internal IndexedHashtable toChemHemSpecimens(string[] response, ref string fromDate, ref string toDate)
        {
            IndexedHashtable result = new IndexedHashtable(response.Length);

            for (int i = 0; i < response.Length; i++)
            {
                string[]    flds     = StringUtils.split(response[i], StringUtils.CARET);
                LabSpecimen specimen = new LabSpecimen();
                specimen.Id             = flds[0];
                specimen.ReportDate     = VistaTimestamp.toUtcString(flds[2]);
                specimen.CollectionDate = VistaTimestamp.toUtcString(flds[1]);
                if (i == 0)
                {
                    fromDate = specimen.CollectionDate;
                }
                if (i == response.Length - 1)
                {
                    toDate = specimen.CollectionDate;
                }
                specimen.Name            = flds[3];
                specimen.AccessionNumber = flds[4];
                if (flds.Length > 6)
                {
                    specimen.Site = flds[5];
                }
                if (flds.Length > 7)
                {
                    specimen.Facility = new SiteId(flds[7], flds[6]);
                }
                string key = flds[1] + '^' + flds[4];
                result.Add(key, specimen);
            }
            return(result);
        }
Esempio n. 2
0
        public string getTimestamp()
        {
            MdoQuery request  = buildGetTimestampRequest();
            string   response = (string)cxn.query(request);

            return(VistaTimestamp.toUtcString(response));
        }
 internal string buildChemHemSpecimensScreenParam(string fromDate, string toDate, string pieceNum)
 {
     if (fromDate == "")
     {
         return("");
     }
     fromDate = VistaTimestamp.fromUtcFromDate(fromDate);
     toDate   = VistaTimestamp.fromUtcToDate(toDate);
     return("S FD=" + fromDate + ",TD=" + toDate + ",CDT=$P(^(0),U," + pieceNum + ") I CDT>=FD,CDT<TD");
 }
        public void TestPrecisionPositions()
        {
            string testDate = VistaTimestamp.fromDateTime(new DateTime(2008, 01, 23, 12, 34, 56, 789));

            Assert.AreEqual("308", testDate.Substring(0, (int)VistaDateTimeIterator.PRECISION.YEAR));
            Assert.AreEqual("30801", testDate.Substring(0, (int)VistaDateTimeIterator.PRECISION.MONTH));
            Assert.AreEqual("3080123", testDate.Substring(0, (int)VistaDateTimeIterator.PRECISION.DAY));
            Assert.AreEqual("3080123.12", testDate.Substring(0, (int)VistaDateTimeIterator.PRECISION.HOUR));
            Assert.AreEqual("3080123.1234", testDate.Substring(0, (int)VistaDateTimeIterator.PRECISION.MINUTE));
            Assert.AreEqual("3080123.123456", testDate.Substring(0, (int)VistaDateTimeIterator.PRECISION.SECOND));
        }
Esempio n. 5
0
        public static string buildFromToDateScreenParam(string fromDate, string toDate, int node, int pieceNum)
        {
            if (fromDate == "")
            {
                return("");
            }
            DateUtils.CheckDateRange(fromDate, toDate);

            // Need test for valid dates.
            fromDate = VistaTimestamp.fromUtcFromDate(fromDate);
            toDate   = VistaTimestamp.fromUtcString(toDate);
            return("S FD=" + fromDate + ",TD=" + toDate + ",CDT=$P(^(" + node + "),U," + pieceNum + ") I CDT>=FD,CDT<TD");
        }
Esempio n. 6
0
        internal ProstheticClaim[] toProstheticClaims(string[] response)
        {
            if (response == null || response.Length == 0)
            {
                return(null);
            }
            List <ProstheticClaim> lst = new List <ProstheticClaim>(response.Length);

            for (int i = 0; i < response.Length; i++)
            {
                if (response[i] == "")
                {
                    continue;
                }
                response[i] = response[i].Replace("&#94;", "^");
                string[] flds = response[i].Split(new char[] { '^' });
                if (flds.Length == 0)
                {
                    continue;
                }
                ProstheticClaim claim = new ProstheticClaim();
                claim.Id = flds[0];
                if (flds.Length > 1)
                {
                    claim.PatientId = flds[1];
                }
                if (flds.Length > 2)
                {
                    claim.PatientName = flds[2];
                }
                if (flds.Length > 3)
                {
                    claim.EpisodeDate = VistaTimestamp.toUtcString(flds[3]);
                }
                if (flds.Length > 4)
                {
                    claim.ItemId = flds[4];
                }
                if (flds.Length > 5)
                {
                    claim.Timestamp = VistaTimestamp.toUtcString(flds[5]);
                }
                if (flds.Length > 6)
                {
                    claim.LastEditTimestamp = VistaTimestamp.toUtcString(flds[6]);
                }
                lst.Add(claim);
            }
            return((ProstheticClaim[])lst.ToArray());
        }
