public override void AddToChunk(string domain, IEnumerable <IEntity> entities) { foreach (var entity in entities) { var entityDomain = GetDomain(domain, entity.Domain); switch (entityDomain) { case "Condition": var obs = entity as Observation; if (obs == null || obs.ValueAsNumber == 1) { var cond = entity as ConditionOccurrence ?? new ConditionOccurrence(entity) { Id = Offset.GetKeyOffset(entity.PersonId).ConditionOccurrenceId }; ConditionForEra.Add(cond); ChunkData.AddData(cond); } break; case "Measurement": if (entity.TypeConceptId != 38000246) { var mes = entity as Measurement ?? new Measurement(entity) { Id = Offset.GetKeyOffset(entity.PersonId).MeasurementId }; //var result = Vocabulary.Lookup(mes.SourceValue, "JMDC-ICD10-MapsToValue", DateTime.MinValue, false); var result = Vocabulary.Lookup(mes.SourceValue, "JMDC-ICD10-MapsToValue", DateTime.MinValue); int conceptId = 4181412; if (result.Any() && result[0].ConceptId.HasValue && result[0].ConceptId > 0) { conceptId = result[0].ConceptId.Value; } if (mes.ValueAsConceptId == 0) { mes.ValueAsConceptId = conceptId; } ChunkData.AddData(mes); } break; case "Meas Value": ChunkData.AddData(entity as Measurement ?? new Measurement(entity) { Id = Offset.GetKeyOffset(entity.PersonId).MeasurementId }); break; case "Observation": if (entity.TypeConceptId != 38000246) { var obser = entity as Observation ?? new Observation(entity) { Id = Offset.GetKeyOffset(entity.PersonId).ObservationId }; //var result = Vocabulary.Lookup(obser.SourceValue, "JMDC-ICD10-MapsToValue", DateTime.MinValue, false); var result = Vocabulary.Lookup(obser.SourceValue, "JMDC-ICD10-MapsToValue", DateTime.MinValue); int conceptId = 4181412; if (result.Any() && result[0].ConceptId.HasValue && result[0].ConceptId > 0) { conceptId = result[0].ConceptId.Value; } if (obser.ValueAsConceptId == 0) { obser.ValueAsConceptId = conceptId; } ChunkData.AddData(obser); } break; case "Procedure": var p = entity as ProcedureOccurrence ?? new ProcedureOccurrence(entity) { Id = Offset.GetKeyOffset(entity.PersonId) .ProcedureOccurrenceId }; ChunkData.AddData(p); break; case "Device": ChunkData.AddData(entity as DeviceExposure ?? new DeviceExposure(entity) { Id = Offset.GetKeyOffset(entity.PersonId).DeviceExposureId }); break; case "Drug": var drg = entity as DrugExposure ?? new DrugExposure(entity) { Id = Offset.GetKeyOffset(entity.PersonId).DrugExposureId }; DrugForEra.Add(drg); ChunkData.AddData(drg); break; } //HIX-823 if (domain == "Procedure" && entityDomain != "Procedure") { var po = (ProcedureOccurrence)entity; po.ConceptId = 0; ChunkData.AddData(po); } if (domain == "Observation" && entityDomain != "Observation") { var o = (Observation)entity; o.ConceptId = 0; ChunkData.AddData(o); } } }
public override void AddToChunk(string domain, IEnumerable <IEntity> entities) { foreach (var entity in entities) { var entityDomain = GetDomain(domain, entity.Domain); switch (entityDomain) { case "Condition": var cond = entity as ConditionOccurrence ?? new ConditionOccurrence(entity) { Id = Offset.GetKeyOffset(entity.PersonId).ConditionOccurrenceId }; ConditionForEra.Add(cond); ChunkData.AddData(cond); break; case "Measurement": ChunkData.AddData(entity as Measurement ?? new Measurement(entity) { Id = Offset.GetKeyOffset(entity.PersonId).MeasurementId }); break; case "Observation": ChunkData.AddData(entity as Observation ?? new Observation(entity) { Id = Offset.GetKeyOffset(entity.PersonId).ObservationId }); break; case "Procedure": ChunkData.AddData(entity as ProcedureOccurrence ?? new ProcedureOccurrence(entity) { Id = Offset.GetKeyOffset(entity.PersonId).ProcedureOccurrenceId }); break; case "Device": ChunkData.AddData(entity as DeviceExposure ?? new DeviceExposure(entity) { Id = Offset.GetKeyOffset(entity.PersonId).DeviceExposureId }); break; case "Drug": var drg = entity as DrugExposure ?? new DrugExposure(entity) { Id = Offset.GetKeyOffset(entity.PersonId).DrugExposureId }; DrugForEra.Add(drg); ChunkData.AddData(drg); break; } } }
public override void AddToChunk(string domain, IEnumerable <IEntity> entities) { foreach (var entity in entities) { var entityDomain = GetDomain(domain, entity.Domain); switch (entityDomain) { case "Condition": var obs = entity as Observation; if (obs == null || obs.ValueAsNumber == 1) { var cond = entity as ConditionOccurrence ?? new ConditionOccurrence(entity) { Id = Offset.GetKeyOffset(entity.PersonId) .ConditionOccurrenceId }; ConditionForEra.Add(cond); ChunkData.AddData(cond); } break; case "Measurement": case "Meas Value": var mes = entity as Measurement ?? new Measurement(entity) { Id = Offset.GetKeyOffset(entity.PersonId).MeasurementId }; if (!string.IsNullOrEmpty(mes.SourceValue)) { if (decimal.TryParse(mes.SourceValue, out var valueAsNumber)) { mes.ValueAsNumber = valueAsNumber; } } ChunkData.AddData(mes); break; case "Observation": var o = entity as Observation ?? new Observation(entity) { Id = Offset.GetKeyOffset(entity.PersonId).ObservationId }; if (!string.IsNullOrEmpty(o.SourceValue)) { if (decimal.TryParse(o.SourceValue, out var valueAsNumber)) { o.ValueAsNumber = valueAsNumber; } else if (string.IsNullOrEmpty(o.ValueAsString)) { o.ValueAsString = o.SourceValue; } } ChunkData.AddData(o); break; case "Procedure": ChunkData.AddData(entity as ProcedureOccurrence ?? new ProcedureOccurrence(entity) { Id = Offset.GetKeyOffset(entity.PersonId) .ProcedureOccurrenceId }); break; case "Device": ChunkData.AddData(entity as DeviceExposure ?? new DeviceExposure(entity) { Id = Offset.GetKeyOffset(entity.PersonId).DeviceExposureId }); break; case "Drug": var drg = entity as DrugExposure ?? new DrugExposure(entity) { Id = Offset.GetKeyOffset(entity.PersonId).DrugExposureId }; //1.Look for day_sply_nbr.If this is not NULL, add the value in days to drug_exposure_start_date to get drug_exposure_end_date //2.If there is a day_sply_nbr and a value in ptnt_mdctn_end_dte_tstmp, use the calculated value from step one as the drug_exposure_end_date //3.If day_sply_nbr is NULL then use the ptnt_mdctn_end_dte_tstmp as the verbatim_end_date and drug_exposure_end_date //4.If both day_sply_nbr is NULL and ptnt_mdctn_end_dte_tstmp is NULL then set the drug_exposure_end_date as the drug_exposure_start_date if (drg.DaysSupply.HasValue && drg.DaysSupply > 0) { drg.EndDate = drg.StartDate.AddDays(drg.DaysSupply.Value); } else if (drg.VerbatimEndDate.HasValue) { drg.EndDate = drg.VerbatimEndDate; } else { drg.EndDate = drg.StartDate; } if (!string.IsNullOrEmpty(drg.Sig) && drg.Sig.Contains("~*~")) { drg.Sig = drg.Sig.Replace("~*~", "~x~"); } DrugForEra.Add(drg); ChunkData.AddData(drg); break; } } }
public override void AddToChunk(string domain, IEnumerable <IEntity> entities) { foreach (var entity in entities) { var entityDomain = GetDomain(domain, entity.Domain); switch (entityDomain) { case "Condition": var cond = entity as ConditionOccurrence ?? new ConditionOccurrence(entity) { Id = Offset.GetKeyOffset(entity.PersonId).ConditionOccurrenceId }; if (!cond.EndDate.HasValue) { cond.EndDate = cond.StartDate; } ConditionForEra.Add(cond); ChunkData.AddData(cond); break; case "Measurement": var mes = entity as Measurement ?? new Measurement(entity) { Id = Offset.GetKeyOffset(entity.PersonId).MeasurementId }; ChunkData.AddData(mes); break; case "Meas Value": var mv = entity as Measurement ?? new Measurement(entity) { Id = Offset.GetKeyOffset(entity.PersonId).MeasurementId }; ChunkData.AddData(mv); break; case "Observation": var o = entity as Observation ?? new Observation(entity) { Id = Offset.GetKeyOffset(entity.PersonId).ObservationId }; ChunkData.AddData(o); break; case "Procedure": var p = entity as ProcedureOccurrence ?? new ProcedureOccurrence(entity) { Id = Offset.GetKeyOffset(entity.PersonId).ProcedureOccurrenceId }; ChunkData.AddData(p); break; case "Device": var dev = entity as DeviceExposure ?? new DeviceExposure(entity) { Id = Offset.GetKeyOffset(entity.PersonId).DeviceExposureId }; if (!dev.EndDate.HasValue) { dev.EndDate = dev.StartDate; } ChunkData.AddData(dev); break; case "Drug": var drg = entity as DrugExposure ?? new DrugExposure(entity) { Id = Offset.GetKeyOffset(entity.PersonId).DrugExposureId }; if (!drg.EndDate.HasValue) { drg.EndDate = drg.StartDate; } DrugForEra.Add(drg); ChunkData.AddData(drg); break; } } }
public override void AddToChunk(string domain, IEnumerable <IEntity> entities) { foreach (var entity in entities) { var entityDomain = GetDomain(domain, entity.Domain); switch (entityDomain) { case "Condition": var obs = entity as Observation; if (obs == null || obs.ValueAsNumber == 1) { var cond = entity as ConditionOccurrence ?? new ConditionOccurrence(entity) { Id = KeyMasterOffsetManager.GetKeyOffset(entity.PersonId).ConditionOccurrenceId }; ConditionForEra.Add(cond); ChunkData.AddData(cond); } break; case "Measurement": var mes = entity as Measurement ?? new Measurement(entity) { Id = KeyMasterOffsetManager.GetKeyOffset(entity.PersonId).MeasurementId }; if (entity.AdditionalFields != null && entity.AdditionalFields.ContainsKey("test_result")) { mes.ValueSourceValue = entity.AdditionalFields["test_result"]; } // HIX-1363 //if rslt_nbr is non-zero, take it for both fields, otherwise, //use NULL for value_as_number and take rslt_txt for value_as_string. if (mes.ValueAsNumber != null && mes.ValueAsNumber != 0) { mes.ValueSourceValue = mes.ValueAsNumber.ToString(); } if (mes.TypeConceptId != 44786627 && mes.TypeConceptId != 44786629) { mes.TypeConceptId = 45754907; } ChunkData.AddData(mes); break; case "Meas Value": var m = entity as Measurement ?? new Measurement(entity) { Id = KeyMasterOffsetManager.GetKeyOffset(entity.PersonId).MeasurementId }; if (entity.AdditionalFields != null && entity.AdditionalFields.ContainsKey("test_result")) { m.ValueSourceValue = entity.AdditionalFields["test_result"]; } if (m.TypeConceptId != 44786627 && m.TypeConceptId != 44786629) { m.TypeConceptId = 45754907; } m.TypeConceptId = 45754907; ChunkData.AddData(m); break; case "Observation": var o = entity as Observation ?? new Observation(entity) { Id = KeyMasterOffsetManager.GetKeyOffset(entity.PersonId).ObservationId }; ChunkData.AddData(o); break; case "Procedure": var proc = entity as ProcedureOccurrence ?? new ProcedureOccurrence(entity) { Id = KeyMasterOffsetManager.GetKeyOffset(entity.PersonId).ProcedureOccurrenceId }; if (proc.TypeConceptId == 0) { proc.TypeConceptId = 38000275; } else if (proc.TypeConceptId == 44786627 || proc.TypeConceptId == 44786629) { proc.TypeConceptId = 42865906; } ChunkData.AddData(proc); break; case "Device": var dev = entity as DeviceExposure ?? new DeviceExposure(entity) { Id = KeyMasterOffsetManager.GetKeyOffset(entity.PersonId).DeviceExposureId }; ChunkData.AddData(dev); break; case "Drug": var drg = entity as DrugExposure ?? new DrugExposure(entity) { Id = KeyMasterOffsetManager.GetKeyOffset(entity.PersonId).DrugExposureId }; if (drg.TypeConceptId == 0) { drg.TypeConceptId = 38000275; } if (!drg.EndDate.HasValue) { drg.EndDate = drg.StartDate; } DrugForEra.Add(drg); ChunkData.AddData(drg); break; } //HIX-823 if (domain == "Procedure" && entityDomain != "Procedure") { var po = (ProcedureOccurrence)entity; po.ConceptId = 0; ChunkData.AddData(po); } if (domain == "Observation" && entityDomain != "Observation") { var o = (Observation)entity; o.ConceptId = 0; ChunkData.AddData(o); } } }
public override void AddToChunk(string domain, IEnumerable <IEntity> entities) { foreach (var entity in entities) { var entityDomain = GetDomain(domain, entity.Domain); switch (entityDomain) { case "Condition": var obs = entity as Observation; if (obs == null || obs.ValueAsNumber == 1) { var cond = entity as ConditionOccurrence ?? new ConditionOccurrence(entity) { Id = Offset.GetKeyOffset(entity.PersonId) .ConditionOccurrenceId }; ConditionForEra.Add(cond); ChunkData.AddData(cond); } break; case "Measurement": var mes = entity as Measurement ?? new Measurement(entity) { Id = Offset.GetKeyOffset(entity.PersonId).MeasurementId }; if (mes.ConceptId == 0 && _covid.Any(c => c == mes.SourceValue)) { mes.ConceptId = 700360; } ChunkData.AddData(mes); break; case "Observation": var o = entity as Observation ?? new Observation(entity) { Id = Offset.GetKeyOffset(entity.PersonId).ObservationId }; ChunkData.AddData(o); break; case "Procedure": ChunkData.AddData(entity as ProcedureOccurrence ?? new ProcedureOccurrence(entity) { Id = Offset.GetKeyOffset(entity.PersonId) .ProcedureOccurrenceId }); break; case "Device": ChunkData.AddData(entity as DeviceExposure ?? new DeviceExposure(entity) { Id = Offset.GetKeyOffset(entity.PersonId).DeviceExposureId }); break; case "Drug": var drg = entity as DrugExposure ?? new DrugExposure(entity) { Id = Offset.GetKeyOffset(entity.PersonId).DrugExposureId }; DrugForEra.Add(drg); ChunkData.AddData(drg); break; } } }
public override void AddToChunk(string domain, IEnumerable <IEntity> entities) { foreach (var entity in entities) { var entityDomain = GetDomain(domain, entity.Domain); switch (entityDomain) { case "Condition": var cond = entity as ConditionOccurrence ?? new ConditionOccurrence(entity) { Id = Offset.GetKeyOffset(entity.PersonId).ConditionOccurrenceId }; //Person < 12 years old with live birth. Removing condition_occurrence if (cond.ConceptId == 4014295 && _personAge < 12) { continue; } //Male with live birth. Removing condition_occurrence if (cond.ConceptId == 4014295 && _currentPerson.GenderConceptId == 8507) { continue; } ConditionForEra.Add(cond); ChunkData.AddData(cond); break; case "Measurement": var mes = entity as Measurement ?? new Measurement(entity) { Id = Offset.GetKeyOffset(entity.PersonId).MeasurementId }; mes.ValueAsConceptId = GetValueAsConceptId(mes, 4181412); ChunkData.AddData(mes); break; case "Meas Value": ChunkData.AddData(entity as Measurement ?? new Measurement(entity) { Id = Offset.GetKeyOffset(entity.PersonId).MeasurementId }); break; case "Observation": var obser = entity as Observation ?? new Observation(entity) { Id = Offset.GetKeyOffset(entity.PersonId).ObservationId }; obser.ValueAsConceptId = GetValueAsConceptId(obser, 45877994); ChunkData.AddData(obser); break; case "Procedure": ChunkData.AddData(entity as ProcedureOccurrence ?? new ProcedureOccurrence(entity) { Id = Offset.GetKeyOffset(entity.PersonId).ProcedureOccurrenceId }); break; case "Device": ChunkData.AddData(entity as DeviceExposure ?? new DeviceExposure(entity) { Id = Offset.GetKeyOffset(entity.PersonId).DeviceExposureId }); break; case "Drug": var drg = entity as DrugExposure ?? new DrugExposure(entity) { Id = Offset.GetKeyOffset(entity.PersonId).DrugExposureId }; DrugForEra.Add(drg); ChunkData.AddData(drg); break; } //HIX-823 if (domain == "Procedure" && entityDomain != "Procedure") { var po = (ProcedureOccurrence)entity; po.ConceptId = 0; ChunkData.AddData(po); } if (domain == "Observation" && entityDomain != "Observation") { var o = (Observation)entity; o.ConceptId = 0; ChunkData.AddData(o); } } }
public override void AddToChunk(string domain, IEnumerable <IEntity> entities) { foreach (var entity in entities) { var entityDomain = GetDomain2(domain, entity.Domain); switch (entityDomain) { case "Condition": var cond = entity as ConditionOccurrence ?? new ConditionOccurrence(entity) { Id = Offset.GetKeyOffset(entity.PersonId).ConditionOccurrenceId }; cond.TypeConceptId = 32020; //EHR encounter diagnosis ConditionForEra.Add(cond); ChunkData.AddData(cond); break; case "Measurement": var mes = entity as Measurement ?? new Measurement(entity) { Id = Offset.GetKeyOffset(entity.PersonId).MeasurementId }; mes.TypeConceptId = 44818702; //Lab result; if (!string.IsNullOrEmpty(mes.SourceValue)) { var result = Vocabulary.Lookup(mes.SourceValue, "Read_Code", mes.StartDate); if (result.Any() && result.Count > 0 && result[0].SourceConceptId > 0 /*&& result[0].Domain == "Measurement"*/) { mes.SourceConceptId = result[0].SourceConceptId; } } if (mes.ConceptId > 0) { if (string.Equals(mes.SourceValue, "4J3R200", StringComparison.Ordinal)) { mes.ConceptId = 756065; mes.ValueSourceValue = "Not Detected"; mes.ValueAsConceptId = 9190; } else if (string.Equals(mes.SourceValue, "4J3R100", StringComparison.Ordinal)) { mes.ConceptId = 756065; mes.ValueSourceValue = "Detected"; mes.ValueAsConceptId = 4126681; } else if (string.Equals(mes.SourceValue, "4J3R.00", StringComparison.Ordinal)) { mes.ConceptId = 706179; } ChunkData.AddData(mes); } else { var o = new Observation(entity) { Id = Offset.GetKeyOffset(entity.PersonId).ObservationId }; ChunkData.AddData(o); } break; case "Observation": var obs = entity as Observation ?? new Observation(entity) { Id = Offset.GetKeyOffset(entity.PersonId).ObservationId }; obs.TypeConceptId = 38000280; //Observation recorded from EHR var valueAsConceptId = GetValueAsConceptId(obs, obs.ValueAsString); if (valueAsConceptId.HasValue) { obs.ValueAsConceptId = valueAsConceptId.Value; } ChunkData.AddData(obs); break; case "Procedure": var proc = entity as ProcedureOccurrence ?? new ProcedureOccurrence(entity) { Id = Offset.GetKeyOffset(entity.PersonId) .ProcedureOccurrenceId }; proc.TypeConceptId = 38000275; //EHR order list entry ChunkData.AddData(proc); break; case "Device": ChunkData.AddData(entity as DeviceExposure ?? new DeviceExposure(entity) { Id = Offset.GetKeyOffset(entity.PersonId).DeviceExposureId }); break; case "Drug": var drg = entity as DrugExposure ?? new DrugExposure(entity) { Id = Offset.GetKeyOffset(entity.PersonId).DrugExposureId }; drg.TypeConceptId = 38000177; //Drug|CVX if (entity.Domain != null && entity.Domain.EndsWith("CVX", StringComparison.OrdinalIgnoreCase)) { drg.TypeConceptId = 38000179; // Physician administered drug (identified as procedure) } DrugForEra.Add(drg); ChunkData.AddData(drg); break; } } }