Skip to content

Architecture / Decision records / ADR-HIS-074

ADR-HIS-074 The notification service: delivery lanes per recipient and channel, ports for what has no contract yet, the interim patient path, and the operations worklist as a task

Status Accepted
Decided 2026-11-26 by session RC-2-S03
Record Drafted 2026-11-26; approved 2026-11-30 by the Enterprise Architecture Board
Where the rule lives services/ess-coordination/ (its README.md; module mod-ess-007, its migration mod-ess-007/src/main/resources/db/mod_ess_007/, notification/types.json, the contract test in mod-ess-007/src/test/java/care/cema/his/ess/mod007/contract/; mod-ess-008 task/NotificationOperations.java and workflow/registrations.json)

Context

Session RC-2-S03 builds MOD-ESS-007 in the coordination unit services/ess-coordination. That is notification dispatch, recipient resolution and delivery status (FR-ESS-NTF-001). It serves notification.v1 (IF-ESS-009) of the ESS contracts (ADR-HIS-067) and publishes NotificationStatusChanged (EVT-ESS-009). Every domain that sends a critical result, a reminder or an alert will call it, and acknowledgement and escalation (FR-ESS-NTF-002) will be built on it. The choices below therefore bind later sessions. The specification and the contract leave these points to the design: - how deliveries are persisted, ordered, retried and moved to other channels (parts 6.6, 6.7, 6.9); - what to do where the recipient data or the channel has no contract yet: on-call and team assignments of Domains 1 and 3, the Domain 2 channel interface (EXT-ISE-013), Domain 7; - how the interim patient path decided for Q-RC2-6 reads a patient's communication preference; - where notification types come from before each domain registers its own; - what the operations worklist of AC-04 is; - how a request is authorized.

Decision

  1. A notification is persisted before it is answered, and delivered by a dispatcher.
  2. requestNotification validates, asks the policy decision point, and commits the notification as Queued with its Idempotency-Key in one transaction. Only then does it answer 201.
  3. A request is merged under the type's deduplication rule only into a notification of the same requester: the requester is part of the deduplication key, so a merged requester can always read, cancel and close what it is answered (part 3, BR-ESS-024).
  4. The dispatcher takes one notification at a time, locked with for update skip locked, critical first and then the oldest (part 6.9). It runs on a schedule (his.notification.scheduler-interval) and once right after the request commits. A restart therefore loses nothing (NFR-ESS-008), and several replicas never work one notification twice.
  5. The recipient is resolved at the first dispatch, not at the request (part 6.2). The outcome, the people and the time are recorded in recipientResolution and resolvedRecipients.
  6. Each channel to each resolved recipient is a lane.
  7. A lane is due, accepted, delivered or given up. Each attempt is a deliveries entry with its times, outcome, reason and the attempt it retries (part 6.6, AC-05), audited as ess.ntf.delivery without content.
  8. A failed attempt is retried with backoff (max-attempts, initial-backoff, max-backoff). When a lane is given up on a high or critical notification, the type's other channels to the same recipient are added at once (part 6.7).
  9. The notification is Sent when a lane is accepted, and Delivered when one is delivered. It is Delivery Failed when every lane is given up. That decision is made by the notification, not per recipient.
  10. The in-application channel is the module's own inbox. Putting a notification in a workforce user's inbox is its delivery (part 6.3). An external channel is Delivered only on the provider's confirmation; acceptance is Sent (Q-RC2-6).
  11. What has no contract yet is a port, and its default never guesses.
  12. Channels (push, sms, email, whatsapp) go through ChannelGateway (EXT-ESS-005, EXT-ISE-013). The default Unconfigured fails every attempt with channel-unavailable. A workforce notification is still delivered in the application. An external-only path ends Delivery Failed with an operations worklist item.
  13. Assignments (on-call holders, team members, holders of a role in a unit, who is off duty) go through Assignments. The default resolves nobody, so a critical or high notification goes to its fallback (PR-NTF-001-3), and a normal or low one is reported unresolved.
  14. A role without a unit resolves to its active holders as IdentityChanged reports them.
  15. A suspended or deactivated account, or one the assignment data shows off duty, is passed over for the next holder or the fallback (PR-NTF-001-4).
  16. Notification types are installed from configuration, and seeded until each domain registers its own.
  17. At start the unit registers the configuration item type ess.notification-type with configuration.v1, with validateNotificationType as its validation hook (contract point 8).
  18. A version activated or rolled back there arrives as ConfigurationChanged. It is read through IF-ESS-012 and installed only if it has no finding.
  19. The seed notification/types.json adds adm.appointment-reminder on behalf of Domain 1 when it is missing, as ADR-HIS-058 point 4 did for task types. Its patient template carries facility, date and time only (Q-RC2-6, FR-ADM-SCH-002 part 13). So its parameters are appointmentStart and facilityName, and the clinic, which names the service, is not one of them.
  20. The interim patient path of Q-RC2-6.
  21. The channels are those of his.notification.patient-channels (sms, then whatsapp) that the type allows by name or through patient-channel.
  22. The patient's active communication-preference directives are read through consent.v1 listConsentDirectives:
    • a directive with decision deny excludes the channels its scope names as data categories (sms, whatsapp, email, push, patient-channel), or every message when it names none;
    • a directive with decision permit that names a channel makes it the preferred one;
    • with no directive, the reminder goes under the general consent.
  23. While the consent service cannot answer, nothing is sent; the dispatcher retries, then ends Delivery Failed with preferences-unavailable.
  24. The mobile number is read from Domain 1 readPerson for each attempt and never stored. The lane keeps a masked address (+62*******7890). No permitted channel, or no number, is Delivery Failed with no-permitted-patient-channel.
  25. The operations worklist of AC-04 is a task of MOD-ESS-008.
  26. MOD-ESS-007 declares the interface api.DeliveryFailureWorklist, and MOD-ESS-008 implements it (NotificationOperations, the primary bean) with TaskService.createInternal.
  27. The item is a task ess.notification-delivery-failure in queue ess.notification-operations (eligible ess.notification-administrator, supervised by ess.workflow-administrator), with the notification as subject. It is created in the transaction that marks the notification Delivery Failed, so the failure and its item commit together.
  28. One task per failure: the create key counts the notification's failures.
  29. MOD-ESS-008 depends on MOD-ESS-007's api package, within the module boundary rule. Run alone, MOD-ESS-007 records the item in its own table.
  30. A normal or low notification that simply had nobody to go to is reported to the requester and opens no item.
  31. A channel provider outage is alerted to operations (part 10: "retry; alternative channel; alert operations; operations worklist item"). A lane given up on a channel for a reason of the channel (not no-permitted-patient-channel, no-patient-template or contact-unavailable) opens the channel's outage (channel_outage, one open per channel). An open outage has one task ess.notification-channel-outage in the same queue, with the channel as subject and the first notification it hit as origin. Lanes given up while it is open are counted on it, not alerted again. It closes when the channel accepts or delivers a message, and a later failure opens a new outage. This holds when the notification itself was delivered on another channel, so a critical result delivered in the application still alerts operations that its push, SMS or email could not be sent.
  32. External content to the workforce is checked twice.
  33. At registration, a template of an external channel for workforce recipients may use no parameter of category patient-name, patient-identifier, diagnosis or result (PR-NTF-001-6).
  34. At send time, such a message is the type's template only if it still uses none. Otherwise it is the minimum message: one item waiting, its priority, the type's title, and "open the hospital app".
  35. It never carries the patient or the subject references. It points to the item's place in the application (his.notification.open-target), which asks for sign-in (AC-06). The in-application message, with its patient context, is answered only to an eligible recipient.
  36. Times in a message are shown in his.notification.zone, with the zone named (NFR-ESS-015, NFR-ESS-016).
  37. Authorization. The resource types are ess.Notification, ess.NotificationSettings and ess.NotificationType. The actions are:
  38. ess.ntf.notification.request, .read, .list, .cancel, .close, .retry and .administer;
  39. ess.ntf.settings.read and .update;
  40. ess.ntf.type.validate.

