Choosing output based on three inputs

Moving a thread from my email. Original question:

How do I write a snippet that determines the various outcomes depending on the 3 initial inputs.

There are 4 types of medications (eg A, B, C, D), 2 types of procedures (X & Y) and 2 types of patient risk profiles (Good & Poor) (The profile is determined by the above equation)

For drugs A & B for procedure X with a Good risk profile the out come is abra-cadabra

For drugs A & B for procedure X with a Poor risk profile the out come is hocus-pocus

For drugs A & B for procedure Y with a Good risk profile the out come is Ali-babba

For drugs A & B for procedure Y with a Poor risk profile the out come is Genie

For drug C for procedure X with a Good risk profile the out come is Windows

For drug C for procedure X with a Poor risk profile the out come is Apple

For drug C for procedure Y with a Good risk profile the out come is Linux

For drug C for procedure Y with a Poor risk profile the out come is Android

For drug D for procedure X with a Good risk profile the out come is Spotify

For drug D for procedure X with a Poor risk profile the out come is Pandora

For drug D for procedure Y with a Good risk profile the out come is Deezer

For drug D for procedure Y with a Poor risk profile the out come is Google Play

There are probably more outcomes. My quest is to simplify it that one I input the 3 data variables an automated outcome will be derived

1 Like

The simplest way to do this is using nested if-statements. The following example illustrates how to do it with just the X/Y procedure and the Good/Poor risk profile:

Procedure: {formmenu: name=procedure; X; Y}
Risk Profile: {formmenu: name=risk; Good; Poor}

Outcome: {= ("abra-cadabra" if risk == "Good" else "hocus-pocus") if procedure == "X" else ("Ali-babba" if risk == "Good" else "Genie")}

Unfortunately, this isn't very readable and is hard to maintain.

A better approach is to used a named list to define the outcomes you want in a structured manner. The following example illustrates this:

Drug: {formmenu: name=drug; A; B; C; D}
Procedure: {formmenu: name=procedure; X; Y}
Risk Profile: {formmenu: name=risk; Good; Poor}

{treatments=[
  "A" = [
    "X" = [ "Good" = "abra-cadabra", "Poor" = "hocus-pocus" ],
    "Y" = [ "Good" = "Ali-babba", "Poor" = "Genie" ]
  ],
  "C" = [
    "X" = [ "Good" = "Windows", "Poor" = "Apple" ],
    "Y" = [ "Good" = "Linux", "Poor" = "Android" ]
  ],
  "D" = [
    "X" = [ "Good" = "Spotify", "Poor" = "Pandora" ],
    "Y" = [ "Good" = "Deezer", "Poor" = "Google Play" ]
  ]
]}

Outcome: {= treatments["A" if drug == "B" else drug][procedure][risk]}

