More help with "if and else if" PLUS is it possible to search within a Formmenu

What I would like to do is to have a drop down menu that can be easily looked up by typing 1 or 2 words from a large list of 30 choices. Once the choice is made it will derive of of 6 codes say A, B, C, D, E, F and these in turn equate to a condition (A = 3 year recall; B = 4 year recall, C = 5 year recall etc).

I failed and batched the last two conditions together (which is not ideal - as they often change & need alteration), but still could not get it to work properly. Do you have any suggestions?

Ideally;

  1. To have a lookup field that if left empty or by simple pressing spacebar would bring up all the 30 or options, however if you typed a few key words/letters it would narrow the options down to one or a few options as a pulldown menu (the option would narrow down as more data in entered) and a single option would eventually be chosen.
  2. The single chosen option would in turn trigger an automatic code or ITEM Number to be generated
  3. The code or ITEM number would then stipulate a condition (RECALL TIME) which is automatically generated but can be edited.

At present the initial formmenu has a very long, unweilding list of options, which presents the end-user with a complex list that is too-long & confusing and not searchable.

https://dashboard.blaze.today/snippet/anMzTLwkHW5WUfOhLLUd

Cheers

George

Let's break up your two parts.

For your first part you would want a mapping from the conditions to your codes and then from the codes to your recalls. The following illustrates this how to do this with two codes:

Map choices to code:
{choice_to_code=["Blue":"A", "Red":"B", "Green":"B", "Yellow":"A", "Pink":"B"]}

Map codes to recall periods:
{code_to_recall=["A":"1 year", "B":"2 years"]}

Choose a color: {formmenu: Blue; Red; Green; Yellow; Pink; name=Choice}
Recall: {=code_to_recall[choice_to_code[choice]]}

The second part is searching a menu. This isn't built-into Text Blaze but you could implement it by some clever use of forms. It's clunky though.

List of options:
{options=["-", "Dog", "Cat", "Catfish", "Hotdog"]}

Search for a specific option or set of options:
{formtext: name=search}

List of options that match the search string (or all options if there is no search string):
{current_options=filter(options, x -> trim(search) == "" or count(split(lower(x), lower(search)))>1)} (note the count(split()) is used to test if the search string is in the option; we'll add a better way to do this in the future. We use the lower() function to do case insensitive search)

The pruned list
{formmenu: values={=current_options}}

Thanks Scott,

I did get the 2 components to work separately BUT I could not combine them.

(A) I would like first to look up an option (descriptor) in the searchable field

(B) pick one descriptor from a set of options.

(C) This would trigger a Item number which would in turn derive a recall.

I can't seem to go from step (B) to (C)

As an output I would also like to display the Descriptor, the Item (Item Number) and Recall (Recall Period) all 3 separately in a table-like format (if possible).

Thanks in advance.
See below my dilemna:
https://dashboard.blaze.today/snippet/pPK0y5xyAMlKsucAuabn

Hi George,

So, the (B) to (C) step should be illustrated by my first example about. What I am calling Code (and denoting by "A","B") would be your item number.

If you wanted to show the descriptor, item number, and recall you would do something like:

Map choices to number:
{choice_to_num=["Blue":"123", "Red":"123", "Green":"456", "Yellow":"789", "Pink":"789"]}

Map numbers to recall periods:
{num_to_recall=["123":"1 year", "456":"2 years", "789":"5 years"]}

Choose a descriptor: {formmenu: Blue; Red; Green; Yellow; Pink; name=Choice}

Descriptor: {=choice}
Number: {=choice_to_num[choice]}
Recall: {=num_to_recall[choice_to_num[choice]]}

The problem lies in connecting the actions of choosing the descriptor using the search menu to derive ONE descriptor and then One item number & One recall result ie step A is missing). In the last example the choice of descriptor is simply from a pull down formmenu.

That is, is it possible to link the sections that you initially showed?

Your snippet is broken because you don't have name=descriptor set on your dynamic form menu so it isn't linked to anything.

I would personally recommend avoiding trying to do the type to search functionality for now though. This is something that should probably be implemented within the native select widget. We won't be adding search soon, but at some point we will as we steadily extend the functionality over time.

