Hello @Mohamed Hassan Anver,

I think that the tutorial is for EF 6 that is designed for .NET Framework. And MS is not promoting more EF Framework, right now, MS has EF core as goal (check this: https://docs.microsoft.com/es-es/ef/efcore-and-ef6/ ) and is the right EF to go in my opinion.

However IRIS is not supporting EF Core https://community.intersystems.com/post/how-can-i-use-iris-net-core-entity-framework. :-( 

Any thought @Bob Kuszewski ?
 

Well, there are only 2 tables related with that queries:

Ens.MessageHeader(https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=EMONITOR_concepts#EMONITOR_concepts_msgs)

EnsLib.HL7.Messages (https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=EHL72_tools#EHL72_tools_classes)

Any Ensemble Message has a header object or record (Ens.MessageHeader) the Message Body related with this Header can be any persistent object. Then you have to check MessageBodyClassName property to check if the body is a EnsLib.HL7.Message, then you can link the Header and Body using MessageBodyId property.

I hope this helps.

Ens.MessageHeader

Hello Lassi,

You should create a new Business Service class extending the HL7 Business Service of your election (TCP, HTTP, etc) and after overwrite this method:

method OnConstructReply(Output pReplyDoc As EnsLib.EDI.Document, pOriginalDoc As EnsLib.EDI.Document, ByRef pReplyCode As %String, ByRef pSC As %Status, pEarlyAck As %Boolean) as %Status

Override this method to construct a customized reply document. Inputs are the original document and the reply code and the status code that the framework produced in processing the original document. If you change the status code but do not construct a reply document, the framework will use the new value to construct a standard reply document. 
If you construct a non-HL7 object it must still have a property called 'Envelope'. Piece:2 of this value will be written verbatim.

Consider this example (I didn't test it):

method OnConstructReply(Output pReplyDoc As EnsLib.EDI.Document, pOriginalDoc As EnsLib.EDI.Document, ByRef pReplyCode As %String, ByRef pSC As %Status, pEarlyAck As %Boolean) as %Status

{

    Set pReplyDoc=pOriginalDoc.NewReplyDocument(,..LocalFacilityApplication)
    Set pReplyDoc.Source=pOriginalDoc.%Id()
    Do:..#UseOriginalControlId pReplyDoc.SetValueAt(pOriginalDoc.GetValueAt("1:10"),"1:10") ; copy the control id to the ack control id
    Set tAckMSA=##class(EnsLib.HL7.Segment).%New($LB("",1))
    Set tAckMSA.Separators=pReplyDoc.Separators
    Do tAckMSA.SetValueAt("MSA",0)
    Do tAckMSA.SetValueAt("CE",1)
    Do tAckMSA.SetValueAt(pOriginalDoc.GetValueAt("1:10"),2)
    Do:$G($$$ExpectedSequenceNumber) tAckMSA.SetValueAt($$$ExpectedSequenceNumber,4)
    Do pReplyDoc.AppendSegment(tAckMSA)
    Set pReplyDoc.IsMutable=0
    Quit $$$OK

}