emr-types
Version:
Comprehensive TypeScript Types Library for Electronic Medical Record (EMR) Applications - Domain-Driven Design with Zod Validation
479 lines • 10.3 kB
TypeScript
/**
* Date/Time Utility Types for EMR Application
*
* Provides comprehensive date and time related types for scheduling,
* appointments, medical records, and business logic.
*
* @package emr-types
*/
/**
* ISO 8601 date string
*/
export type ISODateString = string;
/**
* ISO 8601 datetime string
*/
export type ISODateTimeString = string;
/**
* ISO 8601 time string
*/
export type ISOTimeString = string;
/**
* Unix timestamp in seconds
*/
export type UnixTimestamp = number;
/**
* Unix timestamp in milliseconds
*/
export type UnixTimestampMs = number;
/**
* Date range with start and end dates
*/
export interface DateRange {
start: Date;
end: Date;
}
/**
* Time range with start and end times
*/
export interface TimeRange {
start: Date;
end: Date;
}
/**
* DateTime range with start and end datetimes
*/
export interface DateTimeRange {
start: Date;
end: Date;
}
/**
* Time period types
*/
export declare enum TimePeriod {
MINUTE = "minute",
HOUR = "hour",
DAY = "day",
WEEK = "week",
MONTH = "month",
QUARTER = "quarter",
YEAR = "year",
DECADE = "decade"
}
/**
* Time period configuration
*/
export interface TimePeriodConfig {
type: TimePeriod;
value: number;
label: string;
description?: string;
}
/**
* Relative time period
*/
export interface RelativeTimePeriod {
type: 'relative';
period: TimePeriod;
value: number;
direction: 'past' | 'future';
}
/**
* Absolute time period
*/
export interface AbsoluteTimePeriod {
type: 'absolute';
start: Date;
end: Date;
}
/**
* Union type for time periods
*/
export type TimePeriodType = RelativeTimePeriod | AbsoluteTimePeriod;
/**
* Day of week
*/
export declare enum DayOfWeek {
SUNDAY = 0,
MONDAY = 1,
TUESDAY = 2,
WEDNESDAY = 3,
THURSDAY = 4,
FRIDAY = 5,
SATURDAY = 6
}
/**
* Month of year
*/
export declare enum MonthOfYear {
JANUARY = 0,
FEBRUARY = 1,
MARCH = 2,
APRIL = 3,
MAY = 4,
JUNE = 5,
JULY = 6,
AUGUST = 7,
SEPTEMBER = 8,
OCTOBER = 9,
NOVEMBER = 10,
DECEMBER = 11
}
/**
* Business hours configuration
*/
export interface BusinessHours {
start: string;
end: string;
daysOfWeek: DayOfWeek[];
timezone: string;
}
/**
* Working hours for a specific day
*/
export interface WorkingHours {
dayOfWeek: DayOfWeek;
start: string;
end: string;
isWorkingDay: boolean;
breaks?: TimeRange[];
}
/**
* Schedule configuration
*/
export interface ScheduleConfig {
businessHours: BusinessHours;
workingDays: WorkingHours[];
holidays: Date[];
timezone: string;
slotDuration: number;
bufferTime: number;
}
/**
* Time slot availability
*/
export interface TimeSlotAvailability {
start: Date;
end: Date;
isAvailable: boolean;
reason?: string;
conflicts?: string[];
}
/**
* Recurring schedule pattern
*/
export interface RecurringSchedule {
type: 'daily' | 'weekly' | 'monthly' | 'yearly';
interval: number;
startDate: Date;
endDate?: Date;
daysOfWeek?: DayOfWeek[];
dayOfMonth?: number;
monthOfYear?: MonthOfYear;
}
/**
* Appointment duration in minutes
*/
export type AppointmentDuration = number;
/**
* Appointment time slot
*/
export interface AppointmentTimeSlot {
start: Date;
end: Date;
duration: AppointmentDuration;
isAvailable: boolean;
isBooked: boolean;
appointmentId?: string;
}
/**
* Appointment scheduling window
*/
export interface AppointmentWindow {
start: Date;
end: Date;
availableSlots: AppointmentTimeSlot[];
totalSlots: number;
availableSlotsCount: number;
}
/**
* Appointment scheduling preferences
*/
export interface AppointmentPreferences {
preferredDays: DayOfWeek[];
preferredTimes: TimeRange[];
preferredDuration: AppointmentDuration;
maxAdvanceBooking: number;
minAdvanceBooking: number;
allowSameDayBooking: boolean;
allowEmergencyBooking: boolean;
}
/**
* Medical record timestamp
*/
export interface MedicalRecordTimestamp {
createdAt: Date;
updatedAt: Date;
recordedAt: Date;
effectiveDate: Date;
expiryDate?: Date;
}
/**
* Treatment period
*/
export interface TreatmentPeriod {
startDate: Date;
endDate?: Date;
duration: number;
isActive: boolean;
isCompleted: boolean;
}
/**
* Medication schedule
*/
export interface MedicationSchedule {
startDate: Date;
endDate?: Date;
frequency: MedicationFrequency;
timesPerDay: number;
specificTimes?: string[];
daysOfWeek?: DayOfWeek[];
isActive: boolean;
}
/**
* Medication frequency types
*/
export declare enum MedicationFrequency {
DAILY = "daily",
TWICE_DAILY = "twice_daily",
THREE_TIMES_DAILY = "three_times_daily",
FOUR_TIMES_DAILY = "four_times_daily",
WEEKLY = "weekly",
BIWEEKLY = "biweekly",
MONTHLY = "monthly",
AS_NEEDED = "as_needed",
CUSTOM = "custom"
}
/**
* Follow-up schedule
*/
export interface FollowUpSchedule {
appointmentDate: Date;
reminderDate: Date;
frequency: FollowUpFrequency;
nextFollowUpDate?: Date;
isCompleted: boolean;
}
/**
* Follow-up frequency types
*/
export declare enum FollowUpFrequency {
IMMEDIATE = "immediate",
ONE_WEEK = "one_week",
TWO_WEEKS = "two_weeks",
ONE_MONTH = "one_month",
THREE_MONTHS = "three_months",
SIX_MONTHS = "six_months",
ONE_YEAR = "one_year",
CUSTOM = "custom"
}
/**
* Age calculation result
*/
export interface AgeCalculation {
years: number;
months: number;
days: number;
totalDays: number;
totalMonths: number;
isMinor: boolean;
ageGroup: AgeGroup;
}
/**
* Age group classification
*/
export declare enum AgeGroup {
INFANT = "infant",// 0-2 years
TODDLER = "toddler",// 2-5 years
CHILD = "child",// 6-12 years
TEEN = "teen",// 13-17 years
YOUNG_ADULT = "young_adult",// 18-25 years
ADULT = "adult",// 26-64 years
SENIOR = "senior",// 65+ years
ELDERLY = "elderly"
}
/**
* Duration calculation
*/
export interface DurationCalculation {
totalMinutes: number;
totalHours: number;
totalDays: number;
hours: number;
minutes: number;
seconds: number;
formatted: string;
}
/**
* Pregnancy duration
*/
export interface PregnancyDuration {
weeks: number;
days: number;
trimester: PregnancyTrimester;
estimatedDueDate: Date;
lastMenstrualPeriod: Date;
}
/**
* Pregnancy trimester
*/
export declare enum PregnancyTrimester {
FIRST = "first",// 1-12 weeks
SECOND = "second",// 13-26 weeks
THIRD = "third"
}
/**
* Timezone information
*/
export interface TimezoneInfo {
name: string;
offset: number;
abbreviation: string;
isDST: boolean;
country: string;
}
/**
* Localized date format
*/
export interface LocalizedDateFormat {
locale: string;
format: string;
examples: {
short: string;
medium: string;
long: string;
full: string;
};
}
/**
* Date format preferences
*/
export interface DateFormatPreferences {
locale: string;
timezone: string;
dateFormat: string;
timeFormat: string;
datetimeFormat: string;
weekStartsOn: DayOfWeek;
}
/**
* Date comparison result
*/
export interface DateComparison {
isBefore: boolean;
isAfter: boolean;
isEqual: boolean;
difference: number;
differenceDays: number;
differenceMonths: number;
differenceYears: number;
}
/**
* Date validation result
*/
export interface DateValidation {
isValid: boolean;
isFuture: boolean;
isPast: boolean;
isToday: boolean;
isWeekend: boolean;
isHoliday: boolean;
age?: AgeCalculation;
errors?: string[];
}
/**
* Time validation result
*/
export interface TimeValidation {
isValid: boolean;
isBusinessHours: boolean;
isWorkingDay: boolean;
isAvailable: boolean;
conflicts?: string[];
errors?: string[];
}
/**
* Date range validation
*/
export interface DateRangeValidation {
isValid: boolean;
isOverlapping: boolean;
duration: DurationCalculation;
isWithinRange: boolean;
errors?: string[];
}
/**
* Type guard for ISO date string
*/
export declare function isISODateString(value: unknown): value is ISODateString;
/**
* Type guard for ISO datetime string
*/
export declare function isISODateTimeString(value: unknown): value is ISODateTimeString;
/**
* Type guard for date range
*/
export declare function isDateRange(value: unknown): value is DateRange;
/**
* Type guard for time range
*/
export declare function isTimeRange(value: unknown): value is TimeRange;
/**
* Type guard for business hours
*/
export declare function isBusinessHours(value: unknown): value is BusinessHours;
/**
* Type guard for appointment time slot
*/
export declare function isAppointmentTimeSlot(value: unknown): value is AppointmentTimeSlot;
/**
* Convert date to ISO string
*/
export declare function toISODateString(date: Date): ISODateString;
/**
* Convert date to ISO datetime string
*/
export declare function toISODateTimeString(date: Date): ISODateTimeString;
/**
* Parse ISO date string to Date
*/
export declare function parseISODateString(dateString: ISODateString): Date;
/**
* Parse ISO datetime string to Date
*/
export declare function parseISODateTimeString(dateTimeString: ISODateTimeString): Date;
/**
* Get current date as ISO string
*/
export declare function getCurrentISODateString(): ISODateString;
/**
* Get current datetime as ISO string
*/
export declare function getCurrentISODateTimeString(): ISODateTimeString;
/**
* Calculate age from birth date
*/
export declare function calculateAge(birthDate: Date): AgeCalculation;
/**
* Calculate duration between two dates
*/
export declare function calculateDuration(start: Date, end: Date): DurationCalculation;
/**
* Check if date is in business hours
*/
export declare function isInBusinessHours(date: Date, businessHours: BusinessHours): boolean;
/**
* Check if date is a working day
*/
export declare function isWorkingDay(date: Date, workingDays: WorkingHours[]): boolean;
//# sourceMappingURL=datetime.d.ts.map