Good Morning everyone
I am building an app that should be able to allow users to book an appointment via a date and time. I want the app to base the available timeslots (Day and time) on when weather a previous user has selected that timeslot. The Reactive webapp should not show a timeslot if its not available.
Any suggestions on how I can go about doing this?
Hi Ide,
There's several ways you can go about this, but I honestly think you should try to think of a solution yourself. This is a basic programming question, not an OutSystems-related question. My advise: first think of what you functionally want, and then how you could solve this technically. Then, if you still don't know how to solve a specific part of that, ask again at the forum.
Hello. So I followed you advice and went about to solving this as a basic programming question.
So I want a way to check if the date that has just been entered by the user, is already contained in the database (meaning another user has already selected that date)
I tried to do this using as IF statement in my action flow (I will post it below) but it isn't working. I'm mostly struggling with how to compare the User's date, to all the other dates contained in the database
Good you tried to find a solution yourself! It's by doing this that we become better programmers :).
I assume the user has entered a date, and that's the date you want to check. If the date input is inside the Form, and the form is called "Form1" (as it seems from the auto-generated "Form1.Valid"), then I'd expect at least a check using Form1.BookingDate (or whatever it's called). Instead, I see you comparing the dates that are outputs of two query's.
Secondly, if you want to check if a booking with a certain date is already present, you create a query that searches for such a booking. So say you have a Booking entity, with a BookingDate attribute, you create an aggregate with the Booking entity, and a Filter that compares Booking.BookingDate with the entered date (so Form1.BookingDate). Next, you check, using the GetBookingByDate (assuming that's the aggregate's name) Empty property. If Empty is True, no result was found, if Empty is False then another booking exists.
In your last screen shot I see you have both an AppointmentDate and an AppointmentTime, so you need to compare those both if that's what you want to compare against, but the idea is the same.
Then one very important note that doesn't have directly to do with your question, but with your data model. It seems you have a single Patient entity that contains both a single appointment date/time, but also other patient data, including the patient's picture and a single info field. This is really bad for a number of reasons:
So please revise the data model, and create at least two more entities (Appointment and PatientImage) to hold the appropriate data.
So I have created a GetAppointmentDate aggregate that has a filter but the issue is my form (The form that contains the users appointment date) is not recognized ... So I cannot execute the filter, meaning I can't execute the 'Is Aggregate empty' if statement
Ah, yes, I see your problem. I think (but I'm not too well versed in Reactive Web), you need to create a local variable and use that in the filter, and in your action you need to assign that local variable from your Form, then execute the aggregate (it should be set to on demand).
So I manged to execute the filter, assignment and the if statement excepts, any date the user entered is considered as already part of the database even though I know for a fact it not
Can you share your module (OML file)? It's difficult to see what is wrong without all the code.
Please find the OML attached
You missed the last of my sentence above, "then execute the aggregate (it should be set to on demand)". To do so, set the "Fetch" property of GetAppointmentsByAppointmentDate to "On demand" (it's now "At start"). Also set the "Max. Records" to "1", since there can always be only one result, and we're only interested in whether there's any result:
Next, add a Refresh Data node and refresh the GetAppointmentsByAppointmentDate aggregate after setting the AppointmentDate:
I suspect it will now work. The reason why it didn't work, is that initially AppointmentDate is empty (NullDate()), and apparently your database contains one or more appointments with a NullDate(), so it always found a record.
Yes thank you very much. I have just tested it, its working fine now
Glad I could be of help! Could you mark my answer as Solution so we know your question is solved? Thanks.
Hi,
Have a look at the patient portal guided path:
https://www.outsystems.com/training/paths/25/building-a-patient-self-service-portal/
It allows patients to select a clinic, then a doctor, then a timeslot, and to make a booking.
It has a patient portal, but also a doctors portal.
Regards,
Daniel