 	h.vocabulary_id,
 	h.concept_class_id,
 	CASE 
-		WHEN h.concept_class_id = 'Condition Class'
-			THEN 'C' -- let's make them classification concepts (in previos version Component Class was assigned manually, Jeremy fixed it in the 30-Aug-2019 release)
+		WHEN h.concept_class_id in ('Regimen Class')
+			THEN 'C' 
 		WHEN concept_class_id = 'Modality'
 			THEN 'S' -- can be used as a generic Regimen when we don't know what exact Chemo or Hormonotherapy patient got
+		WHEN h.standard_concept = '' 
+		  THEN null	
 		ELSE h.standard_concept
 		END AS standard_concept,
 	h.concept_code,
 	h.valid_start_date,
 	h.valid_end_date,
-	h.invalid_reason
+	case
+	     when h.invalid_reason = ''
+	       then null
+	      else h.invalid_reason end
 FROM sources.hemonc_cs h
 WHERE h.concept_class_id IN (
-		'Regimen type', -- type
 		'Component Class', -- looks like ATC, perhaps require additional mapping to ATC, in a first run make them "C", then replace with ATC, still a lot of work
 		'Component', -- ingredient, Standard if there's no equivalent in Rx, RxE
 		'Context', -- therapy intent or line or other Context, STANDARD

				'Brand Name',
				'Component Class',
				'Route',
				'Regimen type'
				)
			THEN 'Drug'
		WHEN h.concept_class_id IN (
				'Condition',
				'Condition Class',
				'BioCondition'
				)
			THEN 'Condition'
		WHEN h.concept_class_id IN (

	r.vocabulary_id_1,
	r.vocabulary_id_2,
	r.relationship_id,
    case when
r.valid_start_date is null then (select latest_update from vocabulary WHERE vocabulary_id = 'HemOnc') else r.valid_start_date end,
   case when
r.valid_end_date is null then TO_DATE('20991231', 'yyyymmdd') else r.valid_end_date end,
	r.invalid_reason
FROM sources.hemonc_crs r
JOIN concept_stage cs ON cs.concept_code = r.concept_code_1
