Same attribute value for different entities

0
Hello, For my assignment I have entities the "Coordinator" and "Patient" with both the attribute "CareGroup". An enumeration was used to value this attribute. The enumerations values are "Acute", "Rehab" and "Intensive". Patient will be assigned to one of the caregroups and the coordinator will manage one of the caregroups (he will also be assigned).  For the coordinator I want to create a page where he can see his own patients. So for example, when a coordinator manages the caregroup "Acute", he will only see the the patients with the same caregroup "Acute" (which he manages). Also based on CurrentUser. Is it possible to have a constraint that states something like : EnumerationValue from attribute "Caregroup" of entity "Coordinator" IS EQUAL TO EnumerationValue from attribute "Caregroup" of entity "Patient". So the page should only show patient with the same value for "caregroup" as the coordinator, but for different entities.  Or is there another solution?   Thanks in advance
asked
2 answers
5

Hi Thaibinh, pages are object orientated which means you only can constrain a datagrid, listview and template grid based on objects (CurrentObject, CurrentUser, etc.) and associations. You want a compare based on attributes which isn't possible in Mendix. So another solution is needed.  

- Microflow datasource. Instead of letting the datagrid retrieving  the data by database, it uses a microflow. A microflow retrieve activity is able to compare on attribute level. The list of the retrieve is the output of the microflow. This has disadvantages because the datagrid, listview and template grid isn't able anymore to filter data with searchfields and change the sorting per column.

- The best solution is to make you're CareGroup attribute an separate entity containing the enumeration as attribute. The coordinator has an assocation which CareGroup he uses and the patient has an association to the CareGroup. Then you can constrain in the datagrid, listview and template grid based on association: show the patients which has the CareGroup which has been assigned to the currentuser.

I hope this helps, good luck.

answered
1

You can compare the enumeration values. My advice would be to look into a datasource microflow to retrieve the data.

https://docs.mendix.com/refguide/microflow-source

In the sample "replace" ordertype by your enumeration.

answered