Select association with highest attribute value using a microflow

0
Hi, I have patient and a doctor and I want to automatically assign the patient to the doctor who has the most room (integer) left. It would be great if the name of the doctor then would appear on the right of microflow button. http://imgur.com/uxb3gcB Thanks in advance!
asked
3 answers
0

Hi Kay, A solution could be creating a custom 'New' (microflow)button, for when you want to create a new patient object. This microflowdoes:

  1. create a new patient object
  2. retrieve the doctor that hast the most room left
  3. make an association between the two.

In the data view you would not need 'Select Doctor' button any more. In that space you could automatically display the doctors name.

Is this what you're looking for?

answered
0

Hi Gonzo,

Thank you for the suggestion. However, one user creates the patients and another user screens the patients and assigns them to a doctor.

I hope there is a solution.

answered
0

Kay,

Add a Doctor dataview to your page, inside the Patient dataview. It should retrieve the Doctor over association. Make sure you add the Doctor's name in there as a TextBox.

Now your "Select Doctor" microflow button should do the following:

  1. Parameter should be Patient (should happen by default)
  2. Retrieve from database a list of doctors, only the first one, and sort by your capacity integer (descending)
  3. Change the Patient, add the association to the selected doctor, refresh in client
  4. Decrement the Doctor's capacity integer by 1, commit and refresh in client

I think that should do it! Executing the microflow should associate the doctor and display his/her name on the screen.

answered