question

Ksenia F avatar image
0 Likes"
Ksenia F asked Eric M commented

Help with statisticsColletor

Bed_00.fsm

Hello!

I have several wards with a certain number of beds (green), when the overload begins, patients are placed in reserve beds (gray). How can I get a table with the values: number of beds, free, occupied and overload (number of gray beds occupied). Thanks in advance! I attach the model.


FlexSim 21.0.4
statisticsflexsim healthcareflexsim 21.0.4
bed-00.fsm (159.6 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.

1 Answer

Eric M avatar image
0 Likes"
Eric M answered Eric M commented

Hi @Ksenia F, I included a stats collector that records this data and created a table in the dashboard as well. I put all of the bed locations in groups depending on if they were green or gray. I then use the getcensus command (info here) to get the current occupancy of the locations. I also wrote some code in the "OnModelReset" trigger in the toolbox which calculates the total number of beds in the model by group. I write these values to the global table "TotalBeds" which I use in the stats collector. Let me know if you have any questions!

bed-00-em.fsm


bed-00-em.fsm (696.6 KiB)
· 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.

Ksenia F avatar image Ksenia F commented ·

@Eric M , thank you so much it works!

I'm trying to get better at FlexSim. Could you please explain to me in more detail how this line of code works?

"group[i].as(Group)[j].attrs.drawsurrogate.subnodes.length"

I tried to figure it out with the help of the reference book, but did not fully understand. Thank you very much in advance!

0 Likes 0 ·
Eric M avatar image Eric M Ksenia F commented ·

Definitely! Because group is a reference to the "Locations" group, the group[i] just gets the i-th entry in that group. Here are the contents of the Locations group:

1627490269031.png

As you can see, Locations contains two groups, GreenBeds and GrayBeds. So if i = 1, then Group:GeenBeds will be selected with the first part of the code. The as(Group) just tells flexsim to treat GreenBeds as a group instead of an object. The [j] then finds the j-th entry in the group GreenBeds which looks like this.

1627490384353.png

So the code "group[i].as(Group)[j]" gets us one of the Observation rooms depending on what i and j are. The next step is to find out how many beds are in each observation room. That's where the rest of the code comes in. If we look at the tree of ObservationRoom1, we can see that each individual Bed is a "subnode" of the drawsurrogate node:

1627490510128.png

"attrs.drawsurrogate.subnodes.length" then is saying to find the total number of subnodes of the drawsurrogate node of our object, which happens to be the total number of beds in that multilocation. Hopefully that makes some sense. One helpful thing may be to open the Script box (Debug>Script Console) and run each bit of the following code one period group at a time to see what it returns:

Group("Locations")[1].as(Group)[1].attrs.drawsurrogate.subnodes.length
0 Likes 0 ·
1627490269031.png (9.4 KiB)
1627490384353.png (8.3 KiB)
1627490510128.png (16.7 KiB)
Ksenia F avatar image Ksenia F Eric M commented ·

@Eric M Hello! I need your help. I want to receive statistics for each of the blocks. I tried to split the groups and repeat your code, but when I repeat the steps in the Statistic Collector, it throws an error and does not work. What's my mistake? I apply the model.

Bed-01.fsm

0 Likes 0 ·
bed-01.fsm (165.6 KiB)
Show more comments