@blackcode_sa/metaestetics-api 1.6.3 → 1.6.4
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 +228 -25
- package/dist/admin/index.d.ts +228 -25
- package/dist/admin/index.js +35867 -2493
- package/dist/admin/index.mjs +35856 -2464
- package/dist/backoffice/index.d.mts +252 -1
- package/dist/backoffice/index.d.ts +252 -1
- package/dist/backoffice/index.js +86 -12
- package/dist/backoffice/index.mjs +86 -13
- package/dist/index.d.mts +1400 -554
- package/dist/index.d.ts +1400 -554
- package/dist/index.js +1325 -683
- package/dist/index.mjs +1358 -710
- package/package.json +1 -1
- 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/index.ts +16 -1
- package/src/services/appointment/appointment.service.ts +315 -86
- 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/types/appointment/index.ts +134 -10
- 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/validations/appointment.schema.ts +300 -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
|
@@ -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";
|