For a FHIR server, FHIR Interoperability Adapter, or FHIR client that leverages an interoperability production:
Accessing FHIR Payloads
When a FHIR implementation is using an interoperability production, you access the FHIR payload of the message object differently than implementations where a production is not used. In production-based implementations, the request and response messages (HS.FHIRServer.Interop.RequestOpens in a new tab and HS.FHIRServer.Interop.ResponseOpens in a new tab) contain a QuickStreamId that is used to access a QuickStream object containing the FHIR payload. Though an interoperability request message also contains a Request property of type HS.FHIRServer.API.Data.Request, this Request property cannot be used to access the FHIR payload because its Json property is transient (the same is true for interoperability responses). As a result, a business host in the production that needs to access the FHIR payload must use the QuickStreamID to obtain the payload.
If the payload is in JSON format, the business host can access the payload and convert it to a dynamic object in order to modify it. For example, a BPL business process could use the following code to access and modify the FHIR payload of a request message that is in JSON format:
//Identify payload as a Patient resource and convert to dynamic object
if ((request.Request.RequestMethod="POST") & (request.Request.RequestPath="Patient"))
{
set stream = ##class(HS.SDA3.QuickStream).%OpenId(request.QuickStreamId)
set myPatient = ##class(%DynamicObject).%FromJSON(stream)
// Modify Patient resource
do myPatient.%Set("active", 0, "boolean")
//Update payload with modified Patient resource
do myPatient.%ToJSON(stream)
do stream.%Save()
}
For more examples of manipulating FHIR data as dynamic objects, see FHIR Data.