fhiratwill
Deterministic, transport-neutral building blocks for assembling, terminology-binding, context-rebinding, and planning writes of FHIR R4 resources.
Alpha software. Generated resources remain untrusted until independently validated and reviewed for the intended clinical workflow.
Install
pip install fhiratwill
Python 3.11 or newer is required.
Assemble deterministically
from fhiratwill import assemble_bundle
entities = [
{"resourceType": "Patient", "instance": "subject", "keyword": "gender", "value": "female"},
{"resourceType": "Observation", "instance": "pulse", "keyword": "code", "value": "heart rate"},
{
"resourceType": "Observation",
"instance": "pulse",
"keyword": "valueQuantity",
"value": "72/min",
},
]
result = assemble_bundle(entities, seed="conversion-123")
bundle = result.bundle
Assembly keeps coded concepts as text, refuses unsafe coercions, records PHI-free notes, and produces stable UUIDs for a stable seed. It does not validate clinical truth.
Bind using your terminology adapter
Implement the async TerminologyClient protocol for your terminology service. The library
contains no HTTP client, URL, authentication, or credentials.
from fhiratwill import TerminologyClient, bind_bundle
async def bind(bundle: dict, terminology: TerminologyClient) -> dict:
result = await bind_bundle(bundle, client=terminology)
return result.bundle
Binding uses exact aliases from the packaged, reviewed concepts.yaml; it performs no
fuzzy or model-based coding. A candidate is added only after the adapter verifies it.
Original CodeableConcept.text is retained. Adapters must raise
TerminologyUnavailableError when no authoritative answer is available; outages
propagate and fail closed.
Rebind and compile a write plan
from fhiratwill import (
GENERIC_FHIR_TARGET,
SubjectContext,
compile_write_plan,
rebind_bundle,
)
context = SubjectContext(patient_ref="Patient/123", encounter_ref="Encounter/456")
rebound, notes = rebind_bundle(bundle, context)
plan = compile_write_plan(
bundle=bundle,
context=context,
conversion_id="conversion-123",
tenant_id="tenant-7",
descriptor=GENERIC_FHIR_TARGET,
)
Generated Patient and Encounter resources are always excluded. References are rebound only to caller-supplied context. The optional preflight adapter supports direct reads only—never identity search. Write plans contain deterministic idempotency keys and, when supported by the descriptor, a FHIR transaction Bundle.
Scope
This library:
- assembles grounded entity mappings into deterministic FHIR resources;
- verifies exact terminology candidates through a caller-provided adapter;
- checks and rebinds caller-supplied subject context; and
- compiles destination-neutral write plans.
This library does not submit data, authenticate to an EHR, host a terminology service, perform target HTTP calls, validate full FHIR conformance, provide clinical decision support, or establish HIPAA, GDPR, medical-device, or other regulatory compliance.
Development
python -m pip install -e ".[dev]"
ruff check .
mypy
pytest
python -m build
twine check dist/*
No publishing command is part of the development workflow. See CONTRIBUTING.md and
SECURITY.md before contributing.
License
Apache License 2.0.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fhiratwill-0.1.0.tar.gz.
File metadata
- Download URL: fhiratwill-0.1.0.tar.gz
- Upload date:
- Size: 22.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
310c1f6a4fdf82609f56340f6c6204aa53047d776be09acbfe7a68532e47a1e4
|
|
| MD5 |
b199bc1dbdb1246e0ea34af65c9a4d3c
|
|
| BLAKE2b-256 |
e5fbadba7da426b6d4b3c5000fe51f8e5cff21433c1951be9f4e41d1280d47b1
|
Provenance
The following attestation bundles were made for fhiratwill-0.1.0.tar.gz:
Publisher:
release.yml on Safwanmahmoud/fhirbridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fhiratwill-0.1.0.tar.gz -
Subject digest:
310c1f6a4fdf82609f56340f6c6204aa53047d776be09acbfe7a68532e47a1e4 - Sigstore transparency entry: 2737315961
- Sigstore integration time:
-
Permalink:
Safwanmahmoud/fhirbridge@c4b57d140d3eff202ea3cbfee1ffa997fae1b67d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Safwanmahmoud
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c4b57d140d3eff202ea3cbfee1ffa997fae1b67d -
Trigger Event:
release
-
Statement type:
File details
Details for the file fhiratwill-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fhiratwill-0.1.0-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b8a3e2f9bd9461cf33c79382bf39cefb57856c4d89b5b1647278330e02aefdb
|
|
| MD5 |
ab24b2d5b67a10f1849c9b2c1e3db922
|
|
| BLAKE2b-256 |
952a11fabdbdc23239f439a2cf627e1d7055576483069af22d86c7df8f7af9a2
|
Provenance
The following attestation bundles were made for fhiratwill-0.1.0-py3-none-any.whl:
Publisher:
release.yml on Safwanmahmoud/fhirbridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fhiratwill-0.1.0-py3-none-any.whl -
Subject digest:
1b8a3e2f9bd9461cf33c79382bf39cefb57856c4d89b5b1647278330e02aefdb - Sigstore transparency entry: 2737316157
- Sigstore integration time:
-
Permalink:
Safwanmahmoud/fhirbridge@c4b57d140d3eff202ea3cbfee1ffa997fae1b67d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Safwanmahmoud
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c4b57d140d3eff202ea3cbfee1ffa997fae1b67d -
Trigger Event:
release
-
Statement type: