question

Leah R avatar image
0 Likes"
Leah R asked Jeanette F commented

How to modify patient label based on user input ?

Hello !

I want my user to be able to modify the label of my patients.

In order to do this, I tried using the following function by putting it at the very start of the process in a custom code.

1658243029538.png

However, I am not very comfortable with the tree view and flexscript yet...

Let's say I have an incoming patient with a label called label_1

Can I directly modify the patient label with this function ?

If not, where can I at least get the value the user inputed (I do not understand where subodes[3] could lead in the example) ?


Thanks in advance,

Leah

FlexSim 22.1.0
flexscriptmodel treeuser input
1658243029538.png (34.5 KiB)
· 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.

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @Leah R, 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 Jason Lightfoot commented

This function will directly alter the value of the specified node. So yes, if you pass in the label node it will be changed to match the user input (if the data type is correct).

In the patient flow you have direct access to the patient through 'patient', so the code could look something like this.

// Make sure that the label is present
patient.labels.assert("UserLabel", 0);
// Prompt for value
userinput(patient.labels["UserLabel"], "Please specify label", 1);

userinput_label_fm.fsm

In the example 'subnodes' is used on the model directory itself. So the target node is the label 'myLabel' on the third treenode in the model tree.

1658299797653.png


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

Leah R avatar image Leah R commented ·
Thank you very much, I managed to make it work !


Is it possible to input several values at the same time (in the same window) ? Or do I have to use the function several times ?


Thanks in advance,

Leah


0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Leah R commented ·

You can store multiple inputs in an array label:

treenode temp=person.labels.assert("userString","");
userinput(temp,"test",1);
string userinput=temp.value;
person.labels.assert("userArray",userinput.split(","));

Just enter with a comma seperating the values.


UserInputArray.fsm

2 Likes 2 ·
userinputarray.fsm (40.9 KiB)
Leah R avatar image Leah R Jason Lightfoot ♦♦ commented ·
Amazing, thank you !


I have one last issue regarding that topic: is it possible to make it so the user can input at any time values ?

For instance: the simulation is running, the user wants to change a specific patient label value, the user clicks on some button that opens a window where the user can change the label value, the user closes the window and the simulation goes on with modified values.


0 Likes 0 ·
Show more comments