Question
· Oct 10, 2024

New to working with files in Intersystems

Hi there, 

I'm hoping that someone may be able to point me in the right direction to get started with working with files in Intersystems. I am currently trying to build an interface that will consume a text file containing a list of IDs (one per line) and then write those IDs to an external database. I am comfortable working with the database end but have not worked with files/Stream containers etc yet.

I am struggling with the BP logic as I can't figure out how to access the data within the stream container. My Trace Statements don't appear in the management console when checking despite Trace Logging enabled on the BP.

I really appreciate your time and your help,

Thanks

Dan

My rudimentary ObjectScript looks as follows:

Class ELHTPRODPKG.Interfaces.LancsCare.Processes.LancsCareCSVProcess Extends Ens.BusinessProcess
{ Method OnRequest(pRequest As Ens.StreamContainer, Output pResponse As %Persistent) As %Status
{
        Set sc = $$$OK
        
        // Create a new stream to read the content
        
        $$$TRACE("Step 1")
        
        Set tStreamFile = pRequest.StreamGet()
        
        Set fileContent = tStreamFile.Read()
                
        $$$TRACE("File Content: "_fileContent)
        
    //Set pResponse = sc //Return the status of the operation
    Quit sc  // Return status
}

Product version: HealthShare 2021.1
Discussion (6)2
Log in or sign up to continue

Edit.. for some reason I didnt see the above reply.

Given that you are extending Ens.BusinessProcess you have access to Ensemble/Interoperability.  If you are going down this path you might want to review RecordMaps which is a general purpose way of consuming data from files via a business service based on EnsLib.RecordMap.Service.FileService.  This will open the file, for each line create an instance of your RecordMap object and then if you define in the service the TargetConfigNames sent the Record as a message to commonly a business process.  In the busines process you will receive each line as a message object.  From there you can do what you like with it.

This could be a bit overkill if all you have is a single column in the file(just a column for ID) but is a general way of handling the ingestion of files.