public List <PatientProblemes> FillProblems(IEntryCollection entryCollection) { List <PatientProblemes> Problemes = new List <PatientProblemes>(); foreach (IEntry singleentry in entryCollection) { IObservation probObservation = singleentry.AsAct.EntryRelationship.FirstOrDefault().AsObservation; IIVL_TS effectivetime = probObservation.EffectiveTime; IANY probValue = probObservation.Value[0]; ICD itemVlues = (ICD)probValue; PatientProblemes ptproblem = new PatientProblemes(); ptproblem.ProblemCode = itemVlues.Code != null ? itemVlues.Code : null; IEntryRelationship ObserentryRelation = probObservation.EntryRelationship.Where(e => e.AsObservation.Code.Code.ToString() == "33999-4").FirstOrDefault(); if (ObserentryRelation != null) { IANY probStatusVal = ObserentryRelation.AsObservation.Value.FirstOrDefault(); ICD StatusVlues = (ICD)probStatusVal; ptproblem.Status = StatusVlues.DisplayName; } else { ptproblem.Status = null; } ptproblem.DateDiagnosed = effectivetime.Low != null ? effectivetime.Low.Value != null?effectivetime.Low.AsDateTime.ToString() : null : null; ptproblem.Description = itemVlues.DisplayName != null ? itemVlues.DisplayName : null; Problemes.Add(ptproblem); } return(Problemes); }
/// <summary> /// Get Patient Problems /// </summary> /// <param name="dataArr"></param> /// <returns></returns> public List <PatientProblemes> GetProblems(Dictionary <string, ArrayList> dataArr) { List <PatientProblemes> Problemes = new List <PatientProblemes>(); if (dataArr.Count > 0) { for (int i = 0; i < dataArr.Count; i++) { PatientProblemes ptproblem = new PatientProblemes(); ArrayList itemproblem = dataArr[i.ToString()]; ptproblem.ProblemCode = itemproblem[1].ToString(); ptproblem.Status = itemproblem[4].ToString(); ptproblem.DateDiagnosed = itemproblem[0].ToString(); ptproblem.Description = itemproblem[2].ToString(); Problemes.Add(ptproblem); } } return(Problemes); }
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); }