/** * @license * SPDX-License-Identifier: Apache-2.0 */ // --- CORE & ACCESS --- export type View = 'dashboard' | 'appointments' | 'find-doctor' | 'health-assistant' | 'accounting' | 'doctor-registration' | 'clinic-management' | 'medical-history'; export type Role = 'owner' | 'doctor' | 'staff' | 'patient'; // New types for clinic settings export interface OperatingHours { monday: { active: boolean; start: string; end: string }; tuesday: { active: boolean; start: string; end: string }; wednesday: { active: boolean; start: string; end: string }; thursday: { active: boolean; start: string; end: string }; friday: { active: boolean; start: string; end: string }; saturday: { active: boolean; start: string; end: string }; sunday: { active: boolean; start: string; end: string }; } export interface ClinicSettingsData { operating_hours: OperatingHours; online_booking: { enabled: boolean; auto_confirm: boolean; min_booking_notice_hours: number; cancellation_policy_hours: number; }; financial: { currency: string; tax_rate_percent: number; invoice_footer: string; }; } export interface Clinic { id: string; // UUID name: string; owner_id?: string; // UUID of the owner user created_at: string; // ISO 8601 // Add new detailed profile fields address?: string; contact_phone?: string; contact_email?: string; website?: string; settings?: ClinicSettingsData; } export interface User { id: string; // UUID clinic_id: string; // Foreign Key to Clinic email: string; password_hash: string; role: Role; created_at: string; // ISO 8601 schedule_id?: string; // FK to Schedule } // --- CLINIC OPERATIONS --- export interface Patient { id: string; // UUID clinic_id: string; // FK to Clinic name: string; dob?: string; // YYYY-MM-DD gender?: string; contact_info?: Record; // JSONB created_at: string; // ISO 8601 } export interface Doctor { id: string; // UUID clinic_id: string; // FK to Clinic name: string; specialty?: string; created_at: string; // ISO 8601 // Denormalized for UI convenience photo?: string; } export interface Service { id: string; // UUID clinic_id: string; // FK to Clinic name: string; price: number; duration_minutes: number; currency?: string; } export type AppointmentStatus = 'scheduled' | 'completed' | 'canceled'; export interface Appointment { id: string; // UUID clinic_id: string; // FK to Clinic patient_id: string; // FK to Patient doctor_id: string; // FK to Doctor service_id?: string; // FK to Service start_time: string; // ISO 8601 status: AppointmentStatus; } // --- MEDICAL (EMR) --- export interface Encounter { id: string; // UUID clinic_id: string; // FK to Clinic patient_id: string; // FK to Patient doctor_id: string; // FK to Doctor appointment_id?: string; // FK to Appointment notes?: string; vitals?: Record; // JSONB created_at: string; // ISO 8601 } export interface Problem { encounter_id: string; // UUID description: string; } export interface Allergy { patient_id: string; substance: string; reaction?: string; } export interface Medication { encounter_id: string; // UUID drug_name: string; dosage?: string; instructions?: string; } // --- FINANCIALS --- export type InvoiceStatus = 'draft' | 'issued' | 'paid' | 'canceled'; export interface InvoiceLine { id: string; // UUID invoice_id: string; service_id?: string; quantity: number; price: number; } export interface Invoice { id: string; // UUID clinic_id: string; // FK to Clinic patient_id: string; // FK to Patient total: number; status: InvoiceStatus; issued_at: string; // ISO 8601 invoice_lines: InvoiceLine[]; // Denormalized for UI } export interface Payment { id: string; // UUID invoice_id: string; // FK to Invoice amount: number; method?: string; paid_at: string; // ISO 8601 } // --- UI SPECIFIC --- // For doctor registration flow export interface DoctorRegistrationData { user: Partial; doctor: Partial; } // New type for schedule overrides export interface DayOverride { date: string; // YYYY-MM-DD active: boolean; start?: string; // HH:mm, required if active end?: string; // HH:mm, required if active } // FIX: Define Schedule type for doctor schedule feature. export interface Schedule { id: string; // UUID clinic_id: string; // FK to Clinic appointment_length_minutes: number; buffer_time_minutes: number; overrides: DayOverride[]; // Replaces holidays for more flexibility weekdays: { monday: { active: boolean; start: string; end: string }; tuesday: { active: boolean; start: string; end: string }; wednesday: { active: boolean; start: string; end: string }; thursday: { active: boolean; start: string; end: string }; friday: { active: boolean; start: string; end: string }; saturday: { active: boolean; start: string; end: string }; sunday: { active: boolean; start: string; end: string }; }; }