Find this workflow
This workflow is available as a template in Workflow Automation.
Log in and open Workflow Automation.
Select Templates from the left-hand menu.
Search for
ACP- you will see the ACP templates listed.Click Use this template on the Care Plan Review Automation Workflow to create your own editable copy.
Note: Clicking Use this template creates a new workflow based on the template. You can then modify and configure it without affecting the original template.
Parameters
Before activating the workflow, configure the following:
Parameter | Purpose | Default |
| The name of the date field in your care plan that drives reviews (for example, "Next Review Date"). Must match exactly one date field. | Next Review Date |
| How many days ahead to look for upcoming reviews. A review due within this many days from today will have a task raised. | 7 |
Review type filter | Optional. Restricts the workflow to a specific review type. | None (all types) |
Branch filter | Optional. Restricts the workflow to a specific branch. | None (all branches) |
Important: reviewDateFieldName must resolve to exactly one date field in your configuration. If it is missing, or matches zero or more than one field, the workflow stops at the Config Validation node and raises a configuration error. Set it explicitly before activating.
How the workflow runs
This workflow runs once a day and raises a task for every care plan review falling due within a configurable notice window. For each due review it checks a task has not already been raised, works out who to assign it to, creates the task in Access Care Planning, and notifies the assignee via the Evo Web Feed with a direct link to the case. Reviews that already have a task are skipped, preventing duplicates.
The workflow has two phases. Phase 1 (nodes 1-11) validates configuration and makes sure the review task type exists. Phase 2 (nodes 12-31) queries reviews, loops over each one, and raises and assigns the task.
Node reference
1. Daily Schedule Trigger
Type: Schedule Trigger
Starts the workflow automatically every day at 09:00 (London timezone). No parameters are required and no manual action is needed.
2. Discover Fields
Type: Connector - Component Controller
Retrieves all date fields defined in your care plan configuration. The result is used by the next node to resolve which field the reviewDateFieldName parameter points to.
Technical detail
Folder: Component Controller
Endpoint:
GET /componentsFilter:
type=dateLimit: 1000
3. Resolve Review Date Field
Type: Code - JavaScript
Matches the configured reviewDateFieldName against the date fields returned by Discover Fields. Returns the resolved field along with a count of how many fields matched, so the next node can confirm the configuration is valid and unambiguous.
4. Config Validation
Type: Branch
Gates the rest of the workflow. Checks that the review date field parameter is set and resolves to exactly one field. If both conditions pass, the workflow continues. If not, it routes to the Configuration Error node.
Technical detail
Conditions: 2
Combine: AND (all must match)
5. Discover Task Types
Type: Connector - Task Type Controller
Retrieves all task types defined in the connected instance. The result is used to check whether the "Next Review Date" task type already exists.
Technical detail
Folder: Task Type Controller
Endpoint:
GET /task_typesLimit: 1000
No MQL filter is applied.
6. Configuration Error
Type: Code - JavaScript
Hard stop. Throws a structured error if the configuration is incomplete, halting the run so the problem can be fixed. Reached only when Config Validation fails.
7. Resolve Task Type
Type: Code - JavaScript
Searches the discovered task types for one named "Next Review Date". Matches are sorted by ID so the result is deterministic when a tenant has duplicate task types. Returns the resolved task type ID, the match count, and a needsCreate flag indicating whether the task type has to be created.
Technical detail
javascript
const WANTED = 'Next Review Date'; const rows = $node["Discover Task Types"].output.data.results || []; const wanted = WANTED.trim().toLowerCase(); const matches = rows .filter(t => String(t.name || '').trim().toLowerCase() === wanted) .sort((a, b) => a.id - b.id); // deterministic when a tenant has duplicates return { wantedName: WANTED, taskTypeId: matches.length ? matches[0].id : null, matchCount: matches.length, needsCreate: matches.length === 0, candidates: rows.map(t => ({ id: t.id, name: t.name })) };
8. Task Type Exists?
Type: Branch
Checks whether Resolve Task Type found an existing task type. If it did, the workflow uses it. If not, it routes to Create Task Type.
Technical detail
Condition: task type ID Is Not Empty
9. Effective Task Type
Type: Code - JavaScript
Consolidates the task type ID from either the existing match or the newly created task type, so downstream nodes have a single reliable ID regardless of which path ran. Throws an error if neither resolves to a valid integer ID.
Technical detail
javascript
const resolved = $node["Resolve Task Type"].output.data[0] || {}; const created = $node["Create Task Type"]?.output?.data || {}; const id = resolved.taskTypeId != null ? Number(resolved.taskTypeId) : Number(created.id); if (!Number.isInteger(id) || id <= 0) { throw new Error('Could not resolve or create the "' + resolved.wantedName + '" task type'); } return { taskTypeId: id, source: resolved.taskTypeId != null ? 'existing' : 'created', name: resolved.wantedName };
10. Create Task Type
Type: Connector - Task Type Controller
Creates the "Next Review Date" task type in the connected instance. Reached only when Task Type Exists? finds no existing type.
Technical detail
Folder: Task Type Controller
Endpoint:
POST /task_types
11. Compute Date Range
Type: Code - JavaScript
Calculates the date window used to find upcoming reviews: from today to today plus noticeWindowDays (defaults to 7). The result is used to build the ACP query.
12. Build ACP Query
Type: Code - JavaScript
Constructs the MQL query that finds reviews due within the computed date range. Applies the optional review type and branch filters if they are set.
13. Fetch Reviews from ACP
Type: Connector - Care Planning API
Runs the query built by Build ACP Query and retrieves all care plan reviews falling due within the notice window.
14. ACP Response Valid?
Type: Branch
Checks that ACP returned a valid response. If results came back, the workflow continues to extract them. If the call failed, it routes to the ACP API Error node.
15. Extract & Paginate Reviews
Type: Code - JavaScript
Filters out archived and deleted reviews from the ACP response and generates a deterministic tenantTaskId for each remaining review. This ID is what the workflow uses later to check whether a task already exists, ensuring the same review is never actioned twice.
16. ACP API Error
Type: Code - JavaScript
Structured error halt. Stops the run if the ACP call failed. Reached only when ACP Response Valid? finds no valid response.
17. Loop
Type: Loop - For Each Item
Iterates over each review produced by Extract & Paginate Reviews. All nodes from here to Send Feed Notification run once per review. Capped at 100 iterations as a safety limit.
Technical detail
Loop Mode: For Each Item
Max Iterations: 100
Each iteration exposes the current review as
$node["Loop"].output.item.
18. Extract Review Details
Type: Code - JavaScript
Flattens the current loop item into a clean review object holding the case, component, element, review type, service user name, branch, due date and existing task ID. It also computes the start and end datetimes for the task (09:00 to 09:30 on the due date).
Technical detail
javascript
const r = $node["Loop"].output.item; const due = String(r.dueDate).slice(0, 10); return { caseId: r.caseId, tenantCaseId: r.tenantCaseId, componentId: r.componentId, elementId: r.elementId, reviewType: r.reviewType, serviceUserName: r.serviceUserName, branch: r.branch, branchId: r.branchId, dueDate: due, tenantTaskId: r.tenantTaskId, startDateTime: `${due}T09:00:00.000+0000`, endDateTime: `${due}T09:30:00.000+0000` };
19. Check Existing Task
Type: Connector - Care Planning API
Queries ACP for an existing task matching the review's tenantTaskId. Returns at most 1 result. Used to decide whether a task has already been raised for this review.
Technical detail
Limit: 1
20. Task Already Exists?
Type: Branch
Routes the review based on the result of Check Existing Task. If a task already exists, the review is skipped. If not, the workflow proceeds to create one.
21. Skip (Task Exists)
Type: No-op / Stop
Placeholder node for reviews that already have a task. Routes them straight to Merge Task Branches so the run completes cleanly without raising a duplicate.
22. Fetch Case
Type: Connector - Care Planning API
Fetches the full case record for the current review, by tenantCaseId, to retrieve the customer ID needed for the task and notification.
23. Fetch Branch Admins
Type: Connector - Care Planning API
Fetches the active administrators for the review's branch. Used by the assignee picker as the first-choice pool for who the task is assigned to.
24. Fetch Tenant Admins
Type: Connector - Care Planning API
Fetches active tenant-level administrators. Used as a fallback assignee if no branch admin is available. Returns at most 1 result.
Technical detail
Limit: 1
25. Pick Branch Admin
Type: Code - JavaScript
Selects who the review task is assigned to using a three-tier fallback: primary branch admin first, then a secondary branch admin, then a tenant admin. Where more than one candidate exists, the oldest account wins so the choice is deterministic.
26. Create Review Task
Type: Connector - Care Planning API
Creates the review task in Access Care Planning, using the assignee chosen by Pick Branch Admin, the case, the computed start and end datetimes, and the resolved task type.
////check if htis detail is correct, as per Steven convo
Feature 2353099: Workflow (EWA) - Care Plan Review Automation Workflow Template
Technical detail
Folder: Visit Controller
Endpoint:
POST /visits
27. Fetch Created Task
Type: Connector - Care Planning API
Re-fetches the task just created, by its ID, to return the fully populated record with resolved names for the assignee, customer and branch. These names are needed to build a readable notification.
Technical detail
Folder: Visit Controller
Endpoint:
GET /visits/{tenantVisitId}Path parameter:
tenantVisitId={{ $node["Extract Review Details"].output.data[0].tenantTaskId }}
28. Code
Type: Code - JavaScript
Builds the flat notification payload from the hydrated task, including the title, body and a deep link to open the case.
29. Send Feed Notification
Type: Evo Web Feed - Send Feed Item
Sends the notification to the Evo Web Feed for the assignee, with an "Open Case" link that takes them directly to the case in Access Care Planning.
30. Merge Task Branches
Type: Merge
Merges the two paths, reviews where a task was created and reviews that were skipped, back into a single stream so the run finishes cleanly.
31. Workflow Summary
Type: Code - JavaScript
Returns a completion marker at the end of the run. No side effects.
Technical detail
Execution Tier: Sandboxed
javascript
return { status: 'completed', message: 'Care plan review automation completed', timestamp: new Date().toISOString() };
Workflow summary
Stage | Nodes | What happens |
Trigger | 1 | Workflow starts automatically at 09:00 daily |
Config setup | 2-11 | Validates the review date field, ensures the "Next Review Date" task type exists, and computes the notice window |
Data fetch | 12-16 | Builds and runs the ACP query, then extracts and paginates the due reviews |
Per-review loop | 17-29 | For each due review: checks for an existing task, picks an assignee, creates and re-fetches the task, and sends a feed notification |
Merge and finish | 30-31 | Merges created and skipped reviews and emits a completion summary |
