I am trying to use a string variable in a reference to a patient label, to check the value of multiple labels inside a loop inside of an Assign Labels object.
When tokens enter this Assign Labels, they have several labels set to 0 or 1 depending on whether they need certain imaging tests.
The new label value should be a 0 if all of several labels are set to 0, or 1 if there are any labels set to 1.
I am currently assigning these labels to the patient (they are "xray", "ct", etc. 0/1 for each) and trying to evaluate them by referencing the list in a table, as pictured below:
/**Custom Code*/
Object current = param(1); Object patient = current; treenode activity = param(2); Token token = param(3); Variant assignTo = param(4); string labelName = param(5); treenode processFlow = ownerobject(activity); print(patient); int imgCount = 0; // set count of imaging processes to 0 // check the table of imaging assignment values for imaging names Table headers = Model.find("Tools/GlobalTables/ptFlowPcts"); print(headers); print(headers.numCols); for (int i = 1; i = headers.numCols; i++){ // loop through the number of columns string img = headers.getColHeader(i); // get the column name (imaging type) for each loop imgCount += patient.img; // try to get the 0 or 1 value of this label } if (imgCount = 0){ return 0; // return 0 (no) only if there are no imaging called for } else{ return 1; // return 1 if one or more imaging is called for }
The question at hand is: how can i reference a label on a patient using a variable, so that I can check an arbitrary number of labels in a code block? I have tried a few different things:
label(patient, img)
patient.img
patient."img"
patient.labels[img].value
patient.labels[img].evaluate()
- ... and every other combination I could come up with.
Some of them led to a crash, some just threw an exception saying the label didn't exist. I am at the point where I just have to say I don't know how this should work.
---
Ideally I would just have a label that contains an array with a list of imaging randomly assigned based on our client data. And now that I think about it, I should be able to do that with code. But I'd still like to know better how to do what I described above.
Thanks in advance, you are all always so helpful!