Discussion (2)2
Log in or sign up to continue


If you are using the HS FHIR Resource classes in IRIS for Health then you will see that attributes such as Patient.Picture is a BinaryStream. If you are using a BinaryStream you need to convert it into Base64 encoding which generates a stream of characters that do not include any control characters that may cause a JSON or XML parser to think that it has encountered a line terminator. If you look at the FHIR to SDA nd SDA to FHIR data transformations you will see how they Transform the Inbound Stream from Base64 to Binary and from Binary to Base 64 encoding for the outbound SDA to FHIR JSON or XML.

Hello everyone,

not sure if it is still possible to proceed in this topic, but I am facing a similar problem: would like to embed larger payloads (greater 3M) as presentedForm in a DiagnosticReport to send it to our archive server (have to prepend as well, unfortunately I am not too familiar with FHIR at all).

My brute force method is to populate a HS.FHIR.DTL.vR4.Model.Resource.DiagnosticReport using a DTL, convert it to a DynamicObject, replace the presentedForm.data-Property with the large file stream, and write it out to a QuickStream:

ClassMethod GetQuickStreamFromDiagnosticReport(pDiagRep As HS.FHIR.DTL.vR4.Model.Resource.DiagnosticReport, pFile As %String) As %String
    #dim tStreamInFile As %Stream.FileBinary
    #dim tTempJSON As %Stream.Object
    #dim tDynOb As %DynamicObject
    #dim tQuickStream As HS.SDA3.QuickStream
    Set tStreamInFile = ##class(%Stream.FileBinary).%New()
    Do tStreamInFile.FilenameSet(pFile)
    // convert: DiagnosticReport --> JSON --> DynamicObject
     Set tTempJSON = pDiagRep.ToJSON()
     Set tDynOb = ##class(%DynamicAbstractObject).%FromJSON(tTempJSON)
     // replace presentedForm.(1).data-property by stream
     Do tDynOb.%Get("presentedForm").%Get(0).%Set("data", tStreamInFile, "stream")
    // serialize DynamicObject
    Set tQuickStream = ##class(HS.SDA3.QuickStream).%New()
    Do tDynOb.%ToJSON(tQuickStream)
    Do tQuickStream.%Save()
    Quit tQuickStream.%Id()

It works, although it seems like a hack. Any hints how to improve would be highly appreciated...