question

Courtney Seto avatar image
0 Likes"
Courtney Seto asked Matthew Gillespie commented

How do you set a start time condition on a patient track activity?

I would like to write a constraint so that a patient track activity can only be initiated during a specific time frame (8am-8pm). I am not sure how to model this in the "Activity Start Conditions" in the "Advanced Functions" tab in the patient track with an expression or flexscript code.

FlexSim HC 5.1.0
healthcareactivitystart timeadvanced functions
5 |100000

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

1 Answer

Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Matthew Gillespie commented

You can use the Based on Simulation Time pickoption that handles all the time checking code for you. This pickoption creates a global table and then reads a value from the appropriate cell based on the current time. When you choose the pickoption you'll see the following popup:

Here you configure the table and how many cells you want. The default settings will make a cell for each hour of the day and will generate a blank table like this:

The Activity Start Condition expects a true or false value, so enter a 1 when you want the activity to be able to start and a 0 when you don't want it.

Rather than using the Activity Start Condition I would probable use a Decision Point activity with the Based on Simulation Time pickoption in the Next Activity field to decide which activity to start based on the current time. In that case you'd fill out the table with the Activity ID's.


simtime.png (6.6 KiB)
table.png (7.8 KiB)
· 3
5 |100000

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

Courtney Seto avatar image Courtney Seto commented ·

Thank you!

If I use the Decision Point Activity, would I create a filler Activity for the patient to stay where they are until the appropriate time or could I loop it back to the decision point each hour?

0 Likes 0 ·
Courtney Seto avatar image Courtney Seto commented ·

So I tried using a Decision Point with a loop, but it seems to get stuck on the decision point activity... here is my logic:

130_Decision Point>Next Activity Based on Simulation Time:

8am-8pm: 131_Activity

8pm-8am: 132_Wait for Activity

131_Activity>Next Activity: 140_Departure

132_Wait for Activity>Next Activity: 130_Decision Point

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Courtney Seto commented ·

Do you have a delay time on activity 132? If not it would get in an infinite loop. Here is an example model I put together that shows it working. Patients in this model are only allowed to exit every other hour.

Although, rather than rechecking periodically I would just set the delay to be as long as the remaining time until the next time period. For example, in this model each time period is 60 minutes long so I would see how many minutes are left in the hour and wait that long:

60 - fmod(time(), 60)
0 Likes 0 ·
simulationtime.fsm (64.0 KiB)