oehrpy

openEHR Canonical JSON ⇄ FLAT Converter

Turn a Canonical JSON composition into EHRBase or Better FLAT, or unfold FLAT paths into a tree. Converts as you type, fully client-side.

How it works ↓
Mode
Platform
No :0 index on single-occurrence nodes
InputCANONICAL JSON
OutputFLAT
Output will appear here as you type...
Ready

Canonical JSON and FLAT: the same composition, two shapes

openEHR compositions are usually exchanged in one of two JSON formats. Canonical JSON is the standard serialization of the Reference Model: a deep tree where every object carries its _type. FLAT (the "simplified" format used by EHRBase and Better) is a single map of path|attribute keys to values, such as vital_signs/blood_pressure/systolic|magnitude: 120. It is much easier to build by hand or from a form.

This converter flattens a Canonical JSON composition into FLAT, so you can see how a stored composition maps onto the FLAT paths your application writes, and unfolds a FLAT composition into a tree so you can inspect its structure. It does not convert FLAT back to Canonical JSON.

How to use it

  1. Pick a mode: Canonical → FLAT to flatten a composition, or FLAT → Tree to see a FLAT composition as a nested structure.
  2. Pick the platform dialect: EHRBase 2.x or Better.
  3. Paste your JSON, or click Load Example. The output updates as you type; copy it with one click.

FAQ

Where do I get a Canonical JSON composition?

Fetch it from your CDR, e.g. EHRBase GET /rest/openehr/v1/ehr/{ehr_id}/composition/{uid} with Accept: application/json.

Are the generated FLAT paths guaranteed to be valid?

FLAT paths depend on the template, so check the result with the FLAT validator against the template's Web Template before posting it to a CDR.

Can I do this in Python?

Yes. oehrpy's serialization layer converts RM objects to and from Canonical JSON and FLAT. See the serialization guide.

Is my data uploaded anywhere?

No. The conversion runs entirely in your browser.