Hi everyone,
I’m currently learning OutSystems and working on a Doctor-Patient Dashboard screen. I’ve come across a requirement and would appreciate some guidance.
In the patient assignment screen, I have a dropdown to select a doctor for a patient. The issue I’m facing is:
If a doctor is already assigned to a patient, their name should not appear again in the dropdown list when assigning a doctor to another patient.
Can someone help me understand how I can filter the dropdown list to exclude already assigned doctors?
Thanks in advance for your help!
Hi @Deebha Shree Ravichandran,
You can achieve this by adding a new boolean attribute, HasAppointment, to your HasAppointment entity. Whenever a doctor is assigned to a patient from the patient page, set this attribute to true.
Then, when retrieving doctor data for the dropdown, simply apply a filter in the aggregate to include only those records where HasAppointment is false. This will ensure that only doctors without existing appointments appear in the list.
Attaching the OML for reference.
Hope this helps.
Thanks
Hi @Deebha Shree Ravichandran ,
Could you share more details about how the Doctor and Patient entities are related in your data model? It would also be really helpful if you could provide a sample OML for reference so we can tailor a solution for your use case.
It sounds like you want each doctor to be assigned to only one patient.
You can use ListFilter for your use case, Add filter condition if the doctor already assigned then show other doctors name in list. For example - Doctor Entity, Doctor Mapping entity (Doctor Id and PatientId) and have IsAssigned Attribute in mapping entity then check this condition like - DoctorMapping.IsAssigned = False
You can check this very helpful article by Dorine Boudry OutSystems Reactive— Mutually exclusive Dropdowns
Hello sirWith me, the easiest way is that in your Database, if you have a Boolean attribute that turn to true when a doctor already has an appointment and goes to false when free, you could use that with a filter to only display doctor whose is free, like thisDoctor.IsFree = falseHope this help*Pretty much a dropdown use data from a source list(aggregate) that you have defined before, just put a filter inside the aggregate that you are using to populate data for the dropdown, and you are done
Hi @Deebha Shree Ravichandran ,You can achieve this by using a Join between the Doctor and DoctorAssignment entities and filtering out doctors who already have an assignment. In the filter, check if the Doctor.Assigned = False. This will ensure that only doctors who are not assigned to any patient are displayed in the dropdown list.Thanks,Sahana
You can achieve this easily by adding a boolean attribute HasAppointment to the Doctor table. Then, filter the aggregate used to display the list of doctors using the condition: not Doctor.HasAppointment.
If adding an attribute isn't possible, but you have a joining table for appointments, you can accomplish this using a Data Action. Here’s how:
Create a Data Action that fetches data from both the Doctors and Appointments tables.
Append all doctors to the Data Action output list.
Iterate over the Appointments table.
For each appointment, use the ListIndexOf action to find the corresponding doctor in the output list.
Use the ListRemove action to remove doctors who already have appointments from the output list.
This way, you'll end up with a list of only those doctors who do not have any appointments.
Let me know if you need help implementing it!Thanks,Fazari
Everyone here suggesting using a boolean in the data model, or suggesting ListFilter, I've downvoted you, because these sollutions are bad. Why? I'll explain:
Feel free to delete your bad answer.
As for Deebha's question, in general, when you want to solve things like this, you need to think in steps (until you're so experienced that all the steps appear to you immediately :)):
A note of warning: when saving the new appointment, always check whether someone else didn't make an appointment for this doctor. When the screen starts you run the above query, but while the user is busy entering appointment details, some other user may already have created an appointment for the same doctor. So in the save Action, again check whether the doctor is available. Since theoretically, two or more users can press Save at the same time, and both conclude it's safe to save, you need some way to prevent this. In general, the best way is to use an Entity's Get...ForUpdate Action. In this case, a GetDoctorForUpdate, since it's the doctor's availability that's going to be checked.