Thanks for the advice Scott. It simply means the user requires a 2-step input.

  1. Search for the descriptor he/she wants
  2. Display the descriptor (along with the item number and recall period).

I would appreciate if you review the snippet and make any suggestions to streamline it or make it flow easier. A colleague suggested giving the search result a hidden or background "code or number" and then that "code or number" can equate to a specific set of item numbers and recall periods to be displayed, thus combining the 2 steps. Is that possible? below is the snippet.

https://dashboard.blaze.today/snippet/Iba44N9Q7BDjhYjirZ5x

Thanks
GM

I've gone through your snippet and rewrote is to simplify it. Let me outline the steps I took.

Here is your original snippet:

{formtoggle: name=Search for a specific option or set of Colonoscopy descriptors:; trim=right}{descriptors=["-", "Positive FOBT and subsequent colonoscopy with no abnormalities detected - 32222 - once on a day", "Symptoms consistent with pathology of the colonic mucosa - 32222 - once on a day", "Iron deficiency or anaemia or IDA - 32222 - once on a day", "Abnormal diagnostic imaging of colon - 32222 - once on a day", "First colonoscopy following CRC surgery - 32222 - once on a day", "Pre-operative evaluation - 32222 - once on a day", "Repeat colonoscopy required due to inadequate bowel preparation for previous colonoscopy - 32222 - once on a day", "Management of IBD or inflammatory bowel disease - 32222 - once on a day", "Colonoscopy revealed 1 to 4 low-grade polyps - 32223 - only once in any 5 year period", "Colonoscopy revealed 1 to 4 adenomas each less than 10-mm in diameter and had no villous features or high grade dysplasia - 32223 - only once in any 5 year period", "Moderate risk of CRC due to family history with one FDR less than 55 at diagnosis - 32223 - only once in any 5 year period", "Moderate risk of CRC due to family history with two FDRs at any age at diagnosis - 32223 - only once in any 5 year period", "Moderate risk of CRC due to family history with one FDR and two SDRs at any age at diagnosis - 32223 - only once in any 5 year period", "History of CRC and initial post-op colonoscopy did not reveal any adenomas or CRC - 32223 - only once in any 5 year period", "Moderate risk of CRC due to a history of adenomas greater than 10-mm in diameter - 32224 - only once in any 3 year period", "Moderate risk of CRC due to a history of adenomas with villous features - 32224 - only once in any 3 year period", "Moderate risk of CRC due to a history of adenomas with high grade dysplasia - 32224 - only once in any 3 year period", "Moderate risk of CRC due to a history of 5 to 9 adenomas less than 10-mm in diameter with no villous features or high grade dysplasia - 32224 - only once in any 3 year period", "High risk of CRC due to a history of more than 10 adenomas - 32225 - not more than 4 times in any 12 month period", "High risk of CRC due to previous colonoscopy having a piecemeal or possibly incomplete excision of a large sessile polyp - 32225 - not more than 4 times in any 12 month period", "High risk for CRC due to known or suspected FAP - familial adenomatous polyposis - 32226 - only once in any 12 month period", "High risk for CRC due to known or suspected Lynch Syndrome - 32226 - only once in any 12 month period", "High risk for CRC due to known or suspected Serrated Polyposis Syndrome - 32226 - only once in any 12 month period", "Colonoscopic examination for the treatment of bleeding due to radiation proctitis - 32227 - once on a day", "Colonoscopic examination for the treatment of bleeding due to angioectasia - 32227 - once on a day", "Colonoscopic examination for the treatment of post-polypectomy bleeding - 32227 - once on a day", "Colonoscopic examination for the treatment of colonic strictures with balloon dilatation - 32227 - once on a day", "Colonoscopy other than above indications - 32228 - only once", "Polypectomy - 32229"]; trim=yes} {note} {formtext: name=search; trim=left} {endnote: trim=left}

List of Colonoscopy descriptors that match the search - {current_descriptors=filter(descriptors, x -> trim(search) == "" or count(split(lower(x), lower(search)))>1)}{formmenu: values={=current_descriptors}; trim=left} {endformtoggle: trim=left}

