Article
· Sep 16 2m read

Custom File Adapter - Lookup Table / Dynamic Files

My problem was separating HL7 messages by message type.  I had to create multiple File Operations.  So I with custom code I am able to use 1 File Adapter for 1 interface and multiple message types.  I did experiment pulling the MSH 4 out of the raw content to further access dynamic information, but that may open a need for more robust error checking / lookup default actions.

Using the recommended naming convention of "To_FILE_<IntegrationName>"

I decided to use a generic file name and path in the default settings.

I created a custom class that extended the EnsLib.File.OutboundAdapter  With some custom code that allows me to dynamically control file adapter path specific to each message type via a lookup table.  If I don't have a value then the default generic path will be used.  Otherwise my code will override the File Path and File Name.  Lookup table name can be anything, just needs to match in your code.


 

Custom Code

//SRC1 Pull  3rd piece name of the outbound operation name "<IntegrationName>"

//SRC2 Pull the 1st piece of the DOCTYPE NAME  "ORM" / "ADT" / "ORU" / etc..

// Set a new variable SRC to concatenate the SRC1_SRC2 together

//New Lookup table that will control path names all in one place.

 

Set src1=$PIECE(..%ConfigName,"_",3,3)
Set src2=$PIECE(pDocument.DocTypeName,"_",1,1)
If src=""
{
Set src=src1_"_"_src2
} Set pFilename = ..Adapter.CreateFilename(##class(%File).GetFilename(src), $PIECE((##class(Ens.Rule.FunctionSet).Lookup("HL7FileNamePath",src)),"^",2,2)_..Filename) $$$TRACE(pFilename)
//Reset file path to return a file path based on the Lookup and PIECE function(s)
Set ..Adapter.FilePath =$PIECE((##class(Ens.Rule.FunctionSet).Lookup("HL7FileNamePath",src)),"^",1,1)
$$$TRACE(..Adapter.FilePath)
Set tSC = ..Adapter.open(pFilename) Quit:$$$ISERR(tSC) tSC
Set $ZT="Trap"
Use ..Adapter.Device  Set tSC=..OutputFramedToDevice(pDocument,pSeparators,"",0,..IOLogEntry,.pDoFraming) Use ..Adapter.OldIO
Set $ZT=""

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