internal MicrobiologyReport[] toMicrobiologyReports(string response) { if (response == "") { return(null); } ArrayList lst = new ArrayList(); string[] lines = StringUtils.split(response, '\n'); lines = StringUtils.trimArray(lines); MicrobiologyReport rpt = null; for (int i = 0; i < lines.Length; i++) { lines[i] = lines[i].Replace("<\\Line>", ""); int firstGT = lines[i].IndexOf(">"); lines[i] = lines[i].Substring(firstGT + 1, lines[i].Length - firstGT - 1); string[] flds = StringUtils.split(lines[i], StringUtils.CARET); if (!StringUtils.isNumeric(flds[0])) // the last two lines appear to be the RPC string and the number of results - just ignoring for now but may be useful later { continue; } int fldnum = Convert.ToInt32(flds[0]); switch (fldnum) { case 1: if (rpt != null) { if (!String.IsNullOrEmpty(rpt.Sample)) { rpt.Sample = rpt.Sample.Substring(0, rpt.Sample.Length - 1); } lst.Add(rpt); } rpt = new MicrobiologyReport(); rpt.Title = "Microbiology Report"; if (flds.Length == 2) { string[] parts = StringUtils.split(flds[1], StringUtils.SEMICOLON); if (parts.Length == 2) { rpt.Facility = new SiteId(parts[1], parts[0]); } else if (flds[1] != "") { rpt.Facility = new SiteId(_cxn.DataSource.SiteId.Id, flds[1]); } else { rpt.Facility = _cxn.DataSource.SiteId; } } break; case 2: if (flds.Length == 2) { rpt.Timestamp = VistaTimestamp.toUtcFromRdv(flds[1]); } break; case 3: if (flds.Length == 2) { rpt.Title = flds[1]; } break; case 4: if (flds.Length == 2) { rpt.Sample += flds[1] + '\n'; } break; case 5: if (flds.Length == 2) { rpt.Specimen = new LabSpecimen("", flds[1], "", ""); } break; case 6: if (flds.Length == 2) { rpt.Specimen.AccessionNumber = flds[1]; } break; case 7: if (flds.Length == 2) { rpt.Text += flds[1] + '\n'; } break; } } if (rpt != null) { lst.Add(rpt); } return((MicrobiologyReport[])lst.ToArray(typeof(MicrobiologyReport))); }
internal Note[] toNotes(string response) { if (String.IsNullOrEmpty(response)) { return(null); } string[] lines = StringUtils.split(response, '\n'); ArrayList lst = new ArrayList(); Note note = null; string scannedDoc = ""; bool fInTextPortion = false; for (int i = 0; i < lines.Length; i++) { if (String.IsNullOrEmpty(lines[i])) { continue; } string[] flds = StringUtils.split(lines[i], StringUtils.CARET); if (flds.Length == 1 && fInTextPortion) { scannedDoc += lines[i] + "\n"; continue; } if (flds.Length <= 1) { continue; } if (flds[1] == "[+]") { note.Text = VistaUtils.removeCtlChars(note.Text); lst.Add(note); fInTextPortion = false; } else if (flds[0] == "1") { fInTextPortion = false; note = new Note(); string[] subflds = StringUtils.split(flds[1], StringUtils.SEMICOLON); if (subflds.Length == 2) { note.SiteId = new SiteId(subflds[1], subflds[0]); } else if (flds[1] != "") { note.SiteId = new SiteId(_cxn.DataSource.SiteId.Id, flds[1]); } else { note.SiteId = _cxn.DataSource.SiteId; } } else if (flds[0] == "2") { note.Id = flds[1]; } else if (flds[0] == "3") { note.Timestamp = VistaTimestamp.toUtcFromRdv(flds[1]); } else if (flds[0] == "4") { note.LocalTitle = flds[1]; } else if (flds[0] == "5") { note.Author = new Author("", flds[1], ""); } else if (flds[0] == "6") { fInTextPortion = true; if (!String.IsNullOrEmpty(scannedDoc)) { note.Text += scannedDoc + "\n"; scannedDoc = ""; } note.Text += flds[1] + "\n"; if (flds[1].StartsWith("STANDARD TITLE")) { string[] parts = StringUtils.split(flds[1], StringUtils.COLON); note.StandardTitle = parts[1].Trim(); } } } Note[] notes = (Note[])lst.ToArray(typeof(Note)); return(notes); }