import { type OpenmrsResource } from '@openmrs/esm-framework'; import { type amPm } from '../helpers'; export enum SearchTypes { BASIC = 'basic', ADVANCED = 'advanced', SEARCH_RESULTS = 'search_results', SCHEDULED_VISITS = 'scheduled-visits', } export interface AppointmentLocation { uuid: string; name: string; display?: string; description?: string; locationId?: number; } // note that the API supports two other statuses that we are not currently supporting: "Requested" and "WaitList" export enum AppointmentStatus { SCHEDULED = 'Scheduled', CANCELLED = 'Cancelled', MISSED = 'Missed', CHECKEDIN = 'CheckedIn', COMPLETED = 'Completed', } export interface AppointmentState { appointmentStateId: number; name?: string; description?: string; value?: string; } // Backend appointment states based on Java backend implementation export enum BackendAppointmentStates { NULL = 'NULL', // ID: 1 - Default state CONFIRMED = 'CONFIRMED', // ID: 2 - When appointment is assigned UPCOMING = 'UPCOMING', // ID: 3 - Future appointments (main scheduled state) WAITING = 'WAITING', // ID: 4 - Patient arrived/checked in IN_ADVANCE = 'IN_ADVANCE', // ID: 5 EXPIRED = 'EXPIRED', // ID: 6 - Missed appointments RETIRED = 'RETIRED', // ID: 7 - Cancelled appointments (voided) POSTPONED = 'POSTPONED', // ID: 8 ATTENDED = 'ATTENDED', // ID: 9 - Completed appointments } // Backend appointment state IDs for reference export enum BackendAppointmentStateIds { NULL = 1, CONFIRMED = 2, UPCOMING = 3, WAITING = 4, IN_ADVANCE = 5, EXPIRED = 6, RETIRED = 7, POSTPONED = 8, ATTENDED = 9, } export enum AppointmentKind { SCHEDULED = 'Scheduled', WALKIN = 'WalkIn', VIRTUAL = 'Virtual', } export interface PatientPerson { personId: number; uuid: string; gender: string; birthdate: number | string; age: number; names: Array; } // TODO: remove interface elements that aren't actually present on the Appointment object returned from the Appointment API export interface Appointment { appointmentKind?: AppointmentKind; appointmentState?: string | AppointmentState; appointmentNumber?: string; comments?: string; note?: string; endDateTime?: Date | number | any; location?: AppointmentLocation; patient: { identifier?: string; identifiers?: Array; name: string; uuid: string; age?: string | number; gender?: string; birthdate?: string | number; person?: PatientPerson; patientId?: number; }; provider?: OpenmrsResource; providers?: Array; recurring?: boolean; service?: AppointmentService; appointmentService?: AppointmentService; startDateTime?: string | any; dateAppointmentScheduled?: string | any; status?: AppointmentStatus | string; uuid: string; additionalInfo?: string | null; serviceTypes?: Array | null; voided?: boolean; extensions?: {}; teleconsultationLink?: string | null; appointmentId: string | number; appointmentDate: Date | number | string | any; attended?: boolean; voidReason?: string | null; voidedDate?: string | null; creator?: { uuid: string; username: string; person: PatientPerson; }; voidedBy?: any; createdDate?: number; reason?: { obsId: number; uuid: string; concept: { conceptId: number; uuid: string; display: string; name: string; }; value: { conceptId: number; uuid: string; display: string; name: string; }; obsDatetime: number; person: PatientPerson; }; nextVisitDate?: string | null; encounter?: any; } export interface AppointmentsFetchResponse { data: Array; } export interface AppointmentService { serviceId: number; appointmentServiceId: number; creatorName: string; description: string; durationMins?: number; endTime: string; initialAppointmentStatus: string; location?: OpenmrsResource; maxAppointmentsLimit: number | null; name: string; specialityUuid?: OpenmrsResource | {}; startTime: string; uuid: string; serviceTypes?: Array; color?: string; startTimeTimeFormat?: amPm; endTimeTimeFormat?: amPm; concept?: { uuid: string; display: string; }; } export interface ServiceTypes { duration: number; name: string; uuid: string; } export interface DashboardConfig { name: string; slot: string; title: string; } export interface Observation { uuid: string; concept: { uuid: string; display: string; conceptClass: { uuid: string; display: string; }; }; display: string; groupMembers: null | Array<{ uuid: string; concept: { uuid: string; display: string; }; value: { uuid: string; display: string; }; }>; value: any; obsDatetime: string; } export interface AppointmentPayload { patientUuid: string; serviceUuid: string; startDateTime: string; endDateTime?: string; locationUuid: string; reason: string; comments?: string; status?: string; uuid?: string; } export interface AppointmentCountMap { allAppointmentsCount: number; missedAppointmentsCount; appointmentDate: number; appointmentServiceUuid: string; } export interface AppointmentSummary { appointmentService: OpenmrsResource; appointmentCountMap: Record; } export interface Provider { uuid: string; display: string; comments?: string; response?: string; person: OpenmrsResource; name?: string; } export enum DurationPeriod { monthly, weekly, daily, } export interface Identifier { identifier: string; identifierName?: string; } export interface DailyAppointmentsCountByService { appointmentDate: string; services: Array<{ serviceName: string; serviceUuid: string; count: number; }>; } export interface RecurringPattern { type: 'DAY' | 'WEEK'; period: number; endDate: string; daysOfWeek?: Array; //'MONDAY' | 'TUESDAY' | 'TUESDAY' | 'WEDNESDAY' | 'THURSDAY' | 'FRIDAY' | 'SATURDAY' | 'SUNDAY'>; } export interface RecurringAppointmentsPayload { appointmentRequest: AppointmentPayload; recurringPattern: RecurringPattern; } export interface PatientDetails { dateOfBirth: string; }