Question
· Feb 8, 2019

Studio Terminal Testing Custom Method

Hello ,

I have a class Method  ClassMethod SearchOBXFlag(pSourceMsg As EnsLib.HL7.Message, Identifier As %String) As %String

How can i test this method from terminal or from portal or studio.  In Terminal i am not able to pass a HL7 message to the method since it terminates after segment terminator. It should be great if i can pass a local file with the hl7 message to the function instead.

Any help will be appreciated how to pass a hl7 message to this function inorder to test.

Thanks

Jimmy Christian.

Discussion (6)1
Log in or sign up to continue

The easiest way is to use an existing message that's already in the Ensemble message store. Locate the MessageBodyId value in the header tab of the message viewer, and execute the following commands in the same namespace as the production:

JEFF > Set tMsg = ##class(EnsLib.HL7.Message).%OpenId(BodyID)

JEFF > Write ##class(Package.Name).MethodName(tMsg,"Identifier") 

Substitute the numeric Message Body ID for BodyID, the package name for your class for Package.Name, the method for MethodName and the identifier you want to test with for Identifier. The method you mentioned appears to return a string, so you should see the value displayed once you press enter on the 2nd command.

That seems very interesting. I wasn't aware of such method to import file or refer to a message in the file. Pretty interesting !

Will test this out today and post . Just something i noticed is we have assigned the datatype  to  messages in tMsg object, which is after the fact of referring it to a filename.ext. So in this case if the  message does not match schema/doctype  , below command would fail.

JEFF > set tMsg.DocType="2.3.1:ORU_R01"

Correct?

If the message you wish to test is saved in a separate file outside of Ensemble, you can create a new message object with the following:

JEFF > set tMsg=##class(EnsLib.HL7.Message).ImportFromFile("/path/to/file/filename.ext")

You'll need to set the DocType manually; for messages already received by Ensemble, that was likely taken care of by the business service:

JEFF > set tMsg.DocType="2.3.1:ORU_R01"

Something to keep in mind is that methods expecting a message class as an argument (ex. EnsLib.HL7.Message) work on message objects rather than strings. The tMsg variable created by both the %OpenId() and ImportFromFile() methods are such objects. These objects have a rich set of methods for inspecting, transforming and otherwise working with messages.

The DocType is not automatically set by the ImportFromFile() method. You would need to set it to whatever DocType (i.e. DocTypeCategory:DocTypeName) is required to properly parse the message.

In a Production, the Business Service that receives messages uses the value in the Message Schema Category field to set the DocType for subsequent processing, and if both a DocTypeCategory and DocTypeName are present it will override the automatic selection of the DiocTypeName determined by the HL7 message's MSH:9 value.