pre-selected choice

26 views
Skip to first unread message

Amandine Carmagnac

unread,
Nov 18, 2024, 1:21:16 AM11/18/24
to redca...@googlegroups.com
Dear all 

I have this set up below 

Field 1:
Test performed 
1=internal 
2=external
3=no

Field 2:
Gene 1 
1=WT
2=Mutant
3=not tested 

Field 3:
Gene 2
1=WT
2=Mutant
3=not tested 

Field 4:
Gene 3
1=WT
2=Mutant
3=not tested 

I would like to be able to have different pre-selection options depending on the answer given to field 1. 

If field 1= internal 
I would like to have fields 2, 3 and 4 pre-selected as WT
If field 1= external 
I would like to have field 2 pre-selected as WT and field 3 and 4 pre-selected as not tested 
If field 1= no
I would like fields 2, 3 and 4 pre-selected as not tested.

I know that the action tag @DEFAULT can be used to preselect some options but I'm struggling to come up with a set up that would allow me to give different pre-selection options depending on the "test performed" answer.

Is this possible and, if so, how do I need to set this up?

Thank you so much 

Amandine 


David Edwards

unread,
Nov 18, 2024, 5:26:35 AM11/18/24
to Amandine Carmagnac, redca...@googlegroups.com
Hi Armandine,

Now you could use the @IF() action tag to achieve what you've asked for.

e.g.

In the action tags/annotations section of fields 2, 3, and 4, replace the @DEFAULT tag with this:

Field 2

@IF(([field_1]=1 or [field_1]=2), @DEFAULT=1, @IF([field_1]=3, @DEFAULT=3))

Field 3

@IF(([field_1]=1), @DEFAULT=1, @IF(([field_1]=2 or [field_1]=3), @DEFAULT=3))

Field 4

@IF(([field_1]=1), @DEFAULT=1, @IF(([field_1]=2 or [field_1]=3), @DEFAULT=3))

BUT, the problem with that is ... this will only get executed once when the page first loads.
You could use @SETVALUE instead of @DEFAULT so it executed every time the page loaded, but if the user changes the answer to [field_1] again after page load, it doesn't execute, so it's not much use.

The solution for this escapes me right now, but maybe someone else here can think of a more dynamic way of solving that last problem?

Cheers,
David.



From: redca...@googlegroups.com <redca...@googlegroups.com> on behalf of Amandine Carmagnac <amandine....@gmail.com>
Sent: 18 November 2024 06:21
To: redca...@googlegroups.com <redca...@googlegroups.com>
Subject: [REDCap Open] pre-selected choice
 
--
You received this message because you are subscribed to the Google Groups "Redcap Open" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redcap_open...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/redcap_open/CAByum3A%2B%3D99HG%3DuW6jfuAurHyUSXbAH5Oxu8rTmimH70zdu65A%40mail.gmail.com.

David Edwards

unread,
Nov 18, 2024, 5:36:23 AM11/18/24
to Amandine Carmagnac, redca...@googlegroups.com
Whoopsy daisy!
I just noticed I missed something there ... In red below


From: redca...@googlegroups.com <redca...@googlegroups.com> on behalf of David Edwards <dw...@hotmail.com>
Sent: 18 November 2024 10:26
To: Amandine Carmagnac <amandine....@gmail.com>; redca...@googlegroups.com <redca...@googlegroups.com>
Subject: Re: [REDCap Open] pre-selected choice
 
Hi Armandine,

Now you could use the @IF() action tag to achieve what you've asked for.

e.g.

In the action tags/annotations section of fields 2, 3, and 4, replace the @DEFAULT tag with this:

Field 2

@IF(([field_1]=1 or [field_1]=2), @DEFAULT=1, @IF([field_1]=3, @DEFAULT=3, ''))

Field 3

@IF(([field_1]=1), @DEFAULT=1, @IF(([field_1]=2 or [field_1]=3), @DEFAULT=3, ''))

Field 4

@IF(([field_1]=1), @DEFAULT=1, @IF(([field_1]=2 or [field_1]=3), @DEFAULT=3, ''))

Peter Macisaac (POP)

unread,
Nov 18, 2024, 2:38:39 PM11/18/24
to David Edwards, Amandine Carmagnac, redca...@googlegroups.com
Not sure what you missed?

It appears to be that the data collected references tests done and is not subject to revision so the @default should work

The key issue is to have the data that drive the default in a form that is closed and saved prior to completing a form that contains the @default enabled fields as it only works when you open the form for the first time

If this solution doesn’t work come back to us

Peter



David Edwards

unread,
Nov 18, 2024, 3:29:58 PM11/18/24
to Peter Macisaac (POP), Amandine Carmagnac, redca...@googlegroups.com
I missed the final part of the 2nd @IF on each row - underlined here:



From: Peter Macisaac (POP) <pe...@macisaacinformatics.org>
Sent: 18 November 2024 19:38
To: David Edwards <dw...@hotmail.com>
Cc: Amandine Carmagnac <amandine....@gmail.com>; redca...@googlegroups.com <redca...@googlegroups.com>
Reply all
Reply to author
Forward
0 new messages