Name: django-openehr
Owner: Open Health Care
Description: experimental django models based on openehr archetypes
Created: 2018-01-17 17:23:24.0
Updated: 2018-03-16 12:25:09.0
Pushed: 2018-03-16 12:25:08.0
Homepage: null
Size: 113
Language: Python
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Experimental | Not officially supported by OHCUK
Experimental Django models based on openEHR archetypes and distributed as a Python Package on PyPi, with an accompanying demo Django application, showing the implementation of a single openEHR Template as a Django Form composed of data fields from the correct underlying openEHR Archetypes, as defined in the Template on the UK Apperta Clinical Knowledge Manager
The intentions of the experiment are:
| Django Form | openEHR Template | |——|———-| | IDCR template | IDCR Transfer of Care summary (minimal).v0 |
| Django Model | openEHR Archetype | | ————-| —————– | | models/address_details.py | openEHR-EHR-CLUSTER.address.v1 | | models/adverse_reaction.py | openEHR-EHR-EVALUATION.adverse_reaction_uk.v1 | | models/clinical_synopsis.py | openEHR-EHR-EVALUATION.clinical_synopsis.v1 | models/demographic_personal.py | openEHR-EHR-CLUSTER.individual_personal_uk.v1 | | models/demographic_professional.py | openEHR-EHR-CLUSTER.individual_professional_uk.v1 | | models/inpatient_admission.py | openEHR-EHR-ADMIN_ENTRY.inpatient_admission_uk.v1 | | models/person_name.py | openEHR-EHR-CLUSTER.person_name.v1 | | models/problem_diagnosis.py | openEHR-EHR-EVALUATION.problem_diagnosis.v1 | | models/reason_for_encounter.py | openEHR-EHR-EVALUATION.reason_for_encounter.v1 | | models/relevant_contact.py | openEHR-EHR-ADMIN_ENTRY.relevant_contact_rcp.v0 | | models/symptom_sign/py | openEHR-EHR-CLUSTER.symptom_sign.v1 | | models/telecom_details.py | openEHR-EHR-CLUSTER.telecom_uk.v1 | | models/therapeutic_direction.py | openEHR-EHR-CLUSTER.therapeutic_direction.v1 |
all data from each CKM archetype has been retained as comments in the respective Django model file
| Django Model | openEHR Reference Model artefact | |————–|———————————-| | DV_IDENTIFIER | models/identifier.py |
For this experiment/proof of concept, we have attempted to emulate in Django the two-level clinical modelling paradigm of openEHR (archetypes and templates), a paradigm which is also shared by other clinical modelling technologies such as FHIR (resources and profiles)
openEHR Archetypes have been recreated as Django models. In Django (as in many web frameworks), models are Classes, instances of which can be assigned data attributes, and these data attributes for a given instance map to a given row in a database table. Django contains an object-relational mapper (ORM) which handles this abstraction automatically, and numerous convenience methods which simplify access to related objects through foreign key or join-table relationships.
openEHR Templates have been rendered as Django Forms, which form the second layer of our modelling tooling, allowing constraint and specialisation of our Django model (= our archetype)
Practically, in the absence of an automatable mechanism for creating Django forms from openEHR archetypes, we simply copied and pasted the text from the 'Data' tab of the UK openEHR Clinical Knowledge Manager for each archetype into a text editor. We then reformatted the archetype into a Django model (or model_s_), mapping field types, validations, maxima and minima into their Django idiomatic equivalents. We kept as much contextual information as possible in #comment
form.
Models were quite large and therefore for better readbility and also in an effort to optimise the re-use potential of the models, they have been separated out from models.py
into individual files under the /models/
directory, importable as a module because of the __init__.py
containing an __all__
list.
openEHR implementations tend to store data in documents rather than in relational tables, hence it's possible that in the conversion of Archetypes to Django models we will encounter modelled entities which are impractical to model in a relational fashion, however so far we've been able to model most things that made sense to model.
install django_openehr
oradd django_openehr
to your requirements.txt file, and then run
install -r requirements.txt
django_openehr
to the INSTALLED_APPS list in settings.pyon manage.py makemigrations
on manage.py migrate
on manage.py runserver
on manage.py shell
django_openehr import models
models.PersonName.objects.first().given_name
cus'