Esempio n. 7
0
        public static MdoQuery buildReportTextRequest(string dfn, string fromDate, string toDate, int nrpts, string arg)
        {
            if (String.IsNullOrEmpty(fromDate) || fromDate.Equals("0"))
            {
                fromDate = DateUtils.MinDate;
            }

            if (String.IsNullOrEmpty(toDate))
            {
                toDate = "0";
            }

            CheckRpcParams(dfn, fromDate, toDate);

            if (String.IsNullOrEmpty(arg))
            {
                throw new NullOrEmptyParamException("routine name");
            }

            VistaQuery vq = new VistaQuery("ORWRP REPORT TEXT");

            vq.addParameter(vq.LITERAL, dfn);
            if (nrpts != 0)
            {
                arg += nrpts.ToString();
            }
            vq.addParameter(vq.LITERAL, arg);
            vq.addParameter(vq.LITERAL, "");
            vq.addParameter(vq.LITERAL, "");
            vq.addParameter(vq.LITERAL, "");
            if (fromDate != "0")
            {
                fromDate = VistaTimestamp.fromUtcString(fromDate);
            }
            vq.addParameter(vq.LITERAL, fromDate);
            if (toDate != "0")
            {
                toDate = VistaTimestamp.fromUtcString(toDate);
            }
            vq.addParameter(vq.LITERAL, toDate);
            return(vq);
        }
Esempio n. 8
0
 internal Consult[] toConsults(string response)
 {
     if (String.IsNullOrEmpty(response) || response.StartsWith("< PATIENT DOES NOT HAVE ANY CONSULTS/REQUESTS"))
     {
         return(null);
     }
     string[] rex = StringUtils.split(response, StringUtils.CRLF);
     rex = StringUtils.trimArray(rex);
     Consult[] result = new Consult[rex.Length];
     for (int i = 0; i < rex.Length; i++)
     {
         string[] flds = StringUtils.split(rex[i], StringUtils.CARET);
         Consult  c    = new Consult();
         c.Id        = flds[0];
         c.Text      = getConsultNote(c.Id);
         c.Timestamp = VistaTimestamp.toDateTime(flds[1]);
         c.Status    = VistaOrdersDao.decodeOrderStatus(flds[2]);
         c.Title     = flds[6];
         //c.Service = new KeyValuePair<string, string>("", flds[2]);
         result[i] = c;
     }
     return(result);
 }
Esempio n. 9
0
 public static void CheckVisitString(string s)
 {
     if (String.IsNullOrEmpty(s))
     {
         throw new NullOrEmptyParamException("Visit String");
     }
     string[] pieces = s.Split(new char[] { ';' });
     if (pieces.Length != 3)
     {
         throw new MdoException(MdoExceptionCode.ARGUMENT_INVALID, "Invalid visit string (need 3 semi-colon delimited pieces): " + s);
     }
     if (!isWellFormedIen(pieces[0]))
     {
         throw new MdoException(MdoExceptionCode.ARGUMENT_INVALID, "Invalid visit string (invalid location IEN): " + s);
     }
     if (!VistaTimestamp.isValid(pieces[1]))
     {
         throw new MdoException(MdoExceptionCode.ARGUMENT_INVALID, "Invalid visit string (invalid VistA timestamp): " + s);
     }
     if (pieces[2] != "A" && pieces[2] != "H" && pieces[2] != "E")
     {
         throw new MdoException(MdoExceptionCode.ARGUMENT_INVALID, "Invalid visit string (type must be 'A', 'H' or 'E'): " + s);
     }
 }
        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);
        }
