A light-weight and fast FHIR client. It use Indy's HTTP component (TIdHTTP) for connecting. For FHIR object model, with support for efficiently parsing and writing in JSON and XML format.
This is the documentation of the the settings of the TbsFhirClient and the CRUD interactions you can perform with it. We will then give some examples of search interactions, and explain how to perform operations and transactions.
General overview of the data flow in fhir:
Before we can do any of the interactions, we have to create a new TbsFhirClient instance. This is done by passing the url of the FHIR server's endpoint as a parameter to the constructor:
To specify the preferred format JSON or XML of the content to be used when communicating with the FHIR server, you can use the EncodingFormat attribute:
The FHIR client will send all requests in the specified format. The default setting for this field is JSON.
When communicating the preferred format to the server, this can either be done by appending
_format=[format] to the URL.
The client uses the
_format by default, but if you want, you can disable
A TbsFhirClient named client has been setup in the previous topic, now let's do something with it.
Assume we want to create a new resource instance and want to ask the server to store it for us. This is done using Create.
To read the data for a given resource instance from a server, you'll need its technical id. You may have previously stored this after a Create, or you have found its address in a ResourceReference (e.g. Observation.Subject.Reference).
The Read interaction on the TbsFhirClient has two overloads to cover both cases. Furthermore, it accepts both relative paths and absolute paths (as long as they are within the endpoint passed to the constructor of the TbsFhirClient).
Note that Read can be used to get the most recent version of a resource as well as a specific version, and thus covers the two '˜logical' REST interactions ReadResource and ReadResourceV.
Once you have retrieved a resource, you may edit its contents and send it back to the server. This is done using the Update interaction. It takes the resource instance previously retrieved as a parameter:
There's always a chance that between retrieving the resource and sending an update, someone else has updated the resource as well. Servers supporting version-aware updates may refuse your update in this case and return a HTTP status code 409 (Conflict), which causes the Update interaction to throw a Exception with the same status code.
The Delete interaction on the TbsFHIRClient deletes a resource from the server. It is up to the server to decide whether the resource is actually removed from storage, or whether previous versions are still available for retrieval. The Delete interaction has multiple overloads to allow you to delete based on a url or a resource instance:
The Delete interaction will fail and throw a Exception if the resource was already deleted or if the resource did not exist before deletion, and the server returned an error indicating that.
Note that sending an update to a resource after it has been deleted is not considered an error and may effectively "undelete" it.
After the TbsFhirClient has received a response from the server, you will usually work with the resource instance that was returned. If you still need to check the response from the server, for example to lookup the technical id or version id the server has assigned to your resource instance, you can do this by looking at the LastResponseCode property of the FhirClient.
The FHIR client has a few operations to do basic search.
The most basic search is the client's
Search( AResourceName: String; Params: String) function.
It searches all resources of a specific type based on zero or more criteria. Criteria must conform to the parameters as they would be
specified on the search URL in the REST interface, so for example searching for all patients named 'James' would look like this
The search will return a Bundle containing entries for each resource found. It is even possible to leave out all criteria, effectively resulting in a search that returns all resources of the given type.