Skip to main content

Care Plan Service — Domain Model

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

Aggregates

CarePlan (Root Aggregate)

Invariants:

  • Must reference a valid patientId from registration-service.
  • Only roles care_plan:write or care_plan:admin may create or update.
  • Plans in completed or revoked status are immutable (read-only).
  • status transitions follow the state machine below — no skipping.
  • Optimistic concurrency: version increments atomically; stale writes return 409 Conflict.
  • Maximum 50 active goals and 100 activities per plan (configurable per tenant).

Status State Machine:


CarePlanGoal (Entity, owned by CarePlan)

Invariants:

  • Belongs to exactly one CarePlan.
  • dueAt must be in the future at creation (warning if not — not hard block in MVP).
  • Status transitions: proposed → accepted → in_progress → achieved | cancelled | on_hold.
  • A goal is overdue when dueAt < now and status is not achieved or cancelled.

CarePlanActivity (Entity, owned by CarePlan)

Invariants:

  • Belongs to exactly one CarePlan.
  • May reference a ServiceRequest in orders-service by external ID (not FK).
  • Completion requires completionNote if tenant policy mandates it.
  • Status transitions: not_started → in_progress → completed | cancelled.

CareTeamMember (Entity, owned by CarePlan)

  • References practitionerId from provider-directory-service (soft reference, not FK).
  • Has a role coded as CodeableConcept (e.g., primary care provider, care coordinator, specialist).
  • Effective period: effectiveFrom (required), effectiveTo? (optional — open-ended membership).

Domain Events

Event type (NATS subject)TriggerKey payload fields
care_plan.care_plan.created.v1New CarePlan persistedcarePlanId, patientId, tenantId, status, title
care_plan.care_plan.updated.v1Status or field changedcarePlanId, patientId, previousStatus, newStatus, version
care_plan.care_plan.reviewed.v1Review workflow completedcarePlanId, reviewedBy, reviewedAt, nextReviewDue?
care_plan.goal.created.v1Goal added to plangoalId, carePlanId, patientId, status
care_plan.goal.updated.v1Goal status or target changedgoalId, carePlanId, previousStatus, newStatus
care_plan.activity.created.v1Activity addedactivityId, carePlanId, assigneeId?, status
care_plan.activity.completed.v1Activity marked completeactivityId, carePlanId, completedAt, completionNote?
care_plan.care_team.updated.v1Team membership changedcarePlanId, addedMemberIds[], removedMemberIds[]

All events use CloudEvents v1.0 envelope with tenantid, actorid, correlationid extensions.


Value Objects

Value objectType definition
CarePlanStatusenum { draft, active, on_hold, completed, revoked }
GoalStatusenum { proposed, accepted, in_progress, achieved, cancelled, on_hold }
ActivityStatusenum { not_started, in_progress, completed, cancelled }
CodeableConcept{ coding: Coding[], text?: string }
Coding{ system: string, code: string, display?: string }
TargetDetail{ measure?: CodeableConcept, detailQuantity?: Quantity, dueDate?: string }
Quantity{ value: number, unit: string, system?: string, code?: string }
TenantIdBranded<string, 'TenantId'>
CarePlanIdBranded<string, 'CarePlanId'> — ULID with prefix cp_
GoalIdBranded<string, 'GoalId'> — ULID with prefix cpg_
ActivityIdBranded<string, 'ActivityId'> — ULID with prefix cpa_
CareTeamMemberIdBranded<string, 'CareTeamMemberId'> — ULID with prefix ctm_

Ubiquitous Language

TermDefinition
CarePlanA structured longitudinal plan of care for a patient covering goals, interventions, and responsible team members across one or more conditions
GoalA measurable health objective linked to a care plan, with a coded target, numeric target, or free-text description, and a due date
Activity / InterventionA specific action (education, referral, procedure, monitoring, medication adherence) assigned to a care team member
CareTeamThe set of practitioners responsible for a patient's care plan; each member has a role and effective period
ReviewA formal reassessment of a care plan that updates lastReviewedAt and may change status, goals, or activities
VersionMonotonic integer on the CarePlan aggregate used for optimistic concurrency; every mutation increments it
Overdue goalA goal whose dueAt is past the current date and status is not achieved or cancelled
Closed planA plan in completed or revoked status — immutable, read-only, permanently visible
ActivationTransitioning a plan from draft to active, making it operationally visible to the care team