Maintain a vertical toggle list but trim unused spaces in between selections

Hi Scott,

Below is an example of a toggle list with a long list of selections, of which only 3-5 will be selected at any one time. For ease of reading a vertical presentation is much easier than horizontal panel. However, when selected it would be convenient if they are listed closely together with no gaps in between, or above or below them when inserted into the document. Can you help.

Thanks in advance

George M

Below is the snippet:

{formtoggle: name= Associated_symptoms; formatter=(value) -> "" if value else ""}{if: Associated_symptoms}

{formtoggle: name= Heartburn; formatter=(value) -> " Heartburn." if value else ""}

{formtoggle: name= Acid or food regurgitation; formatter=(value) -> " Acid or food regurgitation." if value else ""}

{formtoggle: name= Throat irritation; formatter=(value) -> " Throat irritation." if value else ""}

{formtoggle: name= Cough; formatter=(value) -> " Cough." if value else ""}

{formtoggle: name= Hoarse voice; formatter=(value) -> " Hoarse voice." if value else ""}

{formtoggle: name= Post-prandial fullness; formatter=(value) -> " Post-prandial fullness." if value else ""}

{formtoggle: name= Early satiety; formatter=(value) -> " Early satiety." if value else ""}

{formtoggle: name= Loss of appetite (anorexia); formatter=(value) -> " Loss of appetite (anorexia);." if value else ""}

{formtoggle: name= Weight loss; formatter=(value) -> " Weight loss." if value else ""}

{formtoggle: name= Nausea; formatter=(value) -> " Nausea." if value else ""}

{formtoggle: name= Vomiting; formatter=(value) -> " Vomiting." if value else ""}

{formtoggle: name= Excessive burping; formatter=(value) -> " Excessive burping." if value else ""}

{formtoggle: name= Excessive belching; formatter=(value) -> " Excessive belching." if value else ""}

{formtoggle: name= Constipation; formatter=(value) -> " Constipation." if value else ""}

{formtoggle: name= Diarrhoea; formatter=(value) -> " Diarrhoea." if value else ""}

{formtoggle: name= Marked abdominal bloating; formatter=(value) -> " Marked abdominal bloating." if value else ""}

{formtoggle: name= Uncomfortable abdominal distension; formatter=(value) -> " Uncomfortable abdominal distension." if value else ""}

{formtoggle: name= Excessive rectal flatus - flatulence; formatter=(value) -> " Excessive rectal flatus - flatulence." if value else ""}

{formtoggle: name= Excessive borborygmi; formatter=(value) -> " Excessive borborygmi." if value else ""}

{formtoggle: name= Fevers; formatter=(value) -> "Fevers." if value else ""}

{formtoggle: name= Night sweats; formatter=(value) -> "Night sweats." if value else ""}

{formtoggle: name= Rigors; formatter=(value) -> "Rigors." if value else ""}{endif}

If you wanted to keep the exact layout, the approach to handle that would be to use a {note} command around the list of toggles and then use an equation command to format the output as you would like it to be in the final snippet.

However, what I think would work best here is a {formmenu} command with the multiple attribute set to yes which allows users to select multiple options. The following example illustrates that (with a shortened list of symptoms, but you could add them all):

{formtoggle: name=Associated Symptoms}{formmenu: multiple=yes; Early satiety; Loss of appetite; Weight loss; Nausea; Vomiting}{endformtoggle}

I also switched out your {formtoggle}+{if} for just a {formtoggle} as that works just as well here and is simpler.

Your solution is simple, elegant and effective.
To develop the list notion further, what if for another list where the options need to be numbered eg - "Potential Causes of Abdominal Pain" the list that the clinician can pick from is again long and again presented as before in a vertical list but the selection is presented as stating that
"The Potential Causes of Abdominal Pain are:

  1. abc
    2 def
    3 xyz
    (not sure why it shows an indent - not meant to)
    leaving out the unselected options. However, the options to be listed in numerical order only in the output (not in the original selection list) and preferably in the order that they were selected - however I suspect that his may not be possible.

Thanks again
George M

You could do something like the following. Wrap the {formmenu} in a {note} block so it is displayed in an the output. then use the {repeat} command to display the symptoms in the you way you would like:

{note}Select symptoms: {formmenu: name=symptoms; multiple=yes; Early satiety; Loss of appetite; Weight loss; Nausea; Vomiting}{endnote}

{if: len(symptoms) > 0 and count(symptoms) > 0; trim=yes}
The potential causes of abdominal pain are:{repeat: for i in seq(1, count(symptoms))}
{=i}. {=symptoms[i]}{endrepeat}
{endif: trim=yes}

(note, the {if} command here is a little more complex than it would ideally be, I'm going to update Text Blaze so in the future you only need count(symptoms) > 0 in the condition)