internal ChemHemReport[] toChemHemReports(string response) { if (response == "") { return(null); } DictionaryHashList lst = new DictionaryHashList(); string[] lines = StringUtils.split(response, StringUtils.CRLF); lines = StringUtils.trimArray(lines); ChemHemReport rpt = null; LabResult rslt = null; string ts = ""; string facilityTag = ""; string facilityName = ""; for (int i = 0; i < lines.Length; i++) { string[] flds = StringUtils.split(lines[i], StringUtils.CARET); if (!StringUtils.isNumeric(flds[0])) { throw new DataMisalignedException("Invalid fldnum: " + flds[0] + " in lines[" + i + "]"); } int fldnum = Convert.ToInt32(flds[0]); switch (fldnum) { case 1: string[] parts = StringUtils.split(flds[1], StringUtils.SEMICOLON); if (parts.Length == 2) { facilityTag = parts[1]; facilityName = parts[0]; } else if (flds[1] != "") { facilityTag = cxn.DataSource.SiteId.Id; facilityName = flds[1]; } else { facilityTag = cxn.DataSource.SiteId.Id; facilityName = cxn.DataSource.SiteId.Name; } break; case 2: if (rpt != null) { if (StringUtils.isEmpty(rslt.Test.RefRange)) { if (!StringUtils.isEmpty(rslt.Test.LowRef) && !StringUtils.isEmpty(rslt.Test.HiRef)) { rslt.Test.RefRange = rslt.Test.LowRef + " - " + rslt.Test.HiRef; } } rpt.AddResult(rslt); } rslt = new LabResult(); rslt.Test = new LabTest(); ts = VistaTimestamp.toUtcFromRdv(flds[1]); if (lst[ts] == null) { rpt = new ChemHemReport(); rpt.Facility = new SiteId(facilityTag, facilityName); rpt.Timestamp = ts; lst.Add(ts, rpt); } break; case 3: if (flds.Length == 2) { rslt.Test.Name = flds[1]; } break; case 4: if (flds.Length == 2) { if (null != rslt) { rslt.SpecimenType = flds[1]; } } break; case 5: if (flds.Length == 2) { rslt.Value = flds[1]; } break; case 6: if (flds.Length == 2) { rslt.BoundaryStatus = flds[1]; } break; case 7: if (flds.Length == 2) { rslt.Test.Units = flds[1]; } break; case 8: if (flds.Length == 2) { rslt.Test.LowRef = flds[1]; } break; case 9: if (flds.Length == 2) { rslt.Test.HiRef = flds[1]; } break; case 10: if (flds.Length == 2) { rslt.Comment += flds[1] + '\n'; } break; } } if (rpt != null) { if (StringUtils.isEmpty(rslt.Test.RefRange)) { if (!StringUtils.isEmpty(rslt.Test.LowRef) && !StringUtils.isEmpty(rslt.Test.HiRef)) { rslt.Test.RefRange = rslt.Test.LowRef + " - " + rslt.Test.HiRef; } } rpt.AddResult(rslt); } ChemHemReport[] result = new ChemHemReport[lst.Count]; for (int i = 0; i < lst.Count; i++) { DictionaryEntry de = lst[i]; result[i] = (ChemHemReport)de.Value; } return(result); }
internal ChemHemReport toChemHemReport(string response, ref string nextDate) { if (String.IsNullOrEmpty(response)) { return null; } string[] lines = StringUtils.split(response, StringUtils.CRLF); lines = StringUtils.trimArray(lines); string[] flds = StringUtils.split(lines[0], StringUtils.CARET); nextDate = flds[2]; if (flds[1] != "CH") { return null; } if (lines.Length == 1) { return null; } int ntests = Convert.ToInt16(flds[0]); ChemHemReport rpt = new ChemHemReport(); rpt.Id = flds[2] + '^' + flds[5]; rpt.Timestamp = flds[2]; rpt.Specimen = new LabSpecimen(); rpt.Specimen.CollectionDate = VistaTimestamp.toUtcString(flds[2]); rpt.Specimen.Name = flds[4]; rpt.Specimen.AccessionNumber = flds[5]; rpt.Author = new Author(); rpt.Author.Name = flds[6]; int lineIdx = 1; for (lineIdx = 1; lineIdx <= ntests; lineIdx++) { LabResult lr = new LabResult(); flds = StringUtils.split(lines[lineIdx], StringUtils.CARET); if (flds.Length < 6) { continue; } lr.Test = new LabTest(); lr.Test.Id = flds[0]; lr.Test.Name = flds[1]; lr.Value = flds[2].Trim(); lr.BoundaryStatus = flds[3]; lr.Test.Units = flds[4].Trim(); lr.Test.RefRange = flds[5]; // MHV patch - probably no one needs this lr.LabSiteId = cxn.DataSource.SiteId.Id; rpt.AddResult(lr); } rpt.Comment = ""; while (lineIdx < lines.Length) { rpt.Comment += lines[lineIdx++].TrimStart() + "\r\n"; } return rpt; }
internal ChemHemReport toChemHemReport(string response, ref string nextDate) { if (String.IsNullOrEmpty(response)) { return(null); } string[] lines = StringUtils.split(response, StringUtils.CRLF); lines = StringUtils.trimArray(lines); string[] flds = StringUtils.split(lines[0], StringUtils.CARET); nextDate = flds[2]; if (flds[1] != "CH") { return(null); } if (lines.Length == 1) { return(null); } int ntests = Convert.ToInt16(flds[0]); ChemHemReport rpt = new ChemHemReport(); rpt.Id = flds[2] + '^' + flds[5]; rpt.Timestamp = flds[2]; rpt.Specimen = new LabSpecimen(); rpt.Specimen.CollectionDate = VistaTimestamp.toUtcString(flds[2]); rpt.Specimen.Name = flds[4]; rpt.Specimen.AccessionNumber = flds[5]; rpt.Author = new Author(); rpt.Author.Name = flds[6]; int lineIdx = 1; for (lineIdx = 1; lineIdx <= ntests; lineIdx++) { LabResult lr = new LabResult(); flds = StringUtils.split(lines[lineIdx], StringUtils.CARET); if (flds.Length < 6) { continue; } lr.Test = new LabTest(); lr.Test.Id = flds[0]; lr.Test.Name = flds[1]; lr.Value = flds[2].Trim(); lr.BoundaryStatus = flds[3]; lr.Test.Units = flds[4].Trim(); lr.Test.RefRange = flds[5]; // MHV patch - probably no one needs this lr.LabSiteId = cxn.DataSource.SiteId.Id; rpt.AddResult(lr); } rpt.Comment = ""; while (lineIdx < lines.Length) { rpt.Comment += lines[lineIdx++].TrimStart() + "\r\n"; } return(rpt); }