/** * @fileoverview Healthcare utilities for medical scheduling and compliance timing * Provides medication schedules, shift patterns, on-call rotations, and compliance windows */ import type { DateInput, DateRange } from './types.js'; import { Duration } from './duration.js'; /** * Standard medical abbreviations for medication frequency */ export type MedicationFrequency = 'QD' | 'BID' | 'TID' | 'QID' | 'q4h' | 'q6h' | 'q8h' | 'q12h' | 'PRN'; /** * Shift duration patterns */ export type ShiftPattern = '8hr' | '12hr' | '24hr'; /** * Configuration for shift scheduling */ export interface ShiftConfig { pattern: ShiftPattern; startTime: { hour: number; minute: number; }; rotation?: 'fixed' | 'rotating'; } /** * Configuration for medication timing */ export interface MedicationConfig { wakeTime?: string; sleepTime?: string; withMeals?: boolean; } /** * On-call slot assignment */ export interface OnCallSlot { staff: string; start: Date; end: Date; } /** * Number of doses per day for each frequency */ export declare const MEDICATION_FREQUENCIES: Record; /** * Hours per shift pattern */ export declare const SHIFT_DURATIONS: Record; /** * Default medication timing config */ export declare const DEFAULT_MEDICATION_CONFIG: Required; /** * Get medication administration times for a given date and frequency * * @param date - The date to get medication times for * @param frequency - Medical frequency abbreviation (QD, BID, TID, etc.) * @param config - Optional configuration for wake/sleep times * @returns Array of Date objects for each dose, empty array for PRN * * @example * ```ts * const times = getMedicationTimes(new Date('2024-01-15'), 'BID'); * // Returns [7:00 AM, 7:00 PM] (twice daily) * * const customTimes = getMedicationTimes(new Date('2024-01-15'), 'TID', { * wakeTime: '06:00', * sleepTime: '21:00' * }); * // Returns [6:00 AM, 1:30 PM, 9:00 PM] (three times daily) * ``` */ export declare function getMedicationTimes(date: DateInput, frequency: MedicationFrequency, config?: MedicationConfig): Date[]; /** * Get the next medication time after a given date/time * * @param after - The date/time to find the next medication time after * @param frequency - Medical frequency abbreviation * @param config - Optional configuration * @returns Next medication Date, or null for PRN * * @example * ```ts * const next = getNextMedicationTime(new Date('2024-01-15T10:00:00'), 'BID'); * // Returns 7:00 PM on same day (next BID dose after 10 AM) * ``` */ export declare function getNextMedicationTime(after: DateInput, frequency: MedicationFrequency, config?: MedicationConfig): Date | null; /** * Parse a medication frequency string to MedicationFrequency type * * @param freq - String to parse (case-insensitive) * @returns MedicationFrequency or null if invalid * * @example * ```ts * parseMedicationFrequency('bid'); // 'BID' * parseMedicationFrequency('q8h'); // 'q8h' * parseMedicationFrequency('invalid'); // null * ``` */ export declare function parseMedicationFrequency(freq: string): MedicationFrequency | null; /** * Generate shift schedule for a date range * * @param start - Start of range * @param end - End of range * @param config - Shift configuration * @returns Array of DateRange objects representing shifts * * @example * ```ts * const shifts = generateShiftSchedule( * new Date('2024-01-15'), * new Date('2024-01-17'), * { pattern: '12hr', startTime: { hour: 7, minute: 0 } } * ); * // Returns 4 shifts: day/night on 15th, day/night on 16th * ``` */ export declare function generateShiftSchedule(start: DateInput, end: DateInput, config: ShiftConfig): DateRange[]; /** * Get the shift containing a specific time * * @param date - The date/time to check * @param config - Shift configuration * @returns DateRange of the shift containing the time * * @example * ```ts * const shift = getShiftForTime( * new Date('2024-01-15T14:00:00'), * { pattern: '8hr', startTime: { hour: 7, minute: 0 } } * ); * // Returns { start: 7:00 AM, end: 3:00 PM } (day shift) * ``` */ export declare function getShiftForTime(date: DateInput, config: ShiftConfig): DateRange; /** * Check if a date/time is during a specific shift * * @param date - The date/time to check * @param shiftStart - When the shift started * @param config - Shift configuration * @returns true if the time is during the shift * * @example * ```ts * isOnShift( * new Date('2024-01-15T10:00:00'), * new Date('2024-01-15T07:00:00'), * { pattern: '8hr', startTime: { hour: 7, minute: 0 } } * ); // true (10 AM is during 7 AM - 3 PM shift) * ``` */ export declare function isOnShift(date: DateInput, shiftStart: DateInput, config: ShiftConfig): boolean; /** * Create an on-call rotation schedule * * @param start - Start of rotation period * @param end - End of rotation period * @param staff - Array of staff names to rotate through * @param hoursPerShift - Hours per on-call shift (default 24) * @returns Array of OnCallSlot assignments * * @example * ```ts * const rotation = createOnCallRotation( * new Date('2024-01-15'), * new Date('2024-01-18'), * ['Dr. Smith', 'Dr. Jones', 'Dr. Brown'], * 24 * ); * // Returns 3 slots, one per doctor per day * ``` */ export declare function createOnCallRotation(start: DateInput, end: DateInput, staff: string[], hoursPerShift?: number): OnCallSlot[]; /** * Get the staff member on call at a specific time * * @param date - The date/time to check * @param rotation - The on-call rotation schedule * @returns Staff name or null if no one is on call * * @example * ```ts * const onCall = getOnCallStaff(new Date('2024-01-16T03:00:00'), rotation); * // Returns 'Dr. Jones' (whoever is on call at 3 AM on the 16th) * ``` */ export declare function getOnCallStaff(date: DateInput, rotation: OnCallSlot[]): string | null; /** * Check if an event occurred within its compliance window * * @param event - When the event occurred * @param deadline - The compliance deadline * @returns true if event is before or at deadline * * @example * ```ts * isWithinComplianceWindow( * new Date('2024-01-15T10:00:00'), * new Date('2024-01-15T12:00:00') * ); // true (event occurred before deadline) * ``` */ export declare function isWithinComplianceWindow(event: DateInput, deadline: DateInput): boolean; /** * Calculate the compliance deadline from an event * * @param event - The triggering event * @param windowHours - Hours until deadline * @returns Deadline Date * * @example * ```ts * const deadline = getComplianceDeadline( * new Date('2024-01-15T08:00:00'), * 72 * ); * // Returns 2024-01-18T08:00:00 (72 hours later) * ``` */ export declare function getComplianceDeadline(event: DateInput, windowHours: number): Date; /** * Calculate time remaining until a compliance deadline * * @param event - Current time or event time * @param deadline - The compliance deadline * @returns Duration until deadline, or null if already past * * @example * ```ts * const remaining = timeUntilDeadline( * new Date('2024-01-15T10:00:00'), * new Date('2024-01-16T10:00:00') * ); * // Returns Duration of 24 hours * ``` */ export declare function timeUntilDeadline(event: DateInput, deadline: DateInput): Duration | null; /** * Calculate rest hours between two shifts * * @param shift1End - End of first shift * @param shift2Start - Start of second shift * @returns Hours of rest between shifts * * @example * ```ts * const rest = calculateRestBetweenShifts( * new Date('2024-01-15T19:00:00'), * new Date('2024-01-16T07:00:00') * ); * // Returns 12 (hours of rest) * ``` */ export declare function calculateRestBetweenShifts(shift1End: DateInput, shift2Start: DateInput): number; //# sourceMappingURL=healthcare.d.ts.map