Canonical Json / XML example with EHRBase

Hello,

I am just starting with openEHR and EHRBase and trying to post a composition using REST-API
(POST /ehr_id/composition) but always get some or the other error. I understand that the api uses canonical json, but I am not able to generate one ( from template) or find any sample. Can someone share a sample template and canonical json or canonical xml, postman collection will be much appreciated. thanks in advance!

Ritika Jain
Philips Healthcare

1 Like

Hi Ritika,

We are also facing similar issue, we posted an OPT template and then posted a JSON with some data, both of which can be found here:
Templates and JSON

I am getting a 204 response when i post the Person JSON

And we don’t know how to actually post content for a person, we haven’t found any JSON with content

And for Corona_Anamnese
I am getting the following error:

Even thought the name attribute is present in the request as highlighted.

If this can help you in anyway and you if you find any JSON with content please let me know.

Thanks,
Venky.
Philips Healthcare.

Hi both,

we got some examples in this postman library that is part of the EHRbase documentation: documentation/examples at master · ehrbase/documentation · GitHub

Might need an update, but I hope this helps you to get started. In general, I recommend to not build the canonical formats (XML and JSON) by hand, as this is not how it is intended.

Please take a look at the openEHR Software Development Kit:

This includes further examples, especially for the flat formats which are way easier to create from a frontend developers perspective. There is also a function to automatically create DTO classes from openEHR Templates. Please check the documentation for further details: 4. SDK — EHRbase documentation

We have an example generator on the roadmap for EHRbase to make beginners life easier. I hope that we can provide this new feature within the next 3 months. In the meantime, you might want to check @pablo’s tools to generate test data: CaboLabs openEHR Toolkit (CoT)

Hope this helps :wink:

Edit: there is also this postman library with more examples for the flat format https://discourse.openehr.org/uploads/short-url/seVAphaSVEz2c22d2Ta1VthWX4X.json

1 Like

HI Ritika, you can use the openEHR Toolkit to generate a canonical JSON with random data from an OPT: https://toolkit.cabolabs.com/

I’ve been using it to generate test COMPOSITIONs for EHRBASE and EHRServer for a while now. Note the canonical XML is also an accepted format.

1 Like

Hi Venky, it seems you are posting a VERSION to the COMPOSITION endpoint.

Try to post the COMPOSITION object alone, without the VERSION container.

Also, it seems that JSON is not canonical: is using the XML attributes @xsi:type. That would be accepted in EHRServer but is not accepted in EHRBASE. In EHRBASE you should use canonical JSON or XML, in canonical JSON the @xsi:type would be _type.

In summary:

  1. use COMPOSITION instead of VERSION
  2. use canonical JSON or XML

Hope that helps.

PS: maybe EHRBASE is missing some type checking there.

1 Like