A package to generate FHIR Resources using a configuration file
Project description
FHIRGenerator
Python Package for FHIR Resource Generation
How to Use this Generator
Installation
This package requires Python 3.10 or higher. Installation can be done with pip
:
pip install fhirgenerator
Usage
The main form of usage is through the generateResources function:
from fhirgenerator import generateResources
output_bundle = generateResources(configuration_dictionary)
This function takes in a configuration dictionary. This is most easily stored in a JSON file, but can be declared within the Python file as well. An example configuration file can be found in the package repo at fhirgenerator/docs/example_config.json
. The below section will also go through what elements in the configuration represent.
Configuration for generateResources()
Meta/Patient Level Configuration
Key | Required? | Data Type | Description | Example |
---|---|---|---|---|
numberPatients |
Yes | integer | The number of patients you wish to generate | 10 |
ageMin |
Yes | integer | The minimum age of the patients you wish to generate | 0 |
ageMax |
Yes | integer | The maximum age of the patients you wish to generate | 89 |
genderMFOU |
Yes | list | A list of 4 values: the first represents the percentage of patients generated that have a Patient.gender of male , the second for a gender of female , the third for a gender of other , and the fourth for a gender of unknown |
[47, 47, 1, 5] |
startDate |
Yes | string | The beginning date of the range that the non-Patient resources will be generated in | "01-01-2022" |
days |
Yes | integer | The total length of time that the non-Patient resources will be generated for | 365 |
usCorePatient |
No | boolean | If included and is true , the Patient resource generated will be a US Core Patient (defaults to a base FHIR Patient) |
true |
bundleType |
No | string | If included and is transaction , the output for generateResources() will be of type transaction (defaults to a Bundle of type collection ) |
"transaction" |
resourceDetails |
Yes | list | See the below section on what data elements an object in the resourceDetails list could contain |
Resource Detail Object in resourceDetails
Configuration
Key | Resources Affected | Required? | Data Type | Description | Example |
---|---|---|---|---|---|
fhirResource |
All | Yes | string | This describes what you would like to generate. Currently supports:
|
"Observation" |
codes |
All | Yes | list of dict | This describes what possible codes you would like to populate the resources code element. For currently supported resource types, this is required (but may not be in the future when considering profiles that have a fixed code ). The dictionaries in this object will have two keys: system and code (the same format that a FHIR Coding datatype would have, with display being optional). |
[{ "system": "http://loinc.org", "code": "12345-6}] |
enumSetList |
Observation | No if minValue and maxValue exist |
list | Gives a list of possible Observation.value[x] choices that resources could have. Currently supported types include: CodeableConcept, Quantity, strings |
["1:8", "1:16", "1:32", 1:64"] |
minValue |
Observation | No if enumSetList exists |
integer | The minimum value for Observation.value[x] |
1 |
maxValue |
Observation | No if enumSetList exists |
integer | The minimum value for Observation.value[x] |
7 |
decimalValue |
Observation | No | integer | If exists, will determine how many decimal places the Observation.value[x] will contain (will be represented as valueQuantity ) |
1 |
unit |
Observation | No | string | If exists, will determine the valueQuantity 's unit, system, and code. Must be in the form of system^code^unit . |
"UCUM^in^inches" |
minOccurancesPerCycle |
All | Yes | integer | The minimum number of times this resource will appear in one cycle | 2 |
maxOccurancesPerCycle |
All | Yes | integer | The maximum number of times this resource will appear in one cycle | 3 |
cycleLengthInDays |
All | Yes | integer | This value divided by the days value will give you the total number of cycles. The total number of resources could therefore be within [minOccurancesPerCycle * (cycleLengthInDays/days), maxOccurancesPerCycle * (cycleLengthInDays/days)] (inclusive) |
365 |
US Core Support
Support currently exists for generating the following US Core STU4 Profiles:
- US Core Patient
- US Core Condition
- currently labels it as a
problem-list-item
for thecategory
with aclinicalStatus
ofactive
- to be US Core compliant, you must provide codes in the
resourceDetails
that are from the US Core Condition Code ValueSet (https://www.hl7.org/fhir/us/core/ValueSet-us-core-condition-code.html). Currently, the generator cannot choose a random code from this expansive list, so you must enter options in the configuration
- currently labels it as a
- US Core Lab Result Observation
- to be US Core compliant, you must provide codes in the
resourceDetails
that are from LOINC. Currently, the generator cannot choose a random code from all LOINC codes, so you must enter code options in the configuration
- to be US Core compliant, you must provide codes in the
- US Core Vital Signs
- US Core BMI
- US Core Head Circumference
- US Core Body Height
History
0.0.5
Improvements
- Updated README
- Added this History page
- Added Procedure, MedicationStatement, Encounter
- Added US Core BMI, Head Circumference (other vital signs in progress)
- Added associated tests for new profiles
- Added support for
unit
in configuration to specify a unit for avalueQuantity
(must be in formsystem^code^display
) - Added support for not including a
decimalValue
in configuration to create avalueInteger
(unless theres a unit, then it will create avalueQuantity
) - Expanded testing scripts to be more comprehensive
0.0.4
- Changed
enumSetList
in configuration to be a list and to include:- a list of titers (as strings) for a valueRatio
- a list of decimals for a valueQuantity
- a list of Codings for a valueCodeableConcept
- a list of strings (that are not titers) for a valueString (this is the default behavior if the
enumSetList
does not meet one of the above criteria)
- Improved testing scripts to be more comprehensive
0.0.3
- First working release of package
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for fhirgenerator-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cee99d5e809b251b6dd0cc480a332d3262de99a003c4afd33b9fe5ab77f5c176 |
|
MD5 | 45f8c5ad09b585d83548132f8d8ee958 |
|
BLAKE2b-256 | dc0996992df9912b66a4fe871101f577d211475962084f6234fe3d5fbd70561a |