Epi Info™ User Guide

Check Code: Customizing the Data Entry Process


Check Code Commands

Create a Skip Pattern Using IF/THEN and GOTO

Use IF/THEN statements to create skip patterns based on the answers to questions in the form. This example creates code, which states that if the person answered No (-) for the Hospitalized field, then the cursor subsequently jumps to the field Was the patient treated with antibiotics? and skips the Hospital Admission date field.

  1. From Form Designer, Open the Ecoli.prj project.
  2. Double click on the FoodHistory_NoCheckCode form.
  3. Click Check Code or select Tools > Check Code Editor. The Check Code Editor opens.
  4. From the Choose Field Block for Action section, expand the node for Page 1 to see the various fields on the first page.
  5. Expand the node for the Hospitalized field.
  6. The action needs to occur after data are entered into the Hospitalized field.
  7. Double click on the after event.
  8. A block of code for the Hospitalized field is created and displayed in the Check Code Editor.
    Choose block for skip action

    Figure 3.11: Dialog Block for Action after Hospitalized

     

  9. The code appears in the Check Code Editor.
    Check Code sample showing After block shell

    Figure 3.12: If/Then Block Code After Hospitalized

     

  10. Click If from the Add Command to Field Block list box. The IF dialog box opens.
  11. From the Available Variables drop-down list, select the field to contain the action. For this example, select Hospitalized. The selected variable appears in the If Condition field.
  12. From the Operators, click =.
  13. From the Operators, click No. The If Condition field will read Hospitalized=(-).
  14. Click the Code Snippet button in the Then section. A list of available commands appears.
  15. From the command list, select GoTo. The GOTO dialog box opens.
  16. Select the field for the cursor to jump to based on a No answer from the list of variables. For this example, select Antibiotics.
  17. In the GOTO dialog box, click OK to return to the IF dialog box.
    If-Then dialog showing conditional GoTo command

    Figure 3.13: If/Then dialog box

     

  18. Click OK. The code appears in the Check Code Editor. The example code appears as:
    Check Code sample showing completed GoTo command

    Figure 3.14: If/Then Check Code Command

     

  19. Click the Verify Check Code button from the Check Code Editor.
  20. Click the Save button from the Check Code Editor.