Exemplo n.º 1
0
        public RadiologyReportsResult GetReports(string dfn)
        {
            RadiologyReportsResult result = new RadiologyReportsResult();

            if (this.broker != null)
            {
                OrwrpReportTextCommand command = new OrwrpReportTextCommand(this.broker);

                command.AddCommandArguments(dfn);

                RpcResponse response = command.Execute();

                result.SetResult(response.Status == RpcResponseStatus.Success, response.InformationalMessage);

                if (result.Success)
                {
                    if (command.ReportList != null)
                    {
                        foreach (OrwrpReport orwrpReport in command.ReportList)
                        {
                            RadiologyReport report = GetRadiologyReport(orwrpReport);

                            result.Items.Add(report);
                        }
                    }
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public RadiologyReportTO(RadiologyReport mdo)
        {
            if (null == mdo)
            {
                return;
            }

            this.id        = mdo.Id;
            this.title     = mdo.Title;
            this.timestamp = mdo.Timestamp;
            if (mdo.Author != null)
            {
                this.author = new AuthorTO(mdo.Author);
            }
            this.text = mdo.Text;
            if (mdo.Facility != null)
            {
                this.facility = new TaggedText(mdo.Facility.Id, mdo.Facility.Name);
            }
            this.status          = mdo.Status;
            this.cptCode         = mdo.CptCode;
            this.clinicalHx      = mdo.ClinicalHx;
            this.impression      = mdo.Impression;
            this.accessionNumber = mdo.AccessionNumber;
            this.caseNumber      = mdo.CaseNumber;
        }
 public TaggedRadiologyReportArray(string tag, RadiologyReport mdo)
 {
     this.tag = tag;
     if (mdo == null)
     {
         this.count = 0;
         return;
     }
     this.rpts    = new RadiologyReportTO[1];
     this.rpts[0] = new RadiologyReportTO(mdo);
     this.count   = 1;
 }
Exemplo n.º 4
0
        private RadiologyReport GetRadiologyReport(OrwrpReport orwrpReport)
        {
            RadiologyReport returnReport = new RadiologyReport()
            {
                Location        = orwrpReport.Location,
                Procedure       = orwrpReport.Procedure,
                ReportStatus    = orwrpReport.ReportStatus,
                CptCode         = orwrpReport.CptCode,
                ReasonForStudy  = orwrpReport.ReasonForStudy,
                ClinicalHistory = orwrpReport.ClinicalHistory,
                Impression      = orwrpReport.Impression,
                ReportText      = orwrpReport.ReportText
            };

            returnReport.ExamDateTime = VistaDates.ParseDateString(orwrpReport.ExamDateTime, VistaDates.VistADateFormatFive);

            return(returnReport);
        }
Exemplo n.º 5
0
        internal Dictionary <string, RadiologyReport> toImagingExamIds(string response)
        {
            if (String.IsNullOrEmpty(response))
            {
                return(null);
            }
            Dictionary <string, RadiologyReport> result = new Dictionary <string, RadiologyReport>();

            string[] rex = StringUtils.split(response, StringUtils.CRLF);
            rex = StringUtils.trimArray(rex);
            for (int i = 0; i < rex.Length; i++)
            {
                RadiologyReport newReport = new RadiologyReport();
                string[]        flds      = StringUtils.split(rex[i], StringUtils.CARET);
                newReport.AccessionNumber = newReport.getAccessionNumber(flds[2], flds[4], DateFormat.VISTA);
                newReport.Id          = flds[1];
                newReport.Timestamp   = flds[2];
                newReport.Title       = flds[3];
                newReport.CaseNumber  = flds[4];
                newReport.Status      = flds[5];
                newReport.Exam        = new ImagingExam();
                newReport.Exam.Status = (flds[8].Split(new char[] { '~' }))[1]; // e.g. 9~COMPLETE
                // maybe map some more fields? lot's of stuff being returned by RPC. For example:
                //ANN ARBOR VAMC;506
                //^6899085.8548-1
                //^3100914.1451
                //^TIBIA & FIBULA 2 VIEWS
                //^794
                //^Verified
                //^
                //^878633
                //^9~COMPLETE
                //^AA RADIOLOGY,AA
                //^RAD~GENERAL RADIOLOGY
                //^
                //^73590
                //^20323714
                //^N
                //^
                //^
                result.Add(newReport.AccessionNumber, newReport);
            }
            return(result);
        }
Exemplo n.º 6
0
        public RadiologyReportTO getImagingReport(string ssn, string accessionNumber)
        {
            RadiologyReportTO result = new RadiologyReportTO();

            if (!mySession.ConnectionSet.IsAuthorized)
            {
                result.fault = new FaultTO("Connections not ready for operation", "Need to login?");
            }
            else if (String.IsNullOrEmpty(ssn))
            {
                result.fault = new FaultTO("Missing SSN");
            }
            else if (String.IsNullOrEmpty(accessionNumber))
            {
                result.fault = new FaultTO("Missing Accession Number");
            }
            if (result.fault != null)
            {
                return(result);
            }

            try
            {
                PatientApi patientApi = new PatientApi();
                Patient[]  matches    = patientApi.match(mySession.ConnectionSet.BaseConnection, ssn);

                if (matches == null || matches.Length != 1)
                {
                    result.fault = new FaultTO("More than one patient has that SSN in this site (" +
                                               mySession.ConnectionSet.BaseConnection.DataSource.SiteId.Id + ")");
                    return(result);
                }
                RadiologyReport report = ImagingExam.getReportText(mySession.ConnectionSet.BaseConnection, matches[0].LocalPid, accessionNumber);

                result = new RadiologyReportTO(report);
            }
            catch (Exception e)
            {
                result.fault = new FaultTO(e);
            }

            return(result);
        }
Exemplo n.º 7
0
        internal RadiologyReport buildRadiologyReport(IDataReader reader)
        {
            SiteId facility = new SiteId()
            {
                Id = DbReaderUtil.getValue(reader, reader.GetOrdinal("station__no"))
            };

            RadiologyReport report = new RadiologyReport()
            {
                Facility   = facility,
                Id         = DbReaderUtil.getValue(reader, reader.GetOrdinal("id")),
                Impression = DbReaderUtil.getValue(reader, reader.GetOrdinal("impressiontextwp")),
                Status     = DbReaderUtil.getValue(reader, reader.GetOrdinal("report_status")),
                Text       = DbReaderUtil.getValue(reader, reader.GetOrdinal("reporttextwp")),
                Title      = DbReaderUtil.getValue(reader, reader.GetOrdinal("procedure102")),
                Timestamp  = DbReaderUtil.getDateTimeValue(reader, reader.GetOrdinal("dt")),
                CaseNumber = DbReaderUtil.getValue(reader, reader.GetOrdinal("caseNumber"))
            };

            return(report);
        }
Exemplo n.º 8
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));
        }
