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

}

BINGO!!

It works like a charm!!

davidreche$ node test.js
Intersystems IRIS instance:  IRIS {}
Open result:  { ok: 1, result: 1, iris_pid: '9511' }
Version:  Node.js Adaptor for InterSystems IRIS: Version: 1.1.161 (CM); IRIS Version: 2019.1 build 284
Set global ^nodeTest(1) result:  { ok: 1,
  global: 'nodeTest',
  subscripts: [ '1' ],
  data: 'At Sun, 21 Oct 2018 19:12:52 GMT: global set from Node.js',
  defined: 1 }
 
Thanks!!

Generated files are hidden by default, and the .disp class is marked as generated. However to show the class, you have to click the little arrow on the row of buttons at the top right of the Server Explorer to open the customization menu. It’s this one:

From there, choose “Filters and Customization” and then uncheck the “Generated files” option (to disable the filter that hides generated classes) and click OK. After that to can added to the Git repo without problem.

Hello @Ward De Backer, 

Have you tested this with IRIS?

I am trying to run it using your guide and the documentation (https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=BXJS_connect), and I have this error:

var db = new irisobj.Iris();
         ^

TypeError: irisobj.Iris is not a constructor

I am using node v8.6.0 and iris.800.node.

My code is almost the same as yours:


let irisobj = require('iris');
var db = new irisobj.Iris();
console.log('Intersystems IRIS instance: ', db);

Thanks