The unit checks these rules itself, before the decision: - a request comes from a service whose domain owns the type; - a service reads, cancels and closes only its own notifications; - a person reads a notification delivered to them (.read, with the patient, part 13), or else needs the administrator's .administer; - retry is for a person; - a user changes only their own channel settings.

Each decision is asked for the facility the notification concerns (architecture 7.5).

Consequences

  • A requesting domain gets an identifier at once, and learns the outcome from NotificationStatusChanged or readNotification. Under load, critical items still go first.
  • Until Domain 2 offers its channel interface, nothing leaves the building. Workforce notifications arrive in the application, and each external channel has one open outage task in the operations queue. A patient reminder ends Delivery Failed with an operations task, which an administrator sees and can retry or reroute. This is visible, not silent.
  • Until Domains 1 and 3 offer assignment data, on-call and team notifications reach only their fallback. A critical request should always name one.
  • FR-ESS-NTF-002 (acknowledgement and escalation) adds timers to the same notification record. A Delivery Failed notification that requires acknowledgement stays open for it, as PR-NTF-001-5 requires.
  • MOD-ESS-008 can replace its recorded notification requests (RecordedNotifier) with real requests once the ESS notification types for escalation and stuck-work alerts are registered.

Alternatives considered

  • Deliver inside the request. Rejected: a slow channel would hold the caller, a crash between the answer and the send would lose the notification, and part 6.9 could not be honoured.
  • A message queue per priority. Rejected for this slice: the outbox, a locked table read in priority order and the schedule already give ordering, at-least-once delivery and replica safety, without a component outside the technology stack.
  • Resolve on-call and team recipients from IdentityChanged roles while Domains 1 and 3 have no contract. Rejected: a role held anywhere in the enterprise is not the on-call holder of a unit. It would notify the wrong people and record them as accountable.
  • Call workflow.v1 createTask over HTTP for the worklist item. Rejected: the task would not commit with the failure, and a lost call would leave a failed notification without its item.