Skip to content

Group scheduled observations by order with a new task per group#707

Merged
labkey-martyp merged 4 commits into
release26.3-SNAPSHOTfrom
26.3_fb_nirc_observation_task_grouping
Jun 18, 2026
Merged

Group scheduled observations by order with a new task per group#707
labkey-martyp merged 4 commits into
release26.3-SNAPSHOTfrom
26.3_fb_nirc_observation_task_grouping

Conversation

@labkey-martyp

Copy link
Copy Markdown
Contributor

Rationale

When a clinical observation is entered from the observation schedule and multiple orders match on category and scheduled date/time, an entry is created in clinical_observations for each matching order. Previously the duplicate entries reused the originating order's existing schedule task id, so the entered observations were tied back to the schedule order tasks instead of a task representing the recording session. This change groups the entries by their originating order's taskid and assigns one task per group.

Related Pull Requests

  • N/A

Changes

  • NIRC_EHRTriggerHelper.handleScheduledObservations now groups scheduled observation entries by their originating order's taskid: the first order group reuses the form's own task and each additional distinct order group gets a freshly created task cloned from the form task, so no order's existing schedule task id is reused and the form task is never left empty.
  • Added resolveGroupTaskId and createTaskFromForm helpers plus a per-batch grouping map that is cleared from the clinical_observations onInit trigger.
  • clinical_observations.js sets the triggering row's taskid to the resolved group task.
  • Added the caseId/problemCategory column to the clinical_observations default view.

When clinical observations are entered from the observation schedule and multiple orders match on category and scheduled date/time, group the resulting clinical_observations entries by their originating order's taskid and assign one task per group. The first order group reuses the form's own task; each additional distinct order group gets a freshly created task cloned from the form task. This means no order's existing schedule task id is reused, while the form task is reused for the first group so it is never left empty.

Also add the caseId/problemCategory column to the clinical_observations default view.
Augments testClinicalObservation to assert that observations entered from the schedule for an animal with a single clinical case stay grouped under one task with no empty task left behind. Adds testScheduledObservationTaskGrouping, which creates two concurrent clinical cases for the same animal so each scheduled category matches two orders, then verifies the entries are grouped into two tasks (one per originating order taskid) with two entries per category and no empty task created.
Provision the dedicated task-grouping test animal (alive demographics, current housing, active assignment) in createTestSubjects so the clinical case form raises no unknown-animal warnings that would keep the validation banner from clearing and time out the submit.

Acknowledge the 'Similar Case Exists' confirmation when finalizing the second case for the same animal and problem area; createClinicalCase now takes the expected finalize-confirmation window title rather than always assuming 'Finalize'.

Query the EHR study folder explicitly (ContainerFilter.Current against getContainerPath) in the observation/task verification helpers, since the study datasets and ehr.tasks are defined there rather than in the project root targeted by the default selectRows overload.
@labkey-martyp labkey-martyp merged commit d98c54d into release26.3-SNAPSHOT Jun 18, 2026
4 of 5 checks passed
@labkey-martyp labkey-martyp deleted the 26.3_fb_nirc_observation_task_grouping branch June 18, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants