How can I avoid errors using a complex snippet when I need to re-run the snippet because I want to change an initial variable?

Hi Scott &/or Dan,

Below is a complex snippet regarding Family History of Colon Cancer - to be used in a questionnaire.

https://dashboard.blaze.today/snippet/5SagsVhl7hQKIkByZwkG

If there is no known Family History of Colon Cancer -> simple single output of "nil known"

If there is a known Family History of Colon Cancer then the affected members need to identified and categorised. There May be only ONE family member or more (2, 3, 4) - rarely is there more than 4. The above example/snippet can only identify & categorise 3. Too hard and complex for me to build it up to 4 - but preferred if possible?

Once the number of family members is determined (usually it unfolds during questioning of patient), the affected member needs to identified as first degree relative (FDR) or second degree relative (SDR).

If FDR then identified as Father; Mother; Older Brother; Younger Brother; Older Sister; Younger Sister.
If SDR then identified as Grandparent; Maternal Grandfather; Paternal Grandfather; Maternal Grandmother; Paternal Grandmother; Maternal Aunt; Paternal Aunt; Maternal Uncle; Paternal Uncle; Maternal Cousin; Paternal Cousin; Maternal Nephew; Paternal Nephew; Maternal Niece; Paternal Niece

Once the family member is identified, then the age group at the time of diagnosis of the colon cancer - either ≤ 55 years of age at diagnosis or > 55 years of age at diagnosis.

Once an age group is identified then the exact age at diagnosis needs to inputted.

Many times the last 2 input are not known and left out.

If a second family member is affected, all the above happens again and so on for a 3rd affected family member; otherwise remains clear.

The snippet works well apart from the fact that after choosing FDR vs SDR and then identifying the type of family member (eg Father, etc) you cannot change these variables as errors appear in the form of "extra" age inputs - which is confusing and the final output is unusable.

How can I avoid errors using a complex snippet when I need to re-run the snippet because I want to change an initial variable?

Thanks again

George Marinos

Hi @George_Marinos - The link you shared is to your personal dashboard, so we can't see it. Could you kindly share the snippet through the "Sharing" tab in your dashboard please? This will add it to the "Snippet Repository". You'll get a link that you can share here.

Thanks Cedric - have shared the snippet.

The error can be elicited by
Step 1 - choose "Yes" to first question (Family History of Colon Cancer)
Step 2 - choose "FDR" for "Select FDR or SDR
Step 3 - choose "Father" (or any selection) for "Select family member"
Step 4 - choose "≤ 55 years of age at diagnosis of CRC" for "Select age group at diagnosis of CRC"
Step 5 - choose ": age at diagnosis was in their 20s" for "Select age at diagnosis of CRC"
So far it works well and correctly.

However, the patient had made an error and it was not his Father who had colon cancer but a second degree relative such as Grandparent (still only dealing with one family member) and so...

Step 6 - change "FDR" in column 2 to "SDR" for "Select FDR or SDR"
Step 7 - choose "Grandparent" (or any selection) for "Select family member" in column 3

This is where the error appears as an EXTRA column for "Select age group at diagnosis of CRC" which if selected then a further column for "Select age at diagnosis of CRC"

The error is also replicated for 2nd & 3rd family members

Hope you understand & hope you can help.

Cheers

George Marinos

Wow, that's a beast of a snippet hehe. Ok, gimme some time to tear it apart and chew on it.

On a side note, you might want to start using the trim=yes setting to make your snippet easier to follow. This isn't a problem when the snippet is still fresh in your mind, but if you decide to change something a few weeks from now, you'll be tearing your hair out :slight_smile:

You can read about trim here: https://blaze.today/commands/formula/https://blaze.today/commands/formula/

@George_Marinos:

Here's an updated version of the snippet:

{note: trim=left; preview=no}
Lists:
First Degree Relatives: {firstDegreeRelative=["", "Father", "Mother", "Older Brother", "Younger Brother", "Older Sister", "Younger Sister"]}{=firstdegreerelative}

Second Degree Relatives: {secondDegreeRelative=["", "Grandparent", "Maternal Grandfather", "Paternal Grandfather", "Maternal Grandmother", "Paternal Grandmother", "Maternal Aunt", "Paternal Aunt", "Maternal Uncle", "Paternal Uncle", "Maternal Cousin", "Paternal Cousin", "Maternal Nephew", "Paternal Nephew", "Maternal Niece", "Paternal Niece"]}{=seconddegreerelative}