Esempio n. 11
0
        internal ElectronMicroscopyReport[] toElectronMicroscopyReports(string response)
        {
            if (response == "")
            {
                return(null);
            }
            ArrayList lst = new ArrayList();

            string[] lines = StringUtils.split(response, StringUtils.CRLF);
            lines = StringUtils.trimArray(lines);
            ElectronMicroscopyReport rpt = null;
            string specimenName          = "";
            string exam         = "";
            string accessionNum = "";

            for (int i = 0; i < lines.Length; i++)
            {
                string[] flds   = StringUtils.split(lines[i], StringUtils.CARET);
                int      fldnum = Convert.ToInt32(flds[0]);
                switch (fldnum)
                {
                case 1:
                    if (rpt != null)
                    {
                        if (!String.IsNullOrEmpty(specimenName))
                        {
                            specimenName = specimenName.Substring(0, specimenName.Length - 1);
                            rpt.Specimen = new LabSpecimen("", specimenName, "", accessionNum);
                        }
                        if (!String.IsNullOrEmpty(exam))
                        {
                            exam     = exam.Substring(0, exam.Length - 1);
                            rpt.Exam = exam;
                        }
                        lst.Add(rpt);
                    }
                    rpt       = new ElectronMicroscopyReport();
                    rpt.Title = "Electron Microscopy Report";
                    if (flds.Length == 2)
                    {
                        string[] parts = StringUtils.split(flds[1], StringUtils.SEMICOLON);
                        if (parts.Length == 2)
                        {
                            rpt.Facility = new SiteId(parts[0], parts[1]);
                        }
                        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)
                    {
                        specimenName += flds[1] + '\n';
                    }
                    break;

                case 4:
                    if (flds.Length == 2)
                    {
                        accessionNum = flds[1];
                    }
                    break;

                case 5:
                    if (flds.Length == 2)
                    {
                        if (!String.IsNullOrEmpty(flds[1].TrimEnd()))
                        {
                            exam += flds[1] + '\n';
                        }
                    }
                    break;
                }
            }

            if (rpt != null)
            {
                if (!String.IsNullOrEmpty(specimenName))
                {
                    specimenName = specimenName.Substring(0, specimenName.Length - 1);
                    rpt.Specimen = new LabSpecimen("", specimenName, "", accessionNum);
                }
                if (!String.IsNullOrEmpty(exam))
                {
                    exam     = exam.Substring(0, exam.Length - 1);
                    rpt.Exam = exam;
                }
                lst.Add(rpt);
            }
            return((ElectronMicroscopyReport[])lst.ToArray(typeof(ElectronMicroscopyReport)));
        }
Esempio n. 12
0
 public static string getVisitString(Encounter encounter)
 {
     return(encounter.LocationId + ';' +
            VistaTimestamp.fromUtcString(encounter.Timestamp) + ';' +
            encounter.Type);
 }
        internal CytologyReport[] toCytologyReports(string response)
        {
            if (response == "")
            {
                return(null);
            }
            ArrayList lst = new ArrayList();

            string[] lines = StringUtils.split(response, StringUtils.CRLF);
            lines = StringUtils.trimArray(lines);
            CytologyReport rpt            = null;
            string         collectionDate = "";
            string         specimenDesc   = "";
            string         accessionNum   = "";

            for (int i = 0; i < lines.Length; i++)
            {
                string[] flds   = StringUtils.split(lines[i], StringUtils.CARET);
                int      fldnum = Convert.ToInt32(flds[0]);
                switch (fldnum)
                {
                case 1:
                    if (rpt != null)
                    {
                        rpt.Specimen = new LabSpecimen("", specimenDesc.Substring(0, specimenDesc.Length - 1), collectionDate, "");
                        rpt.Specimen.AccessionNumber = accessionNum;
                        lst.Add(rpt);
                    }
                    rpt          = new CytologyReport();
                    rpt.Title    = "Cytopathology Report";
                    specimenDesc = "";
                    if (flds.Length == 2)
                    {
                        string[] parts = StringUtils.split(flds[1], StringUtils.SEMICOLON);
                        if (parts.Length == 2)
                        {
                            rpt.Facility = new SiteId(parts[0], parts[1]);
                        }
                        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)
                    {
                        collectionDate = VistaTimestamp.toUtcFromRdv(flds[1]);
                    }
                    break;

                case 3:
                    if (flds.Length == 2)
                    {
                        specimenDesc += flds[1] + '\n';
                    }
                    break;

                case 4:
                    if (flds.Length == 2)
                    {
                        accessionNum = flds[1];
                    }
                    break;

                case 5:
                    if (flds.Length == 2)
                    {
                        rpt.Exam += flds[1] + '\n';
                    }
                    break;
                }
            }

            if (rpt != null)
            {
                rpt.Specimen = new LabSpecimen("", specimenDesc.Substring(0, specimenDesc.Length - 1), collectionDate, "");
                rpt.Specimen.AccessionNumber = accessionNum;
                lst.Add(rpt);
            }
            return((CytologyReport[])lst.ToArray(typeof(CytologyReport)));
        }
