/// <summary> /// Query message handler for the received Hl7 message - send a query response. /// </summary> /// <param name="hl7RequestMessage">Received HL7 message.</param> /// <returns>Hl7Message response.</returns> public override Hl7Message MessageHandler(Hl7Message hl7RequestMessage) { AdrMessage hl7ResponseMessage = new AdrMessage("A19"); if (hl7RequestMessage is QryMessage) { QryMessage qryMessage = (QryMessage)hl7RequestMessage; // Try to get the ADR message from those stored hl7ResponseMessage = GetMatchingResponse(qryMessage.QRD[8]); if (hl7ResponseMessage == null) { // return empty message hl7ResponseMessage = new AdrMessage("A19"); } // copy the QRD segment for (int i = 0; i < qryMessage.QRD.Count; i++) { hl7ResponseMessage.QRD[i] = qryMessage.QRD[i]; } } // fill in the MSA segment hl7ResponseMessage.MSA[1] = "AA"; hl7ResponseMessage.MSA[2] = hl7RequestMessage.MessageControlId; return hl7ResponseMessage; }
public void AddPatientQueryResponse(AdrMessage adrMessage) { // Generate response trigger Hl7Trigger trigger = new Hl7Trigger(TransactionNameEnum.RAD_UNKNOWN); trigger.Trigger = adrMessage; // Add a response trigger to the DssOrderFiller server AddResponseTriggerToActor(ActorTypeEnum.DssOrderFiller, trigger); }
/// <summary> /// Create a correctly typed HL7 message instance based on the incoming Hl7 message. /// </summary> /// <param name="inHl7Message">Incoming HL7 message.</param> /// <param name="messageDelimiters">HL7 message delimiters.</param> /// <returns>Correctly typed HL7 message instance.</returns> public static Hl7Message CreateHl7Message(Hl7Message inHl7Message, Hl7MessageDelimiters messageDelimiters) { Hl7SegmentId segmentId = new Hl7SegmentId(Hl7SegmentEnum.MSH); Hl7Segment mshSegment = (Hl7Segment)inHl7Message.Segments[segmentId.Id]; // can not determine what kind of message we have - so return the inHl7Message if (mshSegment == null) { return(inHl7Message); } System.String messageType = mshSegment[9]; Hl7Message hl7Message = null; // check for ACK message if (messageType == "ACK") { // now try to get the ORC segment segmentId = new Hl7SegmentId(Hl7SegmentEnum.ORC); Hl7Segment orcSegment = (Hl7Segment)inHl7Message.Segments[segmentId.Id]; if (orcSegment != null) { hl7Message = new OrrMessage(); } else { hl7Message = new AckMessage(); } } else { System.String [] messageTypeComponent = new System.String[3]; messageTypeComponent = messageType.Split(messageDelimiters.ComponentDelimiter[0]); System.String messageMainType = System.String.Empty; if (messageTypeComponent.Length > 0) { messageMainType = messageTypeComponent[0]; } switch (messageMainType) { case "ADR": // ADR message hl7Message = new AdrMessage(); break; case "ADT": // ADT message hl7Message = new AdtMessage(); break; case "ORM": // ORM message hl7Message = new OrmMessage(); break; case "ORU": // ORU message hl7Message = new OruMessage(); break; case "QRY": // QRY message hl7Message = new QryMessage(); break; default: // do not know what kind of HL7 message this is - simply return it return(inHl7Message); } } // add the segments from the inMessage to the new hl7Message ICollection segments = inHl7Message.Segments.Values; foreach (Hl7Segment segment in segments) { hl7Message.CopySegment(segment); } return(hl7Message); }
/// <summary> /// Create a correctly typed HL7 message instance based on the incoming Hl7 message. /// </summary> /// <param name="inHl7Message">Incoming HL7 message.</param> /// <param name="messageDelimiters">HL7 message delimiters.</param> /// <returns>Correctly typed HL7 message instance.</returns> public static Hl7Message CreateHl7Message(Hl7Message inHl7Message, Hl7MessageDelimiters messageDelimiters) { Hl7SegmentId segmentId = new Hl7SegmentId(Hl7SegmentEnum.MSH); Hl7Segment mshSegment = (Hl7Segment)inHl7Message.Segments[segmentId.Id]; // can not determine what kind of message we have - so return the inHl7Message if (mshSegment == null) { return inHl7Message; } System.String messageType = mshSegment[9]; Hl7Message hl7Message = null; // check for ACK message if (messageType == "ACK") { // now try to get the ORC segment segmentId = new Hl7SegmentId(Hl7SegmentEnum.ORC); Hl7Segment orcSegment = (Hl7Segment)inHl7Message.Segments[segmentId.Id]; if (orcSegment != null) { hl7Message = new OrrMessage(); } else { hl7Message = new AckMessage(); } } else { System.String []messageTypeComponent = new System.String[3]; messageTypeComponent = messageType.Split(messageDelimiters.ComponentDelimiter[0]); System.String messageMainType = System.String.Empty; if (messageTypeComponent.Length > 0) { messageMainType = messageTypeComponent[0]; } switch (messageMainType) { case "ADR" : // ADR message hl7Message = new AdrMessage(); break; case "ADT" : // ADT message hl7Message = new AdtMessage(); break; case "ORM" : // ORM message hl7Message = new OrmMessage(); break; case "ORU" : // ORU message hl7Message = new OruMessage(); break; case "QRY" : // QRY message hl7Message = new QryMessage(); break; default: // do not know what kind of HL7 message this is - simply return it return inHl7Message; } } // add the segments from the inMessage to the new hl7Message ICollection segments = inHl7Message.Segments.Values; foreach (Hl7Segment segment in segments) { hl7Message.CopySegment(segment); } return hl7Message; }