Age Group 1: {ageGroup01=["", "in their 20s", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "in their 30s", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "in their 40s", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "in their early 50s", "50", "51", "52", "53", "54", "55"]}{=agegroup01}

Age Group 2: {ageGroup02=["", "in their late 50s", "56", "57", "58", "59", "in their 60s", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "in their 70s", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "in their 80s", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "in their 90s"]}{=agegroup02}

Age Group 3: {ageGroup03=["", "≤ 55 years of age at diagnosis of CRC", "> 55 years of age at diagnosis of CRC"]}{=agegroup03}

{endnote: trim=right}

Number of family members with a history of Colon Cancer:
{note: trim=left} {formtext: name=familymembers; default=0}

{endnote: trim=right}
{repeat: familymembers}

{note}
Select FDR or SDR: {formmenu: \ ; FDR; SDR; name=fhcrc}
{endnote: trim=right}
{if: fhcrc=="FDR"; trim=yes}
Select Family Member: {formmenu: values={=firstdegreerelative}; name=FDR}
{else: trim=right}
Select Family Member: {formmenu: values={=secondDegreeRelative}; name=SDR}
{endif: trim=right}
Age group at diagnosis of CRC: {formmenu: values={=agegroup03}; name=agegroup}
{if: agegroup=="≤ 55 years of age at diagnosis of CRC"; trim=right}
Age at diagnosis of CRC: {formmenu: values={=agegroup01}; name=age_at_dx_under_55}
{else: trim=right}
Age at diagnosis of CRC: {formmenu: values={=agegroup02}; name=age_at_dx_over_55}
{endif}{endrepeat}

Wow! Such a different approach. Much simpler and neater & certainly effective.

Is there any way to name each family, such as Family member 1, Family member 2, Family member 3, Family member 4, ....

This is very nice work Cedric

Thank you
George Marinos

Well, you could do it manually with a text field at the beginning. If you want it automated, there should be a way to do it, but I'm not sure how. I'm sure @scott would be able to share a way though.

@scott - I'm thinking something with for x in y etc, but I'm no good at those.

Something like this would work to add a label with a numeric index for each family member:

{note: trim=left; preview=no}
Lists:
First Degree Relatives: {firstDegreeRelative=["", "Father", "Mother", "Older Brother", "Younger Brother", "Older Sister", "Younger Sister"]}{=firstdegreerelative}

Second Degree Relatives: {secondDegreeRelative=["", "Grandparent", "Maternal Grandfather", "Paternal Grandfather", "Maternal Grandmother", "Paternal Grandmother", "Maternal Aunt", "Paternal Aunt", "Maternal Uncle", "Paternal Uncle", "Maternal Cousin", "Paternal Cousin", "Maternal Nephew", "Paternal Nephew", "Maternal Niece", "Paternal Niece"]}{=seconddegreerelative}

Age Group 1: {ageGroup01=["", "in their 20s", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "in their 30s", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "in their 40s", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "in their early 50s", "50", "51", "52", "53", "54", "55"]}{=agegroup01}

Age Group 2: {ageGroup02=["", "in their late 50s", "56", "57", "58", "59", "in their 60s", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "in their 70s", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "in their 80s", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "in their 90s"]}{=agegroup02}

Age Group 3: {ageGroup03=["", "≤ 55 years of age at diagnosis of CRC", "> 55 years of age at diagnosis of CRC"]}{=agegroup03}

{endnote: trim=right}

Number of family members with a history of Colon Cancer:
{note: trim=left} {formtext: name=familymembers; default=0}

{endnote: trim=right}
{repeat: for i in (seq(1, familymembers) if familymembers > 0 else [])}
Family Member {=i}
Select FDR or SDR: {formmenu: \ ; FDR; SDR; name=fhcrc}
{endnote: trim=right}
{if: fhcrc=="FDR"; trim=yes}
Select Family Member: {formmenu: values={=firstdegreerelative}; name=FDR}
{else: trim=right}
Select Family Member: {formmenu: values={=secondDegreeRelative}; name=SDR}
{endif: trim=right}
Age group at diagnosis of CRC: {formmenu: values={=agegroup03}; name=agegroup}
{if: agegroup=="≤ 55 years of age at diagnosis of CRC"; trim=right}
Age at diagnosis of CRC: {formmenu: values={=agegroup01}; name=age_at_dx_under_55}
{else: trim=right}
Age at diagnosis of CRC: {formmenu: values={=agegroup02}; name=age_at_dx_over_55}
{endif}{endrepeat}

