@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
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
## Notification Types (`index.ts`)
|
|
2
|
+
|
|
3
|
+
This file defines the core data structures and enumerations for handling all types of notifications within the MetaTest_v2 system. These types are crucial for ensuring consistency and providing clear contracts for how notification data is stored in Firestore, processed by Cloud Functions, and potentially interpreted by client applications.
|
|
4
|
+
|
|
5
|
+
### Core Concepts
|
|
6
|
+
|
|
7
|
+
1. **`NotificationType` (Enum):**
|
|
8
|
+
|
|
9
|
+
- A comprehensive enumeration that categorizes every possible notification sent by the system.
|
|
10
|
+
- Examples: `APPOINTMENT_REMINDER`, `REQUIREMENT_INSTRUCTION_DUE`, `FORM_SUBMISSION_CONFIRMATION`, `PAYMENT_CONFIRMATION`.
|
|
11
|
+
- **Usage:** This enum is used as a discriminator in the `Notification` union type, allowing for type-safe handling of different notification structures.
|
|
12
|
+
|
|
13
|
+
2. **`BaseNotification` (Interface):**
|
|
14
|
+
|
|
15
|
+
- Defines the common properties shared by all notification types.
|
|
16
|
+
- Includes essential fields like `id`, `userId`, `userRole`, `notificationType`, `notificationTime` (when it should be sent/processed), `title`, `body`, `status`, `isRead`, timestamps (`createdAt`, `updatedAt`, `sentAt`), and various optional linking IDs (`appointmentId`, `patientRequirementInstanceId`, etc.).
|
|
17
|
+
- **Usage:** Specific notification interfaces extend `BaseNotification` to inherit these common fields and add their own type-specific data.
|
|
18
|
+
|
|
19
|
+
3. **`NotificationStatus` (Enum):**
|
|
20
|
+
|
|
21
|
+
- Defines the lifecycle states of a notification document (e.g., `PENDING`, `PROCESSING`, `SENT`, `FAILED`, `CANCELLED`).
|
|
22
|
+
- **Usage:** Tracks the progress of a notification from creation to sending or cancellation.
|
|
23
|
+
|
|
24
|
+
4. **Specific Notification Interfaces (e.g., `RequirementInstructionDueNotification`, `AppointmentReminderNotification`):**
|
|
25
|
+
|
|
26
|
+
- Each interface extends `BaseNotification` and defines properties unique to that particular `NotificationType`.
|
|
27
|
+
- They typically make certain linking IDs (like `appointmentId`) mandatory if the notification contextually requires them.
|
|
28
|
+
- **Example `RequirementInstructionDueNotification`:**
|
|
29
|
+
- `notificationType: NotificationType.REQUIREMENT_INSTRUCTION_DUE`
|
|
30
|
+
- `appointmentId: string` (Mandatory link to the appointment)
|
|
31
|
+
- `patientRequirementInstanceId: string` (Mandatory link to the patient-specific requirement instance)
|
|
32
|
+
- `instructionId: string` (Mandatory link to the specific instruction within that instance)
|
|
33
|
+
- The `body` of this notification will contain the actual instruction text (e.g., "Do not eat for 8 hours before your procedure.").
|
|
34
|
+
- **Usage:** These provide strongly-typed structures for creating, storing, and processing each kind of notification.
|
|
35
|
+
|
|
36
|
+
5. **`Notification` (Union Type):**
|
|
37
|
+
- A TypeScript union of all specific notification interfaces (`RequirementInstructionDueNotification | AppointmentReminderNotification | ...`).
|
|
38
|
+
- **Usage:** Allows functions and services to handle various notification types polymorphically while still enabling type narrowing based on the `notificationType` property.
|
|
39
|
+
|
|
40
|
+
### How to Use These Types
|
|
41
|
+
|
|
42
|
+
- **Creating Notifications:**
|
|
43
|
+
|
|
44
|
+
- When a system event occurs (e.g., appointment confirmed, requirement instruction due), a Cloud Function or service will construct a notification object conforming to one of the specific notification interfaces.
|
|
45
|
+
- The `notificationType` must be set correctly.
|
|
46
|
+
- The `notificationTime` should be set to when the notification should be processed (e.g., `Timestamp.now()` for immediate notifications, or a future `Timestamp` for scheduled ones).
|
|
47
|
+
- Relevant linking IDs (`appointmentId`, `patientRequirementInstanceId`, etc.) must be populated to maintain context and enable lifecycle management.
|
|
48
|
+
- The `title` and `body` should be generated with user-friendly content.
|
|
49
|
+
- This notification object is then typically saved to the `notifications` collection in Firestore (its path defined by `NOTIFICATIONS_COLLECTION`).
|
|
50
|
+
|
|
51
|
+
- **Processing Notifications (e.g., by a sending Cloud Function):**
|
|
52
|
+
|
|
53
|
+
- A scheduled Cloud Function (e.g., `processPendingNotifications`) queries the `notifications` collection for documents with `status: NotificationStatus.PENDING` and `notificationTime <= now()`.
|
|
54
|
+
- For each retrieved document (which can be cast to the `Notification` union type):
|
|
55
|
+
- The function can use a `switch` statement or `if/else if` chain on `notification.notificationType` to handle any type-specific logic before sending (though often the `title` and `body` are pre-formatted).
|
|
56
|
+
- The `notificationTokens`, `title`, `body`, and any relevant `data` (for deep linking, derived from linking IDs) are used to construct the push notification message (e.g., `ExpoPushMessage`).
|
|
57
|
+
- The notification's `status` in Firestore is updated (e.g., to `SENT` or `FAILED`).
|
|
58
|
+
|
|
59
|
+
- **Managing Notification Lifecycles (e.g., Cancellation/Reschedule):**
|
|
60
|
+
|
|
61
|
+
- When an event like an appointment cancellation occurs, Cloud Functions will query the `notifications` collection using relevant linking IDs (e.g., `appointmentId`) and `status: NotificationStatus.PENDING`.
|
|
62
|
+
- Found notifications can then have their `status` updated to `NotificationStatus.CANCELLED`.
|
|
63
|
+
- For reschedules, pending notifications might be cancelled and new ones created, or their `notificationTime` might be updated (this logic is handled by higher-level services/functions that use these types).
|
|
64
|
+
|
|
65
|
+
- **Client Application Usage (Indirect):**
|
|
66
|
+
- Client applications (mobile/web) receive push notifications via services like Expo or FCM.
|
|
67
|
+
- The `data` payload within the received push notification (not directly defined in these Firestore types, but constructed by the sending function) should contain necessary information for deep linking (e.g., `appointmentId`, `screenToOpen`).
|
|
68
|
+
- The client might also fetch a list of notification history from Firestore (e.g., for an in-app notification center), where these types would define the structure of the fetched data.
|
|
69
|
+
|
|
70
|
+
### Key Considerations
|
|
71
|
+
|
|
72
|
+
- **Linking IDs:** Proper use of `appointmentId`, `patientRequirementInstanceId`, `instructionId`, etc., is critical for correctly associating notifications with their sources and managing their lifecycle (e.g., cancelling all pending notifications for a cancelled appointment).
|
|
73
|
+
- **Clarity of `title` and `body`:** These should be user-friendly and provide actionable information.
|
|
74
|
+
- **Deep Linking:** While not defined in these Firestore types, the data sent in the actual push message payload should enable effective deep linking into the relevant parts of the application.
|
|
75
|
+
- **Evolution:** As new notification scenarios arise, new `NotificationType` enum members and corresponding specific interfaces should be added, and the main `Notification` union type updated.
|
|
76
|
+
|
|
77
|
+
This structured approach to notification types ensures scalability, maintainability, and type safety throughout the notification system.
|
|
@@ -4,10 +4,30 @@ import { UserRole } from "../";
|
|
|
4
4
|
* Enumeracija koja definiše sve moguće tipove notifikacija
|
|
5
5
|
*/
|
|
6
6
|
export enum NotificationType {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
// --- Appointment Lifecycle & Reminders ---
|
|
8
|
+
APPOINTMENT_REMINDER = "appointmentReminder", // For upcoming appointments
|
|
9
|
+
APPOINTMENT_STATUS_CHANGE = "appointmentStatusChange", // Generic for status changes like confirmed, checked-in etc.
|
|
10
|
+
APPOINTMENT_RESCHEDULED_PROPOSAL = "appointmentRescheduledProposal", // When clinic proposes a new time
|
|
11
|
+
APPOINTMENT_CANCELLED = "appointmentCancelled", // When an appointment is cancelled
|
|
12
|
+
|
|
13
|
+
// --- Requirement-Driven Instructions ---
|
|
14
|
+
REQUIREMENT_INSTRUCTION_DUE = "requirementInstructionDue", // For specific pre/post care instructions
|
|
15
|
+
|
|
16
|
+
// --- Form Related ---
|
|
17
|
+
FORM_REMINDER = "formReminder", // Reminds user to fill a specific form
|
|
18
|
+
FORM_SUBMISSION_CONFIRMATION = "formSubmissionConfirmation", // Confirms form was submitted
|
|
19
|
+
|
|
20
|
+
// --- Patient Engagement ---
|
|
21
|
+
REVIEW_REQUEST = "reviewRequest", // Request for patient review post-appointment
|
|
22
|
+
|
|
23
|
+
// --- Payment Related (Examples) ---
|
|
24
|
+
PAYMENT_DUE = "paymentDue",
|
|
25
|
+
PAYMENT_CONFIRMATION = "paymentConfirmation",
|
|
26
|
+
PAYMENT_FAILED = "paymentFailed",
|
|
27
|
+
|
|
28
|
+
// --- General & Administrative ---
|
|
29
|
+
GENERAL_MESSAGE = "generalMessage", // For general announcements or direct messages
|
|
30
|
+
ACCOUNT_NOTIFICATION = "accountNotification", // e.g., password change, security alert
|
|
11
31
|
}
|
|
12
32
|
|
|
13
33
|
export const NOTIFICATIONS_COLLECTION = "notifications";
|
|
@@ -57,6 +77,16 @@ export interface BaseNotification {
|
|
|
57
77
|
|
|
58
78
|
/** Uloga korisnika kome je namenjena notifikacija */
|
|
59
79
|
userRole: UserRole;
|
|
80
|
+
|
|
81
|
+
// --- Optional Linking IDs ---
|
|
82
|
+
// These help in managing notifications and for deep-linking in the app.
|
|
83
|
+
appointmentId?: string; // Associated appointment
|
|
84
|
+
patientRequirementInstanceId?: string; // Link to PatientRequirementInstance in patient's subcollection
|
|
85
|
+
instructionId?: string; // Specific instruction ID within a PatientRequirementInstance
|
|
86
|
+
formId?: string; // Associated form (FilledDocument ID)
|
|
87
|
+
originalRequirementId?: string; // ID of the base Requirement template
|
|
88
|
+
transactionId?: string; // Associated payment transaction
|
|
89
|
+
// Add other relevant linking IDs as needed, e.g., clinicId, practitionerId if notification is for them
|
|
60
90
|
}
|
|
61
91
|
|
|
62
92
|
/**
|
|
@@ -64,8 +94,10 @@ export interface BaseNotification {
|
|
|
64
94
|
*/
|
|
65
95
|
export enum NotificationStatus {
|
|
66
96
|
PENDING = "pending",
|
|
97
|
+
PROCESSING = "processing",
|
|
67
98
|
SENT = "sent",
|
|
68
99
|
FAILED = "failed",
|
|
100
|
+
DELIVERED = "delivered",
|
|
69
101
|
CANCELLED = "cancelled",
|
|
70
102
|
PARTIAL_SUCCESS = "partialSuccess",
|
|
71
103
|
}
|
|
@@ -74,7 +106,7 @@ export enum NotificationStatus {
|
|
|
74
106
|
* Notifikacija za pre-requirement
|
|
75
107
|
*/
|
|
76
108
|
export interface PreRequirementNotification extends BaseNotification {
|
|
77
|
-
notificationType: NotificationType.
|
|
109
|
+
notificationType: NotificationType.REQUIREMENT_INSTRUCTION_DUE;
|
|
78
110
|
/** ID tretmana za koji je vezan pre-requirement */
|
|
79
111
|
treatmentId: string;
|
|
80
112
|
/** Lista pre-requirements koji treba da se ispune */
|
|
@@ -87,7 +119,7 @@ export interface PreRequirementNotification extends BaseNotification {
|
|
|
87
119
|
* Notifikacija za post-requirement
|
|
88
120
|
*/
|
|
89
121
|
export interface PostRequirementNotification extends BaseNotification {
|
|
90
|
-
notificationType: NotificationType.
|
|
122
|
+
notificationType: NotificationType.REQUIREMENT_INSTRUCTION_DUE;
|
|
91
123
|
/** ID tretmana za koji je vezan post-requirement */
|
|
92
124
|
treatmentId: string;
|
|
93
125
|
/** Lista post-requirements koji treba da se ispune */
|
|
@@ -97,33 +129,120 @@ export interface PostRequirementNotification extends BaseNotification {
|
|
|
97
129
|
}
|
|
98
130
|
|
|
99
131
|
/**
|
|
100
|
-
*
|
|
132
|
+
* Notification for a specific instruction from a PatientRequirementInstance.
|
|
133
|
+
* Example: "Do not eat 2 hours before your [Procedure Name] appointment."
|
|
134
|
+
*/
|
|
135
|
+
export interface RequirementInstructionDueNotification
|
|
136
|
+
extends BaseNotification {
|
|
137
|
+
notificationType: NotificationType.REQUIREMENT_INSTRUCTION_DUE;
|
|
138
|
+
appointmentId: string; // Mandatory
|
|
139
|
+
patientRequirementInstanceId: string; // Mandatory
|
|
140
|
+
instructionId: string; // Mandatory
|
|
141
|
+
// The 'body' will contain the specific instruction text.
|
|
142
|
+
// 'title' could be "Upcoming: [Requirement Name]" or similar.
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Notification reminding about an upcoming appointment.
|
|
147
|
+
* Example: "Reminder: Your appointment for [Procedure Name] is at [Time] today."
|
|
101
148
|
*/
|
|
102
149
|
export interface AppointmentReminderNotification extends BaseNotification {
|
|
103
150
|
notificationType: NotificationType.APPOINTMENT_REMINDER;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
151
|
+
appointmentId: string; // Mandatory
|
|
152
|
+
appointmentTime: Timestamp; // For easy access to construct message body
|
|
153
|
+
procedureName?: string;
|
|
154
|
+
practitionerName?: string;
|
|
155
|
+
clinicName?: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Notification about a change in appointment status (e.g., confirmed, checked-in).
|
|
160
|
+
* Excludes cancellations and reschedule proposals, which have their own types.
|
|
161
|
+
* Example: "Your appointment for [Procedure Name] has been Confirmed."
|
|
162
|
+
*/
|
|
163
|
+
export interface AppointmentStatusChangeNotification extends BaseNotification {
|
|
164
|
+
notificationType: NotificationType.APPOINTMENT_STATUS_CHANGE;
|
|
165
|
+
appointmentId: string; // Mandatory
|
|
166
|
+
newStatus: string; // The new AppointmentStatus (e.g., "CONFIRMED", "CHECKED_IN")
|
|
167
|
+
previousStatus?: string;
|
|
168
|
+
procedureName?: string;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Notification informing the patient that the clinic has proposed a new time for their appointment.
|
|
173
|
+
* Example: "Action Required: [Clinic Name] has proposed a new time for your [Procedure Name] appointment."
|
|
174
|
+
*/
|
|
175
|
+
export interface AppointmentRescheduledProposalNotification
|
|
176
|
+
extends BaseNotification {
|
|
177
|
+
notificationType: NotificationType.APPOINTMENT_RESCHEDULED_PROPOSAL;
|
|
178
|
+
appointmentId: string; // Mandatory
|
|
179
|
+
newProposedStartTime: Timestamp;
|
|
180
|
+
newProposedEndTime: Timestamp;
|
|
181
|
+
procedureName?: string;
|
|
182
|
+
// May include a deep link to confirm/reject reschedule.
|
|
112
183
|
}
|
|
113
184
|
|
|
114
185
|
/**
|
|
115
|
-
*
|
|
186
|
+
* Notification informing about a cancelled appointment.
|
|
187
|
+
* Example: "Your appointment for [Procedure Name] on [Date] has been cancelled."
|
|
116
188
|
*/
|
|
117
|
-
export interface
|
|
118
|
-
notificationType: NotificationType.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
189
|
+
export interface AppointmentCancelledNotification extends BaseNotification {
|
|
190
|
+
notificationType: NotificationType.APPOINTMENT_CANCELLED;
|
|
191
|
+
appointmentId: string; // Mandatory
|
|
192
|
+
reason?: string; // Reason for cancellation
|
|
193
|
+
cancelledByRole?: UserRole; // Who initiated the cancellation (PATIENT, CLINIC_ADMIN, etc.)
|
|
194
|
+
procedureName?: string;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Notification reminding a user to fill a specific form.
|
|
199
|
+
* Example: "Reminder: Please complete the '[Form Name]' form for your upcoming appointment."
|
|
200
|
+
*/
|
|
201
|
+
export interface FormReminderNotification extends BaseNotification {
|
|
202
|
+
notificationType: NotificationType.FORM_REMINDER;
|
|
203
|
+
appointmentId: string; // Associated appointment for which the form is required
|
|
204
|
+
formId: string; // The ID of the FilledDocument instance
|
|
205
|
+
formName: string; // Display name of the form
|
|
206
|
+
formDeadline?: Timestamp; // Optional: When the form is due
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Notification confirming a form submission.
|
|
211
|
+
* Example: "Thank you! Your '[Form Name]' form has been submitted successfully."
|
|
212
|
+
*/
|
|
213
|
+
export interface FormSubmissionConfirmationNotification
|
|
214
|
+
extends BaseNotification {
|
|
215
|
+
notificationType: NotificationType.FORM_SUBMISSION_CONFIRMATION;
|
|
216
|
+
appointmentId?: string; // Optional, if form is tied to an appointment
|
|
217
|
+
formId: string;
|
|
218
|
+
formName: string;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Notification requesting a patient to leave a review after an appointment.
|
|
223
|
+
* Example: "Hope you had a great experience! Would you like to share your feedback for your visit on [Date]?"
|
|
224
|
+
*/
|
|
225
|
+
export interface ReviewRequestNotification extends BaseNotification {
|
|
226
|
+
notificationType: NotificationType.REVIEW_REQUEST;
|
|
227
|
+
appointmentId: string; // The completed appointment for which review is requested
|
|
228
|
+
practitionerName?: string;
|
|
229
|
+
procedureName?: string;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Generic notification for direct messages or announcements.
|
|
234
|
+
*/
|
|
235
|
+
export interface GeneralMessageNotification extends BaseNotification {
|
|
236
|
+
notificationType: NotificationType.GENERAL_MESSAGE;
|
|
237
|
+
// Could have senderId, conversationId etc. if it's for a chat-like feature
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Example Payment Notification (can be expanded)
|
|
241
|
+
export interface PaymentConfirmationNotification extends BaseNotification {
|
|
242
|
+
notificationType: NotificationType.PAYMENT_CONFIRMATION;
|
|
243
|
+
transactionId: string;
|
|
244
|
+
appointmentId?: string;
|
|
245
|
+
amount: string; // e.g., "€50.00"
|
|
127
246
|
}
|
|
128
247
|
|
|
129
248
|
/**
|
|
@@ -132,5 +251,13 @@ export interface AppointmentNotification extends BaseNotification {
|
|
|
132
251
|
export type Notification =
|
|
133
252
|
| PreRequirementNotification
|
|
134
253
|
| PostRequirementNotification
|
|
254
|
+
| RequirementInstructionDueNotification
|
|
135
255
|
| AppointmentReminderNotification
|
|
136
|
-
|
|
|
256
|
+
| AppointmentStatusChangeNotification
|
|
257
|
+
| AppointmentRescheduledProposalNotification
|
|
258
|
+
| AppointmentCancelledNotification
|
|
259
|
+
| FormReminderNotification
|
|
260
|
+
| FormSubmissionConfirmationNotification
|
|
261
|
+
| ReviewRequestNotification
|
|
262
|
+
| GeneralMessageNotification
|
|
263
|
+
| PaymentConfirmationNotification;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Timestamp } from "firebase/firestore";
|
|
2
|
+
import {
|
|
3
|
+
RequirementType,
|
|
4
|
+
RequirementImportance,
|
|
5
|
+
TimeFrame,
|
|
6
|
+
} from "../../backoffice/types/requirement.types";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Defines the status of a specific instruction within a PatientRequirementInstance.
|
|
10
|
+
* This helps track each actionable item for the patient.
|
|
11
|
+
*/
|
|
12
|
+
export enum PatientInstructionStatus {
|
|
13
|
+
PENDING_NOTIFICATION = "pendingNotification", // Notification is scheduled but not yet due/sent
|
|
14
|
+
ACTION_DUE = "actionDue", // The time for this instruction/notification has arrived
|
|
15
|
+
ACTION_TAKEN = "actionTaken", // Patient has acknowledged or completed this specific instruction
|
|
16
|
+
MISSED = "missed", // The due time for this instruction passed without action
|
|
17
|
+
CANCELLED = "cancelled", // This specific instruction was cancelled (e.g., requirement changed)
|
|
18
|
+
SKIPPED = "skipped", // This specific instruction was skipped (e.g., patient did not want to do it)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Represents a single, timed instruction or notification point derived from a Requirement's timeframe.
|
|
23
|
+
*/
|
|
24
|
+
export interface PatientRequirementInstruction {
|
|
25
|
+
instructionId: string; // Unique ID for this specific instruction (e.g., originalRequirementId + notifyAtIndex)
|
|
26
|
+
instructionText: string; // The specific text for this instruction (e.g., "Do not drink water")
|
|
27
|
+
|
|
28
|
+
dueTime: Timestamp; // When this instruction is due, or when the notification for it should be sent
|
|
29
|
+
actionableWindow: number; // The number of hours before the due time that the instruction is actionable (e.g., 24 hours), after this it will marked as missed if not completed
|
|
30
|
+
status: PatientInstructionStatus;
|
|
31
|
+
|
|
32
|
+
originalNotifyAtValue: number; // The original 'notifyAt' value from Requirement.timeframe.notifyAt (e.g. 2 for 2 hours before)
|
|
33
|
+
originalTimeframeUnit: TimeFrame["unit"]; // e.g. 'hours' or 'days'
|
|
34
|
+
|
|
35
|
+
notificationId?: string; // ID of the notification created for this instruction
|
|
36
|
+
actionTakenAt?: Timestamp; // When the patient marked this specific instruction as actioned
|
|
37
|
+
updatedAt: Timestamp; // Last update to this instruction's status/details
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Defines the overall status of a PatientRequirementInstance.
|
|
42
|
+
*/
|
|
43
|
+
export enum PatientRequirementOverallStatus {
|
|
44
|
+
ACTIVE = "active", // Requirement instance is active, instructions are pending or due.
|
|
45
|
+
ALL_INSTRUCTIONS_MET = "allInstructionsMet", // All instructions actioned/completed by the patient.
|
|
46
|
+
PARTIALLY_COMPLETED = "partiallyCompleted", // Some instructions met, some missed or pending.
|
|
47
|
+
FAILED = "failed", // The patient failed to complete the requirement on time and above treashold of 60%
|
|
48
|
+
CANCELLED_APPOINTMENT = "cancelledAppointment", // Entire requirement instance cancelled due to appointment cancellation.
|
|
49
|
+
SUPERSEDED_RESCHEDULE = "supersededReschedule", // This instance was replaced by a new one due to appointment reschedule.
|
|
50
|
+
FAILED_TO_PROCESS = "failedToProcess", // An error occurred during its creation or initial processing.
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Represents an instance of a backoffice Requirement, tailored to a specific patient and appointment.
|
|
55
|
+
* This document lives in the patient's subcollection: `patients/{patientId}/patientRequirements/{instanceId}`.
|
|
56
|
+
*/
|
|
57
|
+
export interface PatientRequirementInstance {
|
|
58
|
+
id: string; // Firestore document ID
|
|
59
|
+
patientId: string;
|
|
60
|
+
appointmentId: string;
|
|
61
|
+
|
|
62
|
+
originalRequirementId: string; // ID of the base Requirement from `backoffice_requirements`
|
|
63
|
+
requirementType: RequirementType; // 'pre' or 'post', copied from original
|
|
64
|
+
requirementName: string; // Copied from original (for display)
|
|
65
|
+
requirementDescription: string; // Copied from original (overall description)
|
|
66
|
+
requirementImportance: RequirementImportance; // Copied from original
|
|
67
|
+
|
|
68
|
+
overallStatus: PatientRequirementOverallStatus; // Overall status of this requirement instance
|
|
69
|
+
|
|
70
|
+
// Contains each specific timed instruction derived from the Requirement's timeframe.notifyAt
|
|
71
|
+
instructions: PatientRequirementInstruction[];
|
|
72
|
+
|
|
73
|
+
// Timestamps for the instance itself
|
|
74
|
+
createdAt: Timestamp;
|
|
75
|
+
updatedAt: Timestamp;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Firestore subcollection name for patient requirement instances.
|
|
80
|
+
*/
|
|
81
|
+
export const PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME = "patientRequirements";
|
|
@@ -16,6 +16,7 @@ import { ClinicInfo } from "../profile";
|
|
|
16
16
|
import { DoctorInfo } from "../clinic";
|
|
17
17
|
import { PRACTITIONERS_COLLECTION } from "../practitioner";
|
|
18
18
|
import { ProcedureReviewInfo } from "../reviews";
|
|
19
|
+
import type { Contraindication } from "../../backoffice/types/static/contraindication.types";
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Procedure represents a specific medical procedure that can be performed by a practitioner in a clinic
|
|
@@ -26,6 +27,8 @@ export interface Procedure {
|
|
|
26
27
|
id: string;
|
|
27
28
|
/** Name of the procedure */
|
|
28
29
|
name: string;
|
|
30
|
+
/** Photos of the procedure */
|
|
31
|
+
photos?: string[];
|
|
29
32
|
/** Detailed description of the procedure */
|
|
30
33
|
description: string;
|
|
31
34
|
/** Family of procedures this belongs to (aesthetics/surgery) */
|
|
@@ -50,6 +53,8 @@ export interface Procedure {
|
|
|
50
53
|
blockingConditions: BlockingCondition[];
|
|
51
54
|
/** Treatment benefits of this procedure */
|
|
52
55
|
treatmentBenefits: TreatmentBenefit[];
|
|
56
|
+
/** Contraindications of this procedure */
|
|
57
|
+
contraindications: Contraindication[];
|
|
53
58
|
/** Pre-procedure requirements */
|
|
54
59
|
preRequirements: Requirement[];
|
|
55
60
|
/** Post-procedure requirements */
|
|
@@ -93,6 +98,7 @@ export interface CreateProcedureData {
|
|
|
93
98
|
duration: number;
|
|
94
99
|
practitionerId: string;
|
|
95
100
|
clinicBranchId: string;
|
|
101
|
+
photos?: string[];
|
|
96
102
|
}
|
|
97
103
|
|
|
98
104
|
/**
|
|
@@ -112,6 +118,7 @@ export interface UpdateProcedureData {
|
|
|
112
118
|
technologyId?: string;
|
|
113
119
|
productId?: string;
|
|
114
120
|
clinicBranchId?: string;
|
|
121
|
+
photos?: string[];
|
|
115
122
|
}
|
|
116
123
|
|
|
117
124
|
/**
|