 DROP TABLE snomed_ancestor;
 DROP VIEW module_date;
 
---22. Need to check domains before runnig the generic_update
+--22. Need to check domains before running the generic_update
 /*temporary disabled for later use
 DO $_$
 DECLARE

	SELECT vocabulary_pack.CutConceptName(d.term) AS concept_name,
		d.conceptid::TEXT AS concept_code,
		c.active,
		MIN(c.effectivetime) OVER (
			PARTITION BY c.id ORDER BY c.active DESC --if there ever were active versions of the concept, take the earliest one
			) AS effectivestart,
		ROW_NUMBER() OVER (
			PARTITION BY d.conceptid

--Definition status id of the concept is “Fully defined”
--All concepts that sit in hierarchy between the concept and HoCFS/PHoP are “Fully defined”
--Attributes that define concept are limited to “has associated finding” & standard definitions
--! Check these concepts manually before insertion
with hist_of_value AS
(SELECT DISTINCT c.concept_code,
                 c.valid_start_date,
