Question
· May 5, 2023

Healthshare File Adaptor Don't Delete Source File from Server

Hi I want to utilise the file adaptor to pick up some PDF documents however I must not delete the source files from the server.  I can see that there is a setting in the FTP adaptor to not delete from server but not in the file adaptor.  Is there an easy way to do this or do I just need to create a custom adaptor that copies the files to a working location and records in a tracking global when I have done this so that I don't process the same file twice?

Product version: IRIS 2023.1
Discussion (5)2
Log in or sign up to continue

Hey Jon.

One option could be to change the permissions for the source directory to be read only for the account running Ensemble/Healthshare? This way, the adapter will copy the file from the directory but will then be unable to delete it from the directory, while also keeping track of what files it has copied.

The log for the passthrough service will be a bit messy at first. but you'll end up with something like:

However, if the directory you're going to be checking for documents will be an ever growing list of a large number of documents, then your own suggestion of copying the files into a secondary working directory before being picked up by ensemble might actually be the best option as there's a bit of an overhead for the adapter when it's scanning a directory that contains a large number of files.

Depending on how soon after the files creation you need it for onward processing, you could create a scheduled task that copies all files from the previous day into your working directory and then sends an email if that fails for any reason?

Here's how to fix that.

1. Create Inbound adapter which extends default inbound adapter and exposes DeleteFromServer setting:

Class Test.InboundAdapter Extends EnsLib.File.InboundAdapter
{
Parameter SETTINGS = "DeleteFromServer:Basic";
}

2. Create Passthrough Service, which uses your custom adapter:

Class Test.PassthroughService Extends EnsLib.File.PassthroughService
{
Parameter ADAPTER = "Test.InboundAdapter";
}

3. Use your class (2) when you create a new BS, it will have DeleteFromServer property:

I filed an enhancement request, please use DP-422980 as an identifier if you would contact WRC on this topic.

Have had a similar problem.  Likely the issue is your FTP server needs to increase its timeout settings.  
 

You could try extending the FTP adapter and overriding the delete method as follows:

Method delete(pFilename As %StringpFileDir As %StringAs %Boolean
{
Set tSC=..setFilePath(pFileDir,.tOldDirIf $$$ISERR(tSC$$$LOGSTATUS(tSCQuit }
Set tOK=$S(..%isSFTP:..FTP.DeleteSSH(pFilename),1:..FTP.Delete(pFilename))

if 'tOK

{

if ..Connected set tSC=..Disconnect(1)
Set tSC=..Connect(..ConnectTimeout,1)
Set tOK=$S(..%isSFTP:..FTP.DeleteSSH(pFilename),1:..FTP.Delete(pFilename))

}
Do:'tOK ..disconnectOnNetErr(,1)
If ..Connected Set tSC=..restoreFilePath(tOldDirIf $$$ISERR(tSC$$$LOGSTATUS(tSCQuit }
Quit tOK
}

If tOK returns an error, you failed to delete.  this change will disconnect from the server, reconnect and delete again.  As the most likely issue is you are not connected this will work around your ftp server's timeout.  

The other option is to update your FTP server to have a larger timeout window.