Creating a composition for EHRBase

Hello,
As far as I understand there are two ways to commit a composition into EHRBase:
1- Through the SDK
2- Through the rest api using either the xml or the FLAT format.

According to the EHRBase documentation, a flat composition can be created using a web template by concatenating ids and suffixes.
However, I can’t figure out how that works in the following example:
This the relevant part of the Corona_Anamnese web template

"tree": {
        "id": "bericht",
        "name": "Bericht",
        "localizedName": "Bericht",
        "rmType": "COMPOSITION",
        "nodeId": "openEHR-EHR-COMPOSITION.report.v1",
        "min": 1,
        "max": 1,
        "localizedNames": {
            "de": "Bericht"
        },
        "localizedDescriptions": {
            "de": "Ein Dokument zur Übermittlung von Informationen an andere, meist als Antwort auf eine Anfrage."
        },
        "aqlPath": "",
        "children": [
            {
                "id": "category",
                "name": "category",
                "localizedName": "category",
                "rmType": "DV_CODED_TEXT",
                "min": 1,
                "max": 1,
                "aqlPath": "/category",
                "inputs": [
                    {
                        "suffix": "code",
                        "type": "CODED_TEXT",
                        "list": [
                            {
                                "value": "433",
                                "label": "event",
                                "localizedLabels": {
                                    "de": "event"
                                }
                            }
                        ],
                        "terminology": "openehr"
                    }
                ],
                "inContext": true
            }

And this is the corresponding part in the flat composition

"bericht/category|code": "433",
"bericht/category|value": "event",
"bericht/category|terminology": "openehr"

This example is from the postman collection provided by EHRBase. It seems to me that generating a flat composition only using its web template is not straightforward.

Thanks!

Hi Anas,

this is correct. Other implementations provide an “example enddoint” which gives you a list of most paths from the WebTemplate. For EHRbase, this will surely follow not too far away in the future. In the meantine, you could use an instance generator like the one from @pablo: CaboLabs openEHR Toolkit (CoT)

Submit the data as canonical JSON or XML and then retrieve the composition in the flat format. Surely not the most efficient way, but does the trick for now!

3 Likes

Thanks for the prompt reply!
I tried cabolabs free tools generating both the json and xml formats. When I send the composition to EHRBase I get an error.

For the json format I get:

{
    "error":"java.lang.IllegalArgumentException: Composition missing mandatory attribute: name",
    "status":"Bad Request"
}

For the xml format I get:

<?xml version='1.0' encoding='UTF-8'?>
    <Map>
        <error>
            class javax.xml.bind.JAXBElement cannot be cast to class
            com.nedap.archie.rm.RMObject (javax.xml.bind.JAXBElement and 
            com.nedap.archie.rm.RMObject are in unnamed module of loader
            org.springframework.boot.loader.LaunchedURLClassLoader @7a07c5b4)
        </error>
       <status>Internal Server Error</status>
    </Map>

@birger.haarbrandt @pablo Any idea how to fix this?
Thanks!

Hi Anas,

Can you attach the composition or a link in gist etc?

Ian

Hello Ian,
Please find attached the template and associated compositions
Corona_Anamnese.opt (1.1 MB)

Corona_Anamnese_composition.json (73.4 KB)

Corona_Anamnese_composition.xml (84.3 KB)

Hello Ian,

Please let me know if there are other options to look at. This is blocking me from moving forward.

Thank you!

Apoligies Anas - I started replying but forgot to press the post button :frowning:

The main issue you are getting is that the Cabolabs tool actually generates CONTRIBUTION objects, which are the wrappers sitting above a COMPOSITION (and which is generated automatically by the POST /composition call. The composition itself is in the data object within the CONTRIBUTION.

"data" : {
			"@xsi:type" : "COMPOSITION",
			"@archetype_node_id" : "openEHR-EHR-COMPOSITION.report.v1",
			"name" : {
				"value" : "Bericht"
			},
			"archetype_details" : {
				"archetype_id" : {
					"value" : "openEHR-EHR-COMPOSITION.report.v1"
				},
				"template_id" : {
					"value" : "Corona_Anamnese"
				},
				"rm_version" : "1.0.2"

The next issue is that the JSON is not completely conformant with current specs e.g. @archetype_nodeId rather than just archetype_node_id and @xsi:type rather than _type.

I corrected those and still could not get it to commit in a Better CDR, so there must be some other issues I missed and ran out of time but I have attached an example FLAT JSON, so hope that helps!!

response.json (37.1 KB)

Ian

1 Like