Skip to content

ADR-004: Doctor as Role (Not Separate Service) ​

Status ​

Superseded by ADR-013.

Context ​

Doctors are central to our system - they create prescriptions, belong to organizations, and have professional credentials. We needed to decide:

  • Separate Doctor Service: Own service for doctor management
  • Doctor as Role in Identity: DoctorProfile as part of user identity
  • Distributed: Doctor logic spread across services

Decision ​

We will treat Doctor as a role that a User plays, with DoctorProfile as a value object in the Identity service. No separate Doctor service.

Rationale ​

Why Not Separate Doctor Service? ​

A Doctor is not an aggregate root with its own lifecycle - they're always a User first:

User (Aggregate Root)
├── DoctorProfile (Value Object)
├── StaffProfile (Value Object)
└── Memberships (to Organizations)

Where Doctor Logic Lives ​

OperationServiceReason
Create/verify doctor profileIdentityIt's a user profile
Doctor search by specializationIdentityQuerying profile data
Doctor-Patient relationshipPrescriptionPrescriptions link them
Doctor in an organizationOrganizationMembership handles this
Doctor verificationAdminAdmin workflow
Doctor statisticsPrescriptionComputed from prescriptions

When Would a Doctor Service Make Sense? ​

Consider extracting only when:

  • Complex verification workflows (license verification against medical boards)
  • Doctor discovery becomes core feature (search by location, availability, ratings)
  • Doctor-specific settings (notification preferences, prescription templates)
  • Regulatory requirements (doctor-specific audit trails)

Even then, these could be modules within Identity first.

Consequences ​

Positive ​

  • Simpler architecture (no cross-service calls)
  • Clear data ownership
  • Doctor profile is co-located with user data

Negative ​

  • Doctor-related queries may span services
  • Need query layer for doctor search across contexts
  • ADR-003: Event-Driven Architecture
  • ADR-005: Doctor Verification in Admin Service

Documentation follows the source. Planned contracts are marked explicitly.