Question Daniel Durdin · 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

Comments

Daniel Durdin  Oct 10, 2024 to Robert Cemper

Hi Robert,

Thanks for the link but I'm not sure this applies to my interface development. It appears to describe accessing files from the application using Terminal? 

Kind Regards,

Dan

0
Robert Cemper  Oct 10, 2024 to Daniel Durdin

it applies to any code in ObjectScript

0
Daniel Durdin  Oct 11, 2024 to Robert Cemper

Thanks Robert. I ended up resolving my issue by changing my approach to use a Record Mapper for the inbound file. 

Thanks again for pointing me at this resource.

0
Stephen Canzano · Oct 11, 2024

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.

0
Daniel Durdin  Oct 14, 2024 to Stephen Canzano

Thanks Stephen. This is the solution I landed on in the end; it has the added benefit of being a little bit more user friendly for our support team also.

Thank you for your time and help.

0