{formtoggle: name=Display Colonoscopy descriptor / Item No. / Recall Period: ; trim=right} {note}{descriptor_to_item=["Positive FOBT and subsequent colonoscopy with no abnormalities detected":"32222", "Symptoms consistent with colonic pathology":"32222", "Iron deficiency or anaemia or IDA":"32222", "Abnormal diagnostic imaging of colon":"32222", "First colonoscopy following CRC surgery":"32222", "Pre-operative evaluation":"32222", "Repeat colonoscopy required due to inadequate bowel preparation":"32222", "Management of IBD or inflammatory bowel disease":"32222", "Colonoscopy revealed 1 to 4 low-grade polyps":"32223", "Colonoscopy revealed 1 to 4 adenomas less than 10-mm with no villous features or high grade dysplasia":"32223", "Moderate risk of CRC due to family history with one FDR less than 55":"32223", "Moderate risk of CRC due to family history with two FDRs at any age":"32223", "Moderate risk of CRC due to family history with one FDR and two SDRs at any age":"32223", "History of CRC and post-op colonoscopy did not reveal any adenomas or CRC":"32223", "Moderate risk of CRC due to a history of adenomas greater than 10-mm":"32224", "Moderate risk of CRC due to a history of adenomas with villous features":"32224", "Moderate risk of CRC due to a history of adenomas with high grade dysplasia":"32224", "Moderate risk of CRC due to a history of 5 to 9 adenomas less than 10-mm with no villous features or high grade dysplasia":"32224", "High risk of CRC due to a history of more than 10 adenomas":"32225", "High risk of CRC due to having a piecemeal or incomplete excision of a large sessile polyp":"32225", "High risk for CRC due to known or suspected FAP - familial adenomatous polyposis":"32226", "High risk for CRC due to known or suspected Lynch Syndrome":"32226", "High risk for CRC due to known or suspected Serrated Polyposis Syndrome":"32226", "Colonoscopy for the treatment of bleeding due to radiation proctitis":"32227", "Colonoscopy for the treatment of bleeding due to angioectasia":"32227", "Colonoscopy for the treatment of post-polypectomy bleeding":"32227", "Colonoscopy for the treatment of colonic strictures with balloon dilatation":"32227", "Colonoscopy other than above indications":"32228", "Polypectomy":"32229"]} {item_to_recall=["32222":"Once on a day", "32223":"Only once in any 5-year period", "32224":" Only once in any 3-year period ", "32225":"Not more than 4 times in any 12-month period ", "32226":"Only once in any 12-month period ", "32227":"Once on a day", "32228":"Only once ", "32229":"-"]}

Select Colonoscopy Descriptor: {formmenu: Positive FOBT and subsequent colonoscopy with no abnormalities detected; Symptoms consistent with colonic pathology; Iron deficiency or anaemia or IDA; Abnormal diagnostic imaging of colon; First colonoscopy following CRC surgery; Pre-operative evaluation; Repeat colonoscopy required due to inadequate bowel preparation; Management of IBD or inflammatory bowel disease; Colonoscopy revealed 1 to 4 low-grade polyps; Colonoscopy revealed 1 to 4 adenomas less than 10-mm with no villous features or high grade dysplasia; Moderate risk of CRC due to family history with one FDR less than 55; Moderate risk of CRC due to family history with two FDRs at any age; Moderate risk of CRC due to family history with one FDR and two SDRs at any age; History of CRC and post-op colonoscopy did not reveal any adenomas or CRC; Moderate risk of CRC due to a history of adenomas greater than 10-mm; Moderate risk of CRC due to a history of adenomas with villous features; Moderate risk of CRC due to a history of adenomas with high grade dysplasia; Moderate risk of CRC due to a history of 5 to 9 adenomas less than 10-mm with no villous features or high grade dysplasia; High risk of CRC due to a history of more than 10 adenomas; High risk of CRC due to having a piecemeal or incomplete excision of a large sessile polyp; High risk for CRC due to known or suspected FAP - familial adenomatous polyposis; High risk for CRC due to known or suspected Lynch Syndrome; High risk for CRC due to known or suspected Serrated Polyposis Syndrome; Colonoscopy for the treatment of bleeding due to radiation proctitis; Colonoscopy for the treatment of bleeding due to angioectasia; Colonoscopy for the treatment of post-polypectomy bleeding; Colonoscopy for the treatment of colonic strictures with balloon dilatation; Colonoscopy other than above indications; Polypectomy; name=descriptor; trim=left}{endnote: trim=left}

