Health and Fitness

How to Read and Check a FHIR Bundle in JSON or XML

What FHIR resources and Bundles are, how references and required elements work, a worked example with common errors, and how JSON maps to FHIR XML.

Saizul Amin
Saizul Amin7 Nov 2026 · 4 min read
How to Read and Check a FHIR Bundle in JSON or XML

How to Read and Check a FHIR Bundle in JSON or XML

FHIR, short for Fast Healthcare Interoperability Resources, is the HL7 standard behind most modern health APIs. Patient access apps, national record services and many hospital integrations exchange FHIR resources. If you build or test one of these connections, you will spend a lot of time reading JSON payloads and asking whether they are shaped correctly.

Resources and Bundles

A resource is one record of a defined type, such as Patient, Observation, Condition, Encounter or MedicationRequest. Every resource names its type in resourceType and usually has an id. The specification lists the elements of each type, with a cardinality that says whether an element is required and whether it can repeat. An Observation, for example, must have a status and a code.

A Bundle is a resource that holds other resources in an entry list. Each entry can have a fullUrl, often a urn:uuid value, and a resource. A Bundle's type says what it is for: collection simply groups resources, searchset is a search result, and transaction or batch asks a server to process each entry, in which case each entry also needs a request element.

Resources point at each other through references. A reference can be relative, like Patient/pat-1, a urn:uuid that matches an entry's fullUrl, an absolute web address or a hash that points at a contained resource inside the same record.

Worked example

The FHIR Resource Viewer and Validator has a sample collection Bundle with 5 entries: a Patient, two Observations, a Condition and a MedicationRequest. With the Bundle itself, the Resources table lists 6 rows.

The Patient, pat-1, is summarised as Jordan A Sample, female, 1985-04-12. The first Observation, obs-chol, has status final, a LOINC code and a value of 5.2 mmol/L. Its subject reference is the urn:uuid fullUrl of the Patient entry, and since that matches, there is nothing to report.

The second Observation, obs-hdl, has two problems. Its status is done, which is not one of the Observation status codes such as registered, preliminary, final or amended. Its effectiveDateTime is 05/11/2026, a local date style, whereas FHIR expects 2026-11-05 or a full timestamp such as 2026-11-05T10:00:00Z. Its subject is Patient/pat-1, a relative reference that the viewer resolves against the Patient's type and id.

The MedicationRequest, med-1, for Atorvastatin 20 mg tablets, is active with intent order, but its subject points at Patient/pat-2. No resource in the file has that id, so the viewer reports that the reference is not in this file and may live on a server. In a collection sent between two systems that is usually a mistake; in a search result it may be normal.

That gives 3 issues in total, all listed in the summary and against their own resource.

JSON and XML

FHIR defines both a JSON and an XML form, and some systems still require XML. In XML, primitive values are written as value attributes, so the family name becomes <family value="Sample"/>. Repeating elements are written once per item, nested resources inside a Bundle entry sit inside a resource element, and the root element carries the FHIR namespace. The viewer converts JSON to XML in this way and also reads XML and shows it as JSON.

One detail matters for strict systems. FHIR XML expects elements in the order the specification defines, while JSON order is free. The conversion keeps the JSON order, so if a server's schema check complains, reorder the elements or produce the XML from a library that knows the definitions.

Common mistakes

Local date formats. Dates must be YYYY, YYYY-MM or YYYY-MM-DD, and dateTimes with a time must include a time zone offset or Z.

Made-up status values. Status elements are bound to fixed code lists. Words like done, closed or ok are rejected by servers even if humans understand them.

Dangling references. Every reference in a transaction Bundle should resolve either inside the Bundle or on the target server. A typo in an id is easy to miss by eye.

Plain text in coding.system. A system must be a URI such as http://loinc.org, not just the word LOINC.

Treating basic checks as full validation. These checks catch common structural faults. For profiles such as US Core or UK Core, value sets and invariants, run the official HL7 FHIR validator as well.

Where this fits

Use the viewer as a first look, to see what a payload holds and catch obvious faults, before the fuller validation and testing your project requires. It is a structure tool and does not interpret any clinical values.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages