Example FHIR to TranSMART loader
Project description
This package contains a mapper that reads data from HL7 FHIR (STU 3 or R4) resources and translates them to the data model or 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.
⚠️ 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_transmart_loader.git
cd python_transmart_loader
pip install .
cd examples/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
python -m fhir2transmart.fhir2transmart input.json /path/to/output
# Translate all json files in a directory
python -m fhir2transmart.fhir2transmart input_dir /path/to/output
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
python -m fhir2transmart.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 |
identifier |
PatientMapping |
identifier |
|||
gender |
Patient |
sex |
|||
gender |
Observation |
value |
Gender |
||
birthDate |
Observation |
value |
BirthDate |
||
deceased |
Observation |
value |
Deceased |
||
deceasedDate |
Observation |
value |
DeceasedDate |
||
subject |
Observation |
patient |
|||
code |
Observation |
conceptCode |
|||
onsetDateTime |
Observation |
startDate |
|||
abatementDateTime |
Observation |
endDate |
|||
recordedDate |
Observation |
||||
category |
|||||
identifier |
Visit |
||||
period.start |
Visit |
startDate |
|||
period.end |
Visit |
endDate |
|||
status |
Visit |
activeStatusCd |
|||
class |
Visit |
inoutCd |
|||
hospitalization |
Visit |
locationCd |
License
Copyright (c) 2019, The Hyve
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
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
Built Distribution
Hashes for fhir2transmart-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e7e483a8feb45c56eceb83e8380a79f9a412fe00ff676dade4c257fff3ade1b |
|
MD5 | 3637921a399b1ae41bffd5e0ab9b7f62 |
|
BLAKE2b-256 | 896c97d7092663a2240f6d673673f813107deaece3862a586863640fa9c314bc |