Skip to main content

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

fhiratwill-0.1.0.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fhiratwill-0.1.0-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

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

Hashes for fhiratwill-0.1.0.tar.gz
Algorithm Hash digest
SHA256 310c1f6a4fdf82609f56340f6c6204aa53047d776be09acbfe7a68532e47a1e4
MD5 b199bc1dbdb1246e0ea34af65c9a4d3c
BLAKE2b-256 e5fbadba7da426b6d4b3c5000fe51f8e5cff21433c1951be9f4e41d1280d47b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for fhiratwill-0.1.0.tar.gz:

Publisher: release.yml on Safwanmahmoud/fhirbridge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for fhiratwill-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1b8a3e2f9bd9461cf33c79382bf39cefb57856c4d89b5b1647278330e02aefdb
MD5 ab24b2d5b67a10f1849c9b2c1e3db922
BLAKE2b-256 952a11fabdbdc23239f439a2cf627e1d7055576483069af22d86c7df8f7af9a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for fhiratwill-0.1.0-py3-none-any.whl:

Publisher: release.yml on Safwanmahmoud/fhirbridge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.0

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page