Skip to main content

pyehr - a Python implementation of the openEHR® standard

GitHub Actions Workflow Status

pyehr (on pypi, pyehr-openehr) is an open source Python implementation of the openEHR® specification from the ground up in pure Python.

⚠️ Warning: pyehr is under active development and no stable release is available. Though some parts of the core are stable enough, both client and server are liable to change substantially.

pyehr is formed of three parts:

  • core - implementation of object model of BASE, RM, AM, etc. in Python
  • client - used for interacting with OpenEHR REST API servers
  • server - basic Flask-based implementation of the server standard

pyehr.core

pyehr provides an implementation of the following parts of the specification which are used by both the client and the server, and many users may wish to use in a standalone manner.

Features:

  • Work in the RM natively in Python with validation of invariants
text = DVText(
    value="Hello, world!",
    language=CodePhrase(
        terminology_id=TerminologyID("ISO_639-1"),
        code_string="en-gb",
        preferred_term="English (United Kingdom)"
    )
)
  • Serialise all classes to spec-compliant JSON (with '_type' markers)
print(json.dumps(text.as_json(), indent=1))
{
 "_type": "DV_TEXT",
 "value": "Hello, world!",
 "language": {
  "_type": "CODE_PHRASE",
  "terminology_id": {
   "_type": "TERMINOLOGY_ID",
   "value": "ISO_639-1"
  },
  "code_string": "en-gb",
  "preferred_term": "English (United Kingdom)"
 }
}
  • Use methods as described in the spec across classes
from pyehr.core.rm.data_types.quantity.date_time import DVDate, DVDuration

start_date = DVDate("2026-05-07")
duration = DVDuration("P1Y2M6D")
new_date = start_date + duration
print(str(new_date)) 

Support level

Specification part Status
Base model (BASE) ✅ Complete
Reference model (RM) ✅ Complete (aside from rm.extract and rm.integration)
Implementation technology (ITS) - JSON ✅ Serialisation and deserialisation complete and stable for all implemented classes
Archetype model (AOM v1.4 and OPT v1.4) 🟠 Partial implementation for serialisation/deserialisation but methods unimplemented
Implementation technology (ITS) - XML 🟠 Some support for parsing AOM v1.4 archetypes and templates, limited support elsewhere
Archetype model (AOM v2) ❌ Unsupported
Archetype model (ADL v1.4 or ADL v2) ❌ Unsupported

pyehr.client

pyehr provides both a transactional REST API client as well as a more sophisticated client for working more easily with versioned objects.

Features:

  • Transactional clients for /ehr and /demographic endpoints.
from pyehr.client.ehr import OpenEHREHRRestClient, OpenEHRRestClientResponse

client = OpenEHREHRRestClient(
    base_url="https://sandbox.ehrbase.org/ehrbase/rest/openehr/v1"
)

response : OpenEHRRestClientResponse = client.ehr.create_ehr()

print(response.pyehr_obj[0].as_json())
  • More object-oriented client for working with versioned objects more natively
from pyehr.client.change_control import VersionedStoreClient

store = VersionedStoreClient(
    base_url="http://localhost:5000"
)

p1 = ...

log.info("Create PERSON in store")
object_version_id, contribution, versioned_object = store.create(
    obj=p1,
    owner_id=ObjectRef("local", "EHR", GenericID("null", "null")),
    committer=PartySelf(),
    lifecycle_state=VersionLifecycleState.INCOMPLETE
)

pyehr.server

pyehr provides an under-development Flask-based server with accompanying database and authentication backends.

Disclaimer

openEHR® is the registered trademark of the openEHR Foundation and is used with the permission of openEHR International. Use of the trademark does not constitute endorsement of this product by openEHR International or openEHR Foundation.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyehr_openehr-0.1.4.tar.gz (316.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyehr_openehr-0.1.4-py3-none-any.whl (251.8 kB view details)

Uploaded Python 3

File details

Details for the file pyehr_openehr-0.1.4.tar.gz.

File metadata

  • Download URL: pyehr_openehr-0.1.4.tar.gz
  • Upload date:
  • Size: 316.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for pyehr_openehr-0.1.4.tar.gz
Algorithm Hash digest
SHA256 72e475e6956ba193bf1db3b6e040baf680c19ab75cc6bc825ed5c3d9e0142758
MD5 d8920b99e60c56a64b642c405170f586
BLAKE2b-256 e0e63d1ac233ce95b58d6793b043bfea51f2b119805fd04771ab854d1e696d28

See more details on using hashes here.

File details

Details for the file pyehr_openehr-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: pyehr_openehr-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 251.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for pyehr_openehr-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 92be795733501a303b766657240c4583ceba88cded024adbff1e2974fa06261f
MD5 d571e751ae4bda3372497f9295c07cd6
BLAKE2b-256 b31e1c264581f6d08b37634d367560bd518e07d7fc0638af77ae6b53aa5e12a9

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

This release

0.1.4 This release

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page