Select a lookup table depending on a value stored in a hidden value


(B.Gueye) #1

Hello
Is that possible to select a lookup table depending on a value stored in a hidden value.


(Ethan Soergel) #2

Unfortunately no, lookup tables can only be referenced directly. One way you may be able to workaround this is by duplicating whatever you’re using the lookup table for, for each version you’re selecting between. For instance, say you have two lookup tables, A and B. Start off with a question which says “use A or B?” After that, you can have a multiple choice question with lookup table A as the options, but which is displayed only if they selected A. Similarly for B. Then you could have a hidden value which coalesces those two multiple choice questions for use elsewhere in the form.

Taking a step back, it’s worth considering whether these multiple lookup tables should be combined into one. Presumably they store the same sort of information, since they’re used interchangeably. Rather than a lookup table for category A and one for category B, could you use one large lookup table with a “category” column, and then filter on that column in the form? If so, you wouldn’t need to dynamically select the table, just the value to use in the filter.


(B.Gueye) #3

Thank you Ethan
That’s what i have done a lookup table with a category column and do filter by category column. but the matter is depending on the category, there some same values. For example for three drug administration calendar (Drug A, Drug B, and Drug C), these treatement calendar starts by J1:
Drug A : J1
Drug B : J1,J4,J7
Drug C : J1,J2,J3,J4,J5,J6,J7,J8
And i want if for the first day user chooses J1, J1 won’t be appear at when the second treatment will come and so on.
So when i try to test the app, i get an error saying “Node set has more than one node”
Thanks


(Ethan Soergel) #4

Are you working with multiple lookup tables or is this all in that one lookup table?

And i want if for the first day user chooses J1, J1 won’t be appear at when the second treatment will come and so on.

For this you’ll likely need to record on the case which treatments have been taken, so you can exclude them later.

The error “Node set has more than one node” means that you are attempting to select a single value from an expression which matches multiple values. It’s hard to say what could be causing that without seeing the app. If you have an expression which matches all available treatments, you’ll either need the user to select one, or you can return a particular one based on position using the selected-at function.


(B.Gueye) #5

i’m working with one lookup table with three fields(id,name,molecule).
When the user register a patient, a molecule is assigned for.
Now in the form where user valid the the treatment, i created a hidden value and give it as default value the value of the molecule assigned for when user registerd a new patient, and put the filter in the lookup table field to show treatment calendar belongs to molecule.
Thanks


(Ethan Soergel) #6

That sounds like it should work, I’m not sure where the problem is. I’d try looking for hidden values which reference questions that are inside a repeat group. That “Node set has more than one node” error means that the expression matches multiple values. You can also try using join to combine multiple values into one.


(B.Gueye) #7

The problem is every drug infusion has a J1 day . The system find that they are many J1 values.
id - name - molecule
j1 J1 A
j1 J1 B
j2 J2 B
j3 J3 B
j1 J1 C