Skip to content

Overview

This section will cover the approaches to implement and deploy the different FHIR resources and profiles as service.

:::note These guides use Ballerina, a language designed for integration and network services, to build healthcare integrations as microservices. :::

In this implementation pattern, each FHIR resource and profile is represented as an individual service (microservice). A separate Ballerina service will represent a FHIR Resource API. To implement FHIR APIs that support FHIR profiles, it's essential to provide endpoints that client applications can use to interact with your FHIR resources (for creating, reading, updating, deleting, and searching).

To streamline the setup of these APIs, we can use the Ballerina Health CLI Tool to generate the necessary API templates for a FHIR Facade. FHIR API developers can then write the business logic in the generated templates. The Health Tool is versatile and can be used to generate templates for various FHIR specifications such as base resources, USCore, AUBase etc.

Here's an example of how to utilize the Health Tool to generate USCore API templates

  1. Start by cloning the example artifacts of particular FHIR profile and extracting them to a preferred location. This includes the ig-uscore/definitions directory, which includes the definition files of the FHIR specification.

  2. For instance you can find all the latest version of US Core profiles here.

  3. Navigate to the cloned directory and run the following command to generate the templates,

bal health fhir -m template -o genereated_outputs --org-name healthcare_samples --dependent-package ballerinax/health.fhir.r4.uscore501 ig-uscore/definitions

:::info Explanation - -m [mode] - For this instance, mode should be template. - -o [output directory] - Location of the generated Ballerina artifacts. If this path is not specified, the output will be written to the same directory from which the command is run. - --org-name - Organization name of the Ballerina package/template to be generated. - --dependent-package - Fully qualified name of the published Ballerina package containing IG resources (for example: <org>/<package>). This option can be used to generate templates specifically for resources in the given IG. The package name part of this value will be added as a prefix to the template name. The dependent package should be generated first and pushed to Ballerina Central.

::: :::note You can find all the core packages of different FHIR profiles in Ballerina Central.

For instance:

If you want to generate packages for any custom profiles, you can use the Ballerina health package generation tool. ::: :::note - While generating templates, you can use --included-profile or --excluded-profile to include or exclude whichever profiles you want.

::: 3. After you have generated the templates, you should implement the business logic to fetch and process required data. Because, by default these templates do not have any business logic.

  1. To run the service as a standalone server, execute the below command.

    bal run