%% ЛР2 — Диаграмма классов (ИС регистрации пациента в больнице)
classDiagram
  class User {
    +id: UUID
    +login: string
    +passwordHash: string
    +fullName: string
    +role: Role
  }
  class Registrar
  class Doctor {
    +specialty: string
  }
  class HeadOfDepartment
  class Admin
  User <|-- Registrar
  User <|-- Doctor
  User <|-- HeadOfDepartment
  User <|-- Admin

  class Patient {
    +id: UUID
    +fullName: string
    +birthDate: date
    +sex: string
    +phone: string
    +policyNumber: string
  }

  class Department {
    +id: UUID
    +name: string
  }

  class Admission {
    +id: UUID
    +admitDate: datetime
    +dischargeDate: datetime
    +status: AdmissionStatus
  }

  class Appointment {
    +id: UUID
    +dateTime: datetime
    +status: ApptStatus
  }

  class MedicalRecord {
    +id: UUID
    +createdAt: datetime
  }

  class Diagnosis {
    +code: string
    +name: string
    +notes: string
  }

  class TreatmentPlan {
    +id: UUID
    +createdAt: datetime
    +notes: string
  }

  class Prescription {
    +id: UUID
    +drugName: string
    +dosage: string
    +schedule: string
  }

  class Procedure {
    +id: UUID
    +name: string
    +dateTime: datetime
    +result: string
  }

  class Invoice {
    +id: UUID
    +issueDate: date
    +total: money
    +status: InvoiceStatus
  }

  class InvoiceItem {
    +name: string
    +qty: int
    +price: money
    +amount(): money
  }

  class Payment {
    +id: UUID
    +dateTime: datetime
    +amount: money
    +method: PayMethod
  }

  class Report {
    +id: UUID
    +title: string
    +periodStart: date
    +periodEnd: date
    +generatedAt: datetime
  }

  %% Associations & multiplicities
  Patient "1" --> "0..*" Appointment
  Doctor "1" --> "0..*" Appointment
  Appointment "*" --> "0..1" Diagnosis

  Patient "1" --> "1" MedicalRecord
  MedicalRecord "1" --> "0..*" Diagnosis
  MedicalRecord "1" --> "0..*" TreatmentPlan
  TreatmentPlan "1" --> "0..*" Prescription
  TreatmentPlan "1" --> "0..*" Procedure

  Registrar "1" --> "0..*" Admission
  Patient "1" --> "0..*" Admission
  Department "1" --> "0..*" Admission
  Admission "1" --> "0..1" TreatmentPlan

  Invoice "1" --> "1..*" InvoiceItem
  Patient "1" --> "0..*" Invoice
  Admission "0..1" --> "0..*" Invoice

  Invoice "1" --> "0..*" Payment

  HeadOfDepartment "1" --> "0..*" Report
  Department "1" --> "0..*" Report