This module has no automated test suite. Use the steps below to verify correct behavior on a live REDCap instance.
- The module is installed and enabled at the system level (see README.md).
- You have REDCap Admin access.
This test verifies that the next_visitnum query correctly suggests the next sequential visit number for a record, starting at 1 for new records and incrementing with each saved visit.
- In REDCap, create a new project by importing
examples/DefaultFromQueryTest.REDCap.xmlvia New Project > Upload a REDCap project XML file. - Enable the Default From Query module for this project via Manage External Modules.
- Open the module's project configuration and add a query entry:
- Query Name:
next_visitnum - SQL: paste the contents of
examples/one_project.sql - Leave additional project ID fields blank.
- Query Name:
- Save the configuration.
- Create a new record in the project.
- Open the Header form for the first instance.
- Verify that the visit number field is pre-populated with 1.
- Open the project and navigate to the Record Home Page for an existing record (e.g., record
1). - Add a new instance of the repeating instrument by clicking Add new.
- Open the Header form for the new instance.
- Verify that the visit number field is pre-populated with 2.
- Fill in any required fields and save the form.
- Repeat the steps in Test 1b — add another new instance for the same record and open the Header form.
- Verify the suggested visit number is now 3.
- Repeat as desired; the suggested value should increment by 1 each time.
This test verifies that the next_visitnum query correctly suggests the next sequential visit number when visit history spans two REDCap projects. The suggested visit number must be one greater than the highest visit number found in either project.
This test builds on the project created in Test 1 (referred to below as Project 1).
- Create a second REDCap project by importing
examples/DefaultFromQueryTest.REDCap.xmlagain via New Project > Upload a REDCap project XML file. This is Project 2. - Note the Project ID of Project 2 (visible next to the project title).
- In Project 2, navigate to the Record Home Page for record
102. - Open an existing instance of the Header form (or create one if none exists) and manually set the visit number to 5. Save the form.
- In Project 1, open the Default From Query module configuration.
- Edit the
next_visitnumquery entry:- SQL: replace the existing SQL with the contents of
examples/two_projects.sql - Additional Project ID 1 (pid1): enter the Project ID of Project 2
- SQL: replace the existing SQL with the contents of
- Save the configuration.
- In Project 1, navigate to the Record Home Page for record
102. - Confirm that any existing instances of the Header form show only visit numbers lower than 5.
- Add a new instance of the repeating instrument by clicking Add new.
- Open the Header form for the new instance.
- Verify that the visit number field is pre-populated with 6 — one greater than the value of 5 recorded in Project 2.