Implementation plan / Session plan / Handover RC-2-S03
Handover RC-2-S03 Build: Coordination services (notification service)¶
Card: RC-2-S03. Issue: cema-care/his#48. Branch: session/RC-2-S03. Slice: RC-2. Decision record: ADR-HIS-074.
What was built and where¶
MOD-ESS-007 in services/ess-coordination/mod-ess-007 serves all 9 operations of notification.v1 (IF-ESS-009). It publishes NotificationStatusChanged (EVT-ESS-009) on his.ess.notification.v1 through the outbox, aggregate Notification, with no facility in the envelope. The unit's services/ess-coordination/README.md lists the packages and the settings (his.notification.*).
- Request (parts 6.1, 6.5, 7, 10; PR-NTF-001-1, -2):
- only a domain service, and only for a type its domain registered;
- checked against the type: priority, recipient kind, every required template parameter and no undeclared one;
- critical requires
acknowledgementRequired: trueand an escalation policy, and acknowledgement requires a policy. Each refusal is 400 with the pointer; - the Idempotency-Key is unique per requester, and a repeat answers the notification with 200;
- a request that matches the type's deduplication rule within its window, from the same requester, is merged, answered 200 with
mergedRequests(BR-ESS-024). The requester is part of the deduplication key, so another service of the same domain gets a notification of its own; - persisted as Queued before the 201.
- Dispatch (
Dispatcher, parts 6.2 to 6.7, 6.9): - one notification at a time, locked, critical first and then the oldest;
- the recipient is resolved at send time: user, role, team, on-call or patient. A suspended or off-duty person is passed over for the next holder or the fallback (PR-NTF-001-4). Nobody resolved means the fallback for critical and high, and otherwise
unresolvedwith the eventrecipient-unresolved(PR-NTF-001-3); - channels: in-app always for workforce, plus the external channels the type allows and the user's settings enable for the priority. Critical channels are locked on;
- one lane per recipient and channel. Every attempt is recorded with times, outcome, reason and
retryOf, and retried with backoff. When a lane is given up on a high or critical notification, the type's other channels are tried; - Sent, Delivered or Delivery Failed. Delivery Failed opens an operations worklist item, and the notification stays open;
- a channel provider outage (part 10) opens one operations worklist item per outage. That is a lane given up for a reason of the channel, also when the notification was delivered on another channel. Later failures are counted on it, and it closes when the channel accepts or delivers again.
- External content (part 6.4, AC-06): checked at registration (PR-NTF-001-6) and again at send time. A message never carries the patient or the subject; it points to
/inbox/<id>, which needs sign-in. The in-app message with its patient context is answered only to an eligible recipient. - Patient recipient (part 6.10, Q-RC2-6): the interim Domain 2 path of ADR-HIS-074 point 5.
- The channel is sms, or whatsapp where preferred; a communication-preference directive that excludes a channel or every message is honoured.
- The number is read from Domain 1 for each attempt and stored masked only. Acceptance is Sent; Delivered needs a receipt.
- No permitted channel, or no number, is Delivery Failed with
no-permitted-patient-channel. Nothing is sent while the preferences cannot be read. - Lifecycle (D10-ESS 4.3):
cancelNotificationstops pending deliveries;closeNotificationcloses from Delivered without acknowledgement, Acknowledged or Escalation Exhausted, and never an unacknowledged notification that requires acknowledgement (BR-ESS-025);retryNotificationtakes Delivery Failed back to Queued, by a person with a reason, optionally rerouted to a recipient or channels. It emitsrequeued.- Channel settings (AC-07, PR-NTF-001-7):
readNotificationSettingsandupdateNotificationSettings. In-app, and the critical channels at critical, cannot be switched off. A user changes only their own, and each change is audited asess.iam.accountwith before and after (Q-RC2-7). - Notification types:
validateNotificationTypeanswers the findings: PR-NTF-001-6, BR-ESS-023, undeclared parameters, channels the type does not allow, audiences no recipient kind reaches;- item type
ess.notification-typeis registered at start with configuration.v1 whenconfiguration-urlis set, with this hook; - versions are installed from ConfigurationChanged;
- the seed
notification/types.jsonaddsadm.appointment-reminderon behalf of Domain 1. - Cross-cutting duties:
- the policy decision before every action, for the facility the notification concerns. The actions and resource types are in ADR-HIS-074 point 8;
- audit
ess.ntf.deliveryfor the request, resolution, each attempt, failure, cancellation, retry and reroute;ess.ntf.escalationfor closure. Subject references only, never content; - correlation: the request's correlation identifier is carried into the dispatch after commit;
- telemetry from the kit, and the counters
his.ess.notification.attemptsandhis.ess.notification.state; - UTC times to the millisecond, shown in the deployment zone in messages (NFR-ESS-015, -016).
- Migrations
V1__notifications.sqlandV2__channel_outages.sql, schemamod_ess_007.
In MOD-ESS-008:
- task/NotificationOperations implements mod007.api.DeliveryFailureWorklist (ADR-HIS-074 point 6). A delivery failure is a task ess.notification-delivery-failure, and a channel outage a task ess.notification-channel-outage, both in queue ess.notification-operations and created in the same transaction;
- the task types and the queue are added to workflow/registrations.json;
- build.gradle.kts depends on :mod-ess-007, its api package only (the boundary test holds).
In the unit's kit test fixtures: TestTokens.userWithSubject, so that the contract test can act as the owner of the documented account.
No new external dependency. ./gradlew dependencies --write-locks changed no lockfile.
ADR-HIS-074 and its row in the decision record index (73 records). Main holds ADR-HIS-072 (the self-hosted runners), and the open pull request of RC-2-S02 (#153) has taken ADR-HIS-073, so this record is 074. It was drafted as 073 and renumbered when the branch was brought up to date with main.
Checks and their result¶
The integration environment ran as HIS_SESSION=RC-2-S03 (his-rc-2-s03), light profile.
| Check | Command | Result |
|---|---|---|
| Build and every test of the unit | ./gradlew build in services/ess-coordination |
passed: 132 tests (MOD-ESS-007 39, MOD-ESS-008 60, kit 27, app 5 with the module boundary test, MOD-ESS-009 1) |
| Provider contract test | ./gradlew :mod-ess-007:test --tests '*NotificationContractTest' |
passed: all 9 operations of notification.v1 pass his-contract verify contracts/ess, 23 cases; the published NotificationStatusChanged events pass his-contract validate-event |
| Dependency scan and SBOM | platform/delivery-pipeline/bin/dependency-scan services/ess-coordination |
0 blocking (6 medium), lockfiles unchanged |
| Static analysis | platform/delivery-pipeline/bin/static-analysis services/ess-coordination |
no blocking finding |
| Image scan | platform/delivery-pipeline/bin/image-scan services/ess-coordination |
0 blocking (15 low, 116 medium; RC-1-S15 recorded 38 medium; this change adds no dependency, so the rise is in the scanner database or the base image, not checked further) |
| Secret scan | platform/delivery-pipeline/bin/secret-scan code origin/main HEAD and docs |
no secret; no exception file added |
| Documentation | check_links.py; mkdocs build |
0 broken links, 0 duplicate anchors; site builds |
Every operation of notification.v1 is enterprise-scoped, so verify runs no facility cases. The facility goes to the policy decision point with every decision, which LifecycleAndAccessTest.whoSeesWhat exercises.
his-contract verify expects the lowest documented 2xx of an operation. For requestNotification that is 200, the existing notification. requestNotification is the only operation in any contract that documents both 200 and 201. The contract test therefore sends the documented request once first, so that verify's own request is merged under the fixture type's deduplication rule and answered 200. The 201 of a new request and the 200 of a repeated key are covered by NotificationRequestTest.
Requirements and test scenarios¶
Every test carries @Tag with its requirement and scenario, and its display name starts with them. Tests are in services/ess-coordination/mod-ess-007/src/test/java/care/cema/his/ess/mod007/, and one in app/src/test/java/care/cema/his/ess/app/.
| Requirement, criterion | Test |
|---|---|
| FR-ESS-NTF-001 AC-01 on-call role of a unit: delivered to the current holder, status records who | NotificationRequestTest.onCallResolvedToCurrentHolder |
| FR-ESS-NTF-001 AC-02 same idempotency key twice: one notification; PR-NTF-001-1 | NotificationRequestTest.sameKeyOneNotification |
| FR-ESS-NTF-001 AC-03 critical without escalation policy rejected; PR-NTF-001-2 | NotificationRequestTest.criticalWithoutPolicyRejected |
| FR-ESS-NTF-001 AC-04 all channels fail: Delivery Failed, requester event, operations worklist item; PR-NTF-001-5 | DeliveryTest.allChannelsFail; app/NotificationOperationsTest.failureIsAWorklistTask (the MOD-ESS-008 task) |
| FR-ESS-NTF-001 part 10 channel provider outage: retry, alternative channel, operations alerted with a worklist item | DeliveryTest.channelOutageAlerted, recipientReasonIsNoOutage, alternativeChannels; app/NotificationOperationsTest.channelOutageIsAWorklistTask (the MOD-ESS-008 task, with the default unconfigured gateway) |
| FR-ESS-NTF-001 AC-05 each attempt has a timestamp and outcome | DeliveryTest.historyTimestamped; allChannelsFail |
| FR-ESS-NTF-001 AC-06 push or SMS shows no patient detail, only the item, priority and where to open it; opening needs sign-in | DeliveryTest.externalContentCarriesNoPatientDetail; PR-NTF-001-6 LifecycleAndAccessTest.typeValidation |
| FR-ESS-NTF-001 AC-07 a critical-priority channel cannot be switched off; PR-NTF-001-7 | LifecycleAndAccessTest.channelSettings |
| PR-NTF-001-3, PR-NTF-001-4 | NotificationRequestTest.unresolvedRecipient, unavailableHolderPassedOver, roleHolders |
| Parts 6.5, 6.7, 6.9, 6.10, 10, 12; BR-ESS-024, BR-ESS-025; parts 3 and 13; part 4 | duplicateMerged, requestRules, auditedWithoutContent; DeliveryTest.alternativeChannels, criticalFirst, patientReminderBySms, patientPreferences, preferencesUnavailable, survivesUntilNextRun; LifecycleAndAccessTest.cancel, close, retryAndReroute, whoSeesWhat, typeFromConfiguration |
| IF-ESS-009, EVT-ESS-009 | contract/NotificationContractTest |
Scenarios:
- TEST-ESS-025 (on-call recipient resolution; duplicate request; critical without policy) is NotificationRequestTest.
- TEST-ESS-026 (all channels fail: Delivery Failed, requester informed, operations worklist item, escalation proceeds) is DeliveryTest.allChannelsFail and alternativeChannels, with app/NotificationOperationsTest. "Escalation proceeds" is FR-ESS-NTF-002, a later card. What this card guarantees is that the notification stays open and acknowledgement-required for that escalation to pick up, and the test checks both.
All pass.
Done differently from the specification or contract, and why¶
- On-call, team and role-in-unit recipients resolve to nobody in production for now. Domains 1 and 3 have no contract for assignment data. The port
Assignmentsdefaults to none, so such a notification goes to its fallback (critical, high) or is reported unresolved. ADR-HIS-074 point 3 says why IdentityChanged roles are not used in their place. - No external message leaves the unit yet. Domain 2 has no contract for EXT-ISE-013.
ChannelGatewaydefaults toUnconfigured, so every external attempt fails withchannel-unavailable. Workforce notifications are delivered in the application. A patient reminder ends Delivery Failed with an operations task. Delivery receipts have no intake either, so an accepted external message stays Sent. - The seeded
adm.appointment-remindertakesappointmentStartandfacilityName, not the contract example'sclinic. The example's clinic ("Poli Penyakit Dalam") names the service, which Q-RC2-6 and FR-ADM-SCH-002 part 13 exclude from patient content. Domain 1 registers its own type; see the follow-ups. - How a communication-preference directive excludes or prefers a channel is not set by consent.v1. ADR-HIS-074 point 5 reads it from the decision and the channel codes among the scope's data categories. A deny that names no channel excludes every message, so the reading fails toward not sending.
- A normal or low notification with nobody resolved is Delivery Failed with change
recipient-unresolved. The state list of 4.3 has no "unresolved" state, and leaving it Queued would leave it open forever. Only a critical or high one opens an operations item. - "Informational notifications are closed on delivery" (WF-ESS-007) is left to the requester, as section 4.3 makes the calling domain the actor of Closed.
- The kit's audit wire format is the template's provisional one (RC-1-S01 follow-ups), as in the other units.
Review round 1¶
- Part 10 channel provider outage was not alerted to operations when the notification was delivered on another channel, as every workforce notification is in the application. Now built as above (ADR-HIS-074 point 6). Tests:
DeliveryTest.channelOutageAlerted,recipientReasonIsNoOutage,app/NotificationOperationsTest.channelOutageIsAWorklistTask. - Deduplication merged across requesters of the same domain, answering one service with another's notification, which it then could not read. The requester is now part of the deduplication key. Test:
NotificationRequestTest.duplicateMerged. - REP-ESS-011 is listed under the follow-ups.
Questions for a person¶
None. The behaviour comes from FR-ESS-NTF-001, the contract points and the answers to Q-RC2-6 and Q-RC2-7 recorded by RC-2-S01. The readings above are technical and are recorded in ADR-HIS-074. Issue #48 has no comments from people.
Follow-ups outside the card¶
- RC-2-S05 (
services/adm-scheduling-flow): registeradm.appointment-reminderwith a patient template of facility, date and time only. Theclinicparameter of the notification.v1 example would name the service. Until then the seed holds the type withfacilityName. - ESS contract session (next minor version of
notification.v1): - an example request without
clinic; - perhaps the masked address on a delivery, which Q-RC2-6 mentions and the
Deliveryschema has no field for; - a delivery receipt intake once Domain 2 has one.
contracts/common(FN-S04 tool): lethis-contract verifytake the documented status of an operation with several 2xx (for example fromx-his-test). Today it always expects the lowest.- Domain 2 (EXT-ISE-013): a channel interface contract (send, provider receipt), then an HTTP adapter of
ChannelGateway. - Domains 1 and 3: an assignment data contract (on-call holders, team members, role holders in a unit, duty status), then an adapter of
Assignments. - Governance unit (
services/ess-governance): calling another domain's validation hook (its own follow-up from RC-1-S05). Until then a version ofess.notification-typedrafted there gets the finding "cannot be called yet". - RC-1-S16 and RC-1-S17 (policy): register the actions and resource types of ADR-HIS-074 point 8 and the roles
ess.notification-administratorandess.workflow-administrator. Also the rule that a recipient may read a notification concerning a patient only where permitted that subject. - MOD-ESS-008: replace
RecordedNotifierwith requests to MOD-ESS-007 (RC-1-S15's follow-up) once ESS notification types for task escalation and stuck-work alerts are registered. That belongs with FR-ESS-NTF-002, whose escalation policies those requests name. - FR-ESS-NTF-002 (later card): acknowledgement, timers and escalation on the same record. A Delivery Failed notification that requires acknowledgement must escalate as unacknowledged (PR-NTF-001-5).
- Retention: content parameters are kept 90 days and metadata 2 years (D10-ESS retention). No purge job exists yet.
- REP-ESS-011 delivery report (part 9 output: volumes, failures and time to deliver per type, for the notification administrator) is not built, and no session card names it. The data it needs is all in
mod_ess_007.notification(deliveries with their times),channel_outageand the countershis.ess.notification.*. The D10-ESS reporting work of a later slice, or the ESS card that delivers REP-ESS-011 with FR-ESS-NTF-002's escalation report, should build it. - RC-2-S10 (integrate): add
ess-coordinationtoe2e/scenarios/RC-2/stack.json, and sethis.notification.patient-identity-url,consent-urlandconfiguration-url.