Esempio n. 14
0
        internal MicrobiologyReport[] toMicrobiologyReports(string response)
        {
            if (response == "")
            {
                return(null);
            }
            ArrayList lst = new ArrayList();

            string[] lines = StringUtils.split(response, StringUtils.CRLF);
            lines = StringUtils.trimArray(lines);
            MicrobiologyReport rpt = null;

            for (int i = 0; i < lines.Length; i++)
            {
                string[] flds   = StringUtils.split(lines[i], StringUtils.CARET);
                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)));
        }
Esempio n. 15
0
        internal VitalSign[] toLatestVitalSigns(string response)
        {
            if (!cxn.IsConnected)
            {
                throw new NotConnectedException();
            }

            if (response == "")
            {
                return(null);
            }
            string[]  lines    = StringUtils.split(response, StringUtils.CRLF);
            ArrayList lst      = new ArrayList(lines.Length);
            string    category = "Vital Signs";

            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i] == "")
                {
                    continue;
                }
                string[]        flds            = StringUtils.split(lines[i], StringUtils.CARET);
                ObservationType observationType = null;
                if (flds[1] == "T")
                {
                    observationType = new ObservationType(flds[0], category, "Temperature");
                }
                else if (flds[1] == "P")
                {
                    observationType = new ObservationType(flds[0], category, "Pulse");
                }
                else if (flds[1] == "R")
                {
                    observationType = new ObservationType(flds[0], category, "Respiration");
                }
                else if (flds[1] == "BP")
                {
                    observationType = new ObservationType(flds[0], category, "Blood Pressure");
                }
                else if (flds[1] == "HT")
                {
                    observationType = new ObservationType(flds[0], category, "Height");
                }
                else if (flds[1] == "WT")
                {
                    observationType = new ObservationType(flds[0], category, "Weight");
                }
                else if (flds[1] == "PN")
                {
                    observationType = new ObservationType(flds[0], category, "Pain");
                }
                if (observationType == null)
                {
                    continue;
                }
                VitalSign observation = new VitalSign();
                observation.Type   = observationType;
                observation.Value1 = flds[4];
                if (flds.Length == 6)
                {
                    observation.Value2 = flds[5];
                }
                observation.Timestamp = VistaTimestamp.toUtcString(flds[3]);
                lst.Add(observation);
            }
            return((VitalSign[])lst.ToArray(typeof(VitalSign)));
        }
