                             AND   concept_name LIKE '%Povidone-Iodine%');
 
 
+
 COMMIT;
 
--- XXX ??????! Check ingredients first
---Christian, it has already been decided
 -- Delete 3 legged dogs
 DELETE ds_stage
 WHERE drug_concept_code IN (WITH a AS

    ON concept_id_2 = c2.concept_id
   AND c2.concept_class_id = 'Brand Name'
   AND c2.VOCABULARY_ID LIKE 'Rx%'
WHERE ((c2.invalid_reason IS NULL AND cr.invalid_reason IS NULL) OR (c.invalid_reason IS NOT NULL AND cr.invalid_reason IS NOT NULL AND cr.VALID_END_DATE < '02-Feb-2017'))
AND   REGEXP_LIKE (c.concept_name,c2.concept_name)
UNION
--Packs to BN

                         GROUP BY concept_code_1,
                                  b.concept_class_id
                         HAVING COUNT(1) > 1)
AND NOT REGEXP_LIKE (REGEXP_SUBSTR(c.concept_name,'Pack\s.*'),b.concept_name);

DELETE
FROM internal_relationship_stage
