Scripting & More Tab - Show this field if

  • The "Show this field if" field in the Scripting and More tab of the eForm Editor can be used to show or hide items (or make a clinical note), depending on answers to previous questions or other patient information.
  • Below you will find some examples of what types of scripts can go into this field.

Hide an item:

To hide items (eg formulas) so that they do not appear to patients, select the item in the eForm editor and in the Scripting & More tab, in the "Show this field if:" field, enter false.

Display a question, based on demographics:

If you are creating a general health assessment form and you want to ask about the possibility of pregnancy, you can choose to only show this field if the patient is female by entering the following into the "Show this field if" field:

pt.isFemale()
Copy Rule

For a full list of available patient-related functions, please refer to: "ScriptPatient ("Pt") Functions".

Display a question, based on how the patient responds to a Yes/No item type:

  1. Create your first question

    • First, create an item for the initial question asked to the patient. In the Scripting & More tab, ensure you give it an Item Reference.

       

      In our example, we first ask the patient if they smoke, in order to determine whether or not to offer smoking cessation counselling. Our first question "Do you smoke?" will be a Yes/No item type and have the item reference: "smoking".

  2. Create a hidden question

    • Next, create a second item. This question will be hidden, depending on how the patient answers the initial question. In the Scripting & More tab, use the "Show this field if" field to reference the answer that should make the second question appear. The item will appear dark grey with (hidden) underneath to show that it is hidden from patients until the appropriate answer is provided.

       

      In our example, if the patient answers yes, we want to show them a second yes/no question "Would you be interested in smoking cessation counselling?".

      smoking.r == 'Y'
      Copy Rule

Note: .r refers to that item’s response choice (e.g. “N” for no, “Y” for yes).

Display a question based on a patient's text response:

  1. Create your first question

    • First, create an item for the initial question asked to the patient. In the Scripting & More tab, ensure you give it an Item Reference.

       

      In our example, our first question is a menu item type with a caption: "What is your first language?" We provide a menu with the options English, French or Other. We gave this item reference: "language".

  2. Create a hidden question

    • Next, create a second item. This question will be hidden, depending on how the patient answers the initial question. In the Scripting & More tab, use the "Show this field if" field to reference the answer that should make the second question appear. The item will appear dark grey with (hidden) underneath to show that it is hidden from patients until the appropriate answer is provided.

       

      In our example, if the patient answers "Other" we want to show them an additional question "Please specify:" and collect their response using a Text Field item type. Since our menu choice for "Other" has a point value of 3, we can use the following JavaScript expression in the "Show this field if" field:

      language.p == 3
      Copy Rule
    • If your first question is a menu choice allowing multiple selections, use the following ".r" value in combination with Javascript's String.indexOf() function in the "Show this field if" field:

      In our example, if the patient answers "Other" we want to show them an additional question "Please specify:" and collect their response using a Text Field item type. Since our first question is a menu choice allowing multiple selections, we can use the following JavaScript expression in the "Show this field if" field:

      language.r.indexOf("Other") >= 0
      Copy Rule

      Note: In the above example, "Other" is the specific menu choice that you wish to unhide the second question.

Have more questions? Submit a request