Esempio n. 16
0
        internal AnatomicPathologyReport[] toAnatomicPathologyReports(string response)
        {
            if (response == "")
            {
                return(null);
            }
            ArrayList lst = new ArrayList();

            string[] lines = StringUtils.split(response, StringUtils.CRLF);
            lines = StringUtils.trimArray(lines);
            AnatomicPathologyReport rpt = null;

            for (int i = 0; i < lines.Length; i++)
            {
                string[] flds   = StringUtils.split(lines[i], StringUtils.CARET);
                int      fldnum = Convert.ToInt32(flds[0]);
                switch (fldnum)
                {
                case 1:
                    if (rpt != null)
                    {
                        lst.Add(rpt);
                    }
                    rpt       = new AnatomicPathologyReport();
                    rpt.Title = "Anatomic Pathology Report";
                    if (flds.Length == 2)
                    {
                        string[] parts = StringUtils.split(flds[1], StringUtils.SEMICOLON);
                        if (parts.Length == 2)
                        {
                            rpt.Facility = new SiteId(parts[0], parts[1]);
                        }
                        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.Specimen = new LabSpecimen("", flds[1], "", "");
                    }
                    break;

                case 4:     //[DP] 6/20/2011 Allow for the case with a null specimen.
                    if (flds.Length == 2 && rpt.Specimen != null)
                    {
                        rpt.Specimen.AccessionNumber = flds[1];
                    }
                    break;

                case 5:
                    if (flds.Length == 2)
                    {
                        if (!String.IsNullOrEmpty(flds[1].TrimEnd()))
                        {
                            rpt.Exam += flds[1] + '\n';
                        }
                    }
                    break;
                }
            }

            if (rpt != null)
            {
                lst.Add(rpt);
            }
            return((AnatomicPathologyReport[])lst.ToArray(typeof(AnatomicPathologyReport)));
        }
        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);
        }
        /*
         * In order to get the correct results with the correct reports using the DDR calls and RPCs
         * available, we are going to use the user specified fromDate but use today as the toDate (like
         * CPRS does) and retrieve all the specimens with in that time period. Then, we will find the
         * reports, match them up with their specimens and lastly filter those results using our original
         * date range
         */
        public ChemHemReport[] getChemHemReports(string dfn, string fromDate, string toDate)
        {
            if (!String.IsNullOrEmpty(toDate) && toDate.IndexOf(".") == -1)
            {
                toDate += ".235959";
            }

            IndexedHashtable specimens = getChemHemSpecimens(dfn, fromDate, toDate, "3");

            if (specimens == null || specimens.Count == 0)
            {
                return(null);
            }

            ArrayList lst = new ArrayList();
            //string nextDate = VistaTimestamp.fromUtcString(today);
            string nextDate = VistaTimestamp.fromUtcString(toDate);

            // Due to comment above, we want to loop through "ORWLRR INTERIMG" RPC until we
            // get as many reports as the DDR call above told us we would
            // TBD - this while statement screams infinite loop (i.e. what happens if we don't get all the
            // reports the DDR call above said we would?) Should we put an arbitrarily large stop in here?
            // e.g. if count > 1,000,000 then throw an exception that we didn't get what VistA said we should?
            int i = 0;

            while (lst.Count < specimens.Count)
            {
                LabSpecimen specimen = (LabSpecimen)specimens.GetValue(i);
                // ORWLRR INTERIMG rpc and function below updates nextDate for subsequent calls so LEAVE REF ALONE
                string        nextDateBefore = nextDate;
                ChemHemReport rpt            = getChemHemReport(dfn, ref nextDate);
                if (rpt != null)
                {
                    if ((rpt.Specimen != null) && (rpt.Specimen.AccessionNumber == specimen.AccessionNumber))
                    {
                        i++;
                        rpt.Id        = specimen.Id;
                        rpt.Facility  = specimen.Facility;
                        rpt.Specimen  = specimen;
                        rpt.Timestamp = specimen.ReportDate;
                        lst.Add(rpt);
                    }
                }
                // if the next date variable was not changed below, it means we are no longer looping through
                // the reports so we should go ahead and break out of this loop - should take care of
                // infinite loop concerns
                if (nextDate.Equals(nextDateBefore))
                {
                    break;
                }
            }
            // At last, filter the reports based on their timestamps
            ArrayList filteredList = new ArrayList();
            double    startDate    = Convert.ToDouble(fromDate);
            double    stopDate     = Convert.ToDouble(toDate);

            ChemHemReport[] rpts = (ChemHemReport[])lst.ToArray(typeof(ChemHemReport));
            foreach (ChemHemReport report in rpts)
            {
                // if the report doesn't have a timestamp, we will just add it to our list
                if (String.IsNullOrEmpty(report.Timestamp))
                {
                    filteredList.Add(report);
                    continue;
                }
                double reportTimeStamp = Convert.ToDouble(report.Timestamp);
                if (startDate <= reportTimeStamp && reportTimeStamp <= stopDate)
                {
                    filteredList.Add(report);
                }
            }
            return((ChemHemReport[])filteredList.ToArray(typeof(ChemHemReport)));
        }
Esempio n. 19
0
 public string GetDdrListerPart()
 {
     return(VistaTimestamp.fromDateTime(IterStartDate).Substring(0, _precision));
 }
