Question
· Mar 21, 2018

Saving a message to memory from terminal

Trying to save a message to memory from terminal.   The following is not working as I know I'm missing something.

Set HL7Msg=##class(EnsLib.HL7.Message).Identifier(XXXX)

Discussion (3)0
Log in or sign up to continue

ok

• property Identifier as %String [ Calculated,Transient,ReadOnly ];
http://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=ENSLIB&CLASSNAME=EnsLib.HL7.Message#PROPERTY_Identifier

Unique document identification string found at MSH:10 / MessageControlId in document content

You can't set it. It gets calculated and is ReadOnly.

Following http://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=ENSLIB&CLASSNAME=EnsLib.HL7.Message
you should probably start  with

     set Set HL7Msg=##class(EnsLib.HL7.Message).%New()
 and start to compose the message accordingly.

You can do it using below code.

set strADT ="MSH|^~\&|MEDICO|JOE'S HOSPITAL^1.2.3.4.5|OCIEB2B|OCIEUHGB2BTEST|20130730072041|SECURITY|ADT^A01|MSG00001|P|2.7|||AL"_$c(13)
_"EVN|A01|20130626044550||01|00968|20130626043902"_$c(13)
set InputADT=##class(EnsLib.HL7.Message).ImportFromString(strADT)
set InputADT.DocType="2.7:ADT_A01"  
InputADT.%Save()
 

In case you need to import it from a stream you can use ImportFromStream method to import the content from stream.