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
patientIdfrom registration-service. - Only roles
care_plan:writeorcare_plan:adminmay create or update. - Plans in
completedorrevokedstatus are immutable (read-only). statustransitions follow the state machine below — no skipping.- Optimistic concurrency:
versionincrements atomically; stale writes return409 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. dueAtmust 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 < nowand status is notachievedorcancelled.
CarePlanActivity (Entity, owned by CarePlan)
Invariants:
- Belongs to exactly one
CarePlan. - May reference a
ServiceRequestin orders-service by external ID (not FK). - Completion requires
completionNoteif tenant policy mandates it. - Status transitions:
not_started → in_progress → completed | cancelled.
CareTeamMember (Entity, owned by CarePlan)
- References
practitionerIdfrom provider-directory-service (soft reference, not FK). - Has a
rolecoded asCodeableConcept(e.g., primary care provider, care coordinator, specialist). - Effective period:
effectiveFrom(required),effectiveTo?(optional — open-ended membership).
Domain Events
| Event type (NATS subject) | Trigger | Key payload fields |
|---|---|---|
care_plan.care_plan.created.v1 | New CarePlan persisted | carePlanId, patientId, tenantId, status, title |
care_plan.care_plan.updated.v1 | Status or field changed | carePlanId, patientId, previousStatus, newStatus, version |
care_plan.care_plan.reviewed.v1 | Review workflow completed | carePlanId, reviewedBy, reviewedAt, nextReviewDue? |
care_plan.goal.created.v1 | Goal added to plan | goalId, carePlanId, patientId, status |
care_plan.goal.updated.v1 | Goal status or target changed | goalId, carePlanId, previousStatus, newStatus |
care_plan.activity.created.v1 | Activity added | activityId, carePlanId, assigneeId?, status |
care_plan.activity.completed.v1 | Activity marked complete | activityId, carePlanId, completedAt, completionNote? |
care_plan.care_team.updated.v1 | Team membership changed | carePlanId, addedMemberIds[], removedMemberIds[] |
All events use CloudEvents v1.0 envelope with tenantid, actorid, correlationid extensions.
Value Objects
| Value object | Type definition |
|---|---|
CarePlanStatus | enum { draft, active, on_hold, completed, revoked } |
GoalStatus | enum { proposed, accepted, in_progress, achieved, cancelled, on_hold } |
ActivityStatus | enum { 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 } |
TenantId | Branded<string, 'TenantId'> |
CarePlanId | Branded<string, 'CarePlanId'> — ULID with prefix cp_ |
GoalId | Branded<string, 'GoalId'> — ULID with prefix cpg_ |
ActivityId | Branded<string, 'ActivityId'> — ULID with prefix cpa_ |
CareTeamMemberId | Branded<string, 'CareTeamMemberId'> — ULID with prefix ctm_ |
Ubiquitous Language
| Term | Definition |
|---|---|
| CarePlan | A structured longitudinal plan of care for a patient covering goals, interventions, and responsible team members across one or more conditions |
| Goal | A measurable health objective linked to a care plan, with a coded target, numeric target, or free-text description, and a due date |
| Activity / Intervention | A specific action (education, referral, procedure, monitoring, medication adherence) assigned to a care team member |
| CareTeam | The set of practitioners responsible for a patient's care plan; each member has a role and effective period |
| Review | A formal reassessment of a care plan that updates lastReviewedAt and may change status, goals, or activities |
| Version | Monotonic integer on the CarePlan aggregate used for optimistic concurrency; every mutation increments it |
| Overdue goal | A goal whose dueAt is past the current date and status is not achieved or cancelled |
| Closed plan | A plan in completed or revoked status — immutable, read-only, permanently visible |
| Activation | Transitioning a plan from draft to active, making it operationally visible to the care team |