Esempio n. 20
0
        internal RadiologyReport[] toRadiologyReports(string response)
        {
            if (response == "")
            {
                return(null);
            }
            string[]        lines = StringUtils.split(response, StringUtils.CRLF);
            ArrayList       lst   = new ArrayList();
            RadiologyReport rec   = null;

            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i] == "")
                {
                    continue;
                }
                string[] flds = StringUtils.split(lines[i], StringUtils.CARET);
                if (flds[1] == "[+]")
                {
                    lst.Add(rec);
                    continue;
                }
                int fldnum = Convert.ToInt32(flds[0]);
                switch (fldnum)
                {
                // TODO
                // need to consider the following case:
                //1^NH CAMP PENDLETON;NH CAMP PENDLETON <--- not a recognized site code, should add to site 200
                //2^05/24/2010 12:26
                //3^L-SPINE, SERIES (3)
                // lots more stuff in between
                //10^[+]
                case 1:
                    //if (rec != null)
                    //{
                    //    lst.Add(rec);
                    //}
                    rec = new RadiologyReport();
                    string[] parts = StringUtils.split(flds[1], StringUtils.SEMICOLON);
                    if (parts.Length == 2)
                    {
                        rec.Facility = new SiteId(parts[1], parts[0]);
                    }
                    else if (flds[1] != "")
                    {
                        rec.Facility = new SiteId(cxn.DataSource.SiteId.Id, flds[1]);
                    }
                    else
                    {
                        rec.Facility = cxn.DataSource.SiteId;
                    }
                    break;

                case 2:
                    if (flds.Length == 2)
                    {
                        rec.Timestamp = VistaTimestamp.toUtcFromRdv(flds[1]);
                    }
                    break;

                case 3:
                    if (flds.Length == 2)
                    {
                        rec.Title = flds[1];
                    }
                    break;

                case 4:
                    if (flds.Length == 2)
                    {
                        rec.Status = flds[1];
                    }
                    break;

                case 5:
                    if (flds.Length == 2)
                    {
                        rec.CaseNumber      = flds[1];
                        rec.AccessionNumber = rec.getAccessionNumber(rec.Timestamp, rec.CaseNumber, DateFormat.ISO);
                    }
                    break;

                case 6:
                    if (flds.Length == 2)
                    {
                        rec.Text += flds[1] + '\n';
                    }
                    break;
                    //case 7:
                    //    if (flds.Length == 2)
                    //    {
                    //        rec.Impression += flds[1] + '\n';
                    //    }
                    //    break;
                    //case 8:
                    //    if (flds.Length == 2)
                    //    {
                    //        rec.Text += flds[1] + '\n';
                    //    }
                    //    break;
                }
            }
            //if (rec != null)
            //{
            //    lst.Add(rec);
            //}

            return((RadiologyReport[])lst.ToArray(typeof(RadiologyReport)));
        }
