Skip to main content

Communication Service — Service Overview

Status: populated Owner: TBD Last updated: 2026-04-17 Companion: Service Template · 03 platform-services · 02 DDD

1. Purpose

The communication-service is the unified digital communication backbone of the Ghasi-eHealth platform. It owns three tightly-related capabilities behind a single bounded context:

  1. Secure messaging between care-team members and, when licensed, between providers and patients.
  2. Outbound notification orchestration across push (FCM/APNs/WebPush), SMS (via Ghasi-SMS-Gateway and alternates), and email (SES / SendGrid / SMTP).
  3. Virtual session lifecycle management (join-token issuance, waiting-room, admission, fallback-to-messaging continuity) for telehealth encounters.

This consolidates the legacy messaging, notifications-platform, and virtual-care modules into one service per ADR-0047.

2. Bounded Context

Digital Communication — classified as Supporting (important but not a core domain differentiator). The capability is kept in-house because every clinical workflow (results, orders, scheduling, critical alerts) depends on PHI-safe delivery semantics that no SaaS notification vendor enforces by default.

3. Responsibilities

AreaWhat communication-service Owns
Messaging threadsThread lifecycle, participants, messages, read receipts, escalation
Patient-linked messagingOptional patient/encounter linkage, chart-policy-filtered visibility
AttachmentsUpload intake, malware-scan hook, size/type limits, MIME allowlists
Retention / legal holdPer-tenant message retention policy, legal hold flags
Notification orchestrationCategory → channel policy → template → provider dispatch
Provider adaptersPorts for SmsProvider, PushNotificationProvider, EmailProvider
Dispatch logAudit-friendly per-channel outcome (no PHI in structured logs)
Virtual sessionsSession creation from scheduling events, join tokens, admit/remove
Fallback continuityAutomatic fallback messaging thread when virtual session fails
FHIR projectionCommunication, CommunicationRequest, Encounter.class=VR

4. Non-Responsibilities

AreaOwnerWhy Not Communication
Clinical notes contentpatient-chart-serviceMessaging is transport, not the chart of record
Schedulingscheduling-serviceProduces the appointment.* events that create virtual sessions
Identity / user authidentity-serviceConsumes JWTs; does not mint them
Consent recordspatient-portal-service / tenant-serviceMessaging enforces consent, does not store it
SMS delivery transportGhasi-SMS-Gateway (external)Communication is the orchestrator; gateway is the carrier
AI summarization / toneai-gateway-serviceAll assistive AI routes through Kong /v1/ai/*

5. Dependencies

5.1 Upstream (consumed)

DependencyPatternPurpose
identity-serviceCF (JWT claims)sub, tid, roles
scheduling-serviceEvent consumerSCHEDULING.appointment.created / .cancelled / .reminder.sent
patient-portal-serviceEvent consumerportal.notification.queued
laboratory-service / radiology-serviceEvent consumerresult.critical.flagged
Ghasi-SMS-GatewayACL (adapter)Regional SMS delivery with DLR callbacks
FCM / APNs / WebPushACL (adapter)Push delivery
SES / SendGrid / SMTPACL (adapter)Email delivery
interop-service / fhir-gatewayDownstreamCreates Communication, reads Patient, Encounter
config-servicePullTenant branding, templates, channel policy

5.2 Downstream (produced events)

ConsumerConsumes
audit-service.dispatched metadata for accounting of disclosures
patient-chart-service.message.sent when patient-linked to project into chart timeline
virtual-care UXvirtual_session.* realtime signals
billing-servicevirtual_session.billing.chargeable

6. Slice Involvement

SliceScopeMilestone
S1Provider-to-provider messaging, basic email notifications, SMS via Ghasi-SMS-GatewayM1
S2Patient messaging (when portal licensed), push notifications, virtual session lifecycleM2
S3Advanced escalation policies, critical-result fan-out, fallback-to-messaging from virtual careM3
S4Digest bundling, bounce analytics, per-tenant channel SLOsM4

7. Key Architectural Decisions

  1. One service, three capabilities. Messaging, notifications, and virtual sessions share the same tenancy model, auth surface, FHIR projection (Communication), and outbox stream — keeping them in one service prevents four-way coordination.
  2. Ghasi-SMS-Gateway is an adapter, not a replacement. Regional rollouts in Afghanistan use Ghasi-SMS-Gateway; other deployments plug Twilio / Vonage without domain-layer changes.
  3. No PHI in push/SMS/email by default. Dispatch payloads carry opaque ids, deep links, and template keys. BR-MSG-001 / BR-PORT-003.
  4. Canonical CloudEvents types. ghasi.digital_communication.* is the canonical prefix; legacy ghasi.messaging.* and VIRTUAL_CARE.* subjects dual-publish during migration.
  5. Fallback continuity is first-class. A failed virtual session automatically spawns a secure messaging thread linking session id so care continues without manual re-wiring.

8. Architecture Diagram

9. Source reconciliation

Merged _sources/messaging/ (COM-MSG, deprecated) + _sources/digital-communication/ (COM-DCOM, canonical) per ADR-0047:

DecisionOutcome
Canonical prefixAll new routes under /v1/communication/*; legacy /v1/digital-communication/* and /v1/messaging/* remain for migration
FR ID unificationFR-COMMS-MSG-*, FR-COMMS-NOTIF-*, FR-COMMS-VC-* adopted; legacy FR-MSG-*, FR-DCOM-* preserved in traceability column
Eventsghasi.digital_communication.* is canonical; ghasi.messaging.* and VIRTUAL_CARE.* dual-publish until M3
Virtual-care scopeKept inside communication-service; separate virtual-care-service is retired per ADR-0047