emr-types
Version:
Comprehensive TypeScript Types Library for Electronic Medical Record (EMR) Applications - Domain-Driven Design with Zod Validation
381 lines • 12.5 kB
TypeScript
import { BaseDomainEvent } from '../../shared/events/BaseDomainEvent';
import { AppointmentId } from '../value-objects/AppointmentId';
import { TenantId } from '../../tenant/value-objects/TenantId';
import { UserId } from '../../user/value-objects/UserId';
import { Appointment } from '../entities/Appointment';
/**
* Base interface for all appointment domain events
*/
export interface AppointmentDomainEvent extends BaseDomainEvent {
appointmentId: AppointmentId;
tenantId: TenantId;
}
/**
* Event fired when a new appointment is scheduled
*/
export interface AppointmentScheduledEvent extends AppointmentDomainEvent {
eventType: 'AppointmentScheduled';
data: {
appointment: Appointment;
scheduledBy: UserId;
schedulingMethod: 'online' | 'phone' | 'in_person' | 'mobile_app' | 'referral';
source?: string;
previousAppointmentId?: AppointmentId;
};
}
/**
* Event fired when an appointment is confirmed
*/
export interface AppointmentConfirmedEvent extends AppointmentDomainEvent {
eventType: 'AppointmentConfirmed';
data: {
appointment: Appointment;
confirmedBy: UserId;
confirmationMethod: 'email' | 'sms' | 'phone' | 'in_person' | 'auto';
confirmationNotes?: string;
};
}
/**
* Event fired when a patient checks in for an appointment
*/
export interface AppointmentCheckedInEvent extends AppointmentDomainEvent {
eventType: 'AppointmentCheckedIn';
data: {
appointment: Appointment;
checkedInBy: UserId;
checkInTime: Date;
waitTime?: number;
location?: string;
notes?: string;
};
}
/**
* Event fired when an appointment starts
*/
export interface AppointmentStartedEvent extends AppointmentDomainEvent {
eventType: 'AppointmentStarted';
data: {
appointment: Appointment;
startedBy: UserId;
startTime: Date;
actualStartTime: Date;
delayReason?: string;
notes?: string;
};
}
/**
* Event fired when an appointment is completed
*/
export interface AppointmentCompletedEvent extends AppointmentDomainEvent {
eventType: 'AppointmentCompleted';
data: {
appointment: Appointment;
completedBy: UserId;
completionTime: Date;
actualDuration: number;
diagnosis?: string;
treatmentPlan?: string;
followUpRequired: boolean;
followUpDate?: Date;
notes?: string;
};
}
/**
* Event fired when an appointment is cancelled
*/
export interface AppointmentCancelledEvent extends AppointmentDomainEvent {
eventType: 'AppointmentCancelled';
data: {
appointment: Appointment;
cancelledBy: UserId;
cancellationTime: Date;
cancellationReason: string;
cancellationFee?: number;
refundAmount?: number;
rescheduleOffered: boolean;
rescheduleDate?: Date;
notes?: string;
};
}
/**
* Event fired when a patient is a no-show
*/
export interface AppointmentNoShowEvent extends AppointmentDomainEvent {
eventType: 'AppointmentNoShow';
data: {
appointment: Appointment;
recordedBy: UserId;
noShowTime: Date;
noShowReason?: string;
noShowFee?: number;
rescheduleOffered: boolean;
rescheduleDate?: Date;
notes?: string;
};
}
/**
* Event fired when an appointment is rescheduled
*/
export interface AppointmentRescheduledEvent extends AppointmentDomainEvent {
eventType: 'AppointmentRescheduled';
data: {
appointment: Appointment;
rescheduledBy: UserId;
originalDate: Date;
newDate: Date;
rescheduleReason: string;
rescheduleFee?: number;
approvalRequired: boolean;
approvedBy?: UserId;
approvalDate?: Date;
notes?: string;
};
}
/**
* Event fired when an appointment is put on hold
*/
export interface AppointmentOnHoldEvent extends AppointmentDomainEvent {
eventType: 'AppointmentOnHold';
data: {
appointment: Appointment;
putOnHoldBy: UserId;
holdTime: Date;
holdReason: string;
estimatedResumeTime?: Date;
notes?: string;
};
}
/**
* Event fired when an appointment reminder is sent
*/
export interface AppointmentReminderSentEvent extends AppointmentDomainEvent {
eventType: 'AppointmentReminderSent';
data: {
appointment: Appointment;
reminderSentBy: UserId;
reminderTime: Date;
reminderMethod: 'email' | 'sms' | 'phone' | 'push_notification' | 'mail';
reminderAdvanceTime: number;
recipientType: 'patient' | 'guardian' | 'doctor' | 'nurse';
reminderMessage?: string;
deliveryStatus: 'sent' | 'delivered' | 'failed';
notes?: string;
};
}
/**
* Event fired when appointment insurance information is updated
*/
export interface AppointmentInsuranceUpdatedEvent extends AppointmentDomainEvent {
eventType: 'AppointmentInsuranceUpdated';
data: {
appointment: Appointment;
updatedBy: UserId;
oldInsurance?: {
providerName: string;
policyNumber: string;
};
newInsurance: {
providerName: string;
policyNumber: string;
effectiveDate: Date;
};
reason?: string;
preAuthorizationRequired: boolean;
preAuthorizationNumber?: string;
};
}
/**
* Event fired when appointment billing information is updated
*/
export interface AppointmentBillingUpdatedEvent extends AppointmentDomainEvent {
eventType: 'AppointmentBillingUpdated';
data: {
appointment: Appointment;
updatedBy: UserId;
billingChanges: {
field: string;
oldValue?: unknown;
newValue: unknown;
}[];
paymentMethodUpdated?: boolean;
billingStatusChanged?: boolean;
reason?: string;
};
}
/**
* Event fired when appointment quality metrics are recorded
*/
export interface AppointmentQualityMetricsRecordedEvent extends AppointmentDomainEvent {
eventType: 'AppointmentQualityMetricsRecorded';
data: {
appointment: Appointment;
recordedBy: UserId;
qualityMetrics: {
waitTime: number;
consultationTime: number;
patientArrivalTime: Date;
doctorArrivalTime: Date;
treatmentEffectiveness: string;
patientCompliance: string;
followUpCompliance: boolean;
readmissionRisk: string;
};
recordingDate: Date;
notes?: string;
};
}
/**
* Event fired when patient satisfaction survey is completed
*/
export interface AppointmentSatisfactionSurveyCompletedEvent extends AppointmentDomainEvent {
eventType: 'AppointmentSatisfactionSurveyCompleted';
data: {
appointment: Appointment;
surveyCompletedBy: UserId;
surveyDate: Date;
satisfactionScores: {
overallRating: number;
waitTimeRating: number;
doctorRating: number;
nurseRating: number;
facilityRating: number;
communicationRating: number;
treatmentEffectivenessRating: number;
};
wouldRecommend: boolean;
comments?: string;
followUpRequired: boolean;
};
}
/**
* Event fired when appointment location is changed
*/
export interface AppointmentLocationChangedEvent extends AppointmentDomainEvent {
eventType: 'AppointmentLocationChanged';
data: {
appointment: Appointment;
changedBy: UserId;
oldLocation: {
name: string;
type: string;
address: string;
};
newLocation: {
name: string;
type: string;
address: string;
};
changeReason: string;
changeDate: Date;
notes?: string;
};
}
/**
* Event fired when appointment participants are updated
*/
export interface AppointmentParticipantsUpdatedEvent extends AppointmentDomainEvent {
eventType: 'AppointmentParticipantsUpdated';
data: {
appointment: Appointment;
updatedBy: UserId;
participantChanges: {
participantType: 'doctor' | 'nurse' | 'specialist';
oldParticipantId?: UserId;
newParticipantId: UserId;
}[];
reason?: string;
notes?: string;
};
}
/**
* Event fired when appointment medical information is updated
*/
export interface AppointmentMedicalInfoUpdatedEvent extends AppointmentDomainEvent {
eventType: 'AppointmentMedicalInfoUpdated';
data: {
appointment: Appointment;
updatedBy: UserId;
medicalInfoChanges: {
field: string;
oldValue?: unknown;
newValue: unknown;
}[];
diagnosisUpdated?: boolean;
treatmentPlanUpdated?: boolean;
followUpRequiredChanged?: boolean;
reason?: string;
notes?: string;
};
}
/**
* Event fired when appointment reminder settings are updated
*/
export interface AppointmentReminderSettingsUpdatedEvent extends AppointmentDomainEvent {
eventType: 'AppointmentReminderSettingsUpdated';
data: {
appointment: Appointment;
updatedBy: UserId;
reminderSettingChanges: {
setting: string;
oldValue: unknown;
newValue: unknown;
}[];
reason?: string;
notes?: string;
};
}
/**
* Event fired when appointment cancellation policy is updated
*/
export interface AppointmentCancellationPolicyUpdatedEvent extends AppointmentDomainEvent {
eventType: 'AppointmentCancellationPolicyUpdated';
data: {
appointment: Appointment;
updatedBy: UserId;
policyChanges: {
field: string;
oldValue: unknown;
newValue: unknown;
}[];
reason?: string;
notes?: string;
};
}
/**
* Union type for all appointment domain events
*/
export type AppointmentEvent = AppointmentScheduledEvent | AppointmentConfirmedEvent | AppointmentCheckedInEvent | AppointmentStartedEvent | AppointmentCompletedEvent | AppointmentCancelledEvent | AppointmentNoShowEvent | AppointmentRescheduledEvent | AppointmentOnHoldEvent | AppointmentReminderSentEvent | AppointmentInsuranceUpdatedEvent | AppointmentBillingUpdatedEvent | AppointmentQualityMetricsRecordedEvent | AppointmentSatisfactionSurveyCompletedEvent | AppointmentLocationChangedEvent | AppointmentParticipantsUpdatedEvent | AppointmentMedicalInfoUpdatedEvent | AppointmentReminderSettingsUpdatedEvent | AppointmentCancellationPolicyUpdatedEvent;
/**
* Factory functions for creating appointment domain events
*/
export declare const AppointmentEventFactory: {
/**
* Create an AppointmentScheduledEvent
*/
createAppointmentScheduledEvent(appointment: Appointment, scheduledBy: UserId, schedulingMethod: "online" | "phone" | "in_person" | "mobile_app" | "referral", source?: string, previousAppointmentId?: AppointmentId): AppointmentScheduledEvent;
/**
* Create an AppointmentConfirmedEvent
*/
createAppointmentConfirmedEvent(appointment: Appointment, confirmedBy: UserId, confirmationMethod: "email" | "sms" | "phone" | "in_person" | "auto", confirmationNotes?: string): AppointmentConfirmedEvent;
/**
* Create an AppointmentCancelledEvent
*/
createAppointmentCancelledEvent(appointment: Appointment, cancelledBy: UserId, cancellationReason: string, cancellationFee?: number, refundAmount?: number, rescheduleOffered?: boolean, rescheduleDate?: Date, notes?: string): AppointmentCancelledEvent;
};
/**
* Type guard to check if an event is an AppointmentScheduledEvent
*/
export declare function isAppointmentScheduledEvent(event: AppointmentEvent): event is AppointmentScheduledEvent;
/**
* Type guard to check if an event is an AppointmentConfirmedEvent
*/
export declare function isAppointmentConfirmedEvent(event: AppointmentEvent): event is AppointmentConfirmedEvent;
/**
* Type guard to check if an event is an AppointmentCancelledEvent
*/
export declare function isAppointmentCancelledEvent(event: AppointmentEvent): event is AppointmentCancelledEvent;
/**
* Type guard to check if an event is an AppointmentDomainEvent
*/
export declare function isAppointmentDomainEvent(event: unknown): event is AppointmentDomainEvent;
//# sourceMappingURL=AppointmentDomainEvent.d.ts.map