I refined query to identify ‘duplicate’ mappings into RxNorm and RxNorm Extensions. Query finds a source code that maps to both RxNorm and RxNorm Extension and then checks the ingredient of the mapped to standard concept. If the ingredients are the same, it is considered a duplicate. Running against v5.0 05-OCT-18 I get 25 GemScript and 89 HPCPS codes that appear to be duplicates.
SELECT *
FROM
(
SELECT source_vocabulary_id, source_code, source_code_description
, r_target_concept, r_target_description
, e_target_concept, e_target_description
, rac.concept_name as r_ingredient
, eac.concept_name as e_ingredient
FROM
(
SELECT r.source_vocabulary_id, r.source_code, r.source_code_description
, r.target_concept_id as r_target_concept, r.target_concept_name AS r_target_description
, e.target_concept_id as e_target_concept, e.target_concept_name AS e_target_description
FROM
( SELECT c1.vocabulary_id AS source_vocabulary_id, c1.concept_code as source_code, c1.concept_name as source_code_description
, c2.concept_id as target_concept_id, c2.concept_name AS target_concept_name
FROM concept c1
JOIN concept_relationship ON concept_id_1 = c1.concept_id
JOIN concept c2 ON c2.concept_id = concept_id_2
WHERE relationship_id = ‘Maps to’ AND c2.vocabulary_id = ‘RxNorm’ – and c1.concept_code = ‘J1720’
) r
JOIN
(SELECT c1.vocabulary_id AS source_vocabulary_id, c1.concept_code as source_code, c1.concept_name as source_code_description
, c2.concept_id as target_concept_id, c2.concept_name AS target_concept_name
FROM concept c1
JOIN concept_relationship ON concept_id_1 = c1.concept_id
JOIN concept c2 ON c2.concept_id = concept_id_2
WHERE relationship_id = ‘Maps to’ AND c2.vocabulary_id = ‘RxNorm Extension’ – and c1.concept_code = ‘J1720’
) e on e.source_code = r.source_code and e.source_vocabulary_id= r.source_vocabulary_id
)
JOIN concept_ancestor ra ON ra.descendant_concept_id = r_target_concept
JOIN concept rac ON rac.concept_class_id = ‘Ingredient’ AND rac.concept_id = ra.ancestor_concept_id
JOIN concept_ancestor ea ON ea.descendant_concept_id = e_target_concept
JOIN concept eac ON eac.concept_class_id = ‘Ingredient’ AND eac.concept_id = ea.ancestor_concept_id
) WHERE r_ingredient = e_ingredient