 	invalid_reason
 	)
 SELECT DISTINCT TRIM(SUBSTR(c.str, 1, 255)) AS concept_name,
+	TRIM(c.str) AS long_concept_name,
 	'Drug' AS domain_id,
 	'NDC' AS vocabulary_id,
 	'11-digit NDC' AS concept_class_id,

	'11-digit NDC' AS concept_class_id,
	NULL AS standard_concept,
	ndc_code AS concept_code,
	first_value(startDate) OVER (
		PARTITION BY ndc_code ORDER BY startDate rows BETWEEN unbounded preceding
				AND unbounded following
		) AS valid_start_date,
	last_value(endDate) OVER (
		PARTITION BY ndc_code ORDER BY endDate rows BETWEEN unbounded preceding
				AND unbounded following
		) AS valid_end_date,
	last_value(invalid_reason) OVER (
		PARTITION BY ndc_code ORDER BY endDate rows BETWEEN unbounded preceding
				AND unbounded following
		) AS invalid_reason
FROM rxnorm2ndc_mappings_ext m
WHERE NOT EXISTS (

	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);
DROP TABLE main_ndc;
DROP TABLE rxnorm2ndc_mappings_ext;

-- At the end, the three tables concept_stage, concept_relationship_stage and concept_synonym_stage should be ready to be fed into the generic_update.sql script