Add a composition to a folder via openEHR REST API

Sorry I’m being dumb but I can see a way to allocate a composition to a folder in the REST API - help?

1 Like

Since the Directory endpoint always updates the whole structure you simple put it in the Folder structure which represents the directory .

So call EHR API openEHR specs

with

{
  "_type": "FOLDER",
  "name": {
    "_type": "DV_TEXT",
    "value": "root"
  },
  "archetype_node_id": "openEHR-EHR-FOLDER.generic.v1",
  "folders": [
    {
      "_type": "FOLDER",
      "name": {
        "_type": "DV_TEXT",
        "value": "history"
      },
      "archetype_node_id": "openEHR-EHR-FOLDER.generic.v1",
      "folders": [
        {
          "_type": "FOLDER",
          "name": {
            "_type": "DV_TEXT",
            "value": "family"
          },
          "archetype_node_id": "openEHR-EHR-FOLDER.generic.v1",
          "items": [
            {
          		"id": {
          			"_type": "HIER_OBJECT_ID",
          			"value": "d936409e-901f-4994-8d33-ed104d46015b"
          		},
          		"namespace": "my.system.id",
          		"type": "VERSIONED_COMPOSITION"
          	}
          ]
        }
      ]
    }
  ]
}

see also https://github.com/ehrbase/integration-tests/blob/main/tests/robot/DIRECTORY_TESTS/UPDATE_DIRECTORY/H.1__EHR_with_directory.robot

2 Likes

so

  1. Create Directory if not exists.
  2. get old Directory from openehr server
  3. edit the json representing the Directory
  4. Update the whole structure.

The ehrbase sdk has some tools to help with that https://github.com/ehrbase/openEHR_SDK/blob/develop/client/src/test/java/org/ehrbase/openehr/sdk/client/openehrclient/defaultrestclient/DefaultDirectoryCrudEndpointTestIT.java

4 Likes

SEC might want to have a look at adding an endpoint that edits specific FOLDERs. Similar to what we do with compositions. Especially in complex systems with authorisations per FOLDER this is an issue. But it’s also error pronken I think to let every client always change the entire directory.

2 Likes

Yes you are right, that’s on the REST “roadmap” actually, and requires RM 1.1.0+.

2 Likes

That has been already discussed. We proposed an API for that, I think there is a ticket on the openEHR JIRA.

1 Like

Might my question How to retrieve and update a subfolder in the FOLDER Structure? be related to this?

Related JIRA ticket Issue navigator - openEHR JIRA

1 Like

Thanks a lot, @pablo.