162
Views
12
Comments
date and time validation based on database/previous user
Question
Application Type
Reactive

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? 

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

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.

UserImage.jpg
Ide Fatsha

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

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Ide,

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:

  1. Duplicate data. Since a patient can make more than one appointment, and you can store only a single appointment in a patient record, every time a patient makes an appointment, you need to duplicate all data (name, e-mail etc.). This causes the database to fill up more quickly, but is also a nightmare if you need to update the data (e.g. new e-mail address).
  2. You should never store an image in a generic entity containing other data you want to query (like name and e-mail). Binary data is typically very big compared to normal (textual) data, so your entity becomes very slow to query. If you want to store an image in the database, always create a second entity that contains nothing but the Id of the normal entity (so the Id is of type Patient identifier) and the image as binary data.
  3. Having only a single attribute for additional information may be enough for your use case, but typically, you'd also create another entity so you can store more than one remark for a patient.

So please revise the data model, and create at least two more entities (Appointment and PatientImage) to hold the appropriate data.

UserImage.jpg
Ide Fatsha

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

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

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).

UserImage.jpg
Ide Fatsha

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

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Can you share your module (OML file)? It's difficult to see what is wrong without all the code.

UserImage.jpg
Ide Fatsha
AppoinmentBooking.oap
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Ide,

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.

UserImage.jpg
Ide Fatsha

Yes thank you very much. I have just tested it, its working fine now

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Glad I could be of help! Could you mark my answer as Solution so we know your question is solved? Thanks.

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

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

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.