Assembling fhir bundles
Package multiple FHIR R4 resources produced from OpenMed output into a single valid transaction Bundle ready to POST to an EHR.
Safety check
- Claude rated it 6 out of 10, under our bar of 7, so we do not sell it. It is a free link to its author.
An automated scan lowers risk but cannot promise zero risk. How we check skills
Preview
The first lines of SKILL.md
---
name: assembling-fhir-bundles
description: "Package multiple FHIR R4 resources produced from OpenMed output into a single valid transaction Bundle ready to POST to an EHR, using OpenMed's verified bundle assembler openmed.clinical.exporters.fhir.to_bundle. Covers deterministic urn:uuid fullUrls, automatic in-Bundle reference rewriting, request blocks (method/url) for transaction vs batch, and conditional create. Use after exporting-to-fhir when the user has several Condition/Observation/MedicationStatement resources and wants one transaction Bundle, mentions Bundle, transaction, references, or posting to a FHIR server. Builds on exporting-to-fhir; pairs after."
license: Apache-2.0
metadata:
project: OpenMed
category: fhir-interop
pairs: after
version: "1.0"
---
# Assembling FHIR Bundles
A FHIR server ingests one **transaction Bundle**, not loose resources, and the
resources inside it must cross-reference each other (`Condition.subject` →
Patient, `Observation.encounter` → Encounter, `DiagnosticReport.result` →
Observation). OpenMed ships a **deterministic, mechanical** Bundle assembler —
`openmed.clinical.exporters.fhir.to_bundle` — that wraps the resources you built
in `exporting-to-fhir` into a valid R4 Bundle and wires up the references.
## When to use
Use after you have a *list* of standalone resources from `exporting-to-fhir` and
the destination is a FHIR server. Reach for it when the user says "build a
Bundle", "transaction", "POST these resources", or needs internal references
resolved. To check the Bundle against US Core, hand off to `validating-us-core`.
## What OpenMed gives you (verified API)
```python
from openmed.clinical.exporters.fhir import to_bundle, deterministic_fullurl
bundle = to_bundle(
resources, # Sequence[Mapping] each with a resourceType
doc_id="note-2024-03-02-001", # seeds stable urn:uuid fullUrls
bundle_type="transaction", # "transaction" | "batch" | "collection" | ...
)
```
`to_bundle` does exactly three things, and **never** synthesises or validates:
...From maziyarpanahi's repository, Apache-2.0 licence.