Hi Ohia,
You can make a POST request like this:
ehrbase-test-system.com/ehrbase/rest/openehr/v1/ehr/7b3074c9-4c95-48cf-a2cd-64fde424a7aa/directory
(see EHR API for reference).
With the following payload:
{
"_type": "FOLDER",
"name": {
"_type": "DV_TEXT",
"value": "Episode 1234568"
},
"archetype_node_id": "openEHR-EHR-FOLDER.generic.v1",
"details": {
"_type": "ITEM_TREE",
"name": {
"_type": "DV_TEXT",
"value": "Tree"
},
"archetype_node_id": "at0003",
"items": [
{
"_type": "ELEMENT",
"name": {
"_type": "DV_TEXT",
"value": "text"
},
"archetype_node_id": "at0004",
"value": {
"_type": "DV_TEXT",
"value": "Here could be a description of the case"
}
}
]
},
"items": [
{
"id": {
"_type": "HIER_OBJECT_ID",
"value": "d936409e-901f-4994-8d33-ed104d460458"
},
"namespace": "my.system.id",
"type": "VERSIONED_COMPOSITION"
},{
"id": {
"_type": "HIER_OBJECT_ID",
"value": "d936409e-901f-4994-8d33-ed104d460456"
},
"namespace": "my.system.id",
"type": "VERSIONED_COMPOSITION"
}
]
}
}
The name can contain the name of your folder. You can also add any valid openEHR reference model elements under “details”. For now, this does not refer to an actual archetype “openEHR-EHR-FOLDER.generic.v1” but is more like a placeholder. In the future, an archetype can be used to clearly define the content of the “details” section which might contain any metadata that is of relevance for the folder (in our example, this is a free text description).
You place the actual compositions inside the items tree
{
“id”: {
“_type”: “HIER_OBJECT_ID”,
“value”: “d936409e-901f-4994-8d33-ed104d460456”
},
“namespace”: “my.system.id”,
“type”: “VERSIONED_COMPOSITION”
}
You can then obtain the directory again using the following GET request:
ehrbase-test-system.com/ehrbase/rest/openehr/v1/ehr/7b3074c9-4c95-48cf-a2cd-64fde424a7aa/directory
While this might look a bit verbose, you can use functionality inside our openEHR SDK to make your life easier:
https://ehrbase.readthedocs.io/en/latest/04_sdk/02_reference/01_client_module/06_directory/index.html
UUID ehr = openEhrClient.ehrEndpoint().createEhr();
FolderDAO root = openEhrClient.folder(ehr, "");
FolderDAO visit = root.getSubFolder("case1/visit1");
EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV01 = TestData.buildEhrbaseBloodPressureSimpleDeV0();
visit.addCompositionEntity(bloodPressureSimpleDeV01);
EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV02 = TestData.buildEhrbaseBloodPressureSimpleDeV0();
visit.addCompositionEntity(bloodPressureSimpleDeV02);
List<EhrbaseBloodPressureSimpleDeV0Composition> actual = visit.find(EhrbaseBloodPressureSimpleDeV0Composition.class);
assertThat(actual).size().isEqualTo(2);
Hope this helps to get you started!