Descriptor: {=descriptor}

Number: {=descriptor_to_item[descriptor]}

Recall Period: {=item_to_recall[descriptor_to_item[descriptor]]}{endformtoggle: trim=left}

I made the following changes:

  1. Removed the duplication of the descriptor list: In the original version you repeat the list of descriptors three times. This would make the snippet difficult to maintain as you have to update all three places with the exact right string every time you make a change. I consolidate this to a single list.
  2. Removed the duplication of the descriptor select menu: I have removed the select menu in the optional "searching" toggle. I don't believe it is needed as people can select from the second select menu.
  3. Removed some unnecessary attributes E.g. there were a lot of trims that weren't really necessary
  4. Reformatted the named lists I reformatted the named lists to make them easier to read and edit. This doesn't change the behavior at all, but makes the snippet a lot easier to understand and edit.

My reworked version is below. Hope this helps!

{descriptor_to_item=[
"Positive FOBT and subsequent colonoscopy with no abnormalities detected":"32222",
"Symptoms consistent with colonic pathology":"32222",
"Iron deficiency or anaemia or IDA":"32222",
"Abnormal diagnostic imaging of colon":"32222",
"First colonoscopy following CRC surgery":"32222",
"Pre-operative evaluation":"32222",
"Repeat colonoscopy required due to inadequate bowel preparation":"32222",
"Management of IBD or inflammatory bowel disease":"32222",
"Colonoscopy revealed 1 to 4 low-grade polyps":"32223",
"Colonoscopy revealed 1 to 4 adenomas less than 10-mm with no villous features or high grade dysplasia":"32223",
"Moderate risk of CRC due to family history with one FDR less than 55":"32223",
"Moderate risk of CRC due to family history with two FDRs at any age":"32223",
"Moderate risk of CRC due to family history with one FDR and two SDRs at any age":"32223",
"History of CRC and post-op colonoscopy did not reveal any adenomas or CRC":"32223",
"Moderate risk of CRC due to a history of adenomas greater than 10-mm":"32224",
"Moderate risk of CRC due to a history of adenomas with villous features":"32224",
"Moderate risk of CRC due to a history of adenomas with high grade dysplasia":"32224",
"Moderate risk of CRC due to a history of 5 to 9 adenomas less than 10-mm with no villous features or high grade dysplasia":"32224",
"High risk of CRC due to a history of more than 10 adenomas":"32225",
"High risk of CRC due to having a piecemeal or incomplete excision of a large sessile polyp":"32225",
"High risk for CRC due to known or suspected FAP - familial adenomatous polyposis":"32226",
"High risk for CRC due to known or suspected Lynch Syndrome":"32226",
"High risk for CRC due to known or suspected Serrated Polyposis Syndrome":"32226",
"Colonoscopy for the treatment of bleeding due to radiation proctitis":"32227",
"Colonoscopy for the treatment of bleeding due to angioectasia":"32227",
"Colonoscopy for the treatment of post-polypectomy bleeding":"32227",
"Colonoscopy for the treatment of colonic strictures with balloon dilatation":"32227",
"Colonoscopy other than above indications":"32228",
"Polypectomy":"32229"
]}

{item_to_recall=[
"32222":"Once on a day",
"32223":"Only once in any 5-year period",
"32224":" Only once in any 3-year period ",
"32225":"Not more than 4 times in any 12-month period ",
"32226":"Only once in any 12-month period ",
"32227":"Once on a day",
"32228":"Only once ",
"32229":"-"
]; trim=yes}

{descriptors=keys(descriptor_to_item); trim=yes}

{current_descriptors=descriptors; trim=yes}

{note}
{formtoggle: name=Search for a specific option or set of Colonoscopy descriptors:} {formtext: name=search; trim=left} {current_descriptors=filter(descriptors, x -> trim(search) == "" or count(split(lower(x), lower(search)))>1)} {endformtoggle}

Select Colonoscopy Descriptor: {formmenu: values={=current_descriptors}; name=descriptor}

{endnote: trim=right}

Descriptor: {=descriptor}

Number: {=descriptor_to_item[descriptor]}

Recall Period: {=item_to_recall[descriptor_to_item[descriptor]]}