 	AND crs.vocabulary_id_2 = 'RxNorm'
 JOIN sources.package p ON p.productndc = n.productndc
 LEFT JOIN concept_relationship_stage crs1 ON crs1.concept_code_1 = p.pack_code
-	AND crs1.vocabulary_id_1 = 'NDC'
-	AND crs1.vocabulary_id_2 = 'RxNorm'
+	AND crs1.vocabulary_id_1 = crs.vocabulary_id_1
+	AND crs1.vocabulary_id_2 = crs.vocabulary_id_2
 WHERE crs1.concept_code_1 IS NULL;
 
 --30. Working with replacement mappings

	AND crs.valid_end_date <> i.valid_end_date
	AND crs.invalid_reason IS NOT NULL;

--35. Clean up
DROP FUNCTION GetAggrDose (active_numerator_strength IN VARCHAR, active_ingred_unit IN VARCHAR);
DROP FUNCTION GetDistinctDose (active_numerator_strength IN VARCHAR, active_ingred_unit IN VARCHAR, p IN INT);
DROP FUNCTION CheckNDCDate (pDate IN VARCHAR, pDateDefault IN DATE);

	concept_code,
	COALESCE(valid_start_date, latest_update) AS valid_start_date,
	TO_DATE('20991231', 'yyyymmdd') AS valid_end_date,
	NULL AS invalid_reason,
	is_diluent
FROM --get unique and aggregated data from source
	(
	SELECT concept_code,
