openEHR Workflow
Where oehrpy fits in the openEHR data lifecycle — from clinical modelling to querying patient data. Phases highlighted in blue are handled by oehrpy.
Phase 1
Modelling
Outside oehrpy
Archetype Designer
Define archetypes & templates using clinical modelling tools (e.g. Better Archetype Designer)
Export .opt
Export an Operational Template (
.opt) file from the modelling tool
Phase 2
CDR Upload
Outside oehrpy
Upload Template
Upload the
.opt to your CDR (e.g. EHRBase) via its admin APIWeb Template
CDR generates a Web Template with FLAT paths and constraints
oehrpy scope
Phase 3
App Development
oehrpy
Parse OPT
Parse
.opt files with OPTParser to extract template metadataFetch Web Template
Get Web Template JSON from CDR with
get_web_template() for FLAT paths (ADR-0005)Generate Builder
Generate metadata-only builder skeletons with
BuilderGenerator; FLAT paths from Web TemplateValidate Template
Validate OPT files against RM spec using
OPTValidatorValidate Composition
Catch FLAT path errors before submission with
FlatValidator
Phase 4
Write Composition
oehrpy
Template Builder
Construct compositions with type-safe builders (e.g.
VitalSignsBuilder)FLAT Format
Build FLAT compositions with
FlatBuilder using dot-separated pathsCanonical JSON
Serialize RM objects to openEHR canonical JSON with
_type fieldsSubmit to CDR
Send compositions via
EHRBaseClient async REST client
Phase 5
Read / Query
oehrpy
AQL Builder
Build type-safe AQL queries with
AqlBuilder fluent APIExecute Query
Run AQL queries against the CDR via
EHRBaseClientDeserialize
Parse query results back into typed RM objects for processing
Format Reference
.opt
Operational Template — XML file exported from modelling tools
Web Template
CDR-generated JSON with FLAT paths and constraints
FLAT
Dot-separated paths like
bp:0/systolic|magnitude
Canonical JSON
Hierarchical JSON with
_type discriminator fields
AQL
Archetype Query Language for retrieving clinical data
RM
Reference Model — 134 Pydantic classes for openEHR 1.1.0
oehrpy scope (Phases 3–5)
External tools (Phases 1–2)