 	valid_end_date,
 	invalid_reason
 	)
+-- note, there are 39 LOINC Parts which have more than one link to SNOMED due to different representation of Systems and Components in vocabularies
 SELECT DISTINCT maptarget AS concept_code_1, -- LOINC Attribute code
 	referencedcomponentid AS concept_code_2, -- SNOMED Attribute code
 	'LOINC' AS vocabulary_id_1,

  JOIN vocabulary v ON c.vocabulary_id = v.vocabulary_id -- valid_start_date
  WHERE c.vocabulary_id = 'LOINC' AND c.standard_concept = 'C' and c.invalid_reason is null
  AND d.vocabulary_id = 'SNOMED' AND d.invalid_reason IS NULL
;

-- 14.2 Build relationships between LOINC Measurements and respective SNOMED attributes given by the table of 'sources.scccrefset_expressionassociation_int'
-- Note, that some suggested by LOINC relationship_ids ('Characterizes', 'Units', 'Relative to', 'Process agent' 'Inherent location') are useless in the context of a mapping to SNOMED.
INSERT INTO concept_relationship_stage

END $_$;
	

-- 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
