question

Jim Montgomery avatar image
0 Likes"
Jim Montgomery asked Matthew Gillespie edited

How do I assign shirt color based on patient label

As a patient enters the ED model, I would like to assign them a shirt color based on their acuity level. I created a patient label called "ESI" which contains an integer value (1 through 5) for each patient. This capability was fairly straightforward in the old version of FlexSim HC, but I can not figure it out in HC2020. Please provide some step by step instructions. Thank you!!!!

flexsim 20.0.3
5 |100000 characters needed characters left characters exceeded

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

1 Answer

· Write an Answer
Matthew Gillespie avatar image
1 Like"
Matthew Gillespie answered Matthew Gillespie edited

When you add a patient flow it adds a Random Appearance activity. This activity is a Change Visual activity and it randomly chooses different colors and clothes.

The code for determining the shirt color is in the Set Object color popup. All the person's shirts are set to use the object's color so you just need to set that. The initial line of code just chooses a random color from the 20 preset options in the clothesPalette color palette:

Color.fromPalette(duniform(1, 20, stream), clothesPalette)

The simplest way to get a unique color for each ESI value would b to just change this line to use the Color.byNumber() method (for these examples I'm assuming the ESI label is on the token):

Color.byNumber(token.ESI)

If you want to be able to pick which color is assigned to each label value you should make a color pallete and then use the Color.fromPalette() method. I've attached an example model that uses a color palette I made called ESIColors.

Color.fromPalette(token.ESI, "ESIColors")

ColorPalette.fsm

If you're not using the Random Appearance activity in your model you can still add a Change Visual activity and use the Set Object color pickoption with one of the above lines of code.

Another option is to set up different person flowitems in the Flowitem Bin and then use the Person field of the Create Person activity to create a different flowitem for each ESI label value.


1588364274676.png (13.6 KiB)
1588364612053.png (10.0 KiB)
colorpalette.fsm (52.9 KiB)
· 1
5 |100000 characters needed characters left characters exceeded

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

Thanks Matthew! Good tutorial!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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