private static string getReportText(HL7Message hl7Message, bool noAddendum) { // the random chance someone overrides then puts false instead of true if (!noAddendum) { // do static function w/o override return(getReportText(hl7Message)); } // signal the end of capturing text bool endOfReport = false; string html = BLANK; string obxData = BLANK; string obxReportType = BLANK; string obxIteration = BLANK; 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) { // get the segment type string segmentType = segment.fields[ZERO_ELEMENT].value; try { obxData = segment.fields[REPORT_TEXT_ELEMENT].value; obxReportType = segment.fields[REPORT_TYPE_ELEMENT].value; obxIteration = segment.fields[REPORT_ITERATION_ELEMENT].value; // if we find addendum pattern, we then stop if (obxReportType == ADDENDUM && obxIteration != ORIGINAL_REPORT_ITERATION) { endOfReport = true; } if (!endOfReport) { 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, "getReportText(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 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); }