How to read and write values into Ens.StreamContainer
Hi Community,
I have SDA file as Ens.StreamContainer Message using pRequest As Ens.StreamContainer
SDA file structure looks like this
<Name><FamilyName>Lucy</FamilyName><GivenName>Hale</GivenName><MiddleName>Park</MiddleName></Name><Gender><Code>F</Code><Description>F</Description></Gender><BirthTime>2023-09-07T00:00:00</BirthTime>
How can i change individual value from the Steam and then save changed value into the stream?
Comments
Take a look at the following documentation:
https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cl…
Hello smythe,
There are couple of ways to import your file into stream and convert to Ens.StreamContianer
First you can create a
ClassMethod StreamContainer()
{
set file="dir\file" ; Your directory and file name(C:\Intersystems\new13.txt)
set file = ##class(%FileCharacterStream).%New()
do file.LinkToFile(file)
set strmContainer=##class(Ens.StreamContainer).%New(file)
zwrite strmContainer.Stream.Read($$$MaxLocalLength)
}Second, This way it's almost similar way. But Instead of pushing directly into Ens.Streamcontainer. You need to create a object for SDA. Import your file through
ClassMethod FileToSDAToEnsContainer()
{
set file = ##class(%FileCharacterStream).%New()
do file.LinkToFile("C:\FHIRFILE\new13.txt")
set SDA3Container=##class(HS.SDA3.Container).%New()
do SDA3Container.XMLImportSDAString(file.Read($$$MaxLocalLength))
zwrite SDA3Container
do SDA3Container.ToQuickXMLStream(.stream)
set strmContainer=##class(Ens.StreamContainer).%New(stream)
zwrite strmContainer.Stream.Read()
}SDA may be too large to instantiate a Container object. Instead, use ##class(HS.SDA3.Container).InitializeXMLParse and ##class(HS.SDA3.Container).GetNextSDA to instantiate each streamlet.