feat(course): treatment courses with protocol-driven session planning
Laser is six to eight sessions; the previous design only knew single appointments, which is the exception rather than the rule. - CourseProtocol per service: session count and three distinct spacings — min is the earliest that is clinically allowed, ideal is best, max is where the course starts losing its effect - Starting a course creates every session up front as `planned` and copies the protocol's numbers and per-session params, so changing the protocol tomorrow leaves a running course alone - Suggestions anchor on the last *completed* session, not the course start: when session 2 slips, session 3 moves with it - Slots are ranked by distance from ideal, not by earliest available — day 21 is worse than day 27 when 28 is the target - book-all is all-or-nothing inside one transaction, with a moving anchor and a 90-day horizon; sessions past the horizon stay planned and are reported, not treated as failures - The effective minimum is the stricter of the protocol and the task-09 spacing policy, so a clinic rule never fights the protocol - Cancelling one session returns only that session to planned; abandoning a course does not cancel its appointments, which stays an explicit decision One active course per (patient, service) via active_course_key, the same partial-uniqueness trick as Appointment::activeSlotKey. Admin: CourseProtocolsPage, TreatmentCoursePage and a courses tab on the patient record. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1251,3 +1251,75 @@ export interface CreditLedger {
|
||||
package: PatientPackage;
|
||||
rows: CreditLedgerRow[];
|
||||
}
|
||||
|
||||
// ── دورهٔ درمان (تسک ۱۲) ──────────────────────────────────────────────────────
|
||||
|
||||
export interface CourseProtocolStep {
|
||||
session_number: number;
|
||||
params: Record<string, string | number | boolean>;
|
||||
override_duration_minutes: number | null;
|
||||
}
|
||||
|
||||
export interface CourseProtocol {
|
||||
uuid: string;
|
||||
service_uuid: string;
|
||||
service_name: string;
|
||||
session_count: number;
|
||||
min_days: number;
|
||||
ideal_days: number;
|
||||
max_days: number;
|
||||
prefer_same_resource: boolean;
|
||||
active: boolean;
|
||||
steps: CourseProtocolStep[];
|
||||
created_at: number;
|
||||
}
|
||||
|
||||
export interface CourseSessionRow {
|
||||
uuid: string;
|
||||
session_number: number;
|
||||
params: Record<string, string | number | boolean>;
|
||||
appointment_uuid: string | null;
|
||||
slot_start: number | null;
|
||||
status: 'planned' | 'booked' | 'completed' | 'skipped';
|
||||
completed_at: number | null;
|
||||
}
|
||||
|
||||
export interface CourseProgress {
|
||||
completed: number;
|
||||
booked: number;
|
||||
planned: number;
|
||||
skipped: number;
|
||||
total: number;
|
||||
next_session_number: number | null;
|
||||
next_params: Record<string, string | number | boolean>;
|
||||
last_completed_at: number | null;
|
||||
}
|
||||
|
||||
export interface TreatmentCourse {
|
||||
uuid: string;
|
||||
patient_uuid: string;
|
||||
service_uuid: string;
|
||||
service_name: string;
|
||||
protocol_uuid: string;
|
||||
session_count: number;
|
||||
min_days: number;
|
||||
ideal_days: number;
|
||||
max_days: number;
|
||||
patient_package_uuid: string | null;
|
||||
preferred_resource_uuid: string | null;
|
||||
status: 'active' | 'completed' | 'abandoned';
|
||||
abandon_reason: string | null;
|
||||
started_at: number;
|
||||
completed_at: number | null;
|
||||
progress: CourseProgress;
|
||||
sessions?: CourseSessionRow[];
|
||||
}
|
||||
|
||||
export interface NextSlotSuggestion {
|
||||
session_number: number | null;
|
||||
params: Record<string, string | number | boolean>;
|
||||
ideal_at?: number;
|
||||
range?: { min: number; max: number };
|
||||
suggested_slots: { start: number; end: number }[];
|
||||
warning: string | null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user