(Note that since A and B are the same in the example, we pull the A treatments when the user specifies B. We could have also added a B key to our treatments variable.

What if drug A & B have different set of responses;
eg
For drug B for procedure X with a Good risk profile the out come is Netflix
For drug B for procedure X with a Poor risk profile the out come is Hulu

For drug B for procedure Y with a Good risk profile the out come is Stan
For drug B for procedure Y with a Poor risk profile the out come is YouTube

The above example could be modified to handle that like so:

Drug: {formmenu: name=drug; A; B; C; D}
Procedure: {formmenu: name=procedure; X; Y}
Risk Profile: {formmenu: name=risk; Good; Poor}

{treatments=[
  "A" = [
    "X" = [ "Good" = "abra-cadabra", "Poor" = "hocus-pocus" ],
    "Y" = [ "Good" = "Ali-babba", "Poor" = "Genie" ]
  ],
  "B" = [
    "X" = [ "Good" = "Netflix", "Poor" = "Hulu" ],
    "Y" = [ "Good" = "Stan", "Poor" = "YouTube" ]
  ],
  "C" = [
    "X" = [ "Good" = "Windows", "Poor" = "Apple" ],
    "Y" = [ "Good" = "Linux", "Poor" = "Android" ]
  ],
  "D" = [
    "X" = [ "Good" = "Spotify", "Poor" = "Pandora" ],
    "Y" = [ "Good" = "Deezer", "Poor" = "Google Play" ]
  ]
]}

Outcome: {= treatments[drug][procedure][risk]}

Impressive. This function allows for complex deductive guideline to be simplified as a pre-determined outcome once the many input variables are inserted. Thanks once again.GM

Sorry about this follow up Scott, but I when I applied the above snippet into my guidelines a small gliche happens (as one does).(See below) - I suspect that the list does not recognize the formula/condition that I had set up to minimize the options for the Thrombotic risk (which is dependent on the reason for the anti-platelet agent). Is there a work-around? I did use lower case for the formulae (thrombotic_risk) and although the formula works fine, it is not recognised by the list.

SEE BELOW (hope it makes sense)

{formtoggle: name=Anti_Platelet_Rx;formatter=(value) -> "Anti-platelet medication(s) taken - " if value else ""} {if: Anti_Platelet_Rx}{note} Type {endnote} {formmenu: name=anti_platelet_drug; default= ; Low-dose aspirin; Clopidogrel (Plavix or Iscover); Low-dose aspirin + Clopidogrel (Co-Plavix); Dipyridamole (Persantin or Asasantin)}{note} Duration {endnote} {formmenu: default=;- for 1;- for 2;- for 3;- for 4;- for 5;- for 6;- for 7;- for 8;- for 9;- for 10;- for 11;- for 12;- for 15;- for 20;- for 24;- for 30;- for 36}{formmenu: default=;-day;-days;-week;-weeks;-month;-months;-year;-years}

{formtoggle: name=Reasons_Anti_Platelet_Taken; formatter=(value) -> "Anti-platelet medication(s) taken because of - " if value else ""}{if: Reasons_Anti_Platelet_Taken}{formmenu: name=reason; default= Select; IHD with coronary artery stents inserted within 12 months.; IHD with coronary artery stents inserted over 12 months ago.; IHD without coronary artery stents.; Cerebrovascular disease.; Peripheral vascular disease.;- Other:; trim=left}{if: reason==="- Other:"}{formtext: name=Other reason;default=; trim=left}{endif}

{formtext: default= Patient's thrombotic risk profile for stopping anti-platelet treatment should be considered as:; trim=left} {= thrombotic_risk}{endif}

{thrombotic_risk="HIGH thrombotic risk - thus must continue anti-platelet agents." if (reason==" IHD with coronary artery stents inserted within 12 months.") else "LOW thrombotic risk - thus can stop anti-platelet agents."}

{formtoggle: name=Procedure_Bleeding_Risk; formatter=(value) -> "Procedure Bleeding Risk - " if value else ""} {if: Procedure_Bleeding_Risk} {formmenu: name=proc_bleed_risk; default= ; Low; High}{endif}{endif}

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Anti-Platelet Medication: {formmenu: name=anti_platelet_drug; Low-dose aspirin; Clopidogrel (Plavix or Iscover); Low-dose aspirin + Clopidogrel (Co-Plavix); Dipyridamole (Persantin or Asasantin)}

Patient Thrombotic Risk: {formmenu: name=thrombotic_risk; LOW thrombotic risk - thus can stop anti-platelet agents.; HIGH thrombotic risk - thus must continue anti-platelet agents.}

Procedure Bleeding Risk: {formmenu: name=proc_bleed_risk; Low; High}

{treatments=[

"Low-dose aspirin" = [

"Low" = [ "LOW thrombotic risk - thus can stop anti-platelet agents." = "abra-cadabra", "HIGH thrombotic risk - thus must continue anti-platelet agents" = "hocus-pocus" ],

"High" = [ "LOW thrombotic risk - thus can stop anti-platelet agents." = "Ali-babba", "HIGH thrombotic risk - thus must continue anti-platelet agents" = "Genie" ]

],

"Clopidogrel (Plavix or Iscover)" = [

"Low" = [ "LOW thrombotic risk - thus can stop anti-platelet agents." = "Netflix", "HIGH thrombotic risk - thus must continue anti-platelet agents" = "Hulu" ],

"High" = [ "LOW thrombotic risk - thus can stop anti-platelet agents." = "Stan", "HIGH thrombotic risk - thus must continue anti-platelet agents" = "YouTube" ]

],

"Low-dose aspirin + Clopidogrel (Co-Plavix)" = [

"Low" = [ "LOW thrombotic risk - thus can stop anti-platelet agents." = "Windows", "HIGH thrombotic risk - thus must continue anti-platelet agents" = "Apple" ],

"High" = [ "LOW thrombotic risk - thus can stop anti-platelet agents." = "Linux", "HIGH thrombotic risk - thus must continue anti-platelet agents" = "Android" ]

],

"Dipyridamole (Persantin or Asasantin)" = [

"Low" = [ "LOW thrombotic risk - thus can stop anti-platelet agents." = "Spotify", "HIGH thrombotic risk - thus must continue anti-platelet agents" = "Pandora" ],

"High" = [ "LOW thrombotic risk - thus can stop anti-platelet agents." = "Deezer", "HIGH thrombotic risk - thus must continue anti-platelet agents" = "Google Play" ]

]

]}

Outcome: {= treatments[anti_platelet_drug][proc_bleed_risk][thrombotic_risk]}

The is that for "HIGH thrombotic risk - thus must continue anti-platelet agents", you include a period at the end in your {formmenu} but not in your list. They two strings need to be exactly the same to match.

Here is a fixed version (please make sure to read beyond this snippet as I have another example of how to improve it):

{formtoggle: name=Anti_Platelet_Rx;formatter=(value) -> "Anti-platelet medication(s) taken - " if value else ""} {if: Anti_Platelet_Rx}{note} Type {endnote} {formmenu: name=anti_platelet_drug; default= ; Low-dose aspirin; Clopidogrel (Plavix or Iscover); Low-dose aspirin + Clopidogrel (Co-Plavix); Dipyridamole (Persantin or Asasantin)}{note} Duration {endnote} {formmenu: default=;- for 1;- for 2;- for 3;- for 4;- for 5;- for 6;- for 7;- for 8;- for 9;- for 10;- for 11;- for 12;- for 15;- for 20;- for 24;- for 30;- for 36}{formmenu: default=;-day;-days;-week;-weeks;-month;-months;-year;-years}

{formtoggle: name=Reasons_Anti_Platelet_Taken; formatter=(value) -> "Anti-platelet medication(s) taken because of - " if value else ""}{if: Reasons_Anti_Platelet_Taken}{formmenu: name=reason; default= Select; IHD with coronary artery stents inserted within 12 months.; IHD with coronary artery stents inserted over 12 months ago.; IHD without coronary artery stents.; Cerebrovascular disease.; Peripheral vascular disease.;- Other:; trim=left}{if: reason==="- Other:"}{formtext: name=Other reason;default=; trim=left}{endif}

{formtext: default= Patient's thrombotic risk profile for stopping anti-platelet treatment should be considered as:; trim=left} {= thrombotic_risk}{endif}

{thrombotic_risk="HIGH thrombotic risk - thus must continue anti-platelet agents." if (reason==" IHD with coronary artery stents inserted within 12 months.") else "LOW thrombotic risk - thus can stop anti-platelet agents."}

{formtoggle: name=Procedure_Bleeding_Risk; formatter=(value) -> "Procedure Bleeding Risk - " if value else ""} {if: Procedure_Bleeding_Risk} {formmenu: name=proc_bleed_risk; default= ; Low; High}{endif}{endif}

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Anti-Platelet Medication: {formmenu: name=anti_platelet_drug; Low-dose aspirin; Clopidogrel (Plavix or Iscover); Low-dose aspirin + Clopidogrel (Co-Plavix); Dipyridamole (Persantin or Asasantin)}

Patient Thrombotic Risk: {formmenu: name=thrombotic_risk; LOW thrombotic risk - thus can stop anti-platelet agents.; HIGH thrombotic risk - thus must continue anti-platelet agents.}

Procedure Bleeding Risk: {formmenu: name=proc_bleed_risk; Low; High}

{treatments=[

"Low-dose aspirin" = [

"Low" = [ "LOW thrombotic risk - thus can stop anti-platelet agents." = "abra-cadabra", "HIGH thrombotic risk - thus must continue anti-platelet agents." = "hocus-pocus" ],

"High" = [ "LOW thrombotic risk - thus can stop anti-platelet agents." = "Ali-babba", "HIGH thrombotic risk - thus must continue anti-platelet agents." = "Genie" ]

],

"Clopidogrel (Plavix or Iscover)" = [

"Low" = [ "LOW thrombotic risk - thus can stop anti-platelet agents." = "Netflix", "HIGH thrombotic risk - thus must continue anti-platelet agents." = "Hulu" ],

"High" = [ "LOW thrombotic risk - thus can stop anti-platelet agents." = "Stan", "HIGH thrombotic risk - thus must continue anti-platelet agents." = "YouTube" ]

],

"Low-dose aspirin + Clopidogrel (Co-Plavix)" = [

"Low" = [ "LOW thrombotic risk - thus can stop anti-platelet agents." = "Windows", "HIGH thrombotic risk - thus must continue anti-platelet agents." = "Apple" ],

"High" = [ "LOW thrombotic risk - thus can stop anti-platelet agents." = "Linux", "HIGH thrombotic risk - thus must continue anti-platelet agents." = "Android" ]

],

"Dipyridamole (Persantin or Asasantin)" = [

"Low" = [ "LOW thrombotic risk - thus can stop anti-platelet agents." = "Spotify", "HIGH thrombotic risk - thus must continue anti-platelet agents." = "Pandora" ],

"High" = [ "LOW thrombotic risk - thus can stop anti-platelet agents." = "Deezer", "HIGH thrombotic risk - thus must continue anti-platelet agents." = "Google Play" ]

]

]}

Outcome: {= treatments[anti_platelet_drug][proc_bleed_risk][thrombotic_risk]}

This example illustrates something that is an interesting point. Generallu you don't want to hard code long strings like "HIGH thrombotic risk - thus must continue anti-platelet agents." multiple times as it can make it hard to change them or make sure they always match. One way to address this is to pull these labels into variables that allow you to reuse them. I've done that below.

This makes the snippet more readable and makes it very easy to change the labels if you need to down the road.

{formtoggle: name=Anti_Platelet_Rx;formatter=(value) -> "Anti-platelet medication(s) taken - " if value else ""} {if: Anti_Platelet_Rx}{note} Type {endnote} {formmenu: name=anti_platelet_drug; default= ; Low-dose aspirin; Clopidogrel (Plavix or Iscover); Low-dose aspirin + Clopidogrel (Co-Plavix); Dipyridamole (Persantin or Asasantin)}{note} Duration {endnote} {formmenu: default=;- for 1;- for 2;- for 3;- for 4;- for 5;- for 6;- for 7;- for 8;- for 9;- for 10;- for 11;- for 12;- for 15;- for 20;- for 24;- for 30;- for 36}{formmenu: default=;-day;-days;-week;-weeks;-month;-months;-year;-years}

{formtoggle: name=Reasons_Anti_Platelet_Taken; formatter=(value) -> "Anti-platelet medication(s) taken because of - " if value else ""}{if: Reasons_Anti_Platelet_Taken}{formmenu: name=reason; default= Select; IHD with coronary artery stents inserted within 12 months.; IHD with coronary artery stents inserted over 12 months ago.; IHD without coronary artery stents.; Cerebrovascular disease.; Peripheral vascular disease.;- Other:; trim=left}{if: reason==="- Other:"}{formtext: name=Other reason;default=; trim=left}{endif}

{formtext: default= Patient's thrombotic risk profile for stopping anti-platelet treatment should be considered as:; trim=left} {= thrombotic_risk}{endif}

{thrombotic_risk="HIGH thrombotic risk - thus must continue anti-platelet agents." if (reason==" IHD with coronary artery stents inserted within 12 months.") else "LOW thrombotic risk - thus can stop anti-platelet agents."}

{formtoggle: name=Procedure_Bleeding_Risk; formatter=(value) -> "Procedure Bleeding Risk - " if value else ""} {if: Procedure_Bleeding_Risk} {formmenu: name=proc_bleed_risk; default= ; Low; High}{endif}{endif}

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Anti-Platelet Medication: {formmenu: name=anti_platelet_drug; Low-dose aspirin; Clopidogrel (Plavix or Iscover); Low-dose aspirin + Clopidogrel (Co-Plavix); Dipyridamole (Persantin or Asasantin)}

{low_risk_label="LOW thrombotic risk - thus can stop anti-platelet agents."}
{high_risk_label="HIGH thrombotic risk - thus must continue anti-platelet agents."}
Patient Thrombotic Risk: {formmenu: name=thrombotic_risk; {=low_risk_label}; {=high_risk_label}}

Procedure Bleeding Risk: {formmenu: name=proc_bleed_risk; Low; High}

{treatments=[

"Low-dose aspirin" = [

"Low" = [ low_risk_label = "abra-cadabra", high_risk_label = "hocus-pocus" ],

"High" = [ low_risk_label = "Ali-babba", high_risk_label = "Genie" ]

],

"Clopidogrel (Plavix or Iscover)" = [

"Low" = [ low_risk_label = "Netflix", high_risk_label = "Hulu" ],

"High" = [ low_risk_label = "Stan", high_risk_label = "YouTube" ]

],

"Low-dose aspirin + Clopidogrel (Co-Plavix)" = [

"Low" = [ low_risk_label = "Windows", high_risk_label = "Apple" ],

"High" = [ low_risk_label = "Linux", high_risk_label = "Android" ]

],

"Dipyridamole (Persantin or Asasantin)" = [

"Low" = [ low_risk_label = "Spotify", high_risk_label = "Pandora" ],

"High" = [ low_risk_label = "Deezer", high_risk_label = "Google Play" ]

]

]}

Outcome: {= treatments[anti_platelet_drug][proc_bleed_risk][thrombotic_risk]}

Hi Scott,

Sorry to bother you but although the sections below xxxxxxxxxxxx separator works fine the actual equation to derive thrombotic_risk above the separator doesn't work after the second initial variable (reason) is selected.

It seems to work backwards, ie if I pick HIGH thrombotic risk - thus ... in the formmenu for Patient Thrombotic Risk:below the separator it will also appear above the separator even if it does NOT obey the eqations rules for thrombotic_risk.

The purpose is to input the 3 variables at the beginning, see the correct Patient Thrombotic Risk Profile and derive an outcome (guideline).

To simplify I have isolated the section that I suspect doesn't seen to work and placed it below for your perusal:

{formtoggle: name=Reasons_Anti_Platelet_Taken; formatter=(value) -> "Anti-platelet medication(s) taken because of - " if value else ""}{if: Reasons_Anti_Platelet_Taken}{formmenu: name=reason; default= Select; IHD with coronary artery stents inserted within 12 months.; IHD with coronary artery stents inserted over 12 months ago.; IHD without coronary artery stents.; Cerebrovascular disease.; Peripheral vascular disease.;- Other:; trim=left}{if: reason==="- Other:"}{formtext: name=Other reason;default=; trim=left}{endif}

{thrombotic_risk="HIGH thrombotic risk - thus must continue anti-platelet agents." if (reason==" IHD with coronary artery stents inserted within 12 months.") else "LOW thrombotic risk - thus can stop anti-platelet agents."}

{formtext: default= Patient's thrombotic risk profile for stopping anti-platelet treatment should be considered as:; trim=left} {= thrombotic_risk}{endif}

It appears the issue here is you have an extra space in the string in your comparison.

(reason==" IHD with coronary artery stents inserted within 12 months.")

Should be:

(reason=="IHD with coronary artery stents inserted within 12 months.")

(Note the removal of the space before "IHD")

This is a great example of where using a label variable for these strings that are referenced multiple times would be useful.

Thanks, so simple in hindsight.
So grateful. GM

Hi Scott,
I am asking for a Genie out of a Bottle!
Having fixed the issue of deriving a single predetermined outcome /output once 3 variables have been inputed, a neat snippet is completed (which does need your assistance tidying up to make it presentable) however my issue now is that I want to make it an active decision as to whether or not to proceed with the snippet and not a passive decision.
Let me explain, With your toggle function if the button is not pressed there is an opportunity to leave a message and state "No anti-platelet medication is currently taken." However, this is a passive option in the eyes of professional body, in that is being done by omission.
They have asked that before the snippet for anti-platelet treatment be seen that the question be asked, is the patient currently taking anti-platelet medication? If No then the statement "No anti-platelet medication is currently taken." can appear. If Yes is ticked then then snippet for anti-platelet treatment appears (nicely formatted). Is that possible? A Genie out of a Bottle!

Not sure where to submit this query is it part of this string or a new one. However I forgot to add the snippet that I was hoping to get tidied up before it was revealed by a yes toggle. It is:

{formtoggle: name=Anti_Platelet_Rx;formatter=(value) -> "Anti-platelet medication(s) taken - " if value else "No anti-platelet medication, such as a regular low-dose aspirin, is prescribed"} {if: Anti_Platelet_Rx}{note} Type {endnote} {formmenu: name=anti_platelet_drug; default= Low-dose aspirin; Clopidogrel (Plavix or Iscover); Low-dose aspirin + Clopidogrel (Co-Plavix); Dipyridamole (Persantin or Asasantin)}{note} Duration {endnote} {formmenu: default=;- for 1;- for 2;- for 3;- for 4;- for 5;- for 6;- for 7;- for 8;- for 9;- for 10;- for 11;- for 12;- for 15;- for 20;- for 24;- for 30;- for 36}{formmenu: default=;-day;-days;-week;-weeks;-month;-months;-year;-years}

{formtoggle: name=Reasons_Anti_Platelet_Taken; formatter=(value) -> "Anti-platelet medication(s) taken because of - " if value else ""}{if: Reasons_Anti_Platelet_Taken}{formmenu: name=reason; default=IHD with coronary artery stents inserted within 12 months;IHD with coronary artery stents inserted over 12 months ago;IHD without coronary artery stents;Cerebrovascular disease;Peripheral vascular disease;- Other}{if: reason==="- Other"}{formtext: name=Other reason;default=}{endif}

{formtext: default= Patient's thrombotic risk profile for stopping anti-platelet treatment should be considered as:; trim=left} {= thrombotic_risk}{endif}

{thrombotic_risk="HIGH thrombotic risk - thus must continue anti-platelet agents." if (reason=="IHD with coronary artery stents inserted within 12 months") else "LOW thrombotic risk - thus can stop anti-platelet agents."} {formtoggle: name=Procedure_Bleeding_Risk; formatter=(value) -> "Procedure Bleeding Risk - " if value else ""} {if: Procedure_Bleeding_Risk} {formmenu: name=proc_bleed_risk; default= Low; High}{endif}

Outcome: {= treatments[anti_platelet_drug][proc_bleed_risk][thrombotic_risk]}

{note} Anti-Platelet Rx: {formmenu: name=anti_platelet_drug; Low-dose aspirin; Clopidogrel (Plavix or Iscover); Low-dose aspirin + Clopidogrel (Co-Plavix); Dipyridamole (Persantin or Asasantin)}{low_risk_label="LOW thrombotic risk - thus can stop anti-platelet agents."}{high_risk_label="HIGH thrombotic risk - thus must continue anti-platelet agents."} Patient Thrombotic Risk: {formmenu: name=thrombotic_risk; {=low_risk_label}; {=high_risk_label}} Procedure Bleeding Risk: {formmenu: name=proc_bleed_risk; Low; High}{treatments=["Low-dose aspirin" = ["Low" = [ low_risk_label = "abra-cadabra", high_risk_label = "hocus-pocus" ],"High" = [ low_risk_label = "Ali-babba", high_risk_label = "Genie" ]],"Clopidogrel (Plavix or Iscover)" = ["Low" = [ low_risk_label = "Netflix", high_risk_label = "Hulu" ],"High" = [ low_risk_label = "Stan", high_risk_label = "YouTube" ]],"Low-dose aspirin + Clopidogrel (Co-Plavix)" = ["Low" = [ low_risk_label = "Windows", high_risk_label = "Apple" ],"High" = [ low_risk_label = "Linux", high_risk_label = "Android" ]],"Dipyridamole (Persantin or Asasantin)" = ["Low" = [ low_risk_label = "Spotify", high_risk_label = "Pandora" ],"High" = [ low_risk_label = "Deezer", high_risk_label = "Google Play" ]]]}{endnote: trim=yes}{endif}

Not sure I fully understand this. Is the goal to prevent the professional from continuing until they have manually filled in the "No anti-platelet medication is currently taken"? I.e. you don't want them to be able to just go through the defaults as it may increase the risk of them missing something or making a mistake.

Is that correct?

If so, you can you the {error} command to prevent submission of the form until certain form fields have been filled out or other conditions have been met.

It' quite flexible so you can use it for whatever validation you need. Let me know if that is what you were looking for.

Sorry Scott, I sent that query quickly between patients. I will try to elucidate.
When a clinician is presented with the query Do you take Anti-Platelets meds? With the usual formtoggle the clinician is presented with the choice of either ticking the box (meaning yes and all the choices open up) or leaving it empty at which time a preset negative response will be inserted saying something like "No anti-platelet medication is currently taken." However, this is considered to be a passive option by the professional body that I belong to, in that the negative option is being done by omission and not actively thought about or asked of the patient. They require that there be a NO option to be selected either by toggle or menu, which results in the statement "No anti-platelet medication is currently taken." ie it does not simply appear because a clinician forgot or omitted to tick the yes toggle.
Likewise, when the Yes toggle is ticked the entire snippet as shown above appears - like a Genie in a Bottle. What I was hoping for, if I dare to ask, was help in tidying the snippet up.
At present I enter the name of the drug (necessary to show) and duration (necessary to show), then the reason the patient is taking the drug (necessary to show) and this derives the Thrombotic Risk (necessary to show) following which the clinician enters the final variable the procedure risk (necessary to show). Once these 3 variables are entered and the Thrombotic Risk derived a guideline is shown in bright lights. All else (such as the 3 formmenu fields) should be hidden from sight. Using {note}{endnote} will hide them from showing up in the final document but they still appear in the preview and some doctors may be confused and try enter data again. Is there a way to make them invisible? Hope this is clear. The aim is to try to make the template as elegant as possible for a presentation.
Thank yo for all your time and patience.
GeorgeM

As to the {error} question (which I presume is a road block), the clinician may choose not to ask a certain question and simply omit asking that question if it is not relevant. and continue with the next question they feel appropriate (indeed in a patient interview using a structured questionnaire template a good clinician will only ask relevant questions and omit many). Therefore answers can only be documented to those questions that were actually asked not those that were omitted (even if they are negative responses such as No a medication is not taken) and so the error function cannot be used here as a road block.

If I understand it right, you have a binary decision and you want to make sure the user explicitly chooses one of the two options.

In that case, I don't think the toggle isn't the right choice in this case as it only has binary yes/no outcomes. What you need is something with three outcomes: yes/no/not entered.

To do that, I would use the {formmenu} command rather than the toggle and have the default option be something like "Undecided" or "Please Select". You could then use the {error} command to prevent the form being submitted while they were on that default option if you wanted to.

My question is - does the formmenu approach of No / Yes have the option of skipping a question without having to enter any data and thus not print (unless the default is blank?) Is that correct, if default= ; No; Yes; trim left} will that mean if the question is skipped the default answer in empty and there is nothing printed?

But then the issue is how does picking the Yes option on the formmenu open up the remainder of the snippet? Is this where the {import} function can help? As you can see I am struggling to see this project to its end. But hopeful and close.

And finally tidying the snippet up as mentioned above:at present I enter the name of the drug (necessary to show) and duration (necessary to show), then the reason the patient is taking the drug (necessary to show) and this derives the Thrombotic Risk (necessary to show) following which the clinician enters the final variable the procedure risk (necessary to show). Once these 3 variables are entered and the Thrombotic Risk derived a guideline is shown in bright lights. All else (such as the 3 formmenu fields) should be hidden from sight. Using {note}{endnote} will hide them from showing up in the final document but they still appear in the preview and some doctors may be confused and try enter data again. Is there a way to make them invisible?

Sorry Scott,

Just further reading your answer, the clinician always has the choice to skip a question without entering a value and in such a case there should be NO documentation of the question or the answer.

If he answers No then it should state that the patient takes no meds

If he answers Yes then the snippet opens up and further answers are required and a guideline/outcome is produced.

GeorgeM

When using {formmenu} with three options to gate content, you can use the {if} command to dynamically show it the gated content

The following example illustrates this (with an {error} command to prevent form submission until an option is selected -- this is optional, I just wanted to illustrate it):

Select Option: {formmenu: default=...; Option A; Option B; name=option}

{if: option == "..."}
{error: You must select an option!; block=yes}
{else}
{if: option == "Option A"}
Option A selected. Please also fill in...
{else}
Option B selected. Please also fill in...
{endif}
{endif}

To your second question, you can also use the {if} command. You can have an {if} command around the content you want to hide later on that because disabled once the three variables are set.