# How many FOLDER trees can be associated with the same EHR

**URL:** <https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754>\
**Category:** RM\
**Created:** [27 September 2024 09:39 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754 "2024-09-27T09:39:27Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![linforest](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/l/ac8455/32.png) [@linforest](https://discourse.openehr.org/u/linforest)\
**Post date:** [27 September 2024 09:39 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/1 "2024-09-27T09:39:27Z")

</div>

How many FOLDER trees can be associated with the same EHR at the same time?  
In other words, _EHR 0…1 FOLDER\_tree_ OR _EHR 0…n FOLDER\_tree_?

[Figure 20. High-level Structure of the openEHR EHR](https://specifications.openehr.org/releases/BASE/latest/architecture_overview.html#_the_ehr)

 ![image](https://discourse.openehr.org/uploads/default/original/2X/6/6a6d2f616ecd3960917a8666f7df775cca748c5b.png)

This figure seems to imply a single EHR could have more than one folder trees at the same time.

For an EHR already having a Directory FOLDER, when trying to POST an second FOLDER tree JSON to EHRBase Server via openEHR Tool, I got the following error (409):

```auto
{"error":"Conflict","message":"EHR with id 80a71040-3d37-42f3-a86a-ce5405138ce0 already contains a directory."} 

```

 ![image](https://discourse.openehr.org/uploads/default/original/2X/7/7ba1ab796592df1ef2bb8d5a6606f2f9bb9a3218.png)

---

<div class="post-metadata">

**Author:** ![thomas.beale](https://discourse.openehr.org/user_avatar/discourse.openehr.org/thomas.beale/32/35_2.png) [@thomas.beale](https://discourse.openehr.org/u/thomas.beale)\
**Post date:** [27 September 2024 12:00 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/2 "2024-09-27T12:00:31Z")

</div>

You can [see here](https://specifications.openehr.org/releases/RM/development/UML/diagrams/RM-ehr.svg) that `EHR.folders` has cardinality `*`.

---

<div class="post-metadata">

**Author:** ![stefanspiska](https://discourse.openehr.org/user_avatar/discourse.openehr.org/stefanspiska/32/819_2.png) [@stefanspiska](https://discourse.openehr.org/u/stefanspiska)\
**Post date:** [27 September 2024 12:13 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/3 "2024-09-27T12:13:07Z")

</div>

The directory endpoint access the directory of the ehr which is the first folder :

> **[EHR Information Model](https://specifications.openehr.org/releases/RM/development/ehr.html#_ehr_class)**
>
> openEHR EHR Information Model specification

" **directory** : Optional directory structure for this EHR. If present, this is a reference to the first member of `folders` ."

---

<div class="post-metadata">

**Author:** ![linforest](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/l/ac8455/32.png) [@linforest](https://discourse.openehr.org/u/linforest)\
**Post date:** [27 September 2024 12:48 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/4 "2024-09-27T12:48:10Z")

</div>

Thank you very much, @thomas.beale and @stefanspiska. Forgive me please. Honestly, I’m still confused about: What kind of folder hierarchy a single EHR can have, i.e., mono-/multi-hierarchy? What is the relationship between directory and folders? Two separate but related attributes of the EHR class? Or is Directory just a synonym of the very first folder (root) in the first folder tree? Especially the cardinality of the attribute _folders_, **0…1** , looks strange for me.

 ![IMG_20240927_204410](https://discourse.openehr.org/uploads/default/original/2X/b/bee72016981635400d2c0566c017e300a47bb5c7.jpeg)

Now I can understand the 409 error above because I was trying to POST a second directory, violating its cardinality _0…1_. Am I correct?

---

<div class="post-metadata">

**Author:** ![stefanspiska](https://discourse.openehr.org/user_avatar/discourse.openehr.org/stefanspiska/32/819_2.png) [@stefanspiska](https://discourse.openehr.org/u/stefanspiska)\
**Post date:** [27 September 2024 12:54 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/5 "2024-09-27T12:54:04Z")

</div>

Directory is just a reference to folders[0]

So post Directory is create folders[0] which gives you an error if already exist.

I belive at one time only Directory existed and folders was added late and then Directory became simple folders[0] die first element in the list.

---

<div class="post-metadata">

**Author:** ![linforest](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/l/ac8455/32.png) [@linforest](https://discourse.openehr.org/u/linforest)\
**Post date:** [27 September 2024 13:17 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/6 "2024-09-27T13:17:57Z")

</div>

> [@stefanspiska](#):
>
> Directory is just a reference to folders[0]

Thanks, @stefanspiska. I see, it’s a reference relationship.

For **folders[0]**, the index **[0]** means threre can exist more than one folder tree side-by-side?

---

<div class="post-metadata">

**Author:** ![linforest](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/l/ac8455/32.png) [@linforest](https://discourse.openehr.org/u/linforest)\
**Post date:** [27 September 2024 13:25 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/7 "2024-09-27T13:25:36Z")

</div>

Another confusing stuff for me is: there is no POST /Update/Delete operations for folders on the openEHR Tool UI:

```auto
<li class="nav-item dropdown dropend">
            <a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown" >
              Directory
            </a>
            <ul class="dropdown-menu" >
              <li><a class="dropdown-item" href="pdir.html">Post Directory</a></li>
              <li><a class="dropdown-item" href="udir.html">Update Directory</a></li>
              <li><a class="dropdown-item" href="gdir.html">GET Folder/Directory</a></li>
              <li><a class="dropdown-item" href="ddir.html">Delete Directory</a></li>
            </ul>
</li>

```

---

<div class="post-metadata">

**Author:** ![sebastian.garde](https://discourse.openehr.org/user_avatar/discourse.openehr.org/sebastian.garde/32/3070_2.png) [@sebastian.garde](https://discourse.openehr.org/u/sebastian.garde)\
**Post date:** [27 September 2024 13:39 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/8 "2024-09-27T13:39:48Z")

</div>

> [@linforest](#):
>
> Especially the cardinality of the attribute _folders_, **0…1** , looks strange for me.

I think you find this strange because what you have circled is NOT the cardinality, but just the existence (or occurrences) of the _folders_ attribute, i.e. _folders_ may or may not exist (aka is optional).

Then, _if_ it exists, the _cardinality_ of the folders List is \*, i.e. the folders List can contain any number of OBJECT\_REFs (each pointing to the root of a Folder structure, with the first member being the “directory”).

Hope this clarifies this bit.

---

<div class="post-metadata">

**Author:** ![linforest](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/l/ac8455/32.png) [@linforest](https://discourse.openehr.org/u/linforest)\
**Post date:** [27 September 2024 13:50 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/9 "2024-09-27T13:50:25Z")

</div>

> [@sebastian.garde](#):
>
> NOT the cardinality, but just the existence (or occurrences) of the _folders_ attribute

Indeed, I was confusing the two attributes of the EHR class with the “physical” folder structures.

@sebastian.garde Thanks a lot for your clarification.

---

<div class="post-metadata">

**Author:** ![thomas.beale](https://discourse.openehr.org/user_avatar/discourse.openehr.org/thomas.beale/32/35_2.png) [@thomas.beale](https://discourse.openehr.org/u/thomas.beale)\
**Post date:** [27 September 2024 15:21 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/10 "2024-09-27T15:21:32Z")

</div>

> [@linforest](#):
>
> Now I can understand the 409 error above because I was trying to POST a second directory, violating its cardinality _0…1_. Am I correct?

That 0…1 means optionality, not cardinality. It means there could be not even a folders container. if there is something there, it is a List, which is a container, i.e. 0…\* items.

---

<div class="post-metadata">

**Author:** ![sebastian.iancu](https://discourse.openehr.org/user_avatar/discourse.openehr.org/sebastian.iancu/32/31_2.png) [@sebastian.iancu](https://discourse.openehr.org/u/sebastian.iancu)\
**Post date:** [27 September 2024 18:15 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/11 "2024-09-27T18:15:52Z")

</div>

Some other useful info: the EHR.folders was added in RM 1.1.0, previously we only had EHR.directory. The REST specs is lagging behind, as it does not have yet operation for folders. What you see there ion EHRbase is just the REST for directory “resource”. This missing piece of specs is anyway planned to be addressed soon, and hopefully it will be also supported by CDRs.

---

<div class="post-metadata">

**Author:** ![linforest](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/l/ac8455/32.png) [@linforest](https://discourse.openehr.org/u/linforest)\
**Post date:** [27 September 2024 20:21 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/12 "2024-09-27T20:21:13Z")

</div>

It gets vividly clearer and more interesting. Thank you so much, @thomas.beale and @thomas.beale.

---

<div class="post-metadata">

**Author:** ![Lucas](https://discourse.openehr.org/user_avatar/discourse.openehr.org/lucas/32/3185_2.png) [@Lucas](https://discourse.openehr.org/u/Lucas)\
**Post date:** [30 September 2024 15:18 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/13 "2024-09-30T15:18:58Z")

</div>

Interesting post and very helpful, as I am still struggling to understand how folders can be used in openEHR, and now I also know why there is no REST API call for such folders.

I am curious to learn how **“administrative cases”** and **“medical episodes”** are managed in openEHR. Here are the definitions of both terms for context:

- **Administrative Case** : This organizes a patient’s medical treatment from an administrative viewpoint. It includes multiple hospitalizations or outpatient treatments at different times that are grouped under a single administrative case for billing, insurance, or other management purposes.
- **Medical Episode** : This organizes a patient’s medical treatment from a clinical perspective. It may include various hospitalizations or outpatient treatments, potentially spread across different administrative cases, but grouped based on a specific clinical condition or treatment process.

---

<div class="post-metadata">

**Author:** ![Colin\_Sutton](https://discourse.openehr.org/user_avatar/discourse.openehr.org/colin_sutton/32/47_2.png) [@Colin\_Sutton](https://discourse.openehr.org/u/Colin_Sutton)\
**Post date:** [30 September 2024 23:36 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/14 "2024-09-30T23:36:09Z")

</div>

These would be AQL queries providing details for a report that will update as the case or episode progresses. Could they have a generic structure?

---

<div class="post-metadata">

**Author:** ![Lucas](https://discourse.openehr.org/user_avatar/discourse.openehr.org/lucas/32/3185_2.png) [@Lucas](https://discourse.openehr.org/u/Lucas)\
**Post date:** [1 October 2024 14:47 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/15 "2024-10-01T14:47:07Z")

</div>

I hope, that I interpreted your answer as a response to my post 😅

Based on your insight, this means, that the organization of administrative cases and medical episodes need to be managed in the application using predefined AQL queries (logic layer) and not at the openEHR using associations or tags (persistence level).

Can you tell me, if I did understand your insight correctly?

---

<div class="post-metadata">

**Author:** ![stefanspiska](https://discourse.openehr.org/user_avatar/discourse.openehr.org/stefanspiska/32/819_2.png) [@stefanspiska](https://discourse.openehr.org/u/stefanspiska)\
**Post date:** [1 October 2024 15:14 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/16 "2024-10-01T15:14:59Z")

</div>

@Lucas

Folders allow grouping of Composition into logical groups so yes you could use that to modele say a episode of care see: [Representation of Episodes of Care and Encounters in folders](https://discourse.openehr.org/t/representation-of-episodes-of-care-and-encounters-in-folders/226)

---

<div class="post-metadata">

**Author:** ![linforest](https://discourse.openehr.org/letter_avatar_proxy/v4/letter/l/ac8455/32.png) [@linforest](https://discourse.openehr.org/u/linforest)\
**Post date:** [1 October 2024 15:32 UTC](https://discourse.openehr.org/t/how-many-folder-trees-can-be-associated-with-the-same-ehr/5754/17 "2024-10-01T15:32:21Z")

</div>

On the Spec page for the [EHR Model](https://specifications.openehr.org/releases/RM/latest/ehr.html#:~:text=The%20folders%20structures%20can%20be%20used%20in%20the%20EHR%20to), there is a [figure](https://specifications.openehr.org/releases/RM/latest/ehr/diagrams/folders_for_indexing.svg) that shows examples for using folders to organize episode data.

 ![IMG_20241001_232756](https://discourse.openehr.org/uploads/default/original/2X/1/1321564b1e1d8c3ada032b57ec3cefecfd927a77.jpeg)
