Hello, I am relatively new to Mendix and I am trying to figure something probably quite simple out, but I get a little bit stuck on it :). So I have two users, patients and doctors. A doctor is able to make a treatmentplan for a patient. These treatment plans consists of certain (predefined) activities which are performed by the patient. If a patient has a certain common problem the doctor should be able to assign a standard care program to the patient. This standard care program consists of multiple activities which should be added to the treatment plan. I have the following domain model: I already made the care programs and associated the belonging activities, but the problem is now that I don't know how I can add the function for the doctor to select a standard care program for the patient and that the belonging activities get added to the treatment plan of the patient. Is there a certain function in Mendix to do this? I hope my explanation has been clear.
Your domain model looks pretty correct for as far as i understand you use case correctly.
I think you may want to look for a the solution in the organisation of pages and microflows.
What do you think of following scenario?
Doctor logs in to the system
System shows a list of all patients (a page containing a data grid showing all patients)
Doctor edits a patient
System shows the details page of the given patient, listing all treatmentplans ofr the patient.
Doctor selects a button “add treatment plan”
System shows a popup listing all standard care programs.
Doctor selects a standard care program and presses the “select” action button.
Now the microflow behind the "select” action button must contain the logic to create a new treatment plan object and activity obhects for the patient, given the selected standard care program.
Is this what you are looking for?
You would need to use nested views with combination of List MasterDetails dataviews.
Add a dataview to a new/edit page for patient and link its datasource to Patient entity.
Make sure you have a reference selector on the page to allow selecting a Care group.
Add another dataview inside the Patient dataview and link its datasource to CareGroup over association. Put the visibility condition on this dataview to show only when reference selector for CareGroup has a value.
Add a layout grid with 3 – 6 column space division inside the CareGroup dataview.
Add a listview to the left column and set it’s datasource to StandardCareProgram over association to the CareGroup.
Add a dataview to the right colum and make it listen to the listview previously created.
Add a datagrid view inside the listening dataview and set its datasource to TreatmentPlan over association to the StandardCareProgram.
Finally add button “view activities” on this grid to and link to a new page. (See 2nd screenshot) In this page, create a dataview and set its entity to TreatmentPlan over context. Add a datagrid and set its datasource to Activity over association
Check the screenshots below to have a better idea
Addition based on Granit’s comment
For adding a column in a datagrid to show data from associated entity:-
Right click on the column and click “add column” to right. This will add a new column. double click and set is path to the desired field of the Activity_type. (See screenshot)
Farkhanda Abdul Hamid
I have looked in to it more, but I still can't seem to solve it. So to show the list of standard programs I need to pass the current treatment plan or activity object (not sure) to add the activities to the treatment plan, but that is not possible. I keep getting an error, because the page which contains the standard care programs has no data view that accepts an object of type ‘TreatmentPlan’.
Is it possible to explain a little bit more what I have to do with the microflows? Here are some pictures which show how it lookes like