public static void handleProcessingForORU(List <WebserviceObject> wsObjects, List <WebservicePropertySet> webserviceProperties, HL7Message hl7Message, List <MessageGroupInstance> messageGroupInstances, List <MessageGroup> messageGroups, Application app, Message message) { string serviceMessage = BLANK; // make SEL exam object WSShieldsApps.Exam exam = new WSShieldsApps.Exam(); WSShieldsApps.Location location = new WSShieldsApps.Location(); WSShieldsApps.Patient patient = new WSShieldsApps.Patient(); WSShieldsApps.Organization organization = new WSShieldsApps.Organization(); WSShieldsApps.Doctor referring = new WSShieldsApps.Doctor(); // make SEL report object WSShieldsApps.Report report = new WSShieldsApps.Report(); WSShieldsApps.Doctor radiologist = new WSShieldsApps.Doctor(); // for each object - for each property set for that object - handle accordingly wsObjects.ForEach(delegate(WebserviceObject wsObject) { List <WebservicePropertySet> wsProperties = ConfigurationUtility.GetIncomingWebservicePropertySets(wsObject, webserviceProperties); if (app.name == RSERVER) { if (ShieldsExpressLinkDAO.LOCATION == wsObject.name) { location = ShieldsExpressLinkUtility.getShieldsAppObject <WSShieldsApps.Location>( ShieldsExpressLinkUtility.ObjectType.Location, hl7Message, messageGroupInstances, messageGroups, wsProperties); } else if (ShieldsExpressLinkDAO.PATIENT == wsObject.name) { patient = ShieldsExpressLinkUtility.getShieldsAppObject <WSShieldsApps.Patient>( ShieldsExpressLinkUtility.ObjectType.Patient, hl7Message, messageGroupInstances, messageGroups, wsProperties); } else if (ShieldsExpressLinkDAO.ORGANIZATION == wsObject.name) { organization = ShieldsExpressLinkUtility.getShieldsAppObject <WSShieldsApps.Organization>( ShieldsExpressLinkUtility.ObjectType.Organization, hl7Message, messageGroupInstances, messageGroups, wsProperties); } else if (ShieldsExpressLinkDAO.EXAM == wsObject.name) { exam = ShieldsExpressLinkUtility.getShieldsAppObject <WSShieldsApps.Exam>( ShieldsExpressLinkUtility.ObjectType.Exam, hl7Message, messageGroupInstances, messageGroups, wsProperties); } else if (ShieldsExpressLinkDAO.REFERRING == wsObject.name) { referring = ShieldsExpressLinkUtility.getShieldsAppObject <WSShieldsApps.Doctor>( ShieldsExpressLinkUtility.ObjectType.Referring, hl7Message, messageGroupInstances, messageGroups, wsProperties); } else if (ShieldsExpressLinkDAO.REPORT == wsObject.name) { report = ShieldsExpressLinkUtility.getShieldsAppObject <WSShieldsApps.Report>( ShieldsExpressLinkUtility.ObjectType.Report, hl7Message, messageGroupInstances, messageGroups, wsProperties); } else if (ShieldsExpressLinkDAO.RADIOLOGIST == wsObject.name) { radiologist = ShieldsExpressLinkUtility.getShieldsAppObject <WSShieldsApps.Doctor>( ShieldsExpressLinkUtility.ObjectType.Radiologist, hl7Message, messageGroupInstances, messageGroups, wsProperties); // set as radiologist radiologist.Type = RADIOLOGIST_TYPE; radiologist.EnterpriseId = ENTERPRISE_IDENTITY; } } }); // set exam object exam.Location = location; exam.Doctor = referring; exam.Organization = organization; exam.Patient = patient; // make a new exam object WSShieldsApps.Exam exam2Object = new WSShieldsApps.Exam(); // pass the accession so we don't override exam2Object.AccessionNo = exam.AccessionNo; // get the updated exam id only exam.ExamId = ShieldsExpressLinkDAO.GetExamByAccessionNo(exam2Object).ExamId; // handle radiologist serviceMessage += ShieldsExpressLinkDAO.PutDoctor(radiologist); // handle exam serviceMessage += ShieldsExpressLinkDAO.PutExam(exam); // report needs exam id associated to it report.ExamId = exam.ExamId; // report needs radiologist id associated to it report.RadiologistId = radiologist.DoctorId; // handle orignal report serviceMessage += ShieldsExpressLinkDAO.PostReport(report); // handle addendum text only if (ShieldsExpressLinkUtility.isReportAddendum(hl7Message)) { // for each report text starting at "2" (1 == orignal report) get all addendums after for (int reportIteration = 2, n = ShieldsExpressLinkUtility.getNumberOfReportEntries(hl7Message); reportIteration <= n; reportIteration++) { // set the addendum flag report.IsAddendum = true; // re-define report text and observation date report.ReportText = ShieldsExpressLinkUtility.getAddendumReportText(hl7Message, report, reportIteration); // handle inserting of addendum report serviceMessage += ShieldsExpressLinkDAO.PostReport(report, reportIteration); } } // message for the service handleAckForService(hl7Message, message, serviceMessage); // message log handler handleMessageLog(message); }
public static string getAddendumReportText(HL7Message hl7Message, WSShieldsApps.Report report, int addendumId) { bool readAddendumText = false; string html = BLANK; string obxData = BLANK; int addendumPosition = ZERO; List <Segment> segments = new List <Segment>(); List <String> reportText = new List <String>(); // only return obx segment types segments = hl7Message.segments.FindAll(s => s.fields[ZERO_ELEMENT].value == SEGMENT_TYPE_OBX); // for each of those obx segments, process report segments.ForEach(delegate(Segment segment) { try { obxData = segment.fields[REPORT_TEXT_ELEMENT].value; addendumPosition = Convert.ToInt32(segment.fields[REPORT_ITERATION_ELEMENT].value); if (Regex.IsMatch(obxData, ADDENDUM_PATTERN_MATCH_BEGIN)) { if (addendumPosition == addendumId) { // override the addendum report obx date var addendumObservationDate = segment.fields[REPORT_OBX_DTTM].components[FIRST_ELEMENT].value; // set the obx date report.ObservationDate = hl7DateToRealDateTime(addendumObservationDate); // update the addendum text flag to true readAddendumText = true; } } else if (Regex.IsMatch(obxData, ADDENDUM_PATTERN_MATCH_END)) { readAddendumText = false; // still add the end text reportText.Add(obxData); } // if we read, we add to the list of text if (readAddendumText) { reportText.Add(obxData); } } catch (Exception ex) { // get the message control id to notify user of error string messageControlId = HL7MessageUtility.getValueByPosition(hl7Message, SegmentType.MSH, MESSAGE_HEADER_CONTROL_ID); // make a note about it obxData = "Report Segment Cutoff, please resend report, message control id:" + messageControlId; // log error ErrorLogger.LogError(ex, "getAddendumReportText(HL7Message hl7Message)", obxData); // add report text reportText.Add(obxData); } }); html += REPORT_HTML_HEADER; html += String.Join(HTML_LINE_BREAK, reportText.ToArray()); html += REPORT_HTML_FOOTER; return(html); }
public static T getShieldsAppObject <T>(ObjectType type, HL7Message message, List <MessageGroupInstance> messageGroupInstances, List <MessageGroup> messageGroups, List <WebservicePropertySet> wsPropertySet) { Object shieldsAppObject = new Object(); WSShieldsApps.Exam exam = new WSShieldsApps.Exam(); WSShieldsApps.Location location = new WSShieldsApps.Location(); WSShieldsApps.Patient patient = new WSShieldsApps.Patient(); WSShieldsApps.Organization organization = new WSShieldsApps.Organization(); WSShieldsApps.Report report = new WSShieldsApps.Report(); WSShieldsApps.Doctor referring = new WSShieldsApps.Doctor(); WSShieldsApps.Doctor radiologist = new WSShieldsApps.Doctor(); // for each property, get the hl7 position - then get the value for it wsPropertySet.ForEach(delegate(WebservicePropertySet wsProperty) { // cleaner way to get the value that ca be used by all methods here string hl7Value = ShieldsExpressLinkUtility.getHL7ValueSEL(message, messageGroupInstances, messageGroups, wsProperty); switch (type) { case ObjectType.Location: location = getLocation(wsProperty, hl7Value, location); shieldsAppObject = location; break; case ObjectType.Patient: patient = getPatient(wsProperty, hl7Value, patient); shieldsAppObject = patient; break; case ObjectType.Organization: organization = getOrganization(wsProperty, hl7Value, organization); shieldsAppObject = organization; break; case ObjectType.Exam: exam = getExam(wsProperty, hl7Value, exam); shieldsAppObject = exam; break; case ObjectType.Report: report = getReport(wsProperty, message, hl7Value, report); report.ReportText = getReportText(message, true); shieldsAppObject = report; break; case ObjectType.Referring: referring = getReferringDoctor(wsProperty, hl7Value, referring); shieldsAppObject = referring; break; case ObjectType.Radiologist: radiologist = getReadingDoctor(wsProperty, hl7Value, radiologist); shieldsAppObject = radiologist; break; default: break; } }); return((T)shieldsAppObject); }
private static WSShieldsApps.Report getReport(WebservicePropertySet wsProperty, HL7Message message, string hl7Value, WSShieldsApps.Report report) { switch (wsProperty.name) { case ShieldsExpressLinkDAO.PROPERTY_REPORT_OBSERVATION_DATE: report.ObservationDate = hl7DateToRealDateTime(hl7Value); break; default: break; } return(report); }