When using a server-side application to make FHIR requests to the internal FHIR server, your application should use the standard FHIR client. For details about using these built-in classes, see FHIR client.
However there are some cases where you might want to perform actions on the server’s storage without a request. For example, you might want to perform a write operation even though the server’s metadata restricts requests to read-only interactions. In this case, you can bypass the Service.
Your ObjectScript application can also validate a resource.
Bypassing the Service
A server-side application can call the methods of an Interactions subclass directly instead of submitting programmatic requests via the Service. For example, an application could call the Interactions subclass’ Add method directly rather than sending a POST request to the Service. This is especially useful if the server-side application needs to perform actions that are prohibited by the Service. For example, if the server’s metadata configures the endpoint as read-only, programmatic requests to the Service cannot create resources. However, using method calls to the Interactions subclass, a server-side application could update the storage strategy with resources, effectively bypassing the restrictions enforced by the Service.
Programmatic calls to methods of the Interactions class pass FHIR data as dynamic objects. For more information about working with this data, see FHIR Data and Dyanmic Objects.
Validating FHIR Resources
Your ObjectScript application can programmatically validate a resource against the FHIR server’s metadata without using the FHIR $validate operation as long as the resource is represented as a dynamic object. For example, the following code validates a Patient resource against the server’s FHIR Release 4 metadata, which includes the schema for the Patient resource. When calling the LoadSchema method, you can specify the common name of the FHIR version (for example, R4 or STU3) or the name of the server’s base metadata (for example, HL7v40 or HL7v30).
// Put JSON representation of Patient resource into a dynamic object set patient = ##class(%DynamicObject).%FromJSON("c:\localdata\myPatient.json") //Validate the patient resource set schema = ##class(HS.FHIRServer.Schema).LoadSchema("R4") set resourceValidator = ##class(HS.FHIRServer.Util.ResourceValidator).%New(schema) do resourceValidator.ValidateResource(patient)