Exemplo n.º 9
0
 internal Dictionary<string, RadiologyReport> toImagingExamIds(string response)
 {
     if (String.IsNullOrEmpty(response))
     {
         return null;
     }
     Dictionary<string, RadiologyReport> result = new Dictionary<string, RadiologyReport>();
     string[] rex = StringUtils.split(response, StringUtils.CRLF);
     rex = StringUtils.trimArray(rex);
     for (int i = 0; i < rex.Length; i++)
     {
         RadiologyReport newReport = new RadiologyReport();
         string[] flds = StringUtils.split(rex[i], StringUtils.CARET);
         newReport.AccessionNumber = newReport.getAccessionNumber(flds[2], flds[4], DateFormat.VISTA);
         newReport.Id = flds[1];
         newReport.Timestamp = flds[2];
         newReport.Title = flds[3];
         newReport.CaseNumber = flds[4];
         newReport.Status = flds[5];
         newReport.Exam = new ImagingExam();
         newReport.Exam.Status = (flds[8].Split(new char[] { '~' }))[1]; // e.g. 9~COMPLETE
         // maybe map some more fields? lot's of stuff being returned by RPC. For example:
         //ANN ARBOR VAMC;506
         //^6899085.8548-1
         //^3100914.1451
         //^TIBIA & FIBULA 2 VIEWS
         //^794
         //^Verified
         //^
         //^878633
         //^9~COMPLETE
         //^AA RADIOLOGY,AA
         //^RAD~GENERAL RADIOLOGY
         //^
         //^73590
         //^20323714
         //^N
         //^
         //^
         result.Add(newReport.AccessionNumber, newReport);
     }
     return result;
 }