Esempio n. 21
0
        internal VitalSignSet[] toVitalSignsFromRdv(string response)
        {
            if (response == "")
            {
                return(null);
            }
            string[] lines = StringUtils.split(response, StringUtils.CRLF);
            lines = StringUtils.trimArray(lines);
            ArrayList    lst = new ArrayList();
            VitalSignSet rec = null;
            VitalSign    s   = null;

            for (int i = 0; i < lines.Length; i++)
            {
                string[] flds   = StringUtils.split(lines[i], StringUtils.CARET);
                int      fldnum = Convert.ToInt16(flds[0]);
                switch (fldnum)
                {
                case 1:
                    if (rec != null)
                    {
                        lst.Add(rec);
                    }
                    rec = new VitalSignSet();
                    string[] subflds = StringUtils.split(flds[1], StringUtils.SEMICOLON);
                    if (subflds.Length == 1)
                    {
                        rec.Facility = new SiteId("200", subflds[0]);
                    }
                    else
                    {
                        rec.Facility = new SiteId(subflds[1], subflds[0]);
                    }
                    break;

                case 2:
                    if (flds.Length == 2)
                    {
                        rec.Timestamp = VistaTimestamp.toUtcFromRdv(flds[1]);
                    }
                    break;

                case 3:
                    s      = new VitalSign();
                    s.Type = new ObservationType("", VitalSign.VITAL_SIGN, VitalSign.TEMPERATURE);
                    if (flds.Length == 2)
                    {
                        s.Value1 = flds[1];
                    }
                    rec.addVitalSign(VitalSign.TEMPERATURE, s);
                    break;

                case 4:
                    s      = new VitalSign();
                    s.Type = new ObservationType("", VitalSign.VITAL_SIGN, VitalSign.PULSE);
                    if (flds.Length == 2)
                    {
                        s.Value1 = flds[1];
                    }
                    rec.addVitalSign(VitalSign.PULSE, s);
                    break;

                case 5:
                    s      = new VitalSign();
                    s.Type = new ObservationType("", VitalSign.VITAL_SIGN, VitalSign.RESPIRATION);
                    if (flds.Length == 2)
                    {
                        s.Value1 = flds[1];
                    }
                    rec.addVitalSign(VitalSign.RESPIRATION, s);
                    break;

                case 6:
                    s      = new VitalSign();
                    s.Type = new ObservationType("", VitalSign.VITAL_SIGN, VitalSign.BLOOD_PRESSURE);
                    if (flds.Length == 2)
                    {
                        s.Value1 = flds[1];
                    }
                    rec.addVitalSign(VitalSign.BLOOD_PRESSURE, s);
                    break;

                case 7:
                    s      = new VitalSign();
                    s.Type = new ObservationType("", VitalSign.VITAL_SIGN, VitalSign.HEIGHT);
                    if (flds.Length == 2)
                    {
                        s.Value1 = flds[1];
                    }
                    rec.addVitalSign(VitalSign.HEIGHT, s);
                    break;

                case 8:
                    s      = new VitalSign();
                    s.Type = new ObservationType("", VitalSign.VITAL_SIGN, VitalSign.WEIGHT);
                    if (flds.Length == 2)
                    {
                        s.Value1 = flds[1];
                    }
                    rec.addVitalSign(VitalSign.WEIGHT, s);
                    break;

                case 9:
                    s      = new VitalSign();
                    s.Type = new ObservationType("", VitalSign.VITAL_SIGN, VitalSign.PAIN);
                    if (flds.Length == 2)
                    {
                        s.Value1 = flds[1];
                    }
                    rec.addVitalSign(VitalSign.PAIN, s);
                    break;

                case 10:
                    s      = new VitalSign();
                    s.Type = new ObservationType("", VitalSign.VITAL_SIGN, VitalSign.PULSE_OXYMETRY);
                    if (flds.Length == 2)
                    {
                        s.Value1 = flds[1];
                    }
                    rec.addVitalSign(VitalSign.PULSE_OXYMETRY, s);
                    break;

                case 11:
                    s      = new VitalSign();
                    s.Type = new ObservationType("", VitalSign.VITAL_SIGN, VitalSign.CENTRAL_VENOUS_PRESSURE);
                    if (flds.Length == 2)
                    {
                        s.Value1 = flds[1];
                    }
                    rec.addVitalSign(VitalSign.CENTRAL_VENOUS_PRESSURE, s);
                    break;

                case 12:
                    s      = new VitalSign();
                    s.Type = new ObservationType("", VitalSign.VITAL_SIGN, VitalSign.CIRCUMFERENCE_GIRTH);
                    if (flds.Length == 2)
                    {
                        s.Value1 = flds[1];
                    }
                    rec.addVitalSign(VitalSign.CIRCUMFERENCE_GIRTH, s);
                    break;

                case 15:
                    if (flds.Length == 2)
                    {
                        setVitalSignQualifierStrings(rec, flds[1], "Qualifiers");
                        rec.Qualifiers = flds[1];
                    }
                    break;

                case 16:
                    s      = new VitalSign();
                    s.Type = new ObservationType("", VitalSign.VITAL_SIGN, VitalSign.BODY_MASS_INDEX);
                    if (flds.Length == 2)
                    {
                        s.Value1 = flds[1];
                    }
                    rec.addVitalSign(VitalSign.BODY_MASS_INDEX, s);
                    break;

                case 17:
                    if (flds.Length == 2)
                    {
                        setVitalSignQualifierStrings(rec, flds[1], "Units");
                        rec.Units = flds[1];
                    }
                    break;

                default:
                    break;
                }
            }
            lst.Add(rec);
            return((VitalSignSet[])lst.ToArray(typeof(VitalSignSet)));
        }
