question

Yasaman N avatar image
0 Likes"
Yasaman N asked Cliff King edited

How to create random arrival schedules with fixed appointment times?

I am trying to model the arrival of patients, but I am struggling with choosing the right arrival pattern for model. I have experimented with the inter-arrival, appointments, and custom arrivals patterns, but have faced limitations with each.

Please see attached sample arrival data.

I would like to model the arrival of patients that arrive according to appointment times with the following characteristics:

  1. There are different types of patients based on the service they receive. (Column A)
  2. The number of patients that arrive per service is a variable number with the average a and it is between b and c. (Columns B-D)
  3. There are empty appointment slots per day for each patient type. (See Column E)
  4. The operating hours are different per patient type. (Column F-G)
  5. Schedule frequencies are different per patient type. (Column J)

Please see attached sample arrival data.

I would like to create a model with the requirements below:

  1. Create a random number of time slots to be filled per day between start time and end time for a patient type with a set frequency
  2. Assign the generated number of time slots per day into appointment slots randomly. For example, if there are 10 appointments to be filled in a day where 15 slots are available, would not want the 10 appointments to be the first 10. I would like to randomly assign them.
  3. Would like to add a distribution for the variability of the arrivals. For example, would like to see patients coming in between 5 minutes late or 10 minutes early to an appointment.

Thank you

sample-data.xlsx

FlexSim HC 5.3.8
patient arrivalsappointment schedule
sample-data.xlsx (10.1 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Cliff King avatar image
0 Likes"
Cliff King answered Cliff King edited

My first thought is to do all your "heavy lifting" in Excel. By that I mean, use macros, or whatever it takes, to create a single patient appointments table (in the format FlexSim HC expects it for a standard Appointments table on a PatientArrivals object) containing patient arrivals for all types of patients for all the days you plan on running the model for. Then you just need to do a simple import using the Excel Import/Export tool and you're good to go. The "Variability" field for the Appointment table arrival scheme in FlexSim will handle the "5 minutes late to 10 minutes early" requirement you mentioned.

However, because I'm a developer, I thought it'd be a "fun" exercise to try and populate an Appointments table in the model for a single day at the beginning of each new day of the model run. I've attached a test model where I accomplished this. I used the following two global tables to do this: MasterTable and CurDayTable. In my test model, I just worried about the arrivals of your "Patient Type 1" definition, but the idea could be expanded to cover a larger number of arrival types.

The MasterTable contains the maximum appointment slot scheme for this type of patient, matching the one you defined in your Excel sheet range B6-B39, but it is in the exact format that the PatientArrivals1 object expects an Appointment table to be in. I created this table by first populating the Appointment table on the arrivals object and then copy/pasting (CTRL+C/CTRL+V) it into the global table to ensure I had the proper format.

The CurDayTable gets overwritten during run time at the beginning of each day by some code I wrote on a User Event tool I named SetCurDayAppts. I documented each line of code in the user event so hopefully you could understand what I had to do in order to set up the CurDayTable with just the number of appointments for the current day and then copy this scratch table into the Appointments table of the PatientArrivals1 table.

I didn't want to take the little test model any further until I heard back from you as to whether or not you want to pursue this path, or if you would rather just do all the "heavy lifting" in Excel. Let me know if you'd like any further assistance, and I'd be glad to help!

NOTE ADDED Feb 14, 2019: Please improved and corrected model I posted in a later answer down below called "Dynamically_Fill_Appointment_Slots_Daily"!!

Cliff

randomly-fill-appointment-slots-on-a-daily-basis.fsm


· 6
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Cliff King avatar image
1 Like"
Cliff King answered Cliff King edited

Things just got a whole lot slicker! With help from @Matthew Gillespie, I built a model for you that automatically generates a random number of filled appointment slots each day based solely on information provided in a single input table named SlotDefs that looks similar to the information you provided in the Excel spreadsheet initially. I think you're going to like it. It wouldn't be much trouble to change the code in the daily User Event to accept more than a single break period in the appointment schedule, so let me know if this is your desire. I think you're going to like this!

randomly-fill-appointment-slots-on-a-daily-basis-f.fsm


· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Cliff King avatar image
0 Likes"
Cliff King answered

I needed to make a correction to my previous example model I posted. I didn't realize there is a scratch table used by the patient arrival object to sort the current day's arrivals chronologically. The scratch table is stored on a variable named TodaysScheduledArrivals and is sized only once when the model is reset. This is because it doesn't expect the size of the Appointments table to change dynamically during the course of a simulation as it does in our model. In our model I needed to add a couple of lines of code to the SetCurDayAppts user event function to resize the scratch table each day.

dynamically-fill-appt-slots-daily.fsm


5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.