Question
· Mar 15, 2018

Making content of Request and Response messages viewable in Ensemble

I have created a fairly simple process for taking a HL7 message and sending it to an external provider via a HTTP Post and this is all working correctly. However for the request and response messages I am using e a simple structure containing only a message stream and when looking in Ensemble Message viewer none of this stream content is showing (it is all blank). Would I have to create a particular message type to make this show in message viewer and if so could someone provide some guidance around how to achieve this (outline of code included below)

Read message to Stream and forward:

Method OnRequest(tRequest As EnsLib.HL7.Message, Output tResponse As Ens.Response) As %Status
{
    SET postmessage = ##class(UPR.Request.OutboundPost).%New()
    SET postmessage.MessageStream = ##class(%GlobalCharacterStream).%New()  
    SET tStatus = tRequest.OutputToLibraryStream(postmessage.MessageStream)
      SET sndStatus = $$$OK
      SET sndStatus = ..SendRequestAsync("UPR Web Send",postmessage)
      $$$LOGINFO("sndStatus = "_sndStatus)
      quit sndStatus
}

Operation to Post Message:

Parameter ADAPTER = "EnsLib.HTTP.OutboundAdapter";
Parameter INVOCATION = "Queue";

Method PostMessage(pRequest As UPR.Request.OutboundPost, Output pResponse As UPR.Response.OutboundPost) As %Status
{
  Set $ZT="Trap",tSC=$$$OK
  do { 
     Do pRequest.MessageStream.Rewind()
     set input = pRequest.MessageStream
     set hResponse = ##class(%Net.HttpResponse).%New()
     set hSC = ..Adapter.Post(.hResponse,,input)
     set pResponse = ##class(UPR.Response.OutboundPost).%New()
     set len = hResponse.Data.SizeGet()
     While (hResponse.Data.AtEnd = 0) {
        do pResponse.MessageStream.Write(hResponse.Data.Read())
        }
     Quit
     } while (0)
Exit
  Quit hSC
Trap
  Set $ZT="",hSC=$$$EnsSystemError
  Goto Exit
}

Request and Response Messages:

Class UPR.Request.OutboundPost Extends Ens.Request
{
Property MessageStream As %GlobalCharacterStream(CONTENT = "MIXED");
}
Class UPR.Response.OutboundPost Extends Ens.Response
{
Property MessageStream As %GlobalCharacterStream(CONTENT = "MIXED");
}
Discussion (2)1
Log in or sign up to continue

Hi James,

Why do you need to convert the HL7 message to a stream at all?  You can use EnsLib.HL7.Operation.HTTPOperation, which expects a message of type EnsLib.HL7.Message, and handle the conversion and HTTP POST for you. Then you can apply HL7 routing rules and transformations in your production, and see the HL7 parsed out with the appropriate schema overlaid in the message trace.

Steve