Esempio n. 22
0
        internal SurgicalPathologyReport[] toSurgicalPathologyReports(string response)
        {
            if (response == "")
            {
                return(null);
            }
            ArrayList lst = new ArrayList();

            string[] lines = StringUtils.split(response, StringUtils.CRLF);
            lines = StringUtils.trimArray(lines);
            SurgicalPathologyReport rpt = null;
            string specimenName         = "";
            string exam         = "";
            string accessionNum = "";

            IList <SurgicalPathologyReport> rpts   = new List <SurgicalPathologyReport>();
            SurgicalPathologyReport         newRpt = new SurgicalPathologyReport();

            for (int i = 0; i < lines.Length; i++)
            {
                string[] flds   = StringUtils.split(lines[i], StringUtils.CARET);
                int      fldnum = Convert.ToInt32(flds[0]);
                switch (fldnum)
                {
                case 1:
                    newRpt.Title = "Surgical Pathology Report";
                    if (rpt != null)
                    {
                        if (!String.IsNullOrEmpty(specimenName))
                        {
                            specimenName = specimenName.Substring(0, specimenName.Length - 1);
                            rpt.Specimen = new LabSpecimen("", specimenName, "", accessionNum);
                        }
                        if (!String.IsNullOrEmpty(exam))
                        {
                            exam     = exam.Substring(0, exam.Length - 1);
                            rpt.Exam = exam;
                        }
                        lst.Add(rpt);
                    }
                    rpt       = new SurgicalPathologyReport();
                    rpt.Title = "Surgical Pathology Report";
                    if (flds.Length == 2)
                    {
                        string[] parts = StringUtils.split(flds[1], StringUtils.SEMICOLON);
                        if (parts.Length == 2)
                        {
                            newRpt.Facility = new SiteId(parts[0], parts[1]);
                            rpt.Facility    = new SiteId(parts[0], parts[1]);
                        }
                        else if (flds[1] != "")
                        {
                            newRpt.Facility = new SiteId(cxn.DataSource.SiteId.Id, parts[1]);
                            rpt.Facility    = new SiteId(cxn.DataSource.SiteId.Id, flds[1]);
                        }
                        else
                        {
                            newRpt.Facility = cxn.DataSource.SiteId;
                            rpt.Facility    = cxn.DataSource.SiteId;
                        }
                    }
                    break;

                case 2:
                    if (flds.Length == 2)
                    {
                        newRpt.Timestamp = VistaTimestamp.toUtcFromRdv(flds[1]);
                        rpt.Timestamp    = VistaTimestamp.toUtcFromRdv(flds[1]);
                    }
                    break;

                case 3:
                    if (flds.Length == 2)
                    {
                        if (newRpt.Specimen == null)
                        {
                            newRpt.Specimen = new LabSpecimen("", "", "", "");
                        }
                        newRpt.Specimen.Name += flds[1] + '\n';
                        specimenName         += flds[1] + '\n';
                    }
                    break;

                case 4:
                    if (flds.Length == 2)
                    {
                        if (newRpt.Specimen == null)
                        {
                            newRpt.Specimen = new LabSpecimen("", "", "", "");
                        }
                        newRpt.Specimen.AccessionNumber = flds[1];
                        accessionNum = flds[1];
                    }
                    break;

                case 5:
                    if (flds.Length == 2)
                    {
                        if (!String.IsNullOrEmpty(flds[1].TrimEnd()))
                        {
                            newRpt.Exam += flds[1] + '\n';
                            exam        += flds[1] + '\n';
                        }
                    }
                    break;

                case 6:
                    if (newRpt.Specimen != null && !String.IsNullOrEmpty(newRpt.Specimen.Name))
                    {
                        newRpt.Specimen.Name = newRpt.Specimen.Name.TrimEnd(new char[] { '\n' });
                    }
                    if (!String.IsNullOrEmpty(newRpt.Exam))
                    {
                        newRpt.Exam = newRpt.Exam.TrimEnd(new char[] { '\n' });
                    }
                    rpts.Add(newRpt);
                    newRpt = new SurgicalPathologyReport();
                    break;
                }
            }

            if (rpt != null)
            {
                lst.Add(rpt);
            }

            SurgicalPathologyReport[] result = new SurgicalPathologyReport[rpts.Count];
            rpts.CopyTo(result, 0);
            return(result);
            //return (SurgicalPathologyReport[])lst.ToArray(typeof(SurgicalPathologyReport));
        }