question

Tee Hiett avatar image
0 Likes"
Tee Hiett asked Jason Lightfoot commented

How do I convert an h:mm:ss string value into minutes?

In the posting, @Felix Möhlmann got me going with DATE_TIME values but I'm having diffficulty implementing his suggestions. In the attached model, TKC Endoscopy 040522_1.fsm.jpg, I am trying to get the time the patient was scheduled to arrive, which is in string h:mm:ss format, into minutes. The String label on the patient is patient.OriginalSchHM in the Arrivals Table. Note that this is not the time of the arrival of the patient but the time the patient was scheduled to arrive, usually much earlier than the patient's arrival time. This is in the activity Assigned Labels.

This converted value in minutes will be put into a patient label patient.OriginalSeqMins

Any help will be welcome.


FlexSim 21.2.4
arrivalsconvert
· 1
5 |100000

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

Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·

Hi @Tee Hiett, was Felix Möhlmann's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Felix Möhlmann commented

What part of my suggestion in the other post are you having trouble with?

Instead of defining a script label in the table you can also read the scheduled time when assigning a label though the source activity.

1664182099251.png

If you want to continue working with the string time, then the way to convert it into a minute value is to use the DateTime constructor again, just the other way around. Pass in the string, define the format and it will give back the date time value. Since the date time is defined is seconds you then have to convert it to minutes.

DateTime dateTime = DateTime(patient.OriginalSeqHMS, "%H:%M:%S");
double minuteTime = dateTime.as(double)/getmodelunit(TIME_MULTIPLE); 

Though this will return the number of minutes since midnight, since the date is not specified. As such, the model time and the time in minutes from this conversion will be different if you run the simulation for longer than a day. Which is why I originally suggested to read the values directly from the schedule.


To use the "convert" command, the time string has to be in the format specified in the model settings. For your model that would be "hh:mm:ss AM/PM".

1664182360109.png

You can of course change the setting.

1664182472866.png1664182504606.png

58953-tkc-endoscopy-040522-1_1.fsm


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

Tee Hiett avatar image Tee Hiett commented ·

Thanks for the prompt and helpful response. I am beginning to see the value of getting the time value from the arrivals table but when I tried to replicate your statement, I got the error message is shown here:

Errors in statement.jpg

Thanks for your help with this.


0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Tee Hiett commented ·

The header doesn't seem to match those of the healthcare Source activities. It should look like this:

/**Custom Code*/
Object current = param(1); 
Object patient = current;
treenode activity = param(2);
Token token = param(3);
int rowNumber = param(4); //The arrival entry row number
int cycle = param(5); //The current cycle through the arrivals table (first iteration cycle = 1)
string labelName = param(6);
treenode processFlow = ownerobject(activity);


I'm not sure why you can't just use the current model time when the token is created:

Math.frac(Model.dateTime.excelTime)*days(1)

gives you the number of time units since the start of the day/midnight.

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Tee Hiett commented ·

As Jason said, it seems like you are using an "Assign Labels" activity. The rownumber and cycle values (and the correct 'varnode') are only available when the token is first created in the Date Time Source of the Arrivals flow. So you have to assign the label there. They are automatically copied to the patient that the token creates afterwards.

1664263053706.png

0 Likes 0 ·
1664263053706.png (23.4 KiB)