From 09e2b43908df1c62aa9642f59908ddcd6f56e576 Mon Sep 17 00:00:00 2001 From: denyskaduk Date: Fri, 13 Aug 2021 10:19:49 +0300 Subject: [PATCH 1/2] Update load_stage.sql --- BDPM/load_stage.sql | 4089 ++++++++++++++++++++++++------------------- 1 file changed, 2248 insertions(+), 1841 deletions(-) diff --git a/BDPM/load_stage.sql b/BDPM/load_stage.sql index 8025c4126..edaebf09d 100644 --- a/BDPM/load_stage.sql +++ b/BDPM/load_stage.sql @@ -1,4 +1,3 @@ ---change the dates according to the release date DO $_$ BEGIN PERFORM VOCABULARY_PACK.SetLatestUpdate( @@ -23,6 +22,34 @@ TRUNCATE TABLE relationship_to_concept; TRUNCATE TABLE pc_stage; TRUNCATE TABLE concept_synonym_stage; +--do vaccines and insulins manually +DROP TABLE if exists bdpm_vaccine_manual; + +CREATE TABLE bdpm_vaccine_manual +AS +SELECT a.din_7, + a.drug_code, + form_code, + ingredient, + dosage, + volume, + drug_descr, + packaging, + manufacturer, + NULL::INTEGER AS c_id, + NULL::VARCHAR AS c_code, + NULL::VARCHAR AS c_name +from sources.bdpm_packaging a +join sources.bdpm_drug b using(drug_code) +join sources.bdpm_ingredient c using(drug_code) +WHERE ingredient ~* 'POLYOSIDE|HAEMOPHILUS|VARICELLE|influenzae|virus|insulin|ANATOXINE|PAPILLOMAVIRUS|RABIQUE|BORDETELLA|PERTUSS|STREPTOCOCCUS PNEUMONIAE|ROTAVIRUS|POLIOMYELITIQUE' +OR drug_descr ~* 'vacin|vaccin|infanrix|influvac|boostrix|menveo|HBVAXPRO' +or form_code in ('96983','85085','97363','76197','82142','99920') +; + + + +--fill non_drug table with devices DROP TABLE IF EXISTS non_drug; CREATE TABLE non_drug AS SELECT b.drug_code, @@ -32,7 +59,7 @@ SELECT b.drug_code, form_code FROM sources.bdpm_ingredient a JOIN sources.bdpm_drug b ON a.drug_code = b.drug_code -WHERE form_code IN ( +WHERE (form_code IN ( '4307', '9354', '77898', @@ -47,31 +74,33 @@ WHERE form_code IN ( '31035', '66548', '16621', - '31035' + '31035', + '75145' ) OR dosage LIKE '%Bq%' - OR form LIKE '%dialyse%'; - ---insert radiopharmaceutical drugs -INSERT INTO non_drug ( - drug_code, - drug_descr, - ingredient, - form, - form_code - ) + OR form LIKE '%dialyse%') +; + +--add radiopharmaceutical drugs +INSERT INTO non_drug +( + drug_code, + drug_descr, + ingredient, + form, + form_code +) SELECT a.drug_code, - drug_descr, - ingredient, - form, - form_code + drug_descr, + ingredient, + form, + form_code FROM sources.bdpm_drug a -JOIN sources.bdpm_ingredient b ON a.drug_code = b.drug_code + JOIN sources.bdpm_ingredient b ON a.drug_code = b.drug_code WHERE form LIKE '%radio%' - AND a.drug_code NOT IN ( - SELECT drug_code - FROM non_drug - ); +AND a.drug_code::INTEGER NOT IN (66364008) +AND a.drug_code NOT IN (SELECT drug_code FROM non_drug); + --ingredients used in diagnostics INSERT INTO non_drug ( @@ -88,15 +117,18 @@ SELECT a.drug_code, form_code FROM sources.bdpm_drug a JOIN sources.bdpm_ingredient b ON a.drug_code = b.drug_code -WHERE ingredient LIKE '%IOXITALAM%' - OR ingredient LIKE '%GADOTÉR%' - OR ingredient LIKE '%AMIDOTRIZOATE%' - OR form_code='86327' +WHERE (ingredient ILIKE '%IOXITALAM%' + OR ingredient ILIKE '%GADOTÉR%' + OR ingredient ILIKE '%AMIDOTRIZOATE%' + OR ingredient ILIKE '%CARBOM%' + or (ingredient ILIKE '%123%' --and ingredient ILIKE '%IOD%' + ) + OR form_code='86327') AND a.drug_code NOT IN ( SELECT drug_code FROM non_drug ); - + --patterns for dosages INSERT INTO non_drug ( drug_code, @@ -126,6 +158,51 @@ WHERE a.drug_code IN ( FROM non_drug ); + +--nutrients +INSERT INTO non_drug ( + drug_code, + drug_descr, + ingredient, + form, + form_code + ) +SELECT a.drug_code, + drug_descr, + ingredient, + form, + form_code +FROM sources.bdpm_drug a +JOIN sources.bdpm_ingredient b ON a.drug_code = b.drug_code + where a.drug_code NOT IN ( + SELECT drug_code + FROM non_drug + ) +and form ~* ' entéral|tisane|émulsion pour perfusion' +; + + +--some patterns +INSERT INTO non_drug ( + drug_code, + drug_descr, + ingredient, + form, + form_code + ) +SELECT a.drug_code, + drug_descr, + ingredient, + form, + form_code +FROM sources.bdpm_drug a +JOIN sources.bdpm_ingredient b ON a.drug_code = b.drug_code + where a.drug_code NOT IN ( + SELECT drug_code + FROM non_drug + ) +and ingredient ~* 'ÉTHANOL|TYROSINE|PARAFFINE|COLLOÏDAL|GLUTAMINE|LYSINE|GLYCINE|CHLORE ACTIF|ALCOOL|ALANINE'; + --some patterns INSERT INTO non_drug ( drug_code, @@ -141,24 +218,56 @@ SELECT a.drug_code, form_code FROM sources.bdpm_drug a LEFT JOIN sources.bdpm_ingredient b ON a.drug_code = b.drug_code -WHERE drug_descr ~* 'hémofiltration|AMINOMIX|dialys|test|radiopharmaceutique|MIBG|STRUCTOKABIVEN|NUMETAN|NUMETAH|REANUTRIFLEX|CLINIMIX|REVITALOSE|CONTROLE|IOMERON|HEXABRIX|XENETIX' + where a.drug_code NOT IN ( + SELECT drug_code + FROM non_drug + ) +and drug_descr ~* 'ULTRAVIST|IOPAMIRON|OMNISCAN|VISIPAQUE|PROTOXYDE D''AZOTE|OMNIPAQUE|ISOVOL|BIONOLYTE|OXYGENE MEDICINAL|PRIMENE|MEDNUTRIFLEX|AMINOPLASMAL' +; +--some patterns +INSERT INTO non_drug ( + drug_code, + drug_descr, + ingredient, + form, + form_code + ) +SELECT a.drug_code, + drug_descr, + ingredient, + form, + form_code +FROM sources.bdpm_drug a +JOIN sources.bdpm_ingredient b ON a.drug_code = b.drug_code +WHERE drug_descr ~* 'CELSIOR|PLASMALYTE|POLYIONIQUE|PLASMION|ISOPEDIA|ISOFUNDINE|hémofiltration|AMINOMIX|dialys|test|radiopharmaceutique|STRUCTOKABIVEN|NUMETAN|NUMETAH|REANUTRIFLEX|CLINIMIX|REVITALOSE|CONTROLE|IOMERON|HEXABRIX|XENETIX' AND a.drug_code NOT IN ( SELECT drug_code FROM non_drug - ); ---exclude Xofigo -DELETE FROM non_drug - WHERE ingredient LIKE '%RADIUM%223%'; - ---create table with homeopathic drugs as they will be proceeded in different way + ) + --exclude radiopharmacuetical approved drug and testosterone +and a.drug_code::integer not in (66364008,68804011,69909645,69690774,61637467) +; + + + +--create table with homeopathic drugs, they won't be processed DROP TABLE IF EXISTS homeop_drug; -CREATE TABLE homeop_drug AS + +CREATE TABLE homeop_drug +AS SELECT a.* FROM sources.bdpm_ingredient a -JOIN sources.bdpm_drug b ON a.drug_code = b.drug_code -WHERE ingredient LIKE '%HOMÉOPA%' - OR drug_descr LIKE '%degré de dilution compris entre%'; + JOIN sources.bdpm_drug b ON a.drug_code = b.drug_code +WHERE (ingredient LIKE '%HOMÉOPA%' OR drug_descr LIKE '%degré de dilution compris entre%' OR certifier LIKE '%Enreg homéo%') +AND a.drug_code NOT IN (SELECT drug_code + FROM non_drug + UNION + SELECT drug_code + FROM bdpm_vaccine_manual); + + +--collect package information and start extract quantity of drugs DROP TABLE IF EXISTS packaging_pars_1; CREATE TABLE packaging_pars_1 AS SELECT din_7, @@ -173,29 +282,38 @@ SELECT din_7, WHEN NOT packaging ~ '^\d+\s*(mg|g|ml|litre|l)(\s|$|\,)' AND substring(packaging, '^\d+')!='0' THEN substring(packaging, '^\d+') + When packaging ~ 'boîte\sde\s\d+|de\s\d*flacon' then substring(packaging, 'boîte\sde\s(\d+)|e\s(\d*)flacon') ELSE NULL END::INT AS box_size -FROM sources.bdpm_packaging; - +FROM sources.bdpm_packaging + where drug_code NOT IN ( + SELECT drug_code + FROM non_drug + ) + and drug_code NOT IN ( + SELECT drug_code + FROM bdpm_vaccine_manual + ) + and drug_code NOT IN ( + SELECT drug_code + FROM homeop_drug + ) +; + --remove spaces in amount UPDATE packaging_pars_1 SET amount = regexp_replace(amount, '([[:digit:]]+) ([[:digit:]]+)', '\1\2') +--select * from packaging_pars_1 WHERE amount ~ '[[:digit:]]+ [[:digit:]]+'; ----!!need to check inhalers ---select * from packaging_pars_1 WHERE amount LIKE '%dose(s)%'; ---ignore "dose" -UPDATE packaging_pars_1 -SET amount = NULL -WHERE amount LIKE '%dose(s)%'; ---!!!! do not catch comprime etc --- define box size and amount (Quant factor mostly) +-- define box size and quantity factor of drugs DROP TABLE IF EXISTS packaging_pars_2; CREATE TABLE packaging_pars_2 AS SELECT CASE - WHEN NOT p.amount ~* '[[:digit:].,]+\s*(ml|g|mg|l|UI|MBq/ml|GBq/ml|litre(s*)|à|mlavec|kg)(\s|$|\,)' + WHEN NOT p.amount ~* '[[:digit:].,]+\s*(ml|g|mg|l|UI|MBq/ml|GBq/ml|litre(s*)|à|mlavec|kg)(\s|$|\,)' + and p.amount !~* 'dose' AND (replace(substring(p.amount, '[[:digit:].,]+'), ',', '.')) IS NOT NULL THEN substring(p.amount, '\d+')::INT * coalesce(box_size, 1) ELSE box_size @@ -210,6 +328,23 @@ LEFT JOIN LATERAL( AS amount) l ON true ; +-- find proper amount for inhalation drugs +drop table if exists pack_inh; +create table pack_inh as +select box_size, case when amount in ('1 dose','1 dose') then null else amount end as amount ,din_7,drug_code,packaging +from ( +select box_size, substring(packaging, '(\d+\s*dose)') as amount,din_7,drug_code,packaging +from packaging_pars_2 +where packaging ~* 'dose' and amount is null) a ; + +delete from packaging_pars_2 where (din_7,drug_code) in ( +select din_7,drug_code +from pack_inh); + +insert into packaging_pars_2 +select * from pack_inh; + + --pars amount to value and unit DROP TABLE IF EXISTS packaging_pars_3; CREATE TABLE packaging_pars_3 AS @@ -220,14 +355,10 @@ SELECT replace(substring(amount, '[[:digit:].,]+'), ',', '.')::FLOAT AS amount_v drug_code, packaging FROM packaging_pars_2 -LEFT JOIN LATERAL(SELECT unnest(regexp_matches(amount, '(ml|g|mg|l|UI|MBq/ml|GBq/ml|litre(?:s*)|kg)', 'i')) AS amount_unit) l ON true; +LEFT JOIN LATERAL(SELECT unnest(regexp_matches(amount, '(ml|g|mg|l|UI|MBq/ml|GBq/ml|litre(?:s*)|kg|dose)', 'i')) AS amount_unit) l ON true; --manual fix -UPDATE packaging_pars_3 -SET amount_value = 5.5, - amount_unit = 'ml' -WHERE din_7 = 3328273 - AND packaging = 'poudre en flacon(s) en verre + 5,5 ml de solvant en flacon(s) en verre'; + UPDATE packaging_pars_3 SET amount_value = '1', @@ -247,17 +378,6 @@ SET amount_value = '5', WHERE din_7 = 5500092 AND packaging = 'système à double seringues (polypropylène) 1 * 10 ml (5 ml + 5 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application'; -UPDATE packaging_pars_3 -SET amount_value = '20', - amount_unit = 'ml' -WHERE din_7 = 5645150 - AND packaging = 'Poudre en flacon(s) en verre + 20 ml de solvant flacon(s) en verre avec aiguille(s), une seringue à usage unique (polypropylène) et un nécessaire d''injection + un dispositif de transfert BAXJECT II HI-Flow'; - -UPDATE packaging_pars_3 -SET amount_value = '5.5', - amount_unit = 'ml' -WHERE din_7 = 3328310 - AND packaging = 'poudre en flacon(s) en verre + 5,5 ml de solvant en flacon(s) en verre'; UPDATE packaging_pars_3 SET amount_value = '20', @@ -282,9 +402,8 @@ SET amount_value = '3', amount_unit = 'ml' WHERE din_7 = 5611116 AND packaging = '2 poudres en flacons en verre et 2 fois 3 ml de solution en flacons en verre avec nécessaire d''application'; + ---mistakes in the orinal table fixing --- <> --find relationships between ingredients within the one drug DROP TABLE IF EXISTS drug_ingred_to_ingred; @@ -295,27 +414,51 @@ SELECT DISTINCT a.drug_code, b.form_code AS concept_code_2, b.ingredient AS concept_name_2 FROM sources.bdpm_ingredient a +join sources.bdpm_packaging using(drug_code) JOIN sources.bdpm_ingredient b ON a.drug_code = b.drug_code AND a.comp_number = b.comp_number AND a.ingredient != b.ingredient AND a.ingr_nature = 'SA' - AND b.ingr_nature = 'FT'; + AND b.ingr_nature = 'FT' +where a.drug_code NOT IN ( + SELECT drug_code + FROM homeop_drug + ) + AND a.drug_code NOT IN ( + SELECT drug_code + FROM non_drug + ) + AND a.drug_code NOT IN ( + SELECT drug_code + FROM bdpm_vaccine_manual) + + +; --exclude homeopic_drugs and precise ingredients DROP TABLE IF EXISTS ingredient_step_1; CREATE TABLE ingredient_step_1 AS -SELECT * +SELECT a.* FROM sources.bdpm_ingredient a +join sources.bdpm_packaging using(drug_code) WHERE NOT EXISTS ( SELECT 1 FROM drug_ingred_to_ingred b - WHERE a.drug_code = b.drug_code - AND form_code = concept_code_1 + WHERE a.drug_code = b.drug_code::varchar + AND form_code = concept_code_1::varchar ) AND drug_code NOT IN ( SELECT drug_code FROM homeop_drug - ); + ) + AND drug_code NOT IN ( + SELECT drug_code + FROM non_drug + ) + AND drug_code NOT IN ( + SELECT drug_code + FROM bdpm_vaccine_manual) +; --manual fix of dosages UPDATE ingredient_step_1 @@ -347,22 +490,10 @@ UPDATE ingredient_step_1 SET dosage = '31250000000 U' WHERE dosage like '31,25 * 10^9%'; -UPDATE ingredient_step_1 -SET dosage = '1000 DICC50' -WHERE dosage = 'au minimum 10^^3,0 DICC50'; - UPDATE ingredient_step_1 SET dosage = '800000 UFC' WHERE dosage = '2-8 x 10^5 UFC'; -UPDATE ingredient_step_1 -SET dosage = '2000 DICC50' -WHERE dosage = 'au minimum 10^^3,3 DICC50'; - -UPDATE ingredient_step_1 -SET dosage = '5000 DICC50' -WHERE dosage = 'au minimum 10^^3,7 DICC50'; - UPDATE ingredient_step_1 SET dosage = '10000000 U' WHERE dosage = '10^(7+/- 0,5)'; @@ -406,323 +537,570 @@ FROM ( substring(volume, '[[:digit:].,]+\s*(cm *²|g|ml|cm\^2)') AS volume_unit FROM ingredient_step_1 a ) AS s; + + +-- find form of salts +DROP TABLE if exists upd_calc; + +CREATE TABLE upd_calc +AS +SELECT distinct a.drug_code, + a.drug_form, + FIRST_VALUE(b.form_code) OVER (PARTITION BY a.drug_code ORDER BY b.form_code) AS form_code, + FIRST_VALUE(b.ingredient) OVER (PARTITION BY a.drug_code ORDER BY b.form_code) AS ingredient, + a.dosage, + a.volume, + a.ingr_nature, + a.comp_number, + a.dosage_value, + a.dosage_unit, + a.volume_value, + a.volume_unit, + a.form_Code AS old_code, + a.ingredient +FROM ingredient_step_2 a + JOIN sources.bdpm_ingredient b USING (drug_code) +WHERE a.ingredient in ('CALCIUM ÉLÉMENT','POTASSIUM') +and (b.ingredient like '%CALCIUM%' or b.ingredient like '%POTASSIUM%') +and a.form_code != b.form_code; + + +DELETE +FROM ingredient_step_2 +WHERE (drug_code,form_code) IN (SELECT drug_code, old_code FROM upd_calc); + + +INSERT INTO ingredient_step_2 +( + drug_code, + drug_form, + form_code, + ingredient, + dosage, + volume, + ingr_nature, + comp_number, + dosage_value, + dosage_unit, + volume_value, + volume_unit +) +SELECT drug_code, + drug_form, + form_code, + ingredient, + dosage, + volume, + ingr_nature, + comp_number, + dosage_value, + dosage_unit, + volume_value, + volume_unit +FROM upd_calc; + + --recalculate all the possible combinations between packaging info and ingredient info -DROP TABLE IF EXISTS ds_1; -CREATE TABLE ds_1 AS -SELECT DISTINCT din_7::varchar AS concept_code, - a.drug_code, - drug_form, - form_code AS ingredient_code, - ingredient AS ingredient_name, - packaging, - d.drug_descr, - dosage_value, - dosage_unit, - volume_value, - volume_unit, - amount_value AS pack_amount_value, - amount_unit AS pack_amount_unit, - CASE - WHEN volume_value IS NULL - AND amount_value IS NULL - AND dosage_unit != '%' - THEN dosage_value - ELSE NULL - END AS amount_value, - CASE - WHEN volume_value IS NULL - AND amount_value IS NULL - AND dosage_unit != '%' - THEN dosage_unit - ELSE NULL - END AS amount_unit, - CASE - WHEN volume_value IS NOT NULL - AND amount_value IS NOT NULL - AND dosage_unit != '%' - AND ( - lower(coalesce(volume_unit, amount_unit)) = lower(coalesce(amount_unit, volume_unit)) - OR volume_unit = 'g' - AND amount_unit = 'ml' - ) - THEN dosage_value / volume_value * amount_value - WHEN volume_value IS NOT NULL - AND amount_value IS NULL - AND dosage_unit != '%' - AND lower(coalesce(volume_unit, amount_unit)) = lower(coalesce(amount_unit, volume_unit)) - THEN dosage_value - WHEN volume_value IS NULL - AND amount_value IS NOT NULL - AND dosage_unit != '%' - AND lower(coalesce(volume_unit, amount_unit)) = lower(coalesce(amount_unit, volume_unit)) - THEN dosage_value - WHEN ( - volume_value IS NOT NULL - OR amount_value IS NOT NULL - ) - AND dosage_unit != '%' - AND lower(volume_unit) = CONCAT ( - 'm', - lower(amount_unit) - ) - THEN dosage_value / coalesce(volume_value, 1) * coalesce(amount_value, 1) * 1000 - WHEN ( - volume_value IS NOT NULL - OR amount_value IS NOT NULL - ) - AND dosage_unit != '%' - AND lower(amount_unit) = CONCAT ( - 'k', - lower(volume_unit) - ) - THEN dosage_value / coalesce(volume_value, 1) * coalesce(amount_value, 1) * 1000 - /*volume (7g) / (sum (125 mg) * dosage - this is numerator -1 ml * volume (7g) / (sum (dosage) group by within one drug) - this is denumerator -*/ - --not so simple - WHEN lower(volume_unit) = 'ml' - AND ( - lower(amount_unit) LIKE '%g%' - OR amount_unit = 'UI' - ) - THEN amount_value / dos_sum * dosage_value - WHEN dosage_unit = '%' - THEN dosage_value - ELSE NULL - END AS numerator_value, - CASE - WHEN ( - volume_value IS NOT NULL - OR amount_value IS NOT NULL - ) - THEN dosage_unit - WHEN dosage_unit = '%' - THEN '%' - WHEN lower(volume_unit) = 'ml' - AND ( - lower(amount_unit) LIKE '%g%' - OR amount_unit = 'UI' - ) - THEN amount_unit - ELSE NULL - END AS numerator_unit, - CASE - WHEN lower(volume_unit) = 'ml' - AND ( - lower(amount_unit) LIKE '%g%' - OR amount_unit = 'UI' - ) - THEN volume_value * amount_value / dos_sum - ELSE coalesce(amount_value, volume_value) - END AS denominator_value, - CASE - WHEN lower(volume_unit) = 'ml' - AND ( - lower(amount_unit) LIKE '%g%' - OR amount_unit = 'UI' - ) - THEN volume_unit - ELSE coalesce(amount_unit, volume_unit) - END AS denominator_unit, - box_size +DROP TABLE if exists ds_1_1; + +CREATE TABLE ds_1_1 +AS +select COUNT(ingredient_code) OVER (PARTITION BY concept_code) AS c1,* from +( +SELECT DISTINCT din_7::VARCHAR AS concept_code, + a.drug_code, + drug_form, + form_code AS ingredient_code, + ingredient AS ingredient_name, + packaging, + d.drug_descr, + dosage_value, + dosage_unit, + CASE + WHEN volume_value IS NULL THEN 1 + ELSE volume_value + END AS volume_value, + volume_unit, + CASE + WHEN volume_value IS NULL AND amount_value IS NULL THEN dosage_value + ELSE NULL + END AS amount_value, + CASE + WHEN volume_value IS NULL AND amount_value IS NULL THEN dosage_unit + ELSE NULL + END AS amount_unit, + CASE + WHEN COUNT(ingredient) OVER (PARTITION BY a.din_7) > 1 AND (amount_value IS NOT NULL OR amount_unit NOT IN ('ml','mL','g')) THEN dosage_value::VARCHAR + WHEN COUNT(ingredient) OVER (PARTITION BY a.din_7) > 1 AND amount_value IS NULL then dosage_value::VARCHAR + WHEN drug_descr ~ '%' THEN TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'(\d+?\s?\,?\.?\d*\s?)%'),',','.'),' ','')) + WHEN amount_unit ~ 'dose\(s\)' THEN dosage_value::VARCHAR + WHEN drug_descr ~ '\/\d?\s?\,?\d+\s(mL|ml|l|heures)' AND COUNT(ingredient) OVER (PARTITION BY a.din_7) = 1 THEN TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'(\d+?\s?\,?\.?\d*\s)(mg|g|microgrammes|UI|unités|U)\/\d?\s?\,?\d+\s?(ml|mL|l|dose|g|heures)'),',','.'),' ','')) + ELSE TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'(\d+?\s?\,?\.?\d*\s)(ppm mole|mg|g|microgrammes|UI|unités|U)\/(1)?\s?(ml|mL|dose|mole|l|g)'),',','.'),' ','')) + END AS numerator_value, + CASE + WHEN COUNT(ingredient) OVER (PARTITION BY a.din_7) > 1 AND (amount_value IS NOT NULL OR amount_unit NOT IN ('ml','mL','g')) THEN dosage_unit + WHEN COUNT(ingredient) OVER (PARTITION BY a.din_7) > 1 AND amount_value IS NULL then dosage_unit + WHEN drug_descr ~ '%' THEN TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'\d+?\s?\,?\.?\d*\s?(%)'),',','.'),' ','')) + WHEN amount_unit ~ 'dose\(s\)' THEN dosage_unit + WHEN drug_descr ~ '\/\d?\s?\,?\d+\s(mL|ml|l|heures)' AND COUNT(ingredient) OVER (PARTITION BY a.din_7) = 1 THEN TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'\d+?\s?\,?\.?\d*\s(mg|g|microgrammes|UI|unités|U)\/\d?\s?\,?\d+\s?(ml|mL||ldose|g|heures)'),',','.'),' ','')) + ELSE SUBSTRING(drug_descr,'\d+?\s?\,?\.?\d*\s(ppm mole|mg|g|microgrammes|UI|unités|U)\/(1)?\s?(ml|mL|dose|mole|l|g)') + END AS numerator_unit, + CASE + WHEN drug_descr ~ '\/\s?\d?\s?\,?\d+?\s(mL|ml|l|heures)' AND COUNT(ingredient) OVER (PARTITION BY a.din_7) = 1 THEN TRIM(/*REGEXP_REPLACE(*/REGEXP_REPLACE(SUBSTRING(drug_descr,'\/\s?(\d?\s?\,?\d+?)\s?(ml|mL|l|dose|g|heures)'),',','.')/*,' ','')*/) + ELSE NULL + END AS denom, + CASE + WHEN drug_descr ~ '\/\s?\d?\s?\,?\d+\s(mL|ml|l|heures)' AND COUNT(ingredient) OVER (PARTITION BY a.din_7) = 1 THEN TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'\/\d?\s?\,?\d+\s?(ml|mL|l|dose|g|heures)'),',','.'),' ','')) +when drug_descr ~ '\d+?\s?\,?\.?\d*\s((ppm mole|mg|g|microgrammes|UI|unités|U))\/(1)?\s?(ml|mL|dose|mole|l|g)' then SUBSTRING(drug_descr, '\/1?\s?(ml|mL|mole|l|dose|g)') +ELSE NULL + END AS denom_unit, + CASE + WHEN amount_unit NOT IN ('ml','mL','g','dose') THEN NULL + ELSE amount_value + END AS fut_denominator_value, + CASE + WHEN amount_unit NOT IN ('ml','mL','g','dose') THEN NULL + ELSE amount_unit + END AS fut_denominator_unit, + box_size FROM packaging_pars_3 a -JOIN ingredient_step_2 b ON a.drug_code = b.drug_code -JOIN sources.bdpm_drug d ON b.drug_code = d.drug_code -JOIN ( - SELECT drug_code, - sum((dosage_value)) AS dos_sum - FROM ingredient_step_2 - GROUP BY drug_code - ) s ON s.drug_code = a.drug_code; - ---update when we have drug description containing dosage (unit!= %) -UPDATE ds_1 -SET amount_value = replace(substring(drug_descr, '([[:digit:].,]+)\s*(UI|IU|µmol|g|mg|mcg|microgramme(s*)|µg|millions UI|MBq|DICC50|UIK|unités FEIBA|Gbq|UFP|U\.CEIP|ml|U|IR|unités Antihéparine|log DICC50|nanogrammes|M(\.|\s)U\.I\.|UD (unité antigène D)|MU|Ul|unités|U\.I\.|ATU|mmol|mEq|DL50|U\.l\.|unités|MUI|U\.|unités antigène D|Millions UI|ppm mole|UI|kBq|SQ-T|milliard|microlitres|nanokatals|UD \(unité antigène D\)|unité antigène D|M UI|DICT50|micrcrogrammes|GBq|mg.|M.UI|MBq/ml|UD|UIK.|Mq|millions d.UI|U.I|U.D.|ng)(\s|$|\,)'), ',', '.')::FLOAT, - amount_unit = substring(drug_descr, '[[:digit:].,]+\s*(UI|IU|µmol|g|mg|mcg|microgramme(s*)|µg|millions UI|MBq|DICC50|UIK|unités FEIBA|Gbq|UFP|U\.CEIP|ml|U|IR|unités Antihéparine|log DICC50|nanogrammes|M(\.|\s)U\.I\.|UD (unité antigène D)|MU|Ul|unités|U\.I\.|ATU|mmol|mEq|DL50|U\.l\.|unités|MUI|U\.|unités antigène D|Millions UI|ppm mole|UI|kBq|SQ-T|milliard|microlitres|nanokatals|UD \(unité antigène D\)|unité antigène D|M UI|DICT50|micrcrogrammes|GBq|mg.|M.UI|MBq/ml|UD|UIK.|Mq|millions d.UI|U.I|U.D.|ng)(\s|$|\,)') -WHERE drug_descr ~ '[[:digit:].,]+\s*(UI|IU|µmol|g|mg|mcg|microgramme(s*)|µg|millions UI|MBq|DICC50|UIK|unités FEIBA|Gbq|UFP|U\.CEIP|ml|U|IR|unités Antihéparine|log DICC50|nanogrammes|M(\.|\s)U\.I\.|UD (unité antigène D)|MU|Ul|unités|U\.I\.|ATU|mmol|mEq|DL50|U\.l\.|unités|MUI|U\.|unités antigène D|Millions UI|ppm mole|UI|kBq|SQ-T|milliard|microlitres|nanokatals|UD \(unité antigène D\)|unité antigène D|M UI|DICT50|micrcrogrammes|GBq|mg.|M.UI|MBq/ml|UD|UIK.|Mq|millions d.UI|U.I|U.D.|ng)(\s|$|\,)' - AND amount_value IS NULL - AND numerator_value IS NULL; + JOIN ingredient_step_2 b ON a.drug_code = b.drug_code + JOIN sources.bdpm_drug d + ON b.drug_code = d.drug_code + AND a.drug_code NOT IN (SELECT drug_code FROM non_drug + union SELECT drug_code FROM bdpm_vaccine_manual + union + select drug_code + from homeop_drug) + )d +; ---update when we have drug description containing dosage (unit = %) -UPDATE ds_1 -SET numerator_value = replace(substring(drug_descr, '([[:digit:].,]+)\s*%'), ',', '.')::FLOAT, - numerator_unit = substring(drug_descr, '[[:digit:].,]+\s*(%)(\s|$|\,)') -WHERE drug_descr ~ '[[:digit:].,]+\s*%' - AND amount_value IS NULL - AND numerator_value IS NULL; - ---UPDATE unitS WITH translation OF unitS ---HERE SHOULD BE KIND OF MANUAL TABLES DESCRIPTION, BECAUSE unit_translation WE GOT FROM ds_1 BEFORE THIS UPDATE -DROP TABLE IF EXISTS unit_translation; -CREATE TABLE unit_translation ( - unit VARCHAR(100), - translation VARCHAR(100) - ); - -INSERT INTO unit_translation -VALUES - ('%','%'), - ('ATU', 'ATU'), - ('DICC50', 'CCID_50'), - ('DICT50', 'tcid_50'), - ('DL50', 'DL50'), - ('G', 'g'), - ('IR', 'IR'), - ('IU', 'IU'), - ('M U.I.', 'Million IU'), - ('M UI', 'Million IU'), - ('M.U.I.', 'Million IU'), - ('M.UI', 'Million IU'), - ('MU', 'Million U'), - ('Millions UI', 'Million IU'), - ('Mq', 'Mq'), - ('SQ-T', 'SQ-T'), - ('U', 'U'), - ('U.CEIP', 'U.CEIP'), - ('UFP', 'UFP'), - ('UI', 'IU'), - ('unités FEIBA', 'unit FEIBA'), - ('cm ²', 'cm²'), - ('cm^2', 'cm²'), - ('cm²', 'cm²'), - ('kg', 'kg'), - ('l', 'l'), - ('log DICC50', 'log CCID_50'), - ('mEq', 'mEq'), - ('mL', 'ml'), - ('mg', 'mg'), - ('micrcrogrammes', 'mcg'), - ('microgramme', 'mcg'), - ('microgrammes', 'mcg'), - ('microlitres', 'microliter'), - ('micromoles', 'microliter'), - ('milliard', 'U'), - ('millions UI', 'Million IU'), - ('millions d''UI', 'Million IU'), - ('mmol', 'mmol'), - ('nanogrammes', 'ng'), - ('nanokatals', 'nanokatal'), - ('ng', 'ng'), - ('ppm mole', 'ppm mole'), - ('unités', 'U'), - ('µg', 'mcg'), - ('µmol', 'mcmol') - ('UIK', 'U'), - ('UIK.', 'U'), - ('U.D', 'U'), - ('Unités', 'U'), - ('Unité', 'U'), - ('UD (Unité antigène D)', 'U'), - ('Unités antigène D', 'U'), - ('Unités Antihéparine', 'U'), - ('Ul', 'U'), - ('U.I', 'U'), - ('U.D.', 'U'), - ('Unité antigène D', 'U'), ; +DROP TABLE IF EXISTS ds_1; + +CREATE TABLE ds_1 +AS +SELECT concept_code, + c1, + drug_code, + drug_form, + ingredient_code, + ingredient_name, + packaging, + NULL AS pack_amount_value, + NULL AS pack_amount_unit, + drug_descr, + dosage_value, + dosage_unit, + volume_value, + volume_unit, + CASE + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NULL AND amount_value IS NULL AND denom IS NULL THEN dosage_value + ELSE amount_value + END AS amount_value, + CASE + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NULL AND amount_value IS NULL AND denom IS NULL THEN dosage_unit + ELSE amount_unit + END AS amount_unit, + CASE + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NULL AND amount_value IS NULL AND numerator IS NOT NULL AND denom IS NOT NULL THEN TRIM(numerator)::FLOAT + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND drug_descr ~* 'MOMETASONE' THEN dosage_value*TRIM(SUBSTRING(packaging,'(\d+)\sdose'))::FLOAT + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND drug_descr ~* 'PROSTINE E2' THEN dosage_value + ELSE numerator_value + END AS numerator_value, + CASE + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NULL AND amount_value IS NULL AND numerator IS NOT NULL AND denom IS NOT NULL THEN numerator_u + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND drug_descr ~* 'MOMETASONE' THEN dosage_unit + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND drug_descr ~* 'PROSTINE E2' THEN dosage_unit + ELSE numerator_unit + END AS numerator_unit, + CASE + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NULL AND amount_value IS NULL AND numerator IS NOT NULL AND denom IS NOT NULL THEN TRIM(denom)::FLOAT + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND drug_descr ~* 'MOMETASONE' THEN TRIM(SUBSTRING(packaging,'(\d+)\sdose'))::FLOAT + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND drug_descr ~* 'PROSTINE E2' THEN fut_denominator_value + ELSE denominator_value + END AS denominator_value, + CASE + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NULL AND amount_value IS NULL AND numerator IS NOT NULL AND denom IS NOT NULL THEN denom_unit + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND drug_descr ~* 'MOMETASONE' THEN 'dose' + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND drug_descr ~* 'PROSTINE E2' THEN fut_denominator_unit + ELSE denominator_unit + END AS denominator_unit, + box_size +FROM (SELECT concept_code, + c1, + drug_code, + drug_form, + ingredient_code, + ingredient_name, + packaging, + NULL AS pack_amount_value, + NULL AS pack_amount_unit, + drug_descr, + dosage_value, + dosage_unit, + volume_value, + volume_unit, + numerator_value AS numerator, + numerator_unit AS numerator_u, + amount_value AS amount, + denom, + denom_unit, + fut_denominator_value, + fut_denominator_unit, + CASE + WHEN drug_form ~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat' THEN dosage_value + WHEN drug_form ~* 'emplâtre' AND volume_unit IS NULL AND drug_descr !~* '%' THEN dosage_value + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit ~* 'g' THEN dosage_value + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NULL AND denom IS NULL AND volume_unit IS NULL THEN dosage_value + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NULL AND fut_denominator_value IS NULL AND denom IS NULL AND volume_unit IS NULL THEN dosage_value + WHEN dosage_unit != 'g' AND volume_unit IS NULL AND fut_denominator_unit NOT IN ('ml','mL') AND numerator_value IS NULL THEN dosage_value + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit IS NOT NULL AND volume_unit = 'g' AND fut_denominator_unit IS NULL AND volume_value NOT IN (100,10,1) THEN dosage_value + END AS amount_value, + CASE + WHEN drug_form ~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat' THEN dosage_unit + WHEN drug_form ~* 'emplâtre' AND volume_unit IS NULL AND drug_descr !~* '%' THEN dosage_unit + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit ~* 'g' THEN dosage_unit + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NULL AND denom IS NULL AND volume_unit IS NULL THEN dosage_unit + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NULL AND fut_denominator_value IS NULL AND denom IS NULL AND volume_unit IS NULL THEN dosage_unit + WHEN dosage_unit != 'g' AND volume_unit IS NULL AND fut_denominator_unit NOT IN ('ml','mL') AND numerator_value IS NULL THEN dosage_unit + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit IS NOT NULL AND volume_unit = 'g' AND fut_denominator_unit IS NULL AND volume_value NOT IN (100,10,1) THEN dosage_unit + END AS amount_unit, + CASE + WHEN drug_form ~* 'emplâtre' AND volume_unit = 'g' AND drug_descr !~* '%' THEN (dosage_value / volume_value) / 1000 + WHEN drug_form ~* 'emplâtre' AND drug_descr ~* '%' THEN ((TRIM(SUBSTRING(drug_descr,'(\d+)\s?\%'))::FLOAT)*10) / 1000 + WHEN dosage_unit = 'g' AND volume_unit = 'ml' AND fut_denominator_unit IN ('ml','mL') THEN ((dosage_value*1000) / volume_value)*fut_denominator_value + WHEN dosage_unit = 'g' AND volume_unit = 'g' AND fut_denominator_unit IN ('ml','mL') THEN ((dosage_value / volume_value)*1000)*fut_denominator_value + WHEN dosage_unit != 'g' AND volume_unit = 'ml' AND fut_denominator_unit IN ('ml','mL') THEN (dosage_value / volume_value)*fut_denominator_value + WHEN dosage_unit != 'g' AND volume_unit != 'ml' AND fut_denominator_unit NOT IN ('ml','mL') THEN (dosage_value / volume_value)*fut_denominator_value + WHEN dosage_unit = 'g' AND volume_unit = 'g' AND fut_denominator_unit = 'g' THEN (dosage_value / volume_value)*fut_denominator_value + WHEN dosage_unit != 'g' AND volume_unit = 'ml' AND fut_denominator_unit NOT IN ('ml','mL') THEN dosage_value + WHEN dosage_unit != 'g' AND volume_unit = 'g' AND fut_denominator_unit IN ('ml','mL') THEN dosage_value /(volume_value*1000) + WHEN dosage_unit != 'g' AND volume_unit IS NULL AND fut_denominator_unit IN ('ml','mL') AND numerator_value IS NULL THEN dosage_value + WHEN dosage_unit IS NOT NULL AND volume_unit = 'ml' AND fut_denominator_unit IS NULL THEN dosage_value + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit IS NOT NULL AND volume_unit = 'g' AND fut_denominator_unit IS NULL AND volume_value IN (100,10,1) THEN dosage_value / volume_value + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit != 'g' AND volume_unit IS NOT NULL AND fut_denominator_unit IS NULL AND numerator_value IS NULL THEN dosage_value + WHEN drug_descr ~* '%' AND volume_unit IS NULL THEN (TRIM(REGEXP_REPLACE(SUBSTRING(drug_descr,'(\d*\,?\d+?)\s?\%'),',','.'))::FLOAT)*10*fut_denominator_value + WHEN volume_unit IS NULL AND numerator_value IS NOT NULL AND denom IS NOT NULL THEN (TRIM(numerator_value)::FLOAT/TRIM(denom)::FLOAT)*fut_denominator_value + WHEN numerator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr ~* '\/\s?(ml|ML|mL)' AND fut_denominator_value IS NOT NULL AND fut_denominator_unit != 'g' THEN (TRIM(numerator_value)::FLOAT)*fut_denominator_value + WHEN numerator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr ~* '\/\s?(ml|ML|mL)' AND fut_denominator_value IS NOT NULL AND fut_denominator_unit = 'g' THEN (TRIM(numerator_value)::FLOAT) + WHEN drug_descr ~* 'unidose' AND volume_unit IS NULL AND denom IS NULL AND drug_descr !~* '%' AND fut_denominator_unit !~* 'dose' THEN dosage_value + WHEN drug_descr ~* 'unidose' AND volume_unit IS NULL AND denom IS NULL AND drug_descr !~* '%' AND fut_denominator_unit ~* 'dose' THEN dosage_value*fut_denominator_value + WHEN drug_form ~* 'collyre' AND drug_descr ~* 'TOBRABACT' THEN (TRIM(REGEXP_REPLACE(SUBSTRING(drug_descr,'(\d+\,\d+)\s?\%'),',','.'))::FLOAT)*10*fut_denominator_value + WHEN drug_form ~* 'collyre' AND drug_descr ~* 'LUMIGAN|OPHTASILOXANE' THEN dosage_value + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit !~* 'dose|g' AND drug_descr !~* 'g\/l' THEN TRIM(numerator_value)::FLOAT + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit !~* 'dose|g' AND drug_descr ~* 'g\/l' THEN TRIM(numerator_value)::FLOAT*fut_denominator_value + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit ~* 'dose' THEN TRIM(numerator_value)::FLOAT*fut_denominator_value + END AS numerator_value, + CASE + WHEN drug_form ~* 'emplâtre' AND volume_unit = 'g' AND drug_descr !~* '%' AND dosage_unit = 'g' THEN 'mg' + WHEN drug_form ~* 'emplâtre' AND volume_unit = 'g' AND drug_descr !~* '%' AND dosage_unit != 'g' THEN dosage_unit + WHEN drug_form ~* 'emplâtre' AND drug_descr ~* '%' THEN 'mg' + WHEN dosage_unit = 'g' AND volume_unit = 'ml' AND fut_denominator_unit IN ('ml','mL') THEN 'mg' + WHEN dosage_unit = 'g' AND volume_unit = 'g' AND fut_denominator_unit IN ('ml','mL') THEN 'mg' + WHEN dosage_unit != 'g' AND volume_unit = 'ml' AND fut_denominator_unit IN ('ml','mL') THEN dosage_unit + WHEN dosage_unit != 'g' AND volume_unit != 'ml' AND fut_denominator_unit NOT IN ('ml','mL') THEN dosage_unit + WHEN dosage_unit = 'g' AND volume_unit = 'g' AND fut_denominator_unit = 'g' THEN dosage_unit + WHEN dosage_unit != 'g' AND volume_unit = 'ml' AND fut_denominator_unit NOT IN ('ml','mL') THEN dosage_unit + WHEN dosage_unit != 'g' AND volume_unit = 'g' AND fut_denominator_unit IN ('ml','mL') THEN dosage_unit + WHEN dosage_unit != 'g' AND volume_unit IS NULL AND fut_denominator_unit IN ('ml','mL') AND numerator_value IS NULL THEN dosage_unit + WHEN dosage_unit IS NOT NULL AND volume_unit = 'ml' AND fut_denominator_unit IS NULL THEN dosage_unit + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit IS NOT NULL AND volume_unit = 'g' AND fut_denominator_unit IS NULL AND volume_value IN (100,10,1) THEN dosage_unit + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit != 'g' AND volume_unit IS NOT NULL AND fut_denominator_unit IS NULL AND numerator_value IS NULL THEN dosage_unit + WHEN drug_descr ~* '%' AND volume_unit IS NULL THEN 'mg' + WHEN volume_unit IS NULL AND numerator_value IS NOT NULL AND denom IS NOT NULL THEN dosage_unit + WHEN numerator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr ~* '\/\s?(ml|ML|mL)' AND fut_denominator_value IS NOT NULL AND fut_denominator_unit != 'g' THEN numerator_unit + WHEN numerator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr ~* '\/\s?(ml|ML|mL)' AND fut_denominator_value IS NOT NULL AND fut_denominator_unit = 'g' THEN numerator_unit + WHEN drug_descr ~* 'unidose' AND volume_unit IS NULL AND denom IS NULL AND drug_descr !~* '%' THEN dosage_unit + WHEN drug_form ~* 'collyre' AND drug_descr ~* 'TOBRABACT' THEN 'mg' + WHEN drug_form ~* 'collyre' AND drug_descr ~* 'LUMIGAN|OPHTASILOXANE' THEN dosage_unit + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit !~* 'dose|g' AND drug_descr !~* 'g\/l' THEN numerator_unit + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit !~* 'dose|g' AND drug_descr ~* 'g\/l' THEN 'mg' + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit ~* 'dose' THEN numerator_unit + END AS numerator_unit, + CASE + WHEN drug_form ~* 'emplâtre' AND volume_unit = 'g' AND drug_descr !~* '%' THEN NULL + WHEN drug_form ~* 'emplâtre' AND drug_descr ~* '%' THEN NULL + WHEN dosage_unit != 'g' AND volume_unit = 'ml' AND fut_denominator_unit NOT IN ('ml','mL') THEN volume_value + WHEN dosage_unit != 'g' AND volume_unit = 'g' AND fut_denominator_unit IN ('ml','mL') THEN NULL + WHEN dosage_unit != 'g' AND volume_unit = 'ml' AND fut_denominator_unit IN ('ml','mL') THEN fut_denominator_value + WHEN dosage_unit IS NOT NULL AND volume_unit = 'ml' AND fut_denominator_unit IS NULL THEN volume_value + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit != 'g' AND volume_unit IS NOT NULL AND fut_denominator_unit IS NULL AND numerator_value IS NULL THEN volume_value + WHEN numerator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr ~* '\/\s?(ml|ML|mL)' AND fut_denominator_value IS NOT NULL AND fut_denominator_unit = 'g' THEN NULL + WHEN drug_form ~* 'collyre' AND drug_descr ~* 'LUMIGAN|OPHTASILOXANE' THEN NULL + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit ~* 'g' THEN NULL + WHEN dosage_unit != 'g' AND volume_unit IS NULL AND fut_denominator_unit NOT IN ('ml','mL') AND numerator_value IS NULL THEN NULL + ELSE fut_denominator_value + END AS denominator_value, + CASE + WHEN drug_form ~* 'emplâtre' AND volume_unit = 'g' AND drug_descr !~* '%' THEN 'mg' + WHEN drug_form ~* 'emplâtre' AND drug_descr ~* '%' THEN 'mg' + WHEN dosage_unit != 'g' AND volume_unit = 'ml' AND fut_denominator_unit NOT IN ('ml','mL') THEN volume_unit + WHEN dosage_unit IS NOT NULL AND volume_unit = 'ml' AND fut_denominator_unit IS NULL THEN volume_unit + WHEN dosage_unit != 'g' AND volume_unit = 'g' AND fut_denominator_unit IN ('ml','mL') THEN 'mg' + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit IS NOT NULL AND volume_unit = 'g' AND fut_denominator_unit IS NULL AND volume_value IN (100,10,1) THEN volume_unit + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit != 'g' AND volume_unit IS NOT NULL AND fut_denominator_unit IS NULL AND numerator_value IS NULL THEN volume_unit + WHEN numerator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr ~* '\/\s?(ml|ML|mL)' AND fut_denominator_value IS NOT NULL AND fut_denominator_unit = 'g' THEN denom_unit + WHEN drug_form ~* 'collyre' AND drug_descr ~* 'LUMIGAN|OPHTASILOXANE' THEN volume_unit + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit ~* 'g' THEN NULL + WHEN dosage_unit != 'g' AND volume_unit IS NULL AND fut_denominator_unit NOT IN ('ml','mL') AND numerator_value IS NULL THEN NULL + ELSE fut_denominator_unit + END AS denominator_unit, + CASE + WHEN box_size = 1 THEN NULL + ELSE box_size + END AS box_size + FROM ds_1_1) a; + +-- manual fix +update ds_1 +set numerator_value = numerator_value/denominator_value, +denominator_value = null +where packaging ~* 'avec cuillère-mesure' +and denominator_value = 5 +and denominator_unit in ('ml','mL') +; + +update ds_1 +set numerator_value = 50 +where concept_code = '2750567' +; + +update ds_1 +set numerator_value = 20, +numerator_unit = 'mg' +where concept_code = '3646843'; + +update ds_1 +set numerator_value = 20, +numerator_unit = 'mg' +where concept_code = '3646837'; + + + +update ds_1 +set numerator_value = (dosage_value*10)*denominator_value, +numerator_unit = 'mg' +where concept_code in ('3894707','3894713','3894736','3006088'); + +update ds_1 +set denominator_value = 1 +where denominator_unit ='g' and denominator_value is null + ; + +update ds_1 +set numerator_value = 100 +where concept_code = '3140486' +; -UPDATE ds_1 -SET amount_unit = ( - SELECT translation - FROM unit_translation --manual table - WHERE trim(upper(amount_unit)) = upper(unit) - ) -WHERE EXISTS ( - SELECT 1 - FROM unit_translation - WHERE trim(upper(amount_unit)) = upper(unit) - ); UPDATE ds_1 -SET numerator_unit = ( - SELECT translation - FROM unit_translation - WHERE trim(upper(numerator_unit)) = upper(unit) - ) -WHERE EXISTS ( - SELECT 1 - FROM unit_translation - WHERE trim(upper(numerator_unit)) = upper(unit) - ); + SET amount_value = NULL, + amount_unit = NULL +WHERE amount_value IS NOT NULL +AND numerator_value IS NOT NULL +AND denominator_unit IS NOT NULL; UPDATE ds_1 -SET denominator_unit = ( - SELECT translation - FROM unit_translation - WHERE trim(upper(denominator_unit)) = upper(unit) - ) -WHERE EXISTS ( - SELECT 1 - FROM unit_translation - WHERE trim(upper(denominator_unit)) = upper(unit) - ); + SET numerator_value = NULL, + numerator_unit = NULL +WHERE amount_value IS NOT NULL +AND numerator_value IS NOT NULL +AND denominator_unit IS NULL; + + +-- give clear dosage for oxygen +UPDATE ds_1 a + SET numerator_value = b.amount_value, + numerator_unit = b.amount_unit, + amount_value = NULL, + amount_unit = NULL, + denominator_unit = NULL +FROM ds_1 b +WHERE a.concept_code = b.concept_code +AND a.drug_code = b.drug_code +AND a.drug_form = b.drug_form +AND a.ingredient_code = b.ingredient_code +AND a.ingredient_name = b.ingredient_name +AND a.amount_unit IN ('% ','%','ppm mole'); + + +-- update dosage for multidrugs +DROP TABLE if exists ds_1_2; + +CREATE TABLE ds_1_2 +AS +SELECT DISTINCT concept_code, + drug_code, + ingredient_code, + CASE + WHEN numerator_value IS NOT NULL THEN NULL + ELSE amount_value + END AS amount_value, + CASE + WHEN numerator_value IS NOT NULL THEN NULL + ELSE amount_unit + END AS amount_unit, + numerator_value, + numerator_unit, + denominator_value, + denominator_unit, + box_size +FROM (SELECT concept_code, + drug_code, + ingredient_code, + TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'(\d+?\s?\,?\.?\d*\s)(ppm mole|mg|g|microgrammes|UI|unités|U)'),',','.'),' ','')) AS amount_value, + TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'\d+?\s?\,?\.?\d*\s(ppm mole|mg|g|microgrammes|UI|unités|U)'),',','.'),' ','')) AS amount_unit, + CASE + WHEN drug_descr ~ '\/\d?\s?\,?\d+\s(mL|ml|l|heures)' THEN TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'(\d+?\s?\,?\.?\d*\s)(mg|g|microgrammes|UI|unités|U)\/\d?\s?\,?\d+\s?(ml|mL|l|dose|g|heures)'),',','.'),' ','')) + ELSE TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'(\d+?\s?\,?\.?\d*\s)(ppm mole|mg|g|microgrammes|UI|unités|U)\/(1)?\s?(ml|mL|dose|mole|l|g)'),',','.'),' ','')) + END AS numerator_value, + CASE + WHEN drug_descr ~ '\/\d?\s?\,?\d+\s(mL|ml|l|heures)' THEN TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'\d+?\s?\,?\.?\d*\s(mg|g|microgrammes|UI|unités|U)\/\d?\s?\,?\d+\s?(ml|mL||ldose|g|heures)'),',','.'),' ','')) + ELSE SUBSTRING(drug_descr,'\d+?\s?\,?\.?\d*\s(ppm mole|mg|g|microgrammes|UI|unités|U)\/(1)?\s?(ml|mL|dose|mole|l|g)') + END AS numerator_unit, + TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'\/(\d?\s?\,?\d+)\s?(ml|mL|l|dose|g|heures)'),',','.'),' ','')) AS denominator_value, + CASE + WHEN drug_descr ~ '\/\d?\s?\,?\d+\s(mL|ml|l|heures)' THEN TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'\/\d?\s?\,?\d+\s?(ml|mL|l|dose|g|heures)'),',','.'),' ','')) + ELSE SUBSTRING(drug_descr,'\/1?\s?(ml|mL|mole|l|dose|g)') + END AS denominator_unit, + box_size + FROM (SELECT COUNT(1) OVER (PARTITION BY concept_code,drug_code,ingredient_code,drug_form) AS c2, + * + FROM ds_1) a + WHERE c2 > 1) az; + ---make sure we don't include non-drug into ds_stage DELETE FROM ds_1 -WHERE drug_code IN ( - SELECT drug_code - FROM non_drug - ); ---manual ds_1 fixes +WHERE concept_code IN (SELECT concept_code FROM ds_1_2); + +INSERT INTO ds_1 +( + concept_code, + ingredient_code, + amount_value, + amount_unit, + numerator_value, + numerator_unit, + denominator_value, + denominator_unit, + box_size +) +SELECT concept_code, + ingredient_code, + amount_value::FLOAT, + amount_unit, + numerator_value::FLOAT, + numerator_unit, + denominator_value::FLOAT, + denominator_unit, + box_size +FROM ds_1_2; + +-- update with standard units +UPDATE ds_1 + SET amount_unit = attr_name +FROM rtc_1 +WHERE TRIM(UPPER(amount_unit)) = UPPER(original_name); + UPDATE ds_1 - SET amount_value = 20, - amount_unit = 'mg' -WHERE concept_code = '3646843'; + SET numerator_unit = attr_name +--from unit_translation + FROM rtc_1 +WHERE TRIM(UPPER(numerator_unit)) = UPPER(original_name); + +UPDATE ds_1 + SET denominator_unit = attr_name +--from unit_translation + FROM rtc_1 +WHERE TRIM(UPPER(denominator_unit)) = UPPER(original_name); + + +--manual fixes + UPDATE ds_1 SET numerator_unit = 'mg' WHERE concept_code = '5654597' AND ingredient_code = '01080'; - ---for gazes consider whole volume as amount -UPDATE ds_1 -SET amount_value = denominator_value, - amount_unit = denominator_unit, - numerator_value = NULL, - numerator_unit = NULL, - denominator_value = NULL, - denominator_unit = NULL + +update ds_1 +set amount_value = amount_value*1000, +amount_unit = 'mg' +where amount_unit = 'g'; + +update ds_1 +set numerator_value = numerator_value*1000, +numerator_unit = 'mg' +where numerator_unit = 'g'; + +update ds_1 +set denominator_value = denominator_value*1000, +denominator_unit = 'mg' +where denominator_unit = 'g'; + +update ds_1 +set denominator_value = null, +denominator_unit = null WHERE drug_form = 'gaz' - AND amount_value IS NULL - AND amount_unit IS NULL; +; -DROP TABLE pack_st_1; -CREATE TABLE pack_st_1 AS -SELECT drug_code, - drug_form, - form_code -FROM ingredient_step_1 -WHERE drug_code IN ( - SELECT drug_code - FROM ( - SELECT DISTINCT drug_code, - drug_form - FROM ingredient_step_1 - ) AS s0 - GROUP BY drug_code - HAVING count(1) > 1 - ) - AND drug_code NOT IN ( - SELECT drug_code - FROM non_drug - ) - AND drug_code NOT IN ( - SELECT drug_code - FROM homeop_drug - ) - AND drug_code NOT IN ( - '64122611', - '67657035' - ); ---sequence will be used in pack component definition -DROP SEQUENCE IF EXISTS pack_sequence; -CREATE SEQUENCE pack_sequence MINVALUE 1 MAXVALUE 1000000 START WITH 1 INCREMENT BY 1 CACHE 100; +update ds_1 +set numerator_value = numerator_value*0.0001, +numerator_unit = '%' +where numerator_unit = 'ppm mole'; ---take all the pack components -DROP TABLE IF EXISTS pack_comp_list; -CREATE TABLE pack_comp_list AS +update ds_1 +set numerator_value = amount_value, +numerator_unit = amount_unit, +amount_value = null, +amount_unit = null +where amount_value is not null and denominator_value is not null and drug_descr ~* '\/\d*\,?\d*?\s?ml'; + +update ds_1 +set denominator_value = null, +denominator_unit = null +where amount_value is not null and denominator_value is not null; + +update ds_1 +set numerator_unit = null +where amount_value is not null +and numerator_unit is not null +; + +-- create table for packs +DROP TABLE pack_st_1; + +CREATE TABLE pack_st_1 +AS +SELECT drug_code, + drug_form, + form_code +FROM ingredient_step_2 +WHERE drug_code IN (SELECT drug_code + FROM (SELECT DISTINCT drug_code, drug_form FROM ingredient_step_2) AS s0 + GROUP BY drug_code + HAVING COUNT(1) > 1) +AND drug_code NOT IN (SELECT drug_code FROM non_drug) +AND drug_code NOT IN (SELECT drug_code FROM homeop_drug) +AND drug_code NOT IN ('64122611','67657035') +AND drug_code NOT IN (SELECT drug_code + FROM sources.bdpm_packaging + WHERE din_7 IN (3012520,5754637,5611085,3007865,3007867,3008279,3012518,3048384,3209686)); + + + + + +--sequence will be used in pack component definition +DROP SEQUENCE IF EXISTS pack_sequence; +CREATE SEQUENCE pack_sequence MINVALUE 1 MAXVALUE 1000000 START WITH 1 INCREMENT BY 1 CACHE 100; + +--collect all pack components +DROP TABLE IF EXISTS pack_comp_list; +CREATE TABLE pack_comp_list AS SELECT 'PACK' || nextval('pack_sequence') AS pack_component_code, a.* FROM ( @@ -738,32 +1116,38 @@ FROM ( WHERE a.drug_code NOT IN ( SELECT drug_code FROM non_drug + union + select drug_code + from bdpm_vaccine_manual + union + select drug_code + from homeop_drug ) ) A; + + ---pack content, but need to put amounts manualy +--fill pack content, but need to be changed amounts manually DROP TABLE IF EXISTS pack_cont_1; CREATE TABLE pack_cont_1 AS SELECT DISTINCT concept_code, pack_component_code, - a.drug_descr AS pack_name, - CONCAT ( + a.drug_descr AS pack_name,a.drug_form, + CONCAT ( a.drug_descr, ' ', a.drug_form ) AS pack_component_name, - packaging --, amount_value, amount_drug_code,drug_form,drug_descr,denominator_value,denominator_unit + packaging , pack_amount_value,a.denominator_value,a.denominator_unit FROM pack_comp_list B JOIN ds_1 A ON a.drug_code = b.drug_code AND a.drug_form = b.drug_form AND a.drug_descr = b.drug_descr AND coalesce(a.denominator_value, '0') = coalesce(b.denominator_value, '0') AND coalesce(a.denominator_unit, '0') = coalesce(b.denominator_unit, '0'); + -UPDATE pack_cont_1 -SET pack_component_name = 'INERT INGREDIENT Metered Dose Inhaler' -WHERE concept_code = '5731866' - AND pack_component_name LIKE '%ARIDOL, poudre pour inhalation en gélule gélule transparente%'; +; --ds_stage for Pack_components DROP TABLE IF EXISTS ds_pack_1; @@ -881,413 +1265,97 @@ SELECT pack_component_code, denominator_value, denominator_unit FROM ds_pack_1; - ---sum up the same ingredients manualy -DELETE -FROM ds_stage -WHERE drug_concept_code = '3087355' - AND ingredient_concept_code = '5356' - AND box_size = 20 - AND amount_value IS NULL - AND amount_unit IS NULL - AND numerator_value = 1.4 - AND numerator_unit = 'g' - AND denominator_value = 10 - AND denominator_unit = 'g'; - -DELETE -FROM ds_stage -WHERE drug_concept_code = '3200509' - AND ingredient_concept_code = '1261' - AND box_size = 1 - AND amount_value IS NULL - AND amount_unit IS NULL - AND numerator_value = 5 - AND numerator_unit = 'mg' - AND denominator_value = 1 - AND denominator_unit = 'ml'; - -DELETE -FROM ds_stage -WHERE drug_concept_code = '3205777' - AND ingredient_concept_code = '1261' - AND box_size = 1 - AND amount_value IS NULL - AND amount_unit IS NULL - AND numerator_value = 3 - AND numerator_unit = 'mg' - AND denominator_value = 1 - AND denominator_unit = 'ml'; - -DELETE -FROM ds_stage -WHERE drug_concept_code = '3698389' - AND ingredient_concept_code = '563' - AND box_size = 10 - AND amount_value IS NULL - AND amount_unit IS NULL - AND numerator_value = 0.695 - AND numerator_unit = 'g' - AND denominator_value = 500 - AND denominator_unit = 'ml'; - -DELETE -FROM ds_stage -WHERE drug_concept_code = '3698426' - AND ingredient_concept_code = '563' - AND box_size = 10 - AND amount_value IS NULL - AND amount_unit IS NULL - AND numerator_value = 1.2 - AND numerator_unit = 'g' - AND denominator_value = 500 - AND denominator_unit = 'ml'; - -DELETE -FROM ds_stage -WHERE drug_concept_code = '5536774' - AND ingredient_concept_code = '1261' - AND box_size = 25 - AND amount_value IS NULL - AND amount_unit IS NULL - AND numerator_value = 3 - AND numerator_unit = 'mg' - AND denominator_value = 1 - AND denominator_unit = 'ml'; - -UPDATE ds_stage -SET numerator_value = 2.5 -WHERE drug_concept_code = '3087355' - AND ingredient_concept_code = '5356' - AND box_size = 20 - AND amount_value IS NULL - AND amount_unit IS NULL - AND numerator_value = 1.1 - AND numerator_unit = 'g' - AND denominator_value = 10 - AND denominator_unit = 'g'; - -UPDATE ds_stage -SET numerator_value = 7 -WHERE drug_concept_code = '3200509' - AND ingredient_concept_code = '1261' - AND box_size = 1 - AND amount_value IS NULL - AND amount_unit IS NULL - AND numerator_value = 2 - AND numerator_unit = 'mg' - AND denominator_value = 1 - AND denominator_unit = 'ml'; - -UPDATE ds_stage -SET numerator_value = 5.7 -WHERE drug_concept_code = '3205777' - AND ingredient_concept_code = '1261' - AND box_size = 1 - AND amount_value IS NULL - AND amount_unit IS NULL - AND numerator_value = 2.7 - AND numerator_unit = 'mg' - AND denominator_value = 1 - AND denominator_unit = 'ml'; - -UPDATE ds_stage -SET numerator_value = 1.715 -WHERE drug_concept_code = '3698389' - AND ingredient_concept_code = '563' - AND box_size = 10 - AND amount_value IS NULL - AND amount_unit IS NULL - AND numerator_value = 1.015 - AND numerator_unit = 'g' - AND denominator_value = 500 - AND denominator_unit = 'ml'; - -UPDATE ds_stage -SET numerator_value = 2.795 -WHERE drug_concept_code = '3698426' - AND ingredient_concept_code = '563' - AND box_size = 10 - AND amount_value IS NULL - AND amount_unit IS NULL - AND numerator_value = 1.595 - AND numerator_unit = 'g' - AND denominator_value = 500 - AND denominator_unit = 'ml'; - -UPDATE ds_stage -SET numerator_value = 5.7 -WHERE drug_concept_code = '5536774' - AND ingredient_concept_code = '1261' - AND box_size = 25 - AND amount_value IS NULL - AND amount_unit IS NULL - AND numerator_value = 2.7 - AND numerator_unit = 'mg' - AND denominator_value = 1 - AND denominator_unit = 'ml'; - -DELETE -FROM ds_stage -WHERE drug_concept_code = '3284943' - AND ingredient_concept_code = '29848' - AND box_size = 5 - AND amount_value = 0.23 - AND amount_unit = 'mg'; - -DELETE -FROM ds_stage -WHERE drug_concept_code = '3354164' - AND ingredient_concept_code = '1023' - AND box_size = 24 - AND amount_value = 300 - AND amount_unit = 'mg'; - -DELETE -FROM ds_stage -WHERE drug_concept_code = '3404695' - AND ingredient_concept_code = '2202' - AND box_size = 24 - AND amount_value = 62.5 - AND amount_unit = 'mg'; - -DELETE -FROM ds_stage -WHERE drug_concept_code = '5758486' - AND ingredient_concept_code = '29848' - AND box_size = 30 - AND amount_value = 0.23 - AND amount_unit = 'mg'; - -DELETE -FROM ds_stage -WHERE drug_concept_code = '3584846' - AND ingredient_concept_code = '1023' - AND box_size = 30 - AND amount_value = 500 - AND amount_unit = 'mg'; - -UPDATE ds_stage -SET amount_value = 1.53 -WHERE drug_concept_code = '3284943' - AND ingredient_concept_code = '29848' - AND box_size = 5 - AND amount_value = 1.31 - AND amount_unit = 'mg'; - -UPDATE ds_stage -SET amount_value = 500 -WHERE drug_concept_code = '3354164' - AND ingredient_concept_code = '1023' - AND box_size = 24 - AND amount_value = 200 - AND amount_unit = 'mg'; - -UPDATE ds_stage -SET amount_value = 250 -WHERE drug_concept_code = '3404695' - AND ingredient_concept_code = '2202' - AND box_size = 24 - AND amount_value = 187.5 - AND amount_unit = 'mg'; - -UPDATE ds_stage -SET amount_value = 700 -WHERE drug_concept_code = '3584846' - AND ingredient_concept_code = '1023' - AND box_size = 30 - AND amount_value = 200 - AND amount_unit = 'mg'; - -UPDATE ds_stage -SET amount_value = 1.53 -WHERE drug_concept_code = '5758486' - AND ingredient_concept_code = '29848' - AND box_size = 30 - AND amount_value = 1.31 - AND amount_unit = 'mg'; - ---sometimes denominator is just a sum of components, so in this case we need to ignore denominators -UPDATE ds_stage -SET amount_value = numerator_value, - amount_unit = numerator_unit, - numerator_value = NULL, - numerator_unit = NULL, - denominator_value = NULL, - denominator_unit = NULL -WHERE drug_concept_code IN ( - SELECT a.drug_concept_code - FROM ds_stage a - JOIN ( - SELECT drug_concept_code, - sum(numerator_value) AS summ, - numerator_unit - FROM ds_stage - GROUP BY drug_concept_code, - denominator_value, - denominator_unit, - numerator_unit - ) b ON a.drug_concept_code = b.drug_concept_code - AND summ / denominator_value < 1.2 - AND summ / denominator_value > 0.8 - AND a.numerator_unit = b.numerator_unit - WHERE a.numerator_unit = a.denominator_unit - ); - ---drug with no din7 -INSERT INTO ds_stage ( - drug_concept_code, - ingredient_concept_code, - numerator_value, - numerator_unit, - denominator_value, - denominator_unit - ) -VALUES ( - '60253264', - '612', - 2.5, - 'IU', - 1, - 'ml' - ); - -UPDATE ds_stage -SET numerator_value = numerator_value * 10 * denominator_value, - numerator_unit = 'mg' -WHERE numerator_unit = '%'; - ---update drugs that have amount+denominator -UPDATE ds_stage -SET numerator_value = amount_value, - numerator_unit = amount_unit, - amount_value = NULL, - amount_unit = NULL -WHERE denominator_unit IS NOT NULL - AND numerator_unit IS NULL - AND amount_unit IS NOT NULL; - -UPDATE ds_stage -SET denominator_value = NULL, - denominator_unit = NULL -WHERE denominator_unit IS NOT NULL - AND numerator_unit IS NULL; - -UPDATE ds_stage a -SET amount_value = b.amount_value, - amount_unit = b.amount_unit, - numerator_value = b.numerator_value, - numerator_unit = b.numerator_unit, - denominator_value = b.denominator_value, - denominator_unit = b.denominator_unit -FROM ds_stage_update b -WHERE a.drug_concept_code = b.drug_concept_code - AND a.ingredient_concept_code = b.ingredient_concept_code - AND a.box_size = b.box_size; - -UPDATE ds_stage -SET numerator_value = amount_value * 30, - numerator_unit = amount_unit, - denominator_value = 30, - denominator_unit = 'ACTUAT', - amount_value = NULL, - amount_unit = NULL -WHERE drug_concept_code IN ( - '2761996', - '3000459' - ); + UPDATE ds_stage SET numerator_value = power(10, numerator_value), numerator_unit = 'CCID_50' WHERE numerator_unit = 'log CCID_50'; -UPDATE ds_stage -SET numerator_value = 10 -WHERE drug_concept_code = '5704697' - AND ingredient_concept_code = '51742'; - -UPDATE ds_stage -SET numerator_value = 20 -WHERE drug_concept_code = '5704711' - AND ingredient_concept_code = '51742'; -UPDATE ds_stage -SET numerator_value = 10 -WHERE drug_concept_code = '5750852' - AND ingredient_concept_code = '51742'; -UPDATE ds_stage -SET numerator_value = 20 -WHERE drug_concept_code = '5750875' - AND ingredient_concept_code = '51742'; +-- extract Suppliers +DROP TABLE IF EXISTS dcs_manufacturer; +CREATE TABLE dcs_manufacturer AS +SELECT DISTINCT LTRIM(manufacturer,' ') AS concept_name, + drug_code, + 'Supplier'::VARCHAR AS concept_class_id +FROM sources.bdpm_drug + JOIN sources.bdpm_packaging USING (drug_code) +WHERE drug_code NOT IN +( + SELECT drug_code + FROM non_drug +UNION + SELECT drug_code + FROM bdpm_vaccine_manual +UNION + SELECT drug_code + FROM homeop_drug +) +; -UPDATE ds_stage -SET numerator_value = 10 -WHERE drug_concept_code = '5756211' - AND ingredient_concept_code = '51742'; +-- find suppliers automaticly and fit names to standard +drop table if exists dcs_manufacturer_1; +create table dcs_manufacturer_1 as +with az as ( +select a.concept_name as attr_name, a.concept_class_id as attr_class, a.drug_code, c.* +from dcs_manufacturer a +join devv5.concept c on uppeR(a.concept_name) = upper(c.concept_name) +where c.concept_class_id = 'Supplier' +and c.vocabulary_id like 'Rx%' +and c.invalid_reason is null +), +ab as ( +select a.concept_name as attr_name, a.concept_class_id as attr_class, a.drug_code, c.* +from dcs_manufacturer a +join devv5.concept c on uppeR(substring(a.concept_name, '^\w+')) = upper(c.concept_name) +where c.concept_class_id = 'Supplier' +and c.invalid_reason is null +and c.vocabulary_id like 'Rx%' +and a.drug_code not in (select drug_code from az) +), +ac as ( +select a.concept_name as attr_name, a.concept_class_id as attr_class, a.drug_code, c.* +from dcs_manufacturer a +join devv5.concept c on uppeR(substring(a.concept_name, '^\w+\s\w+')) = upper(c.concept_name) +where c.concept_class_id = 'Supplier' +and c.invalid_reason is null +and c.vocabulary_id like 'Rx%' +and a.drug_code not in (select drug_code from az union select drug_code from ab) +) + +select * from az +union +select * from ab +union +select * from ac +; -UPDATE ds_stage -SET numerator_value = 20 -WHERE drug_concept_code = '5756228' - AND ingredient_concept_code = '51742'; -DELETE -FROM ds_stage -WHERE ingredient_concept_code = '3011' - AND amount_value = 0; - ---update dosages for inhalers -DROP TABLE IF EXISTS ds_inhaler; -CREATE TABLE ds_inhaler AS - WITH a AS ( - SELECT drug_concept_code, - ingredient_concept_code, - box_size, - amount_value, - amount_unit, - numerator_value, - numerator_unit, - denominator_value, - denominator_unit, - packaging, - substring(packaging, '(\d+)(\s*) dose')::INT AS num_coef, - substring(packaging, '(\d+) (plaquette|cartouche|flacon|inhalateur)')::INT AS box_coef - FROM ds_stage a - JOIN sources.bdpm_packaging b ON drug_concept_code = din_7::VARCHAR - WHERE packaging LIKE '%dose%inhal%' - OR packaging LIKE '%inhal%dose%' - ) +insert into dcs_manufacturer_1 +with upd as( +select m.concept_name as attr_name, m.concept_class_id as attr_class, m.drug_code, c.concept_id from dcs_manufacturer m, concept c +where drug_code not in (select drug_code from dcs_manufacturer_1) +and m.concept_name like c.concept_name||'%' +and c.vocabulary_id in ('RxNorm','RxNorm Extension') +and c.concept_class_id = 'Supplier' +and c.invalid_reason != 'D' +and length(c.concept_name) > 3 +and c.concept_name not in ('PHARMA') +) + + +select attr_name,attr_class,drug_code, cc.* +from concept_relationship r, upd, concept cc +where r.concept_id_1 = upd.concept_id +and cc.concept_id = r.concept_id_2 +and r.invalid_reason is null +and cc.vocabulary_id in ('RxNorm','RxNorm Extension') +and cc.invalid_reason is null +; -SELECT DISTINCT drug_concept_code, - ingredient_concept_code, - box_coef AS box_size, - NULL AS amount_value, - NULL AS amount_unit, - a.amount_value * num_coef AS numerator_value, - a.amount_unit AS numerator_unit, - num_coef AS denominator_value, - 'ACTUAT' AS denominator_unit -FROM a; - -UPDATE ds_stage a -SET box_size = b.box_size, - amount_value = NULL, - amount_unit = NULL, - numerator_value = b.numerator_value, - numerator_unit = b.numerator_unit, - denominator_value = b.denominator_value, - denominator_unit = b.denominator_unit -FROM ds_inhaler b -WHERE a.drug_concept_code = b.drug_concept_code - AND a.ingredient_concept_code = b.ingredient_concept_code; ---manufacturers -DROP TABLE IF EXISTS dcs_manufacturer; -CREATE TABLE dcs_manufacturer AS -SELECT DISTINCT ltrim(manufacturer, ' ') AS concept_name, - 'Supplier'::varchar AS concept_class_id -FROM sources.bdpm_drug; --Parsing drug description extracting brand names DROP TABLE IF EXISTS brand_name; @@ -1295,9 +1363,20 @@ CREATE TABLE brand_name AS SELECT rtrim(substring(drug_descr, '^(([A-Z]+(\s)?-?/?[A-Z]+(\s)?[A-Z]?)+)'), ' ') AS brand_name, drug_code FROM sources.bdpm_drug +join sources.bdpm_packaging using(drug_code) WHERE drug_descr NOT LIKE '%degré de dilution compris entre%' - AND substring(drug_descr, '^(([A-Z]+(\s)?-?[A-Z]+)+)') IS NOT NULL; + AND substring(drug_descr, '^(([A-Z]+(\s)?-?[A-Z]+)+)') IS NOT NULL + and drug_code not in (select drug_code +from non_drug +union +select drug_code +from bdpm_vaccine_manual +union +select drug_code +from homeop_drug +) +; UPDATE brand_name SET brand_name = 'NP100 PREMATURES AP-HP' @@ -1327,7 +1406,7 @@ UPDATE brand_name SET brand_name = 'ACTIVOX' WHERE brand_name LIKE 'ACTIVOX %'; ---Brand name = Ingredient (RxNorm) +-- delete Brand name that equal as Ingredient name (RxNorm) DELETE FROM brand_name WHERE upper(brand_name) IN ( @@ -1336,22 +1415,47 @@ WHERE upper(brand_name) IN ( WHERE concept_class_id = 'Ingredient' ); ---Brand name = Ingredient (BDPM translated) + +-- delete Brand name that equal as Ingredient name (BDPM original) DELETE FROM brand_name -WHERE lower(brand_name) IN ( - SELECT lower(translation) - FROM ingr_translation_all +WHERE lower(substring(brand_name,'^\w+')) IN ( + SELECT lower(original_name) + FROM rtc_1 + where attr_class = 'Ingredient' ); ---Brand name = Ingredient (BDPM original) +--Brand name = Ingredient (BDPM translated) DELETE FROM brand_name -WHERE lower(brand_name) IN ( - SELECT lower(concept_name) - FROM ingr_translation_all +WHERE lower(substring(brand_name,'^\w+')) IN ( + SELECT lower(attr_name) + FROM rtc_1 + where attr_class = 'Ingredient' + ); + + +delete +FROM brand_name +WHERE lower(substring(brand_name,'^\w+\s\w+')) IN ( + SELECT lower(original_name) + FROM rtc_1 + where attr_class = 'Ingredient' ); + +delete +FROM brand_name +WHERE lower(substring(brand_name,'^\w+\s\w+')) IN ( + SELECT lower(attr_name) + FROM rtc_1 + where attr_class = 'Ingredient' + ); + + + + +-- manual delete DELETE FROM brand_name WHERE brand_name IN ( @@ -1370,6 +1474,7 @@ UPDATE brand_name SET brand_name = regexp_replace(brand_name, 'ADULTES|ENFANTS|NOURRISSONS', '', 'g') WHERE brand_name ilike 'SUPPOSITOIRE%'; +drop table if exists bn; CREATE TABLE bn AS SELECT * @@ -1399,15 +1504,115 @@ WHERE brand_name IN (SELECT brand_name FROM bn); DELETE FROM brand_name -WHERE SUBSTRING(UPPER(brand_name),'\w+') IN (SELECT UPPER(concept_name) +WHERE SUBSTRING(UPPER(brand_name),'(\w+)E ') IN (SELECT UPPER(concept_name) FROM concept WHERE concept_Class_id = 'Ingredient') -AND brand_name NOT IN (SELECT UPPER(concept_name) - FROM concept - WHERE concept_Class_id = 'Brand Name' - AND invalid_reason IS NULL - AND vocabulary_id LIKE 'Rx%'); +; + +UPDATE brand_name + SET brand_name = 'FERVEX' +WHERE brand_name ~* 'fervex' +; +UPDATE brand_name + SET brand_name = 'ALYOSTAL' +WHERE brand_name ~* 'ALYOSTAL' +; +UPDATE brand_name + SET brand_name = 'DRILL MAUX DE GORGE' +WHERE brand_name ~* 'DRILL MAUX DE GORGE' +; +UPDATE brand_name + SET brand_name = 'MICROLAX' +WHERE brand_name ~* 'MICROLAX' +; +UPDATE brand_name + SET brand_name = 'RHINADVIL' +WHERE brand_name ~* 'RHINADVIL' +; +UPDATE brand_name + SET brand_name = 'ARKOGELULES' +WHERE brand_name ~* 'ARKOGELULES' +; +UPDATE brand_name + SET brand_name = 'OLIGOSTIM' +WHERE brand_name ~* 'OLIGOSTIM' +; +UPDATE brand_name + SET brand_name = 'ELUSANES' +WHERE brand_name ~* 'ELUSANES' +; +UPDATE brand_name + SET brand_name = 'ANGI SPRAY' +WHERE brand_name ~* 'ANGI\-SPRAY' +; +UPDATE brand_name + SET brand_name = 'ELEVIT' +WHERE brand_name ~* 'ELEVIT' +; + +with a as +( +select drug_code, brand_name, ingredient , position(upper(regexp_replace(ingredient, 'É' , 'E')) in upper(brand_name)) as p1 +from brand_name +join sources.bdpm_ingredient using(drug_code) +where length (ingredient) > 4 +), +b as ( +select drug_code, brand_name, ingredient , position(upper(substring(regexp_replace(ingredient, 'É' , 'E'),'^\w+\s\w+\s\w+')) in upper(brand_name)) as p1 +from brand_name +join sources.bdpm_ingredient using(drug_code) +where length (ingredient) > 4 +and drug_code not in (select drug_code from a where p1 >0) +), +c as ( +select drug_code, brand_name, ingredient , position(upper(substring(regexp_replace(ingredient, 'É' , 'E'),'^\w+\s\w+')) in upper(brand_name)) as p1 +from brand_name +join sources.bdpm_ingredient using(drug_code) +where length (ingredient) > 4 +and drug_code not in (select drug_code from a where p1 >0 union select drug_code from b where p1 >0 ) +), +d as ( +select * from ( +select drug_code, brand_name, ingredient , position(upper(substring(regexp_replace(ingredient, 'É' , 'E'),'^\w+')) in upper(brand_name)) as p1 +from brand_name +join sources.bdpm_ingredient using(drug_code) +where length (ingredient) > 4 +and drug_code not in +( +select drug_code from a where p1 >0 +union +select drug_code from b where p1 >0 +union +select drug_code from c where p1 >0 +) +) ds where p1>0 +) + + + + + +delete from brand_name +where drug_code in ( +select drug_code from a where p1 >0 +union +select drug_code from b where p1 >0 +union +select drug_code from c where p1 >0 +union +select drug_code from d where p1 >0 +) +and drug_code not in +( +select drug_code from brand_name where upper(substring(brand_name,'^\w+')) in (select upper(concept_name) from devv5.concept where concept_class_id = 'Brand Name' and vocabulary_id like 'Rx%' and invalid_reason is null) +) +; + + +delete from brand_name where brand_name ~* 'GOMENOL|GOMENOL SOLUBLE|GOMENOLEO|HEPATOUM'; + + --list for drug_concept_stage DROP TABLE IF EXISTS dcs_bn; CREATE TABLE dcs_bn AS @@ -1417,15 +1622,32 @@ FROM brand_name WHERE drug_code NOT IN ( SELECT drug_code FROM non_drug - ); + ) +; --list of Dose Form (translated before) DROP TABLE IF EXISTS list; CREATE TABLE list AS -SELECT trim(translation) AS concept_name, +SELECT distinct trim(initcap(attr_name)) AS concept_name, 'Dose Form'::VARCHAR AS concept_class_id, NULL::VARCHAR AS concept_code -FROM form_translation --manual table +FROM rtc_1 +where upper(trim(original_name)) in +( +select distinct upper(replace(CONCAT(trim(form),' ',trim(route)),' ',' ')) +from sources.bdpm_drug +join sources.bdpm_packaging using(drug_code) +where drug_code not in +(select drug_code from non_drug + union + select drug_code + from bdpm_vaccine_manual + union + SELECT drug_code + FROM homeop_drug +) +) + UNION @@ -1438,28 +1660,48 @@ FROM dcs_bn UNION --manufacturers -SELECT trim(concept_name), +SELECT distinct uppeR(trim(concept_name)), + concept_class_id, + NULL +from dcs_manufacturer_1 + +union + +SELECT distinct uppeR(trim(concept_name)), concept_class_id, NULL -FROM dcs_manufacturer; +FROM dcs_manufacturer +where concept_name not in (select +attr_name from dcs_manufacturer_1) +; DELETE FROM list WHERE concept_name LIKE '%Enteric Oral Capsule%'; - +/* INSERT INTO list VALUES ( 'inert ingredients', 'Ingredient', NULL - ); + );*/ + +DO $$ DECLARE ex INTEGER; + +BEGIN +SELECT MAX(REPLACE(concept_code,'OMOP','')::INT4) +1 INTO ex +FROM devv5.concept +WHERE concept_code LIKE 'OMOP%' +AND concept_code NOT LIKE '% %'; ---temporary sequence -DROP SEQUENCE IF EXISTS new_vocc; -CREATE SEQUENCE new_vocc MINVALUE 1 MAXVALUE 1000000 START WITH 1 INCREMENT BY 1 CACHE 100; +DROP SEQUENCE IF EXISTS new_vocab; + +EXECUTE 'CREATE SEQUENCE new_vocab INCREMENT BY 1 START WITH ' || ex || ' NO CYCLE CACHE 20'; + +END $$; --put OMOP||numbers UPDATE list -SET concept_code = 'OMOP' || nextval('new_vocc'); +SET concept_code = 'OMOP' || nextval('new_vocab'); --Fill drug_concept_stage --Drug Product @@ -1512,7 +1754,7 @@ INSERT INTO drug_concept_stage ( SELECT SUBSTR(d.drug_descr, 1, 240), 'BDPM', 'Device', - NULL, + 'S', din_7::VARCHAR, NULL, 'Device', @@ -1539,7 +1781,7 @@ INSERT INTO drug_concept_stage ( valid_end_date, invalid_reason ) -SELECT DISTINCT concept_name, +SELECT DISTINCT initcap(concept_name), 'BDPM', concept_class_id, NULL, @@ -1552,29 +1794,40 @@ SELECT DISTINCT concept_name, FROM list; -- units -INSERT INTO drug_concept_stage ( - concept_name, - vocabulary_id, - concept_class_id, - standard_concept, - concept_code, - possible_excipient, - domain_id, - valid_start_date, - valid_end_date, - invalid_reason - ) -SELECT DISTINCT concept_code, - 'BDPM', - 'unit', - NULL, - concept_code, - NULL, - 'Drug', - TO_DATE('19700101', 'yyyymmdd'), - TO_DATE('20991231', 'yyyymmdd'), - NULL -FROM aut_unit_all_mapped; +INSERT INTO drug_concept_stage +( + concept_name, + vocabulary_id, + concept_class_id, + standard_concept, + concept_code, + possible_excipient, + domain_id, + valid_start_date, + valid_end_date, + invalid_reason +) +SELECT DISTINCT attr_name, + 'BDPM', + 'Unit', + NULL, + attr_name, + NULL, + 'Drug', + TO_DATE('19700101','yyyymmdd'), + TO_DATE('20991231','yyyymmdd'), + NULL +FROM rtc_1 +WHERE attr_name IN (SELECT amount_unit + FROM ds_stage + UNION + SELECT numerator_unit + FROM ds_stage + UNION + SELECT denominator_unit + FROM ds_stage) +and attr_class = 'Unit' +; -- Pack_components INSERT INTO drug_concept_stage ( @@ -1639,292 +1892,89 @@ INSERT INTO drug_concept_stage ( valid_end_date, invalid_reason ) -SELECT DISTINCT translation, +SELECT DISTINCT --initcap(trim(original_name)), +initcap(trim(first_value (attr_name) over(partition by form_code))), 'BDPM', 'Ingredient', NULL, - concept_code, + form_code, NULL, 'Drug', TO_DATE('19700101', 'yyyymmdd'), TO_DATE('20991231', 'yyyymmdd'), NULL -FROM ingr_translation_all; +FROM (select original_name,attr_name from rtc_ingred union select original_name,attr_name from rtc_1 where attr_class = 'Ingredient') a +join ingredient_step_2 on trim(upper(original_name)) = trim(upper(ingredient)) +where drug_code NOT IN ( + SELECT drug_code + FROM non_drug + union + select drug_code + from bdpm_vaccine_manual + union + SELECT drug_code + FROM homeop_drug +) + ; -DELETE -FROM drug_concept_stage -WHERE concept_code IN ( - '89969', - '49487', - '24033', - '72310', - '31035', - '66548', - '16621', - '31035' - ); +--Forms mapping +INSERT INTO relationship_to_concept ( + concept_code_1, + vocabulary_id_1, + concept_id_2, + precedence, + conversion_factor + ) +SELECT distinct concept_code, + 'BDPM', + to_id, + precedence, + NULL::float +FROM rtc_1 --manual table +JOIN drug_concept_stage d ON lower(d.concept_name) = lower(attr_name) +where attr_class = 'Dose Form' and to_id is not null +; ---standard concept definition, not sure if we need this -UPDATE drug_concept_stage dcs -SET standard_concept = 'S' -FROM ( - SELECT concept_code - FROM drug_concept_stage - WHERE concept_class_id NOT IN ( - 'Brand Name', - 'Dose Form', - 'unit', - 'Ingredient', - 'Supplier' - ) - ) d -WHERE d.concept_code = dcs.concept_code; +--units +INSERT INTO relationship_to_concept ( + concept_code_1, + vocabulary_id_1, + concept_id_2, + precedence, + conversion_factor + ) +SELECT distinct concept_code, + 'BDPM', + to_id, + precedence, + conversion_factor +FROM rtc_1 --manual table +join drug_concept_stage ON lower( concept_name) = lower(attr_name) +where attr_class = 'Unit' and to_id is not null +; ---standard concept definition, not sure if we need this -UPDATE drug_concept_stage dcs -SET standard_concept = 'S' -FROM ( - SELECT concept_name, - MIN(concept_code) m - FROM drug_concept_stage - WHERE concept_class_id = 'Ingredient' - GROUP BY concept_name - HAVING count(concept_name) > 1 - ) d -WHERE d.m = dcs.concept_code; -UPDATE drug_concept_stage -SET standard_concept = 'S' -WHERE concept_class_id = 'Ingredient' - AND concept_name NOT IN ( - SELECT concept_name - FROM drug_concept_stage - WHERE concept_class_id = 'Ingredient' - GROUP BY concept_name - HAVING count(concept_name) > 1 - ); ---drug with no din7 -INSERT INTO drug_concept_stage ( - concept_name, - vocabulary_id, - concept_class_id, - standard_concept, - concept_code, - possible_excipient, - domain_id, - valid_start_date, - valid_end_date, - invalid_reason - ) -VALUES ( - 'VACCIN RABIQUE INACTIVE MERIEUX, poudre et solvant pour suspension injectable. Vaccin rabique préparé sur cellules diploïdes humaines', - 'BDPM', - 'Drug Product', - 'S', - '60253264', - NULL, - 'Drug', - TO_DATE('19960107', 'yyyymmdd'), - TO_DATE('20991231', 'yyyymmdd'), - NULL - ); - ---Drug to ingredients -INSERT INTO internal_relationship_stage ( - concept_code_1, - concept_code_2 - ) -SELECT DISTINCT drug_concept_code, - ingredient_concept_code -FROM ds_stage d -WHERE d.drug_concept_code NOT IN ( - SELECT drug_code - FROM non_drug - ) - AND d.drug_concept_code NOT IN ( - SELECT pack_component_code - FROM pack_cont_1 - ); - ---Homeop. drug to ingredients -INSERT INTO internal_relationship_stage ( - concept_code_1, - concept_code_2 - ) -SELECT DISTINCT din_7, - form_code -FROM sources.bdpm_packaging -JOIN homeop_drug using (drug_code); - ---Pack Component to Ingredient -INSERT INTO internal_relationship_stage ( - concept_code_1, - concept_code_2 - ) -SELECT DISTINCT drug_concept_code, - ingredient_concept_code -FROM ds_stage d -WHERE d.drug_concept_code IN ( - SELECT pack_component_code - FROM pack_cont_1 - ); - -INSERT INTO internal_relationship_stage (concept_code_1) -SELECT concept_code -FROM drug_concept_stage -WHERE concept_name LIKE '%INERT INGREDIENT Metered Dose Inhaler%'; - -UPDATE internal_relationship_stage -SET concept_code_2 = ( - SELECT concept_code - FROM drug_concept_stage - WHERE concept_name LIKE '%inert ingredients%' - ) -WHERE concept_code_1 IN ( - SELECT concept_code - FROM drug_concept_stage - WHERE concept_name LIKE '%INERT INGREDIENT Metered Dose Inhaler%' - ) - AND concept_code_2 IS NULL; - ---Drug to Brand Name -INSERT INTO internal_relationship_stage ( - concept_code_1, - concept_code_2 - ) -SELECT DISTINCT din_7, - concept_code -FROM brand_name b -JOIN drug_concept_stage d ON lower(brand_name) = lower(concept_name) - AND d.concept_class_id = 'Brand Name' -JOIN sources.bdpm_packaging p ON p.drug_code = b.drug_code -WHERE b.drug_code NOT IN ( - SELECT drug_code - FROM non_drug - ); - ---Drug to Supplier -INSERT INTO internal_relationship_stage ( - concept_code_1, - concept_code_2 - ) -SELECT DISTINCT din_7, - concept_code -FROM sources.bdpm_drug b -JOIN drug_concept_stage d ON lower(manufacturer) = ' ' || lower(concept_name) - AND d.concept_class_id = 'Supplier' -JOIN sources.bdpm_packaging p ON p.drug_code = b.drug_code -WHERE b.drug_code NOT IN ( - SELECT drug_code - FROM non_drug - ); - ---Drug to Dose Form ---separately for packs and drugs ---for drugs, excluding packs and non_drugs -INSERT INTO internal_relationship_stage ( - concept_code_1, - concept_code_2 - ) -SELECT DISTINCT din_7, - concept_code -FROM sources.bdpm_drug d -JOIN form_translation ON replace(CONCAT ( - form, - ' ', - route - ), ' ', ' ') = form_route -JOIN drug_concept_stage ON translation = concept_name - AND concept_class_id = 'Dose Form' -JOIN sources.bdpm_packaging p ON p.drug_code = d.drug_code -WHERE d.drug_code NOT IN ( - SELECT drug_code - FROM non_drug - ) - AND d.drug_code NOT IN ( - SELECT concept_code::VARCHAR - FROM pack_cont_1 - ); - --- Drug to Dose Form for Pack components -INSERT INTO internal_relationship_stage ( - concept_code_1, - concept_code_2 - ) -SELECT pack_component_code, - concept_code -FROM pf_from_pack_comp_list pf -JOIN drug_concept_stage dcs ON pack_form = concept_name; - ---manual update of code_ingred_to_ingred -DELETE -FROM code_ingred_to_ingred -WHERE cast (concept_code_1 as int4) IN ( - SELECT form_code - FROM non_drug - ); - ---Ingredient to Ingredient -INSERT INTO internal_relationship_stage ( - concept_code_1, - concept_code_2 - ) -SELECT * -FROM code_ingred_to_ingred; - ---manualy defined same ingredients -INSERT INTO internal_relationship_stage ( - concept_code_1, - concept_code_2 - ) -SELECT DISTINCT b.concept_code concept_code_1, - a.concept_code concept_code_2 -FROM drug_concept_stage a -JOIN drug_concept_stage b ON a.concept_name = b.concept_name -WHERE a.concept_name IN ( - SELECT concept_name - FROM drug_concept_stage - GROUP BY concept_name - HAVING count(8) > 1 - ) - AND a.concept_class_id = 'Ingredient' - AND a.standard_concept = 'S' - AND b.standard_concept IS NULL - AND b.concept_code NOT IN ( - SELECT concept_code_2 - FROM code_ingred_to_ingred - ); - ---drug doesn't have packaging -INSERT INTO internal_relationship_stage ( - concept_code_1, - concept_code_2 - ) -SELECT '60253264', - concept_code -FROM drug_concept_stage -WHERE concept_name = 'Injectable Solution'; - -INSERT INTO internal_relationship_stage ( +INSERT INTO relationship_to_concept ( concept_code_1, - concept_code_2 + vocabulary_id_1, + concept_id_2, + precedence, + conversion_factor ) -SELECT '60253264', - concept_code -FROM drug_concept_stage -WHERE concept_name = 'VACCIN RABIQUE INACTIVE MERIEUX'; +SELECT distinct d.concept_code , + 'BDPM', + to_id, + case when precedence is null then 1 else precedence end , + NULL::float +from (select original_name,attr_name,to_id,precedence from rtc_ingred union select original_name,attr_name,to_id,precedence from rtc_1 where attr_class = 'Ingredient') a +join drug_concept_stage d ON lower( concept_name) = lower(attr_name) +where d.concept_class_id = 'Ingredient' and to_id is not null +--FROM RxE_Ing_st_0 -- RxNormExtension name equivalence + ; -INSERT INTO internal_relationship_stage ( - concept_code_1, - concept_code_2 - ) -SELECT '60253264', - concept_code -FROM drug_concept_stage -WHERE concept_name = 'SANOFI PASTEUR'; ---Forms mapping +--suppliers found manually INSERT INTO relationship_to_concept ( concept_code_1, vocabulary_id_1, @@ -1932,15 +1982,19 @@ INSERT INTO relationship_to_concept ( precedence, conversion_factor ) -SELECT concept_code, - 'BDPM', - concept_id, - precedence, - NULL -FROM aut_form_all_mapped --manual table -JOIN drug_concept_stage d ON lower(d.concept_name) = lower(translation); +select c.concept_code, +c.vocabulary_id, +a.concept_id, +1, +NULL::float +from devv5.concept a +join drug_concept_stage c on upper(c.concept_name) = upper(a.concept_name) +where c.concept_class_id = 'Supplier' +and a.concept_class_id = 'Supplier' +and a.invalid_reason is null +and a.vocabulary_id like 'Rx%' +; ---Brand names INSERT INTO relationship_to_concept ( concept_code_1, vocabulary_id_1, @@ -1948,15 +2002,19 @@ INSERT INTO relationship_to_concept ( precedence, conversion_factor ) -SELECT concept_code, +SELECT distinct concept_code , 'BDPM', - concept_id, + to_id, precedence, - NULL -FROM aut_bn_mapped_all a --manual table -JOIN drug_concept_stage d ON lower(d.concept_name) = lower(a.brand_name); + NULL::float +from rtc_1 +join drug_concept_stage ON lower( concept_name) = lower(attr_name) +where concept_class_id = 'Supplier' and to_id is not null +and concept_code not in ( select concept_code_1 from relationship_to_concept) +; + +--Brands from RxE ---units INSERT INTO relationship_to_concept ( concept_code_1, vocabulary_id_1, @@ -1964,14 +2022,15 @@ INSERT INTO relationship_to_concept ( precedence, conversion_factor ) -SELECT concept_code, +SELECT distinct concept_code , 'BDPM', - concept_id_2, + to_id, precedence, - conversion_factor -FROM aut_unit_all_mapped; --manual table + NULL::float +from rtc_1 +join drug_concept_stage ON lower( concept_name) = lower(attr_name) +where concept_class_id = 'Brand Name' and to_id is not null;-- RxNormExtension name equivalence ---ingredients INSERT INTO relationship_to_concept ( concept_code_1, vocabulary_id_1, @@ -1979,407 +2038,1056 @@ INSERT INTO relationship_to_concept ( precedence, conversion_factor ) -SELECT concept_code, +SELECT distinct dc.concept_code , 'BDPM', - concept_id, - precedence, - NULL -FROM aut_ingr_mapped_all; --manual table - -DROP TABLE IF EXISTS ingr_map_update; -CREATE TABLE ingr_map_update AS - WITH a AS ( - SELECT a.concept_code, - a.concept_name, - vocabulary_id_1, - precedence, - rank() OVER ( - PARTITION BY a.concept_code ORDER BY c2.concept_id - ) AS rank, - c2.concept_id, - c2.standard_concept - FROM drug_concept_stage a - JOIN relationship_to_concept rc ON a.concept_code = rc.concept_code_1 - JOIN concept c1 ON c1.concept_id = concept_id_2 - JOIN concept c2 ON trim(regexp_replace(lower(c1.concept_name), 'for homeopathic preparations|tartrate|phosphate', '', 'g')) = trim(regexp_replace(lower(c2.concept_name), 'for homeopathic preparations', '', 'g')) - AND c2.standard_concept = 'S' - AND c2.concept_class_id = 'Ingredient' - WHERE c1.invalid_reason IS NOT NULL - ) + c.concept_id, + 1 as precedence, + NULL::float +from /*rtc_1*/ concept c +join drug_concept_stage dc ON lower(dc.concept_name) = lower(c.concept_name) +where c.concept_class_id = dc.concept_class_id and c.concept_class_id = 'Brand Name' --and to_id is not null +and dc.concept_code not in ( select concept_code_1 from relationship_to_concept) +and c.vocabulary_id like 'Rx%' +and c.invalid_reason is null +;-- RxNormExtension name equivalence + + + +/* +drop table if exists relationship_concept_to_map; +create table relationship_concept_to_map_1 as +SELECT coalesce(ingredient,unit) as original_name, coalesce (a.concept_name,ingredient,unit) as attr_name, a.concept_class_id as attr_class, null::integer as concept_id_2, null::integer as precedenece, null::float as conversion_factor, null::varchar as indicator_rxe +FROM drug_concept_stage a + LEFT JOIN relationship_to_concept c ON c.concept_code_1 = a.concept_code + LEFT JOIN (SELECT amount_unit AS unit + FROM ds_stage + UNION + SELECT numerator_unit + FROM ds_stage + UNION + SELECT denominator_unit + FROM ds_stage) d ON d.unit = a.concept_code + LEFT JOIN (SELECT DISTINCT form_code, + ingredient + FROM sources.bdpm_ingredient + WHERE drug_code NOT IN (SELECT drug_code + FROM bdpm_vaccine_manual + UNION + SELECT drug_code + FROM non_drug + UNION + SELECT drug_code + FROM homeop_drug) + --AND UPPER(ingredient) NOT IN (SELECT UPPER(original_name) FROM rtc_1) + ) e ON a.concept_code = e.form_code +WHERE a.concept_class_id IN ('Ingredient','Brand Name','Supplier','Dose Form','Unit') +and c.concept_code_1 is null +; +*/ -SELECT concept_code, - concept_name, - vocabulary_id_1, - precedence, - concept_id, - standard_concept -FROM a -WHERE concept_code IN ( - SELECT concept_code - FROM a - GROUP BY concept_code - HAVING count(concept_code) = 1 - ) -UNION + + +---manual work +/*drop table if exists pack_amount_manual; +create table pack_amount_manual as +--insert into pack_amount_manual +select concept_code,pack_component_code,packaging,pack_amount_value,drug_form +from pack_cont_1 +--where concept_code not in (select concept_code from pack_amount_manual) +order by concept_code, pack_component_code +; +*/ + +************************* + + +update pack_cont_1 a +set pack_amount_value = c.pack_amount_value +from pack_amount_manual c +where a.concept_code = c.concept_code +and a.packaging = c.packaging +and a.drug_form = c.drug_form +; +UPDATE pack_cont_1 + SET pack_amount_value = '2' +WHERE concept_code = '3016965' +AND pack_name = 'APREPITANT ZENTIVA 125 mg, gélule et APREPITANT ZENTIVA 80 mg, gélule' +AND drug_form = 'gélule blanche' +AND pack_component_name = 'APREPITANT ZENTIVA 125 mg, gélule et APREPITANT ZENTIVA 80 mg, gélule gélule blanche' +AND packaging = 'plaquette(s) polyamide aluminium PVC de 1 gélule de 125 mg et de 2 gélule(s) blanches' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '3016965' +AND pack_name = 'APREPITANT ZENTIVA 125 mg, gélule et APREPITANT ZENTIVA 80 mg, gélule' +AND drug_form = 'gélule blanche et rose' +AND pack_component_name = 'APREPITANT ZENTIVA 125 mg, gélule et APREPITANT ZENTIVA 80 mg, gélule gélule blanche et rose' +AND packaging = 'plaquette(s) polyamide aluminium PVC de 1 gélule de 125 mg et de 2 gélule(s) blanches' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '14' +WHERE concept_code = '3584622' +AND pack_name = 'NAEMIS, comprimé' +AND drug_form = 'comprimé blanc' +AND pack_component_name = 'NAEMIS, comprimé comprimé blanc' +AND packaging = '1 plaquette(s) PVC polyéthylène aluminium-ACLAR de 24 comprimés (10 comprimés roses et 14 comprimés blancs)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '10' +WHERE concept_code = '3584622' +AND pack_name = 'NAEMIS, comprimé' +AND drug_form = 'comprimé rose' +AND pack_component_name = 'NAEMIS, comprimé comprimé rose' +AND packaging = '1 plaquette(s) PVC polyéthylène aluminium-ACLAR de 24 comprimés (10 comprimés roses et 14 comprimés blancs)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; + + +UPDATE pack_cont_1 + SET pack_amount_value = '5' +WHERE concept_code = '3008105' +AND pack_name = 'TRINORDIOL, comprimé enrobé' +AND drug_form = 'comprimé blanc' +AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé blanc' +AND packaging = '1 plaquette(s) PVC-Aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '6' +WHERE concept_code = '3008105' +AND pack_name = 'TRINORDIOL, comprimé enrobé' +AND drug_form = 'comprimé brique' +AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé brique' +AND packaging = '1 plaquette(s) PVC-Aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '10' +WHERE concept_code = '3008105' +AND pack_name = 'TRINORDIOL, comprimé enrobé' +AND drug_form = 'comprimé jaune' +AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé jaune' +AND packaging = '1 plaquette(s) PVC-Aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '6' +WHERE concept_code = '3008106' +AND pack_name = 'TRINORDIOL, comprimé enrobé' +AND drug_form = 'comprimé blanc' +AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé blanc' +AND packaging = '3 plaquette(s) PVC-Aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '5' +WHERE concept_code = '3008106' +AND pack_name = 'TRINORDIOL, comprimé enrobé' +AND drug_form = 'comprimé brique' +AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé brique' +AND packaging = '3 plaquette(s) PVC-Aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '10' +WHERE concept_code = '3008106' +AND pack_name = 'TRINORDIOL, comprimé enrobé' +AND drug_form = 'comprimé jaune' +AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé jaune' +AND packaging = '3 plaquette(s) PVC-Aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '7' +WHERE concept_code = '3184064' +AND pack_name = 'ADEPAL, comprimé enrobé' +AND drug_form = 'comprimé blanc' +AND pack_component_name = 'ADEPAL, comprimé enrobé comprimé blanc' +AND packaging = '1 plaquette(s) thermoformée(s) PVC aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '14' +WHERE concept_code = '3184064' +AND pack_name = 'ADEPAL, comprimé enrobé' +AND drug_form = 'comprimé rose orangé' +AND pack_component_name = 'ADEPAL, comprimé enrobé comprimé rose orangé' +AND packaging = '1 plaquette(s) thermoformée(s) PVC aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '7' +WHERE concept_code = '3184087' +AND pack_name = 'ADEPAL, comprimé enrobé' +AND drug_form = 'comprimé blanc' +AND pack_component_name = 'ADEPAL, comprimé enrobé comprimé blanc' +AND packaging = '3 plaquette(s) thermoformée(s) PVC aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '14' +WHERE concept_code = '3184087' +AND pack_name = 'ADEPAL, comprimé enrobé' +AND drug_form = 'comprimé rose orangé' +AND pack_component_name = 'ADEPAL, comprimé enrobé comprimé rose orangé' +AND packaging = '3 plaquette(s) thermoformée(s) PVC aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '6' +WHERE concept_code = '3280709' +AND pack_name = 'TRINORDIOL, comprimé enrobé' +AND drug_form = 'comprimé blanc' +AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé blanc' +AND packaging = '1 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '5' +WHERE concept_code = '3280709' +AND pack_name = 'TRINORDIOL, comprimé enrobé' +AND drug_form = 'comprimé brique' +AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé brique' +AND packaging = '1 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '10' +WHERE concept_code = '3280709' +AND pack_name = 'TRINORDIOL, comprimé enrobé' +AND drug_form = 'comprimé jaune' +AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé jaune' +AND packaging = '1 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '6' +WHERE concept_code = '3280715' +AND pack_name = 'TRINORDIOL, comprimé enrobé' +AND drug_form = 'comprimé blanc' +AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé blanc' +AND packaging = '3 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '5' +WHERE concept_code = '3280715' +AND pack_name = 'TRINORDIOL, comprimé enrobé' +AND drug_form = 'comprimé brique' +AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé brique' +AND packaging = '3 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '10' +WHERE concept_code = '3280715' +AND pack_name = 'TRINORDIOL, comprimé enrobé' +AND drug_form = 'comprimé jaune' +AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé jaune' +AND packaging = '3 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '5' +WHERE concept_code = '3588413' +AND pack_name = 'DAILY, comprimé enrobé' +AND drug_form = 'comprimé blanc' +AND pack_component_name = 'DAILY, comprimé enrobé comprimé blanc' +AND packaging = '1 plaquette thermoformée (aluminium/PVC/PVDC) de 21 comprimés' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '10' +WHERE concept_code = '3588413' +AND pack_name = 'DAILY, comprimé enrobé' +AND drug_form = 'comprimé jaune' +AND pack_component_name = 'DAILY, comprimé enrobé comprimé jaune' +AND packaging = '1 plaquette thermoformée (aluminium/PVC/PVDC) de 21 comprimés' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '6' +WHERE concept_code = '3588413' +AND pack_name = 'DAILY, comprimé enrobé' +AND drug_form = 'comprimé rose' +AND pack_component_name = 'DAILY, comprimé enrobé comprimé rose' +AND packaging = '1 plaquette thermoformée (aluminium/PVC/PVDC) de 21 comprimés' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '5' +WHERE concept_code = '3588436' +AND pack_name = 'DAILY, comprimé enrobé' +AND drug_form = 'comprimé blanc' +AND pack_component_name = 'DAILY, comprimé enrobé comprimé blanc' +AND packaging = '3 plaquettes thermoformées (aluminium/PVC/PVDC) de 21 comprimés' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '10' +WHERE concept_code = '3588436' +AND pack_name = 'DAILY, comprimé enrobé' +AND drug_form = 'comprimé jaune' +AND pack_component_name = 'DAILY, comprimé enrobé comprimé jaune' +AND packaging = '3 plaquettes thermoformées (aluminium/PVC/PVDC) de 21 comprimés' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '6' +WHERE concept_code = '3588436' +AND pack_name = 'DAILY, comprimé enrobé' +AND drug_form = 'comprimé rose' +AND pack_component_name = 'DAILY, comprimé enrobé comprimé rose' +AND packaging = '3 plaquettes thermoformées (aluminium/PVC/PVDC) de 21 comprimés' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '12' +WHERE concept_code = '3698604' +AND pack_name = 'DOLIRHUMEPRO PARACETAMOL, PSEUDOEPHEDRINE ET DOXYLAMINE, comprimé' +AND drug_form = 'comprimé jour' +AND pack_component_name = 'DOLIRHUMEPRO PARACETAMOL, PSEUDOEPHEDRINE ET DOXYLAMINE, comprimé comprimé jour' +AND packaging = 'plaquette(s) thermoformée(s) PVC-Aluminium de 16 comprimés' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '4' +WHERE concept_code = '3698604' +AND pack_name = 'DOLIRHUMEPRO PARACETAMOL, PSEUDOEPHEDRINE ET DOXYLAMINE, comprimé' +AND drug_form = 'comprimé nuit' +AND pack_component_name = 'DOLIRHUMEPRO PARACETAMOL, PSEUDOEPHEDRINE ET DOXYLAMINE, comprimé comprimé nuit' +AND packaging = 'plaquette(s) thermoformée(s) PVC-Aluminium de 16 comprimés' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '5' +WHERE concept_code = '3899975' +AND pack_name = 'EVANECIA, comprimé enrobé' +AND drug_form = 'comprimé blanc' +AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé blanc' +AND packaging = '1 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '10' +WHERE concept_code = '3899975' +AND pack_name = 'EVANECIA, comprimé enrobé' +AND drug_form = 'comprimé jaune' +AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé jaune' +AND packaging = '1 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '6' +WHERE concept_code = '3899975' +AND pack_name = 'EVANECIA, comprimé enrobé' +AND drug_form = 'comprimé rouge brique' +AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé rouge brique' +AND packaging = '1 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '5' +WHERE concept_code = '3899981' +AND pack_name = 'EVANECIA, comprimé enrobé' +AND drug_form = 'comprimé blanc' +AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé blanc' +AND packaging = '3 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '10' +WHERE concept_code = '3899981' +AND pack_name = 'EVANECIA, comprimé enrobé' +AND drug_form = 'comprimé jaune' +AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé jaune' +AND packaging = '3 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '6' +WHERE concept_code = '3899981' +AND pack_name = 'EVANECIA, comprimé enrobé' +AND drug_form = 'comprimé rouge brique' +AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé rouge brique' +AND packaging = '3 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '7' +WHERE concept_code = '3918106' +AND pack_name = 'PACILIA, comprimé enrobé' +AND drug_form = 'comprimé blanc' +AND pack_component_name = 'PACILIA, comprimé enrobé comprimé blanc' +AND packaging = '1 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '14' +WHERE concept_code = '3918106' +AND pack_name = 'PACILIA, comprimé enrobé' +AND drug_form = 'comprimé rose' +AND pack_component_name = 'PACILIA, comprimé enrobé comprimé rose' +AND packaging = '1 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '7' +WHERE concept_code = '3918112' +AND pack_name = 'PACILIA, comprimé enrobé' +AND drug_form = 'comprimé blanc' +AND pack_component_name = 'PACILIA, comprimé enrobé comprimé blanc' +AND packaging = '3 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '14' +WHERE concept_code = '3918112' +AND pack_name = 'PACILIA, comprimé enrobé' +AND drug_form = 'comprimé rose' +AND pack_component_name = 'PACILIA, comprimé enrobé comprimé rose' +AND packaging = '3 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' +AND pack_amount_value IS NULL +AND denominator_value IS NULL +AND denominator_unit IS NULL; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5500089' +AND pack_name = 'TISSEEL, solutions pour colle' +AND drug_form = 'composant 1' +AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' +AND packaging = 'système à double seringues (polypropylène) 1 * 2 ml (1 ml + 1 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' +AND pack_amount_value IS NULL +AND denominator_value = 1.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5500089' +AND pack_name = 'TISSEEL, solutions pour colle' +AND drug_form = 'composant 2' +AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' +AND packaging = 'système à double seringues (polypropylène) 1 * 2 ml (1 ml + 1 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' +AND pack_amount_value IS NULL +AND denominator_value = 1.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5500091' +AND pack_name = 'TISSEEL, solutions pour colle' +AND drug_form = 'composant 1' +AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' +AND packaging = 'système à double seringues (polypropylène) 1 * 4 ml (2 ml + 2 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' +AND pack_amount_value IS NULL +AND denominator_value = 2.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5500091' +AND pack_name = 'TISSEEL, solutions pour colle' +AND drug_form = 'composant 2' +AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' +AND packaging = 'système à double seringues (polypropylène) 1 * 4 ml (2 ml + 2 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' +AND pack_amount_value IS NULL +AND denominator_value = 2.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5500092' +AND pack_name = 'TISSEEL, solutions pour colle' +AND drug_form = 'composant 1' +AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' +AND packaging = 'système à double seringues (polypropylène) 1 * 10 ml (5 ml + 5 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' +AND pack_amount_value IS NULL +AND denominator_value = 5.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5500092' +AND pack_name = 'TISSEEL, solutions pour colle' +AND drug_form = 'composant 2' +AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' +AND packaging = 'système à double seringues (polypropylène) 1 * 10 ml (5 ml + 5 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' +AND pack_amount_value IS NULL +AND denominator_value = 5.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5503190' +AND pack_name = 'TISSEEL, solutions pour colle' +AND drug_form = 'composant 1' +AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' +AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 2 ml (1 ml + 1 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' +AND pack_amount_value IS NULL +AND denominator_value = 2.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5503190' +AND pack_name = 'TISSEEL, solutions pour colle' +AND drug_form = 'composant 2' +AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' +AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 2 ml (1 ml + 1 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' +AND pack_amount_value IS NULL +AND denominator_value = 2.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5503191' +AND pack_name = 'TISSEEL, solutions pour colle' +AND drug_form = 'composant 1' +AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' +AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 4 ml (2 ml + 2 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' +AND pack_amount_value IS NULL +AND denominator_value = 4.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5503191' +AND pack_name = 'TISSEEL, solutions pour colle' +AND drug_form = 'composant 2' +AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' +AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 4 ml (2 ml + 2 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' +AND pack_amount_value IS NULL +AND denominator_value = 4.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5503192' +AND pack_name = 'TISSEEL, solutions pour colle' +AND drug_form = 'composant 1' +AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' +AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 10 ml (5 ml + 5 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' +AND pack_amount_value IS NULL +AND denominator_value = 10.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5503192' +AND pack_name = 'TISSEEL, solutions pour colle' +AND drug_form = 'composant 2' +AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' +AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 10 ml (5 ml + 5 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' +AND pack_amount_value IS NULL +AND denominator_value = 10.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5620894' +AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' +AND drug_form = 'poudre 1' +AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 1' +AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 2 ml de solution + 2 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' +AND pack_amount_value IS NULL +AND denominator_value = 2.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5620894' +AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' +AND drug_form = 'poudre 2' +AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 2' +AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 2 ml de solution + 2 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' +AND pack_amount_value IS NULL +AND denominator_value = 2.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5620894' +AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' +AND drug_form = 'solution de reconstitution de la poudre 1' +AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle solution de reconstitution de la poudre 1' +AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 2 ml de solution + 2 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' +AND pack_amount_value IS NULL +AND denominator_value = 2.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5620902' +AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' +AND drug_form = 'poudre 1' +AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 1' +AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 5 ml de solution + 5 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' +AND pack_amount_value IS NULL +AND denominator_value = 5.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5620902' +AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' +AND drug_form = 'poudre 2' +AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 2' +AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 5 ml de solution + 5 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' +AND pack_amount_value IS NULL +AND denominator_value = 5.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5620902' +AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' +AND drug_form = 'solution de reconstitution de la poudre 1' +AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle solution de reconstitution de la poudre 1' +AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 5 ml de solution + 5 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' +AND pack_amount_value IS NULL +AND denominator_value = 5.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5620925' +AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' +AND drug_form = 'poudre 1' +AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 1' +AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 1 ml de solution + 1 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' +AND pack_amount_value IS NULL +AND denominator_value = 1.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5620925' +AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' +AND drug_form = 'poudre 2' +AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 2' +AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 1 ml de solution + 1 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' +AND pack_amount_value IS NULL +AND denominator_value = 1.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5620925' +AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' +AND drug_form = 'solution de reconstitution de la poudre 1' +AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle solution de reconstitution de la poudre 1' +AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 1 ml de solution + 1 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' +AND pack_amount_value IS NULL +AND denominator_value = 1.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5645167' +AND pack_name = 'WILSTART, poudres et solvants pour solution injectable' +AND drug_form = 'poudre du composant 1' +AND pack_component_name = 'WILSTART, poudres et solvants pour solution injectable poudre du composant 1' +AND packaging = '1 flacon(s) en verre de 1000 UI - 1 flacon(s) en verre de 10 ml - 1 flacon(s) en verre de 500 UI - 1 flacon(s) en verre de 5 ml avec dispositif(s) de transfert' +AND pack_amount_value IS NULL +AND denominator_value = 1.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5645167' +AND pack_name = 'WILSTART, poudres et solvants pour solution injectable' +AND drug_form = 'poudre du composant 2' +AND pack_component_name = 'WILSTART, poudres et solvants pour solution injectable poudre du composant 2' +AND packaging = '1 flacon(s) en verre de 1000 UI - 1 flacon(s) en verre de 10 ml - 1 flacon(s) en verre de 500 UI - 1 flacon(s) en verre de 5 ml avec dispositif(s) de transfert' +AND pack_amount_value IS NULL +AND denominator_value = 1.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5755766' +AND pack_name = 'ARTISS, solutions pour colle' +AND drug_form = 'solution de protéines pour colle' +AND pack_component_name = 'ARTISS, solutions pour colle solution de protéines pour colle' +AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (1 ml + 1 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' +AND pack_amount_value IS NULL +AND denominator_value = 1.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5755766' +AND pack_name = 'ARTISS, solutions pour colle' +AND drug_form = 'solution de thrombine' +AND pack_component_name = 'ARTISS, solutions pour colle solution de thrombine' +AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (1 ml + 1 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' +AND pack_amount_value IS NULL +AND denominator_value = 1.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5755772' +AND pack_name = 'ARTISS, solutions pour colle' +AND drug_form = 'solution de protéines pour colle' +AND pack_component_name = 'ARTISS, solutions pour colle solution de protéines pour colle' +AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (2 ml + 2 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' +AND pack_amount_value IS NULL +AND denominator_value = 1.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5755772' +AND pack_name = 'ARTISS, solutions pour colle' +AND drug_form = 'solution de thrombine' +AND pack_component_name = 'ARTISS, solutions pour colle solution de thrombine' +AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (2 ml + 2 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' +AND pack_amount_value IS NULL +AND denominator_value = 1.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5755789' +AND pack_name = 'ARTISS, solutions pour colle' +AND drug_form = 'solution de protéines pour colle' +AND pack_component_name = 'ARTISS, solutions pour colle solution de protéines pour colle' +AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (5 ml + 5 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' +AND pack_amount_value IS NULL +AND denominator_value = 1.0 +AND denominator_unit = 'ml'; +UPDATE pack_cont_1 + SET pack_amount_value = '1' +WHERE concept_code = '5755789' +AND pack_name = 'ARTISS, solutions pour colle' +AND drug_form = 'solution de thrombine' +AND pack_component_name = 'ARTISS, solutions pour colle solution de thrombine' +AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (5 ml + 5 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' +AND pack_amount_value IS NULL +AND denominator_value = 1.0 +AND denominator_unit = 'ml'; + + + +/* +delete from drug_concept_stage +where concept_code in ( +select pack_component_code from pack_cont_1 +where concept_code in (select concept_code from pack_amount_manual where pack_amount_value is null) +) +; +delete from ds_stage +where drug_concept_code in +( +select pack_component_code from pack_cont_1 +where concept_code in (select concept_code from pack_amount_manual where pack_amount_value is null) +) +; + + +delete from pack_cont_1 +where concept_code in (select concept_code from pack_amount_manual where pack_amount_value is null); +*/ + +insert into relationship_to_concept +( +concept_code_1, +vocabulary_id_1, +concept_id_2, +precedence +) +select distinct concept_code, vocabulary_id, concept_id_2 , precedenece +from (select * from relationship_concept_to_mapped_1 union select * from relationship_concept_to_map_1) rt +join drug_concept_stage +on upper(concept_name) = upper(attr_name) +and concept_class_id= attr_class +where concept_id_2 is not null +; + + +delete from drug_concept_stage where concept_code in ( +select concept_code +from relationship_concept_to_mapped_1 +join drug_concept_stage +on upper(concept_name) = upper(attr_name) +and concept_class_id= attr_class +where indicator_rxe = 'd') +; + +delete from drug_concept_stage where concept_code in ( +select concept_code +from relationship_concept_to_map_1 +join drug_concept_stage +on upper(concept_name) = upper(attr_name) +and concept_class_id= attr_class +where indicator_rxe != '+' and concept_id_2 is null) +; + + + + +DELETE +FROM drug_concept_stage +WHERE concept_code IN (SELECT concept_code + FROM drug_concept_stage + LEFT JOIN relationship_to_concept ON concept_code_1 = concept_code + WHERE concept_code_1 IS NULL + AND concept_class_id = 'Ingredient' + AND concept_name ~* 'Homeopathic Preparation'); + + + + + +ALTER TABLE ds_stage +-- add mapped ingredient's concept_id to aid next step in dealing with dublicates +ADD concept_id INT4; + +UPDATE ds_stage + SET concept_id = (SELECT concept_id_2 + FROM relationship_to_concept + WHERE concept_code_1 = ingredient_concept_code + AND precedence = 1); + + +--Fix ingredients that got replaced/mapped as same one (e.g. Sodium ascorbate + Ascorbic acid => Ascorbic acid) +DROP TABLE if exists ds_split; + +CREATE TABLE ds_split +AS +SELECT DISTINCT drug_concept_code, + MIN(ingredient_concept_code) OVER (PARTITION BY drug_concept_code,concept_id)::VARCHAR AS ingredient_concept_code, + --one at random + SUM(amount_value) OVER (PARTITION BY drug_concept_code,concept_id) AS amount_value, + amount_unit, + SUM(numerator_value) OVER (PARTITION BY drug_concept_code,concept_id) AS numerator_value, + numerator_unit, + denominator_value, + denominator_unit, + NULL::INT4 AS box_size, + concept_id +FROM ds_stage +WHERE (drug_concept_code,concept_id) IN (SELECT drug_concept_code, + concept_id + FROM ds_stage + GROUP BY drug_concept_code, + concept_id + HAVING COUNT(*) > 1); + +DELETE +FROM ds_stage +WHERE (drug_concept_code,concept_id) IN (SELECT drug_concept_code, concept_id FROM ds_split); + + +INSERT INTO ds_stage +( + drug_concept_code, + ingredient_concept_code, + box_size, + amount_value, + amount_unit, + numerator_value, + numerator_unit, + denominator_value, + denominator_unit, + concept_id +) +SELECT drug_concept_code, + ingredient_concept_code, + box_size, + amount_value, + amount_unit, + numerator_value, + numerator_unit, + denominator_value, + denominator_unit, + concept_id +FROM ds_split; + +ALTER TABLE ds_stage DROP COLUMN concept_id; -SELECT concept_code, - concept_name, - vocabulary_id_1, - rank, - concept_id, - standard_concept -FROM a -WHERE concept_code IN ( - SELECT concept_code - FROM a - GROUP BY concept_code - HAVING count(concept_code) != 1 - ); -DELETE -FROM relationship_to_concept -WHERE ( - concept_code_1, - concept_id_2 - ) IN ( - SELECT concept_code_1, - concept_id_2 - FROM relationship_to_concept - JOIN drug_concept_stage s ON s.concept_code = concept_code_1 - JOIN concept c ON c.concept_id = concept_id_2 - WHERE c.standard_concept IS NULL - AND s.concept_class_id = 'Ingredient' - ); -INSERT INTO relationship_to_concept -SELECT concept_code, - vocabulary_id_1, - concept_id, - precedence, - NULL -FROM ingr_map_update; ---add RxNorm Extension -DROP TABLE IF EXISTS RxE_Ing_st_0; -CREATE TABLE RxE_Ing_st_0 AS -SELECT a.concept_code AS concept_code_1, - a.concept_name AS concept_name_1, - c.concept_id, - c.concept_name -FROM drug_concept_stage a -JOIN concept c ON lower(a.concept_name) = lower(c.concept_name) -WHERE a.concept_class_id = 'Ingredient' - AND a.concept_code NOT IN ( - SELECT concept_code_1 - FROM relationship_to_concept - ) - AND c.vocabulary_id = 'RxNorm Extension' - AND c.concept_class_id = 'Ingredient' - AND c.invalid_reason IS NULL; -INSERT INTO relationship_to_concept ( - concept_code_1, - vocabulary_id_1, - concept_id_2, - precedence, - conversion_factor - ) -SELECT concept_code_1, - 'BDPM', - concept_id, - 1, - NULL -FROM RxE_Ing_st_0 -- RxNormExtension name equivalence - ; ---one ingredient found manualy -INSERT INTO relationship_to_concept ( + + + +--Drug to ingredients +INSERT INTO internal_relationship_stage ( concept_code_1, - vocabulary_id_1, - concept_id_2, - precedence, - conversion_factor + concept_code_2 ) -VALUES ( - '538', - 'BDPM', - 21014151, - 1, - NULL - ); - -INSERT INTO relationship_to_concept -SELECT concept_code, - 'BDPM', - 19127890, - 1, - NULL -FROM drug_concept_stage -WHERE concept_name LIKE '%inert ingredients%'; ---need to add manufacturer lately - ---manufacturer -DROP TABLE IF EXISTS RxE_Man_st_0; -CREATE TABLE RxE_Man_st_0 AS -SELECT a.concept_code AS concept_code_1, - a.concept_name AS concept_name_1, - c.concept_id, - c.concept_name concept, - rank() OVER ( - PARTITION BY a.concept_code ORDER BY c.concept_id - ) AS precedence -FROM drug_concept_stage a -JOIN concept c ON regexp_replace(lower(a.concept_name), ' ltd| plc| uk| \(.*\)| pharmaceuticals| pharma| gmbh| laboratories| ab| international| france| imaging', '', 'g') = regexp_replace(lower(c.concept_name), ' ltd| plc| uk| \(.*\)| pharmaceuticals| pharma| gmbh| laboratories| ab| international| france| imaging', '', 'g') -WHERE a.concept_class_id = 'Supplier' - AND a.concept_code NOT IN ( - SELECT concept_code_1 - FROM relationship_to_concept +SELECT DISTINCT drug_concept_code, + ingredient_concept_code +FROM ds_stage d +WHERE d.drug_concept_code NOT IN ( + SELECT drug_code + FROM non_drug ) - AND c.vocabulary_id LIKE 'RxNorm%' - AND c.concept_class_id = 'Supplier' - AND c.invalid_reason IS NULL; + AND d.drug_concept_code NOT IN ( + SELECT pack_component_code + FROM pack_cont_1 + ) +; -INSERT INTO relationship_to_concept -SELECT concept_code, - 'BDPM', - concept_id, - precedence, - NULL -FROM aut_supp_mapped a -JOIN drug_concept_stage b using (concept_name);--suppliers found manually -INSERT INTO relationship_to_concept ( +--Pack Component to Ingredient +INSERT INTO internal_relationship_stage ( concept_code_1, - vocabulary_id_1, - concept_id_2, - precedence, - conversion_factor + concept_code_2 ) -SELECT concept_code_1, - 'BDPM', - concept_id, - precedence, - NULL -FROM RxE_Man_st_0; -- RxNormExtension name equivalence - ---Brands from RxE +SELECT DISTINCT drug_concept_code, + ingredient_concept_code +FROM ds_stage d +WHERE d.drug_concept_code IN ( + SELECT pack_component_code + FROM pack_cont_1 + ); -DROP TABLE IF EXISTS RxE_BR_n_st_0; -CREATE TABLE RxE_BR_n_st_0 AS -SELECT a.concept_code AS concept_code_1, - a.concept_name AS concept_name_1, - c.concept_id, - c.concept_name -FROM drug_concept_stage a -JOIN concept c ON lower(a.concept_name) = lower(c.concept_name) -WHERE a.concept_class_id = 'Brand Name' - AND a.concept_code NOT IN ( - SELECT concept_code_1 - FROM relationship_to_concept +--Drug to Brand Name +INSERT INTO internal_relationship_stage ( + concept_code_1, + concept_code_2 + ) +SELECT DISTINCT din_7, + concept_code +FROM brand_name b +JOIN drug_concept_stage d ON lower(brand_name) = lower(concept_name) + AND d.concept_class_id = 'Brand Name' +JOIN sources.bdpm_packaging p ON p.drug_code = b.drug_code +WHERE b.drug_code NOT IN ( + SELECT drug_code + FROM non_drug ) - AND c.vocabulary_id LIKE 'RxNorm%' - AND c.concept_class_id = 'Brand Name' - AND c.invalid_reason IS NULL; -INSERT INTO relationship_to_concept ( +; + + +--Drug to Supplier +INSERT INTO internal_relationship_stage ( concept_code_1, - vocabulary_id_1, - concept_id_2, - precedence, - conversion_factor + concept_code_2 ) -SELECT concept_code_1, - 'BDPM', - concept_id, - 1, - NULL -FROM RxE_BR_n_st_0 ;-- RxNormExtension name equivalence - -DELETE -FROM relationship_to_concept -WHERE ctid IN ( - SELECT MAX(ctid) - FROM relationship_to_concept - GROUP BY concept_code_1, - precedence - HAVING count(1) > 1 +SELECT DISTINCT din_7, + d.concept_code +FROM dcs_manufacturer_1 b +JOIN drug_concept_stage d ON lower(b.concept_name) = lower(d.concept_name) + AND d.concept_class_id = 'Supplier' +JOIN sources.bdpm_packaging p ON p.drug_code = b.drug_code +WHERE b.drug_code NOT IN ( + SELECT drug_code + FROM non_drug ); + -DELETE -FROM internal_relationship_stage -WHERE ctid IN ( - SELECT MAX(ctid) - FROM internal_relationship_stage - GROUP BY concept_code_1, - concept_code_2 - HAVING count(1) > 1 +INSERT INTO internal_relationship_stage ( + concept_code_1, + concept_code_2 + ) +SELECT DISTINCT din_7, + d.concept_code +FROM dcs_manufacturer b +JOIN drug_concept_stage d ON lower(b.concept_name) = lower(d.concept_name) + AND d.concept_class_id = 'Supplier' +JOIN sources.bdpm_packaging p ON p.drug_code = b.drug_code +WHERE b.drug_code NOT IN ( + SELECT drug_code + FROM non_drug + union + select drug_code + from dcs_manufacturer_1 ); -UPDATE ds_stage -SET amount_value = numerator_value, - amount_unit = numerator_unit, - numerator_value = NULL, - numerator_unit = NULL, - denominator_value = NULL, - denominator_unit = NULL -WHERE ( - ingredient_concept_code = '16736' - AND drug_concept_code IN ( - SELECT concept_code - FROM drug_concept_stage - WHERE concept_name IN ( - 'JINARC 30 mg, comprimé, JINARC 90 mg, comprimé comprimé de 90 mg', - 'JINARC 15 mg, comprimé, JINARC 45 mg, comprimé comprimé de 45 mg', - 'JINARC 30 mg, comprimé, JINARC 60 mg, comprimé comprimé de 60 mg' - ) - ) - ) - OR ( - ingredient_concept_code = '41238' - AND drug_concept_code IN ( - SELECT concept_code - FROM drug_concept_stage - WHERE concept_name IN ( - 'OTEZLA 10 mg, comprimé pelliculé, OTEZLA 20 mg, comprimé pelliculé, OTEZLA 30 mg, comprimé pelliculé, comprimé 30 mg', - 'OTEZLA 10 mg, comprimé pelliculé, OTEZLA 20 mg, comprimé pelliculé, OTEZLA 30 mg, comprimé pelliculé, comprimé 20 mg' - ) - ) - ); ---delete non-relevant brand names -DELETE -FROM relationship_to_concept -WHERE concept_code_1 IN ( - SELECT concept_code - FROM drug_concept_stage a - LEFT JOIN internal_relationship_stage b ON a.concept_code = b.concept_code_2 - WHERE a.concept_class_id = 'Brand Name' - AND b.concept_code_1 IS NULL +--Drug to Dose Form +--separately for packs and drugs +INSERT INTO internal_relationship_stage ( + concept_code_1, + concept_code_2 + ) +SELECT DISTINCT din_7, + concept_code +FROM sources.bdpm_drug d +JOIN rtc_1 ON upper(replace(CONCAT(trim(form),' ',trim(route)),' ',' ')) = upper(trim(original_name)) +JOIN drug_concept_stage ON uppeR(attr_name) = uppeR(concept_name) + AND concept_class_id = 'Dose Form' +JOIN sources.bdpm_packaging p ON p.drug_code = d.drug_code +WHERE d.drug_code NOT IN ( + SELECT drug_code + FROM non_drug + ) + AND d.drug_code NOT IN ( + SELECT concept_code::VARCHAR + FROM pack_cont_1) + and d.drug_code not in (select drug_code from bdpm_vaccine_manual ); ---update ds_stage after relationship_to concept found identical ingredients -DELETE -FROM drug_concept_stage -WHERE concept_code IN ( - SELECT concept_code - FROM drug_concept_stage a - LEFT JOIN internal_relationship_stage b ON a.concept_code = b.concept_code_2 - WHERE a.concept_class_id = 'Brand Name' - AND b.concept_code_1 IS NULL - ); +-- Drug to Dose Form for Pack components +INSERT INTO internal_relationship_stage ( + concept_code_1, + concept_code_2 + ) +SELECT pack_component_code, + concept_code +FROM pf_from_pack_comp_list pf +JOIN drug_concept_stage dcs ON pack_form = concept_name +where pack_component_code in (select pack_component_code from pack_cont_1) +; -DROP TABLE IF EXISTS ds_sum; -CREATE TABLE ds_sum AS - WITH a AS ( - SELECT DISTINCT ds.drug_concept_code, - ds.ingredient_concept_code, - ds.box_size, - ds.amount_value, - ds.amount_unit, - ds.numerator_value, - ds.numerator_unit, - ds.denominator_value, - ds.denominator_unit, - rc.concept_id_2 +update ds_stage +set box_size = null +where drug_concept_code in ( + SELECT drug_concept_code + FROM ds_stage + WHERE drug_concept_code NOT IN ( + SELECT drug_concept_code FROM ds_stage ds - JOIN ds_stage ds2 ON ds.drug_concept_code = ds2.drug_concept_code - AND ds.ingredient_concept_code != ds2.ingredient_concept_code - JOIN relationship_to_concept rc ON ds.ingredient_concept_code = rc.concept_code_1 - JOIN relationship_to_concept rc2 ON ds2.ingredient_concept_code = rc2.concept_code_1 - WHERE rc.concept_id_2 = rc2.concept_id_2 + JOIN internal_relationship_stage i ON concept_code_1 = drug_concept_code + JOIN drug_concept_stage ON concept_code = concept_code_2 + AND concept_class_id = 'Dose Form' + WHERE box_size IS NOT NULL ) + AND box_size IS NOT NULL +); -SELECT drug_concept_code, - max(ingredient_concept_code) OVER ( - PARTITION BY drug_concept_code, - concept_id_2 - ) AS ingredient_concept_code, - box_size, - sum(amount_value) OVER (PARTITION BY drug_concept_code) AS amount_value, - amount_unit, - sum(numerator_value) OVER ( - PARTITION BY drug_concept_code, - concept_id_2 - ) AS numerator_value, - numerator_unit, - denominator_value, - denominator_unit -FROM a - -UNION -SELECT drug_concept_code, - ingredient_concept_code, - box_size, - NULL AS amount_value, - NULL AS amount_unit, - NULL AS numerator_value, - NULL AS numerator_unit, - NULL AS denominator_value, - NULL AS denominator_unit -FROM a -WHERE ( - drug_concept_code, - ingredient_concept_code - ) NOT IN ( - SELECT drug_concept_code, - max(ingredient_concept_code) - FROM a - GROUP BY drug_concept_code - ); +-- remove from ds_stage drugs without dosage +DELETE +FROM ds_stage +WHERE drug_concepT_code IN (SELECT drug_concept_code + FROM ds_stage + WHERE numerator_value IS NULL + AND amount_value IS NULL); +-- remove from ds_stage drugs with volume only DELETE FROM ds_stage -WHERE ( - drug_concept_code, - ingredient_concept_code - ) IN ( - SELECT drug_concept_code, - ingredient_concept_code - FROM ds_sum - ); +WHERE drug_concept_code IN (SELECT drug_concept_code + FROM ds_stage + WHERE numerator_unit = 'ml' + OR amount_unit = 'ml'); -INSERT INTO ds_stage -SELECT * -FROM ds_sum -WHERE coalesce(amount_value, numerator_value) IS NOT NULL; ---update irs after relationship_to concept found identical ingredients -DELETE -FROM internal_relationship_stage -WHERE ( - concept_code_1, - concept_code_2 - ) IN ( - SELECT concept_code_1, - concept_code_2 - FROM ( - SELECT DISTINCT concept_code_1, - concept_code_2, - COUNT(concept_code_2) OVER (PARTITION BY concept_code_1) AS irs_cnt - FROM internal_relationship_stage - JOIN drug_concept_stage ON concept_code = concept_code_2 - AND concept_class_id = 'Ingredient' - ) irs - JOIN ( - SELECT DISTINCT drug_concept_code, - COUNT(ingredient_concept_code) OVER (PARTITION BY drug_concept_code) AS ds_cnt - FROM ds_stage - ) ds ON drug_concept_code = concept_code_1 - AND irs_cnt != ds_cnt - ) - AND ( - concept_code_1, - concept_code_2 - ) NOT IN ( - SELECT drug_concept_code, - ingredient_concept_code - FROM ds_stage - ); ---update IRS -remove suppliers where Dose form or dosage doesn't exist +--remove suppliers where Dose form or dosage doesn't exist DELETE FROM internal_relationship_stage WHERE ( @@ -2410,260 +3118,6 @@ WHERE ( ) ); ---manualy define packs amounts -DROP TABLE IF EXISTS p_c_amount; -CREATE TABLE p_c_amount AS -SELECT DISTINCT a.pack_component_code, - a.packaging, - a.concept_code::int4, - b.drug_form, - 99 AS amount, - 99 AS box_size -FROM pack_cont_1 a -JOIN pack_comp_list b ON a.pack_component_code = b.pack_component_code; - ---!!!!check -DO $_$ -BEGIN -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 2170290 AND DRUG_FORM = 'poudre'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 2170290 AND DRUG_FORM = 'solution'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 2219116 AND DRUG_FORM = 'solution 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 2219116 AND DRUG_FORM = 'solution 2'; -UPDATE P_C_AMOUNT SET AMOUNT = '14' WHERE CONCEPT_CODE = 2733209 AND DRUG_FORM = 'comprimé à 1 mg'; -UPDATE P_C_AMOUNT SET AMOUNT = '11' WHERE CONCEPT_CODE = 2733209 AND DRUG_FORM = '"comprimé à 0,5 mg"'; -UPDATE P_C_AMOUNT SET AMOUNT = '12' WHERE CONCEPT_CODE = 2742556 AND DRUG_FORM = 'comprimé jour'; -UPDATE P_C_AMOUNT SET AMOUNT = '4' WHERE CONCEPT_CODE = 2742556 AND DRUG_FORM = 'comprimé nuit'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 2794926 AND DRUG_FORM = 'solution de 63 microgrammes'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 2794926 AND DRUG_FORM = 'solution de 94 microgrammes'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3001051 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '84' WHERE CONCEPT_CODE = 3001051 AND DRUG_FORM = 'comprimé rose'; -UPDATE P_C_AMOUNT SET AMOUNT = '20' WHERE CONCEPT_CODE = 3048384 AND DRUG_FORM = 'poche A'; -UPDATE P_C_AMOUNT SET AMOUNT = '20' WHERE CONCEPT_CODE = 3048384 AND DRUG_FORM = 'poche B'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 3209686 AND DRUG_FORM = 'solvant'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 3209686 AND DRUG_FORM = 'poudre'; -UPDATE P_C_AMOUNT SET AMOUNT = '12' WHERE CONCEPT_CODE = 3254882 AND DRUG_FORM = 'comprimé bleu'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 3254882 AND DRUG_FORM = 'comprimé rouge'; -UPDATE P_C_AMOUNT SET AMOUNT = '10' WHERE CONCEPT_CODE = 3254882 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3254913 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3254913 AND DRUG_FORM = 'comprimé orange'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3254913 AND DRUG_FORM = 'comprimé orange pâle'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3254936 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3254936 AND DRUG_FORM = 'comprimé orange'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3254936 AND DRUG_FORM = 'comprimé orange pâle'; -UPDATE P_C_AMOUNT SET AMOUNT = '4' WHERE CONCEPT_CODE = 3263651 AND DRUG_FORM = 'comprimé'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 3263651 AND DRUG_FORM = 'solution'; -UPDATE P_C_AMOUNT SET AMOUNT = '4' WHERE CONCEPT_CODE = 3269642 AND DRUG_FORM = 'comprimé'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 3269642 AND DRUG_FORM = 'solution'; -UPDATE P_C_AMOUNT SET AMOUNT = '48' WHERE CONCEPT_CODE = 3272443 AND DRUG_FORM = 'gélule bleue'; -UPDATE P_C_AMOUNT SET AMOUNT = '48' WHERE CONCEPT_CODE = 3272443 AND DRUG_FORM = 'gélule rouge gastro-résistante'; -UPDATE P_C_AMOUNT SET AMOUNT = '24' WHERE CONCEPT_CODE = 3273129 AND DRUG_FORM = 'gélule bleue'; -UPDATE P_C_AMOUNT SET AMOUNT = '24' WHERE CONCEPT_CODE = 3273129 AND DRUG_FORM = 'gélule rouge gastro-résistante'; -UPDATE P_C_AMOUNT SET AMOUNT = '20' WHERE CONCEPT_CODE = 3292546 AND DRUG_FORM = 'solution en ampoule B'; -UPDATE P_C_AMOUNT SET AMOUNT = '20' WHERE CONCEPT_CODE = 3292546 AND DRUG_FORM = 'solution en ampoule A'; -UPDATE P_C_AMOUNT SET AMOUNT = '48' WHERE CONCEPT_CODE = 3295438 AND DRUG_FORM = 'gélule bleue gastro-soluble'; -UPDATE P_C_AMOUNT SET AMOUNT = '48' WHERE CONCEPT_CODE = 3295438 AND DRUG_FORM = 'gélule rouge gastro-résistante'; -UPDATE P_C_AMOUNT SET AMOUNT = '24' WHERE CONCEPT_CODE = 3299548 AND DRUG_FORM = 'gélule bleue gastro-soluble'; -UPDATE P_C_AMOUNT SET AMOUNT = '24' WHERE CONCEPT_CODE = 3299548 AND DRUG_FORM = 'gélule rouge gastro-résistante'; -UPDATE P_C_AMOUNT SET AMOUNT = '5' WHERE CONCEPT_CODE = 3305065 AND DRUG_FORM = 'comprimé marron foncé'; -UPDATE P_C_AMOUNT SET AMOUNT = '10' WHERE CONCEPT_CODE = 3305065 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 3305065 AND DRUG_FORM = 'comprimé beige'; -UPDATE P_C_AMOUNT SET AMOUNT = '5' WHERE CONCEPT_CODE = 3305071 AND DRUG_FORM = 'comprimé marron foncé'; -UPDATE P_C_AMOUNT SET AMOUNT = '10' WHERE CONCEPT_CODE = 3305071 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 3305071 AND DRUG_FORM = 'comprimé beige'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 3305088 AND DRUG_FORM = 'comprimé beige'; -UPDATE P_C_AMOUNT SET AMOUNT = '10' WHERE CONCEPT_CODE = 3305088 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '5' WHERE CONCEPT_CODE = 3305088 AND DRUG_FORM = 'comprimé marron foncé'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 3305094 AND DRUG_FORM = 'comprimé beige'; -UPDATE P_C_AMOUNT SET AMOUNT = '10' WHERE CONCEPT_CODE = 3305094 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '5' WHERE CONCEPT_CODE = 3305094 AND DRUG_FORM = 'comprimé marron foncé'; -UPDATE P_C_AMOUNT SET AMOUNT = '11' WHERE CONCEPT_CODE = 3344355 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '10' WHERE CONCEPT_CODE = 3344355 AND DRUG_FORM = 'comprimé bleu'; -UPDATE P_C_AMOUNT SET AMOUNT = '14' WHERE CONCEPT_CODE = 3357300 AND DRUG_FORM = 'solution A'; -UPDATE P_C_AMOUNT SET AMOUNT = '14' WHERE CONCEPT_CODE = 3357300 AND DRUG_FORM = 'solution B'; -UPDATE P_C_AMOUNT SET AMOUNT = '11' WHERE CONCEPT_CODE = 3360437 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '10' WHERE CONCEPT_CODE = 3360437 AND DRUG_FORM = 'comprimé rose'; -UPDATE P_C_AMOUNT SET AMOUNT = '3' WHERE CONCEPT_CODE = 3386477 AND DRUG_FORM = 'comprimé bleu'; -UPDATE P_C_AMOUNT SET AMOUNT = '3' WHERE CONCEPT_CODE = 3386477 AND DRUG_FORM = 'comprimé rose'; -UPDATE P_C_AMOUNT SET AMOUNT = '14' WHERE CONCEPT_CODE = 3438524 AND DRUG_FORM = 'comprimé jaune'; -UPDATE P_C_AMOUNT SET AMOUNT = '14' WHERE CONCEPT_CODE = 3438524 AND DRUG_FORM = 'comprimé rose'; -UPDATE P_C_AMOUNT SET AMOUNT = '4' WHERE CONCEPT_CODE = 3447463 AND DRUG_FORM = 'gélule'; -UPDATE P_C_AMOUNT SET AMOUNT = '12' WHERE CONCEPT_CODE = 3447463 AND DRUG_FORM = 'comprimé'; -UPDATE P_C_AMOUNT SET AMOUNT = '24' WHERE CONCEPT_CODE = 3490370 AND DRUG_FORM = 'gélule orange'; -UPDATE P_C_AMOUNT SET AMOUNT = '24' WHERE CONCEPT_CODE = 3490370 AND DRUG_FORM = 'gélule verte'; -UPDATE P_C_AMOUNT SET AMOUNT = '24' WHERE CONCEPT_CODE = 3490387 AND DRUG_FORM = 'gélule orange'; -UPDATE P_C_AMOUNT SET AMOUNT = '24' WHERE CONCEPT_CODE = 3490387 AND DRUG_FORM = 'gélule verte'; -UPDATE P_C_AMOUNT SET AMOUNT = '14' WHERE CONCEPT_CODE = 3526435 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '14' WHERE CONCEPT_CODE = 3526435 AND DRUG_FORM = 'comprimé gris'; -UPDATE P_C_AMOUNT SET AMOUNT = '4' WHERE CONCEPT_CODE = 3542871 AND DRUG_FORM = 'solution 2 : glucose avec calcium'; -UPDATE P_C_AMOUNT SET AMOUNT = '4' WHERE CONCEPT_CODE = 3542871 AND DRUG_FORM = 'solution 1 : acides aminés avec électrolytes'; -UPDATE P_C_AMOUNT SET AMOUNT = '4' WHERE CONCEPT_CODE = 3542919 AND DRUG_FORM = 'solution d''acides aminés'; -UPDATE P_C_AMOUNT SET AMOUNT = '4' WHERE CONCEPT_CODE = 3542919 AND DRUG_FORM = 'solution de glucose'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 3549583 AND DRUG_FORM = 'suspension'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 3549583 AND DRUG_FORM = 'poudre'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 3552473 AND DRUG_FORM = 'poudre'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 3552473 AND DRUG_FORM = 'suspension'; -UPDATE P_C_AMOUNT SET AMOUNT = '8' WHERE CONCEPT_CODE = 3563583 AND DRUG_FORM = 'solution 2 : glucose avec calcium'; -UPDATE P_C_AMOUNT SET AMOUNT = '8' WHERE CONCEPT_CODE = 3563583 AND DRUG_FORM = 'solution 1 : acides aminés avec électrolytes'; -UPDATE P_C_AMOUNT SET AMOUNT = '8' WHERE CONCEPT_CODE = 3563608 AND DRUG_FORM = 'solution 1 : acides aminés avec électrolytes'; -UPDATE P_C_AMOUNT SET AMOUNT = '8' WHERE CONCEPT_CODE = 3563608 AND DRUG_FORM = 'solution 2 : glucose avec calcium'; -UPDATE P_C_AMOUNT SET AMOUNT = '8' WHERE CONCEPT_CODE = 3563695 AND DRUG_FORM = 'solution d''acides aminés'; -UPDATE P_C_AMOUNT SET AMOUNT = '8' WHERE CONCEPT_CODE = 3563695 AND DRUG_FORM = 'solution de glucose'; -UPDATE P_C_AMOUNT SET AMOUNT = '14' WHERE CONCEPT_CODE = 3575304 AND DRUG_FORM = 'sachet 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '14' WHERE CONCEPT_CODE = 3575304 AND DRUG_FORM = 'sachet 2'; -UPDATE P_C_AMOUNT SET AMOUNT = '4' WHERE CONCEPT_CODE = 3575327 AND DRUG_FORM = 'comprimé bleu'; -UPDATE P_C_AMOUNT SET AMOUNT = '12' WHERE CONCEPT_CODE = 3575327 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '16' WHERE CONCEPT_CODE = 3583947 AND DRUG_FORM = 'comprimé beige'; -UPDATE P_C_AMOUNT SET AMOUNT = '12' WHERE CONCEPT_CODE = 3583947 AND DRUG_FORM = 'comprimé bleu'; -UPDATE P_C_AMOUNT SET AMOUNT = '10' WHERE CONCEPT_CODE = 3584622 AND DRUG_FORM = 'comprimé rose'; -UPDATE P_C_AMOUNT SET AMOUNT = '14' WHERE CONCEPT_CODE = 3584622 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '16' WHERE CONCEPT_CODE = 3584792 AND DRUG_FORM = 'comprimé rouge'; -UPDATE P_C_AMOUNT SET AMOUNT = '12' WHERE CONCEPT_CODE = 3584792 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3589938 AND DRUG_FORM = 'comprimé bleu ciel'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3589938 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3589938 AND DRUG_FORM = 'comprimé bleu foncé'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3589944 AND DRUG_FORM = 'comprimé bleu ciel'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3589944 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3589944 AND DRUG_FORM = 'comprimé bleu foncé'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3589950 AND DRUG_FORM = 'comprimé bleu foncé'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3589950 AND DRUG_FORM = 'comprimé bleu ciel'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3589950 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3589967 AND DRUG_FORM = 'comprimé bleu foncé'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3589967 AND DRUG_FORM = 'comprimé bleu ciel'; -UPDATE P_C_AMOUNT SET AMOUNT = '7' WHERE CONCEPT_CODE = 3589967 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 3603791 AND DRUG_FORM = 'poudre'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 3603791 AND DRUG_FORM = 'solution'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 3635118 AND DRUG_FORM = 'gélule blanche'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 3635118 AND DRUG_FORM = 'gélule blanche et rose'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 3687434 AND DRUG_FORM = 'poudre'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 3687434 AND DRUG_FORM = 'suspension'; -UPDATE P_C_AMOUNT SET AMOUNT = '3' WHERE CONCEPT_CODE = 3689516 AND DRUG_FORM = 'comprimé 300 IR'; -UPDATE P_C_AMOUNT SET AMOUNT = '28' WHERE CONCEPT_CODE = 3689516 AND DRUG_FORM = 'comprimé 100 IR'; -UPDATE P_C_AMOUNT SET AMOUNT = '5' WHERE CONCEPT_CODE = 3715811 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '10' WHERE CONCEPT_CODE = 3715811 AND DRUG_FORM = 'comprimé vert'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 3715811 AND DRUG_FORM = 'comprimé beige'; -UPDATE P_C_AMOUNT SET AMOUNT = '5' WHERE CONCEPT_CODE = 3715828 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '10' WHERE CONCEPT_CODE = 3715828 AND DRUG_FORM = 'comprimé vert'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 3715828 AND DRUG_FORM = 'comprimé beige'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 3759027 AND DRUG_FORM = 'solution à 22 microgrammes'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 3759027 AND DRUG_FORM = '"solution à 8,8 microgrammes"'; -UPDATE P_C_AMOUNT SET AMOUNT = '10' WHERE CONCEPT_CODE = 3770000 AND DRUG_FORM = 'comprimé jaune'; -UPDATE P_C_AMOUNT SET AMOUNT = '5' WHERE CONCEPT_CODE = 3770000 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 3770000 AND DRUG_FORM = 'comprimé brique'; -UPDATE P_C_AMOUNT SET AMOUNT = '11' WHERE CONCEPT_CODE = 3771809 AND DRUG_FORM = 'comprimé à 1 mg'; -UPDATE P_C_AMOUNT SET AMOUNT = '14' WHERE CONCEPT_CODE = 3771809 AND DRUG_FORM = '"comprimé à 0,5 mg"'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 3788164 AND DRUG_FORM = 'poudre du sachet B'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 3788164 AND DRUG_FORM = 'poudre du sachet A'; -UPDATE P_C_AMOUNT SET AMOUNT = '24' WHERE CONCEPT_CODE = 3813057 AND DRUG_FORM = 'granulés'; -UPDATE P_C_AMOUNT SET AMOUNT = '4' WHERE CONCEPT_CODE = 3813057 AND DRUG_FORM = 'comprimé'; -UPDATE P_C_AMOUNT SET AMOUNT = '72' WHERE CONCEPT_CODE = 3828455 AND DRUG_FORM = 'granulés'; -UPDATE P_C_AMOUNT SET AMOUNT = '12' WHERE CONCEPT_CODE = 3828455 AND DRUG_FORM = 'comprimé'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 3909484 AND DRUG_FORM = 'comprimé rouge foncé'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 3909484 AND DRUG_FORM = 'comprimé jaune foncé'; -UPDATE P_C_AMOUNT SET AMOUNT = '17' WHERE CONCEPT_CODE = 3909484 AND DRUG_FORM = 'comprimé jaune clair'; -UPDATE P_C_AMOUNT SET AMOUNT = '5' WHERE CONCEPT_CODE = 3909484 AND DRUG_FORM = 'comprimé rouge'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 3909490 AND DRUG_FORM = 'comprimé rouge foncé'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 3909490 AND DRUG_FORM = 'comprimé jaune foncé'; -UPDATE P_C_AMOUNT SET AMOUNT = '17' WHERE CONCEPT_CODE = 3909490 AND DRUG_FORM = 'comprimé jaune clair'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 3909490 AND DRUG_FORM = 'comprimé rouge'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 4166252 AND DRUG_FORM = 'compartiment de la solution de glucose'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 4166252 AND DRUG_FORM = 'compartiment de l''émulsion lipidique'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 4166252 AND DRUG_FORM = 'compartiment des acides aminés'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5500089 AND DRUG_FORM = 'composant 2'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5500089 AND DRUG_FORM = 'composant 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5500091 AND DRUG_FORM = 'composant 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5500091 AND DRUG_FORM = 'composant 2'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5500092 AND DRUG_FORM = 'composant 2'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5500092 AND DRUG_FORM = 'composant 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 5611085 AND DRUG_FORM = 'solvant (flacon 2)'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 5611085 AND DRUG_FORM = 'poudre (flacon 3)'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 5611085 AND DRUG_FORM = 'solvant (flacon 4)'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 5611085 AND DRUG_FORM = 'poudre (flacon 1)'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 5611091 AND DRUG_FORM = 'poudre (flacon 1)'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 5611091 AND DRUG_FORM = 'solvant (flacon 2)'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 5611091 AND DRUG_FORM = 'solvant (flacon 4)'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 5611091 AND DRUG_FORM = 'poudre (flacon 3)'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 5611116 AND DRUG_FORM = 'solvant (flacon 4)'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 5611116 AND DRUG_FORM = 'poudre (flacon 3)'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 5611116 AND DRUG_FORM = 'solvant (flacon 2)'; -UPDATE P_C_AMOUNT SET AMOUNT = '2' WHERE CONCEPT_CODE = 5611116 AND DRUG_FORM = 'poudre (flacon 1)'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5620894 AND DRUG_FORM = 'solution de reconstitution de la poudre 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5620894 AND DRUG_FORM = 'poudre 2'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5620894 AND DRUG_FORM = 'poudre 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5620902 AND DRUG_FORM = 'poudre 2'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5620902 AND DRUG_FORM = 'solution de reconstitution de la poudre 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5620902 AND DRUG_FORM = 'poudre 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5620925 AND DRUG_FORM = 'poudre 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5620925 AND DRUG_FORM = 'poudre 2'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5620925 AND DRUG_FORM = 'solution de reconstitution de la poudre 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5645167 AND DRUG_FORM = 'poudre du composant 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5645167 AND DRUG_FORM = 'poudre du composant 2'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5650932 AND DRUG_FORM = 'solution 2'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5650932 AND DRUG_FORM = 'solution 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5650949 AND DRUG_FORM = 'solution 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5650949 AND DRUG_FORM = 'solution 2'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5731866 AND DRUG_FORM = 'gélule transparente'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5754637 AND DRUG_FORM = 'solution 2'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5754637 AND DRUG_FORM = 'solution 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5754643 AND DRUG_FORM = 'solution 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5754643 AND DRUG_FORM = 'solution 2'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5754666 AND DRUG_FORM = 'solution 2'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5754666 AND DRUG_FORM = 'solution 1'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5755766 AND DRUG_FORM = 'solution de protéines pour colle'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5755766 AND DRUG_FORM = 'solution de thrombine'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5755772 AND DRUG_FORM = 'solution de thrombine'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5755772 AND DRUG_FORM = 'solution de protéines pour colle'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5755789 AND DRUG_FORM = 'solution de protéines pour colle'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 5755789 AND DRUG_FORM = 'solution de thrombine'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 2794903 AND DRUG_FORM = 'solution de 94 microgrammes'; -UPDATE P_C_AMOUNT SET AMOUNT = '1' WHERE CONCEPT_CODE = 2794903 AND DRUG_FORM = 'solution de 63 microgrammes'; -UPDATE P_C_AMOUNT SET AMOUNT = '4' WHERE CONCEPT_CODE = 3000888 AND DRUG_FORM = 'comprimé 20 mg'; -UPDATE P_C_AMOUNT SET AMOUNT = '4' WHERE CONCEPT_CODE = 3000888 AND DRUG_FORM = 'comprimé 10 mg'; -UPDATE P_C_AMOUNT SET AMOUNT = '19' WHERE CONCEPT_CODE = 3000888 AND DRUG_FORM = 'comprimé 30 mg'; -UPDATE P_C_AMOUNT SET AMOUNT = '28' WHERE CONCEPT_CODE = 3001606 AND DRUG_FORM = 'comprimé de 15 mg'; -UPDATE P_C_AMOUNT SET AMOUNT = '28' WHERE CONCEPT_CODE = 3001606 AND DRUG_FORM = 'comprimé de 45 mg'; -UPDATE P_C_AMOUNT SET AMOUNT = '28' WHERE CONCEPT_CODE = 3001609 AND DRUG_FORM = 'comprimé de 60 mg'; -UPDATE P_C_AMOUNT SET AMOUNT = '28' WHERE CONCEPT_CODE = 3001609 AND DRUG_FORM = 'comprimé de 30 mg'; -UPDATE P_C_AMOUNT SET AMOUNT = '28' WHERE CONCEPT_CODE = 3001611 AND DRUG_FORM = 'comprimé de 90 mg'; -UPDATE P_C_AMOUNT SET AMOUNT = '28' WHERE CONCEPT_CODE = 3001611 AND DRUG_FORM = 'comprimé de 30 mg'; -UPDATE P_C_AMOUNT SET AMOUNT = '10' WHERE CONCEPT_CODE = 3004510 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 3004510 AND DRUG_FORM = 'comprimé beige'; -UPDATE P_C_AMOUNT SET AMOUNT = '5' WHERE CONCEPT_CODE = 3004510 AND DRUG_FORM = 'comprimé marron foncé'; -UPDATE P_C_AMOUNT SET AMOUNT = '10' WHERE CONCEPT_CODE = 3004511 AND DRUG_FORM = 'comprimé blanc'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 3004511 AND DRUG_FORM = 'comprimé beige'; -UPDATE P_C_AMOUNT SET AMOUNT = '5' WHERE CONCEPT_CODE = 3004511 AND DRUG_FORM = 'comprimé marron foncé'; -UPDATE P_C_AMOUNT SET AMOUNT = '48' WHERE CONCEPT_CODE = 3272443 AND DRUG_FORM = 'gélule bleue gastro-soluble'; -UPDATE P_C_AMOUNT SET AMOUNT = '24' WHERE CONCEPT_CODE = 3273129 AND DRUG_FORM = 'gélule bleue gastro-soluble'; -UPDATE P_C_AMOUNT SET AMOUNT = '6' WHERE CONCEPT_CODE = 3759027 AND DRUG_FORM = 'solution à 8,8 microgrammes'; -UPDATE P_C_AMOUNT SET AMOUNT = NULL WHERE AMOUNT='99'; --- fix box_size -UPDATE p_c_amount SET box_size = 1 WHERE concept_code = '2761996'; -UPDATE p_c_amount SET box_size = 1 WHERE concept_code = '3184064'; -UPDATE p_c_amount SET box_size = 3 WHERE concept_code = '3184087'; -UPDATE p_c_amount SET box_size = 1 WHERE concept_code = '3254913'; -UPDATE p_c_amount SET box_size = 3 WHERE concept_code = '3254936'; -UPDATE p_c_amount SET box_size = 1 WHERE concept_code = '3280709'; -UPDATE p_c_amount SET box_size = 3 WHERE concept_code = '3280715'; -UPDATE p_c_amount SET box_size = 1 WHERE concept_code = '3305065'; -UPDATE p_c_amount SET box_size = 3 WHERE concept_code = '3305071'; -UPDATE p_c_amount SET box_size = 1 WHERE concept_code = '3305088'; -UPDATE p_c_amount SET box_size = 3 WHERE concept_code = '3305094'; -UPDATE p_c_amount SET box_size = 1 WHERE concept_code = '3584622'; -UPDATE p_c_amount SET box_size = 1 WHERE concept_code = '3588413'; -UPDATE p_c_amount SET box_size = 3 WHERE concept_code = '3588436'; -UPDATE p_c_amount SET box_size = 1 WHERE concept_code = '3589938'; -UPDATE p_c_amount SET box_size = 3 WHERE concept_code = '3589944'; -UPDATE p_c_amount SET box_size = 1 WHERE concept_code = '3589950'; -UPDATE p_c_amount SET box_size = 3 WHERE concept_code = '3589967'; -UPDATE p_c_amount SET box_size = 1 WHERE concept_code = '3715811'; -UPDATE p_c_amount SET box_size = 3 WHERE concept_code = '3715828'; -UPDATE p_c_amount SET box_size = 3 WHERE concept_code = '3770000'; -UPDATE p_c_amount SET box_size = 1 WHERE concept_code = '3899975'; -UPDATE p_c_amount SET box_size = 3 WHERE concept_code = '3899981'; -UPDATE p_c_amount SET box_size = 1 WHERE concept_code = '3909484'; -UPDATE p_c_amount SET box_size = 1 WHERE concept_code = '3918106'; -UPDATE p_c_amount SET box_size = 3 WHERE concept_code = '3918112'; -UPDATE p_c_amount SET box_size = NULL WHERE box_size=99; -END $_$; --insert results into pack_content table INSERT INTO pc_stage ( @@ -2674,139 +3128,92 @@ INSERT INTO pc_stage ( ) SELECT concept_code, pack_component_code, - amount, - box_size -FROM p_c_amount; + pack_amount_value::int, + null as box_size +FROM pack_cont_1 + ; ---concept_synonym_stage +-- add in concept_synonym_stage French name INSERT INTO concept_synonym_stage ( synonym_name, synonym_concept_code, synonym_vocabulary_id, language_concept_id ) -SELECT concept_name, +SELECT original_name, concept_code, 'BDPM', 4180190 -- French language -FROM ingr_translation_all - -UNION - -SELECT form_route, - concept_code, - 'BDPM', - 4180190 -FROM form_translation ft -JOIN drug_concept_stage dcs ON ft.translation = dcs.concept_name - -UNION - -SELECT concept_name, - concept_code, - 'BDPM', - 4180186 -FROM drug_concept_stage -WHERE concept_class_id != 'unit'; +FROM rtc_1 +join drug_concept_stage on upper(attr_name) = upper(concept_name) +where original_name is not null +; --- Create sequence for new OMOP-created standard concepts -DO $_$ -DECLARE - ex INTEGER; -BEGIN - SELECT MAX(replace(concept_code, 'OMOP','')::int4)+1 into ex FROM concept WHERE concept_code like 'OMOP%' and concept_code not like '% %'; - DROP SEQUENCE IF EXISTS new_vocab; - EXECUTE 'CREATE SEQUENCE new_vocab INCREMENT BY 1 START WITH ' || ex || ' NO CYCLE CACHE 20'; -END$_$; +-- +update drug_concept_stage d +set concept_name = trim(regexp_replace (c.concept_name, '\(\w+\-?\s?\w+?\)|EU$|A\/S\s\(\w+\-?\s?\w+?\)','')) +from drug_concept_stage c +where c.concept_code= d.concept_code +and d.concept_code in ( +select concept_code from drug_concept_stage +left join relationship_to_concept on concept_code = concept_code_1 +where concept_class_id = 'Supplier' +and concept_code_1 is null +); +--find code for attributes from previous iteration DROP TABLE IF EXISTS code_replace; CREATE TABLE code_replace AS -SELECT 'OMOP' || nextval('new_vocab') AS new_code, - concept_code AS old_code +SELECT distinct case when c.invalid_reason is null then min(c.concept_code) over (partition by c.concept_name) else min(c.concept_code) over (partition by c.concept_name) end AS new_code, + s0.concept_code AS old_code FROM ( - SELECT concept_code + SELECT concept_code, concept_name, vocabulary_id, concept_class_id FROM drug_concept_stage - WHERE concept_code LIKE 'OMOP%' or concept_code like '%PACK%' - GROUP BY concept_code - ORDER BY LPAD(concept_code, 50, '0') - ) AS s0; + WHERE concept_code LIKE 'OMOP%'-- or concept_code like '%PACK%' + ) AS s0 +join devv5.concept c on upper(s0.concept_name) = upper(c.concept_name) +where c.vocabulary_id = s0.vocabulary_id +and c.concept_class_id = s0.concept_class_id +union + select distinct 'OMOP' || nextval('new_vocab') as new_code, +dcs.concept_code as old_code + from drug_concept_stage dcs + where dcs.concept_code like 'PACK%' +; + UPDATE drug_concept_stage a SET concept_code = b.new_code FROM code_replace b WHERE a.concept_code = b.old_code; -UPDATE relationship_to_concept a -SET concept_code_1 = b.new_code -FROM code_replace b -WHERE a.concept_code_1 = b.old_code; - -UPDATE ds_stage a -SET ingredient_concept_code = b.new_code -FROM code_replace b -WHERE a.ingredient_concept_code = b.old_code; +UPDATE internal_relationship_stage c + SET concept_code_2 = new_code +FROM code_replace de +WHERE c.concept_code_2 = de.old_code; -UPDATE ds_stage a -SET drug_concept_code = b.new_code -FROM code_replace b -WHERE a.drug_concept_code = b.old_code; +UPDATE internal_relationship_stage c + SET concept_code_1 = new_code +FROM code_replace de +WHERE c.concept_code_1 = de.old_code; -UPDATE internal_relationship_stage a -SET concept_code_1 = b.new_code -FROM code_replace b -WHERE a.concept_code_1 = b.old_code; +UPDATE relationship_to_concept c + SET concept_code_1 = new_code +FROM code_replace de +WHERE c.concept_code_1 = de.old_code; -UPDATE internal_relationship_stage a -SET concept_code_2 = b.new_code -FROM code_replace b -WHERE a.concept_code_2 = b.old_code; +UPDATE ds_stage c + SET drug_concept_code = new_code +FROM code_replace de +WHERE drug_concept_code = de.old_code; -UPDATE pc_stage a -SET drug_concept_code = b.new_code -FROM code_replace b -WHERE a.drug_concept_code = b.old_code; +UPDATE pc_stage c + SET drug_concept_code = new_code +FROM code_replace de +WHERE drug_concept_code = de.old_code; -UPDATE drug_concept_stage -SET standard_concept = NULL -WHERE concept_code IN ( - SELECT concept_code - FROM drug_concept_stage - JOIN internal_relationship_stage ON concept_code_1 = concept_code - WHERE concept_class_id = 'Ingredient' - AND standard_concept IS NOT NULL - ); UPDATE drug_concept_stage SET concept_class_id = 'Drug Product' WHERE concept_class_id = 'Drug Pack'; -DELETE -FROM drug_concept_stage -WHERE concept_code IN ( - SELECT pack_concept_code - FROM pc_stage - - UNION ALL - - SELECT drug_concept_code - FROM pc_stage - ); - -DELETE -FROM internal_relationship_stage -WHERE concept_code_1 IN ( - SELECT pack_concept_code - FROM pc_stage - - UNION ALL - - SELECT drug_concept_code - FROM pc_stage - ); - -DELETE -FROM ds_stage -WHERE drug_concept_code IN ( - SELECT drug_concept_code - FROM pc_stage - ); From dc38a7b2800224f08943fbd42555691c354bb73a Mon Sep 17 00:00:00 2001 From: Timur Date: Mon, 18 Apr 2022 15:37:28 +0300 Subject: [PATCH 2/2] small refactoring --- BDPM/load_stage.sql | 4797 +++++++++++++++++++++++++------------------ 1 file changed, 2821 insertions(+), 1976 deletions(-) diff --git a/BDPM/load_stage.sql b/BDPM/load_stage.sql index edaebf09d..830518f87 100644 --- a/BDPM/load_stage.sql +++ b/BDPM/load_stage.sql @@ -1,3 +1,22 @@ +/************************************************************************** +* Copyright 2020 Observational Health Data Sciences and Informatics (OHDSI) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Authors: Dmitry Dymshyts +* Date: 2022 +**************************************************************************/ + DO $_$ BEGIN PERFORM VOCABULARY_PACK.SetLatestUpdate( @@ -23,84 +42,88 @@ TRUNCATE TABLE pc_stage; TRUNCATE TABLE concept_synonym_stage; --do vaccines and insulins manually -DROP TABLE if exists bdpm_vaccine_manual; - -CREATE TABLE bdpm_vaccine_manual -AS +DROP TABLE IF EXISTS bdpm_vaccine_manual; +CREATE TABLE bdpm_vaccine_manual AS SELECT a.din_7, - a.drug_code, - form_code, - ingredient, - dosage, - volume, - drug_descr, - packaging, - manufacturer, - NULL::INTEGER AS c_id, - NULL::VARCHAR AS c_code, - NULL::VARCHAR AS c_name -from sources.bdpm_packaging a -join sources.bdpm_drug b using(drug_code) -join sources.bdpm_ingredient c using(drug_code) -WHERE ingredient ~* 'POLYOSIDE|HAEMOPHILUS|VARICELLE|influenzae|virus|insulin|ANATOXINE|PAPILLOMAVIRUS|RABIQUE|BORDETELLA|PERTUSS|STREPTOCOCCUS PNEUMONIAE|ROTAVIRUS|POLIOMYELITIQUE' -OR drug_descr ~* 'vacin|vaccin|infanrix|influvac|boostrix|menveo|HBVAXPRO' -or form_code in ('96983','85085','97363','76197','82142','99920') -; - - + a.drug_code, + c.form_code, + c.ingredient, + c.dosage, + c.volume, + b.drug_descr, + a.packaging, + b.manufacturer, + NULL::INTEGER AS c_id, + NULL::VARCHAR AS c_code, + NULL::VARCHAR AS c_name +FROM sources.bdpm_packaging a +JOIN sources.bdpm_drug b ON b.drug_code = a.drug_code +JOIN sources.bdpm_ingredient c ON c.drug_code = a.drug_code +WHERE c.ingredient ~* 'POLYOSIDE|HAEMOPHILUS|VARICELLE|influenzae|virus|insulin|ANATOXINE|PAPILLOMAVIRUS|RABIQUE|BORDETELLA|PERTUSS|STREPTOCOCCUS PNEUMONIAE|ROTAVIRUS|POLIOMYELITIQUE' + OR b.drug_descr ~* 'vacin|vaccin|infanrix|influvac|boostrix|menveo|HBVAXPRO' + OR c.form_code IN ( + '96983', + '85085', + '97363', + '76197', + '82142', + '99920' + ); --fill non_drug table with devices DROP TABLE IF EXISTS non_drug; CREATE TABLE non_drug AS -SELECT b.drug_code, +SELECT a.drug_code, + b.drug_descr, + a.ingredient, + b.form, + a.form_code +FROM sources.bdpm_ingredient a +JOIN sources.bdpm_drug b ON b.drug_code = a.drug_code +WHERE ( + a.form_code IN ( + '4307', + '9354', + '77898', + '87188', + '94901', + '41804', + '14832', + '72310', + '89969', + '49487', + '24033', + '31035', + '66548', + '16621', + '31035', + '75145' + ) + OR a.dosage LIKE '%Bq%' + OR b.form LIKE '%dialyse%' + ); + +--add radiopharmaceutical drugs +INSERT INTO non_drug ( + drug_code, drug_descr, ingredient, form, form_code -FROM sources.bdpm_ingredient a -JOIN sources.bdpm_drug b ON a.drug_code = b.drug_code -WHERE (form_code IN ( - '4307', - '9354', - '77898', - '87188', - '94901', - '41804', - '14832', - '72310', - '89969', - '49487', - '24033', - '31035', - '66548', - '16621', - '31035', - '75145' - ) - OR dosage LIKE '%Bq%' - OR form LIKE '%dialyse%') -; - ---add radiopharmaceutical drugs -INSERT INTO non_drug -( - drug_code, - drug_descr, - ingredient, - form, - form_code -) + ) SELECT a.drug_code, - drug_descr, - ingredient, - form, - form_code + a.drug_descr, + b.ingredient, + a.form, + b.form_code FROM sources.bdpm_drug a - JOIN sources.bdpm_ingredient b ON a.drug_code = b.drug_code +JOIN sources.bdpm_ingredient b ON b.drug_code = a.drug_code WHERE form LIKE '%radio%' -AND a.drug_code::INTEGER NOT IN (66364008) -AND a.drug_code NOT IN (SELECT drug_code FROM non_drug); - + AND a.drug_code <> '66364008' + AND a.drug_code NOT IN ( + SELECT drug_code + FROM non_drug + ); --ingredients used in diagnostics INSERT INTO non_drug ( @@ -111,33 +134,36 @@ INSERT INTO non_drug ( form_code ) SELECT a.drug_code, - drug_descr, - ingredient, - form, - form_code + a.drug_descr, + b.ingredient, + a.form, + b.form_code FROM sources.bdpm_drug a -JOIN sources.bdpm_ingredient b ON a.drug_code = b.drug_code -WHERE (ingredient ILIKE '%IOXITALAM%' - OR ingredient ILIKE '%GADOTÉR%' - OR ingredient ILIKE '%AMIDOTRIZOATE%' - OR ingredient ILIKE '%CARBOM%' - or (ingredient ILIKE '%123%' --and ingredient ILIKE '%IOD%' - ) - OR form_code='86327') +JOIN sources.bdpm_ingredient b ON b.drug_code = a.drug_code +WHERE ( + b.ingredient ILIKE '%IOXITALAM%' + OR b.ingredient ILIKE '%GADOTÉR%' + OR b.ingredient ILIKE '%AMIDOTRIZOATE%' + OR b.ingredient ILIKE '%CARBOM%' + OR ( + b.ingredient LIKE '%123%' --and ingredient ILIKE '%IOD%' + ) + OR b.form_code = '86327' + ) AND a.drug_code NOT IN ( SELECT drug_code FROM non_drug ); - + --patterns for dosages INSERT INTO non_drug ( drug_code, ingredient, form_code ) -SELECT DISTINCT drug_code, - ingredient, - form_code +SELECT DISTINCT a.drug_code, + a.ingredient, + a.form_code FROM sources.bdpm_ingredient a WHERE a.drug_code IN ( SELECT drug_code @@ -145,20 +171,19 @@ WHERE a.drug_code IN ( WHERE packaging LIKE '%compartiment%' ) AND ( - drug_form LIKE '%compartiment%' - OR drug_form = '%émulsion%' + a.drug_form LIKE '%compartiment%' + OR a.drug_form = '%émulsion%' ) - AND drug_form NOT LIKE '%compartiment A%' - AND drug_form NOT LIKE '%compartiment B%' - AND drug_form NOT LIKE '%compartiment C%' - AND drug_form NOT LIKE '%compartiment (A)%' - AND drug_form NOT LIKE '%compartiment (B)%' + AND a.drug_form NOT LIKE '%compartiment A%' + AND a.drug_form NOT LIKE '%compartiment B%' + AND a.drug_form NOT LIKE '%compartiment C%' + AND a.drug_form NOT LIKE '%compartiment (A)%' + AND a.drug_form NOT LIKE '%compartiment (B)%' AND a.drug_code NOT IN ( SELECT drug_code FROM non_drug ); - --nutrients INSERT INTO non_drug ( drug_code, @@ -168,19 +193,17 @@ INSERT INTO non_drug ( form_code ) SELECT a.drug_code, - drug_descr, - ingredient, - form, - form_code + a.drug_descr, + b.ingredient, + a.form, + b.form_code FROM sources.bdpm_drug a -JOIN sources.bdpm_ingredient b ON a.drug_code = b.drug_code - where a.drug_code NOT IN ( +JOIN sources.bdpm_ingredient b ON b.drug_code = a.drug_code +WHERE a.drug_code NOT IN ( SELECT drug_code FROM non_drug ) -and form ~* ' entéral|tisane|émulsion pour perfusion' -; - + AND a.form ~* ' entéral|tisane|émulsion pour perfusion'; --some patterns INSERT INTO non_drug ( @@ -191,17 +214,17 @@ INSERT INTO non_drug ( form_code ) SELECT a.drug_code, - drug_descr, - ingredient, - form, - form_code + a.drug_descr, + b.ingredient, + a.form, + b.form_code FROM sources.bdpm_drug a -JOIN sources.bdpm_ingredient b ON a.drug_code = b.drug_code - where a.drug_code NOT IN ( +JOIN sources.bdpm_ingredient b ON b.drug_code = a.drug_code +WHERE a.drug_code NOT IN ( SELECT drug_code FROM non_drug ) -and ingredient ~* 'ÉTHANOL|TYROSINE|PARAFFINE|COLLOÏDAL|GLUTAMINE|LYSINE|GLYCINE|CHLORE ACTIF|ALCOOL|ALANINE'; + AND b.ingredient ~* 'ÉTHANOL|TYROSINE|PARAFFINE|COLLOÏDAL|GLUTAMINE|LYSINE|GLYCINE|CHLORE ACTIF|ALCOOL|ALANINE'; --some patterns INSERT INTO non_drug ( @@ -212,18 +235,18 @@ INSERT INTO non_drug ( form_code ) SELECT a.drug_code, - drug_descr, - ingredient, - form, - form_code + a.drug_descr, + b.ingredient, + a.form, + b.form_code FROM sources.bdpm_drug a -LEFT JOIN sources.bdpm_ingredient b ON a.drug_code = b.drug_code - where a.drug_code NOT IN ( +LEFT JOIN sources.bdpm_ingredient b ON b.drug_code = a.drug_code +WHERE a.drug_code NOT IN ( SELECT drug_code FROM non_drug ) -and drug_descr ~* 'ULTRAVIST|IOPAMIRON|OMNISCAN|VISIPAQUE|PROTOXYDE D''AZOTE|OMNIPAQUE|ISOVOL|BIONOLYTE|OXYGENE MEDICINAL|PRIMENE|MEDNUTRIFLEX|AMINOPLASMAL' -; + AND a.drug_descr ~* 'ULTRAVIST|IOPAMIRON|OMNISCAN|VISIPAQUE|PROTOXYDE D''AZOTE|OMNIPAQUE|ISOVOL|BIONOLYTE|OXYGENE MEDICINAL|PRIMENE|MEDNUTRIFLEX|AMINOPLASMAL'; + --some patterns INSERT INTO non_drug ( drug_code, @@ -233,39 +256,46 @@ INSERT INTO non_drug ( form_code ) SELECT a.drug_code, - drug_descr, - ingredient, + a.drug_descr, + b.ingredient, form, form_code FROM sources.bdpm_drug a -JOIN sources.bdpm_ingredient b ON a.drug_code = b.drug_code -WHERE drug_descr ~* 'CELSIOR|PLASMALYTE|POLYIONIQUE|PLASMION|ISOPEDIA|ISOFUNDINE|hémofiltration|AMINOMIX|dialys|test|radiopharmaceutique|STRUCTOKABIVEN|NUMETAN|NUMETAH|REANUTRIFLEX|CLINIMIX|REVITALOSE|CONTROLE|IOMERON|HEXABRIX|XENETIX' +JOIN sources.bdpm_ingredient b ON b.drug_code = a.drug_code +WHERE a.drug_descr ~* 'CELSIOR|PLASMALYTE|POLYIONIQUE|PLASMION|ISOPEDIA|ISOFUNDINE|hémofiltration|AMINOMIX|dialys|test|radiopharmaceutique|STRUCTOKABIVEN|NUMETAN|NUMETAH|REANUTRIFLEX|CLINIMIX|REVITALOSE|CONTROLE|IOMERON|HEXABRIX|XENETIX' AND a.drug_code NOT IN ( SELECT drug_code FROM non_drug ) - --exclude radiopharmacuetical approved drug and testosterone -and a.drug_code::integer not in (66364008,68804011,69909645,69690774,61637467) -; - - + --exclude radiopharmacuetical approved drug and testosterone + AND a.drug_code NOT IN ( + '66364008', + '68804011', + '69909645', + '69690774', + '61637467' + ); --create table with homeopathic drugs, they won't be processed DROP TABLE IF EXISTS homeop_drug; - -CREATE TABLE homeop_drug -AS +CREATE TABLE homeop_drug AS SELECT a.* FROM sources.bdpm_ingredient a - JOIN sources.bdpm_drug b ON a.drug_code = b.drug_code -WHERE (ingredient LIKE '%HOMÉOPA%' OR drug_descr LIKE '%degré de dilution compris entre%' OR certifier LIKE '%Enreg homéo%') -AND a.drug_code NOT IN (SELECT drug_code - FROM non_drug - UNION - SELECT drug_code - FROM bdpm_vaccine_manual); - - +JOIN sources.bdpm_drug b ON b.drug_code = a.drug_code +WHERE ( + a.ingredient LIKE '%HOMÉOPA%' + OR b.drug_descr LIKE '%degré de dilution compris entre%' + OR b.certifier LIKE '%Enreg homéo%' + ) + AND a.drug_code NOT IN ( + SELECT drug_code + FROM non_drug + + UNION ALL + + SELECT drug_code + FROM bdpm_vaccine_manual + ); --collect package information and start extract quantity of drugs DROP TABLE IF EXISTS packaging_pars_1; @@ -274,92 +304,109 @@ SELECT din_7, drug_code, packaging, CASE - WHEN packaging ~ '^[[:digit:].,]+\s*(mg|g|ml|litre|l)(\s|$|\,)' - THEN substring(packaging, '(^[[:digit:].,]+\s*(mg|g|ml|litre|l))') - ELSE substring(packaging, 'de.*') + WHEN packaging ~ '^[[:digit:].,]+\s*(mg|g|ml|litre|l)(\s|$|,)' + THEN SUBSTRING(packaging, '(^[[:digit:].,]+\s*(mg|g|ml|litre|l))') + ELSE SUBSTRING(packaging, 'de.*') END AS amount, CASE - WHEN NOT packaging ~ '^\d+\s*(mg|g|ml|litre|l)(\s|$|\,)' - AND substring(packaging, '^\d+')!='0' - THEN substring(packaging, '^\d+') - When packaging ~ 'boîte\sde\s\d+|de\s\d*flacon' then substring(packaging, 'boîte\sde\s(\d+)|e\s(\d*)flacon') + WHEN NOT packaging ~ '^\d+\s*(mg|g|ml|litre|l)(\s|$|,)' + AND SUBSTRING(packaging, '^\d+') <> '0' + THEN SUBSTRING(packaging, '^\d+') + WHEN packaging ~ 'boîte\sde\s\d+|de\s\d*flacon' + THEN SUBSTRING(packaging, 'boîte\sde\s(\d+)|e\s(\d*)flacon') ELSE NULL - END::INT AS box_size + END::INT2 AS box_size FROM sources.bdpm_packaging - where drug_code NOT IN ( +WHERE drug_code NOT IN ( SELECT drug_code FROM non_drug - ) - and drug_code NOT IN ( + ) + AND drug_code NOT IN ( SELECT drug_code FROM bdpm_vaccine_manual - ) - and drug_code NOT IN ( + ) + AND drug_code NOT IN ( SELECT drug_code FROM homeop_drug - ) -; + ); --remove spaces in amount UPDATE packaging_pars_1 -SET amount = regexp_replace(amount, '([[:digit:]]+) ([[:digit:]]+)', '\1\2') +SET amount = REGEXP_REPLACE(amount, '([[:digit:]]+) ([[:digit:]]+)', '\1\2') --select * from packaging_pars_1 WHERE amount ~ '[[:digit:]]+ [[:digit:]]+'; - -- define box size and quantity factor of drugs DROP TABLE IF EXISTS packaging_pars_2; CREATE TABLE packaging_pars_2 AS -SELECT - CASE - WHEN NOT p.amount ~* '[[:digit:].,]+\s*(ml|g|mg|l|UI|MBq/ml|GBq/ml|litre(s*)|à|mlavec|kg)(\s|$|\,)' - and p.amount !~* 'dose' - AND (replace(substring(p.amount, '[[:digit:].,]+'), ',', '.')) IS NOT NULL - THEN substring(p.amount, '\d+')::INT * coalesce(box_size, 1) +SELECT CASE + WHEN NOT p.amount ~* '[[:digit:].,]+\s*(ml|g|mg|l|UI|MBq/ml|GBq/ml|litre(s*)|à|mlavec|kg)(\s|$|,)' + AND p.amount NOT ILIKE '%dose%' + AND SUBSTRING(p.amount, '[[:digit:].,]+') IS NOT NULL + THEN SUBSTRING(p.amount, '\d+')::INT2 * COALESCE(box_size, 1) ELSE box_size END AS box_size, - l.amount, - din_7, - drug_code, - packaging + l.amount, + p.din_7, + p.drug_code, + p.packaging FROM packaging_pars_1 p -LEFT JOIN LATERAL( - SELECT unnest(regexp_matches(p.amount, '([[:digit:].,]+\s*(?:ml|g|mg|l|UI|MBq/ml|GBq/ml|litres|kg))(?:\s|$|\,)', 'i')) - AS amount) l ON true -; +LEFT JOIN LATERAL(SELECT UNNEST(REGEXP_MATCHES(p.amount, '([[:digit:].,]+\s*(?:ml|g|mg|l|UI|MBq/ml|GBq/ml|litres|kg))(?:\s|$|,)', 'i')) AS amount) l ON TRUE; -- find proper amount for inhalation drugs -drop table if exists pack_inh; -create table pack_inh as -select box_size, case when amount in ('1 dose','1 dose') then null else amount end as amount ,din_7,drug_code,packaging -from ( -select box_size, substring(packaging, '(\d+\s*dose)') as amount,din_7,drug_code,packaging -from packaging_pars_2 -where packaging ~* 'dose' and amount is null) a ; +DROP TABLE IF EXISTS pack_inh; +CREATE TABLE pack_inh AS +SELECT box_size, + CASE + WHEN amount IN ( + '1 dose', + '1 dose' + ) + THEN NULL + ELSE amount + END AS amount, + din_7, + drug_code, + packaging +FROM ( + SELECT box_size, + SUBSTRING(packaging, '(\d+\s*dose)') AS amount, + din_7, + drug_code, + packaging + FROM packaging_pars_2 + WHERE packaging ILIKE '%dose%' + AND amount IS NULL + ) a; -delete from packaging_pars_2 where (din_7,drug_code) in ( -select din_7,drug_code -from pack_inh); - -insert into packaging_pars_2 -select * from pack_inh; +DELETE +FROM packaging_pars_2 +WHERE ( + din_7, + drug_code + ) IN ( + SELECT din_7, + drug_code + FROM pack_inh + ); +INSERT INTO packaging_pars_2 +SELECT * +FROM pack_inh; --pars amount to value and unit DROP TABLE IF EXISTS packaging_pars_3; CREATE TABLE packaging_pars_3 AS -SELECT replace(substring(amount, '[[:digit:].,]+'), ',', '.')::FLOAT AS amount_value, +SELECT REPLACE(SUBSTRING(amount, '[[:digit:].,]+'), ',', '.')::NUMERIC AS amount_value, l.amount_unit, box_size, din_7, drug_code, packaging FROM packaging_pars_2 -LEFT JOIN LATERAL(SELECT unnest(regexp_matches(amount, '(ml|g|mg|l|UI|MBq/ml|GBq/ml|litre(?:s*)|kg|dose)', 'i')) AS amount_unit) l ON true; +LEFT JOIN LATERAL(SELECT UNNEST(REGEXP_MATCHES(amount, '(ml|g|mg|l|UI|MBq/ml|GBq/ml|litre(?:s*)|kg|dose)', 'i')) AS amount_unit) l ON TRUE; --manual fix - - UPDATE packaging_pars_3 SET amount_value = '1', amount_unit = 'ml' @@ -378,7 +425,6 @@ SET amount_value = '5', WHERE din_7 = 5500092 AND packaging = 'système à double seringues (polypropylène) 1 * 10 ml (5 ml + 5 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application'; - UPDATE packaging_pars_3 SET amount_value = '20', amount_unit = 'ml' @@ -402,8 +448,6 @@ SET amount_value = '3', amount_unit = 'ml' WHERE din_7 = 5611116 AND packaging = '2 poudres en flacons en verre et 2 fois 3 ml de solution en flacons en verre avec nécessaire d''application'; - - --find relationships between ingredients within the one drug DROP TABLE IF EXISTS drug_ingred_to_ingred; @@ -414,13 +458,13 @@ SELECT DISTINCT a.drug_code, b.form_code AS concept_code_2, b.ingredient AS concept_name_2 FROM sources.bdpm_ingredient a -join sources.bdpm_packaging using(drug_code) -JOIN sources.bdpm_ingredient b ON a.drug_code = b.drug_code +JOIN sources.bdpm_packaging USING (drug_code) +JOIN sources.bdpm_ingredient b ON b.drug_code = a.drug_code AND a.comp_number = b.comp_number - AND a.ingredient != b.ingredient + AND a.ingredient <> b.ingredient AND a.ingr_nature = 'SA' AND b.ingr_nature = 'FT' -where a.drug_code NOT IN ( +WHERE a.drug_code NOT IN ( SELECT drug_code FROM homeop_drug ) @@ -430,22 +474,20 @@ where a.drug_code NOT IN ( ) AND a.drug_code NOT IN ( SELECT drug_code - FROM bdpm_vaccine_manual) - - -; + FROM bdpm_vaccine_manual + ); --exclude homeopic_drugs and precise ingredients DROP TABLE IF EXISTS ingredient_step_1; CREATE TABLE ingredient_step_1 AS SELECT a.* FROM sources.bdpm_ingredient a -join sources.bdpm_packaging using(drug_code) +JOIN sources.bdpm_packaging USING (drug_code) WHERE NOT EXISTS ( SELECT 1 FROM drug_ingred_to_ingred b - WHERE a.drug_code = b.drug_code::varchar - AND form_code = concept_code_1::varchar + WHERE a.drug_code = b.drug_code + AND form_code = concept_code_1 ) AND drug_code NOT IN ( SELECT drug_code @@ -457,8 +499,8 @@ WHERE NOT EXISTS ( ) AND drug_code NOT IN ( SELECT drug_code - FROM bdpm_vaccine_manual) -; + FROM bdpm_vaccine_manual + ); --manual fix of dosages UPDATE ingredient_step_1 @@ -473,22 +515,22 @@ WHERE form_code = '04031' UPDATE ingredient_step_1 SET dosage = '30000000 U' -WHERE drug_code='60973899'; +WHERE drug_code = '60973899'; --spaces in dosages UPDATE ingredient_step_1 -SET dosage = regexp_replace(dosage, '(?<=[[:digit:],])\s(?=[[:digit:],])', '', 'g') +SET dosage = REGEXP_REPLACE(dosage, '(?<=[[:digit:],])\s(?=[[:digit:],])', '', 'g') WHERE dosage ~ '[[:digit:],]+ [[:digit:],]+'; --spaces in volume UPDATE ingredient_step_1 -SET volume = regexp_replace(volume, '(?<=[[:digit:],])\s(?=[[:digit:],])', '', 'g') +SET volume = REGEXP_REPLACE(volume, '(?<=[[:digit:],])\s(?=[[:digit:],])', '', 'g') WHERE volume ~ '[[:digit:],]+ [[:digit:],]+'; --manual fix of dosages UPDATE ingredient_step_1 SET dosage = '31250000000 U' -WHERE dosage like '31,25 * 10^9%'; +WHERE dosage LIKE '31,25 * 10^9%'; UPDATE ingredient_step_1 SET dosage = '800000 UFC' @@ -524,584 +566,1171 @@ SELECT drug_code, WHEN '19.000.000' THEN '19000' ELSE dosage_value - END::FLOAT dosage_value, + END::NUMERIC AS dosage_value, dosage_unit, volume_value, volume_unit FROM ( SELECT a.*, - replace(substring(dosage, '([[:digit:].,]+)\s*(UI|UFC|IU|micromoles|µmol|g|mg|mcg|microgramme(s*)|µg|millions UI|MBq|DICC50|UIK|unités FEIBA|Gbq|UFP|U\.CEIP|ml|U|IR|unités Antihéparine|log DICC50|nanogrammes|M(\.|\s)U\.I\.|UD (unité antigène D)|MU|Ul|unités|%|U\.I\.|ATU|mmol|mEq|DL50|U\.l\.|unités|MUI|U\.|unités antigène D|Millions UI|ppm mole|UI|kBq|SQ-T|milliard|microlitres|nanokatals|UD \(unité antigène D\)|unité antigène D|M UI|DICT50|micrcrogrammes|GBq|mg.|M.UI|MBq/ml|UD|UIK.|Mq|millions d.UI|U.I|U.D.|ng)(\s|$)'), ',', '.') AS dosage_value, - substring(dosage, '[[:digit:].,]+\s*((UI|UFC|micromoles|IU|µmol|g|mg|mcg|microgramme(s*)|µg|millions UI|MBq|DICC50|UIK|unités FEIBA|Gbq|UFP|U\.CEIP|ml|U|IR|unités Antihéparine|log DICC50|nanogrammes|M(\.|\s)U\.I\.|UD (unité antigène D)|MU|Ul|unités|%|U\.I\.|ATU|mmol|mEq|DL50|U\.l\.|unités|MUI|U\.|unités antigène D|Millions UI|ppm mole|UI|kBq|SQ-T|milliard|microlitres|nanokatals|UD \(unité antigène D\)|unité antigène D|M UI|DICT50|micrcrogrammes|GBq|mg.|M.UI|MBq/ml|UD|UIK.|Mq|millions d.UI|U.I|U.D.|ng)(\s|$))') AS dosage_unit, - replace(substring(volume, '([[:digit:].,]+)\s*(cm *²|g|ml|cm\^2)') -- for denominartor - , ',', '.')::FLOAT AS volume_value, - substring(volume, '[[:digit:].,]+\s*(cm *²|g|ml|cm\^2)') AS volume_unit + REPLACE(SUBSTRING(dosage, '([[:digit:].,]+)\s*(UI|UFC|IU|micromoles|µmol|g|mg|mcg|microgramme(s*)|µg|millions UI|MBq|DICC50|UIK|unités FEIBA|Gbq|UFP|U\.CEIP|ml|U|IR|unités Antihéparine|log DICC50|nanogrammes|M(\.|\s)U\.I\.|UD (unité antigène D)|MU|Ul|unités|%|U\.I\.|ATU|mmol|mEq|DL50|U\.l\.|unités|MUI|U\.|unités antigène D|Millions UI|ppm mole|UI|kBq|SQ-T|milliard|microlitres|nanokatals|UD \(unité antigène D\)|unité antigène D|M UI|DICT50|micrcrogrammes|GBq|mg.|M.UI|MBq/ml|UD|UIK.|Mq|millions d.UI|U.I|U.D.|ng)(\s|$)'), ',', '.') AS dosage_value, + SUBSTRING(dosage, '[[:digit:].,]+\s*((UI|UFC|micromoles|IU|µmol|g|mg|mcg|microgramme(s*)|µg|millions UI|MBq|DICC50|UIK|unités FEIBA|Gbq|UFP|U\.CEIP|ml|U|IR|unités Antihéparine|log DICC50|nanogrammes|M(\.|\s)U\.I\.|UD (unité antigène D)|MU|Ul|unités|%|U\.I\.|ATU|mmol|mEq|DL50|U\.l\.|unités|MUI|U\.|unités antigène D|Millions UI|ppm mole|UI|kBq|SQ-T|milliard|microlitres|nanokatals|UD \(unité antigène D\)|unité antigène D|M UI|DICT50|micrcrogrammes|GBq|mg.|M.UI|MBq/ml|UD|UIK.|Mq|millions d.UI|U.I|U.D.|ng)(\s|$))') AS dosage_unit, + REPLACE(SUBSTRING(volume, '([[:digit:].,]+)\s*(cm *²|g|ml|cm\^2)') -- for denominartor + , ',', '.')::NUMERIC AS volume_value, + SUBSTRING(volume, '[[:digit:].,]+\s*(cm *²|g|ml|cm\^2)') AS volume_unit FROM ingredient_step_1 a ) AS s; - -- find form of salts DROP TABLE if exists upd_calc; - -CREATE TABLE upd_calc -AS -SELECT distinct a.drug_code, - a.drug_form, - FIRST_VALUE(b.form_code) OVER (PARTITION BY a.drug_code ORDER BY b.form_code) AS form_code, - FIRST_VALUE(b.ingredient) OVER (PARTITION BY a.drug_code ORDER BY b.form_code) AS ingredient, - a.dosage, - a.volume, - a.ingr_nature, - a.comp_number, - a.dosage_value, - a.dosage_unit, - a.volume_value, - a.volume_unit, - a.form_Code AS old_code, - a.ingredient +CREATE TABLE upd_calc AS +SELECT DISTINCT a.drug_code, + a.drug_form, + FIRST_VALUE(b.form_code) OVER ( + PARTITION BY a.drug_code ORDER BY b.form_code + ) AS form_code, + FIRST_VALUE(b.ingredient) OVER ( + PARTITION BY a.drug_code ORDER BY b.form_code + ) AS ingredient, + a.dosage, + a.volume, + a.ingr_nature, + a.comp_number, + a.dosage_value, + a.dosage_unit, + a.volume_value, + a.volume_unit, + a.form_code AS old_code FROM ingredient_step_2 a - JOIN sources.bdpm_ingredient b USING (drug_code) -WHERE a.ingredient in ('CALCIUM ÉLÉMENT','POTASSIUM') -and (b.ingredient like '%CALCIUM%' or b.ingredient like '%POTASSIUM%') -and a.form_code != b.form_code; - +JOIN sources.bdpm_ingredient b USING (drug_code) +WHERE a.ingredient IN ( + 'CALCIUM ÉLÉMENT', + 'POTASSIUM' + ) + AND ( + b.ingredient LIKE '%CALCIUM%' + OR b.ingredient LIKE '%POTASSIUM%' + ) + AND a.form_code <> b.form_code; DELETE FROM ingredient_step_2 -WHERE (drug_code,form_code) IN (SELECT drug_code, old_code FROM upd_calc); - +WHERE ( + drug_code, + form_code + ) IN ( + SELECT drug_code, + old_code + FROM upd_calc + ); -INSERT INTO ingredient_step_2 -( - drug_code, - drug_form, - form_code, - ingredient, - dosage, - volume, - ingr_nature, - comp_number, - dosage_value, - dosage_unit, - volume_value, - volume_unit -) +INSERT INTO ingredient_step_2 ( + drug_code, + drug_form, + form_code, + ingredient, + dosage, + volume, + ingr_nature, + comp_number, + dosage_value, + dosage_unit, + volume_value, + volume_unit + ) SELECT drug_code, - drug_form, - form_code, - ingredient, - dosage, - volume, - ingr_nature, - comp_number, - dosage_value, - dosage_unit, - volume_value, - volume_unit + drug_form, + form_code, + ingredient, + dosage, + volume, + ingr_nature, + comp_number, + dosage_value, + dosage_unit, + volume_value, + volume_unit FROM upd_calc; - - --recalculate all the possible combinations between packaging info and ingredient info -DROP TABLE if exists ds_1_1; - -CREATE TABLE ds_1_1 -AS -select COUNT(ingredient_code) OVER (PARTITION BY concept_code) AS c1,* from -( -SELECT DISTINCT din_7::VARCHAR AS concept_code, - a.drug_code, - drug_form, - form_code AS ingredient_code, - ingredient AS ingredient_name, - packaging, - d.drug_descr, - dosage_value, - dosage_unit, - CASE - WHEN volume_value IS NULL THEN 1 - ELSE volume_value - END AS volume_value, - volume_unit, - CASE - WHEN volume_value IS NULL AND amount_value IS NULL THEN dosage_value - ELSE NULL - END AS amount_value, - CASE - WHEN volume_value IS NULL AND amount_value IS NULL THEN dosage_unit - ELSE NULL - END AS amount_unit, - CASE - WHEN COUNT(ingredient) OVER (PARTITION BY a.din_7) > 1 AND (amount_value IS NOT NULL OR amount_unit NOT IN ('ml','mL','g')) THEN dosage_value::VARCHAR - WHEN COUNT(ingredient) OVER (PARTITION BY a.din_7) > 1 AND amount_value IS NULL then dosage_value::VARCHAR - WHEN drug_descr ~ '%' THEN TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'(\d+?\s?\,?\.?\d*\s?)%'),',','.'),' ','')) - WHEN amount_unit ~ 'dose\(s\)' THEN dosage_value::VARCHAR - WHEN drug_descr ~ '\/\d?\s?\,?\d+\s(mL|ml|l|heures)' AND COUNT(ingredient) OVER (PARTITION BY a.din_7) = 1 THEN TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'(\d+?\s?\,?\.?\d*\s)(mg|g|microgrammes|UI|unités|U)\/\d?\s?\,?\d+\s?(ml|mL|l|dose|g|heures)'),',','.'),' ','')) - ELSE TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'(\d+?\s?\,?\.?\d*\s)(ppm mole|mg|g|microgrammes|UI|unités|U)\/(1)?\s?(ml|mL|dose|mole|l|g)'),',','.'),' ','')) - END AS numerator_value, - CASE - WHEN COUNT(ingredient) OVER (PARTITION BY a.din_7) > 1 AND (amount_value IS NOT NULL OR amount_unit NOT IN ('ml','mL','g')) THEN dosage_unit - WHEN COUNT(ingredient) OVER (PARTITION BY a.din_7) > 1 AND amount_value IS NULL then dosage_unit - WHEN drug_descr ~ '%' THEN TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'\d+?\s?\,?\.?\d*\s?(%)'),',','.'),' ','')) - WHEN amount_unit ~ 'dose\(s\)' THEN dosage_unit - WHEN drug_descr ~ '\/\d?\s?\,?\d+\s(mL|ml|l|heures)' AND COUNT(ingredient) OVER (PARTITION BY a.din_7) = 1 THEN TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'\d+?\s?\,?\.?\d*\s(mg|g|microgrammes|UI|unités|U)\/\d?\s?\,?\d+\s?(ml|mL||ldose|g|heures)'),',','.'),' ','')) - ELSE SUBSTRING(drug_descr,'\d+?\s?\,?\.?\d*\s(ppm mole|mg|g|microgrammes|UI|unités|U)\/(1)?\s?(ml|mL|dose|mole|l|g)') - END AS numerator_unit, - CASE - WHEN drug_descr ~ '\/\s?\d?\s?\,?\d+?\s(mL|ml|l|heures)' AND COUNT(ingredient) OVER (PARTITION BY a.din_7) = 1 THEN TRIM(/*REGEXP_REPLACE(*/REGEXP_REPLACE(SUBSTRING(drug_descr,'\/\s?(\d?\s?\,?\d+?)\s?(ml|mL|l|dose|g|heures)'),',','.')/*,' ','')*/) - ELSE NULL - END AS denom, - CASE - WHEN drug_descr ~ '\/\s?\d?\s?\,?\d+\s(mL|ml|l|heures)' AND COUNT(ingredient) OVER (PARTITION BY a.din_7) = 1 THEN TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'\/\d?\s?\,?\d+\s?(ml|mL|l|dose|g|heures)'),',','.'),' ','')) -when drug_descr ~ '\d+?\s?\,?\.?\d*\s((ppm mole|mg|g|microgrammes|UI|unités|U))\/(1)?\s?(ml|mL|dose|mole|l|g)' then SUBSTRING(drug_descr, '\/1?\s?(ml|mL|mole|l|dose|g)') -ELSE NULL - END AS denom_unit, - CASE - WHEN amount_unit NOT IN ('ml','mL','g','dose') THEN NULL - ELSE amount_value - END AS fut_denominator_value, - CASE - WHEN amount_unit NOT IN ('ml','mL','g','dose') THEN NULL - ELSE amount_unit - END AS fut_denominator_unit, - box_size -FROM packaging_pars_3 a - JOIN ingredient_step_2 b ON a.drug_code = b.drug_code - JOIN sources.bdpm_drug d - ON b.drug_code = d.drug_code - AND a.drug_code NOT IN (SELECT drug_code FROM non_drug - union SELECT drug_code FROM bdpm_vaccine_manual - union - select drug_code - from homeop_drug) - )d -; +DROP TABLE IF EXISTS ds_1_1; +CREATE TABLE ds_1_1 AS +SELECT COUNT(ingredient_code) OVER (PARTITION BY concept_code) AS c1, + * +FROM ( + SELECT DISTINCT din_7::VARCHAR AS concept_code, + a.drug_code, + drug_form, + form_code AS ingredient_code, + ingredient AS ingredient_name, + packaging, + d.drug_descr, + dosage_value, + dosage_unit, + CASE + WHEN volume_value IS NULL + THEN 1 + ELSE volume_value + END AS volume_value, + volume_unit, + CASE + WHEN volume_value IS NULL + AND amount_value IS NULL + THEN dosage_value + ELSE NULL + END AS amount_value, + CASE + WHEN volume_value IS NULL + AND amount_value IS NULL + THEN dosage_unit + ELSE NULL + END AS amount_unit, + CASE + WHEN COUNT(ingredient) OVER (PARTITION BY a.din_7) > 1 + AND ( + amount_value IS NOT NULL + OR amount_unit NOT IN ( + 'ml', + 'mL', + 'g' + ) + ) + THEN devv5.numeric_to_text(dosage_value) + WHEN COUNT(ingredient) OVER (PARTITION BY a.din_7) > 1 + AND amount_value IS NULL + THEN devv5.numeric_to_text(dosage_value) + WHEN drug_descr LIKE '%\%%' + THEN REPLACE(REPLACE(SUBSTRING(drug_descr, '(\d+?\s?,?\.?\d*\s?)%'), ',', '.'), ' ', '') + WHEN amount_unit LIKE '%dose(s)%' + THEN devv5.numeric_to_text(dosage_value) + WHEN drug_descr ~ '\/\d?\s?,?\d+\s(mL|ml|l|heures)' + AND COUNT(ingredient) OVER (PARTITION BY a.din_7) = 1 + THEN REPLACE(REPLACE(SUBSTRING(drug_descr, '(\d+?\s?,?\.?\d*\s)(mg|g|microgrammes|UI|unités|U)\/\d?\s?,?\d+\s?(ml|mL|l|dose|g|heures)'), ',', '.'), ' ', '') + ELSE REPLACE(REPLACE(SUBSTRING(drug_descr, '(\d+?\s?,?\.?\d*\s)(ppm mole|mg|g|microgrammes|UI|unités|U)\/(1)?\s?(ml|mL|dose|mole|l|g)'), ',', '.'), ' ', '') + END AS numerator_value, + CASE + WHEN COUNT(ingredient) OVER (PARTITION BY a.din_7) > 1 + AND ( + amount_value IS NOT NULL + OR amount_unit NOT IN ( + 'ml', + 'mL', + 'g' + ) + ) + THEN dosage_unit + WHEN COUNT(ingredient) OVER (PARTITION BY a.din_7) > 1 + AND amount_value IS NULL + THEN dosage_unit + WHEN drug_descr ~ '%' + THEN REPLACE(REPLACE(SUBSTRING(drug_descr, '\d+?\s?,?\.?\d*\s?(%)'), ',', '.'), ' ', '') + WHEN amount_unit ~ 'dose\(s\)' + THEN dosage_unit + WHEN drug_descr ~ '\/\d?\s?,?\d+\s(mL|ml|l|heures)' + AND COUNT(ingredient) OVER (PARTITION BY a.din_7) = 1 + THEN REPLACE(REPLACE(SUBSTRING(drug_descr, '\d+?\s?,?\.?\d*\s(mg|g|microgrammes|UI|unités|U)\/\d?\s?,?\d+\s?(ml|mL||ldose|g|heures)'), ',', '.'), ' ', '') + ELSE SUBSTRING(drug_descr, '\d+?\s?,?\.?\d*\s(ppm mole|mg|g|microgrammes|UI|unités|U)\/(1)?\s?(ml|mL|dose|mole|l|g)') + END AS numerator_unit, + CASE + WHEN drug_descr ~ '\/\s?\d?\s?,?\d+?\s(mL|ml|l|heures)' + AND COUNT(ingredient) OVER (PARTITION BY a.din_7) = 1 + THEN TRIM(/*REGEXP_REPLACE(*/ REPLACE(SUBSTRING(drug_descr, '\/\s?(\d?\s?,?\d+?)\s?(ml|mL|l|dose|g|heures)'), ',', '.') /*,' ','')*/) + ELSE NULL + END AS denom, + CASE + WHEN drug_descr ~ '\/\s?\d?\s?,?\d+\s(mL|ml|l|heures)' + AND COUNT(ingredient) OVER (PARTITION BY a.din_7) = 1 + THEN REPLACE(REPLACE(SUBSTRING(drug_descr, '\/\d?\s?,?\d+\s?(ml|mL|l|dose|g|heures)'), ',', '.'), ' ', '') + WHEN drug_descr ~ '\d+?\s?,?\.?\d*\s((ppm mole|mg|g|microgrammes|UI|unités|U))\/(1)?\s?(ml|mL|dose|mole|l|g)' + THEN SUBSTRING(drug_descr, '\/1?\s?(ml|mL|mole|l|dose|g)') + ELSE NULL + END AS denom_unit, + CASE + WHEN amount_unit NOT IN ( + 'ml', + 'mL', + 'g', + 'dose' + ) + THEN NULL + ELSE amount_value + END AS fut_denominator_value, + CASE + WHEN amount_unit NOT IN ( + 'ml', + 'mL', + 'g', + 'dose' + ) + THEN NULL + ELSE amount_unit + END AS fut_denominator_unit, + box_size + FROM packaging_pars_3 a + JOIN ingredient_step_2 b ON b.drug_code = a.drug_code + JOIN sources.bdpm_drug d ON d.drug_code = b.drug_code + AND a.drug_code NOT IN ( + SELECT drug_code + FROM non_drug + + UNION ALL + + SELECT drug_code + FROM bdpm_vaccine_manual + + UNION ALL + + SELECT drug_code + FROM homeop_drug + ) + ) d; DROP TABLE IF EXISTS ds_1; - -CREATE TABLE ds_1 -AS +CREATE TABLE ds_1 AS SELECT concept_code, - c1, - drug_code, - drug_form, - ingredient_code, - ingredient_name, - packaging, - NULL AS pack_amount_value, - NULL AS pack_amount_unit, - drug_descr, - dosage_value, - dosage_unit, - volume_value, - volume_unit, - CASE - WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NULL AND amount_value IS NULL AND denom IS NULL THEN dosage_value - ELSE amount_value - END AS amount_value, - CASE - WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NULL AND amount_value IS NULL AND denom IS NULL THEN dosage_unit - ELSE amount_unit - END AS amount_unit, - CASE - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NULL AND amount_value IS NULL AND numerator IS NOT NULL AND denom IS NOT NULL THEN TRIM(numerator)::FLOAT - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND drug_descr ~* 'MOMETASONE' THEN dosage_value*TRIM(SUBSTRING(packaging,'(\d+)\sdose'))::FLOAT - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND drug_descr ~* 'PROSTINE E2' THEN dosage_value - ELSE numerator_value - END AS numerator_value, - CASE - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NULL AND amount_value IS NULL AND numerator IS NOT NULL AND denom IS NOT NULL THEN numerator_u - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND drug_descr ~* 'MOMETASONE' THEN dosage_unit - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND drug_descr ~* 'PROSTINE E2' THEN dosage_unit - ELSE numerator_unit - END AS numerator_unit, - CASE - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NULL AND amount_value IS NULL AND numerator IS NOT NULL AND denom IS NOT NULL THEN TRIM(denom)::FLOAT - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND drug_descr ~* 'MOMETASONE' THEN TRIM(SUBSTRING(packaging,'(\d+)\sdose'))::FLOAT - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND drug_descr ~* 'PROSTINE E2' THEN fut_denominator_value - ELSE denominator_value - END AS denominator_value, - CASE - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NULL AND amount_value IS NULL AND numerator IS NOT NULL AND denom IS NOT NULL THEN denom_unit - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND drug_descr ~* 'MOMETASONE' THEN 'dose' - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND drug_descr ~* 'PROSTINE E2' THEN fut_denominator_unit - ELSE denominator_unit - END AS denominator_unit, - box_size -FROM (SELECT concept_code, - c1, - drug_code, - drug_form, - ingredient_code, - ingredient_name, - packaging, - NULL AS pack_amount_value, - NULL AS pack_amount_unit, - drug_descr, - dosage_value, - dosage_unit, - volume_value, - volume_unit, - numerator_value AS numerator, - numerator_unit AS numerator_u, - amount_value AS amount, - denom, - denom_unit, - fut_denominator_value, - fut_denominator_unit, - CASE - WHEN drug_form ~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat' THEN dosage_value - WHEN drug_form ~* 'emplâtre' AND volume_unit IS NULL AND drug_descr !~* '%' THEN dosage_value - WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit ~* 'g' THEN dosage_value - WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NULL AND denom IS NULL AND volume_unit IS NULL THEN dosage_value - WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NULL AND fut_denominator_value IS NULL AND denom IS NULL AND volume_unit IS NULL THEN dosage_value - WHEN dosage_unit != 'g' AND volume_unit IS NULL AND fut_denominator_unit NOT IN ('ml','mL') AND numerator_value IS NULL THEN dosage_value - WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit IS NOT NULL AND volume_unit = 'g' AND fut_denominator_unit IS NULL AND volume_value NOT IN (100,10,1) THEN dosage_value - END AS amount_value, - CASE - WHEN drug_form ~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat' THEN dosage_unit - WHEN drug_form ~* 'emplâtre' AND volume_unit IS NULL AND drug_descr !~* '%' THEN dosage_unit - WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit ~* 'g' THEN dosage_unit - WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NULL AND denom IS NULL AND volume_unit IS NULL THEN dosage_unit - WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NULL AND fut_denominator_value IS NULL AND denom IS NULL AND volume_unit IS NULL THEN dosage_unit - WHEN dosage_unit != 'g' AND volume_unit IS NULL AND fut_denominator_unit NOT IN ('ml','mL') AND numerator_value IS NULL THEN dosage_unit - WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit IS NOT NULL AND volume_unit = 'g' AND fut_denominator_unit IS NULL AND volume_value NOT IN (100,10,1) THEN dosage_unit - END AS amount_unit, - CASE - WHEN drug_form ~* 'emplâtre' AND volume_unit = 'g' AND drug_descr !~* '%' THEN (dosage_value / volume_value) / 1000 - WHEN drug_form ~* 'emplâtre' AND drug_descr ~* '%' THEN ((TRIM(SUBSTRING(drug_descr,'(\d+)\s?\%'))::FLOAT)*10) / 1000 - WHEN dosage_unit = 'g' AND volume_unit = 'ml' AND fut_denominator_unit IN ('ml','mL') THEN ((dosage_value*1000) / volume_value)*fut_denominator_value - WHEN dosage_unit = 'g' AND volume_unit = 'g' AND fut_denominator_unit IN ('ml','mL') THEN ((dosage_value / volume_value)*1000)*fut_denominator_value - WHEN dosage_unit != 'g' AND volume_unit = 'ml' AND fut_denominator_unit IN ('ml','mL') THEN (dosage_value / volume_value)*fut_denominator_value - WHEN dosage_unit != 'g' AND volume_unit != 'ml' AND fut_denominator_unit NOT IN ('ml','mL') THEN (dosage_value / volume_value)*fut_denominator_value - WHEN dosage_unit = 'g' AND volume_unit = 'g' AND fut_denominator_unit = 'g' THEN (dosage_value / volume_value)*fut_denominator_value - WHEN dosage_unit != 'g' AND volume_unit = 'ml' AND fut_denominator_unit NOT IN ('ml','mL') THEN dosage_value - WHEN dosage_unit != 'g' AND volume_unit = 'g' AND fut_denominator_unit IN ('ml','mL') THEN dosage_value /(volume_value*1000) - WHEN dosage_unit != 'g' AND volume_unit IS NULL AND fut_denominator_unit IN ('ml','mL') AND numerator_value IS NULL THEN dosage_value - WHEN dosage_unit IS NOT NULL AND volume_unit = 'ml' AND fut_denominator_unit IS NULL THEN dosage_value - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit IS NOT NULL AND volume_unit = 'g' AND fut_denominator_unit IS NULL AND volume_value IN (100,10,1) THEN dosage_value / volume_value - WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit != 'g' AND volume_unit IS NOT NULL AND fut_denominator_unit IS NULL AND numerator_value IS NULL THEN dosage_value - WHEN drug_descr ~* '%' AND volume_unit IS NULL THEN (TRIM(REGEXP_REPLACE(SUBSTRING(drug_descr,'(\d*\,?\d+?)\s?\%'),',','.'))::FLOAT)*10*fut_denominator_value - WHEN volume_unit IS NULL AND numerator_value IS NOT NULL AND denom IS NOT NULL THEN (TRIM(numerator_value)::FLOAT/TRIM(denom)::FLOAT)*fut_denominator_value - WHEN numerator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr ~* '\/\s?(ml|ML|mL)' AND fut_denominator_value IS NOT NULL AND fut_denominator_unit != 'g' THEN (TRIM(numerator_value)::FLOAT)*fut_denominator_value - WHEN numerator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr ~* '\/\s?(ml|ML|mL)' AND fut_denominator_value IS NOT NULL AND fut_denominator_unit = 'g' THEN (TRIM(numerator_value)::FLOAT) - WHEN drug_descr ~* 'unidose' AND volume_unit IS NULL AND denom IS NULL AND drug_descr !~* '%' AND fut_denominator_unit !~* 'dose' THEN dosage_value - WHEN drug_descr ~* 'unidose' AND volume_unit IS NULL AND denom IS NULL AND drug_descr !~* '%' AND fut_denominator_unit ~* 'dose' THEN dosage_value*fut_denominator_value - WHEN drug_form ~* 'collyre' AND drug_descr ~* 'TOBRABACT' THEN (TRIM(REGEXP_REPLACE(SUBSTRING(drug_descr,'(\d+\,\d+)\s?\%'),',','.'))::FLOAT)*10*fut_denominator_value - WHEN drug_form ~* 'collyre' AND drug_descr ~* 'LUMIGAN|OPHTASILOXANE' THEN dosage_value - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit !~* 'dose|g' AND drug_descr !~* 'g\/l' THEN TRIM(numerator_value)::FLOAT - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit !~* 'dose|g' AND drug_descr ~* 'g\/l' THEN TRIM(numerator_value)::FLOAT*fut_denominator_value - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit ~* 'dose' THEN TRIM(numerator_value)::FLOAT*fut_denominator_value - END AS numerator_value, - CASE - WHEN drug_form ~* 'emplâtre' AND volume_unit = 'g' AND drug_descr !~* '%' AND dosage_unit = 'g' THEN 'mg' - WHEN drug_form ~* 'emplâtre' AND volume_unit = 'g' AND drug_descr !~* '%' AND dosage_unit != 'g' THEN dosage_unit - WHEN drug_form ~* 'emplâtre' AND drug_descr ~* '%' THEN 'mg' - WHEN dosage_unit = 'g' AND volume_unit = 'ml' AND fut_denominator_unit IN ('ml','mL') THEN 'mg' - WHEN dosage_unit = 'g' AND volume_unit = 'g' AND fut_denominator_unit IN ('ml','mL') THEN 'mg' - WHEN dosage_unit != 'g' AND volume_unit = 'ml' AND fut_denominator_unit IN ('ml','mL') THEN dosage_unit - WHEN dosage_unit != 'g' AND volume_unit != 'ml' AND fut_denominator_unit NOT IN ('ml','mL') THEN dosage_unit - WHEN dosage_unit = 'g' AND volume_unit = 'g' AND fut_denominator_unit = 'g' THEN dosage_unit - WHEN dosage_unit != 'g' AND volume_unit = 'ml' AND fut_denominator_unit NOT IN ('ml','mL') THEN dosage_unit - WHEN dosage_unit != 'g' AND volume_unit = 'g' AND fut_denominator_unit IN ('ml','mL') THEN dosage_unit - WHEN dosage_unit != 'g' AND volume_unit IS NULL AND fut_denominator_unit IN ('ml','mL') AND numerator_value IS NULL THEN dosage_unit - WHEN dosage_unit IS NOT NULL AND volume_unit = 'ml' AND fut_denominator_unit IS NULL THEN dosage_unit - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit IS NOT NULL AND volume_unit = 'g' AND fut_denominator_unit IS NULL AND volume_value IN (100,10,1) THEN dosage_unit - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit != 'g' AND volume_unit IS NOT NULL AND fut_denominator_unit IS NULL AND numerator_value IS NULL THEN dosage_unit - WHEN drug_descr ~* '%' AND volume_unit IS NULL THEN 'mg' - WHEN volume_unit IS NULL AND numerator_value IS NOT NULL AND denom IS NOT NULL THEN dosage_unit - WHEN numerator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr ~* '\/\s?(ml|ML|mL)' AND fut_denominator_value IS NOT NULL AND fut_denominator_unit != 'g' THEN numerator_unit - WHEN numerator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr ~* '\/\s?(ml|ML|mL)' AND fut_denominator_value IS NOT NULL AND fut_denominator_unit = 'g' THEN numerator_unit - WHEN drug_descr ~* 'unidose' AND volume_unit IS NULL AND denom IS NULL AND drug_descr !~* '%' THEN dosage_unit - WHEN drug_form ~* 'collyre' AND drug_descr ~* 'TOBRABACT' THEN 'mg' - WHEN drug_form ~* 'collyre' AND drug_descr ~* 'LUMIGAN|OPHTASILOXANE' THEN dosage_unit - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit !~* 'dose|g' AND drug_descr !~* 'g\/l' THEN numerator_unit - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit !~* 'dose|g' AND drug_descr ~* 'g\/l' THEN 'mg' - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit ~* 'dose' THEN numerator_unit - END AS numerator_unit, - CASE - WHEN drug_form ~* 'emplâtre' AND volume_unit = 'g' AND drug_descr !~* '%' THEN NULL - WHEN drug_form ~* 'emplâtre' AND drug_descr ~* '%' THEN NULL - WHEN dosage_unit != 'g' AND volume_unit = 'ml' AND fut_denominator_unit NOT IN ('ml','mL') THEN volume_value - WHEN dosage_unit != 'g' AND volume_unit = 'g' AND fut_denominator_unit IN ('ml','mL') THEN NULL - WHEN dosage_unit != 'g' AND volume_unit = 'ml' AND fut_denominator_unit IN ('ml','mL') THEN fut_denominator_value - WHEN dosage_unit IS NOT NULL AND volume_unit = 'ml' AND fut_denominator_unit IS NULL THEN volume_value - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit != 'g' AND volume_unit IS NOT NULL AND fut_denominator_unit IS NULL AND numerator_value IS NULL THEN volume_value - WHEN numerator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr ~* '\/\s?(ml|ML|mL)' AND fut_denominator_value IS NOT NULL AND fut_denominator_unit = 'g' THEN NULL - WHEN drug_form ~* 'collyre' AND drug_descr ~* 'LUMIGAN|OPHTASILOXANE' THEN NULL - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit ~* 'g' THEN NULL - WHEN dosage_unit != 'g' AND volume_unit IS NULL AND fut_denominator_unit NOT IN ('ml','mL') AND numerator_value IS NULL THEN NULL - ELSE fut_denominator_value - END AS denominator_value, - CASE - WHEN drug_form ~* 'emplâtre' AND volume_unit = 'g' AND drug_descr !~* '%' THEN 'mg' - WHEN drug_form ~* 'emplâtre' AND drug_descr ~* '%' THEN 'mg' - WHEN dosage_unit != 'g' AND volume_unit = 'ml' AND fut_denominator_unit NOT IN ('ml','mL') THEN volume_unit - WHEN dosage_unit IS NOT NULL AND volume_unit = 'ml' AND fut_denominator_unit IS NULL THEN volume_unit - WHEN dosage_unit != 'g' AND volume_unit = 'g' AND fut_denominator_unit IN ('ml','mL') THEN 'mg' - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit IS NOT NULL AND volume_unit = 'g' AND fut_denominator_unit IS NULL AND volume_value IN (100,10,1) THEN volume_unit - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND dosage_unit != 'g' AND volume_unit IS NOT NULL AND fut_denominator_unit IS NULL AND numerator_value IS NULL THEN volume_unit - WHEN numerator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr ~* '\/\s?(ml|ML|mL)' AND fut_denominator_value IS NOT NULL AND fut_denominator_unit = 'g' THEN denom_unit - WHEN drug_form ~* 'collyre' AND drug_descr ~* 'LUMIGAN|OPHTASILOXANE' THEN volume_unit - WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' AND numerator_value IS NOT NULL AND fut_denominator_value IS NOT NULL AND denom IS NULL AND volume_unit IS NULL AND drug_descr !~* '%' AND drug_descr !~* '\/\s?(ml|ML|mL)' AND drug_descr !~* 'unidose' AND fut_denominator_unit ~* 'g' THEN NULL - WHEN dosage_unit != 'g' AND volume_unit IS NULL AND fut_denominator_unit NOT IN ('ml','mL') AND numerator_value IS NULL THEN NULL - ELSE fut_denominator_unit - END AS denominator_unit, - CASE - WHEN box_size = 1 THEN NULL - ELSE box_size - END AS box_size - FROM ds_1_1) a; + c1, + drug_code, + drug_form, + ingredient_code, + ingredient_name, + packaging, + NULL AS pack_amount_value, + NULL AS pack_amount_unit, + drug_descr, + dosage_value, + dosage_unit, + volume_value, + volume_unit, + CASE + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NULL + AND amount_value IS NULL + AND denom IS NULL + THEN dosage_value + ELSE amount_value + END AS amount_value, + CASE + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NULL + AND amount_value IS NULL + AND denom IS NULL + THEN dosage_unit + ELSE amount_unit + END AS amount_unit, + CASE + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NULL + AND amount_value IS NULL + AND numerator IS NOT NULL + AND denom IS NOT NULL + THEN TRIM(numerator)::NUMERIC + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND drug_descr ILIKE '%MOMETASONE%' + THEN dosage_value * SUBSTRING(packaging, '(\d+)\sdose')::NUMERIC + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND drug_descr ILIKE '%PROSTINE E2%' + THEN dosage_value + ELSE numerator_value + END AS numerator_value, + CASE + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NULL + AND amount_value IS NULL + AND numerator IS NOT NULL + AND denom IS NOT NULL + THEN numerator_u + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND drug_descr ILIKE '%MOMETASONE%' + THEN dosage_unit + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND drug_descr ILIKE '%PROSTINE E2%' + THEN dosage_unit + ELSE numerator_unit + END AS numerator_unit, + CASE + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NULL + AND amount_value IS NULL + AND numerator IS NOT NULL + AND denom IS NOT NULL + THEN TRIM(denom)::NUMERIC + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND drug_descr ILIKE '%MOMETASONE%' + THEN SUBSTRING(packaging, '(\d+)\sdose')::NUMERIC + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND drug_descr ILIKE '%PROSTINE E2%' + THEN fut_denominator_value + ELSE denominator_value + END AS denominator_value, + CASE + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NULL + AND amount_value IS NULL + AND numerator IS NOT NULL + AND denom IS NOT NULL + THEN denom_unit + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND drug_descr ILIKE '%MOMETASONE%' + THEN 'dose' + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND drug_descr ILIKE '%PROSTINE E2%' + THEN fut_denominator_unit + ELSE denominator_unit + END AS denominator_unit, + box_size +FROM ( + SELECT concept_code, + c1, + drug_code, + drug_form, + ingredient_code, + ingredient_name, + packaging, + NULL AS pack_amount_value, + NULL AS pack_amount_unit, + drug_descr, + dosage_value, + dosage_unit, + volume_value, + volume_unit, + numerator_value AS numerator, + numerator_unit AS numerator_u, + amount_value AS amount, + denom, + denom_unit, + fut_denominator_value, + fut_denominator_unit, + CASE + WHEN drug_form ~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat' + THEN dosage_value + WHEN drug_form ~* 'emplâtre' + AND volume_unit IS NULL + AND drug_descr NOT LIKE '%\%%' + THEN dosage_value + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NOT NULL + AND fut_denominator_value IS NOT NULL + AND denom IS NULL + AND volume_unit IS NULL + AND drug_descr NOT LIKE '%\%%' + AND drug_descr !~* '\/\s?(ml|ML|mL)' + AND drug_descr NOT ILIKE '%unidose%' + AND fut_denominator_unit ILIKE '%g%' + THEN dosage_value + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NOT NULL + AND fut_denominator_value IS NULL + AND denom IS NULL + AND volume_unit IS NULL + THEN dosage_value + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NULL + AND fut_denominator_value IS NULL + AND denom IS NULL + AND volume_unit IS NULL + THEN dosage_value + WHEN dosage_unit <> 'g' + AND volume_unit IS NULL + AND fut_denominator_unit NOT IN ( + 'ml', + 'mL' + ) + AND numerator_value IS NULL + THEN dosage_value + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND dosage_unit IS NOT NULL + AND volume_unit = 'g' + AND fut_denominator_unit IS NULL + AND volume_value NOT IN ( + 100, + 10, + 1 + ) + THEN dosage_value + END AS amount_value, + CASE + WHEN drug_form ~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat' + THEN dosage_unit + WHEN drug_form ILIKE '%emplâtre%' + AND volume_unit IS NULL + AND drug_descr NOT LIKE '%\%%' + THEN dosage_unit + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NOT NULL + AND fut_denominator_value IS NOT NULL + AND denom IS NULL + AND volume_unit IS NULL + AND drug_descr NOT LIKE '%\%%' + AND drug_descr !~* '\/\s?(ml|ML|mL)' + AND drug_descr NOT ILIKE '%unidose%' + AND fut_denominator_unit ILIKE '%g%' + THEN dosage_unit + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NOT NULL + AND fut_denominator_value IS NULL + AND denom IS NULL + AND volume_unit IS NULL + THEN dosage_unit + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NULL + AND fut_denominator_value IS NULL + AND denom IS NULL + AND volume_unit IS NULL + THEN dosage_unit + WHEN dosage_unit <> 'g' + AND volume_unit IS NULL + AND fut_denominator_unit NOT IN ( + 'ml', + 'mL' + ) + AND numerator_value IS NULL + THEN dosage_unit + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND dosage_unit IS NOT NULL + AND volume_unit = 'g' + AND fut_denominator_unit IS NULL + AND volume_value NOT IN ( + 100, + 10, + 1 + ) + THEN dosage_unit + END AS amount_unit, + CASE + WHEN drug_form ILIKE '%emplâtre%' + AND volume_unit = 'g' + AND drug_descr NOT LIKE '%\%%' + THEN (dosage_value / volume_value) / 1000 + WHEN drug_form ILIKE '%emplâtre%' + AND drug_descr LIKE '%\%%' + THEN ((TRIM(SUBSTRING(drug_descr, '(\d+)\s?\%'))::NUMERIC) * 10) / 1000 + WHEN dosage_unit = 'g' + AND volume_unit = 'ml' + AND fut_denominator_unit IN ( + 'ml', + 'mL' + ) + THEN ((dosage_value * 1000) / volume_value) * fut_denominator_value + WHEN dosage_unit = 'g' + AND volume_unit = 'g' + AND fut_denominator_unit IN ( + 'ml', + 'mL' + ) + THEN ((dosage_value / volume_value) * 1000) * fut_denominator_value + WHEN dosage_unit <> 'g' + AND volume_unit = 'ml' + AND fut_denominator_unit IN ( + 'ml', + 'mL' + ) + THEN (dosage_value / volume_value) * fut_denominator_value + WHEN dosage_unit <> 'g' + AND volume_unit <> 'ml' + AND fut_denominator_unit NOT IN ( + 'ml', + 'mL' + ) + THEN (dosage_value / volume_value) * fut_denominator_value + WHEN dosage_unit = 'g' + AND volume_unit = 'g' + AND fut_denominator_unit = 'g' + THEN (dosage_value / volume_value) * fut_denominator_value + WHEN dosage_unit <> 'g' + AND volume_unit = 'ml' + AND fut_denominator_unit NOT IN ( + 'ml', + 'mL' + ) + THEN dosage_value + WHEN dosage_unit <> 'g' + AND volume_unit = 'g' + AND fut_denominator_unit IN ( + 'ml', + 'mL' + ) + THEN dosage_value / (volume_value * 1000) + WHEN dosage_unit <> 'g' + AND volume_unit IS NULL + AND fut_denominator_unit IN ( + 'ml', + 'mL' + ) + AND numerator_value IS NULL + THEN dosage_value + WHEN dosage_unit IS NOT NULL + AND volume_unit = 'ml' + AND fut_denominator_unit IS NULL + THEN dosage_value + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND dosage_unit IS NOT NULL + AND volume_unit = 'g' + AND fut_denominator_unit IS NULL + AND volume_value IN ( + 100, + 10, + 1 + ) + THEN dosage_value / volume_value + WHEN drug_form !~* 'ovule|collyre|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND dosage_unit <> 'g' + AND volume_unit IS NOT NULL + AND fut_denominator_unit IS NULL + AND numerator_value IS NULL + THEN dosage_value + WHEN drug_descr LIKE '%\%%' + AND volume_unit IS NULL + THEN (TRIM(REPLACE(SUBSTRING(drug_descr, '(\d*,?\d+?)\s?\%'), ',', '.'))::NUMERIC) * 10 * fut_denominator_value + WHEN volume_unit IS NULL + AND numerator_value IS NOT NULL + AND denom IS NOT NULL + THEN (TRIM(numerator_value)::NUMERIC / TRIM(denom)::NUMERIC) * fut_denominator_value + WHEN numerator_value IS NOT NULL + AND denom IS NULL + AND volume_unit IS NULL + AND drug_descr NOT LIKE '%\%%' + AND drug_descr ~* '\/\s?(ml|ML|mL)' + AND fut_denominator_value IS NOT NULL + AND fut_denominator_unit <> 'g' + THEN (TRIM(numerator_value)::NUMERIC) * fut_denominator_value + WHEN numerator_value IS NOT NULL + AND denom IS NULL + AND volume_unit IS NULL + AND drug_descr NOT LIKE '%\%%' + AND drug_descr ~* '\/\s?(ml|ML|mL)' + AND fut_denominator_value IS NOT NULL + AND fut_denominator_unit = 'g' + THEN (TRIM(numerator_value)::NUMERIC) + WHEN drug_descr ILIKE '%unidose%' + AND volume_unit IS NULL + AND denom IS NULL + AND drug_descr NOT LIKE '%\%%' + AND fut_denominator_unit NOT ILIKE '%dose%' + THEN dosage_value + WHEN drug_descr ILIKE '%unidose%' + AND volume_unit IS NULL + AND denom IS NULL + AND drug_descr NOT LIKE '%\%%' + AND fut_denominator_unit ILIKE '%dose%' + THEN dosage_value * fut_denominator_value + WHEN drug_form ILIKE '%collyre%' + AND drug_descr ILIKE '%TOBRABACT%' + THEN (TRIM(REPLACE(SUBSTRING(drug_descr, '(\d+,\d+)\s?\%'), ',', '.'))::NUMERIC) * 10 * fut_denominator_value + WHEN drug_form ILIKE '%collyre%' + AND drug_descr ~* 'LUMIGAN|OPHTASILOXANE' + THEN dosage_value + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NOT NULL + AND fut_denominator_value IS NOT NULL + AND denom IS NULL + AND volume_unit IS NULL + AND drug_descr NOT LIKE '%\%%' + AND drug_descr !~* '\/\s?(ml|ML|mL)' + AND drug_descr NOT ILIKE '%unidose%' + AND fut_denominator_unit !~* 'dose|g' + AND drug_descr NOT ILIKE '%g/l%' + THEN TRIM(numerator_value)::NUMERIC + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NOT NULL + AND fut_denominator_value IS NOT NULL + AND denom IS NULL + AND volume_unit IS NULL + AND drug_descr NOT LIKE '%\%%' + AND drug_descr !~* '\/\s?(ml|ML|mL)' + AND drug_descr NOT ILIKE '%unidose%' + AND fut_denominator_unit !~* 'dose|g' + AND drug_descr ILIKE '%g/l%' + THEN TRIM(numerator_value)::NUMERIC * fut_denominator_value + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NOT NULL + AND fut_denominator_value IS NOT NULL + AND denom IS NULL + AND volume_unit IS NULL + AND drug_descr NOT LIKE '%\%%' + AND drug_descr !~* '\/\s?(ml|ML|mL)' + AND drug_descr NOT ILIKE '%unidose%' + AND fut_denominator_unit ILIKE '%dose%' + THEN TRIM(numerator_value)::NUMERIC * fut_denominator_value + END AS numerator_value, + CASE + WHEN drug_form ILIKE '%emplâtre%' + AND volume_unit = 'g' + AND drug_descr NOT LIKE '%\%%' + AND dosage_unit = 'g' + THEN 'mg' + WHEN drug_form ILIKE '%emplâtre%' + AND volume_unit = 'g' + AND drug_descr NOT LIKE '%\%%' + AND dosage_unit <> 'g' + THEN dosage_unit + WHEN drug_form ILIKE '%emplâtre%' + AND drug_descr LIKE '%\%%' + THEN 'mg' + WHEN dosage_unit = 'g' + AND volume_unit = 'ml' + AND fut_denominator_unit IN ( + 'ml', + 'mL' + ) + THEN 'mg' + WHEN dosage_unit = 'g' + AND volume_unit = 'g' + AND fut_denominator_unit IN ( + 'ml', + 'mL' + ) + THEN 'mg' + WHEN dosage_unit <> 'g' + AND volume_unit = 'ml' + AND fut_denominator_unit IN ( + 'ml', + 'mL' + ) + THEN dosage_unit + WHEN dosage_unit <> 'g' + AND volume_unit <> 'ml' + AND fut_denominator_unit NOT IN ( + 'ml', + 'mL' + ) + THEN dosage_unit + WHEN dosage_unit = 'g' + AND volume_unit = 'g' + AND fut_denominator_unit = 'g' + THEN dosage_unit + WHEN dosage_unit <> 'g' + AND volume_unit = 'ml' + AND fut_denominator_unit NOT IN ( + 'ml', + 'mL' + ) + THEN dosage_unit + WHEN dosage_unit <> 'g' + AND volume_unit = 'g' + AND fut_denominator_unit IN ( + 'ml', + 'mL' + ) + THEN dosage_unit + WHEN dosage_unit <> 'g' + AND volume_unit IS NULL + AND fut_denominator_unit IN ( + 'ml', + 'mL' + ) + AND numerator_value IS NULL + THEN dosage_unit + WHEN dosage_unit IS NOT NULL + AND volume_unit = 'ml' + AND fut_denominator_unit IS NULL + THEN dosage_unit + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND dosage_unit IS NOT NULL + AND volume_unit = 'g' + AND fut_denominator_unit IS NULL + AND volume_value IN ( + 100, + 10, + 1 + ) + THEN dosage_unit + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND dosage_unit <> 'g' + AND volume_unit IS NOT NULL + AND fut_denominator_unit IS NULL + AND numerator_value IS NULL + THEN dosage_unit + WHEN drug_descr LIKE '%\%%' + AND volume_unit IS NULL + THEN 'mg' + WHEN volume_unit IS NULL + AND numerator_value IS NOT NULL + AND denom IS NOT NULL + THEN dosage_unit + WHEN numerator_value IS NOT NULL + AND denom IS NULL + AND volume_unit IS NULL + AND drug_descr NOT LIKE '%\%%' + AND drug_descr ~* '\/\s?(ml|ML|mL)' + AND fut_denominator_value IS NOT NULL + AND fut_denominator_unit <> 'g' + THEN numerator_unit + WHEN numerator_value IS NOT NULL + AND denom IS NULL + AND volume_unit IS NULL + AND drug_descr NOT LIKE '%\%%' + AND drug_descr ~* '\/\s?(ml|ML|mL)' + AND fut_denominator_value IS NOT NULL + AND fut_denominator_unit = 'g' + THEN numerator_unit + WHEN drug_descr ILIKE '%unidose%' + AND volume_unit IS NULL + AND denom IS NULL + AND drug_descr NOT LIKE '%\%%' + THEN dosage_unit + WHEN drug_form ILIKE '%collyre%' + AND drug_descr ILIKE '%TOBRABACT%' + THEN 'mg' + WHEN drug_form ILIKE '%collyre%' + AND drug_descr ~* 'LUMIGAN|OPHTASILOXANE' + THEN dosage_unit + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NOT NULL + AND fut_denominator_value IS NOT NULL + AND denom IS NULL + AND volume_unit IS NULL + AND drug_descr !~* '%' + AND drug_descr !~* '\/\s?(ml|ML|mL)' + AND drug_descr NOT ILIKE '%unidose%' + AND fut_denominator_unit !~* 'dose|g' + AND drug_descr NOT ILIKE '%g/l%' + THEN numerator_unit + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NOT NULL + AND fut_denominator_value IS NOT NULL + AND denom IS NULL + AND volume_unit IS NULL + AND drug_descr !~* '%' + AND drug_descr !~* '\/\s?(ml|ML|mL)' + AND drug_descr NOT ILIKE '%unidose%' + AND fut_denominator_unit !~* 'dose|g' + AND drug_descr ILIKE '%g/l%' + THEN 'mg' + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NOT NULL + AND fut_denominator_value IS NOT NULL + AND denom IS NULL + AND volume_unit IS NULL + AND drug_descr !~* '%' + AND drug_descr !~* '\/\s?(ml|ML|mL)' + AND drug_descr NOT ILIKE '%unidose%' + AND fut_denominator_unit ILIKE '%dose%' + THEN numerator_unit + END AS numerator_unit, + CASE + WHEN drug_form ILIKE '%emplâtre%' + AND volume_unit = 'g' + AND drug_descr NOT LIKE '%\%%' + THEN NULL + WHEN drug_form ILIKE '%emplâtre%' + AND drug_descr LIKE '%\%%' + THEN NULL + WHEN dosage_unit <> 'g' + AND volume_unit = 'ml' + AND fut_denominator_unit NOT IN ( + 'ml', + 'mL' + ) + THEN volume_value + WHEN dosage_unit <> 'g' + AND volume_unit = 'g' + AND fut_denominator_unit IN ( + 'ml', + 'mL' + ) + THEN NULL + WHEN dosage_unit <> 'g' + AND volume_unit = 'ml' + AND fut_denominator_unit IN ( + 'ml', + 'mL' + ) + THEN fut_denominator_value + WHEN dosage_unit IS NOT NULL + AND volume_unit = 'ml' + AND fut_denominator_unit IS NULL + THEN volume_value + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND dosage_unit <> 'g' + AND volume_unit IS NOT NULL + AND fut_denominator_unit IS NULL + AND numerator_value IS NULL + THEN volume_value + WHEN numerator_value IS NOT NULL + AND denom IS NULL + AND volume_unit IS NULL + AND drug_descr NOT LIKE '%\%%' + AND drug_descr ~* '\/\s?(ml|ML|mL)' + AND fut_denominator_value IS NOT NULL + AND fut_denominator_unit = 'g' + THEN NULL + WHEN drug_form ILIKE '%collyre%' + AND drug_descr ~* 'LUMIGAN|OPHTASILOXANE' + THEN NULL + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NOT NULL + AND fut_denominator_value IS NOT NULL + AND denom IS NULL + AND volume_unit IS NULL + AND drug_descr NOT LIKE '%\%%' + AND drug_descr !~* '\/\s?(ml|ML|mL)' + AND drug_descr NOT ILIKE '%unidose%' + AND fut_denominator_unit ILIKE '%g%' + THEN NULL + WHEN dosage_unit <> 'g' + AND volume_unit IS NULL + AND fut_denominator_unit NOT IN ( + 'ml', + 'mL' + ) + AND numerator_value IS NULL + THEN NULL + ELSE fut_denominator_value + END AS denominator_value, + CASE + WHEN drug_form ILIKE '%emplâtre%' + AND volume_unit = 'g' + AND drug_descr NOT LIKE '%\%%' + THEN 'mg' + WHEN drug_form ILIKE '%emplâtre%' + AND drug_descr LIKE '%\%%' + THEN 'mg' + WHEN dosage_unit <> 'g' + AND volume_unit = 'ml' + AND fut_denominator_unit NOT IN ( + 'ml', + 'mL' + ) + THEN volume_unit + WHEN dosage_unit IS NOT NULL + AND volume_unit = 'ml' + AND fut_denominator_unit IS NULL + THEN volume_unit + WHEN dosage_unit <> 'g' + AND volume_unit = 'g' + AND fut_denominator_unit IN ( + 'ml', + 'mL' + ) + THEN 'mg' + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND dosage_unit IS NOT NULL + AND volume_unit = 'g' + AND fut_denominator_unit IS NULL + AND volume_value IN ( + 100, + 10, + 1 + ) + THEN volume_unit + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND dosage_unit <> 'g' + AND volume_unit IS NOT NULL + AND fut_denominator_unit IS NULL + AND numerator_value IS NULL + THEN volume_unit + WHEN numerator_value IS NOT NULL + AND denom IS NULL + AND volume_unit IS NULL + AND drug_descr NOT LIKE '%\%%' + AND drug_descr ~* '\/\s?(ml|ML|mL)' + AND fut_denominator_value IS NOT NULL + AND fut_denominator_unit = 'g' + THEN denom_unit + WHEN drug_form ILIKE '%collyre%' + AND drug_descr ~* 'LUMIGAN|OPHTASILOXANE' + THEN volume_unit + WHEN drug_form !~* 'ovule|comprimé|suppositoire|microsphère|microgranule|gélule|granulé|gomme|capsule|pastille|film|lyophilisat|emplâtre' + AND numerator_value IS NOT NULL + AND fut_denominator_value IS NOT NULL + AND denom IS NULL + AND volume_unit IS NULL + AND drug_descr NOT LIKE '%\%%' + AND drug_descr !~* '\/\s?(ml|ML|mL)' + AND drug_descr NOT ILIKE '%unidose%' + AND fut_denominator_unit ILIKE '%g%' + THEN NULL + WHEN dosage_unit <> 'g' + AND volume_unit IS NULL + AND fut_denominator_unit NOT IN ( + 'ml', + 'mL' + ) + AND numerator_value IS NULL + THEN NULL + ELSE fut_denominator_unit + END AS denominator_unit, + CASE + WHEN box_size = 1 + THEN NULL + ELSE box_size + END AS box_size + FROM ds_1_1 + ) a; -- manual fix -update ds_1 -set numerator_value = numerator_value/denominator_value, -denominator_value = null -where packaging ~* 'avec cuillère-mesure' -and denominator_value = 5 -and denominator_unit in ('ml','mL') -; - -update ds_1 -set numerator_value = 50 -where concept_code = '2750567' -; - -update ds_1 -set numerator_value = 20, -numerator_unit = 'mg' -where concept_code = '3646843'; +UPDATE ds_1 +SET numerator_value = numerator_value / denominator_value, + denominator_value = NULL +WHERE packaging ILIKE '%avec cuillère-mesure%' + AND denominator_value = 5 + AND denominator_unit IN ( + 'ml', + 'mL' + ); -update ds_1 -set numerator_value = 20, -numerator_unit = 'mg' -where concept_code = '3646837'; +UPDATE ds_1 +SET numerator_value = 50 +WHERE concept_code = '2750567'; +UPDATE ds_1 +SET numerator_value = 20, + numerator_unit = 'mg' +WHERE concept_code = '3646843'; - -update ds_1 -set numerator_value = (dosage_value*10)*denominator_value, -numerator_unit = 'mg' -where concept_code in ('3894707','3894713','3894736','3006088'); +UPDATE ds_1 +SET numerator_value = 20, + numerator_unit = 'mg' +WHERE concept_code = '3646837'; -update ds_1 -set denominator_value = 1 -where denominator_unit ='g' and denominator_value is null - ; +UPDATE ds_1 +SET numerator_value = (dosage_value * 10) * denominator_value, + numerator_unit = 'mg' +WHERE concept_code IN ( + '3894707', + '3894713', + '3894736', + '3006088' + ); -update ds_1 -set numerator_value = 100 -where concept_code = '3140486' -; +UPDATE ds_1 +SET denominator_value = 1 +WHERE denominator_unit = 'g' + AND denominator_value IS NULL; +UPDATE ds_1 +SET numerator_value = 100 +WHERE concept_code = '3140486'; UPDATE ds_1 - SET amount_value = NULL, - amount_unit = NULL +SET amount_value = NULL, + amount_unit = NULL WHERE amount_value IS NOT NULL -AND numerator_value IS NOT NULL -AND denominator_unit IS NOT NULL; + AND numerator_value IS NOT NULL + AND denominator_unit IS NOT NULL; UPDATE ds_1 - SET numerator_value = NULL, - numerator_unit = NULL +SET numerator_value = NULL, + numerator_unit = NULL WHERE amount_value IS NOT NULL -AND numerator_value IS NOT NULL -AND denominator_unit IS NULL; - + AND numerator_value IS NOT NULL + AND denominator_unit IS NULL; -- give clear dosage for oxygen -UPDATE ds_1 a - SET numerator_value = b.amount_value, - numerator_unit = b.amount_unit, - amount_value = NULL, - amount_unit = NULL, - denominator_unit = NULL -FROM ds_1 b -WHERE a.concept_code = b.concept_code -AND a.drug_code = b.drug_code -AND a.drug_form = b.drug_form -AND a.ingredient_code = b.ingredient_code -AND a.ingredient_name = b.ingredient_name -AND a.amount_unit IN ('% ','%','ppm mole'); - +UPDATE ds_1 +SET numerator_value = amount_value, + numerator_unit = amount_unit, + amount_value = NULL, + amount_unit = NULL, + denominator_unit = NULL +WHERE TRIM(amount_unit) IN ( + '%', + 'ppm mole' + ); -- update dosage for multidrugs DROP TABLE if exists ds_1_2; - -CREATE TABLE ds_1_2 -AS +CREATE TABLE ds_1_2 AS SELECT DISTINCT concept_code, - drug_code, - ingredient_code, - CASE - WHEN numerator_value IS NOT NULL THEN NULL - ELSE amount_value - END AS amount_value, - CASE - WHEN numerator_value IS NOT NULL THEN NULL - ELSE amount_unit - END AS amount_unit, - numerator_value, - numerator_unit, - denominator_value, - denominator_unit, - box_size -FROM (SELECT concept_code, - drug_code, - ingredient_code, - TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'(\d+?\s?\,?\.?\d*\s)(ppm mole|mg|g|microgrammes|UI|unités|U)'),',','.'),' ','')) AS amount_value, - TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'\d+?\s?\,?\.?\d*\s(ppm mole|mg|g|microgrammes|UI|unités|U)'),',','.'),' ','')) AS amount_unit, - CASE - WHEN drug_descr ~ '\/\d?\s?\,?\d+\s(mL|ml|l|heures)' THEN TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'(\d+?\s?\,?\.?\d*\s)(mg|g|microgrammes|UI|unités|U)\/\d?\s?\,?\d+\s?(ml|mL|l|dose|g|heures)'),',','.'),' ','')) - ELSE TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'(\d+?\s?\,?\.?\d*\s)(ppm mole|mg|g|microgrammes|UI|unités|U)\/(1)?\s?(ml|mL|dose|mole|l|g)'),',','.'),' ','')) - END AS numerator_value, - CASE - WHEN drug_descr ~ '\/\d?\s?\,?\d+\s(mL|ml|l|heures)' THEN TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'\d+?\s?\,?\.?\d*\s(mg|g|microgrammes|UI|unités|U)\/\d?\s?\,?\d+\s?(ml|mL||ldose|g|heures)'),',','.'),' ','')) - ELSE SUBSTRING(drug_descr,'\d+?\s?\,?\.?\d*\s(ppm mole|mg|g|microgrammes|UI|unités|U)\/(1)?\s?(ml|mL|dose|mole|l|g)') - END AS numerator_unit, - TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'\/(\d?\s?\,?\d+)\s?(ml|mL|l|dose|g|heures)'),',','.'),' ','')) AS denominator_value, - CASE - WHEN drug_descr ~ '\/\d?\s?\,?\d+\s(mL|ml|l|heures)' THEN TRIM(REGEXP_REPLACE(REGEXP_REPLACE(SUBSTRING(drug_descr,'\/\d?\s?\,?\d+\s?(ml|mL|l|dose|g|heures)'),',','.'),' ','')) - ELSE SUBSTRING(drug_descr,'\/1?\s?(ml|mL|mole|l|dose|g)') - END AS denominator_unit, - box_size - FROM (SELECT COUNT(1) OVER (PARTITION BY concept_code,drug_code,ingredient_code,drug_form) AS c2, - * - FROM ds_1) a - WHERE c2 > 1) az; - + drug_code, + ingredient_code, + CASE + WHEN numerator_value IS NOT NULL + THEN NULL + ELSE amount_value + END AS amount_value, + CASE + WHEN numerator_value IS NOT NULL + THEN NULL + ELSE amount_unit + END AS amount_unit, + numerator_value, + numerator_unit, + denominator_value, + denominator_unit, + box_size +FROM ( + SELECT concept_code, + drug_code, + ingredient_code, + REPLACE(REPLACE(SUBSTRING(drug_descr, '(\d+?\s?,?\.?\d*\s)(ppm mole|mg|g|microgrammes|UI|unités|U)'), ',', '.'), ' ', '') AS amount_value, + REPLACE(REPLACE(SUBSTRING(drug_descr, '\d+?\s?,?\.?\d*\s(ppm mole|mg|g|microgrammes|UI|unités|U)'), ',', '.'), ' ', '') AS amount_unit, + CASE + WHEN drug_descr ~ '\/\d?\s?,?\d+\s(mL|ml|l|heures)' + THEN REPLACE(REPLACE(SUBSTRING(drug_descr, '(\d+?\s?,?\.?\d*\s)(mg|g|microgrammes|UI|unités|U)\/\d?\s?,?\d+\s?(ml|mL|l|dose|g|heures)'), ',', '.'), ' ', '') + ELSE REPLACE(REPLACE(SUBSTRING(drug_descr, '(\d+?\s?,?\.?\d*\s)(ppm mole|mg|g|microgrammes|UI|unités|U)\/(1)?\s?(ml|mL|dose|mole|l|g)'), ',', '.'), ' ', '') + END AS numerator_value, + CASE + WHEN drug_descr ~ '\/\d?\s?,?\d+\s(mL|ml|l|heures)' + THEN REPLACE(REPLACE(SUBSTRING(drug_descr, '\d+?\s?,?\.?\d*\s(mg|g|microgrammes|UI|unités|U)\/\d?\s?,?\d+\s?(ml|mL||ldose|g|heures)'), ',', '.'), ' ', '') + ELSE SUBSTRING(drug_descr, '\d+?\s?,?\.?\d*\s(ppm mole|mg|g|microgrammes|UI|unités|U)\/(1)?\s?(ml|mL|dose|mole|l|g)') + END AS numerator_unit, + REPLACE(REPLACE(SUBSTRING(drug_descr, '\/(\d?\s?,?\d+)\s?(ml|mL|l|dose|g|heures)'), ',', '.'), ' ', '') AS denominator_value, + CASE + WHEN drug_descr ~ '\/\d?\s?,?\d+\s(mL|ml|l|heures)' + THEN REPLACE(REPLACE(SUBSTRING(drug_descr, '\/\d?\s?,?\d+\s?(ml|mL|l|dose|g|heures)'), ',', '.'), ' ', '') + ELSE SUBSTRING(drug_descr, '\/1?\s?(ml|mL|mole|l|dose|g)') + END AS denominator_unit, + box_size + FROM ( + SELECT COUNT(*) OVER ( + PARTITION BY concept_code, + drug_code, + ingredient_code, + drug_form + ) AS c2, + * + FROM ds_1 + ) a + WHERE c2 > 1 + ) az; DELETE FROM ds_1 -WHERE concept_code IN (SELECT concept_code FROM ds_1_2); +WHERE concept_code IN ( + SELECT concept_code + FROM ds_1_2 + ); -INSERT INTO ds_1 -( - concept_code, - ingredient_code, - amount_value, - amount_unit, - numerator_value, - numerator_unit, - denominator_value, - denominator_unit, - box_size -) -SELECT concept_code, - ingredient_code, - amount_value::FLOAT, - amount_unit, - numerator_value::FLOAT, - numerator_unit, - denominator_value::FLOAT, - denominator_unit, - box_size +INSERT INTO ds_1 ( + concept_code, + ingredient_code, + amount_value, + amount_unit, + numerator_value, + numerator_unit, + denominator_value, + denominator_unit, + box_size + ) +SELECT concept_code, + ingredient_code, + amount_value::NUMERIC, + amount_unit, + numerator_value::NUMERIC, + numerator_unit, + denominator_value::NUMERIC, + denominator_unit, + box_size FROM ds_1_2; -- update with standard units UPDATE ds_1 - SET amount_unit = attr_name +SET amount_unit = attr_name FROM rtc_1 WHERE TRIM(UPPER(amount_unit)) = UPPER(original_name); UPDATE ds_1 - SET numerator_unit = attr_name +SET numerator_unit = attr_name --from unit_translation - FROM rtc_1 +FROM rtc_1 WHERE TRIM(UPPER(numerator_unit)) = UPPER(original_name); UPDATE ds_1 - SET denominator_unit = attr_name +SET denominator_unit = attr_name --from unit_translation - FROM rtc_1 +FROM rtc_1 WHERE TRIM(UPPER(denominator_unit)) = UPPER(original_name); - - --manual fixes - UPDATE ds_1 SET numerator_unit = 'mg' WHERE concept_code = '5654597' AND ingredient_code = '01080'; - -update ds_1 -set amount_value = amount_value*1000, -amount_unit = 'mg' -where amount_unit = 'g'; - -update ds_1 -set numerator_value = numerator_value*1000, -numerator_unit = 'mg' -where numerator_unit = 'g'; - -update ds_1 -set denominator_value = denominator_value*1000, -denominator_unit = 'mg' -where denominator_unit = 'g'; - -update ds_1 -set denominator_value = null, -denominator_unit = null -WHERE drug_form = 'gaz' -; +UPDATE ds_1 +SET amount_value = amount_value * 1000, + amount_unit = 'mg' +WHERE amount_unit = 'g'; + +UPDATE ds_1 +SET numerator_value = numerator_value * 1000, + numerator_unit = 'mg' +WHERE numerator_unit = 'g'; + +UPDATE ds_1 +SET denominator_value = denominator_value * 1000, + denominator_unit = 'mg' +WHERE denominator_unit = 'g'; -update ds_1 -set numerator_value = numerator_value*0.0001, -numerator_unit = '%' -where numerator_unit = 'ppm mole'; +UPDATE ds_1 +SET denominator_value = NULL, + denominator_unit = NULL +WHERE drug_form = 'gaz'; -update ds_1 -set numerator_value = amount_value, -numerator_unit = amount_unit, -amount_value = null, -amount_unit = null -where amount_value is not null and denominator_value is not null and drug_descr ~* '\/\d*\,?\d*?\s?ml'; +UPDATE ds_1 +SET numerator_value = numerator_value * 0.0001, + numerator_unit = '%' +WHERE numerator_unit = 'ppm mole'; -update ds_1 -set denominator_value = null, -denominator_unit = null -where amount_value is not null and denominator_value is not null; +UPDATE ds_1 +SET numerator_value = amount_value, + numerator_unit = amount_unit, + amount_value = NULL, + amount_unit = NULL +WHERE amount_value IS NOT NULL + AND denominator_value IS NOT NULL + AND drug_descr ~* '\/\d*,?\d*?\s?ml'; -update ds_1 -set numerator_unit = null -where amount_value is not null -and numerator_unit is not null -; +UPDATE ds_1 +SET denominator_value = NULL, + denominator_unit = NULL +WHERE amount_value IS NOT NULL + AND denominator_value IS NOT NULL; + +UPDATE ds_1 +SET numerator_unit = NULL +WHERE amount_value IS NOT NULL + AND numerator_unit IS NOT NULL; -- create table for packs DROP TABLE pack_st_1; - -CREATE TABLE pack_st_1 -AS +CREATE TABLE pack_st_1 AS SELECT drug_code, - drug_form, - form_code + drug_form, + form_code FROM ingredient_step_2 -WHERE drug_code IN (SELECT drug_code - FROM (SELECT DISTINCT drug_code, drug_form FROM ingredient_step_2) AS s0 - GROUP BY drug_code - HAVING COUNT(1) > 1) -AND drug_code NOT IN (SELECT drug_code FROM non_drug) -AND drug_code NOT IN (SELECT drug_code FROM homeop_drug) -AND drug_code NOT IN ('64122611','67657035') -AND drug_code NOT IN (SELECT drug_code - FROM sources.bdpm_packaging - WHERE din_7 IN (3012520,5754637,5611085,3007865,3007867,3008279,3012518,3048384,3209686)); - - - - - ---sequence will be used in pack component definition -DROP SEQUENCE IF EXISTS pack_sequence; -CREATE SEQUENCE pack_sequence MINVALUE 1 MAXVALUE 1000000 START WITH 1 INCREMENT BY 1 CACHE 100; +WHERE drug_code IN ( + SELECT drug_code + FROM ( + SELECT DISTINCT drug_code, + drug_form + FROM ingredient_step_2 + ) AS s0 + GROUP BY drug_code + HAVING COUNT(*) > 1 + ) + AND drug_code NOT IN ( + SELECT drug_code + FROM non_drug + ) + AND drug_code NOT IN ( + SELECT drug_code + FROM homeop_drug + ) + AND drug_code NOT IN ( + '64122611', + '67657035' + ) + AND drug_code NOT IN ( + SELECT drug_code + FROM sources.bdpm_packaging + WHERE din_7 IN ( + 3012520, + 5754637, + 5611085, + 3007865, + 3007867, + 3008279, + 3012518, + 3048384, + 3209686 + ) + ); --collect all pack components DROP TABLE IF EXISTS pack_comp_list; CREATE TABLE pack_comp_list AS -SELECT 'PACK' || nextval('pack_sequence') AS pack_component_code, +SELECT 'PACK' || ROW_NUMBER() OVER () AS pack_component_code, a.* FROM ( SELECT DISTINCT a.drug_code, @@ -1110,44 +1739,47 @@ FROM ( denominator_value, denominator_unit FROM ds_1 a - JOIN pack_st_1 b ON a.drug_code = b.drug_code - AND a.drug_form = b.drug_form - AND a.ingredient_code = form_code + JOIN pack_st_1 b ON b.drug_code = a.drug_code + AND b.drug_form = a.drug_form + AND b.form_code = a.ingredient_code WHERE a.drug_code NOT IN ( SELECT drug_code FROM non_drug - union - select drug_code - from bdpm_vaccine_manual - union - select drug_code - from homeop_drug + + UNION ALL + + SELECT drug_code + FROM bdpm_vaccine_manual + + UNION ALL + + SELECT drug_code + FROM homeop_drug ) - ) A; - - + ) a; --fill pack content, but need to be changed amounts manually DROP TABLE IF EXISTS pack_cont_1; CREATE TABLE pack_cont_1 AS SELECT DISTINCT concept_code, pack_component_code, - a.drug_descr AS pack_name,a.drug_form, - CONCAT ( + a.drug_descr AS pack_name, + a.drug_form, + CONCAT ( a.drug_descr, ' ', a.drug_form ) AS pack_component_name, - packaging , pack_amount_value,a.denominator_value,a.denominator_unit -FROM pack_comp_list B -JOIN ds_1 A ON a.drug_code = b.drug_code + a.packaging, + a.pack_amount_value, + a.denominator_value, + a.denominator_unit +FROM pack_comp_list b +JOIN ds_1 a ON a.drug_code = b.drug_code AND a.drug_form = b.drug_form AND a.drug_descr = b.drug_descr - AND coalesce(a.denominator_value, '0') = coalesce(b.denominator_value, '0') - AND coalesce(a.denominator_unit, '0') = coalesce(b.denominator_unit, '0'); - - -; + AND COALESCE(a.denominator_value, '0') = COALESCE(b.denominator_value, '0') + AND COALESCE(a.denominator_unit, '0') = COALESCE(b.denominator_unit, '0'); --ds_stage for Pack_components DROP TABLE IF EXISTS ds_pack_1; @@ -1163,19 +1795,19 @@ SELECT pack_component_code, volume_value, volume_unit, pack_amount_value, - PACK_amount_unit, + pack_amount_unit, amount_value, amount_unit, numerator_value, numerator_unit, a.denominator_value, a.denominator_unit, - NULL::INT AS box_size + NULL::INT2 AS box_size FROM ds_1 a -JOIN pack_comp_list b ON coalesce(a.denominator_value, '0') = coalesce(b.denominator_value, '0') - AND coalesce(a.denominator_unit, '0') = coalesce(b.denominator_unit, '0') - AND a.drug_form = b.drug_form - AND a.drug_code = b.drug_code; +JOIN pack_comp_list b ON b.drug_form = a.drug_form + AND b.drug_code = a.drug_code + AND COALESCE(a.denominator_value, '0') = COALESCE(b.denominator_value, '0') + AND COALESCE(a.denominator_unit, '0') = COALESCE(b.denominator_unit, '0'); --pack components forms DROP TABLE IF EXISTS pf_from_pack_comp_list; @@ -1226,7 +1858,6 @@ FROM pack_comp_list pcl JOIN sources.bdpm_drug d ON d.drug_code = pcl.drug_code; --ds_1 for drugs and ds_pack_1 for packs -TRUNCATE TABLE ds_stage; INSERT INTO ds_stage ( drug_concept_code, ingredient_concept_code, @@ -1238,7 +1869,7 @@ INSERT INTO ds_stage ( denominator_value, denominator_unit ) -SELECT concept_code::VARCHAR, +SELECT concept_code, ingredient_code, box_size, amount_value, @@ -1264,119 +1895,161 @@ SELECT pack_component_code, numerator_unit, denominator_value, denominator_unit -FROM ds_pack_1; - +FROM ds_pack_1; UPDATE ds_stage -SET numerator_value = power(10, numerator_value), +SET numerator_value = POWER(10, numerator_value), numerator_unit = 'CCID_50' WHERE numerator_unit = 'log CCID_50'; - - -- extract Suppliers DROP TABLE IF EXISTS dcs_manufacturer; CREATE TABLE dcs_manufacturer AS -SELECT DISTINCT LTRIM(manufacturer,' ') AS concept_name, - drug_code, - 'Supplier'::VARCHAR AS concept_class_id +SELECT DISTINCT LTRIM(manufacturer, ' ') AS concept_name, + drug_code, + 'Supplier' AS concept_class_id FROM sources.bdpm_drug - JOIN sources.bdpm_packaging USING (drug_code) -WHERE drug_code NOT IN -( - SELECT drug_code - FROM non_drug -UNION - SELECT drug_code - FROM bdpm_vaccine_manual -UNION - SELECT drug_code - FROM homeop_drug -) -; +JOIN sources.bdpm_packaging USING (drug_code) +WHERE drug_code NOT IN ( + SELECT drug_code + FROM non_drug + + UNION ALL + + SELECT drug_code + FROM bdpm_vaccine_manual + + UNION ALL + + SELECT drug_code + FROM homeop_drug + ); -- find suppliers automaticly and fit names to standard -drop table if exists dcs_manufacturer_1; -create table dcs_manufacturer_1 as -with az as ( -select a.concept_name as attr_name, a.concept_class_id as attr_class, a.drug_code, c.* -from dcs_manufacturer a -join devv5.concept c on uppeR(a.concept_name) = upper(c.concept_name) -where c.concept_class_id = 'Supplier' -and c.vocabulary_id like 'Rx%' -and c.invalid_reason is null -), -ab as ( -select a.concept_name as attr_name, a.concept_class_id as attr_class, a.drug_code, c.* -from dcs_manufacturer a -join devv5.concept c on uppeR(substring(a.concept_name, '^\w+')) = upper(c.concept_name) -where c.concept_class_id = 'Supplier' -and c.invalid_reason is null -and c.vocabulary_id like 'Rx%' -and a.drug_code not in (select drug_code from az) -), -ac as ( -select a.concept_name as attr_name, a.concept_class_id as attr_class, a.drug_code, c.* -from dcs_manufacturer a -join devv5.concept c on uppeR(substring(a.concept_name, '^\w+\s\w+')) = upper(c.concept_name) -where c.concept_class_id = 'Supplier' -and c.invalid_reason is null -and c.vocabulary_id like 'Rx%' -and a.drug_code not in (select drug_code from az union select drug_code from ab) -) - -select * from az -union -select * from ab -union -select * from ac -; +DROP TABLE IF EXISTS dcs_manufacturer_1; +CREATE TABLE dcs_manufacturer_1 AS + WITH az AS ( + SELECT a.concept_name AS attr_name, + a.concept_class_id AS attr_class, + a.drug_code, + c.* + FROM dcs_manufacturer a + JOIN concept c ON UPPER(a.concept_name) = UPPER(c.concept_name) + WHERE c.concept_class_id = 'Supplier' + AND c.vocabulary_id LIKE 'Rx%' + AND c.invalid_reason IS NULL + ), + ab AS ( + SELECT a.concept_name AS attr_name, + a.concept_class_id AS attr_class, + a.drug_code, + c.* + FROM dcs_manufacturer a + JOIN concept c ON UPPER(SUBSTRING(a.concept_name, '^\w+')) = UPPER(c.concept_name) + WHERE c.concept_class_id = 'Supplier' + AND c.invalid_reason IS NULL + AND c.vocabulary_id LIKE 'Rx%' + AND a.drug_code NOT IN ( + SELECT drug_code + FROM az + ) + ), + ac AS ( + SELECT a.concept_name AS attr_name, + a.concept_class_id AS attr_class, + a.drug_code, + c.* + FROM dcs_manufacturer a + JOIN concept c ON UPPER(SUBSTRING(a.concept_name, '^\w+\s\w+')) = UPPER(c.concept_name) + WHERE c.concept_class_id = 'Supplier' + AND c.invalid_reason IS NULL + AND c.vocabulary_id LIKE 'Rx%' + AND a.drug_code NOT IN ( + SELECT drug_code + FROM az + + UNION ALL + + SELECT drug_code + FROM ab + ) + ) +SELECT * +FROM az -insert into dcs_manufacturer_1 -with upd as( -select m.concept_name as attr_name, m.concept_class_id as attr_class, m.drug_code, c.concept_id from dcs_manufacturer m, concept c -where drug_code not in (select drug_code from dcs_manufacturer_1) -and m.concept_name like c.concept_name||'%' -and c.vocabulary_id in ('RxNorm','RxNorm Extension') -and c.concept_class_id = 'Supplier' -and c.invalid_reason != 'D' -and length(c.concept_name) > 3 -and c.concept_name not in ('PHARMA') -) - - -select attr_name,attr_class,drug_code, cc.* -from concept_relationship r, upd, concept cc -where r.concept_id_1 = upd.concept_id -and cc.concept_id = r.concept_id_2 -and r.invalid_reason is null -and cc.vocabulary_id in ('RxNorm','RxNorm Extension') -and cc.invalid_reason is null -; +UNION ALL + +SELECT * +FROM ab +UNION ALL +SELECT * +FROM ac; + +INSERT INTO dcs_manufacturer_1 +WITH upd AS ( + SELECT m.concept_name AS attr_name, + m.concept_class_id AS attr_class, + m.drug_code, + c.concept_id + FROM dcs_manufacturer m, + concept c + WHERE drug_code NOT IN ( + SELECT drug_code + FROM dcs_manufacturer_1 + ) + AND m.concept_name LIKE c.concept_name || '%' + AND c.vocabulary_id IN ( + 'RxNorm', + 'RxNorm Extension' + ) + AND c.concept_class_id = 'Supplier' + --and c.invalid_reason != 'D' --?? only 'U' will match + AND c.invalid_reason IS NULL /*confirmed by Dima*/ + AND LENGTH(c.concept_name) > 3 + AND c.concept_name NOT IN ('PHARMA') + ) +SELECT attr_name, + attr_class, + drug_code, + cc.* +FROM concept_relationship r, + upd, + concept cc +WHERE r.concept_id_1 = upd.concept_id + AND cc.concept_id = r.concept_id_2 + AND r.invalid_reason IS NULL + AND cc.vocabulary_id IN ( + 'RxNorm', + 'RxNorm Extension' + ) + AND cc.invalid_reason IS NULL; --Parsing drug description extracting brand names DROP TABLE IF EXISTS brand_name; CREATE TABLE brand_name AS -SELECT rtrim(substring(drug_descr, '^(([A-Z]+(\s)?-?/?[A-Z]+(\s)?[A-Z]?)+)'), ' ') AS brand_name, +SELECT RTRIM(SUBSTRING(drug_descr, '^(([A-Z]+(\s)?-?/?[A-Z]+(\s)?[A-Z]?)+)')) AS brand_name, drug_code FROM sources.bdpm_drug -join sources.bdpm_packaging using(drug_code) +JOIN sources.bdpm_packaging USING (drug_code) WHERE drug_descr NOT LIKE '%degré de dilution compris entre%' - AND substring(drug_descr, '^(([A-Z]+(\s)?-?[A-Z]+)+)') IS NOT NULL - and drug_code not in (select drug_code -from non_drug -union -select drug_code -from bdpm_vaccine_manual -union -select drug_code -from homeop_drug -) - -; + AND SUBSTRING(drug_descr, '^(([A-Z]+(\s)?-?[A-Z]+)+)') IS NOT NULL + AND drug_code NOT IN ( + SELECT drug_code + FROM non_drug + + UNION ALL + + SELECT drug_code + FROM bdpm_vaccine_manual + + UNION ALL + + SELECT drug_code + FROM homeop_drug + ); UPDATE brand_name SET brand_name = 'NP100 PREMATURES AP-HP' @@ -1409,52 +2082,46 @@ WHERE brand_name LIKE 'ACTIVOX %'; -- delete Brand name that equal as Ingredient name (RxNorm) DELETE FROM brand_name -WHERE upper(brand_name) IN ( - SELECT upper(concept_name) +WHERE UPPER(brand_name) IN ( + SELECT UPPER(concept_name) FROM concept WHERE concept_class_id = 'Ingredient' ); - -- delete Brand name that equal as Ingredient name (BDPM original) DELETE FROM brand_name -WHERE lower(substring(brand_name,'^\w+')) IN ( - SELECT lower(original_name) - FROM rtc_1 - where attr_class = 'Ingredient' +WHERE LOWER(SUBSTRING(brand_name, '^\w+')) IN ( + SELECT LOWER(original_name) + FROM rtc_1 + WHERE attr_class = 'Ingredient' ); --Brand name = Ingredient (BDPM translated) DELETE FROM brand_name -WHERE lower(substring(brand_name,'^\w+')) IN ( - SELECT lower(attr_name) +WHERE LOWER(SUBSTRING(brand_name,'^\w+')) IN ( + SELECT LOWER(attr_name) FROM rtc_1 where attr_class = 'Ingredient' ); - -delete +DELETE FROM brand_name -WHERE lower(substring(brand_name,'^\w+\s\w+')) IN ( - SELECT lower(original_name) - FROM rtc_1 - where attr_class = 'Ingredient' +WHERE LOWER(SUBSTRING(brand_name, '^\w+\s\w+')) IN ( + SELECT LOWER(original_name) + FROM rtc_1 + WHERE attr_class = 'Ingredient' ); - -delete + +DELETE FROM brand_name -WHERE lower(substring(brand_name,'^\w+\s\w+')) IN ( - SELECT lower(attr_name) - FROM rtc_1 - where attr_class = 'Ingredient' +WHERE LOWER(SUBSTRING(brand_name, '^\w+\s\w+')) IN ( + SELECT LOWER(attr_name) + FROM rtc_1 + WHERE attr_class = 'Ingredient' ); - - - - -- manual delete DELETE FROM brand_name @@ -1471,188 +2138,273 @@ WHERE brand_name IN ( ); UPDATE brand_name -SET brand_name = regexp_replace(brand_name, 'ADULTES|ENFANTS|NOURRISSONS', '', 'g') -WHERE brand_name ilike 'SUPPOSITOIRE%'; +SET brand_name = REGEXP_REPLACE(brand_name, 'ADULTES|ENFANTS|NOURRISSONS', '', 'g') +WHERE brand_name ILIKE 'SUPPOSITOIRE%'; -drop table if exists bn; -CREATE TABLE bn -AS +DROP TABLE IF EXISTS bn; +CREATE TABLE bn AS SELECT * FROM brand_name - JOIN concept - ON UPPER (brand_name) = UPPER (concept_name) - AND vocabulary_id = 'RxNorm Extension' - AND invalid_reason = 'D'; +JOIN concept ON UPPER(brand_name) = UPPER(concept_name) + AND vocabulary_id = 'RxNorm Extension' + AND invalid_reason = 'D'; DELETE FROM bn -WHERE brand_name IN (SELECT brand_name - FROM bn - JOIN concept c - ON brand_name = UPPER (c.concept_name) - AND c.concept_class_id = 'Brand Name' - AND c.invalid_reason IS NULL - AND c.vocabulary_id LIKE 'Rx%'); +WHERE brand_name IN ( + SELECT brand_name + FROM bn + JOIN concept c ON brand_name = UPPER(c.concept_name) + AND c.concept_class_id = 'Brand Name' + AND c.invalid_reason IS NULL + AND c.vocabulary_id LIKE 'Rx%' + ); DELETE FROM bn -WHERE brand_name IN ('ADEPAL','AMARANCE','AVADENE','BIAFINE','BORIPHARM N','CARBOSYLANE ENFANT','CARBOSYMAG','CLINIMIX N','CRESOPHENE','DETURGYLONE','EVANECIA','FEMSEPTCOMBI','HEPARGITOL','JASMINE','LEUCODININE B','NOVOFEMME','NUMETAH G','PACILIA','PERMIXON','PHAEVA','REVITALOSE'); +WHERE brand_name IN ( + 'ADEPAL', + 'AMARANCE', + 'AVADENE', + 'BIAFINE', + 'BORIPHARM N', + 'CARBOSYLANE ENFANT', + 'CARBOSYMAG', + 'CLINIMIX N', + 'CRESOPHENE', + 'DETURGYLONE', + 'EVANECIA', + 'FEMSEPTCOMBI', + 'HEPARGITOL', + 'JASMINE', + 'LEUCODININE B', + 'NOVOFEMME', + 'NUMETAH G', + 'PACILIA', + 'PERMIXON', + 'PHAEVA', + 'REVITALOSE' + ); DELETE FROM brand_name -WHERE brand_name IN (SELECT brand_name FROM bn); +WHERE brand_name IN ( + SELECT brand_name + FROM bn + ); DELETE FROM brand_name -WHERE SUBSTRING(UPPER(brand_name),'(\w+)E ') IN (SELECT UPPER(concept_name) - FROM concept - WHERE concept_Class_id = 'Ingredient') -; +WHERE SUBSTRING(UPPER(brand_name), '(\w+)E ') IN ( + SELECT UPPER(concept_name) + FROM concept + WHERE concept_Class_id = 'Ingredient' + ); UPDATE brand_name - SET brand_name = 'FERVEX' -WHERE brand_name ~* 'fervex' -; -UPDATE brand_name - SET brand_name = 'ALYOSTAL' -WHERE brand_name ~* 'ALYOSTAL' -; -UPDATE brand_name - SET brand_name = 'DRILL MAUX DE GORGE' -WHERE brand_name ~* 'DRILL MAUX DE GORGE' -; -UPDATE brand_name - SET brand_name = 'MICROLAX' -WHERE brand_name ~* 'MICROLAX' -; +SET brand_name = 'FERVEX' +WHERE brand_name ILIKE '%fervex%'; + UPDATE brand_name - SET brand_name = 'RHINADVIL' -WHERE brand_name ~* 'RHINADVIL' -; +SET brand_name = 'ALYOSTAL' +WHERE brand_name ILIKE '%ALYOSTAL%'; + UPDATE brand_name - SET brand_name = 'ARKOGELULES' -WHERE brand_name ~* 'ARKOGELULES' -; +SET brand_name = 'DRILL MAUX DE GORGE' +WHERE brand_name ILIKE '%DRILL MAUX DE GORGE%'; + UPDATE brand_name - SET brand_name = 'OLIGOSTIM' -WHERE brand_name ~* 'OLIGOSTIM' -; +SET brand_name = 'MICROLAX' +WHERE brand_name ILIKE '%MICROLAX%'; + UPDATE brand_name - SET brand_name = 'ELUSANES' -WHERE brand_name ~* 'ELUSANES' -; +SET brand_name = 'RHINADVIL' +WHERE brand_name ILIKE '%RHINADVIL%'; + UPDATE brand_name - SET brand_name = 'ANGI SPRAY' -WHERE brand_name ~* 'ANGI\-SPRAY' -; +SET brand_name = 'ARKOGELULES' +WHERE brand_name ILIKE '%ARKOGELULES%'; + UPDATE brand_name - SET brand_name = 'ELEVIT' -WHERE brand_name ~* 'ELEVIT' -; +SET brand_name = 'OLIGOSTIM' +WHERE brand_name ILIKE '%OLIGOSTIM%'; -with a as -( -select drug_code, brand_name, ingredient , position(upper(regexp_replace(ingredient, 'É' , 'E')) in upper(brand_name)) as p1 -from brand_name -join sources.bdpm_ingredient using(drug_code) -where length (ingredient) > 4 -), -b as ( -select drug_code, brand_name, ingredient , position(upper(substring(regexp_replace(ingredient, 'É' , 'E'),'^\w+\s\w+\s\w+')) in upper(brand_name)) as p1 -from brand_name -join sources.bdpm_ingredient using(drug_code) -where length (ingredient) > 4 -and drug_code not in (select drug_code from a where p1 >0) -), -c as ( -select drug_code, brand_name, ingredient , position(upper(substring(regexp_replace(ingredient, 'É' , 'E'),'^\w+\s\w+')) in upper(brand_name)) as p1 -from brand_name -join sources.bdpm_ingredient using(drug_code) -where length (ingredient) > 4 -and drug_code not in (select drug_code from a where p1 >0 union select drug_code from b where p1 >0 ) -), -d as ( -select * from ( -select drug_code, brand_name, ingredient , position(upper(substring(regexp_replace(ingredient, 'É' , 'E'),'^\w+')) in upper(brand_name)) as p1 -from brand_name -join sources.bdpm_ingredient using(drug_code) -where length (ingredient) > 4 -and drug_code not in -( -select drug_code from a where p1 >0 -union -select drug_code from b where p1 >0 -union -select drug_code from c where p1 >0 -) -) ds where p1>0 -) - - - - - -delete from brand_name -where drug_code in ( -select drug_code from a where p1 >0 -union -select drug_code from b where p1 >0 -union -select drug_code from c where p1 >0 -union -select drug_code from d where p1 >0 -) -and drug_code not in -( -select drug_code from brand_name where upper(substring(brand_name,'^\w+')) in (select upper(concept_name) from devv5.concept where concept_class_id = 'Brand Name' and vocabulary_id like 'Rx%' and invalid_reason is null) -) -; +UPDATE brand_name +SET brand_name = 'ELUSANES' +WHERE brand_name ILIKE '%ELUSANES%'; +UPDATE brand_name +SET brand_name = 'ANGI SPRAY' +WHERE brand_name ILIKE '%ANGI-SPRAY%'; -delete from brand_name where brand_name ~* 'GOMENOL|GOMENOL SOLUBLE|GOMENOLEO|HEPATOUM'; - +UPDATE brand_name +SET brand_name = 'ELEVIT' +WHERE brand_name ILIKE '%ELEVIT%'; + +WITH a +AS ( + SELECT drug_code, + brand_name, + ingredient, + position(UPPER(REPLACE(ingredient, 'É', 'E')) IN UPPER(brand_name)) AS p1 + FROM brand_name + JOIN sources.bdpm_ingredient USING (drug_code) + WHERE LENGTH(ingredient) > 4 + ), +b +AS ( + SELECT drug_code, + brand_name, + ingredient, + position(UPPER(SUBSTRING(REPLACE(ingredient, 'É', 'E'), '^\w+\s\w+\s\w+')) IN UPPER(brand_name)) AS p1 + FROM brand_name + JOIN sources.bdpm_ingredient USING (drug_code) + WHERE LENGTH(ingredient) > 4 + AND drug_code NOT IN ( + SELECT drug_code + FROM a + WHERE p1 > 0 + ) + ), +c +AS ( + SELECT drug_code, + brand_name, + ingredient, + position(UPPER(SUBSTRING(REPLACE(ingredient, 'É', 'E'), '^\w+\s\w+')) IN UPPER(brand_name)) AS p1 + FROM brand_name + JOIN sources.bdpm_ingredient USING (drug_code) + WHERE LENGTH(ingredient) > 4 + AND drug_code NOT IN ( + SELECT drug_code + FROM a + WHERE p1 > 0 + + UNION ALL + + SELECT drug_code + FROM b + WHERE p1 > 0 + ) + ), +d +AS ( + SELECT * + FROM ( + SELECT drug_code, + brand_name, + ingredient, + position(UPPER(SUBSTRING(REPLACE(ingredient, 'É', 'E'), '^\w+')) IN UPPER(brand_name)) AS p1 + FROM brand_name + JOIN sources.bdpm_ingredient USING (drug_code) + WHERE LENGTH(ingredient) > 4 + AND drug_code NOT IN ( + SELECT drug_code + FROM a + WHERE p1 > 0 + + UNION ALL + + SELECT drug_code + FROM b + WHERE p1 > 0 + + UNION ALL + + SELECT drug_code + FROM c + WHERE p1 > 0 + ) + ) ds + WHERE p1 > 0 + ) +DELETE +FROM brand_name +WHERE drug_code IN ( + SELECT drug_code + FROM a + WHERE p1 > 0 + + UNION ALL + + SELECT drug_code + FROM b + WHERE p1 > 0 + + UNION ALL + + SELECT drug_code + FROM c + WHERE p1 > 0 + + UNION ALL + + SELECT drug_code + FROM d + WHERE p1 > 0 + ) + AND drug_code NOT IN ( + SELECT drug_code + FROM brand_name + WHERE UPPER(SUBSTRING(brand_name, '^\w+')) IN ( + SELECT UPPER(concept_name) + FROM concept + WHERE concept_class_id = 'Brand Name' + AND vocabulary_id LIKE 'Rx%' + AND invalid_reason IS NULL + ) + ); +DELETE +FROM brand_name +WHERE brand_name ~* 'GOMENOL|GOMENOL SOLUBLE|GOMENOLEO|HEPATOUM'; --list for drug_concept_stage DROP TABLE IF EXISTS dcs_bn; CREATE TABLE dcs_bn AS SELECT DISTINCT brand_name AS concept_name, - 'Brand Name'::VARCHAR AS concept_class_id + 'Brand Name' AS concept_class_id FROM brand_name WHERE drug_code NOT IN ( SELECT drug_code FROM non_drug - ) -; + ); --list of Dose Form (translated before) DROP TABLE IF EXISTS list; CREATE TABLE list AS -SELECT distinct trim(initcap(attr_name)) AS concept_name, - 'Dose Form'::VARCHAR AS concept_class_id, +SELECT TRIM(INITCAP(attr_name)) AS concept_name, + 'Dose Form' AS concept_class_id, NULL::VARCHAR AS concept_code -FROM rtc_1 -where upper(trim(original_name)) in -( -select distinct upper(replace(CONCAT(trim(form),' ',trim(route)),' ',' ')) -from sources.bdpm_drug -join sources.bdpm_packaging using(drug_code) -where drug_code not in -(select drug_code from non_drug - union - select drug_code - from bdpm_vaccine_manual - union - SELECT drug_code - FROM homeop_drug -) -) - +FROM rtc_1 +WHERE UPPER(TRIM(original_name)) IN ( + SELECT UPPER(REPLACE(CONCAT ( + TRIM(form), + ' ', + TRIM(route) + ), ' ', ' ')) + FROM sources.bdpm_drug + JOIN sources.bdpm_packaging USING (drug_code) + WHERE drug_code NOT IN ( + SELECT drug_code + FROM non_drug + + UNION ALL + + SELECT drug_code + FROM bdpm_vaccine_manual + + UNION ALL + + SELECT drug_code + FROM homeop_drug + ) + ) UNION --Brand Names -SELECT trim(concept_name), +SELECT TRIM(concept_name), concept_class_id, NULL FROM dcs_bn @@ -1660,24 +2412,26 @@ FROM dcs_bn UNION --manufacturers -SELECT distinct uppeR(trim(concept_name)), +SELECT UPPER(TRIM(concept_name)), concept_class_id, NULL -from dcs_manufacturer_1 +FROM dcs_manufacturer_1 -union +UNION -SELECT distinct uppeR(trim(concept_name)), +SELECT UPPER(TRIM(concept_name)), concept_class_id, NULL FROM dcs_manufacturer -where concept_name not in (select -attr_name from dcs_manufacturer_1) -; +WHERE concept_name NOT IN ( + SELECT attr_name + FROM dcs_manufacturer_1 + ); DELETE FROM list WHERE concept_name LIKE '%Enteric Oral Capsule%'; + /* INSERT INTO list VALUES ( @@ -1686,22 +2440,18 @@ VALUES ( NULL );*/ -DO $$ DECLARE ex INTEGER; - +DO $$ +DECLARE + ex INTEGER; BEGIN -SELECT MAX(REPLACE(concept_code,'OMOP','')::INT4) +1 INTO ex -FROM devv5.concept -WHERE concept_code LIKE 'OMOP%' -AND concept_code NOT LIKE '% %'; - -DROP SEQUENCE IF EXISTS new_vocab; + SELECT MAX(REPLACE(concept_code,'OMOP','')::INT4) +1 INTO ex FROM concept WHERE concept_code LIKE 'OMOP%' AND concept_code NOT LIKE '% %'; + DROP SEQUENCE IF EXISTS new_vocab; + EXECUTE 'CREATE SEQUENCE new_vocab START WITH ' || ex || ' CACHE 20'; +END $$; -EXECUTE 'CREATE SEQUENCE new_vocab INCREMENT BY 1 START WITH ' || ex || ' NO CYCLE CACHE 20'; - -END $$; --put OMOP||numbers UPDATE list -SET concept_code = 'OMOP' || nextval('new_vocab'); +SET concept_code = 'OMOP' || NEXTVAL('new_vocab'); --Fill drug_concept_stage --Drug Product @@ -1721,10 +2471,10 @@ SELECT SUBSTR(d.drug_descr, 1, 240), 'BDPM', 'Drug Product', NULL, - din_7::VARCHAR, + p.din_7, NULL, 'Drug', - approval_date, + d.approval_date, TO_DATE('20991231', 'yyyymmdd'), NULL FROM sources.bdpm_drug d @@ -1755,10 +2505,10 @@ SELECT SUBSTR(d.drug_descr, 1, 240), 'BDPM', 'Device', 'S', - din_7::VARCHAR, + p.din_7, NULL, 'Device', - approval_date, + d.approval_date, TO_DATE('20991231', 'yyyymmdd'), NULL FROM sources.bdpm_drug d @@ -1781,7 +2531,7 @@ INSERT INTO drug_concept_stage ( valid_end_date, invalid_reason ) -SELECT DISTINCT initcap(concept_name), +SELECT DISTINCT INITCAP(concept_name), 'BDPM', concept_class_id, NULL, @@ -1794,40 +2544,44 @@ SELECT DISTINCT initcap(concept_name), FROM list; -- units -INSERT INTO drug_concept_stage -( - concept_name, - vocabulary_id, - concept_class_id, - standard_concept, - concept_code, - possible_excipient, - domain_id, - valid_start_date, - valid_end_date, - invalid_reason -) +INSERT INTO drug_concept_stage ( + concept_name, + vocabulary_id, + concept_class_id, + standard_concept, + concept_code, + possible_excipient, + domain_id, + valid_start_date, + valid_end_date, + invalid_reason + ) SELECT DISTINCT attr_name, - 'BDPM', - 'Unit', - NULL, - attr_name, - NULL, - 'Drug', - TO_DATE('19700101','yyyymmdd'), - TO_DATE('20991231','yyyymmdd'), - NULL + 'BDPM', + 'Unit', + NULL, + attr_name, + NULL, + 'Drug', + TO_DATE('19700101', 'yyyymmdd'), + TO_DATE('20991231', 'yyyymmdd'), + NULL FROM rtc_1 -WHERE attr_name IN (SELECT amount_unit - FROM ds_stage - UNION - SELECT numerator_unit - FROM ds_stage - UNION - SELECT denominator_unit - FROM ds_stage) -and attr_class = 'Unit' -; +WHERE attr_name IN ( + SELECT amount_unit + FROM ds_stage + + UNION ALL + + SELECT numerator_unit + FROM ds_stage + + UNION ALL + + SELECT denominator_unit + FROM ds_stage + ) + AND attr_class = 'Unit'; -- Pack_components INSERT INTO drug_concept_stage ( @@ -1892,48 +2646,60 @@ INSERT INTO drug_concept_stage ( valid_end_date, invalid_reason ) -SELECT DISTINCT --initcap(trim(original_name)), -initcap(trim(first_value (attr_name) over(partition by form_code))), +SELECT DISTINCT --INITCAP(TRIM(original_name)), + INITCAP(TRIM(FIRST_VALUE(a.attr_name) OVER (PARTITION BY i.form_code))), 'BDPM', 'Ingredient', NULL, - form_code, + i.form_code, NULL, 'Drug', TO_DATE('19700101', 'yyyymmdd'), TO_DATE('20991231', 'yyyymmdd'), NULL -FROM (select original_name,attr_name from rtc_ingred union select original_name,attr_name from rtc_1 where attr_class = 'Ingredient') a -join ingredient_step_2 on trim(upper(original_name)) = trim(upper(ingredient)) -where drug_code NOT IN ( +FROM ( + SELECT original_name, + attr_name + FROM rtc_ingred + + UNION + + SELECT original_name, + attr_name + FROM rtc_1 + WHERE attr_class = 'Ingredient' + ) a +JOIN ingredient_step_2 i ON TRIM(UPPER(i.ingredient)) = TRIM(UPPER(a.original_name)) +WHERE drug_code NOT IN ( SELECT drug_code FROM non_drug - union - select drug_code - from bdpm_vaccine_manual - union - SELECT drug_code - FROM homeop_drug -) - ; + + UNION ALL + + SELECT drug_code + FROM bdpm_vaccine_manual + + UNION ALL + + SELECT drug_code + FROM homeop_drug + ); --Forms mapping INSERT INTO relationship_to_concept ( concept_code_1, vocabulary_id_1, concept_id_2, - precedence, - conversion_factor + precedence ) -SELECT distinct concept_code, +SELECT DISTINCT concept_code, 'BDPM', - to_id, - precedence, - NULL::float -FROM rtc_1 --manual table -JOIN drug_concept_stage d ON lower(d.concept_name) = lower(attr_name) -where attr_class = 'Dose Form' and to_id is not null -; + r.to_id, + r.precedence +FROM rtc_1 r --manual table +JOIN drug_concept_stage d ON LOWER(d.concept_name) = LOWER(r.attr_name) +WHERE r.attr_class = 'Dose Form' + AND r.to_id IS NOT NULL; --units INSERT INTO relationship_to_concept ( @@ -1943,120 +2709,126 @@ INSERT INTO relationship_to_concept ( precedence, conversion_factor ) -SELECT distinct concept_code, +SELECT DISTINCT concept_code, 'BDPM', - to_id, - precedence, - conversion_factor -FROM rtc_1 --manual table -join drug_concept_stage ON lower( concept_name) = lower(attr_name) -where attr_class = 'Unit' and to_id is not null -; - - + r.to_id, + r.precedence, + r.conversion_factor +FROM rtc_1 r --manual table +JOIN drug_concept_stage d ON LOWER(d.concept_name) = LOWER(r.attr_name) +WHERE r.attr_class = 'Unit' + AND r.to_id IS NOT NULL; INSERT INTO relationship_to_concept ( concept_code_1, vocabulary_id_1, concept_id_2, - precedence, - conversion_factor + precedence ) -SELECT distinct d.concept_code , +SELECT DISTINCT d.concept_code, 'BDPM', - to_id, - case when precedence is null then 1 else precedence end , - NULL::float -from (select original_name,attr_name,to_id,precedence from rtc_ingred union select original_name,attr_name,to_id,precedence from rtc_1 where attr_class = 'Ingredient') a -join drug_concept_stage d ON lower( concept_name) = lower(attr_name) -where d.concept_class_id = 'Ingredient' and to_id is not null ---FROM RxE_Ing_st_0 -- RxNormExtension name equivalence - ; - + a.to_id, + COALESCE(a.precedence, 1) +FROM ( + SELECT original_name, + attr_name, + to_id, + precedence + FROM rtc_ingred + + UNION + + SELECT original_name, + attr_name, + to_id, + precedence + FROM rtc_1 + WHERE attr_class = 'Ingredient' + ) a +JOIN drug_concept_stage d ON LOWER(d.concept_name) = LOWER(a.attr_name) +WHERE d.concept_class_id = 'Ingredient' + AND a.to_id IS NOT NULL; + --FROM RxE_Ing_st_0 -- RxNormExtension name equivalence --suppliers found manually INSERT INTO relationship_to_concept ( concept_code_1, vocabulary_id_1, concept_id_2, - precedence, - conversion_factor + precedence ) -select c.concept_code, -c.vocabulary_id, -a.concept_id, -1, -NULL::float -from devv5.concept a -join drug_concept_stage c on upper(c.concept_name) = upper(a.concept_name) -where c.concept_class_id = 'Supplier' -and a.concept_class_id = 'Supplier' -and a.invalid_reason is null -and a.vocabulary_id like 'Rx%' -; +SELECT c.concept_code, + c.vocabulary_id, + a.concept_id, + 1 +FROM concept a +JOIN drug_concept_stage c ON UPPER(c.concept_name) = UPPER(a.concept_name) +WHERE c.concept_class_id = 'Supplier' + AND a.concept_class_id = 'Supplier' + AND a.invalid_reason IS NULL + AND a.vocabulary_id LIKE 'Rx%'; INSERT INTO relationship_to_concept ( concept_code_1, vocabulary_id_1, concept_id_2, - precedence, - conversion_factor + precedence ) -SELECT distinct concept_code , +SELECT DISTINCT concept_code, 'BDPM', - to_id, - precedence, - NULL::float -from rtc_1 -join drug_concept_stage ON lower( concept_name) = lower(attr_name) -where concept_class_id = 'Supplier' and to_id is not null -and concept_code not in ( select concept_code_1 from relationship_to_concept) -; + r.to_id, + r.precedence +FROM rtc_1 r +JOIN drug_concept_stage d ON LOWER(d.concept_name) = LOWER(r.attr_name) +WHERE d.concept_class_id = 'Supplier' + AND r.to_id IS NOT NULL + AND d.concept_code NOT IN ( + SELECT concept_code_1 + FROM relationship_to_concept + ); --Brands from RxE - INSERT INTO relationship_to_concept ( concept_code_1, vocabulary_id_1, concept_id_2, - precedence, - conversion_factor + precedence ) -SELECT distinct concept_code , +SELECT DISTINCT concept_code, 'BDPM', - to_id, - precedence, - NULL::float -from rtc_1 -join drug_concept_stage ON lower( concept_name) = lower(attr_name) -where concept_class_id = 'Brand Name' and to_id is not null;-- RxNormExtension name equivalence + r.to_id, + r.precedence +FROM rtc_1 r +JOIN drug_concept_stage d ON LOWER(d.concept_name) = LOWER(r.attr_name) +WHERE concept_class_id = 'Brand Name' + AND r.to_id IS NOT NULL;-- RxNormExtension name equivalence INSERT INTO relationship_to_concept ( concept_code_1, vocabulary_id_1, concept_id_2, - precedence, - conversion_factor + precedence ) -SELECT distinct dc.concept_code , +SELECT DISTINCT dc.concept_code, 'BDPM', c.concept_id, - 1 as precedence, - NULL::float -from /*rtc_1*/ concept c -join drug_concept_stage dc ON lower(dc.concept_name) = lower(c.concept_name) -where c.concept_class_id = dc.concept_class_id and c.concept_class_id = 'Brand Name' --and to_id is not null -and dc.concept_code not in ( select concept_code_1 from relationship_to_concept) -and c.vocabulary_id like 'Rx%' -and c.invalid_reason is null -;-- RxNormExtension name equivalence - - + 1 AS precedence +FROM /*rtc_1*/ concept c +JOIN drug_concept_stage dc ON LOWER(dc.concept_name) = LOWER(c.concept_name) +WHERE c.concept_class_id = dc.concept_class_id + AND c.concept_class_id = 'Brand Name' --and to_id is not null + AND dc.concept_code NOT IN ( + SELECT concept_code_1 + FROM relationship_to_concept + ) + AND c.vocabulary_id LIKE 'Rx%' + AND c.invalid_reason IS NULL; + -- RxNormExtension name equivalence /* drop table if exists relationship_concept_to_map; create table relationship_concept_to_map_1 as -SELECT coalesce(ingredient,unit) as original_name, coalesce (a.concept_name,ingredient,unit) as attr_name, a.concept_class_id as attr_class, null::integer as concept_id_2, null::integer as precedenece, null::float as conversion_factor, null::varchar as indicator_rxe +SELECT COALESCE(ingredient,unit) as original_name, COALESCE (a.concept_name,ingredient,unit) as attr_name, a.concept_class_id as attr_class, null::integer as concept_id_2, null::integer as precedenece, null::NUMERIC as conversion_factor, null::varchar as indicator_rxe FROM drug_concept_stage a LEFT JOIN relationship_to_concept c ON c.concept_code_1 = a.concept_code LEFT JOIN (SELECT amount_unit AS unit @@ -2085,9 +2857,6 @@ and c.concept_code_1 is null ; */ - - - ---manual work /*drop table if exists pack_amount_manual; create table pack_amount_manual as @@ -2099,836 +2868,910 @@ order by concept_code, pack_component_code ; */ -************************* - - -update pack_cont_1 a -set pack_amount_value = c.pack_amount_value -from pack_amount_manual c -where a.concept_code = c.concept_code -and a.packaging = c.packaging -and a.drug_form = c.drug_form -; +DO $$ +BEGIN +UPDATE pack_cont_1 a +SET pack_amount_value = c.pack_amount_value +FROM pack_amount_manual c +WHERE a.concept_code = c.concept_code + AND a.packaging = c.packaging + AND a.drug_form = c.drug_form; + UPDATE pack_cont_1 - SET pack_amount_value = '2' +SET pack_amount_value = '2' WHERE concept_code = '3016965' -AND pack_name = 'APREPITANT ZENTIVA 125 mg, gélule et APREPITANT ZENTIVA 80 mg, gélule' -AND drug_form = 'gélule blanche' -AND pack_component_name = 'APREPITANT ZENTIVA 125 mg, gélule et APREPITANT ZENTIVA 80 mg, gélule gélule blanche' -AND packaging = 'plaquette(s) polyamide aluminium PVC de 1 gélule de 125 mg et de 2 gélule(s) blanches' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'APREPITANT ZENTIVA 125 mg, gélule et APREPITANT ZENTIVA 80 mg, gélule' + AND drug_form = 'gélule blanche' + AND pack_component_name = 'APREPITANT ZENTIVA 125 mg, gélule et APREPITANT ZENTIVA 80 mg, gélule gélule blanche' + AND packaging = 'plaquette(s) polyamide aluminium PVC de 1 gélule de 125 mg et de 2 gélule(s) blanches' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '3016965' -AND pack_name = 'APREPITANT ZENTIVA 125 mg, gélule et APREPITANT ZENTIVA 80 mg, gélule' -AND drug_form = 'gélule blanche et rose' -AND pack_component_name = 'APREPITANT ZENTIVA 125 mg, gélule et APREPITANT ZENTIVA 80 mg, gélule gélule blanche et rose' -AND packaging = 'plaquette(s) polyamide aluminium PVC de 1 gélule de 125 mg et de 2 gélule(s) blanches' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '14' -WHERE concept_code = '3584622' -AND pack_name = 'NAEMIS, comprimé' -AND drug_form = 'comprimé blanc' -AND pack_component_name = 'NAEMIS, comprimé comprimé blanc' -AND packaging = '1 plaquette(s) PVC polyéthylène aluminium-ACLAR de 24 comprimés (10 comprimés roses et 14 comprimés blancs)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '10' + AND pack_name = 'APREPITANT ZENTIVA 125 mg, gélule et APREPITANT ZENTIVA 80 mg, gélule' + AND drug_form = 'gélule blanche et rose' + AND pack_component_name = 'APREPITANT ZENTIVA 125 mg, gélule et APREPITANT ZENTIVA 80 mg, gélule gélule blanche et rose' + AND packaging = 'plaquette(s) polyamide aluminium PVC de 1 gélule de 125 mg et de 2 gélule(s) blanches' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '14' WHERE concept_code = '3584622' -AND pack_name = 'NAEMIS, comprimé' -AND drug_form = 'comprimé rose' -AND pack_component_name = 'NAEMIS, comprimé comprimé rose' -AND packaging = '1 plaquette(s) PVC polyéthylène aluminium-ACLAR de 24 comprimés (10 comprimés roses et 14 comprimés blancs)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; + AND pack_name = 'NAEMIS, comprimé' + AND drug_form = 'comprimé blanc' + AND pack_component_name = 'NAEMIS, comprimé comprimé blanc' + AND packaging = '1 plaquette(s) PVC polyéthylène aluminium-ACLAR de 24 comprimés (10 comprimés roses et 14 comprimés blancs)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; +UPDATE pack_cont_1 +SET pack_amount_value = '10' +WHERE concept_code = '3584622' + AND pack_name = 'NAEMIS, comprimé' + AND drug_form = 'comprimé rose' + AND pack_component_name = 'NAEMIS, comprimé comprimé rose' + AND packaging = '1 plaquette(s) PVC polyéthylène aluminium-ACLAR de 24 comprimés (10 comprimés roses et 14 comprimés blancs)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; UPDATE pack_cont_1 - SET pack_amount_value = '5' +SET pack_amount_value = '5' WHERE concept_code = '3008105' -AND pack_name = 'TRINORDIOL, comprimé enrobé' -AND drug_form = 'comprimé blanc' -AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé blanc' -AND packaging = '1 plaquette(s) PVC-Aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '6' + AND pack_name = 'TRINORDIOL, comprimé enrobé' + AND drug_form = 'comprimé blanc' + AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé blanc' + AND packaging = '1 plaquette(s) PVC-Aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '6' WHERE concept_code = '3008105' -AND pack_name = 'TRINORDIOL, comprimé enrobé' -AND drug_form = 'comprimé brique' -AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé brique' -AND packaging = '1 plaquette(s) PVC-Aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '10' + AND pack_name = 'TRINORDIOL, comprimé enrobé' + AND drug_form = 'comprimé brique' + AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé brique' + AND packaging = '1 plaquette(s) PVC-Aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '10' WHERE concept_code = '3008105' -AND pack_name = 'TRINORDIOL, comprimé enrobé' -AND drug_form = 'comprimé jaune' -AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé jaune' -AND packaging = '1 plaquette(s) PVC-Aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '6' + AND pack_name = 'TRINORDIOL, comprimé enrobé' + AND drug_form = 'comprimé jaune' + AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé jaune' + AND packaging = '1 plaquette(s) PVC-Aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '6' WHERE concept_code = '3008106' -AND pack_name = 'TRINORDIOL, comprimé enrobé' -AND drug_form = 'comprimé blanc' -AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé blanc' -AND packaging = '3 plaquette(s) PVC-Aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '5' + AND pack_name = 'TRINORDIOL, comprimé enrobé' + AND drug_form = 'comprimé blanc' + AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé blanc' + AND packaging = '3 plaquette(s) PVC-Aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '5' WHERE concept_code = '3008106' -AND pack_name = 'TRINORDIOL, comprimé enrobé' -AND drug_form = 'comprimé brique' -AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé brique' -AND packaging = '3 plaquette(s) PVC-Aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '10' + AND pack_name = 'TRINORDIOL, comprimé enrobé' + AND drug_form = 'comprimé brique' + AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé brique' + AND packaging = '3 plaquette(s) PVC-Aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '10' WHERE concept_code = '3008106' -AND pack_name = 'TRINORDIOL, comprimé enrobé' -AND drug_form = 'comprimé jaune' -AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé jaune' -AND packaging = '3 plaquette(s) PVC-Aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '7' + AND pack_name = 'TRINORDIOL, comprimé enrobé' + AND drug_form = 'comprimé jaune' + AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé jaune' + AND packaging = '3 plaquette(s) PVC-Aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '7' WHERE concept_code = '3184064' -AND pack_name = 'ADEPAL, comprimé enrobé' -AND drug_form = 'comprimé blanc' -AND pack_component_name = 'ADEPAL, comprimé enrobé comprimé blanc' -AND packaging = '1 plaquette(s) thermoformée(s) PVC aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '14' + AND pack_name = 'ADEPAL, comprimé enrobé' + AND drug_form = 'comprimé blanc' + AND pack_component_name = 'ADEPAL, comprimé enrobé comprimé blanc' + AND packaging = '1 plaquette(s) thermoformée(s) PVC aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '14' WHERE concept_code = '3184064' -AND pack_name = 'ADEPAL, comprimé enrobé' -AND drug_form = 'comprimé rose orangé' -AND pack_component_name = 'ADEPAL, comprimé enrobé comprimé rose orangé' -AND packaging = '1 plaquette(s) thermoformée(s) PVC aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '7' + AND pack_name = 'ADEPAL, comprimé enrobé' + AND drug_form = 'comprimé rose orangé' + AND pack_component_name = 'ADEPAL, comprimé enrobé comprimé rose orangé' + AND packaging = '1 plaquette(s) thermoformée(s) PVC aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '7' WHERE concept_code = '3184087' -AND pack_name = 'ADEPAL, comprimé enrobé' -AND drug_form = 'comprimé blanc' -AND pack_component_name = 'ADEPAL, comprimé enrobé comprimé blanc' -AND packaging = '3 plaquette(s) thermoformée(s) PVC aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '14' + AND pack_name = 'ADEPAL, comprimé enrobé' + AND drug_form = 'comprimé blanc' + AND pack_component_name = 'ADEPAL, comprimé enrobé comprimé blanc' + AND packaging = '3 plaquette(s) thermoformée(s) PVC aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '14' WHERE concept_code = '3184087' -AND pack_name = 'ADEPAL, comprimé enrobé' -AND drug_form = 'comprimé rose orangé' -AND pack_component_name = 'ADEPAL, comprimé enrobé comprimé rose orangé' -AND packaging = '3 plaquette(s) thermoformée(s) PVC aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '6' + AND pack_name = 'ADEPAL, comprimé enrobé' + AND drug_form = 'comprimé rose orangé' + AND pack_component_name = 'ADEPAL, comprimé enrobé comprimé rose orangé' + AND packaging = '3 plaquette(s) thermoformée(s) PVC aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '6' WHERE concept_code = '3280709' -AND pack_name = 'TRINORDIOL, comprimé enrobé' -AND drug_form = 'comprimé blanc' -AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé blanc' -AND packaging = '1 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '5' + AND pack_name = 'TRINORDIOL, comprimé enrobé' + AND drug_form = 'comprimé blanc' + AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé blanc' + AND packaging = '1 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '5' WHERE concept_code = '3280709' -AND pack_name = 'TRINORDIOL, comprimé enrobé' -AND drug_form = 'comprimé brique' -AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé brique' -AND packaging = '1 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '10' + AND pack_name = 'TRINORDIOL, comprimé enrobé' + AND drug_form = 'comprimé brique' + AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé brique' + AND packaging = '1 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '10' WHERE concept_code = '3280709' -AND pack_name = 'TRINORDIOL, comprimé enrobé' -AND drug_form = 'comprimé jaune' -AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé jaune' -AND packaging = '1 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '6' + AND pack_name = 'TRINORDIOL, comprimé enrobé' + AND drug_form = 'comprimé jaune' + AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé jaune' + AND packaging = '1 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '6' WHERE concept_code = '3280715' -AND pack_name = 'TRINORDIOL, comprimé enrobé' -AND drug_form = 'comprimé blanc' -AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé blanc' -AND packaging = '3 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '5' + AND pack_name = 'TRINORDIOL, comprimé enrobé' + AND drug_form = 'comprimé blanc' + AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé blanc' + AND packaging = '3 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '5' WHERE concept_code = '3280715' -AND pack_name = 'TRINORDIOL, comprimé enrobé' -AND drug_form = 'comprimé brique' -AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé brique' -AND packaging = '3 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '10' + AND pack_name = 'TRINORDIOL, comprimé enrobé' + AND drug_form = 'comprimé brique' + AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé brique' + AND packaging = '3 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '10' WHERE concept_code = '3280715' -AND pack_name = 'TRINORDIOL, comprimé enrobé' -AND drug_form = 'comprimé jaune' -AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé jaune' -AND packaging = '3 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '5' + AND pack_name = 'TRINORDIOL, comprimé enrobé' + AND drug_form = 'comprimé jaune' + AND pack_component_name = 'TRINORDIOL, comprimé enrobé comprimé jaune' + AND packaging = '3 plaquette(s) PVC-Aluminium suremballée(s)/surpochée(s) de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '5' WHERE concept_code = '3588413' -AND pack_name = 'DAILY, comprimé enrobé' -AND drug_form = 'comprimé blanc' -AND pack_component_name = 'DAILY, comprimé enrobé comprimé blanc' -AND packaging = '1 plaquette thermoformée (aluminium/PVC/PVDC) de 21 comprimés' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '10' + AND pack_name = 'DAILY, comprimé enrobé' + AND drug_form = 'comprimé blanc' + AND pack_component_name = 'DAILY, comprimé enrobé comprimé blanc' + AND packaging = '1 plaquette thermoformée (aluminium/PVC/PVDC) de 21 comprimés' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '10' WHERE concept_code = '3588413' -AND pack_name = 'DAILY, comprimé enrobé' -AND drug_form = 'comprimé jaune' -AND pack_component_name = 'DAILY, comprimé enrobé comprimé jaune' -AND packaging = '1 plaquette thermoformée (aluminium/PVC/PVDC) de 21 comprimés' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '6' + AND pack_name = 'DAILY, comprimé enrobé' + AND drug_form = 'comprimé jaune' + AND pack_component_name = 'DAILY, comprimé enrobé comprimé jaune' + AND packaging = '1 plaquette thermoformée (aluminium/PVC/PVDC) de 21 comprimés' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '6' WHERE concept_code = '3588413' -AND pack_name = 'DAILY, comprimé enrobé' -AND drug_form = 'comprimé rose' -AND pack_component_name = 'DAILY, comprimé enrobé comprimé rose' -AND packaging = '1 plaquette thermoformée (aluminium/PVC/PVDC) de 21 comprimés' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '5' + AND pack_name = 'DAILY, comprimé enrobé' + AND drug_form = 'comprimé rose' + AND pack_component_name = 'DAILY, comprimé enrobé comprimé rose' + AND packaging = '1 plaquette thermoformée (aluminium/PVC/PVDC) de 21 comprimés' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '5' WHERE concept_code = '3588436' -AND pack_name = 'DAILY, comprimé enrobé' -AND drug_form = 'comprimé blanc' -AND pack_component_name = 'DAILY, comprimé enrobé comprimé blanc' -AND packaging = '3 plaquettes thermoformées (aluminium/PVC/PVDC) de 21 comprimés' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '10' + AND pack_name = 'DAILY, comprimé enrobé' + AND drug_form = 'comprimé blanc' + AND pack_component_name = 'DAILY, comprimé enrobé comprimé blanc' + AND packaging = '3 plaquettes thermoformées (aluminium/PVC/PVDC) de 21 comprimés' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '10' WHERE concept_code = '3588436' -AND pack_name = 'DAILY, comprimé enrobé' -AND drug_form = 'comprimé jaune' -AND pack_component_name = 'DAILY, comprimé enrobé comprimé jaune' -AND packaging = '3 plaquettes thermoformées (aluminium/PVC/PVDC) de 21 comprimés' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '6' + AND pack_name = 'DAILY, comprimé enrobé' + AND drug_form = 'comprimé jaune' + AND pack_component_name = 'DAILY, comprimé enrobé comprimé jaune' + AND packaging = '3 plaquettes thermoformées (aluminium/PVC/PVDC) de 21 comprimés' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '6' WHERE concept_code = '3588436' -AND pack_name = 'DAILY, comprimé enrobé' -AND drug_form = 'comprimé rose' -AND pack_component_name = 'DAILY, comprimé enrobé comprimé rose' -AND packaging = '3 plaquettes thermoformées (aluminium/PVC/PVDC) de 21 comprimés' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '12' + AND pack_name = 'DAILY, comprimé enrobé' + AND drug_form = 'comprimé rose' + AND pack_component_name = 'DAILY, comprimé enrobé comprimé rose' + AND packaging = '3 plaquettes thermoformées (aluminium/PVC/PVDC) de 21 comprimés' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '12' WHERE concept_code = '3698604' -AND pack_name = 'DOLIRHUMEPRO PARACETAMOL, PSEUDOEPHEDRINE ET DOXYLAMINE, comprimé' -AND drug_form = 'comprimé jour' -AND pack_component_name = 'DOLIRHUMEPRO PARACETAMOL, PSEUDOEPHEDRINE ET DOXYLAMINE, comprimé comprimé jour' -AND packaging = 'plaquette(s) thermoformée(s) PVC-Aluminium de 16 comprimés' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '4' + AND pack_name = 'DOLIRHUMEPRO PARACETAMOL, PSEUDOEPHEDRINE ET DOXYLAMINE, comprimé' + AND drug_form = 'comprimé jour' + AND pack_component_name = 'DOLIRHUMEPRO PARACETAMOL, PSEUDOEPHEDRINE ET DOXYLAMINE, comprimé comprimé jour' + AND packaging = 'plaquette(s) thermoformée(s) PVC-Aluminium de 16 comprimés' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '4' WHERE concept_code = '3698604' -AND pack_name = 'DOLIRHUMEPRO PARACETAMOL, PSEUDOEPHEDRINE ET DOXYLAMINE, comprimé' -AND drug_form = 'comprimé nuit' -AND pack_component_name = 'DOLIRHUMEPRO PARACETAMOL, PSEUDOEPHEDRINE ET DOXYLAMINE, comprimé comprimé nuit' -AND packaging = 'plaquette(s) thermoformée(s) PVC-Aluminium de 16 comprimés' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '5' + AND pack_name = 'DOLIRHUMEPRO PARACETAMOL, PSEUDOEPHEDRINE ET DOXYLAMINE, comprimé' + AND drug_form = 'comprimé nuit' + AND pack_component_name = 'DOLIRHUMEPRO PARACETAMOL, PSEUDOEPHEDRINE ET DOXYLAMINE, comprimé comprimé nuit' + AND packaging = 'plaquette(s) thermoformée(s) PVC-Aluminium de 16 comprimés' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '5' WHERE concept_code = '3899975' -AND pack_name = 'EVANECIA, comprimé enrobé' -AND drug_form = 'comprimé blanc' -AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé blanc' -AND packaging = '1 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '10' + AND pack_name = 'EVANECIA, comprimé enrobé' + AND drug_form = 'comprimé blanc' + AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé blanc' + AND packaging = '1 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '10' WHERE concept_code = '3899975' -AND pack_name = 'EVANECIA, comprimé enrobé' -AND drug_form = 'comprimé jaune' -AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé jaune' -AND packaging = '1 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '6' + AND pack_name = 'EVANECIA, comprimé enrobé' + AND drug_form = 'comprimé jaune' + AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé jaune' + AND packaging = '1 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '6' WHERE concept_code = '3899975' -AND pack_name = 'EVANECIA, comprimé enrobé' -AND drug_form = 'comprimé rouge brique' -AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé rouge brique' -AND packaging = '1 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '5' + AND pack_name = 'EVANECIA, comprimé enrobé' + AND drug_form = 'comprimé rouge brique' + AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé rouge brique' + AND packaging = '1 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '5' WHERE concept_code = '3899981' -AND pack_name = 'EVANECIA, comprimé enrobé' -AND drug_form = 'comprimé blanc' -AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé blanc' -AND packaging = '3 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '10' + AND pack_name = 'EVANECIA, comprimé enrobé' + AND drug_form = 'comprimé blanc' + AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé blanc' + AND packaging = '3 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '10' WHERE concept_code = '3899981' -AND pack_name = 'EVANECIA, comprimé enrobé' -AND drug_form = 'comprimé jaune' -AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé jaune' -AND packaging = '3 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '6' + AND pack_name = 'EVANECIA, comprimé enrobé' + AND drug_form = 'comprimé jaune' + AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé jaune' + AND packaging = '3 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '6' WHERE concept_code = '3899981' -AND pack_name = 'EVANECIA, comprimé enrobé' -AND drug_form = 'comprimé rouge brique' -AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé rouge brique' -AND packaging = '3 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '7' + AND pack_name = 'EVANECIA, comprimé enrobé' + AND drug_form = 'comprimé rouge brique' + AND pack_component_name = 'EVANECIA, comprimé enrobé comprimé rouge brique' + AND packaging = '3 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '7' WHERE concept_code = '3918106' -AND pack_name = 'PACILIA, comprimé enrobé' -AND drug_form = 'comprimé blanc' -AND pack_component_name = 'PACILIA, comprimé enrobé comprimé blanc' -AND packaging = '1 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '14' + AND pack_name = 'PACILIA, comprimé enrobé' + AND drug_form = 'comprimé blanc' + AND pack_component_name = 'PACILIA, comprimé enrobé comprimé blanc' + AND packaging = '1 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '14' WHERE concept_code = '3918106' -AND pack_name = 'PACILIA, comprimé enrobé' -AND drug_form = 'comprimé rose' -AND pack_component_name = 'PACILIA, comprimé enrobé comprimé rose' -AND packaging = '1 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '7' + AND pack_name = 'PACILIA, comprimé enrobé' + AND drug_form = 'comprimé rose' + AND pack_component_name = 'PACILIA, comprimé enrobé comprimé rose' + AND packaging = '1 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '7' WHERE concept_code = '3918112' -AND pack_name = 'PACILIA, comprimé enrobé' -AND drug_form = 'comprimé blanc' -AND pack_component_name = 'PACILIA, comprimé enrobé comprimé blanc' -AND packaging = '3 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '14' + AND pack_name = 'PACILIA, comprimé enrobé' + AND drug_form = 'comprimé blanc' + AND pack_component_name = 'PACILIA, comprimé enrobé comprimé blanc' + AND packaging = '3 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '14' WHERE concept_code = '3918112' -AND pack_name = 'PACILIA, comprimé enrobé' -AND drug_form = 'comprimé rose' -AND pack_component_name = 'PACILIA, comprimé enrobé comprimé rose' -AND packaging = '3 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' -AND pack_amount_value IS NULL -AND denominator_value IS NULL -AND denominator_unit IS NULL; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'PACILIA, comprimé enrobé' + AND drug_form = 'comprimé rose' + AND pack_component_name = 'PACILIA, comprimé enrobé comprimé rose' + AND packaging = '3 plaquette(s) thermoformée(s) PVC-Aluminium de 21 comprimé(s)' + AND pack_amount_value IS NULL + AND denominator_value IS NULL + AND denominator_unit IS NULL; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5500089' -AND pack_name = 'TISSEEL, solutions pour colle' -AND drug_form = 'composant 1' -AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' -AND packaging = 'système à double seringues (polypropylène) 1 * 2 ml (1 ml + 1 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' -AND pack_amount_value IS NULL -AND denominator_value = 1.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSEEL, solutions pour colle' + AND drug_form = 'composant 1' + AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' + AND packaging = 'système à double seringues (polypropylène) 1 * 2 ml (1 ml + 1 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' + AND pack_amount_value IS NULL + AND denominator_value = 1.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5500089' -AND pack_name = 'TISSEEL, solutions pour colle' -AND drug_form = 'composant 2' -AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' -AND packaging = 'système à double seringues (polypropylène) 1 * 2 ml (1 ml + 1 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' -AND pack_amount_value IS NULL -AND denominator_value = 1.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSEEL, solutions pour colle' + AND drug_form = 'composant 2' + AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' + AND packaging = 'système à double seringues (polypropylène) 1 * 2 ml (1 ml + 1 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' + AND pack_amount_value IS NULL + AND denominator_value = 1.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5500091' -AND pack_name = 'TISSEEL, solutions pour colle' -AND drug_form = 'composant 1' -AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' -AND packaging = 'système à double seringues (polypropylène) 1 * 4 ml (2 ml + 2 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' -AND pack_amount_value IS NULL -AND denominator_value = 2.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSEEL, solutions pour colle' + AND drug_form = 'composant 1' + AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' + AND packaging = 'système à double seringues (polypropylène) 1 * 4 ml (2 ml + 2 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' + AND pack_amount_value IS NULL + AND denominator_value = 2.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5500091' -AND pack_name = 'TISSEEL, solutions pour colle' -AND drug_form = 'composant 2' -AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' -AND packaging = 'système à double seringues (polypropylène) 1 * 4 ml (2 ml + 2 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' -AND pack_amount_value IS NULL -AND denominator_value = 2.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSEEL, solutions pour colle' + AND drug_form = 'composant 2' + AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' + AND packaging = 'système à double seringues (polypropylène) 1 * 4 ml (2 ml + 2 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' + AND pack_amount_value IS NULL + AND denominator_value = 2.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5500092' -AND pack_name = 'TISSEEL, solutions pour colle' -AND drug_form = 'composant 1' -AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' -AND packaging = 'système à double seringues (polypropylène) 1 * 10 ml (5 ml + 5 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' -AND pack_amount_value IS NULL -AND denominator_value = 5.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSEEL, solutions pour colle' + AND drug_form = 'composant 1' + AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' + AND packaging = 'système à double seringues (polypropylène) 1 * 10 ml (5 ml + 5 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' + AND pack_amount_value IS NULL + AND denominator_value = 5.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5500092' -AND pack_name = 'TISSEEL, solutions pour colle' -AND drug_form = 'composant 2' -AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' -AND packaging = 'système à double seringues (polypropylène) 1 * 10 ml (5 ml + 5 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' -AND pack_amount_value IS NULL -AND denominator_value = 5.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSEEL, solutions pour colle' + AND drug_form = 'composant 2' + AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' + AND packaging = 'système à double seringues (polypropylène) 1 * 10 ml (5 ml + 5 ml) avec piston, clippées dans un double porte-seringue et munies de capuchons, avec un set de dispositifs d''application constitué de 2 pièces de raccordement et de 4 canules d''application' + AND pack_amount_value IS NULL + AND denominator_value = 5.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5503190' -AND pack_name = 'TISSEEL, solutions pour colle' -AND drug_form = 'composant 1' -AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' -AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 2 ml (1 ml + 1 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' -AND pack_amount_value IS NULL -AND denominator_value = 2.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSEEL, solutions pour colle' + AND drug_form = 'composant 1' + AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' + AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 2 ml (1 ml + 1 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' + AND pack_amount_value IS NULL + AND denominator_value = 2.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5503190' -AND pack_name = 'TISSEEL, solutions pour colle' -AND drug_form = 'composant 2' -AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' -AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 2 ml (1 ml + 1 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' -AND pack_amount_value IS NULL -AND denominator_value = 2.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSEEL, solutions pour colle' + AND drug_form = 'composant 2' + AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' + AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 2 ml (1 ml + 1 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' + AND pack_amount_value IS NULL + AND denominator_value = 2.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5503191' -AND pack_name = 'TISSEEL, solutions pour colle' -AND drug_form = 'composant 1' -AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' -AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 4 ml (2 ml + 2 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' -AND pack_amount_value IS NULL -AND denominator_value = 4.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSEEL, solutions pour colle' + AND drug_form = 'composant 1' + AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' + AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 4 ml (2 ml + 2 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' + AND pack_amount_value IS NULL + AND denominator_value = 4.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5503191' -AND pack_name = 'TISSEEL, solutions pour colle' -AND drug_form = 'composant 2' -AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' -AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 4 ml (2 ml + 2 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' -AND pack_amount_value IS NULL -AND denominator_value = 4.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSEEL, solutions pour colle' + AND drug_form = 'composant 2' + AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' + AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 4 ml (2 ml + 2 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' + AND pack_amount_value IS NULL + AND denominator_value = 4.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5503192' -AND pack_name = 'TISSEEL, solutions pour colle' -AND drug_form = 'composant 1' -AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' -AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 10 ml (5 ml + 5 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' -AND pack_amount_value IS NULL -AND denominator_value = 10.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSEEL, solutions pour colle' + AND drug_form = 'composant 1' + AND pack_component_name = 'TISSEEL, solutions pour colle composant 1' + AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 10 ml (5 ml + 5 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' + AND pack_amount_value IS NULL + AND denominator_value = 10.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5503192' -AND pack_name = 'TISSEEL, solutions pour colle' -AND drug_form = 'composant 2' -AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' -AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 10 ml (5 ml + 5 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' -AND pack_amount_value IS NULL -AND denominator_value = 10.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSEEL, solutions pour colle' + AND drug_form = 'composant 2' + AND pack_component_name = 'TISSEEL, solutions pour colle composant 2' + AND packaging = '1 seringue (polypropylène) à double compartiment de 1 * 10 ml (5 ml + 5 ml) fermée par un capuchons avec un dispositif constitué de 2 pièces de raccordement et de 4 canules' + AND pack_amount_value IS NULL + AND denominator_value = 10.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5620894' -AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' -AND drug_form = 'poudre 1' -AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 1' -AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 2 ml de solution + 2 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' -AND pack_amount_value IS NULL -AND denominator_value = 2.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' + AND drug_form = 'poudre 1' + AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 1' + AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 2 ml de solution + 2 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' + AND pack_amount_value IS NULL + AND denominator_value = 2.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5620894' -AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' -AND drug_form = 'poudre 2' -AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 2' -AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 2 ml de solution + 2 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' -AND pack_amount_value IS NULL -AND denominator_value = 2.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' + AND drug_form = 'poudre 2' + AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 2' + AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 2 ml de solution + 2 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' + AND pack_amount_value IS NULL + AND denominator_value = 2.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5620894' -AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' -AND drug_form = 'solution de reconstitution de la poudre 1' -AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle solution de reconstitution de la poudre 1' -AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 2 ml de solution + 2 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' -AND pack_amount_value IS NULL -AND denominator_value = 2.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' + AND drug_form = 'solution de reconstitution de la poudre 1' + AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle solution de reconstitution de la poudre 1' + AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 2 ml de solution + 2 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' + AND pack_amount_value IS NULL + AND denominator_value = 2.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5620902' -AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' -AND drug_form = 'poudre 1' -AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 1' -AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 5 ml de solution + 5 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' -AND pack_amount_value IS NULL -AND denominator_value = 5.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' + AND drug_form = 'poudre 1' + AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 1' + AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 5 ml de solution + 5 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' + AND pack_amount_value IS NULL + AND denominator_value = 5.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5620902' -AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' -AND drug_form = 'poudre 2' -AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 2' -AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 5 ml de solution + 5 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' -AND pack_amount_value IS NULL -AND denominator_value = 5.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' + AND drug_form = 'poudre 2' + AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 2' + AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 5 ml de solution + 5 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' + AND pack_amount_value IS NULL + AND denominator_value = 5.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5620902' -AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' -AND drug_form = 'solution de reconstitution de la poudre 1' -AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle solution de reconstitution de la poudre 1' -AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 5 ml de solution + 5 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' -AND pack_amount_value IS NULL -AND denominator_value = 5.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' + AND drug_form = 'solution de reconstitution de la poudre 1' + AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle solution de reconstitution de la poudre 1' + AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 5 ml de solution + 5 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' + AND pack_amount_value IS NULL + AND denominator_value = 5.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5620925' -AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' -AND drug_form = 'poudre 1' -AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 1' -AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 1 ml de solution + 1 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' -AND pack_amount_value IS NULL -AND denominator_value = 1.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' + AND drug_form = 'poudre 1' + AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 1' + AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 1 ml de solution + 1 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' + AND pack_amount_value IS NULL + AND denominator_value = 1.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5620925' -AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' -AND drug_form = 'poudre 2' -AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 2' -AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 1 ml de solution + 1 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' -AND pack_amount_value IS NULL -AND denominator_value = 1.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' + AND drug_form = 'poudre 2' + AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle poudre 2' + AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 1 ml de solution + 1 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' + AND pack_amount_value IS NULL + AND denominator_value = 1.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5620925' -AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' -AND drug_form = 'solution de reconstitution de la poudre 1' -AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle solution de reconstitution de la poudre 1' -AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 1 ml de solution + 1 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' -AND pack_amount_value IS NULL -AND denominator_value = 1.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle' + AND drug_form = 'solution de reconstitution de la poudre 1' + AND pack_component_name = 'TISSUCOL KIT, poudres, solution et solvant pour colle intralésionnelle solution de reconstitution de la poudre 1' + AND packaging = 'poudre 1 en flacon (verre) contenant un barreau magnétique (acier inoxydable) + poudre 2 en flacon (verre) + 1 ml de solution + 1 ml de solvant en flacons (verre) + nécessaire de préparation et d''application' + AND pack_amount_value IS NULL + AND denominator_value = 1.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5645167' -AND pack_name = 'WILSTART, poudres et solvants pour solution injectable' -AND drug_form = 'poudre du composant 1' -AND pack_component_name = 'WILSTART, poudres et solvants pour solution injectable poudre du composant 1' -AND packaging = '1 flacon(s) en verre de 1000 UI - 1 flacon(s) en verre de 10 ml - 1 flacon(s) en verre de 500 UI - 1 flacon(s) en verre de 5 ml avec dispositif(s) de transfert' -AND pack_amount_value IS NULL -AND denominator_value = 1.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'WILSTART, poudres et solvants pour solution injectable' + AND drug_form = 'poudre du composant 1' + AND pack_component_name = 'WILSTART, poudres et solvants pour solution injectable poudre du composant 1' + AND packaging = '1 flacon(s) en verre de 1000 UI - 1 flacon(s) en verre de 10 ml - 1 flacon(s) en verre de 500 UI - 1 flacon(s) en verre de 5 ml avec dispositif(s) de transfert' + AND pack_amount_value IS NULL + AND denominator_value = 1.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5645167' -AND pack_name = 'WILSTART, poudres et solvants pour solution injectable' -AND drug_form = 'poudre du composant 2' -AND pack_component_name = 'WILSTART, poudres et solvants pour solution injectable poudre du composant 2' -AND packaging = '1 flacon(s) en verre de 1000 UI - 1 flacon(s) en verre de 10 ml - 1 flacon(s) en verre de 500 UI - 1 flacon(s) en verre de 5 ml avec dispositif(s) de transfert' -AND pack_amount_value IS NULL -AND denominator_value = 1.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'WILSTART, poudres et solvants pour solution injectable' + AND drug_form = 'poudre du composant 2' + AND pack_component_name = 'WILSTART, poudres et solvants pour solution injectable poudre du composant 2' + AND packaging = '1 flacon(s) en verre de 1000 UI - 1 flacon(s) en verre de 10 ml - 1 flacon(s) en verre de 500 UI - 1 flacon(s) en verre de 5 ml avec dispositif(s) de transfert' + AND pack_amount_value IS NULL + AND denominator_value = 1.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5755766' -AND pack_name = 'ARTISS, solutions pour colle' -AND drug_form = 'solution de protéines pour colle' -AND pack_component_name = 'ARTISS, solutions pour colle solution de protéines pour colle' -AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (1 ml + 1 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' -AND pack_amount_value IS NULL -AND denominator_value = 1.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'ARTISS, solutions pour colle' + AND drug_form = 'solution de protéines pour colle' + AND pack_component_name = 'ARTISS, solutions pour colle solution de protéines pour colle' + AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (1 ml + 1 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' + AND pack_amount_value IS NULL + AND denominator_value = 1.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5755766' -AND pack_name = 'ARTISS, solutions pour colle' -AND drug_form = 'solution de thrombine' -AND pack_component_name = 'ARTISS, solutions pour colle solution de thrombine' -AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (1 ml + 1 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' -AND pack_amount_value IS NULL -AND denominator_value = 1.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'ARTISS, solutions pour colle' + AND drug_form = 'solution de thrombine' + AND pack_component_name = 'ARTISS, solutions pour colle solution de thrombine' + AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (1 ml + 1 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' + AND pack_amount_value IS NULL + AND denominator_value = 1.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5755772' -AND pack_name = 'ARTISS, solutions pour colle' -AND drug_form = 'solution de protéines pour colle' -AND pack_component_name = 'ARTISS, solutions pour colle solution de protéines pour colle' -AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (2 ml + 2 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' -AND pack_amount_value IS NULL -AND denominator_value = 1.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' + AND pack_name = 'ARTISS, solutions pour colle' + AND drug_form = 'solution de protéines pour colle' + AND pack_component_name = 'ARTISS, solutions pour colle solution de protéines pour colle' + AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (2 ml + 2 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' + AND pack_amount_value IS NULL + AND denominator_value = 1.0 + AND denominator_unit = 'ml'; + +UPDATE pack_cont_1 +SET pack_amount_value = '1' WHERE concept_code = '5755772' -AND pack_name = 'ARTISS, solutions pour colle' -AND drug_form = 'solution de thrombine' -AND pack_component_name = 'ARTISS, solutions pour colle solution de thrombine' -AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (2 ml + 2 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' -AND pack_amount_value IS NULL -AND denominator_value = 1.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' -WHERE concept_code = '5755789' -AND pack_name = 'ARTISS, solutions pour colle' -AND drug_form = 'solution de protéines pour colle' -AND pack_component_name = 'ARTISS, solutions pour colle solution de protéines pour colle' -AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (5 ml + 5 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' -AND pack_amount_value IS NULL -AND denominator_value = 1.0 -AND denominator_unit = 'ml'; -UPDATE pack_cont_1 - SET pack_amount_value = '1' -WHERE concept_code = '5755789' -AND pack_name = 'ARTISS, solutions pour colle' -AND drug_form = 'solution de thrombine' -AND pack_component_name = 'ARTISS, solutions pour colle solution de thrombine' -AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (5 ml + 5 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' -AND pack_amount_value IS NULL -AND denominator_value = 1.0 -AND denominator_unit = 'ml'; + AND pack_name = 'ARTISS, solutions pour colle' + AND drug_form = 'solution de thrombine' + AND pack_component_name = 'ARTISS, solutions pour colle solution de thrombine' + AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (2 ml + 2 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' + AND pack_amount_value IS NULL + AND denominator_value = 1.0 + AND denominator_unit = 'ml'; +UPDATE pack_cont_1 +SET pack_amount_value = '1' +WHERE concept_code = '5755789' + AND pack_name = 'ARTISS, solutions pour colle' + AND drug_form = 'solution de protéines pour colle' + AND pack_component_name = 'ARTISS, solutions pour colle solution de protéines pour colle' + AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (5 ml + 5 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' + AND pack_amount_value IS NULL + AND denominator_value = 1.0 + AND denominator_unit = 'ml'; +UPDATE pack_cont_1 +SET pack_amount_value = '1' +WHERE concept_code = '5755789' + AND pack_name = 'ARTISS, solutions pour colle' + AND drug_form = 'solution de thrombine' + AND pack_component_name = 'ARTISS, solutions pour colle solution de thrombine' + AND packaging = '1 seringue(s) préremplie(s) polypropylène à double compartiment (5 ml + 5 ml) avec dispositif double piston pour seringue + 2 pièces de raccordement et 4 canules d’application' + AND pack_amount_value IS NULL + AND denominator_value = 1.0 + AND denominator_unit = 'ml'; +END $$; /* delete from drug_concept_stage where concept_code in ( select pack_component_code from pack_cont_1 where concept_code in (select concept_code from pack_amount_manual where pack_amount_value is null) -) -; +); + delete from ds_stage where drug_concept_code in ( select pack_component_code from pack_cont_1 where concept_code in (select concept_code from pack_amount_manual where pack_amount_value is null) -) -; - +); delete from pack_cont_1 where concept_code in (select concept_code from pack_amount_manual where pack_amount_value is null); */ -insert into relationship_to_concept -( -concept_code_1, -vocabulary_id_1, -concept_id_2, -precedence -) -select distinct concept_code, vocabulary_id, concept_id_2 , precedenece -from (select * from relationship_concept_to_mapped_1 union select * from relationship_concept_to_map_1) rt -join drug_concept_stage -on upper(concept_name) = upper(attr_name) -and concept_class_id= attr_class -where concept_id_2 is not null -; - - -delete from drug_concept_stage where concept_code in ( -select concept_code -from relationship_concept_to_mapped_1 -join drug_concept_stage -on upper(concept_name) = upper(attr_name) -and concept_class_id= attr_class -where indicator_rxe = 'd') -; - -delete from drug_concept_stage where concept_code in ( -select concept_code -from relationship_concept_to_map_1 -join drug_concept_stage -on upper(concept_name) = upper(attr_name) -and concept_class_id= attr_class -where indicator_rxe != '+' and concept_id_2 is null) -; - - - +INSERT INTO relationship_to_concept ( + concept_code_1, + vocabulary_id_1, + concept_id_2, + precedence + ) +SELECT DISTINCT dcs.concept_code, + dcs.vocabulary_id, + rt.concept_id_2, + rt.precedenece +FROM ( + SELECT * + FROM relationship_concept_to_mapped_1 + + UNION + + SELECT * + FROM relationship_concept_to_map_1 + ) rt +JOIN drug_concept_stage dcs ON UPPER(dcs.concept_name) = UPPER(rt.attr_name) + AND dcs.concept_class_id = attr_class +WHERE rt.concept_id_2 IS NOT NULL; DELETE FROM drug_concept_stage -WHERE concept_code IN (SELECT concept_code - FROM drug_concept_stage - LEFT JOIN relationship_to_concept ON concept_code_1 = concept_code - WHERE concept_code_1 IS NULL - AND concept_class_id = 'Ingredient' - AND concept_name ~* 'Homeopathic Preparation'); - - +WHERE concept_code IN ( + SELECT dcs.concept_code + FROM relationship_concept_to_mapped_1 r + JOIN drug_concept_stage dcs ON UPPER(dcs.concept_name) = UPPER(r.attr_name) + AND dcs.concept_class_id = r.attr_class + WHERE r.indicator_rxe = 'd' + ); +DELETE +FROM drug_concept_stage +WHERE concept_code IN ( + SELECT dcs.concept_code + FROM relationship_concept_to_map_1 r + JOIN drug_concept_stage dcs ON UPPER(dcs.concept_name) = UPPER(r.attr_name) + AND dcs.concept_class_id = r.attr_class + WHERE r.indicator_rxe <> '+' + AND r.concept_id_2 IS NULL + ); +DELETE +FROM drug_concept_stage +WHERE concept_code IN ( + SELECT concept_code + FROM drug_concept_stage dcs + LEFT JOIN relationship_to_concept r ON r.concept_code_1 = dcs.concept_code + WHERE r.concept_code_1 IS NULL + AND dcs.concept_class_id = 'Ingredient' + AND dcs.concept_name ILIKE '%Homeopathic Preparation%' + ); ALTER TABLE ds_stage --- add mapped ingredient's concept_id to aid next step in dealing with dublicates -ADD concept_id INT4; - -UPDATE ds_stage - SET concept_id = (SELECT concept_id_2 - FROM relationship_to_concept - WHERE concept_code_1 = ingredient_concept_code - AND precedence = 1); + -- add mapped ingredient's concept_id to aid next step in dealing with dublicates + ADD concept_id INT4; ---Fix ingredients that got replaced/mapped as same one (e.g. Sodium ascorbate + Ascorbic acid => Ascorbic acid) -DROP TABLE if exists ds_split; +UPDATE ds_stage dss +SET concept_id = rtc.concept_id_2 +FROM relationship_to_concept rtc +WHERE rtc.concept_code_1 = dss.ingredient_concept_code + AND rtc.precedence = 1; -CREATE TABLE ds_split -AS +--Fix ingredients that got REPLACEd/mapped as same one (e.g. Sodium ascorbate + Ascorbic acid => Ascorbic acid) +DROP TABLE IF EXISTS ds_split; +CREATE TABLE ds_split AS SELECT DISTINCT drug_concept_code, - MIN(ingredient_concept_code) OVER (PARTITION BY drug_concept_code,concept_id)::VARCHAR AS ingredient_concept_code, - --one at random - SUM(amount_value) OVER (PARTITION BY drug_concept_code,concept_id) AS amount_value, - amount_unit, - SUM(numerator_value) OVER (PARTITION BY drug_concept_code,concept_id) AS numerator_value, - numerator_unit, - denominator_value, - denominator_unit, - NULL::INT4 AS box_size, - concept_id + MIN(ingredient_concept_code) OVER ( + PARTITION BY drug_concept_code, + concept_id + ) AS ingredient_concept_code, + --one at random + SUM(amount_value) OVER ( + PARTITION BY drug_concept_code, + concept_id + ) AS amount_value, + amount_unit, + SUM(numerator_value) OVER ( + PARTITION BY drug_concept_code, + concept_id + ) AS numerator_value, + numerator_unit, + denominator_value, + denominator_unit, + NULL::INT2 AS box_size, + concept_id FROM ds_stage -WHERE (drug_concept_code,concept_id) IN (SELECT drug_concept_code, - concept_id - FROM ds_stage - GROUP BY drug_concept_code, - concept_id - HAVING COUNT(*) > 1); +WHERE ( + drug_concept_code, + concept_id + ) IN ( + SELECT drug_concept_code, + concept_id + FROM ds_stage + GROUP BY drug_concept_code, + concept_id + HAVING COUNT(*) > 1 + ); DELETE FROM ds_stage -WHERE (drug_concept_code,concept_id) IN (SELECT drug_concept_code, concept_id FROM ds_split); - +WHERE ( + drug_concept_code, + concept_id + ) IN ( + SELECT drug_concept_code, + concept_id + FROM ds_split + ); -INSERT INTO ds_stage -( - drug_concept_code, - ingredient_concept_code, - box_size, - amount_value, - amount_unit, - numerator_value, - numerator_unit, - denominator_value, - denominator_unit, - concept_id -) +INSERT INTO ds_stage ( + drug_concept_code, + ingredient_concept_code, + box_size, + amount_value, + amount_unit, + numerator_value, + numerator_unit, + denominator_value, + denominator_unit, + concept_id + ) SELECT drug_concept_code, - ingredient_concept_code, - box_size, - amount_value, - amount_unit, - numerator_value, - numerator_unit, - denominator_value, - denominator_unit, - concept_id + ingredient_concept_code, + box_size, + amount_value, + amount_unit, + numerator_value, + numerator_unit, + denominator_value, + denominator_unit, + concept_id FROM ds_split; ALTER TABLE ds_stage DROP COLUMN concept_id; - - - - - - - - --Drug to ingredients INSERT INTO internal_relationship_stage ( concept_code_1, @@ -2944,9 +3787,7 @@ WHERE d.drug_concept_code NOT IN ( AND d.drug_concept_code NOT IN ( SELECT pack_component_code FROM pack_cont_1 - ) -; - + ); --Pack Component to Ingredient INSERT INTO internal_relationship_stage ( @@ -2961,83 +3802,86 @@ WHERE d.drug_concept_code IN ( FROM pack_cont_1 ); - --Drug to Brand Name INSERT INTO internal_relationship_stage ( concept_code_1, concept_code_2 ) -SELECT DISTINCT din_7, - concept_code +SELECT DISTINCT p.din_7, + d.concept_code FROM brand_name b -JOIN drug_concept_stage d ON lower(brand_name) = lower(concept_name) +JOIN drug_concept_stage d ON LOWER(d.concept_name) = LOWER(b.brand_name) AND d.concept_class_id = 'Brand Name' JOIN sources.bdpm_packaging p ON p.drug_code = b.drug_code WHERE b.drug_code NOT IN ( SELECT drug_code FROM non_drug - ) - -; - + ); --Drug to Supplier INSERT INTO internal_relationship_stage ( concept_code_1, concept_code_2 ) -SELECT DISTINCT din_7, +SELECT DISTINCT p.din_7, d.concept_code -FROM dcs_manufacturer_1 b -JOIN drug_concept_stage d ON lower(b.concept_name) = lower(d.concept_name) +FROM dcs_manufacturer_1 b +JOIN drug_concept_stage d ON LOWER(d.concept_name) = LOWER(b.concept_name) AND d.concept_class_id = 'Supplier' JOIN sources.bdpm_packaging p ON p.drug_code = b.drug_code WHERE b.drug_code NOT IN ( SELECT drug_code FROM non_drug ); - INSERT INTO internal_relationship_stage ( concept_code_1, concept_code_2 ) -SELECT DISTINCT din_7, +SELECT DISTINCT p.din_7, d.concept_code -FROM dcs_manufacturer b -JOIN drug_concept_stage d ON lower(b.concept_name) = lower(d.concept_name) +FROM dcs_manufacturer b +JOIN drug_concept_stage d ON LOWER(d.concept_name) = LOWER(b.concept_name) AND d.concept_class_id = 'Supplier' JOIN sources.bdpm_packaging p ON p.drug_code = b.drug_code WHERE b.drug_code NOT IN ( SELECT drug_code FROM non_drug - union - select drug_code - from dcs_manufacturer_1 + + UNION ALL + + SELECT drug_code + FROM dcs_manufacturer_1 ); - --Drug to Dose Form --separately for packs and drugs INSERT INTO internal_relationship_stage ( concept_code_1, concept_code_2 ) -SELECT DISTINCT din_7, - concept_code +SELECT DISTINCT p.din_7, + dcs.concept_code FROM sources.bdpm_drug d -JOIN rtc_1 ON upper(replace(CONCAT(trim(form),' ',trim(route)),' ',' ')) = upper(trim(original_name)) -JOIN drug_concept_stage ON uppeR(attr_name) = uppeR(concept_name) - AND concept_class_id = 'Dose Form' +JOIN rtc_1 r ON UPPER(TRIM(r.original_name)) = UPPER(REPLACE(CONCAT ( + TRIM(d.form), + ' ', + TRIM(d.route) + ), ' ', ' ')) +JOIN drug_concept_stage dcs ON UPPER(dcs.concept_name) = UPPER(r.attr_name) + AND dcs.concept_class_id = 'Dose Form' JOIN sources.bdpm_packaging p ON p.drug_code = d.drug_code WHERE d.drug_code NOT IN ( SELECT drug_code FROM non_drug ) AND d.drug_code NOT IN ( - SELECT concept_code::VARCHAR - FROM pack_cont_1) - and d.drug_code not in (select drug_code from bdpm_vaccine_manual + SELECT concept_code + FROM pack_cont_1 + ) + AND d.drug_code NOT IN ( + SELECT drug_code + FROM bdpm_vaccine_manual ); -- Drug to Dose Form for Pack components @@ -3045,47 +3889,51 @@ INSERT INTO internal_relationship_stage ( concept_code_1, concept_code_2 ) -SELECT pack_component_code, - concept_code +SELECT pf.pack_component_code, + dcs.concept_code FROM pf_from_pack_comp_list pf -JOIN drug_concept_stage dcs ON pack_form = concept_name -where pack_component_code in (select pack_component_code from pack_cont_1) -; - -update ds_stage -set box_size = null -where drug_concept_code in ( - SELECT drug_concept_code - FROM ds_stage - WHERE drug_concept_code NOT IN ( - SELECT drug_concept_code - FROM ds_stage ds - JOIN internal_relationship_stage i ON concept_code_1 = drug_concept_code - JOIN drug_concept_stage ON concept_code = concept_code_2 - AND concept_class_id = 'Dose Form' - WHERE box_size IS NOT NULL - ) - AND box_size IS NOT NULL -); +JOIN drug_concept_stage dcs ON pf.pack_form = dcs.concept_name +WHERE pf.pack_component_code IN ( + SELECT pack_component_code + FROM pack_cont_1 + ); +UPDATE ds_stage ds +SET box_size = NULL +WHERE ds.drug_concept_code IN ( + SELECT ds_int.drug_concept_code + FROM ds_stage ds_int + WHERE ds_int.drug_concept_code NOT IN ( + SELECT ds_int2.drug_concept_code + FROM ds_stage ds_int2 + JOIN internal_relationship_stage i ON i.concept_code_1 = ds_int2.drug_concept_code + JOIN drug_concept_stage dcs ON dcs.concept_code = i.concept_code_2 + AND dcs.concept_class_id = 'Dose Form' + WHERE ds_int2.box_size IS NOT NULL + ) + AND ds_int.box_size IS NOT NULL + ) + AND ds.box_size IS NOT NULL; -- remove from ds_stage drugs without dosage DELETE FROM ds_stage -WHERE drug_concepT_code IN (SELECT drug_concept_code - FROM ds_stage - WHERE numerator_value IS NULL - AND amount_value IS NULL); +WHERE drug_concept_code IN ( + SELECT drug_concept_code + FROM ds_stage + WHERE numerator_value IS NULL + AND amount_value IS NULL + ); -- remove from ds_stage drugs with volume only DELETE FROM ds_stage -WHERE drug_concept_code IN (SELECT drug_concept_code - FROM ds_stage - WHERE numerator_unit = 'ml' - OR amount_unit = 'ml'); - - +WHERE drug_concept_code IN ( + SELECT drug_concept_code + FROM ds_stage + WHERE numerator_unit = 'ml' + OR amount_unit = 'ml' + ); --remove suppliers where Dose form or dosage doesn't exist DELETE @@ -3094,12 +3942,12 @@ WHERE ( concept_code_1, concept_code_2 ) IN ( - SELECT DISTINCT concept_code_1, - concept_code_2 - FROM internal_relationship_stage - JOIN drug_concept_stage a ON concept_code_2 = a.concept_code + SELECT irs.concept_code_1, + irs.concept_code_2 + FROM internal_relationship_stage irs + JOIN drug_concept_stage a ON a.concept_code = irs.concept_code_2 AND a.concept_class_id = 'Supplier' - JOIN drug_concept_stage b ON concept_code_1 = b.concept_code + JOIN drug_concept_stage b ON b.concept_code = irs.concept_code_1 AND b.concept_class_id IN ( 'Drug Product', 'Drug Pack' @@ -3107,9 +3955,9 @@ WHERE ( WHERE ( b.concept_code NOT IN ( SELECT concept_code_1 - FROM internal_relationship_stage - JOIN drug_concept_stage ON concept_code_2 = concept_code - AND concept_class_id = 'Dose Form' + FROM internal_relationship_stage irs_int + JOIN drug_concept_stage dcs_int ON dcs_int.concept_code = irs_int.concept_code_2 + AND dcs_int.concept_class_id = 'Dose Form' ) OR b.concept_code NOT IN ( SELECT drug_concept_code @@ -3118,20 +3966,16 @@ WHERE ( ) ); - --insert results into pack_content table INSERT INTO pc_stage ( pack_concept_code, drug_concept_code, - amount, - box_size + amount ) SELECT concept_code, pack_component_code, - pack_amount_value::int, - null as box_size -FROM pack_cont_1 - ; + pack_amount_value::int2 +FROM pack_cont_1; -- add in concept_synonym_stage French name INSERT INTO concept_synonym_stage ( @@ -3140,46 +3984,49 @@ INSERT INTO concept_synonym_stage ( synonym_vocabulary_id, language_concept_id ) -SELECT original_name, - concept_code, +SELECT r.original_name, + dcs.concept_code, 'BDPM', 4180190 -- French language -FROM rtc_1 -join drug_concept_stage on upper(attr_name) = upper(concept_name) -where original_name is not null -; - --- -update drug_concept_stage d -set concept_name = trim(regexp_replace (c.concept_name, '\(\w+\-?\s?\w+?\)|EU$|A\/S\s\(\w+\-?\s?\w+?\)','')) -from drug_concept_stage c -where c.concept_code= d.concept_code -and d.concept_code in ( -select concept_code from drug_concept_stage -left join relationship_to_concept on concept_code = concept_code_1 -where concept_class_id = 'Supplier' -and concept_code_1 is null -); +FROM rtc_1 r +JOIN drug_concept_stage dcs ON UPPER(dcs.concept_name) = UPPER(r.attr_name) +WHERE r.original_name IS NOT NULL; + +UPDATE drug_concept_stage d +SET concept_name = TRIM(REGEXP_REPLACE(c.concept_name, '\(\w+\-?\s?\w+?\)|EU$|A\/S\s\(\w+\-?\s?\w+?\)', '')) +FROM drug_concept_stage c +WHERE c.concept_code = d.concept_code + AND d.concept_code IN ( + SELECT dcs_int.concept_code + FROM drug_concept_stage dcs_int + LEFT JOIN relationship_to_concept rtc_int ON rtc_int.concept_code_1 = dcs_int.concept_code + WHERE dcs_int.concept_class_id = 'Supplier' + AND rtc_int.concept_code_1 IS NULL + ); --find code for attributes from previous iteration DROP TABLE IF EXISTS code_replace; CREATE TABLE code_replace AS -SELECT distinct case when c.invalid_reason is null then min(c.concept_code) over (partition by c.concept_name) else min(c.concept_code) over (partition by c.concept_name) end AS new_code, +SELECT DISTINCT MIN(c.concept_code) OVER (PARTITION BY c.concept_name) AS new_code, s0.concept_code AS old_code FROM ( - SELECT concept_code, concept_name, vocabulary_id, concept_class_id + SELECT concept_code, + concept_name, + vocabulary_id, + concept_class_id FROM drug_concept_stage - WHERE concept_code LIKE 'OMOP%'-- or concept_code like '%PACK%' + WHERE concept_code LIKE 'OMOP%' -- or concept_code like '%PACK%' ) AS s0 -join devv5.concept c on upper(s0.concept_name) = upper(c.concept_name) -where c.vocabulary_id = s0.vocabulary_id -and c.concept_class_id = s0.concept_class_id -union - select distinct 'OMOP' || nextval('new_vocab') as new_code, -dcs.concept_code as old_code - from drug_concept_stage dcs - where dcs.concept_code like 'PACK%' -; +JOIN concept c ON UPPER(s0.concept_name) = UPPER(c.concept_name) +WHERE c.vocabulary_id = s0.vocabulary_id + AND c.concept_class_id = s0.concept_class_id + +UNION ALL + +SELECT 'OMOP' || NEXTVAL('new_vocab') AS new_code, + dcs.concept_code AS old_code +FROM drug_concept_stage dcs +WHERE dcs.concept_code LIKE 'PACK%'; UPDATE drug_concept_stage a @@ -3188,32 +4035,30 @@ FROM code_replace b WHERE a.concept_code = b.old_code; UPDATE internal_relationship_stage c - SET concept_code_2 = new_code +SET concept_code_2 = new_code FROM code_replace de WHERE c.concept_code_2 = de.old_code; UPDATE internal_relationship_stage c - SET concept_code_1 = new_code +SET concept_code_1 = new_code FROM code_replace de WHERE c.concept_code_1 = de.old_code; UPDATE relationship_to_concept c - SET concept_code_1 = new_code +SET concept_code_1 = new_code FROM code_replace de WHERE c.concept_code_1 = de.old_code; UPDATE ds_stage c - SET drug_concept_code = new_code +SET drug_concept_code = new_code FROM code_replace de WHERE drug_concept_code = de.old_code; UPDATE pc_stage c - SET drug_concept_code = new_code +SET drug_concept_code = new_code FROM code_replace de WHERE drug_concept_code = de.old_code; - UPDATE drug_concept_stage SET concept_class_id = 'Drug Product' -WHERE concept_class_id = 'Drug Pack'; - +WHERE concept_class_id = 'Drug Pack'; \ No newline at end of file