1 Like

Thank you Scott. Impressive.

I have a related problem, which I thought your above solution can be applied, however I cannot solve it. Hoping you guys can help.

I have generated a series of questions (each question represented by a single snippet - like above "How many family members have colon cancer") which my medical students use to examine patients. The purpose is for teaching at university and to standard medical history taking (also to ensure completeness and standardise the medical examination of a patient to a certain problem). Originally the questions were designed for a medically trained person but now I would like the questions to be answered directly by the patient (direct access and time saver). Most questions are easy "Yes" or "No" and can be easily reworded and reformatted BUT unfortunately there are 2 closely related questions (both very complex but similar snippets) that I need to amalgamate, but I just can't seem to do it.

The premise is, many patients take some form of a "Blood Thinner" to partially inhibit or prevent coagulation of the blood. There are 2 groups of these blood thinners, Anti-Platelet Agents and Anti-Coagulant Medication. The Anti-Platelet Agents are either (1) Low-dose aspirin (Cartia or Astrix) (2) Clopidogrel (Plavix or Iscover) (3) Low-dose aspirin + Clopidogrel (Co-Plavix) or (4) Dipyridamole (Persantin or Asasantin). The Anti-Coagulant Medication are (1) Warfarin (2) Apixaban (Eliquis) (3) Rivaroxaban (Xarelto) or (4) Dabigatran (Pradaxa). The 2 groups of drugs ( Anti-Platelet Agents and Anti-Coagulant Medication) are prescribed for 2 different set of reasons. Depending on what which drug you take and for which reason there a set guidelines to instruct the patient how to stop the medication before surgery/procedure and how to restart after the surgery/procedure. Patients can also take one drug from each group (ie an Anti-Platelet Agent as well as an Anti-Coagulant Medication) for 2 different reasons and therefore need separate guidelines for each medication.

For the Dr and medical student it is easy to keep the 2 questions separate (as I have done and will share at the end of this long-winded enquiry) BUT for patients it is not feasible to ask the question (1) Do you take an Anti-Platelet Agent? and (2) Do you take an Anti-Coagulant Medication? The patient doesn't know what this class of medications are.

What I would like to be able to do (using a simplified approach - as above) is to ask ONE question only -> Do you take any Blood Thinning Medication? which the patient will understand.

