FHIR to pandas.dataframe for AI and ML
Project description
:fire: fhiry - FHIR to pandas dataframe for data analysis, AI and ML
Open Source Python library for import of FHIR resources to pandas dataframe
Bulk data export using FHIR may be important if you want to export a cohort for analysis or machine learning. :fire: Fhiry is a python package to facilitate this by converting a folder of FHIR bundles/ndjson into a pandas data frame for analysis and importing into ML packages such as Tensorflow and PyTorch. Test it with the synthea sample or the downloaded ndjson from the SMART Bulk data server. Use the 'Discussions' tab above for feature requests.
Installation
pip install fhiry
Usage
Import FHIR bundles (JSON) from folder to pandas dataframe
import fhiry.parallel as fp
df = fp.process('/path/to/fhir/resources')
print(df.info())
Example source data set: Synthea
Jupyter notebook example: notebooks/synthea.ipynb
Import NDJSON from folder to pandas dataframe
import fhiry.parallel as fp
df = fp.ndjson('/path/to/fhir/ndjson/files')
print(df.info())
Example source data set: SMART Bulk Data Server Export
Jupyter notebook example: notebooks/ndjson.ipynb
Import FHIR Search results to pandas dataframe
Fetch and import resources from FHIR Search API results to pandas dataframe.
Documentation: fhir-search.md
Example: Import all conditions with a certain code from FHIR Server
Fetch and import all condition resources with Snomed (Codesystem http://snomed.info/sct
) Code 39065001
in the FHIR element Condition.code
(resource type specific FHIR search parameter code
) to a pandas dataframe:
from fhiry.fhirsearch import Fhirsearch
fs = Fhirsearch(fhir_base_url = "http://fhir-server:8080/fhir")
my_fhir_search_parameters = {
"code": "http://snomed.info/sct|39065001",
}
df = fs.search(resource_type = "Condition", search_parameters = my_fhir_search_parameters)
print(df.info())
Columns
- see df.columns
patientId
fullUrl
resource.resourceType
resource.id
resource.name
resource.telecom
resource.gender
...
...
...
Documentation
Contributors
- Bell Eapen |
- Markus Mandalka
- WIP, PR welcome, please see CONTRIBUTING.md
- using CC
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 Distributions
Built Distribution
Hashes for fhiry-2.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e9c52cfbdcd6d12bbfc0a3d603e84a132062a875abb2f0a12fd98c826c78d48 |
|
MD5 | a151008f8c451ed29ddfa986f2d9fb5e |
|
BLAKE2b-256 | ffd7b417f2865b91d465eef7b3f15e896f4f8d3b9cb9bfc75f9bccdc9f0d205f |