Exemplo n.º 10
0
 public RadiologyReport toRadiologyReport(RadiologyReport report, string reportText)
 {
     report.Text = reportText;
     return report;
 }
Exemplo n.º 11
0
        public CdaSourceResult GetSource(CdaOptions options)
        {
            // *** Collect the source data in a source object ***

            CdaSourceResult returnVal = new CdaSourceResult();

            // *** Create new document id ***
            returnVal.Source.DocumentId = Guid.NewGuid().ToString("B");

            // *** Get CDA settings ***
            CdaSettingsResult result = this.dashboardRepository.Settings.GetCdaSettings();

            // *** Add results to return ***
            returnVal.Success = result.Success;
            returnVal.Message = result.Message;

            if (result.Success)
            {
                // *** Add CDA settings to return ***
                returnVal.Source.ManufacturerModelName     = result.ManufacturerModelName;
                returnVal.Source.SoftwareName              = result.SoftwareName;
                returnVal.Source.ProviderOrganizationPhone = result.ProviderOrganizationPhone;

                //// *** Get the VPR data ***
                //VprOperationResult vprResult = this.dashboardRepository.Vpr.GetVprData(options);

                //// *** Add results to return ***
                //returnVal.Success = vprResult.Success;
                //returnVal.Message = vprResult.Message;

                //// *** Add vpr data to return ***
                //if (result.Success)
                //    returnVal.Source.VprData = vprResult.VprData;

                // *** Add options to return ***
                returnVal.Source.Options = options;

                // *** Add pregnancies ***
                string pregIen = (options.DocumentType == CDA.IheDocumentType.PPVS) ? options.SelectedItemIen : "";

                PregnancyListResult pregResult = this.dashboardRepository.Pregnancy.GetPregnancies(options.Patient.Dfn, pregIen);

                if (pregResult.Success)
                {
                    returnVal.Source.Pregnancies = pregResult.Pregnancies;
                }
                else
                {
                    returnVal.SetResult(false, pregResult.Message);
                }

                // *** Add pregnancy status ***
                PatientDemographicsResult patResult = this.dashboardRepository.Patients.GetPatientDemographics(options.Patient.Dfn);

                if (patResult.Success)
                {
                    returnVal.Source.Patient = patResult.Patient;
                }
                else if (returnVal.Success)
                {
                    returnVal.SetResult(false, patResult.Message);
                }

                // *** Get Observations By Date Range ***

                string tiuIen   = "";
                string fromDate = "";
                string toDate   = "";

                if (options.DocumentType == CDA.IheDocumentType.PPVS)
                {
                    // TODO: Add date range when working...

                    // *** Translate a pregnancy into a date range ***
                    // *** The date range should include the postpartum period ***
                    //options.SelectedDateRange = CdaOptions.DateRange.Custom;
                    //options.FromDate = returnVal.Source.Pregnancies[0].EndDate.AddDays(-1);
                    //TimeSpan ts = DateTime.Now - options.FromDate;

                    //if (ts.TotalDays > 60)
                    //    options.ToDate = options.FromDate.AddDays(42);
                    //else
                    //    options.ToDate = DateTime.Now.AddDays(1);

                    //toDate = options.ToDate.ToString(VistaDates.VistADateOnlyFormat);
                    //fromDate = options.FromDate.ToString(VistaDates.VistADateOnlyFormat);

                    // TODO: Clear pregIen ?
                    //pregIen = "";
                }
                else if (options.SelectedItemIen == "-1")
                {
                    tiuIen = "";
                    if (options.FromDate != DateTime.MinValue)
                    {
                        fromDate = options.FromDate.ToString(VistaDates.VistADateOnlyFormat);
                    }

                    if (options.ToDate != DateTime.MinValue)
                    {
                        toDate = options.ToDate.ToString(VistaDates.VistADateOnlyFormat);
                    }
                }
                else
                {
                    tiuIen = options.SelectedItemIen;
                }

                ObservationListResult observationsResult = this.dashboardRepository.Observations.GetObservations(options.Patient.Dfn, pregIen, "", tiuIen, fromDate, toDate, "", -1, -1);

                if (observationsResult.Success)
                {
                    returnVal.Source.Observations = observationsResult.Observations;

                    // *** For PPVS remove observations which belong to pregnancies other than the one chosen by the user ***
                    if (options.DocumentType == CDA.IheDocumentType.PPVS)
                    {
                        returnVal.Source.Observations = returnVal.Source.Observations
                                                        .Where(o => o.PregnancyIen == "" || o.PregnancyIen == options.SelectedItemIen)
                                                        .ToList();
                    }
                }

                // *** Get the VPR data ***
                VprOperationResult vprResult = this.dashboardRepository.Vpr.GetVprData(options);

                // *** Add results to return ***
                returnVal.Success = vprResult.Success;
                returnVal.Message = vprResult.Message;

                // *** Add vpr data to return ***
                if (result.Success)
                {
                    returnVal.Source.VprData = vprResult.VprData;
                }

                ValueSetType[] valueSets = null;

                if (options.DocumentType == CDA.IheDocumentType.APHP)
                {
                    // *** Get Value Sets Needed for APHP ***
                    valueSets = new ValueSetType[]
                    {
                        ValueSetType.AntepartumEducation,
                        ValueSetType.HistoryOfInfection,
                        ValueSetType.HistoryOfPastIllness,
                        ValueSetType.AntepartumFamilyHistory,
                        ValueSetType.MenstrualHistory
                    };
                }
                else if (options.DocumentType == CDA.IheDocumentType.APE)
                {
                    valueSets = new ValueSetType[] { ValueSetType.AntepartumEducation };

                    returnVal.Source.EducationItems = this.GetEducationItems(options.Patient.Dfn, options.FromDate, options.ToDate);
                }

                if (valueSets != null)
                {
                    foreach (var valueSetType in valueSets)
                    {
                        CdaValueSetResult vsResult = this.dashboardRepository.CdaDocuments.GetValueSet(valueSetType);
                        if (vsResult.Success)
                        {
                            returnVal.Source.ValueSets.Add(valueSetType, vsResult.ValueSet);
                        }
                    }
                }

                if (options.DocumentType == CDA.IheDocumentType.XDR_I)
                {
                    // *** Get Radiology Reports ***
                    RadiologyReportsResult radResult = this.dashboardRepository.Radiology.GetReports(options.Patient.Dfn);

                    if (radResult.Success)
                    {
                        if (radResult.Items.Count > 0)
                        {
                            string   tempDate = Util.Piece(options.SelectedItemIen, "|", 1);
                            string   tempProc = Util.Piece(options.SelectedItemIen, "|", 2);
                            DateTime selected;
                            if (DateTime.TryParse(tempDate, out selected))
                            {
                                RadiologyReport rpt = radResult.Items.FirstOrDefault(r => r.ExamDateTime == selected && r.Procedure == tempProc);

                                returnVal.Source.ImageReportText = rpt.Detail;
                            }
                        }
                    }
                }
            }

            return(returnVal);
        }
Exemplo n.º 12
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)));
        }
Exemplo n.º 13
0
 public RadiologyReport toRadiologyReport(RadiologyReport report, string reportText)
 {
     report.Text = reportText;
     return(report);
 }