Question
· Dec 18, 2019

Batch header and footer in Ensemble File Operation

Hello community,

I am receiving a HL7 message over TCP connection.

I have to set up  a process/operation to produce a daily file with this HL7 messages to be created in a directory using EnsLib.File.OutboundAdapter
and EnsLib.HL7.Operation.FileOperation. The file needs to have a header line added each time it is created and a footer .I did not find any standard class file under File Adapter which will create header/footer. 

Any suggestion will be greatly appreciated.

Thanks,

Jimmy Christian

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

Are these standard HL7 batch headers and footers (BHS/BTS, FHS/FTS, etc) or something custom to your organization?

If they are one of the HL7 standards, have a look at these docs on HL7 batches:
https://docs.intersystems.com/healthconnect20191/csp/docbook/Doc.View.cl...

One tricky part will be triggering when an old batch ends/new batch begins -- this will depend on your local requirements.

If they are custom, there are a few approaches you can consider:

  1. You could use the Record Mapper to define a record map class with header/footer and a single field record for the HL7 content. You would then use one of the  EnsLib.RecordMap.Operation.* classes instead of EnsLib.HL7.Operation.FileOperation: https://docs.intersystems.com/healthconnect20191/csp/docbook/DocBook.UI.... In particular, have a look at RolloverSchedule and/or RolloverLimit to control when a new batch file is created.
  2. If you're comfortable creating a custom class that extends EnsLib.HL7.Operation.FileOperation, you could override the outputDocument method. In your custom version of outputDocument you could check if the file already exists using ##class(%File).Exists(pathToFile) and if it doesn't you would write out the footer to the previous file and the header to the new file before calling the standard version of outputDocument using ##super. https://docs.intersystems.com/healthconnect20191/csp/docbook/Doc.View.cl...

Thank you Marc for the detailed information.

I earlier tried the approach using the Record Mapper but it did not seam feasible in this scenario. 

So i have done is 

Created a CUSTOM operation class which extends Ens.BusinessOperation, EnsLib.HL7.Operation.Standard

It uses the file adapter.

Then I overided the oninit and outputDocument method.

  1. The file adapter creates HL7 file as usual
  2. I created a new method which calls the override outputDocument method and passes the filename . Then I do a count of segments and create another file into which I copy all the necessary information and delete the file which was originaly created .
  3. Above method is called in oninit, so it is triggered on schedule whenever the operation starts. First I check if a file exists, if it does and is not the current file then I call this new method.

Hello Pankaja,

Seems like for now custom code is the only option. I was not able to find any out of the box functionality for writing the counts of the total transactions without a custom code.

Here are few strategies for custom code i looked into.

1) In the File Operation , write the messages to a "Temp" File. At a certain time through a task or some other logic read from the temp file and collect all details you need and then write to another File.

2) I yet have to explore this option. At a point in time when you want your file, read from the Enslib.Hl7.Msg and create a file per your needs.

3) Write the live messages to a temp database. Generate necessary file from it when needed. Delete the messages from the DB and copy it to a Archive DB if needed.

4) As live messages are coming write to a Global and then run a task to create messages from the Globals.

Thanks,

Jimmy Christian.