OPT

OPT Generator

AM classes generated with the AM / RM Generator are used to read the OPT2 JSON files. The correct AM Release is used based on the information found in the OPT2.

Only a single line of code is needed to load an operational template:

fromjson-convert

This starts a cascade of fromJson() calls to read the entire JSON file:

fromjson-operational-template

...another level (loading 'original_language' from above):

fromjson-terminology-code

...code for reading HashMaps with generic types:

(there are 10 pages of code like this - who would want to write this by hand?
...and maintain release specific changes for every release?)

fromjson-hashmaps

OPT Usage

openEHR SDK for Operational Templates (OPT)

The idea is to have native classes that can be used by developers without requiring them to know anything about openEHR.

Instead of giving them the OpenAPI schema and asking them to send data to the openEHR CDR, let them use simple classes in their favorite programming language they are used to work with. These classes (SDK) take care of everything openEHR related and can be used in “frontend” languages that web developers are familiar with.

The RM classes are also generated and are imported in the first line of the screenshot below. The RM release (e.g. 1.1.0 in this case) is automatically looked-up from the OPT.

A sample code of how OPT model class is used:

builder-opt-usage

This is the BloodPressure class generated from the OPT:

builder-opt-generated1

There are 893 lines of similar classes - they stop when constrained RM data types are reached:

builder-opt-generated2

A sample code of how COMPOSITION model class is used:

builder-opt-composition-usage

This is the COMPOSITION class generated from the OPT:

builder-opt-composition-generated1

This is an OBSERVATION class generated from the OPT for blood pressure showing how toJson() methods add overridden properties to the standard RM OBSERVATION class:

builder-opt-tojson-blood-pressure-observation

And this is the resulting JSON:

builder-opt-composition-json

SDK as Dart

openEHR SDK for OPTs as Dart Code

Above are just a few screenshots. A complete SDK is available for the Vital signs template.

SDK as JSON

openEHR SDK for OPTs as JSON

In the SDK as a JSON you get all that was used for the above code as a nested (or flat) list of types (e.g. OO classes).

openEHR JavaScript SDK

openEHR SDK for JavaScript

JavaScript SDK for AM and RM classes.

Builder

Learn more about generating openEHR applications

Computable Specifications

Learn more about openEHR AM / RM generator

Programming Language

Learn more about languages supported by the openEHR SDK generator