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 RuleFor 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:
-
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".
- First, create an item for the initial question asked to the patient. In the Scripting & More tab, ensure you give it an Item Reference.
-
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?".
Copy Rulesmoking.r == 'Y'
- 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.
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:
-
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".
- First, create an item for the initial question asked to the patient. In the Scripting & More tab, ensure you give it an Item Reference.
-
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:
Copy Rulelanguage.p == 3
-
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:
Copy Rulelanguage.r.indexOf("Other") >= 0
Note: In the above example, "Other" is the specific menu choice that you wish to unhide the second 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.