How do I assign shirt color based on patient label

How do I assign shirt color based on patient label

jim_m3
Not applicable
137 Views
2 Replies
Message 1 of 3

How do I assign shirt color based on patient label

jim_m3
Not applicable

[ FlexSim 20.0.3 ]

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!!!!

Accepted solutions (1)
138 Views
2 Replies
Replies (2)
Message 2 of 3

Matthew_Gillespie
Autodesk
Autodesk
Accepted solution

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.

27932-1588364274676.png

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

27944-1588364612053.png

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.



Matthew Gillespie
FlexSim Software Developer

Message 3 of 3

jim_m3
Not applicable

Thanks Matthew! Good tutorial!

0 Likes