The patient may pick 1, 2 or 3 choices from a complete list of Blood Thinning medications -> (1) Low-dose aspirin (Cartia or Astrix) (2) Clopidogrel (Plavix or Iscover) (3) Low-dose aspirin + Clopidogrel (Co-Plavix) (4) Dipyridamole (Persantin or Asasantin) (5) Warfarin (6) Apixaban (Eliquis) (7) Rivaroxaban (Xarelto) or (8) Dabigatran (Pradaxa) and depending on the answer, be presented with a choice of Why the medication is prescribed? (set of reasons will vary depending on which group the drug belongs to Anti-Platelet Agents or Anti-Coagulant Medication, and then generate a predetermined guideline for each medication taken. I hope it isn't too confusing. I think going through the 2 snippets may make it easier.

I have shared the snippets that I would like to combine in a simplified way below.

Thanks if you can help.

George

Hi Cedric - one thing that intrigued me was the line
-> Select FDR or SDR: {formmenu: \ ; FDR; SDR; name=fhcrc}

What was the purpose of " \ " ; is it important? Can it be replaced by "Select FDR or SDR"

Thanks again

George

I used it to make the first option a blank space. The reason for the backslash is to "escape" the empty space and treat it as an actual space rather than part of the command.

Yes, it can absolutely be replaced with anything you want :slight_smile:

I see what you're trying to do. Gonna need some time to figure out a good solution. Please bear with me :slight_smile:

I'm thinking the first step would be to create two lists for the two categories, and then merging them to create the values for the dropdown menu like so:

{anti_platelet_drug=["Low-dose aspirin", "Clopidogrel (Plavix or Iscover)", "Low-dose aspirin + Clopidogrel (Co-Plavix)", "Dipyridamole (Persantin or Asasantin)"]; trim=yes}
{anti_coagulant_drug=["Warfarin", "Eliquis (Apixaban)", "Xarelto (Rivaroxaban)", "Pradaxa (Dabigatran)"]; trim=yes}
{allmeds=merge(anti_platelet_drug, anti_coagulant_drug); trim=yes}

Please tick which medications you're taking:
{formmenu: name=medication; values={=allmeds}; multiple=yes}

Hi Cedric,
Yes I agree. However the FIRST QUESTION TO BE ASKED IS "Do you take ANY Blood-Thinning Medication?"

If no -> end of question trail.

If yes -> the patient is then presented with the question "Which Blood-Thinning medication do you take?" and they choose from the list you setup, with the anti-platelet agents listed on top and the anti-coagulant agents below. It must be noted that some patients can take up to 3 different Blood-Thinning medication.

Next they will need to pick a reason for taking each agent, and this in turn will derive a predetermined Guideline to withdraw and restart the medication before and after a procedure, respectively.

Well, the first question is easy to implement.

Do you take ANY Blood-Thinning Medication? {formmenu: name=medstaken; \ ; Yes; No; cols=8}
{if: medstaken==""}This question is mandatory{elseif: medstaken=="Yes"}
{anti_platelet_drug=["Low-dose aspirin", "Clopidogrel (Plavix or Iscover)", "Low-dose aspirin + Clopidogrel (Co-Plavix)", "Dipyridamole (Persantin or Asasantin)"]; trim=yes}
{anti_coagulant_drug=["Warfarin", "Eliquis (Apixaban)", "Xarelto (Rivaroxaban)", "Pradaxa (Dabigatran)"]; trim=yes}
{allmeds=merge(anti_platelet_drug, anti_coagulant_drug); trim=yes}

Please tick which medications you're taking:
{formmenu: name=medication; values={=allmeds}; multiple=yes}
{elseif: medstaken=="No"}{endif}

@George_Marinos

Maybe something along these lines:

{note: trim=yes}

{anti_platelet_drug=["Low-dose aspirin", "Clopidogrel (Plavix or Iscover)", "Low-dose aspirin + Clopidogrel (Co-Plavix)", "Dipyridamole (Persantin or Asasantin)"]; trim=yes}

{anti_coagulant_drug=["Warfarin", "Eliquis (Apixaban)", "Xarelto (Rivaroxaban)", "Pradaxa (Dabigatran)"]; trim=yes}

{allmeds=merge(anti_platelet_drug, anti_coagulant_drug); trim=yes}

{endnote: trim=yes}

Do you take ANY Blood-Thinning Medication? {formmenu: name=medstaken; \ ; Yes; No; cols=8; trim=right}

{if: medstaken=="No"}

No medication taken.

{elseif: medstaken=="Yes"}

Please choose which medication you are currently taking: {formmenu: name=medication; values={=allmeds}; multiple=yes; cols=35}

{if: medication==[]}{else}Reason for taking medication: {formmenu: name=anti_platelet_reason; default=Select reason for taking Anti-Platelet Agent; IHD without coronary artery stents; IHD with coronary artery stents inserted over 12 months ago; IHD with coronary artery stents inserted within 12 months; Cerebrovascular disease;Peripheral vascular disease; NO recognised clinical indication for taking this treatment}

{endif: trim=right}

{if: includes(medication, "Low-dose aspirin")}

For Low-dose aspirin:

{if: anti_platelet_reason == "IHD with coronary artery stents inserted within 12 months"}Do not stop low-dose aspirin before procedure - ONLY omit on day of procedure; restart low-dose aspirin on the next day after procedure.{elseif: anti_platelet_reason == "NO recognised clinical indication for taking this treatment"}Stop low-dose aspirin for 5-days prior procedure; restart low-dose aspirin 7 days after the procedure if biopsy specimens are taken; otherwise if no biopsy specimens are taken restart low-dose aspirin on the next day after procedure.{elseif: includes(["IHD without coronary artery stents", "IHD with coronary artery stents inserted over 12 months ago", "Cerebrovascular disease", "Peripheral vascular disease"], anti_platelet_reason)}Stop low-dose aspirin ONLY for 2-days prior procedure; restart low-dose aspirin on the next day after procedure.

{endif}{endif: trim=right}

{if: includes(medication, "Clopidogrel (Plavix or Iscover)")}

For Clopidogrel (Plavix or Iscover):

{if: anti_platelet_reason == "IHD with coronary artery stents inserted within 12 months"}Discontinue Clopidogrel medication 7 days before the procedure & replace with low-dose aspirin; do not stop low-dose aspirin before procedure - ONLY omit on day of procedure & restart low-dose aspirin on the next day after procedure; restart Clopidogrel medication 7 days after the procedure (and stop low-dose aspirin) if biopsy specimens are taken; otherwise if no biopsy specimens are taken restart Clopidogrel medication on the next day after the procedure (and stop low-dose aspirin).{elseif: anti_platelet_reason == "NO recognised clinical indication for taking this treatment"}Discontinue Clopidogrel medication therapy 7 days before the procedure. Restart Clopidogrel medication 7 days after the procedure if biopsy specimens taken; otherwise if no biopsy specimens are taken restart Clopidogrel medication on the next day after the procedure.{elseif: includes(["IHD without coronary artery stents", "IHD with coronary artery stents inserted over 12 months ago", "Cerebrovascular disease", "Peripheral vascular disease"], anti_platelet_reason)}Discontinue Clopidogrel medication 7 days before the procedure & replace with low-dose aspirin; stop low-dose aspirin 2-days before procedure & restart low-dose aspirin on the next day after procedure; restart Clopidogrel medication 7 days after the procedure (and stop low-dose aspirin) if biopsy specimens are taken; otherwise if no biopsy specimens are taken restart Clopidogrel medication on the next day after the procedure (and stop low-dose aspirin).

{endif}{endif: trim=right}

{else} This question is mandatory{endif}

Hi Cedric,
Close but not right -> because for each drug there is a different set of reasons for taking the medications. There are 2 groups of reasons: one set for Anti-Platelet agents and one set for Anti-Coagulant Medication; PLUS there are separate guidelines for each medication.

Sorry, Maybe I didn't look at your snippet to closely and it is incomplete?

Not sure how to introduce the anti-coagulant medication which have a different set of reasons to take the medications and different guidelines?

A bit too complex for me. I will try.

In the line
{if: medication==[]}{else}Reason for taking medication: {formmenu: name=anti_platelet_reason; default=Select reason for taking Anti-Platelet Agent; IHD without coronary artery stents; IHD with coronary artery stents inserted over 12 months ago; IHD with coronary artery stents inserted within 12 months; Cerebrovascular disease;Peripheral vascular disease; NO recognised clinical indication for taking this treatment}

Not sure what [] denotes and how do I insert "{elseif: medication=="anti_coagulant_drug"}Reason for taking medication: {formmenu: name=anti_coagulant_reason; default=Select reason for taking Anti-Coagulant Medication; AF without valvular disease;AF and mitral stenosis;Prosthetic metal heart valve and AF;Prosthetic metal heart valve in mitral position;Prosthetic metal heart valve in aortic position;Xenograft heart valve;Greater than 6-months after Pulmonary Embolism or Deep Venous Thrombosis;Less than 6-months after Pulmonary Embolism or Deep Venous Thrombosis;Thrombophilia syndromes}"

George

Cheers
George

Hi Guys,
Below is my attempt, using Cedric's lead.

I don't think it's ideal, because the patient is prompted to give 2 reasons that medications are taken if even the patient only takes ONE group of medications. But I just could not solve the problem.

I am hopeful that it can be improved. Any suggestions? Help!

Ok, quick question — can there be only ONE reason for taking medication from each category? i.e. could the patient have multiple reasons for taking anti-platelet meds, and multiple reasons for taking anti-coagulents?

Because if there can only be one reason for each of the categories, I'd just put all of the reasons in one list, with the question: "Reason for taking medication"

{reasonslist=["IHD without coronary artery stents", "IHD with coronary artery stents inserted over 12 months ago", "IHD with coronary artery stents inserted within 12 months", "Cerebrovascular disease;Peripheral vascular disease", "NO recognised clinical indication for taking this treatment", "AF without valvular disease", "AF and mitral stenosis;Prosthetic metal heart valve and AF", "Prosthetic metal heart valve in mitral position", "Prosthetic metal heart valve in aortic position", "Xenograft heart valve;Greater than 6-months after Pulmonary Embolism or Deep Venous Thrombosis", "Less than 6-months after Pulmonary Embolism or Deep Venous Thrombosis", "Thrombophilia syndromes"]}

Reason for taking medication: {formmenu: name=reasons; multiple=yes; values={=reasonslist}}{if: reasons==[]} Please select the relevant conditions{endif: trim=right}

Then you can query the reasons variable in each med and give the indications accordingly. What do you think?

As for the [], that's a condition for when no choice is made i.e. it denotes an empty list.

Hi Cedric,

That will work re: reasons as there is only 1 reason per class of meds.

However my attempts to integrate the above snippet into the whole Blood Thinning guidelines failed

Any ideas?

George