- 01 Jul 2022
- 6 Minutes to read
- Print
- DarkLight
FHIR Module
- Updated on 01 Jul 2022
- 6 Minutes to read
- Print
- DarkLight
FHIR Module Overview
The Fast Healthcare Interoperability Resources (FHIR) Module allows Decisions to integrate with the FHIR API. Developed by HL7 Inc., FHIR is a standard for electronic healthcare data exchange that was designed based on REST web services. The FHIR Module provides users with pre-built Flow steps that can help users to access and manipulate FHIR data objects.
- Installation of the FHIR module. To learn how to install a module, see Installing Modules in Decisions.
FHIR Step | Input | Output |
---|---|---|
Add Resource to Bundle | FHIR Bundle, Resource to Add | FHIR Bundle (with the added resource) |
Cast FHIR Resource to FHIR Type | FHIRTypeName - predefined list of resource types, FHIR Resource | FHIR Resource Result - Resource of a given type |
For Each Resource in FHIR Bundle | FHIR Bundle | Cell |
Get Json For | FHIRBundle, FHIRObject, FHIRResource | This takes in FHIR objects (bundle or resource) and converts data into JSON |
Get Resources from Bundle | FHIR Bundle | Resources List |
Read JSON and Cast to FHIR Type | JSON String - describing a Resource | FHIR Resource Result - Resource of a given type |
Read Bundle From JSONData | JSON String - describing a Bundle | FHIR Bundle |
Read Resource From JSON | JSON String - describing a Resource | FHIR Resource |
What are FHIR Objects?
- Resource Types: To view a list of resource types and their attributes, visit https://www.hl7.org/fhir/valueset-resource-types.html
- Bundle Types: To view a list of bundle types and their attributes, visit https://www.hl7.org/fhir/valueset-bundle-type.html
Example A
This example will demonstrate how to pull a patient’s data from an FHIR bundle resource (in this case the bundle type is a transaction) and then check if the patient is older than 18 years. The input of this Flow will be a JSON string describing a transaction that has a patient resource. The JSON file used in this example can be downloaded below.
- In a Designer Project, click CREATE FLOW, select Default under Flow, and click CREATE. Name the Flow and select CREATE.
- In the Flow Designer, add a Create Data step from the Steps panel to the Done path of the Start step.
- With the Create Data step selected, click Show Editor under the Data category on the Properties panel.
- In the Data Definitions window, enter "BundleJSON" in the Name field and select String [Text] as the Type. Click Edit under Input and select input mapping to Merge Plain Text. Paste the JSON string describing a Bundle into the Merge Text Editor. Click CLOSE to save.
- From the Done path, add a Read Bundle from JSONData step from the Integration > FHIR category. Select Unknown next to the Json FHIRDATA field under the Inputs category on the Properties panel and click Select From Flow. Select Bundle JSON and click DONE.
- From the Done path add a Get Resources from Bundle step by navigating to Integration > FHIR. Under the Inputs category, select Unknown next to the FHIRBundle field and choose Select From Flow. Select ReadBundleFromJSONData1_Output and click DONE.
- From the Done path, add a Cast FHIR Resource to FHIR Type step by navigating to Integration > FHIR. Under the Settings category on Properties panel, enter "patient" in the FHIRTypeName field. Select Unknown next to FHIR Resource and click Select From Flow. Click Resource List, select Last, and click DONE.
- On the Done path, add a Parse Date step by navigating to Data > Dates. Select Unknown next to the Date field and chose Select From Flow. Click FHIR Resource Result, select BirthDateElement, and click DONE. The Parse Date step will convert BirthDateElement to a DateTime type that can be used as input.
- On the Done path of the Parse Date step, add an Add Years step from the Data > Dates category. For the Source Date field, choose Select From Flow and map in ParseDate_Output. Set input mapping for Years to Constant and enter "18".
- Add a Run Rule step from the Rulescategory in the Steps panel to the Done path of the Add Years step to check if the patient is older than 18 years. Configure the Rule to evaluate if the given input of plus18years is less than or equal to the current date. Then, click Save to save the Rule and click Close to return to the Flow Designer.Learn more about creating a Rule at Creating a Rule.
- For the input of the Rule, chose Select From Flow and map AddYears_Output. Connect the Incorrect Type path to the End step.
- For this example, add a Show Popup step to the Fase path (Child) and another Show Popup step to True path (Adult). Connect the Done paths of the two Show Popup steps and the Incorrect Type path of the Read JSON and Cast to FHIR Type step to the End path. Click Save to save changes to the Flow.
Debug
- For example purposes, two Show PopUp steps were added to the True/False paths to show if the patient is a child or an adult. Select Debug to run the Flow in the debugger.
- In this example, the birthdate of the patient is 12/25/2000 meaning the patient is older than 18 and should follow the True path.
Example B
In this example, a Flow will take in JSON of a Resource Patient and pull a contact’s email address and send an automated email to someone in the patient’s listed contacts.
The JSON file used in this example can be downloaded below:
- In a Designer Project, click CREATE FLOW, select Default under Flow, and click CREATE. Name the Flow and select CREATE
- In the Flow Designer, add a Create Data step from the Steps panel to the Done path of the Start step.
- Set Name to "PatientJSON" and Type to "String". Select input mapping to Merge Plain Text and input JSON string describing a Patient.
- Add the step to read the JSON string and allow us to get data from FHIR Resource Type. From the Done path add a Read JSON and Cast to FHIR Type step from the Integration > FHIR category in the Steps panel. Select "Patient" for FHIRTypeName and choose Select From Flow to input PatientJSON.
- On the Done path, add a Send Email step from the Favorite Steps category.
- Pull the email of the patient’s contact from the FHIR Resource Result output. For Email > To choose Build Array and Select From Flow and map FHIR Resource Result.Contact.First.Telecom.AllValue.First.Data from FHIR Resource Result can be used in the Subject and Body inputs.
- Connect the remaining outcome paths to the End step. Save the Flow.
- After running the debugger, the following email will be received.
Example C
This example will demonstrate how to take in an FHIR Bundle and use the For Each Resource in the FHIR Bundle step to cast FHIR Resources to their proper resource type. The JSON file used in this example can be downloaded below:
- In a Designer Project, click CREATE FLOW, select Default under Flow, and click CREATE. Name the Flow and select CREATE.
- On the Start step, create a string type for JSON Bundle data and input the JSON file content.
- Add the Read Bundle from JSONData step to the Start step. Select Unknown from next to the Json FHIRData field and select Select From Flow. Select JSONBundle and click DONE.
- Add the For Each Resource in FHIR Bundle step to loop through each resource in the bundle. Select ReadBundleFromJSONData1_Output from the Flow for the FHIR Bundle field.
- Add a String Match Step to the Next path to sort/map Resources to their proper type. In this example, the resource types expected are Patient and Organization. Map the String to Match input field to Next Resource.ResourceType.
- Add a Cast FHIR Resource to Type step for each Resource Type. Then, set the FHIR Resource field input to Next Resource and update the output results for each Resource. Connect the Done path to the End step. Connect the Incorrect Type and Done paths from the Cast FHIR Resource to FHIR Type to the For Each Resource in FHIR Bundle step. Click Save to save Flow.