I have strings that I have to insert in a db but I want to first modify their value if they fall under certain conditions.
For example I have the strings Epatite, Epatite B, EpatiteáB, EpB3 that I want them to be changed to EP B before being inserted into the db.
This is piece of my code:
// vaccines[index] is the string to compare
var vac = makeUniform(vaccines[index]);
const queryInsert = {
    text: 'INSERT INTO coverages (vaccine) VALUES ($1) ON CONFLICT DO NOTHING;',
    values: [vac]
}
var printText = '[INSERT Italy IN coverages]';
promises.push(postgreSQLlib.query(queryInsert, printText, false));
function makeUniform(val) {
    if(val === 'DIF' || val === 'Difterite') {
        return 'DIPH'; // diphtheria
    }
    else if(val === 'Epatite' || val === 'Epatite B' || val === 'EpatiteáB' || val === 'EpB3') {
        return 'EP B'; // hepatitis B
    }
    else if(val === 'HIB' || val === 'Hib3' || val === 'Hib') {
        return 'HIB'; // haemophilus influenzae B
    }
    else {
        return val;
    }
}
Whene I execute SELECT DISTINCT vaccine FROM coverages ORDER BY vaccine; on psql shell, I get:
DIPH
DT-DTP3
DTP3
EP A
EP B
EpatiteáB
Hib
HIB
M-MPR1
M-MPR1-MPRV ...
There is EpatiteáB which theoretically should have changed in EP B.
Why it doesn't work?
EDIT 1
vaccines[index] comes from an online pdf of which I did web scraping using the textract package of Node.js.
Thanks
 
    