示例fhir到transmart loader
fhir2transmart的Python项目详细描述
此包包含从HL7 FHIR(stu 3或r4)资源读取数据的映射程序 并将它们转换为TranSMART平台的数据模型, 一个用于转化生物医学研究的开源数据共享和分析平台。
它还提供了一个应用映射器并将转换后的数据写入制表符分隔的文件的实用程序。 可以使用transmart-copy工具将其加载到transmart数据库中。
fhir阅读器基于fhirclient包,向transmart的写入基于transmart-loader。
注:这是一个非常初步的版本,仍在开发中。 可在https://github.com/thehyve/python_fhir2transmart/issues报告问题。
安装
这个包需要Python3.6
要安装fhir2transmart,请执行以下操作:
pip install fhir2transmart
或来源:
git clone https://github.com/thehyve/python_fhir2transmart.git
cd python_fhir2transmart
pip install .
使用以下命令运行测试(包括覆盖率):
python setup.py test
用法
从json文件input.json读取输入并将输出写入transmart copy 格式化为/path/to/output。输出目录应该是 空的不存在(然后它将被创建)。
# 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-ontology选项,概念和本体节点 基于输入数据创建。本体时不要使用此选项 已单独加载
示例数据位于MITRE SyntheticMass。说明:
# 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
这将在output目录中生成目录i2b2metadata和i2b2demodata。 生成的数据可以使用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
映射
下表显示了FHIR资源如何映射到 Transmart数据模型。
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 |