Question
· Jan 14, 2016

Pass path from EnsLib.HL7.Service.FTPService to EnsLib.HL7.MsgRouter.RoutingEngine?

I have a service named FTP_In that is of class EnsLib.HL7.Service.FTPService.   It picks up files from multiple subfolders and sends them to an EnsLib.HL7.MsgRouter.RoutingEngine.   What I want to do is somehow capture the subfolder as a variable for use in the routing rules.  Is this possible?

Let's say I have the following files and directory structure on my FTP Server

/incoming/green/apple.dat
/incoming/yellow/banana.dat

I want the Routing Rule to be able to send anything that came from the /green/ folder to one operation and from /yellow/ to another.

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

Hi Scott,

On initial investigation at least, it certainly seems like the property 'Source' on the message header, returns only the root folder path ie, "/incoming",  not the subdirectoryr path when you have used the Subdirectory Levels settings of the FTP adapter.

One option perhaps would be to see if there is some other information in the HL7 Message data (Source system ?  Source Facility ?) that could provide enough information for your business rule.

Another option would be to have multiple FTP_In business services, one for each sub-folder, although I realise this is inpracticle if the subfolder names aren't fixed, or, there could be many of them. 

Perhaps others in the community have a better approach (including subclasssing the product's Adapters perhaps) to exposing this detail.

Steve

I think using message header information is the obvious solution, but my reasons for doing this were slightly more complicated.  No need to elaborate though as I think I'll end up writing a custom function.

Thanks for the input.

User Dmitry Maslennikov has stated on this StackOverflow question that it does include the full path but when I looked in the viewer it was visually truncated.  I hadn't been able to verify in code yet.

I'll see if I can validate and if it's not there then use part of the message header.

Thanks Scott,

Our EnsLib.HL7.Service.FTPService uses the FilePath setting in the Source information which does not account for the sub directory searching option:

OnProcessInput() line:

Set tIOStream.Name=pFTPStream.Attributes("Filename")_$C(13,10)_"via FTP "_..Adapter.FTPServer_":"_..Adapter.FTPPort_" path '"_..Adapter.FilePath_"'"
 

But the adapter is passing the actual path where the file was retrieved from in pFTPStream.Attributes("FTPDir") . I will make the change in EnsLib.HL7.Service.FTPService to use  pFTPStream.Attributes("FTPDir") instead of ..Adapter.FilePath but I am afraid I cannot advise on which release this will be in.

To verify from terminal using  write  ##class(EnsLib.HL7.Message).%OpenId(<id>).Source

returns before the code change:

somefile.hl7
via FTP 192.168.224.100:2121 path '/hl7'

to

somefile.hl7
via FTP 192.168.224.100:2121 path '/hl7/1/yellow/'

Would this be sufficient for your needs or since you state the reasons are more complicated  a more elegant solution in the Ensemble service is needed.

Kind regards

James

James,

Using Ensemble 2018.1.2, I'm using the pInput.Attributes("FTPDir") to get the full difectory of the filename (where pInput is %Stream.Object) when I have a root directory defined (e.g. /send) and the property Subdirectory Levels = 2.

I also, was trying to find a way  to use the subfolders of the file that's on the server to either run a rule or more simply, create the same folders on our side.  When the production service uses Subdirectory Levels, this subfolder information is not part of the ..Adapter.FilePath (e.g. the root folder is /send, the file is /send/sub1/sub2/testfile.txt, Subdirectory Levels=2, but the Adapter.FilePath = /send/testfile.txt)

However, using the FTPDir attribute of the %Stream.Object gives me the full directory of the source object, from which I can "piece" together appropriate storage path on our end.

Thanks!

And just to elaborate a little, what I was trying to do involved a lookup table.  Let's say I had an FTP adapter that picked up files from /ftpdir/ and 1 subfolder deep.  If I had

/ftpdir/green/
/ftpdir/red/

I could then have entries in the lookup table for "green" and "red" and (relatively) easily create a rule to do stuff based on the folder.  What I'm trying to do now is be able to block things.  So I have a lookup table named "BlockCustomer".  I could create the key value pair "green:1" and then use $PIECE on the proposed .SourcePath property to determine if it should be blocked.  

Although now that I think about it, I guess this could be done with the message header.  However if I have multiple facilities for a single customer the given field in the header may differ.  I'm not sure.