184.108.40.206. Composition Endpoint¶
DefaultRestClient includes a
with the following functionalities.
220.127.116.11.1. Commit composition¶
Committing a composition is done using the
Its idea is that the client already works with an instance of the composition
(of a generated template entity type, like described here).
For example, a new instance could be created and modified to contain two values entered via a user interface. This object now might only contain those two values, and a representation of the structure of the composition (as generated type/class definition).
Despite that this simplified example only mentions two values, it is still necessary to provide data to all fields, which are required as per openEHR Reference Model. Otherwise the backend server might reject the payload as invalid.
Afterwards, calling the
mergeCompositionEntity method would commit the composition to the server.
Before returning data, this method also processes the server response to enrich the given composition object.
Specifically, server-side created data values like the composition’s Version Uid are written into the object.
Therefore, and after successful execution, the method returns a representation of the composition as it is now persisting on the backend server.
A very simplified example could look like:
// Initializing the object EhrbaseBloodPressureSimpleDeV0Composition composition = new EhrbaseBloodPressureSimpleDeV0Composition(); // Adding values [...].setSystolicMagnitude(120.0); [...].setSystolicUnits("mm[Hg]"); [...].setDiastolicMagnitude(120.0); [...].setDiastolicUnits("mm[Hg]"); // Committing and altering the object with the response data client.compositionEndpoint(ehrId).mergeCompositionEntity(composition); // For instance, the specific Version UID can now be accessed composition.getVersionUid();
18.104.22.168.2. Find composition¶
To retrieve the latest version of a specific composition -
or to get response that allows to understand that no such composition exists -
find method can be used.
The usage is illustrated in the following example:
UUID compositionId = $COMPOSITION_ID; Optional<EhrbaseBloodPressureSimpleDeV0Composition> compo = compositionEndpoint .find(compositionId, EhrbaseBloodPressureSimpleDeV0Composition.class);