This feature (Automatically Close Cases) is only available to CommCare users with a Pro Plan or higher. For more details, see the CommCare Software Plan page. |
This feature allows users with Edit Data access (see CommCareHQ Web Users) to configure updates to cases, including the ability to close cases. Without this feature, the only ways to close cases are by filling out a form that closes a case, finding the case in the Case List and manually using the Close Case button, or by using the Importing Cases Using Excel tool.
Note that automatic update rules will only trigger on cases that are currently open. If a case has already been closed, it will not be updated by a rule, even if it otherwise matches the filter criteria.
Here are some examples of when this is useful:
Automatically closing and removing stale cases from users' phones
Regularly closing cases that have a specified combination of case properties (for example, a case updated by two apps where both users' protocols are completed)
Cases are closed by creating rules.
The basic process of defining a rule is:
Define all of the criteria for the cases you want to match.
Choose all of the actions to apply to the cases that match the criteria.
Navigate to Data → Automatically Updates Cases, you will see a list of all rules for the project along with the name, case type, status, and last time the rule has run to completion.
If "Last Run" is not updated, it means that the rule has not yet run or did not run to completion on its last run. The completion could not have succeeded due to exceeding the maximum number of automatic updates per day (10,000), due to exceeding the max run time (24 hours), or that there was an error during the run.
For example, imagine that you want to close any "Patient" cases which have not been updated in a year. You want to do this to reduce the caseload on the users' phones and to keep the reports accurate.
The following filter criteria are available for matching cases:
NB: It is possible to reference parent/master case properties in any of the case property filters. The syntax follows the convention of "parent/<case_property>" or "host/<case_property>". Possible use case: Close the growth monitoring case when the parent (i.e., person case) turns 6.5 years old.
The following actions can be performed on cases that match the filter criteria:
Rules run automatically every day at Midnight GMT. You cannot choose when a rule is run.
You can update, delete, or deactivate a rule at any time from the list of rules.
In addition to the dynamic case properties created by your app(s), you can reference the following case properties in automatic update rule criteria:
Case Property | Description |
---|---|
name | The case's name |
owner_id | The system identifier for the case's owner |
opened_on | The timestamp that the case was opened |
opened_by | The system identifier for the case's opener |
modified_on | The timestamp that the case was last modified on mobile |
server_modified_on | The timestamp that the case was last modified on the server |
external_id | An optional external id your app may assign to the case |
Parent cases may also be referenced in the automatic update rule criteria by prefixing the property name with "parent/". So, for example, parent/name references the parent case's name.
The case close action shows up in the case history as a form submission. You can view the form that closed the case by looking in the Submit History report or the Manage Forms tool. The form will also show up in the Case History of any cases closed by a rule. In the case history for the form name will show up as "Unknown" and the user as "system":
If a rule ran and closed cases and you want to undo that action, you should go to Manage Forms or Submit History report, locate the form submission that closed the cases, and archive it. This will restore the case to its prior status. For more information on archiving forms, please see Archive Forms.
To find the forms, you will want to use the following filters:
You can add the filter options in the following order: