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!
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)
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:
use COMPOSITION instead of VERSION
use canonical JSON or XML
Hope that helps.
PS: maybe EHRBASE is missing some type checking there.
I believe you are talking about CaboLabs openEHR Toolkit this particular toolkit but for some reason I am not able to post the output composition of this tool. I am pretty sure it is not canonical, can your suggest some other ways to convert templates to flat forms