public static MessageType getMessageType(HL7Message message, string hl7Input) { if (hl7Input == BLANK) { throw new ArgumentException(ERROR_NO_MESSAGE_TYPE); } Dictionary <string, MessageType> messageTypeDictionary = new Dictionary <string, MessageType>() { { MESSAGE_TYPE_ADT, MessageType.ADT }, { MESSAGE_TYPE_ORM, MessageType.ORM }, { MESSAGE_TYPE_ORU, MessageType.ORU }, { MESSAGE_TYPE_SIU, MessageType.SIU }, { MESSAGE_TYPE_UNK, MessageType.UNKNOWN } }; // get the message type based on the configuration value MessageType result; messageTypeDictionary.TryGetValue(HL7MessageUtility.getValueByPosition(message, SegmentType.MSH, MESSAGE_TYPE_POSITION), out result); // based on the configuration file, we'll return the message type return(result); }
private static string getHL7ValueSEL(HL7Message message, List <MessageGroupInstance> messageGroupInstances, List <MessageGroup> messageGroups, WebservicePropertySet wsProperty ) { // get the ms groups List <MessageGroup> msGroups = ConfigurationUtility.GetIncomingWebserviceMessageGroup(wsProperty, messageGroups); // get segment string type MessageGroupInstance messageGroupInstance = messageGroupInstances.Find(i => i.id == msGroups[ZERO].messageGroupInstanceId); // get the message position for this specific column List <Configuration> configMessagePoisition = ConfigurationDAO.GetMessagePosition(messageGroupInstance); // get the coordinates for the message item string messageCoordinates = HL7MessageUtility.getItemCoordinates(configMessagePoisition); // get segment string type string segmentType = configMessagePoisition[ZERO_ELEMENT].segmentType.name; // get the value for the database inside of the value position string hl7Value = HL7MessageUtility.getValueByPosition( message, HL7MessageUtility.getSegmentType(segmentType), messageCoordinates); return(hl7Value); }
public static List <T> Parse <T>(string input, char delimiter, List <T> dataSet, T data) { List <string> delimiterResult = HL7MessageUtility.getDelimitedData(input, delimiter); for (int inputIndex = ZERO, delimiterLen = delimiterResult.Count; inputIndex < delimiterLen; inputIndex++) { // get the data set alone } return(dataSet); }
private static string getReportText(HL7Message hl7Message) { string html = BLANK; string obxData = 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; 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); }
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); }