The FHIR Profiling tool is a development utility that can be used to generate FHIR Resource JSON schemasTemplates according to any FHIR version specification. The FHIR Profiling tool performs two key activities:
First creates a FHIR Profiling SQLite database (fhir_profiles.db) by parsing and storing JSON specification files uploaded to the project. By default, the tool generates resources according to FHIR v4.0.1, however this is configurable.
Using this database, the FHIR Profiling tool generates and writes the desired FHIR Resource JSON schemas to a FHIRresources.lua fileschema, which you can then use in other projects to create and map FHIR resources.
How to use
...
Expand |
---|
title | STEP 1: Import the FHIR Profiling Tool and enter the Translator |
---|
|
Using +COMPONENT, import the FHIR Profiling Tool, and click Edit to open the Translator. |
Expand |
---|
title | STEP 2: Optionally, update Set the FHIR version specification you want to use to generate resources |
---|
| The FHIR Profiling Tool already contains the necessary files to generate |
By default, the FHIR Profiling Tool is pre-loaded with the FHIR v4.0.1 resources. If needed, you can update the version specification used. The component contains specifications for FHIR v4.0.0 and v4.0.1, so you can change the default configuration to use v4.0.0 by changing the custom field FhirVersion in the component card to “4.0.0”. Image AddedNeed another FHIR Version? This can be adapted by manually uploading the new FHIR specification to the component: Go to the official http://hl7.org/fhir/directory.html and download the FHIR specification for the version you need.
In the downloaded specification files, locate “profiles-resources.json” and “types-resources.json”. Upload and replace the current resource.json and types.json files in the fhirUtils/profiles folder. Image Removed. Create a new folder with your version name (ex. v3_0_0) under the Specifications folder and upload these files into your version’s folder with the names “resources.json” and “types.json” respectively. Image AddedUpdate the FhirVersion custom field value to your new version (ex. 3.0.0)
|
Expand |
---|
title | STEP 3: Optionally, add any custom or extension profiles you wish to add onto on top of the standard specification |
---|
|
Similarly to STEP 2, if If any custom or extension profiles are needed, you can add the <custom_profiles>.json files to the fhirUtils/profiles folder and use table.insert() on line 19 to specify the profile you want to add to the fhir_profiles.db Specifications/Custom folder. If no extensions are needed, the folder should be left empty. Note that if the custom profile’s specification exists as a standalone resource, it will need to be nested within a larger bundle resource definition. Let’s walk through this process using an example custom profile - De-Identified UDS Plus Patient. Start with a bundle resource definition (sample: ). Notice that the fullUrl and resource tables are empty.Image AddedGo to your reference and copy the Canonical url and JSON specification Image AddedUpdate the fullUrl value and load the custom profile into the resource table. Note that you may need to remove an extra set of curly brackets as the resource table’s brackets are equivalent to the ones in the JSON specification from the screenshot in the previous step Image AddedUpload the finished JSON (sample: View file |
---|
name | de-identified_uds_plus_patient.json |
---|
| ) into the Specifications/Custom folderImage Added
|
Expand |
---|
title | STEP 4: Create or Update the fhir_profiles database |
---|
| If this is the first time running the component, in the LoadDatabase function set:
clean to true to cleanup the resource.json and types.json files used to create the database
refresh to true to create or update the databaseSet the component to refresh the database if using a new FHIR version OR custom profiles |
|
This component processes and stores specification data in a SQLite database (Specifications/fhir_profiles.db) for easy access. If you wish to update the FHIR version and/or load any custom profiles into that database, set the custom field Refresh in the component card to “true” before starting the component. This flag tells the component to reference the specified FHIR version and any files in the Specifications/Custom folder and refresh the database on startup. |
Expand |
---|
title | STEP 5: Specify a list of resource schemas you wish to generate from your newly created profiles database |
---|
| Modify the ResourceList to include all of the FHIR Resources you wish to generate.
Code Block |
---|
|
local ResourceList = {
'Patient',
'Appointment'
} | Now that the component card has been configured to the correct FhirVersion and Refresh details, you can start the component! If the component was set with Refresh as true, it will take some time to initialize and load the database. It will reset the Refresh flag to false when done. Once ready, the component will provide a URL in the component status: Image Added |
Expand |
---|
title | STEP 6: Take a look at FHIRresoruces.lua - notice it contains all of the FHIR resource JSON schemas |
---|
|
Notice the FHIRresources.lua module contains JSON strings for each resource in your list. This file can now be used in other projects to create and map FHIR resources! Image Removed |
The FHIR Profiling Tool also contains an example of how to use the FHIRresources.lua and the FHIR Library to create FHIR resources.
Expand |
---|
title | Call FHIRcreate and specify the resource you wish to generate and map values into the FHIR JSON object |
---|
|
Code Block |
---|
| -- Create a Patient resource
local patient = FHIRcreate{resource='Patient'}
-- Populate the resource
patient.resourceType = "Patient"
patient.identifier[1].system = "https://radboud.nl/identifiers/PatientIdentifier"
patient.identifier[1].type.coding.system = "http://terminology.hl7.org/CodeSystem/v2-0203"
patient.identifier[1].type.coding.code = "MR"
patient.identifier[1].type.coding.display = "Medical record number"
patient.identifier[1].value = "1234"
patient.name.family = "test_ln"
patient.name.given = "test_fn"
patient.gender = "male"
patient.birthDate = "2001-10-10"
patient.address.use = "home"
patient.address.line = "123 street"
patient.address.city = "Seattle"
patient.address.state = "WA"
patient.address.postalCode = "98052"
patient.address.country = "USA" |
Using the annotations, click on the patient table generated by FHIRcreate, ready to be populated. Image Removed |
Expand |
---|
title | Use FHIRclean to remove empty nodes and serialize the resource as a string |
---|
|
Code Block |
---|
|
-- Clean and serialize the resource
FHIRclean(patient)
local NewPatientJson = json.serialize{data=patient}Click on the provided URL to use the tool |
| Clicking on the provided URL will take you to the FHIR Profiling Tool’s menu which contains a list of all the FHIR resources and types available in the SQLite database. Image AddedClicking on any of the links will trigger the tool to generate a template JSON for the specified FHIR resource or type: Image AddedYou can now copy the template JSON and bring it over to your FHIR component to use in your interface. See https://interfaceware.atlassian.net/wiki/x/AgBbrg for an example of how to use a FHIR JSON template to generate and map FHIR resources. |