Metadata-Version: 2.4
Name: pyehr-openehr
Version: 0.0.5
Summary: Python implementation of the openEHR (R) standard
Project-URL: Homepage, https://github.com/henrydwright/pyehr
Project-URL: Issues, https://github.com/henrydwright/pyehr/issues
Author: Henry Wright
License-Expression: GPL-3.0-or-later
License-File: LICENCE
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Framework :: Flask
Classifier: Intended Audience :: Healthcare Industry
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.12.1
Requires-Dist: annotated-doc==0.0.4
Requires-Dist: annotated-types==0.6.0
Requires-Dist: antlr4-python3-runtime==4.13.2
Requires-Dist: antlr4-tools==0.2.2
Requires-Dist: anyio==4.12.1
Requires-Dist: attrs==25.3.0
Requires-Dist: blinker==1.9.0
Requires-Dist: certifi==2025.8.3
Requires-Dist: cffi==2.0.0
Requires-Dist: charset-normalizer==3.4.3
Requires-Dist: click==8.3.1
Requires-Dist: compress-pickle==2.1.0
Requires-Dist: coverage==7.11.3
Requires-Dist: cryptography==46.0.3
Requires-Dist: dnspython==2.8.0
Requires-Dist: elementpath==5.1.1
Requires-Dist: email-validator==2.3.0
Requires-Dist: fastapi-cli==0.0.20
Requires-Dist: fastapi-cloud-cli==0.10.1
Requires-Dist: fastar==0.8.0
Requires-Dist: flask==3.1.2
Requires-Dist: h11==0.16.0
Requires-Dist: httpcore==1.0.9
Requires-Dist: httptools==0.7.1
Requires-Dist: httpx==0.28.1
Requires-Dist: idna==3.10
Requires-Dist: iniconfig==2.0.0
Requires-Dist: install-jdk==1.1.0
Requires-Dist: itsdangerous==2.2.0
Requires-Dist: jinja2==3.1.6
Requires-Dist: jsonschema-specifications==2025.9.1
Requires-Dist: jsonschema==4.25.1
Requires-Dist: lz4==4.3.3
Requires-Dist: markdown-it-py==4.0.0
Requires-Dist: markupsafe==3.0.3
Requires-Dist: mdurl==0.1.2
Requires-Dist: mongomock==4.3.0
Requires-Dist: numpy==1.26.3
Requires-Dist: packaging==23.2
Requires-Dist: pluggy==1.4.0
Requires-Dist: pycparser==2.23
Requires-Dist: pydantic-core==2.41.5
Requires-Dist: pydantic-extra-types==2.11.0
Requires-Dist: pydantic-settings==2.12.0
Requires-Dist: pydantic==2.12.5
Requires-Dist: pygments==2.19.2
Requires-Dist: pymongo==4.15.5
Requires-Dist: pytest-cov==7.0.0
Requires-Dist: pytest==8.0.0
Requires-Dist: python-dotenv==1.2.1
Requires-Dist: python-multipart==0.0.21
Requires-Dist: pytz==2025.2
Requires-Dist: pyyaml==6.0.3
Requires-Dist: referencing==0.36.2
Requires-Dist: requests==2.32.4
Requires-Dist: rich-toolkit==0.17.1
Requires-Dist: rich==14.2.0
Requires-Dist: rignore==0.7.6
Requires-Dist: rpds-py==0.27.1
Requires-Dist: ruamel-yaml-clib==0.2.8
Requires-Dist: ruamel-yaml==0.18.5
Requires-Dist: semver==3.0.2
Requires-Dist: sentinels==1.1.1
Requires-Dist: sentry-sdk==2.49.0
Requires-Dist: shellingham==1.5.4
Requires-Dist: starlette==0.50.0
Requires-Dist: typer==0.21.1
Requires-Dist: typing-extensions==4.15.0
Requires-Dist: typing-inspection==0.4.2
Requires-Dist: uritools==4.0.2
Requires-Dist: urllib3==2.5.0
Requires-Dist: uvicorn==0.40.0
Requires-Dist: uvloop==0.22.1
Requires-Dist: watchfiles==1.1.1
Requires-Dist: websockets==16.0
Requires-Dist: werkzeug==3.1.5
Requires-Dist: xmlschema==4.3.1
Description-Content-Type: text/markdown

# pyehr - a Python implementation of the openEHR® standard

![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/henrydwright/pyehr/python-app.yml)

pyehr (on pypi, pyehr-openehr) is an open source Python implementation of the [openEHR® specification](https://specifications.openehr.org/start) 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

```python

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)

```python
print(json.dumps(text.as_json(), indent=1))
```
```json
{
 "_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
```python
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.

```python
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

```python
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.