axelv / fhir-py-types

Convert FHIR StructureDefinition to Python type annotations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

build status Supported Python version

Quick start

Download StructureDefinition bundle and build type definitions from it:

git clone --depth 1 https://github.com/beda-software/fhir-py-types.git
cd fhir-py-types/spec/
sh download_spec_bundle.sh
cd ..
docker compose up

The generated type definitions can then be found in generated/resources.py.

How it works

The build process is based on the standard StructureDefintion resource (available in JSON format from the FHIR download page, direct link at the time of writing).

Contributing

The project uses poetry for package management.

Type definitions can be generated by running:

poetry install
poetry run typegen --from-bundles spec/fhir.types.json --from-bundles spec/fhir.resources.json --outfile generated/resources.py

Where spec/fhir.types.json and spec/fhir.resources.json are bundles of StructureDefinition resources.

Type check definitions (the very first type checking process might take a while to complete, consecutive runs should be faster)

poetry run mypy generated/resources.py

About

Convert FHIR StructureDefinition to Python type annotations

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 95.2%Language:Shell 3.4%Language:Dockerfile 1.5%