I'm running into an intermittent issue with some of our Custom Operations/Processes as a result of some large FHIR R4 Binaries. Essentially we get a response from an AthenaHealth FHIR endpoint that appears to be too large to be processed using the IRIS Built In Functions for FHIR:
I've replicated it on the command line here using a file (binary.json) that has the response from the FHIR Endpoint. Not sharing full contents due to PHI concerns.
HSCUSTOM>S file=##class(%Stream.FileCharacter).%New()
HSCUSTOM>Do file.LinkToFile("/data/binary.json")
HSCUSTOM>w file.Size
4033045
HSCUSTOM>Set FhirBinary = ##class(HS.FHIR.DTL.vR4.Model.Resource.Binary).%New()
HSCUSTOM 2d1>Do FhirBinary.FromJSON(file,"vR4")
<MAXSTRING>%GetNext+12^%Iterator.Object.1
Looking into the Class Code:
/// Pure binary content defined by a format other than FHIR.
Class HS.FHIR.DTL.vR4.Model.Resource.Binary Extends HS.FHIR.DTL.vR4.Model.Base.Resource [ Not ProcedureBlock ]
{
/// code
/// <p>
/// MimeType of the binary content.
/// <p>
/// mimetypes|4.0.1 is the REQUIRED FHIR4 ValueSet for codes;
/// you may NOT extend mimetypes|4.0.1 and you may NOT use codes from other ValueSets.
Property contentType As %String(MAXLEN = 1000000, XMLNAME = "contentType", XMLPROJECTION = "ATTRIBUTE") [ Required ];
/// Reference
/// <p>
/// Identifies another resource to use as proxy when enforcing access control.
/// <p>
/// Any FHIR4 Resource may be indicated by this Reference
Property securityContext As HS.FHIR.DTL.vR4.Model.Base.Reference(XMLNAME = "securityContext", XMLPROJECTION = "ELEMENT");
/// base64Binary
/// <p>
/// The actual content.
Property data As %Binary(XMLNAME = "data", XMLPROJECTION = "ATTRIBUTE");
It appears the data is stored as a %Binary (which is basically a %String) and hits the <MAXSTRING> error.
Sample data:
{
"contentType": "image/png",
"data": "<LONG Base64 Encoded Content>",
"id": "XXXXXXXXXXX",
"meta": {
"security": [
{
"code": "NOPAT",
"display": "no disclosure to patient, family or caregivers without attending provider's authorization",
"system": "http://terminology.hl7.org/CodeSystem/v3-ActCode"
}
]
},
"resourceType": "Binary"
}
I'm essentially trying to deserialize so I can get at the content-type, security, and id properties easily to determine if we do anything with the Base64 itself. It seems odd that productized code from IRIS wouldn't handle this, although I can't say I'm super confident the source data is complying to any standards outside of shape.
We could refactor our existing code to handle SOME of this using DynamicObjects:
HSCUSTOM>s dynObj={}.%FromJSON(file)
HSCUSTOM>w dynObj.contentType
image/png
HSCUSTOM>w $EXTRACT(dynObj.data,1,100) W $EXTRACT(dynObj.data,1,100)
^
<MAXSTRING>
That said, if I still need to access the binary content itself, I'm not sure the best way to handle that. If anyone has run into anything similar, I'd appreciate some feedback.
Thank you!
-Vic