Skip to main content

Example FHIR to TranSMART loader

Project description

Build status codecov PyPI PyPI - Downloads

This package contains a mapper that reads data from HL7 FHIR (STU 3 or R4) resources and translates them to the data model of the TranSMART platform, an open source data sharing and analytics platform for translational biomedical research.

It also provides a utility that applies the mapper and writes the translated data to tab-separated files that can be loaded into a TranSMART database using the transmart-copy tool.

The FHIR reader is based on the fhirclient package, writing to TranSMART is based on transmart-loader.

⚠️ Note: this is a very preliminary version, still under development. Issues can be reported at https://github.com/thehyve/python_fhir2transmart/issues.

Installation

The package requires Python 3.6.

To install fhir2transmart, do:

pip install fhir2transmart

Or from source:

git clone https://github.com/thehyve/python_fhir2transmart.git
cd python_fhir2transmart
pip install .

Run tests (including coverage) with:

python setup.py test

Usage

Read input from a JSON file input.json and write the output in transmart-copy format to /path/to/output. The output directory should be empty of not existing (then it will be created).

# Translate one json file
fhir2transmart [--with-ontology] input.json /path/to/output
# Translate all json files in a directory
fhir2transmart [--with-ontology] input_dir /path/to/output

With the --with-ontology option, concepts and ontology nodes are created based on the input data. Do not use this option when ontologies have already been loaded separately.

Example data is available at MITRE SyntheticMass. Instructions:

# Download 1K Sample Synthetic Patient Records, FHIR STU3 : 20MB
wget https://syntheticmass.mitre.org/downloads/2017_11_06/synthea_sample_data_fhir_stu3_nov2017.zip
# unzip creates a directory 'fhir' containing 282MB of json files
unzip synthea_sample_data_fhir_stu3_nov2017.zip
# create an output directory
mkdir output
# apply the mapping
fhir2transmart fhir output

This generates the directories i2b2metadata and i2b2demodata in the output directory. The generated data can be loaded using transmart-copy:

# Download transmart-copy:
curl -f -L https://repo.thehyve.nl/service/local/repositories/releases/content/org/transmartproject/transmart-copy/17.1-HYVE-5.9-RC3/transmart-copy-17.1-HYVE-5.9-RC3.jar -o transmart-copy.jar
# Load data
PGUSER=tm_cz PGPASSWORD=tm_cz java -jar transmart-copy.jar -d output

Mapping

The following mapping table shows how FHIR resources are mapped to the TranSMART data model.

FIHR

TranSMART

Resource type

attribute

Class

attribute

concept

modifier

Patient

identifier

PatientMapping

identifier

Patient

gender

Patient

sex

Patient

gender

Observation

value

Gender

Patient

birthDate

Observation

value

BirthDate

Patient

deceased

Observation

value

Deceased

Patient

deceasedDate

Observation

value

DeceasedDate

Condition

subject

Observation

patient

Condition

code

Observation

conceptCode

Condition

onsetDateTime

Observation

startDate

Condition

abatementDateTime

Observation

endDate

Condition

recordedDate

Observation

Condition

category

Encounter

identifier

Visit

Encounter

period.start

Visit

startDate

Encounter

period.end

Visit

endDate

Encounter

status

Visit

activeStatusCd

Encounter

class

Visit

inoutCd

Encounter

hospitalization

Visit

locationCd

Acknowledgement

This project was funded by the German Ministry of Education and Research (BMBF) as part of the project DIFUTURE - Data Integration for Future Medicine within the German Medical Informatics Initiative (grant no. 01ZZ1804D).

License

Copyright (c) 2019 The Hyve B.V.

The FHIR to TranSMART loader is licensed under the MIT License. See the file LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fhir2transmart-0.2.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

fhir2transmart-0.2.1-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file fhir2transmart-0.2.1.tar.gz.

File metadata

  • Download URL: fhir2transmart-0.2.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.6.7

File hashes

Hashes for fhir2transmart-0.2.1.tar.gz
Algorithm Hash digest
SHA256 427b9fdc316c893137d64f16d85c6a38ea3cdced09f89f03695b25d7acf7a056
MD5 68704ddf85c8680e44552d64a4552eb6
BLAKE2b-256 c00a33db8544d8ce0540775b7a14f37ff68cfdaa1f41e1e630c64ffdc647c3e4

See more details on using hashes here.

File details

Details for the file fhir2transmart-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: fhir2transmart-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.6.7

File hashes

Hashes for fhir2transmart-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cb8f7b0732ce0acc8c9b490a0b73fdfa58a1b415bfa56ef87f6d423d1f500721
MD5 69c05951390265428e939057097792af
BLAKE2b-256 1a9914289e1740b2786f28a56a45918c61f37c6c9d19d94147e2389986cdf242

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page