public List <LabResult> FillLabResults(IEntryCollection entryCollection) { List <LabResult> labResult = new List <LabResult>(); foreach (IEntry entryitem in entryCollection) { IOrganizer entryOrganizer = entryitem.AsOrganizer; IComponent4Collection entryComponent = entryOrganizer.Component; LabResult ptLabResult = new LabResult(); foreach (IComponent4 obserComponent in entryComponent) { IObservation entryObservation = obserComponent.AsObservation; IReferenceRange referenceRange = entryObservation.ReferenceRange.FirstOrDefault(); meterialCode = entryObservation.Code; try{ valueCode = (IPQ)entryObservation.Value[0]; }catch (Exception) {} ptLabResult.TestPerformed = meterialCode.DisplayName; ptLabResult.ReportDate = entryObservation.EffectiveTime == null ? null : new DateTime?(Convert.ToDateTime(entryObservation.EffectiveTime.AsDateTime)); ptLabResult.LonicCode = meterialCode.Code; ptLabResult.Units = valueCode != null?valueCode.Unit.ToString() : string.Empty; ptLabResult.TestResultn = valueCode != null?valueCode.Value.ToString():string.Empty; ptLabResult.NormalFindings = referenceRange != null ? referenceRange.ObservationRange.Text != null ? referenceRange.ObservationRange.Text.Text : null : null; } labResult.Add(ptLabResult); } return(labResult); }
public List <VitalSigns> FillVitalSigns(IEntryCollection entryCollection) { List <VitalSigns> vitalSigns = new List <VitalSigns>(); foreach (IEntry singleentry in entryCollection) { IOrganizer organizer = singleentry.AsOrganizer; IComponent4Collection component = organizer.Component; IIVL_TS effectivetime = organizer.EffectiveTime; if (effectivetime == null) { throw new InvalidOperationException(); } VitalSigns ptvitalSigns = new VitalSigns(); try { ptvitalSigns.VitalDate = effectivetime.AsDateTime; } catch (Exception) { ptvitalSigns.VitalDate = effectivetime != null ? effectivetime.Low != null ? effectivetime.Low.Value != null ? new DateTime?(effectivetime.Low.AsDateTime) : null : null : effectivetime.Value != null ? new DateTime?(effectivetime.AsDateTime) : new DateTime?(effectivetime.AsDateTime); } foreach (IComponent4 orgComponent in component) { IObservation orgObservation = orgComponent.AsObservation; ICD itemCode = orgObservation.Code; IANY vitalSignsObservationValue = orgObservation.Value[0]; IPQ itemVlues = (IPQ)vitalSignsObservationValue; if (itemCode.Code != null) { if (itemCode.Code.ToString() == "8302-2") { ptvitalSigns.Height = Convert.ToInt16(itemVlues.Value); ptvitalSigns.HeightUnit = Convert.ToString(itemVlues.Unit); } if (itemCode.Code.ToString() == "3141-9") { ptvitalSigns.WEIGHT = Convert.ToInt16(itemVlues.Value); ptvitalSigns.WeightUnit = Convert.ToString(itemVlues.Unit); } if (itemCode.Code.ToString() == "8480-6") { ptvitalSigns.BloodPressure = itemVlues.Value.ToString() + " " + itemVlues.Unit.ToString(); ptvitalSigns.BloodPressureSystolic = itemVlues.Value.ToString(); } if (itemCode.Code.ToString() == "8462-4") { ptvitalSigns.BloodPressureDiastolic = itemVlues.Value.ToString(); } } } vitalSigns.Add(ptvitalSigns); } return(vitalSigns); }
public void GenerateVitalSignsEntryEmpty(III hl7III, Factory hl7Factory) { IEntry entry = functionalStatus.Section.Entry.Append(); entry.TypeCode = x_ActRelationshipEntry.DRIV; entry.AsOrganizer.ClassCode = x_ActClassDocumentEntryOrganizer.CLUSTER; entry.AsOrganizer.MoodCode = "EVN"; hl7III = entry.AsOrganizer.TemplateId.Append(); hl7III.Init("2.16.840.1.113883.10.20.22.4.26"); hl7III = entry.AsOrganizer.Id.Append(); hl7III.NullFlavor = "UNK"; entry.AsOrganizer.Code.Code = "46680005"; entry.AsOrganizer.Code.CodeSystem = "2.16.840.1.113883.6.96"; entry.AsOrganizer.Code.CodeSystemName = "SNOMED CT"; entry.AsOrganizer.Code.DisplayName = "Vital signs"; entry.AsOrganizer.StatusCode.Init("completed"); entry.AsOrganizer.EffectiveTime.Init(DateTime.Now); IComponent4 component = entry.AsOrganizer.Component.Append(); // Height Component component.AsObservation.ClassCode = "OBS"; component.AsObservation.MoodCode = x_ActMoodDocumentObservation.EVN; hl7III = component.AsObservation.TemplateId.Append(); hl7III.Init("2.16.840.1.113883.10.20.22.4.27"); hl7III = component.AsObservation.Id.Append(); hl7III.NullFlavor = "UNK"; component.AsObservation.Code.NullFlavor = "UNK"; component.AsObservation.Text.Reference.NullFlavor = "UNK"; component.AsObservation.StatusCode.Init("completed"); component.AsObservation.EffectiveTime.NullFlavor = "NA"; IPQ PQ = hl7Factory.CreatePQ(); PQ.NullFlavor = "UNK"; component.AsObservation.Value.Add(PQ); ICE CE = hl7Factory.CreateCE(); CE.NullFlavor = "UNK"; component.AsObservation.InterpretationCode.Add(CE); IReferenceRange refRange = hl7Factory.CreateReferenceRange(); refRange.ObservationRange.Text.Text = ""; component.AsObservation.ReferenceRange.Add(refRange); }
public void GenerateVitalSignsEntry(VitalSigns vitalSign, III hl7III, Factory hl7Factory, ref int refId) { IEntry entry = functionalStatus.Section.Entry.Append(); entry.TypeCode = x_ActRelationshipEntry.DRIV; entry.AsOrganizer.ClassCode = x_ActClassDocumentEntryOrganizer.CLUSTER; entry.AsOrganizer.MoodCode = "EVN"; hl7III = entry.AsOrganizer.TemplateId.Append(); hl7III.Init("2.16.840.1.113883.10.20.22.4.26"); hl7III = entry.AsOrganizer.Id.Append(); hl7III.Init(Guid.NewGuid().ToString()); entry.AsOrganizer.Code.Code = "46680005"; entry.AsOrganizer.Code.CodeSystem = "2.16.840.1.113883.6.96"; entry.AsOrganizer.Code.CodeSystemName = "SNOMED CT"; entry.AsOrganizer.Code.DisplayName = "Vital signs"; entry.AsOrganizer.StatusCode.Init("completed"); IVXB_TS low = new IVXB_TS(); low.Init(Convert.ToDateTime(vitalSign.Entrydate)); entry.AsOrganizer.EffectiveTime = new IVL_TS().Init(low: low); //entry.AsOrganizer.EffectiveTime.Init(Convert.ToDateTime(vitalSign.Entrydate)); ///'''' Height Component ''''''' IComponent4 component = entry.AsOrganizer.Component.Append(); // Height Component component.AsObservation.ClassCode = "OBS"; component.AsObservation.MoodCode = x_ActMoodDocumentObservation.EVN; hl7III = component.AsObservation.TemplateId.Append(); hl7III.Init("2.16.840.1.113883.10.20.22.4.27"); hl7III = component.AsObservation.Id.Append(); hl7III.Init(Guid.NewGuid().ToString()); component.AsObservation.Code.Code = "8302-2"; component.AsObservation.Code.CodeSystem = "2.16.840.1.113883.6.1"; component.AsObservation.Code.CodeSystemName = "LOINC"; component.AsObservation.Code.DisplayName = "Height"; component.AsObservation.Text.Reference.Value = "#vit" + Convert.ToString(refId); component.AsObservation.StatusCode.Init("completed"); low.Init(Convert.ToDateTime(vitalSign.Entrydate)); component.AsObservation.EffectiveTime = new IVL_TS().Init(low: low); //component.AsObservation.EffectiveTime.Init(Convert.ToDateTime(vitalSign.Entrydate)); IPQ PQ = hl7Factory.CreatePQ(); if (!string.IsNullOrEmpty(Convert.ToString(vitalSign.Height))) { PQ.Value = Convert.ToDouble(vitalSign.Height); PQ.Unit = "inch"; } else { PQ.NullFlavor = "UNK"; } component.AsObservation.Value.Add(PQ); ICE CE = hl7Factory.CreateCE(); CE.Code = "N"; CE.CodeSystem = "2.16.840.1.113883.5.83"; component.AsObservation.InterpretationCode.Add(CE); ///'''' Weight Component ''''''''' component = entry.AsOrganizer.Component.Append(); // Weight Component component.AsObservation.ClassCode = "OBS"; component.AsObservation.MoodCode = x_ActMoodDocumentObservation.EVN; hl7III = component.AsObservation.TemplateId.Append(); hl7III.Init("2.16.840.1.113883.10.20.22.4.27"); hl7III = component.AsObservation.Id.Append(); hl7III.Init(Guid.NewGuid().ToString()); component.AsObservation.Code.Code = "3141-9"; component.AsObservation.Code.CodeSystem = "2.16.840.1.113883.6.1"; component.AsObservation.Code.CodeSystemName = "LOINC"; component.AsObservation.Code.DisplayName = "Patient Body Weight - Measured"; component.AsObservation.Text.Reference.Value = "#vit" + Convert.ToString(refId + 1); component.AsObservation.StatusCode.Init("completed"); low.Init(Convert.ToDateTime(vitalSign.Entrydate)); component.AsObservation.EffectiveTime = new IVL_TS().Init(low: low); //component.AsObservation.EffectiveTime.Init(Convert.ToDateTime(vitalSign.Entrydate)); if (!string.IsNullOrEmpty(Convert.ToString(vitalSign.WEIGHT))) { PQ = hl7Factory.CreatePQ(); PQ.Value = Convert.ToDouble(vitalSign.WEIGHT); PQ.Unit = "Kg"; } else { PQ.NullFlavor = "UNK"; } component.AsObservation.Value.Add(PQ); CE = hl7Factory.CreateCE(); CE.Code = "N"; CE.CodeSystem = "2.16.840.1.113883.5.83"; component.AsObservation.InterpretationCode.Add(CE); ///'''' BloodPressure Component ''''''''' component = entry.AsOrganizer.Component.Append(); // Blood Pressure component.AsObservation.ClassCode = "OBS"; component.AsObservation.MoodCode = x_ActMoodDocumentObservation.EVN; hl7III = component.AsObservation.TemplateId.Append(); hl7III.Init("2.16.840.1.113883.10.20.22.4.27"); hl7III = component.AsObservation.Id.Append(); hl7III.Init(Guid.NewGuid().ToString()); component.AsObservation.Code.Code = "3141-9"; component.AsObservation.Code.CodeSystem = "2.16.840.1.113883.6.1"; component.AsObservation.Code.CodeSystemName = "LOINC"; component.AsObservation.Code.DisplayName = "Intravascular Systolic"; component.AsObservation.Text.Reference.Value = "#vit" + Convert.ToString(refId + 2); component.AsObservation.StatusCode.Init("completed"); low.Init(Convert.ToDateTime(vitalSign.Entrydate)); component.AsObservation.EffectiveTime = new IVL_TS().Init(low: low); // component.AsObservation.EffectiveTime.Init(Convert.ToDateTime(vitalSign.Entrydate)); PQ = hl7Factory.CreatePQ(); if (string.IsNullOrEmpty(Convert.ToString(vitalSign.BloodPressure))) { PQ.NullFlavor = "UNK"; } else { PQ.Value = Convert.ToDouble(vitalSign.BloodPressure.Split('/')[0]); PQ.Unit = "mm[Hg]"; } component.AsObservation.Value.Add(PQ); CE = hl7Factory.CreateCE(); CE.Code = "N"; CE.CodeSystem = "2.16.840.1.113883.5.83"; component.AsObservation.InterpretationCode.Add(CE); refId = refId + 3; }
public Dictionary <string, ArrayList> GetDataCollection(ISection sections, PatientClinicalInformation ptInformation) { Dictionary <string, ArrayList> componententries = new Dictionary <string, ArrayList>(); IEntryCollection entries = sections.Entry; IStrucDocText sectiontext = sections.Text; IStrucDocElementCollection textitem = sectiontext.Items; if (entries.Count() > 0) { int count = 0; foreach (IEntry singlerecord in entries) { itemAct = singlerecord.AsAct; itemEncounter = singlerecord.AsEncounter; itemSubstanceAdministration = singlerecord.AsSubstanceAdministration; observation = singlerecord.AsObservation; organizer = singlerecord.AsOrganizer; procedure = singlerecord.AsProcedure; //if(sections.Code.Code== "18776-5") // { // } ArrayList arrayList = new ArrayList(); if (itemAct != null) { entryRelationship = itemAct.EntryRelationship; IIVL_TS efftime = itemAct.EffectiveTime; if (efftime != null && efftime.Low != null) { if (efftime.Low.Value != null) { arrayList.Add(efftime.Low.AsDateTime.ToString()); } else { arrayList.Add("null"); } } else { arrayList.Add("null"); } if (entryRelationship != null && entryRelationship.Count > 0) { observation = entryRelationship.Select(o => o.AsObservation).FirstOrDefault(); if (observation != null) { if (observation.Participant.Count() > 0) { string participent = observation.Participant.Select(p => p.ParticipantRole).FirstOrDefault().AsPlayingEntity.Name.FirstOrDefault().Text; arrayList.Add(participent); } entity = observation.EntryRelationship; foreach (IEntryRelationship singlentity in entity) { IObservation entityobservation = singlentity.AsObservation; IANY observationvalue = entityobservation.Value.FirstOrDefault(); if (observationvalue != null) { var obj = observationvalue.GetType(); string objname = obj.Name; switch (objname) { default: ICD strcd = (ICD)observationvalue; arrayList.Add(strcd.Code); arrayList.Add(strcd.DisplayName); break; case "PQ": IPQ strpq = (IPQ)observationvalue; arrayList.Add(strpq.Value.ToString() + " " + strpq.Unit.ToString()); break; } } } componententries.Add(count.ToString(), arrayList); count++; } } else { arrayList.Add(itemAct.Text.Text); componententries.Add(count.ToString(), arrayList); count++; } } else if (itemEncounter != null) { entryRelationship = itemEncounter.EntryRelationship; if ((entryRelationship.Select(t => t.TypeCode).FirstOrDefault().ToString()) == "RSON") { observation = entryRelationship.Select(o => o.AsObservation).FirstOrDefault(); IIVL_TS efftime = observation.EffectiveTime; IANY observationvalue = observation.Value.FirstOrDefault(); ICD str = (ICD)observationvalue; arrayList.Add(str.DisplayName); arrayList.Add(ptInformation.ptClinicInformation.ClinicName); if (efftime.Low != null) { arrayList.Add(efftime.Low.AsDateTime); } else { arrayList.Add(null); } arrayList.Add(str.Code); } componententries.Add(count.ToString(), arrayList); count++; } else if (itemSubstanceAdministration != null) { consumable = itemSubstanceAdministration.Consumable; manufacturedProduct = consumable.ManufacturedProduct; material = manufacturedProduct.AsMaterial; arrayList.Add(material.Code.Code); arrayList.Add(itemSubstanceAdministration.StatusCode.Code.ToString()); ISXCM_TSCollection efftime = itemSubstanceAdministration.EffectiveTime; if (efftime.Count > 1) { foreach (IVL_TS daterange in efftime) { string startdatetime = daterange.Low != null ? daterange.Low.Value != null?daterange.Low.AsDateTime.ToString() : "null" : "null"; string EndDAtetime = daterange.High != null ? daterange.High.Value != null?daterange.High.AsDateTime.ToString() : "null" : "null"; arrayList.Add(startdatetime); arrayList.Add(EndDAtetime); break; } } else { arrayList.Add(efftime[0].AsDateTime.ToString()); } arrayList.Add(material.Code.DisplayName); if (itemSubstanceAdministration.DoseQuantity != null) { arrayList.Add(itemSubstanceAdministration.DoseQuantity.Value.ToString() + " " + itemSubstanceAdministration.DoseQuantity.Unit.ToString()); } else { arrayList.Add("NA"); } if (manufacturedProduct.ManufacturerOrganization != null) { arrayList.Add(manufacturedProduct.ManufacturerOrganization.Name.ToString()); } else { arrayList.Add("NA"); } componententries.Add(count.ToString(), arrayList); count++; } else if (observation != null) { if (observation.Value.Count > 0) { IANY observationvalue = observation.Value.FirstOrDefault(); ICD str = (ICD)observationvalue; arrayList.Add(str.Code); arrayList.Add(str.DisplayName); IIVL_TS efftime = observation.EffectiveTime; if (efftime != null && efftime.Low != null) { if (efftime.Low.Value != null) { arrayList.Add(efftime.Low.AsDateTime.ToString()); } else { arrayList.Add("null"); } } else { arrayList.Add("null"); } } else { arrayList.Add(null); arrayList.Add(null); arrayList.Add(null); } componententries.Add(count.ToString(), arrayList); count++; } else if (organizer != null) { IComponent4Collection orgComponent = organizer.Component; foreach (IComponent4 objItem in orgComponent) { IObservation orgObservation = objItem.AsObservation; arrayList.Add(orgObservation.Code.DisplayName); if (orgObservation.Value != null) { IANY observationvalue = orgObservation.Value.FirstOrDefault(); var obj = observationvalue.GetType(); string objname = obj.Name; switch (objname) { default: ICD strcd = (ICD)observationvalue; arrayList.Add(strcd.Code); arrayList.Add(strcd.DisplayName); break; case "PQ": IPQ strpq = (IPQ)observationvalue; arrayList.Add(strpq.Value.ToString() + " " + strpq.Unit.ToString()); break; } //IPQ str = (IPQ)observationvalue; //arrayList.Add(str.Value.ToString() + " " + str.Unit.ToString()); } IIVL_TS efftime = orgObservation.EffectiveTime; if (efftime != null && efftime.Low != null) { if (efftime.Low.Value != null) { arrayList.Add(efftime.Low.AsDateTime.ToString()); } else { arrayList.Add("null"); } } else { arrayList.Add("null"); } if (orgObservation.ReferenceRange != null) { if (orgObservation.ReferenceRange.Count > 0) { arrayList.Add(orgObservation.ReferenceRange[0].ObservationRange.Text.Text); } else { arrayList.Add("NA"); } } } arrayList.Add(organizer.Code.Code); componententries.Add(count.ToString(), arrayList); count++; } else if (procedure != null) { if (procedure.Code != null) { arrayList.Add(procedure.Code.Code); arrayList.Add(procedure.Code.DisplayName); } else { arrayList.Add(null); arrayList.Add(null); } componententries.Add(count.ToString(), arrayList); count++; } } } return(componententries); }
public void GenerateProblemEntry(PatientProblemes patientProblem, string refId, DateTime dateofbirth, III hl7III, Factory hl7Factory) { IEntry entry = functionalStatus.Section.Entry.Append(); entry.TypeCode = x_ActRelationshipEntry.DRIV; entry.AsAct.ClassCode = x_ActClassDocumentEntryAct.ACT; entry.AsAct.MoodCode = x_DocumentActMood.EVN; IIVXB_TS TS = hl7Factory.CreateIVXB_TS(); hl7III = entry.AsAct.Id.Append(); hl7III.Init(Convert.ToString(patientProblem.PatientGuid)); hl7III = entry.AsAct.TemplateId.Append(); hl7III.Init("2.16.840.1.113883.10.20.22.4.3"); entry.AsAct.Code.Code = "CONC"; entry.AsAct.Code.CodeSystem = "2.16.840.1.113883.5.6"; entry.AsAct.Code.CodeSystemName = "LOINC"; entry.AsAct.StatusCode.Init((Convert.ToString(patientProblem.Status) == "Active" ? "active" : "completed")); if (patientProblem.DateDiagnosed != null) { entry.AsAct.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS()); } else { entry.AsAct.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS()); //entry.AsAct.EffectiveTime.NullFlavor = "UNK"; /* Not Compiled * entry.AsAct.EffectiveTime = new IVL_TS().Init(Value:null, low:new IVXB_TS().Init(Convert.ToDateTime(patientProblem.DateDiagnosed)),high:null,width:null,center:null);*/ // Setting the DateTime. } IEntryRelationship entryRel = entry.AsAct.EntryRelationship.Append(); entryRel.TypeCode = x_ActRelationshipEntryRelationship.SUBJ; entryRel.AsObservation.ClassCode = "OBS"; entryRel.AsObservation.MoodCode = x_ActMoodDocumentObservation.EVN; III TempId = entryRel.AsObservation.TemplateId.Append(); TempId.Root = "2.16.840.1.113883.10.20.22.4.4"; hl7III = entryRel.AsObservation.Id.Append(); hl7III.Root = Guid.NewGuid().ToString(); entryRel.AsObservation.Code.Code = Convert.ToString(patientProblem.Description).ToLower().Contains("finding") ? "404684003" : Convert.ToString(patientProblem.Description).ToLower().Contains("disease") ? "282291009" : "409586006"; entryRel.AsObservation.Code.CodeSystem = "2.16.840.1.113883.6.96"; entryRel.AsObservation.Code.DisplayName = Convert.ToString(patientProblem.Description).ToLower().Contains("finding") ? "Finding" : Convert.ToString(patientProblem.Description).ToLower().Contains("disease") ? "Diagnosis" : "Complaint"; IED ED = hl7Factory.CreateED(); ED.Reference.Value = refId; entryRel.AsObservation.Text = ED; ICS CS = hl7Factory.CreateCS(); CS.Init("completed"); entryRel.AsObservation.StatusCode = CS; if (Convert.ToString(patientProblem.Status) == "Resolved") { if (object.ReferenceEquals(patientProblem.DateDiagnosed, DBNull.Value)) { entry.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS()); } else { entry.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS()); //entryRel.AsObservation.EffectiveTime.NullFlavor = "UNK"; /* Not Compiled * entryRel.AsObservation.EffectiveTime.Init(low: new IVXB_TS().Init(Convert.ToDateTime(patientProblem.DateDiagnosed)), high: new IVXB_TS()); * // Because Allergy Start Date is Missing. * * entryRel.AsObservation.EffectiveTime.High.NullFlavor = "UNK";*/ } } else { if (object.ReferenceEquals(patientProblem.DateDiagnosed, DBNull.Value)) { entryRel.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS()); //entryRel.AsObservation.EffectiveTime.NullFlavor = "UNK"; } else { entryRel.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS()); //entryRel.AsObservation.EffectiveTime.NullFlavor = "UNK"; /* Not Compiled * entryRel.AsObservation.EffectiveTime.Init(low: new IVXB_TS().Init(Convert.ToDateTime(patientProblem.DateDiagnosed)), high: new IVXB_TS()); * entryRel.AsObservation.EffectiveTime.High.NullFlavor = "UNK";*/ } } ICD CD = hl7Factory.CreateCD(); string snomedCode = GetSNOMED(Convert.ToString(patientProblem.Description)); if (string.IsNullOrEmpty(snomedCode)) { CD.NullFlavor = "UNK"; } else { CD.Code = snomedCode; CD.CodeSystem = "2.16.840.1.113883.6.96"; CD.CodeSystemName = "SNOMED CT"; CD.DisplayName = Convert.ToString(patientProblem.Description); } entryRel.AsObservation.Value.Add(CD); ///''''''''''''Problem Observation'''''''''''''''''' IEntryRelationship entryProblemObs = entryRel.AsObservation.EntryRelationship.Append(); entryProblemObs.TypeCode = x_ActRelationshipEntryRelationship.SUBJ; entryProblemObs.AsObservation.ClassCode = "OBS"; entryProblemObs.AsObservation.MoodCode = x_ActMoodDocumentObservation.EVN; TempId = entryProblemObs.AsObservation.TemplateId.Append(); TempId.Root = "2.16.840.1.113883.10.20.22.4.4"; hl7III = entryProblemObs.AsObservation.Id.Append(); hl7III.Root = Guid.NewGuid().ToString(); entryProblemObs.AsObservation.Code.Code = Convert.ToString(patientProblem.Description).ToLower().Contains("finding") ? "404684003" : Convert.ToString(patientProblem.Description).ToLower().Contains("disease") ? "282291009" : "409586006"; entryProblemObs.AsObservation.Code.CodeSystem = "2.16.840.1.113883.6.96"; entryProblemObs.AsObservation.Code.DisplayName = Convert.ToString(patientProblem.Description).ToLower().Contains("finding") ? "Finding" : Convert.ToString(patientProblem.Description).ToLower().Contains("disease") ? "Diagnosis" : "Complaint"; ED = hl7Factory.CreateED(); ED.Reference.Value = refId; entryProblemObs.AsObservation.Text = ED; CS = hl7Factory.CreateCS(); CS.Init("completed"); entryProblemObs.AsObservation.StatusCode = CS; if (Convert.ToString(patientProblem.Status) == "Resolved") { if (object.ReferenceEquals(patientProblem.DateDiagnosed, DBNull.Value)) { entryProblemObs.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS()); //entryProblemObs.AsObservation.EffectiveTime.NullFlavor = "UNK"; } else { entryProblemObs.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS()); /* Not Compiled * entryProblemObs.AsObservation.EffectiveTime.Init(low: new IVXB_TS().Init(Convert.ToDateTime(patientProblem.DateDiagnosed)), high: new IVXB_TS()); * // Because Allergy Start Date is Missing. * entryProblemObs.AsObservation.EffectiveTime.High.NullFlavor = "UNK";*/ } } else { if (object.ReferenceEquals(patientProblem.DateDiagnosed, DBNull.Value)) { entryProblemObs.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS()); } else { entryProblemObs.AsObservation.EffectiveTime = new IVL_TS().Init(low: new IVXB_TS()); /* Not Compiled * entryProblemObs.AsObservation.EffectiveTime.Init(low: new IVXB_TS().Init(Convert.ToDateTime(patientProblem.DateDiagnosed)), high: new IVXB_TS()); * entryProblemObs.AsObservation.EffectiveTime.High.NullFlavor = "UNK";*/ } } CD = hl7Factory.CreateCD(); snomedCode = GetSNOMED(Convert.ToString(patientProblem.Description)); if (string.IsNullOrEmpty(snomedCode)) { CD.NullFlavor = "UNK"; } else { CD.Code = snomedCode; CD.CodeSystem = "2.16.840.1.113883.6.96"; CD.DisplayName = Convert.ToString(patientProblem.Description); } entryProblemObs.AsObservation.Value.Add(CD); ///'''''''''''' Age Observation'''''''''''''''''' if ((!object.ReferenceEquals(patientProblem.DateDiagnosed, DBNull.Value))) { IEntryRelationship age_EntryRel = entryRel.AsObservation.EntryRelationship.Append(); age_EntryRel.TypeCode = x_ActRelationshipEntryRelationship.SUBJ; age_EntryRel.InversionInd = true; age_EntryRel.InversionIndSpecified = true; age_EntryRel.AsObservation.ClassCode = "OBS"; age_EntryRel.AsObservation.MoodCode = x_ActMoodDocumentObservation.EVN; hl7III = age_EntryRel.AsObservation.TemplateId.Append(); hl7III.Init("2.16.840.1.113883.10.20.22.4.31"); CD = hl7Factory.CreateCD(); CD.Init("445518008", "2.16.840.1.113883.6.96", "", "Age"); age_EntryRel.AsObservation.Code = CD; age_EntryRel.AsObservation.StatusCode.Init("completed"); IPQ PQ = hl7Factory.CreatePQ(); PQ.Value = calcYear(Convert.ToDateTime(patientProblem.DateDiagnosed), dateofbirth); PQ.Unit = "a"; age_EntryRel.AsObservation.Value.Add(PQ); } ///'''''''''''' Problem Status Observation''''''''''''' IEntryRelationship problemStatus_EntryRel = entryRel.AsObservation.EntryRelationship.Append(); problemStatus_EntryRel.TypeCode = x_ActRelationshipEntryRelationship.REFR; problemStatus_EntryRel.InversionInd = true; problemStatus_EntryRel.InversionIndSpecified = true; problemStatus_EntryRel.AsObservation.ClassCode = "OBS"; problemStatus_EntryRel.AsObservation.MoodCode = x_ActMoodDocumentObservation.EVN; hl7III = problemStatus_EntryRel.AsObservation.TemplateId.Append(); hl7III.Init("2.16.840.1.113883.10.20.22.4.6"); CD = hl7Factory.CreateCD(); CD.Init("33999-4", "2.16.840.1.113883.6.1", "LOINC", "Status"); problemStatus_EntryRel.AsObservation.Code = CD; problemStatus_EntryRel.AsObservation.StatusCode.Init("completed"); //55561003-Active, 73425007-Inactive, 413322009- Resolved CD = hl7Factory.CreateCD(); CD.Init((Convert.ToString(patientProblem.Status) == "Active" ? "55561003" : (Convert.ToString(patientProblem.Status) == "Inactive" ? "73425007" : "413322009")), "2.16.840.1.113883.6.96", "SNOMED CT", Convert.ToString(patientProblem.Status)); problemStatus_EntryRel.AsObservation.Value.Add(CD); }