Docs: Getting Started
Getting Started with oehrpy
oehrpy is a Python SDK for openEHR, the open standard for vendor-neutral electronic health records. It gives you type-safe Reference Model classes, template-based composition builders, canonical JSON and FLAT serialization, an async EHRBase client and an AQL query builder. New to openEHR? The openEHR workflow overview explains how templates, compositions and CDRs fit together.
Installation
Install oehrpy using pip:
pip install oehrpyOr install from source for development:
git clone https://github.com/platzhersh/oehrpy.git
cd oehrpy
pip install -e ".[dev]"Requirements: Python 3.10 or higher is required.
Quick Start
Here's a quick example to get you started with oehrpy:
from oehrpy.rm import DV_TEXT, DV_QUANTITY, CODE_PHRASE, TERMINOLOGY_ID
# Create a simple text value
text = DV_TEXT(value="Patient temperature recorded")
# Create a quantity with units
temperature = DV_QUANTITY(
magnitude=37.2,
units="°C",
property=CODE_PHRASE(
terminology_id=TERMINOLOGY_ID(value="openehr"),
code_string="127"
)
)
print(f"Temperature: {temperature.magnitude} {temperature.units}")Overview
oehrpy is a comprehensive Python SDK for openEHR that provides:
- Type-safe RM Classes: 134 Pydantic models for openEHR Reference Model 1.1.0 (includes BASE types)
- OPT Parser & Code Generation: Parse OPT 1.4 XML files and auto-generate type-safe Python builder classes
- Template Builders: Pre-built composition builders for common clinical templates
- FLAT Format Support: Full support for EHRBase FLAT format serialization
- Canonical JSON: Convert between RM objects and openEHR canonical JSON
- EHRBase Client: Async REST client for EHRBase CDR operations
- AQL Builder: Fluent API for building type-safe AQL queries
- Full IDE Support: Complete autocomplete and type checking
Guides
- Reference Model: the RM 1.1.0 classes, data types, validation and type safety
- Templates & Builders: parse OPT templates and build compositions
- Serialization: canonical JSON and the FLAT format
- EHRBase Client: EHRs, compositions and queries against EHRBase
- AQL Query Builder: build AQL queries without string concatenation
- FLAT & OPT Validation: catch template mismatches before the CDR does
- Development: set up, regenerate the RM classes, run the tests