@blackcode_sa/metaestetics-api 1.6.3 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/index.d.mts +439 -25
- package/dist/admin/index.d.ts +439 -25
- package/dist/admin/index.js +36107 -2493
- package/dist/admin/index.mjs +36093 -2461
- package/dist/backoffice/index.d.mts +254 -1
- package/dist/backoffice/index.d.ts +254 -1
- package/dist/backoffice/index.js +86 -12
- package/dist/backoffice/index.mjs +86 -13
- package/dist/index.d.mts +1434 -621
- package/dist/index.d.ts +1434 -621
- package/dist/index.js +1381 -970
- package/dist/index.mjs +1433 -1016
- package/package.json +1 -1
- package/src/admin/aggregation/appointment/appointment.aggregation.service.ts +321 -0
- package/src/admin/booking/booking.admin.ts +376 -3
- package/src/admin/index.ts +15 -1
- package/src/admin/notifications/notifications.admin.ts +1 -1
- package/src/admin/requirements/README.md +128 -0
- package/src/admin/requirements/patient-requirements.admin.service.ts +482 -0
- package/src/backoffice/types/product.types.ts +2 -0
- package/src/index.ts +16 -1
- package/src/services/appointment/appointment.service.ts +386 -250
- package/src/services/clinic/clinic-admin.service.ts +3 -0
- package/src/services/clinic/clinic-group.service.ts +8 -0
- package/src/services/documentation-templates/documentation-template.service.ts +24 -16
- package/src/services/documentation-templates/filled-document.service.ts +253 -136
- package/src/services/patient/patientRequirements.service.ts +285 -0
- package/src/services/procedure/procedure.service.ts +1 -0
- package/src/types/appointment/index.ts +136 -11
- package/src/types/documentation-templates/index.ts +34 -2
- package/src/types/notifications/README.md +77 -0
- package/src/types/notifications/index.ts +154 -27
- package/src/types/patient/patient-requirements.ts +81 -0
- package/src/types/procedure/index.ts +7 -0
- package/src/validations/appointment.schema.ts +298 -62
- package/src/validations/documentation-templates/template.schema.ts +55 -0
- package/src/validations/documentation-templates.schema.ts +9 -14
- package/src/validations/notification.schema.ts +3 -3
- package/src/validations/patient/patient-requirements.schema.ts +75 -0
- package/src/validations/procedure.schema.ts +3 -0
package/dist/admin/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ declare enum DocumentElementType {
|
|
|
17
17
|
TEXT_INPUT = "text_input",
|
|
18
18
|
DATE_PICKER = "date_picker",
|
|
19
19
|
SIGNATURE = "signature",
|
|
20
|
+
DITIGAL_SIGNATURE = "digital_signature",
|
|
20
21
|
FILE_UPLOAD = "file_upload"
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
@@ -164,9 +165,23 @@ interface DocumentTemplate {
|
|
|
164
165
|
createdBy: string;
|
|
165
166
|
elements: DocumentElement[];
|
|
166
167
|
tags?: string[];
|
|
168
|
+
isUserForm?: boolean;
|
|
169
|
+
isRequired?: boolean;
|
|
170
|
+
sortingOrder?: number;
|
|
167
171
|
version: number;
|
|
168
172
|
isActive: boolean;
|
|
169
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Enum for filled document status
|
|
176
|
+
*/
|
|
177
|
+
declare enum FilledDocumentStatus {
|
|
178
|
+
DRAFT = "draft",
|
|
179
|
+
SKIPPED = "skipped",
|
|
180
|
+
PENDING = "pending",
|
|
181
|
+
COMPLETED = "completed",// When doctor or patient completes the form
|
|
182
|
+
SIGNED = "signed",// Only used for user forms
|
|
183
|
+
REJECTED = "rejected"
|
|
184
|
+
}
|
|
170
185
|
|
|
171
186
|
/**
|
|
172
187
|
* Nivoi sertifikacije medicinskog osoblja, poređani od najnižeg do najvišeg
|
|
@@ -507,7 +522,9 @@ interface Product {
|
|
|
507
522
|
id?: string;
|
|
508
523
|
name: string;
|
|
509
524
|
brandId: string;
|
|
525
|
+
brandName: string;
|
|
510
526
|
technologyId: string;
|
|
527
|
+
technologyName: string;
|
|
511
528
|
createdAt: Date;
|
|
512
529
|
updatedAt: Date;
|
|
513
530
|
isActive: boolean;
|
|
@@ -545,6 +562,8 @@ interface Procedure {
|
|
|
545
562
|
id: string;
|
|
546
563
|
/** Name of the procedure */
|
|
547
564
|
name: string;
|
|
565
|
+
/** Photos of the procedure */
|
|
566
|
+
photos?: string[];
|
|
548
567
|
/** Detailed description of the procedure */
|
|
549
568
|
description: string;
|
|
550
569
|
/** Family of procedures this belongs to (aesthetics/surgery) */
|
|
@@ -569,6 +588,8 @@ interface Procedure {
|
|
|
569
588
|
blockingConditions: BlockingCondition[];
|
|
570
589
|
/** Treatment benefits of this procedure */
|
|
571
590
|
treatmentBenefits: TreatmentBenefit[];
|
|
591
|
+
/** Contraindications of this procedure */
|
|
592
|
+
contraindications: Contraindication[];
|
|
572
593
|
/** Pre-procedure requirements */
|
|
573
594
|
preRequirements: Requirement[];
|
|
574
595
|
/** Post-procedure requirements */
|
|
@@ -1118,10 +1139,19 @@ declare enum UserRole {
|
|
|
1118
1139
|
* Enumeracija koja definiše sve moguće tipove notifikacija
|
|
1119
1140
|
*/
|
|
1120
1141
|
declare enum NotificationType {
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1142
|
+
APPOINTMENT_REMINDER = "appointmentReminder",// For upcoming appointments
|
|
1143
|
+
APPOINTMENT_STATUS_CHANGE = "appointmentStatusChange",// Generic for status changes like confirmed, checked-in etc.
|
|
1144
|
+
APPOINTMENT_RESCHEDULED_PROPOSAL = "appointmentRescheduledProposal",// When clinic proposes a new time
|
|
1145
|
+
APPOINTMENT_CANCELLED = "appointmentCancelled",// When an appointment is cancelled
|
|
1146
|
+
REQUIREMENT_INSTRUCTION_DUE = "requirementInstructionDue",// For specific pre/post care instructions
|
|
1147
|
+
FORM_REMINDER = "formReminder",// Reminds user to fill a specific form
|
|
1148
|
+
FORM_SUBMISSION_CONFIRMATION = "formSubmissionConfirmation",// Confirms form was submitted
|
|
1149
|
+
REVIEW_REQUEST = "reviewRequest",// Request for patient review post-appointment
|
|
1150
|
+
PAYMENT_DUE = "paymentDue",
|
|
1151
|
+
PAYMENT_CONFIRMATION = "paymentConfirmation",
|
|
1152
|
+
PAYMENT_FAILED = "paymentFailed",
|
|
1153
|
+
GENERAL_MESSAGE = "generalMessage",// For general announcements or direct messages
|
|
1154
|
+
ACCOUNT_NOTIFICATION = "accountNotification"
|
|
1125
1155
|
}
|
|
1126
1156
|
declare const NOTIFICATIONS_COLLECTION = "notifications";
|
|
1127
1157
|
/**
|
|
@@ -1156,14 +1186,22 @@ interface BaseNotification {
|
|
|
1156
1186
|
isRead: boolean;
|
|
1157
1187
|
/** Uloga korisnika kome je namenjena notifikacija */
|
|
1158
1188
|
userRole: UserRole;
|
|
1189
|
+
appointmentId?: string;
|
|
1190
|
+
patientRequirementInstanceId?: string;
|
|
1191
|
+
instructionId?: string;
|
|
1192
|
+
formId?: string;
|
|
1193
|
+
originalRequirementId?: string;
|
|
1194
|
+
transactionId?: string;
|
|
1159
1195
|
}
|
|
1160
1196
|
/**
|
|
1161
1197
|
* Status notifikacije
|
|
1162
1198
|
*/
|
|
1163
1199
|
declare enum NotificationStatus {
|
|
1164
1200
|
PENDING = "pending",
|
|
1201
|
+
PROCESSING = "processing",
|
|
1165
1202
|
SENT = "sent",
|
|
1166
1203
|
FAILED = "failed",
|
|
1204
|
+
DELIVERED = "delivered",
|
|
1167
1205
|
CANCELLED = "cancelled",
|
|
1168
1206
|
PARTIAL_SUCCESS = "partialSuccess"
|
|
1169
1207
|
}
|
|
@@ -1171,7 +1209,7 @@ declare enum NotificationStatus {
|
|
|
1171
1209
|
* Notifikacija za pre-requirement
|
|
1172
1210
|
*/
|
|
1173
1211
|
interface PreRequirementNotification extends BaseNotification {
|
|
1174
|
-
notificationType: NotificationType.
|
|
1212
|
+
notificationType: NotificationType.REQUIREMENT_INSTRUCTION_DUE;
|
|
1175
1213
|
/** ID tretmana za koji je vezan pre-requirement */
|
|
1176
1214
|
treatmentId: string;
|
|
1177
1215
|
/** Lista pre-requirements koji treba da se ispune */
|
|
@@ -1183,7 +1221,7 @@ interface PreRequirementNotification extends BaseNotification {
|
|
|
1183
1221
|
* Notifikacija za post-requirement
|
|
1184
1222
|
*/
|
|
1185
1223
|
interface PostRequirementNotification extends BaseNotification {
|
|
1186
|
-
notificationType: NotificationType.
|
|
1224
|
+
notificationType: NotificationType.REQUIREMENT_INSTRUCTION_DUE;
|
|
1187
1225
|
/** ID tretmana za koji je vezan post-requirement */
|
|
1188
1226
|
treatmentId: string;
|
|
1189
1227
|
/** Lista post-requirements koji treba da se ispune */
|
|
@@ -1192,37 +1230,108 @@ interface PostRequirementNotification extends BaseNotification {
|
|
|
1192
1230
|
deadline: Timestamp;
|
|
1193
1231
|
}
|
|
1194
1232
|
/**
|
|
1195
|
-
*
|
|
1233
|
+
* Notification for a specific instruction from a PatientRequirementInstance.
|
|
1234
|
+
* Example: "Do not eat 2 hours before your [Procedure Name] appointment."
|
|
1235
|
+
*/
|
|
1236
|
+
interface RequirementInstructionDueNotification extends BaseNotification {
|
|
1237
|
+
notificationType: NotificationType.REQUIREMENT_INSTRUCTION_DUE;
|
|
1238
|
+
appointmentId: string;
|
|
1239
|
+
patientRequirementInstanceId: string;
|
|
1240
|
+
instructionId: string;
|
|
1241
|
+
}
|
|
1242
|
+
/**
|
|
1243
|
+
* Notification reminding about an upcoming appointment.
|
|
1244
|
+
* Example: "Reminder: Your appointment for [Procedure Name] is at [Time] today."
|
|
1196
1245
|
*/
|
|
1197
1246
|
interface AppointmentReminderNotification extends BaseNotification {
|
|
1198
1247
|
notificationType: NotificationType.APPOINTMENT_REMINDER;
|
|
1199
|
-
/** ID zakazanog termina */
|
|
1200
1248
|
appointmentId: string;
|
|
1201
|
-
/** Vreme termina */
|
|
1202
1249
|
appointmentTime: Timestamp;
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1250
|
+
procedureName?: string;
|
|
1251
|
+
practitionerName?: string;
|
|
1252
|
+
clinicName?: string;
|
|
1253
|
+
}
|
|
1254
|
+
/**
|
|
1255
|
+
* Notification about a change in appointment status (e.g., confirmed, checked-in).
|
|
1256
|
+
* Excludes cancellations and reschedule proposals, which have their own types.
|
|
1257
|
+
* Example: "Your appointment for [Procedure Name] has been Confirmed."
|
|
1258
|
+
*/
|
|
1259
|
+
interface AppointmentStatusChangeNotification extends BaseNotification {
|
|
1260
|
+
notificationType: NotificationType.APPOINTMENT_STATUS_CHANGE;
|
|
1261
|
+
appointmentId: string;
|
|
1262
|
+
newStatus: string;
|
|
1263
|
+
previousStatus?: string;
|
|
1264
|
+
procedureName?: string;
|
|
1207
1265
|
}
|
|
1208
1266
|
/**
|
|
1209
|
-
*
|
|
1267
|
+
* Notification informing the patient that the clinic has proposed a new time for their appointment.
|
|
1268
|
+
* Example: "Action Required: [Clinic Name] has proposed a new time for your [Procedure Name] appointment."
|
|
1210
1269
|
*/
|
|
1211
|
-
interface
|
|
1212
|
-
notificationType: NotificationType.
|
|
1213
|
-
|
|
1270
|
+
interface AppointmentRescheduledProposalNotification extends BaseNotification {
|
|
1271
|
+
notificationType: NotificationType.APPOINTMENT_RESCHEDULED_PROPOSAL;
|
|
1272
|
+
appointmentId: string;
|
|
1273
|
+
newProposedStartTime: Timestamp;
|
|
1274
|
+
newProposedEndTime: Timestamp;
|
|
1275
|
+
procedureName?: string;
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1278
|
+
* Notification informing about a cancelled appointment.
|
|
1279
|
+
* Example: "Your appointment for [Procedure Name] on [Date] has been cancelled."
|
|
1280
|
+
*/
|
|
1281
|
+
interface AppointmentCancelledNotification extends BaseNotification {
|
|
1282
|
+
notificationType: NotificationType.APPOINTMENT_CANCELLED;
|
|
1214
1283
|
appointmentId: string;
|
|
1215
|
-
/** Novi status termina */
|
|
1216
|
-
appointmentStatus: string;
|
|
1217
|
-
/** Prethodni status termina */
|
|
1218
|
-
previousStatus: string;
|
|
1219
|
-
/** Razlog promene (opciono) */
|
|
1220
1284
|
reason?: string;
|
|
1285
|
+
cancelledByRole?: UserRole;
|
|
1286
|
+
procedureName?: string;
|
|
1287
|
+
}
|
|
1288
|
+
/**
|
|
1289
|
+
* Notification reminding a user to fill a specific form.
|
|
1290
|
+
* Example: "Reminder: Please complete the '[Form Name]' form for your upcoming appointment."
|
|
1291
|
+
*/
|
|
1292
|
+
interface FormReminderNotification extends BaseNotification {
|
|
1293
|
+
notificationType: NotificationType.FORM_REMINDER;
|
|
1294
|
+
appointmentId: string;
|
|
1295
|
+
formId: string;
|
|
1296
|
+
formName: string;
|
|
1297
|
+
formDeadline?: Timestamp;
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* Notification confirming a form submission.
|
|
1301
|
+
* Example: "Thank you! Your '[Form Name]' form has been submitted successfully."
|
|
1302
|
+
*/
|
|
1303
|
+
interface FormSubmissionConfirmationNotification extends BaseNotification {
|
|
1304
|
+
notificationType: NotificationType.FORM_SUBMISSION_CONFIRMATION;
|
|
1305
|
+
appointmentId?: string;
|
|
1306
|
+
formId: string;
|
|
1307
|
+
formName: string;
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Notification requesting a patient to leave a review after an appointment.
|
|
1311
|
+
* Example: "Hope you had a great experience! Would you like to share your feedback for your visit on [Date]?"
|
|
1312
|
+
*/
|
|
1313
|
+
interface ReviewRequestNotification extends BaseNotification {
|
|
1314
|
+
notificationType: NotificationType.REVIEW_REQUEST;
|
|
1315
|
+
appointmentId: string;
|
|
1316
|
+
practitionerName?: string;
|
|
1317
|
+
procedureName?: string;
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Generic notification for direct messages or announcements.
|
|
1321
|
+
*/
|
|
1322
|
+
interface GeneralMessageNotification extends BaseNotification {
|
|
1323
|
+
notificationType: NotificationType.GENERAL_MESSAGE;
|
|
1324
|
+
}
|
|
1325
|
+
interface PaymentConfirmationNotification extends BaseNotification {
|
|
1326
|
+
notificationType: NotificationType.PAYMENT_CONFIRMATION;
|
|
1327
|
+
transactionId: string;
|
|
1328
|
+
appointmentId?: string;
|
|
1329
|
+
amount: string;
|
|
1221
1330
|
}
|
|
1222
1331
|
/**
|
|
1223
1332
|
* Unija svih tipova notifikacija
|
|
1224
1333
|
*/
|
|
1225
|
-
type Notification = PreRequirementNotification | PostRequirementNotification | AppointmentReminderNotification |
|
|
1334
|
+
type Notification = PreRequirementNotification | PostRequirementNotification | RequirementInstructionDueNotification | AppointmentReminderNotification | AppointmentStatusChangeNotification | AppointmentRescheduledProposalNotification | AppointmentCancelledNotification | FormReminderNotification | FormSubmissionConfirmationNotification | ReviewRequestNotification | GeneralMessageNotification | PaymentConfirmationNotification;
|
|
1226
1335
|
|
|
1227
1336
|
declare class NotificationsAdmin {
|
|
1228
1337
|
private expo;
|
|
@@ -1243,7 +1352,7 @@ declare class NotificationsAdmin {
|
|
|
1243
1352
|
/**
|
|
1244
1353
|
* Ažurira status notifikacije
|
|
1245
1354
|
*/
|
|
1246
|
-
|
|
1355
|
+
updateNotificationStatus(notificationId: string, status: NotificationStatus, error?: string): Promise<void>;
|
|
1247
1356
|
/**
|
|
1248
1357
|
* Šalje notifikaciju kroz Expo servis sa boljim error handlingom
|
|
1249
1358
|
*/
|
|
@@ -1630,6 +1739,186 @@ declare class PractitionerInviteMailingService extends BaseMailingService {
|
|
|
1630
1739
|
}): Promise<void>;
|
|
1631
1740
|
}
|
|
1632
1741
|
|
|
1742
|
+
/**
|
|
1743
|
+
* Enum defining the possible statuses of an appointment.
|
|
1744
|
+
*/
|
|
1745
|
+
declare enum AppointmentStatus {
|
|
1746
|
+
PENDING = "pending",// Initial state after booking, before confirmation (if applicable)
|
|
1747
|
+
CONFIRMED = "confirmed",// Confirmed by clinic/practitioner
|
|
1748
|
+
CHECKED_IN = "checked_in",// Patient has arrived
|
|
1749
|
+
IN_PROGRESS = "in_progress",// Procedure has started
|
|
1750
|
+
COMPLETED = "completed",// Procedure finished successfully
|
|
1751
|
+
CANCELED_PATIENT = "canceled_patient",// Canceled by the patient
|
|
1752
|
+
CANCELED_PATIENT_RESCHEDULED = "canceled_patient_rescheduled",// Canceled by the patient and rescheduled by the clinic
|
|
1753
|
+
CANCELED_CLINIC = "canceled_clinic",// Canceled by the clinic/practitioner
|
|
1754
|
+
NO_SHOW = "no_show",// Patient did not attend
|
|
1755
|
+
RESCHEDULED_BY_CLINIC = "rescheduled_by_clinic"
|
|
1756
|
+
}
|
|
1757
|
+
/**
|
|
1758
|
+
* Enum defining the payment status of an appointment.
|
|
1759
|
+
*/
|
|
1760
|
+
declare enum PaymentStatus {
|
|
1761
|
+
UNPAID = "unpaid",
|
|
1762
|
+
PAID = "paid",
|
|
1763
|
+
PARTIALLY_PAID = "partially_paid",
|
|
1764
|
+
REFUNDED = "refunded",
|
|
1765
|
+
NOT_APPLICABLE = "not_applicable"
|
|
1766
|
+
}
|
|
1767
|
+
/**
|
|
1768
|
+
* Enum for different types of media that can be attached to an appointment.
|
|
1769
|
+
*/
|
|
1770
|
+
declare enum MediaType {
|
|
1771
|
+
BEFORE_PHOTO = "before_photo",
|
|
1772
|
+
AFTER_PHOTO = "after_photo",
|
|
1773
|
+
CONSENT_SCAN = "consent_scan",
|
|
1774
|
+
OTHER_DOCUMENT = "other_document"
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* Interface to describe a media file linked to an appointment.
|
|
1778
|
+
*/
|
|
1779
|
+
interface AppointmentMediaItem {
|
|
1780
|
+
id: string;
|
|
1781
|
+
type: MediaType;
|
|
1782
|
+
url: string;
|
|
1783
|
+
fileName?: string;
|
|
1784
|
+
uploadedAt: Timestamp;
|
|
1785
|
+
uploadedBy: string;
|
|
1786
|
+
description?: string;
|
|
1787
|
+
}
|
|
1788
|
+
/**
|
|
1789
|
+
* Interface for procedure-specific information
|
|
1790
|
+
*/
|
|
1791
|
+
interface ProcedureExtendedInfo {
|
|
1792
|
+
id: string;
|
|
1793
|
+
name: string;
|
|
1794
|
+
description: string;
|
|
1795
|
+
cost: number;
|
|
1796
|
+
duration: number;
|
|
1797
|
+
procedureFamily: ProcedureFamily;
|
|
1798
|
+
procedureCategoryId: string;
|
|
1799
|
+
procedureCategoryName: string;
|
|
1800
|
+
procedureSubCategoryId: string;
|
|
1801
|
+
procedureSubCategoryName: string;
|
|
1802
|
+
procedureTechnologyId: string;
|
|
1803
|
+
procedureTechnologyName: string;
|
|
1804
|
+
procedureProductBrandId: string;
|
|
1805
|
+
procedureProductBrandName: string;
|
|
1806
|
+
procedureProductId: string;
|
|
1807
|
+
procedureProductName: string;
|
|
1808
|
+
}
|
|
1809
|
+
/**
|
|
1810
|
+
* Interface to describe a filled form linked to an appointment.
|
|
1811
|
+
*/
|
|
1812
|
+
interface LinkedFormInfo {
|
|
1813
|
+
formId: string;
|
|
1814
|
+
templateId: string;
|
|
1815
|
+
templateVersion: number;
|
|
1816
|
+
title: string;
|
|
1817
|
+
isUserForm: boolean;
|
|
1818
|
+
status: FilledDocumentStatus;
|
|
1819
|
+
path: string;
|
|
1820
|
+
submittedAt?: Timestamp;
|
|
1821
|
+
completedAt?: Timestamp;
|
|
1822
|
+
}
|
|
1823
|
+
/**
|
|
1824
|
+
* Interface for summarized patient review information linked to an appointment.
|
|
1825
|
+
*/
|
|
1826
|
+
interface PatientReviewInfo {
|
|
1827
|
+
reviewId: string;
|
|
1828
|
+
rating: number;
|
|
1829
|
+
comment?: string;
|
|
1830
|
+
reviewedAt: Timestamp;
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* Represents a booked appointment, aggregating key information and relevant procedure rules.
|
|
1834
|
+
*/
|
|
1835
|
+
interface Appointment {
|
|
1836
|
+
/** Unique identifier for the appointment */
|
|
1837
|
+
id: string;
|
|
1838
|
+
/** Reference to the associated CalendarEvent */
|
|
1839
|
+
calendarEventId: string;
|
|
1840
|
+
/** ID of the clinic branch */
|
|
1841
|
+
clinicBranchId: string;
|
|
1842
|
+
/** Aggregated clinic information (snapshot) */
|
|
1843
|
+
clinicInfo: ClinicInfo;
|
|
1844
|
+
/** ID of the practitioner */
|
|
1845
|
+
practitionerId: string;
|
|
1846
|
+
/** Aggregated practitioner information (snapshot) */
|
|
1847
|
+
practitionerInfo: PractitionerProfileInfo;
|
|
1848
|
+
/** ID of the patient */
|
|
1849
|
+
patientId: string;
|
|
1850
|
+
/** Aggregated patient information (snapshot) */
|
|
1851
|
+
patientInfo: PatientProfileInfo;
|
|
1852
|
+
/** ID of the procedure */
|
|
1853
|
+
procedureId: string;
|
|
1854
|
+
/** Aggregated procedure information including product/brand (snapshot) */
|
|
1855
|
+
procedureInfo: ProcedureSummaryInfo;
|
|
1856
|
+
/** Extended procedure information */
|
|
1857
|
+
procedureExtendedInfo: ProcedureExtendedInfo;
|
|
1858
|
+
/** Status of the appointment */
|
|
1859
|
+
status: AppointmentStatus;
|
|
1860
|
+
/** Timestamps */
|
|
1861
|
+
bookingTime: Timestamp;
|
|
1862
|
+
confirmationTime?: Timestamp | null;
|
|
1863
|
+
cancellationTime?: Timestamp | null;
|
|
1864
|
+
rescheduleTime?: Timestamp | null;
|
|
1865
|
+
appointmentStartTime: Timestamp;
|
|
1866
|
+
appointmentEndTime: Timestamp;
|
|
1867
|
+
procedureActualStartTime?: Timestamp | null;
|
|
1868
|
+
actualDurationMinutes?: number;
|
|
1869
|
+
/** Cancellation Details */
|
|
1870
|
+
cancellationReason?: string | null;
|
|
1871
|
+
canceledBy?: "patient" | "clinic" | "practitioner" | "system";
|
|
1872
|
+
/** Notes */
|
|
1873
|
+
internalNotes?: string | null;
|
|
1874
|
+
patientNotes?: string | null;
|
|
1875
|
+
/** Payment Details */
|
|
1876
|
+
cost: number;
|
|
1877
|
+
currency: Currency;
|
|
1878
|
+
paymentStatus: PaymentStatus;
|
|
1879
|
+
paymentTransactionId?: string | null;
|
|
1880
|
+
/** Procedure-related conditions and requirements */
|
|
1881
|
+
blockingConditions: BlockingCondition[];
|
|
1882
|
+
contraindications: Contraindication[];
|
|
1883
|
+
preProcedureRequirements: Requirement[];
|
|
1884
|
+
postProcedureRequirements: Requirement[];
|
|
1885
|
+
/** Tracking information for requirements completion */
|
|
1886
|
+
completedPreRequirements?: string[];
|
|
1887
|
+
completedPostRequirements?: string[];
|
|
1888
|
+
/** NEW: Linked forms (consent, procedure-specific forms, etc.) */
|
|
1889
|
+
linkedFormIds?: string[];
|
|
1890
|
+
linkedForms?: LinkedFormInfo[];
|
|
1891
|
+
pendingUserFormsIds?: string[];
|
|
1892
|
+
/** NEW: Media items (before/after photos, scanned documents, etc.) */
|
|
1893
|
+
media?: AppointmentMediaItem[];
|
|
1894
|
+
/** NEW: Information about the patient's review for this appointment */
|
|
1895
|
+
reviewInfo?: PatientReviewInfo | null;
|
|
1896
|
+
/** NEW: Details about the finalization of the appointment by the practitioner */
|
|
1897
|
+
finalizedDetails?: {
|
|
1898
|
+
by: string;
|
|
1899
|
+
at: Timestamp;
|
|
1900
|
+
notes?: string;
|
|
1901
|
+
};
|
|
1902
|
+
/** Timestamps for record creation and updates */
|
|
1903
|
+
createdAt: Timestamp;
|
|
1904
|
+
updatedAt: Timestamp;
|
|
1905
|
+
/** Recurring appointment information */
|
|
1906
|
+
isRecurring?: boolean;
|
|
1907
|
+
recurringAppointmentId?: string | null;
|
|
1908
|
+
/** NEW: Flag for soft deletion or archiving */
|
|
1909
|
+
isArchived?: boolean;
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
/**
|
|
1913
|
+
* Interface for the data required by orchestrateAppointmentCreation
|
|
1914
|
+
*/
|
|
1915
|
+
interface OrchestrateAppointmentCreationData {
|
|
1916
|
+
patientId: string;
|
|
1917
|
+
procedureId: string;
|
|
1918
|
+
appointmentStartTime: admin.firestore.Timestamp;
|
|
1919
|
+
appointmentEndTime: admin.firestore.Timestamp;
|
|
1920
|
+
patientNotes?: string | null;
|
|
1921
|
+
}
|
|
1633
1922
|
/**
|
|
1634
1923
|
* Admin service for handling booking-related operations.
|
|
1635
1924
|
* This is the cloud-based implementation that will be used in Cloud Functions.
|
|
@@ -1684,6 +1973,131 @@ declare class BookingAdmin {
|
|
|
1684
1973
|
* @returns Promise resolving to an array of calendar events
|
|
1685
1974
|
*/
|
|
1686
1975
|
private getPractitionerCalendarEvents;
|
|
1976
|
+
/**
|
|
1977
|
+
* Orchestrates the creation of a new appointment, including data aggregation.
|
|
1978
|
+
* This method is intended to be called from a trusted backend environment (e.g., an Express route handler in a Cloud Function).
|
|
1979
|
+
*
|
|
1980
|
+
* @param data - Data required to create the appointment.
|
|
1981
|
+
* @param authenticatedUserId - The ID of the user making the request (for auditing, and usually is the patientId).
|
|
1982
|
+
* @returns Promise resolving to an object indicating success, and appointmentId or an error message.
|
|
1983
|
+
*/
|
|
1984
|
+
orchestrateAppointmentCreation(data: OrchestrateAppointmentCreationData, authenticatedUserId: string): Promise<{
|
|
1985
|
+
success: boolean;
|
|
1986
|
+
appointmentId?: string;
|
|
1987
|
+
appointmentData?: Appointment;
|
|
1988
|
+
error?: string;
|
|
1989
|
+
}>;
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
/**
|
|
1993
|
+
* Defines the status of a specific instruction within a PatientRequirementInstance.
|
|
1994
|
+
* This helps track each actionable item for the patient.
|
|
1995
|
+
*/
|
|
1996
|
+
declare enum PatientInstructionStatus {
|
|
1997
|
+
PENDING_NOTIFICATION = "pendingNotification",// Notification is scheduled but not yet due/sent
|
|
1998
|
+
ACTION_DUE = "actionDue",// The time for this instruction/notification has arrived
|
|
1999
|
+
ACTION_TAKEN = "actionTaken",// Patient has acknowledged or completed this specific instruction
|
|
2000
|
+
MISSED = "missed",// The due time for this instruction passed without action
|
|
2001
|
+
CANCELLED = "cancelled",// This specific instruction was cancelled (e.g., requirement changed)
|
|
2002
|
+
SKIPPED = "skipped"
|
|
2003
|
+
}
|
|
2004
|
+
/**
|
|
2005
|
+
* Represents a single, timed instruction or notification point derived from a Requirement's timeframe.
|
|
2006
|
+
*/
|
|
2007
|
+
interface PatientRequirementInstruction {
|
|
2008
|
+
instructionId: string;
|
|
2009
|
+
instructionText: string;
|
|
2010
|
+
dueTime: Timestamp;
|
|
2011
|
+
actionableWindow: number;
|
|
2012
|
+
status: PatientInstructionStatus;
|
|
2013
|
+
originalNotifyAtValue: number;
|
|
2014
|
+
originalTimeframeUnit: TimeFrame["unit"];
|
|
2015
|
+
notificationId?: string;
|
|
2016
|
+
actionTakenAt?: Timestamp;
|
|
2017
|
+
updatedAt: Timestamp;
|
|
2018
|
+
}
|
|
2019
|
+
/**
|
|
2020
|
+
* Defines the overall status of a PatientRequirementInstance.
|
|
2021
|
+
*/
|
|
2022
|
+
declare enum PatientRequirementOverallStatus {
|
|
2023
|
+
ACTIVE = "active",// Requirement instance is active, instructions are pending or due.
|
|
2024
|
+
ALL_INSTRUCTIONS_MET = "allInstructionsMet",// All instructions actioned/completed by the patient.
|
|
2025
|
+
PARTIALLY_COMPLETED = "partiallyCompleted",// Some instructions met, some missed or pending.
|
|
2026
|
+
FAILED = "failed",// The patient failed to complete the requirement on time and above treashold of 60%
|
|
2027
|
+
CANCELLED_APPOINTMENT = "cancelledAppointment",// Entire requirement instance cancelled due to appointment cancellation.
|
|
2028
|
+
SUPERSEDED_RESCHEDULE = "supersededReschedule",// This instance was replaced by a new one due to appointment reschedule.
|
|
2029
|
+
FAILED_TO_PROCESS = "failedToProcess"
|
|
2030
|
+
}
|
|
2031
|
+
/**
|
|
2032
|
+
* Represents an instance of a backoffice Requirement, tailored to a specific patient and appointment.
|
|
2033
|
+
* This document lives in the patient's subcollection: `patients/{patientId}/patientRequirements/{instanceId}`.
|
|
2034
|
+
*/
|
|
2035
|
+
interface PatientRequirementInstance {
|
|
2036
|
+
id: string;
|
|
2037
|
+
patientId: string;
|
|
2038
|
+
appointmentId: string;
|
|
2039
|
+
originalRequirementId: string;
|
|
2040
|
+
requirementType: RequirementType;
|
|
2041
|
+
requirementName: string;
|
|
2042
|
+
requirementDescription: string;
|
|
2043
|
+
requirementImportance: RequirementImportance;
|
|
2044
|
+
overallStatus: PatientRequirementOverallStatus;
|
|
2045
|
+
instructions: PatientRequirementInstruction[];
|
|
2046
|
+
createdAt: Timestamp;
|
|
2047
|
+
updatedAt: Timestamp;
|
|
2048
|
+
}
|
|
2049
|
+
/**
|
|
2050
|
+
* Firestore subcollection name for patient requirement instances.
|
|
2051
|
+
*/
|
|
2052
|
+
declare const PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME = "patientRequirements";
|
|
2053
|
+
|
|
2054
|
+
/**
|
|
2055
|
+
* @class PatientRequirementsAdminService
|
|
2056
|
+
* @description Handles administrative tasks for patient requirement instances, primarily managing associated notifications.
|
|
2057
|
+
* This service is intended to be used by Cloud Functions triggered by changes to PatientRequirementInstance documents.
|
|
2058
|
+
*/
|
|
2059
|
+
declare class PatientRequirementsAdminService {
|
|
2060
|
+
private db;
|
|
2061
|
+
private notificationsAdmin;
|
|
2062
|
+
constructor(firestore?: admin.firestore.Firestore);
|
|
2063
|
+
/**
|
|
2064
|
+
* Processes a newly created or updated PatientRequirementInstance to schedule notifications for its instructions.
|
|
2065
|
+
* It will also cancel pre-existing notifications if due times have changed significantly.
|
|
2066
|
+
*
|
|
2067
|
+
* @param patientId - The ID of the patient.
|
|
2068
|
+
* @param instance - The PatientRequirementInstance data (either new or updated).
|
|
2069
|
+
* @param previousInstanceData - Optional. The previous state of the instance data if it's an update.
|
|
2070
|
+
* Used to determine if notifications need to be cancelled/rescheduled.
|
|
2071
|
+
* @returns {Promise<void>} A promise that resolves when processing is complete.
|
|
2072
|
+
*/
|
|
2073
|
+
processRequirementInstanceAndScheduleNotifications(patientId: string, instance: PatientRequirementInstance, previousInstanceData?: PatientRequirementInstance): Promise<void>;
|
|
2074
|
+
/**
|
|
2075
|
+
* Cancels all PENDING notifications associated with a specific PatientRequirementInstance.
|
|
2076
|
+
* Typically called when the instance itself is deleted or its overall status becomes CANCELLED.
|
|
2077
|
+
*
|
|
2078
|
+
* @param instance - The PatientRequirementInstance.
|
|
2079
|
+
* @returns {Promise<void>}
|
|
2080
|
+
*/
|
|
2081
|
+
cancelAllNotificationsForInstance(instance: PatientRequirementInstance): Promise<void>;
|
|
2082
|
+
/**
|
|
2083
|
+
* (Optional - For a cron job)
|
|
2084
|
+
* Scans for instructions that are past their due time but not yet actioned, and updates their status to MISSED.
|
|
2085
|
+
* This would typically be called by a scheduled Cloud Function.
|
|
2086
|
+
*
|
|
2087
|
+
* @param patientId - The ID of the patient.
|
|
2088
|
+
* @param instanceId - The ID of the PatientRequirementInstance.
|
|
2089
|
+
* @returns {Promise<void>}
|
|
2090
|
+
*/
|
|
2091
|
+
updateMissedInstructions(patientId: string, instanceId: string): Promise<void>;
|
|
2092
|
+
/**
|
|
2093
|
+
* Calculates and updates the overallStatus of a PatientRequirementInstance
|
|
2094
|
+
* based on the statuses of its individual instructions.
|
|
2095
|
+
*
|
|
2096
|
+
* @param patientId - The ID of the patient.
|
|
2097
|
+
* @param instanceId - The ID of the PatientRequirementInstance to update.
|
|
2098
|
+
* @returns {Promise<void>} A promise that resolves when processing is complete.
|
|
2099
|
+
*/
|
|
2100
|
+
updateOverallInstanceStatus(patientId: string, instanceId: string): Promise<void>;
|
|
1687
2101
|
}
|
|
1688
2102
|
|
|
1689
2103
|
/**
|
|
@@ -1729,4 +2143,4 @@ interface TimeInterval {
|
|
|
1729
2143
|
end: Timestamp;
|
|
1730
2144
|
}
|
|
1731
2145
|
|
|
1732
|
-
export { type
|
|
2146
|
+
export { type AppointmentReminderNotification, type AvailableSlot, BaseMailingService, type BaseNotification, BookingAdmin, type BookingAvailabilityRequest, type BookingAvailabilityResponse, type Clinic, ClinicAggregationService, type ClinicInfo, type ClinicLocation, type DoctorInfo, NOTIFICATIONS_COLLECTION, type Notification, NotificationStatus, NotificationType, NotificationsAdmin, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, type PatientProfile as Patient, PatientAggregationService, PatientInstructionStatus, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, PatientRequirementsAdminService, type PostRequirementNotification, type Practitioner, PractitionerAggregationService, PractitionerInviteMailingService, type PractitionerToken, PractitionerTokenStatus, type PreRequirementNotification, type Procedure, ProcedureAggregationService, type ProcedureSummaryInfo, type TimeInterval, UserRole };
|