@blackcode_sa/metaestetics-api 1.5.35 → 1.5.37
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/index.d.mts +1829 -1514
- package/dist/index.d.ts +1829 -1514
- package/dist/index.js +2055 -1118
- package/dist/index.mjs +2071 -1123
- package/package.json +1 -1
- package/src/index.ts +26 -0
- package/src/services/appointment/appointment.service.ts +8 -0
package/dist/index.js
CHANGED
|
@@ -30,9 +30,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
APPOINTMENTS_COLLECTION: () => APPOINTMENTS_COLLECTION,
|
|
33
34
|
AUTH_ERRORS: () => AUTH_ERRORS,
|
|
34
35
|
AdminTokenStatus: () => AdminTokenStatus,
|
|
35
36
|
AllergyType: () => AllergyType,
|
|
37
|
+
AppointmentService: () => AppointmentService,
|
|
38
|
+
AppointmentStatus: () => AppointmentStatus,
|
|
36
39
|
AuthService: () => AuthService,
|
|
37
40
|
BlockingCondition: () => BlockingCondition,
|
|
38
41
|
BrandService: () => BrandService,
|
|
@@ -82,6 +85,7 @@ __export(index_exports, {
|
|
|
82
85
|
PRACTITIONERS_COLLECTION: () => PRACTITIONERS_COLLECTION,
|
|
83
86
|
PROCEDURES_COLLECTION: () => PROCEDURES_COLLECTION,
|
|
84
87
|
PatientService: () => PatientService,
|
|
88
|
+
PaymentStatus: () => PaymentStatus,
|
|
85
89
|
PracticeType: () => PracticeType,
|
|
86
90
|
PractitionerService: () => PractitionerService,
|
|
87
91
|
PractitionerStatus: () => PractitionerStatus,
|
|
@@ -196,6 +200,7 @@ __export(index_exports, {
|
|
|
196
200
|
procedureSummaryInfoSchema: () => procedureSummaryInfoSchema,
|
|
197
201
|
requesterInfoSchema: () => requesterInfoSchema,
|
|
198
202
|
reviewSchema: () => reviewSchema,
|
|
203
|
+
searchAppointmentsSchema: () => searchAppointmentsSchema,
|
|
199
204
|
searchPatientsSchema: () => searchPatientsSchema,
|
|
200
205
|
syncedCalendarEventSchema: () => syncedCalendarEventSchema,
|
|
201
206
|
timeSlotSchema: () => timeSlotSchema2,
|
|
@@ -220,6 +225,109 @@ __export(index_exports, {
|
|
|
220
225
|
});
|
|
221
226
|
module.exports = __toCommonJS(index_exports);
|
|
222
227
|
|
|
228
|
+
// src/validations/appointment.schema.ts
|
|
229
|
+
var import_zod = require("zod");
|
|
230
|
+
|
|
231
|
+
// src/types/appointment/index.ts
|
|
232
|
+
var AppointmentStatus = /* @__PURE__ */ ((AppointmentStatus2) => {
|
|
233
|
+
AppointmentStatus2["SCHEDULED"] = "scheduled";
|
|
234
|
+
AppointmentStatus2["CONFIRMED"] = "confirmed";
|
|
235
|
+
AppointmentStatus2["CHECKED_IN"] = "checked_in";
|
|
236
|
+
AppointmentStatus2["IN_PROGRESS"] = "in_progress";
|
|
237
|
+
AppointmentStatus2["COMPLETED"] = "completed";
|
|
238
|
+
AppointmentStatus2["CANCELED_PATIENT"] = "canceled_patient";
|
|
239
|
+
AppointmentStatus2["CANCELED_CLINIC"] = "canceled_clinic";
|
|
240
|
+
AppointmentStatus2["NO_SHOW"] = "no_show";
|
|
241
|
+
AppointmentStatus2["RESCHEDULED"] = "rescheduled";
|
|
242
|
+
return AppointmentStatus2;
|
|
243
|
+
})(AppointmentStatus || {});
|
|
244
|
+
var PaymentStatus = /* @__PURE__ */ ((PaymentStatus3) => {
|
|
245
|
+
PaymentStatus3["UNPAID"] = "unpaid";
|
|
246
|
+
PaymentStatus3["PAID"] = "paid";
|
|
247
|
+
PaymentStatus3["PARTIALLY_PAID"] = "partially_paid";
|
|
248
|
+
PaymentStatus3["REFUNDED"] = "refunded";
|
|
249
|
+
PaymentStatus3["NOT_APPLICABLE"] = "not_applicable";
|
|
250
|
+
return PaymentStatus3;
|
|
251
|
+
})(PaymentStatus || {});
|
|
252
|
+
var APPOINTMENTS_COLLECTION = "appointments";
|
|
253
|
+
|
|
254
|
+
// src/validations/appointment.schema.ts
|
|
255
|
+
var createAppointmentSchema = import_zod.z.object({
|
|
256
|
+
calendarEventId: import_zod.z.string().min(1, "Calendar event ID is required"),
|
|
257
|
+
clinicBranchId: import_zod.z.string().min(1, "Clinic branch ID is required"),
|
|
258
|
+
practitionerId: import_zod.z.string().min(1, "Practitioner ID is required"),
|
|
259
|
+
patientId: import_zod.z.string().min(1, "Patient ID is required"),
|
|
260
|
+
procedureId: import_zod.z.string().min(1, "Procedure ID is required"),
|
|
261
|
+
appointmentStartTime: import_zod.z.any().refine(
|
|
262
|
+
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0,
|
|
263
|
+
"Appointment start time must be a valid timestamp"
|
|
264
|
+
),
|
|
265
|
+
appointmentEndTime: import_zod.z.any().refine(
|
|
266
|
+
(val) => val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0,
|
|
267
|
+
"Appointment end time must be a valid timestamp"
|
|
268
|
+
),
|
|
269
|
+
cost: import_zod.z.number().min(0, "Cost must be a non-negative number"),
|
|
270
|
+
currency: import_zod.z.string().min(1, "Currency is required"),
|
|
271
|
+
patientNotes: import_zod.z.string().nullable().optional(),
|
|
272
|
+
initialStatus: import_zod.z.nativeEnum(AppointmentStatus, {
|
|
273
|
+
errorMap: () => ({ message: "Invalid appointment status" })
|
|
274
|
+
}),
|
|
275
|
+
initialPaymentStatus: import_zod.z.nativeEnum(PaymentStatus, {
|
|
276
|
+
errorMap: () => ({ message: "Invalid payment status" })
|
|
277
|
+
}).optional().default("unpaid" /* UNPAID */)
|
|
278
|
+
});
|
|
279
|
+
var updateAppointmentSchema = import_zod.z.object({
|
|
280
|
+
status: import_zod.z.nativeEnum(AppointmentStatus, {
|
|
281
|
+
errorMap: () => ({ message: "Invalid appointment status" })
|
|
282
|
+
}).optional(),
|
|
283
|
+
confirmationTime: import_zod.z.any().refine(
|
|
284
|
+
(val) => val === null || val === void 0 || val instanceof Date || (val == null ? void 0 : val._seconds) !== void 0,
|
|
285
|
+
"Confirmation time must be a valid timestamp or null"
|
|
286
|
+
).optional(),
|
|
287
|
+
actualDurationMinutes: import_zod.z.number().positive("Duration must be positive").optional(),
|
|
288
|
+
cancellationReason: import_zod.z.string().nullable().optional(),
|
|
289
|
+
canceledBy: import_zod.z.enum(["patient", "clinic", "practitioner", "system"]).optional(),
|
|
290
|
+
internalNotes: import_zod.z.string().nullable().optional(),
|
|
291
|
+
paymentStatus: import_zod.z.nativeEnum(PaymentStatus, {
|
|
292
|
+
errorMap: () => ({ message: "Invalid payment status" })
|
|
293
|
+
}).optional(),
|
|
294
|
+
paymentTransactionId: import_zod.z.string().nullable().optional(),
|
|
295
|
+
completedPreRequirements: import_zod.z.array(import_zod.z.string()).optional(),
|
|
296
|
+
completedPostRequirements: import_zod.z.array(import_zod.z.string()).optional()
|
|
297
|
+
}).refine(
|
|
298
|
+
(data) => {
|
|
299
|
+
if (data.status === "canceled_clinic" /* CANCELED_CLINIC */ || data.status === "canceled_patient" /* CANCELED_PATIENT */) {
|
|
300
|
+
return !!data.cancellationReason && !!data.canceledBy;
|
|
301
|
+
}
|
|
302
|
+
return true;
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
message: "Cancellation reason and canceled by must be provided when canceling an appointment",
|
|
306
|
+
path: ["status"]
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
var searchAppointmentsSchema = import_zod.z.object({
|
|
310
|
+
patientId: import_zod.z.string().optional(),
|
|
311
|
+
practitionerId: import_zod.z.string().optional(),
|
|
312
|
+
clinicBranchId: import_zod.z.string().optional(),
|
|
313
|
+
startDate: import_zod.z.date().optional(),
|
|
314
|
+
endDate: import_zod.z.date().optional(),
|
|
315
|
+
status: import_zod.z.union([
|
|
316
|
+
import_zod.z.nativeEnum(AppointmentStatus),
|
|
317
|
+
import_zod.z.array(import_zod.z.nativeEnum(AppointmentStatus))
|
|
318
|
+
]).optional(),
|
|
319
|
+
limit: import_zod.z.number().positive().optional(),
|
|
320
|
+
startAfter: import_zod.z.any().optional()
|
|
321
|
+
}).refine(
|
|
322
|
+
(data) => {
|
|
323
|
+
return !!(data.patientId || data.practitionerId || data.clinicBranchId);
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
message: "At least one of patientId, practitionerId, or clinicBranchId must be provided",
|
|
327
|
+
path: ["searchCriteria"]
|
|
328
|
+
}
|
|
329
|
+
);
|
|
330
|
+
|
|
223
331
|
// src/config/firebase.ts
|
|
224
332
|
var import_app = require("firebase/app");
|
|
225
333
|
var import_firestore = require("firebase/firestore");
|
|
@@ -355,86 +463,86 @@ var UserRole = /* @__PURE__ */ ((UserRole2) => {
|
|
|
355
463
|
var USERS_COLLECTION = "users";
|
|
356
464
|
|
|
357
465
|
// src/services/auth.service.ts
|
|
358
|
-
var
|
|
466
|
+
var import_zod18 = require("zod");
|
|
359
467
|
|
|
360
468
|
// src/validations/schemas.ts
|
|
361
|
-
var
|
|
469
|
+
var import_zod3 = require("zod");
|
|
362
470
|
|
|
363
471
|
// src/validations/documentation-templates/template.schema.ts
|
|
364
|
-
var
|
|
365
|
-
var baseElementSchema =
|
|
366
|
-
id:
|
|
472
|
+
var import_zod2 = require("zod");
|
|
473
|
+
var baseElementSchema = import_zod2.z.object({
|
|
474
|
+
id: import_zod2.z.string().optional(),
|
|
367
475
|
// Make id optional so we can omit it later
|
|
368
|
-
type:
|
|
369
|
-
required:
|
|
476
|
+
type: import_zod2.z.nativeEnum(DocumentElementType),
|
|
477
|
+
required: import_zod2.z.boolean().optional()
|
|
370
478
|
});
|
|
371
479
|
var headingElementSchema = baseElementSchema.extend({
|
|
372
|
-
type:
|
|
373
|
-
text:
|
|
374
|
-
level:
|
|
480
|
+
type: import_zod2.z.literal("heading" /* HEADING */),
|
|
481
|
+
text: import_zod2.z.string().min(1).max(200),
|
|
482
|
+
level: import_zod2.z.nativeEnum(HeadingLevel)
|
|
375
483
|
});
|
|
376
484
|
var paragraphElementSchema = baseElementSchema.extend({
|
|
377
|
-
type:
|
|
378
|
-
text:
|
|
485
|
+
type: import_zod2.z.literal("paragraph" /* PARAGRAPH */),
|
|
486
|
+
text: import_zod2.z.string().min(1).max(5e3)
|
|
379
487
|
});
|
|
380
488
|
var listElementSchema = baseElementSchema.extend({
|
|
381
|
-
type:
|
|
382
|
-
items:
|
|
383
|
-
listType:
|
|
489
|
+
type: import_zod2.z.literal("list" /* LIST */),
|
|
490
|
+
items: import_zod2.z.array(import_zod2.z.string().min(1).max(500)).min(1).max(100),
|
|
491
|
+
listType: import_zod2.z.nativeEnum(ListType)
|
|
384
492
|
});
|
|
385
493
|
var dynamicTextElementSchema = baseElementSchema.extend({
|
|
386
|
-
type:
|
|
387
|
-
text:
|
|
494
|
+
type: import_zod2.z.literal("dynamic_text" /* DYNAMIC_TEXT */),
|
|
495
|
+
text: import_zod2.z.string().min(1).max(5e3)
|
|
388
496
|
});
|
|
389
497
|
var binaryChoiceElementSchema = baseElementSchema.extend({
|
|
390
|
-
type:
|
|
391
|
-
question:
|
|
392
|
-
defaultValue:
|
|
498
|
+
type: import_zod2.z.literal("binary_choice" /* BINARY_CHOICE */),
|
|
499
|
+
question: import_zod2.z.string().min(1).max(500),
|
|
500
|
+
defaultValue: import_zod2.z.boolean().optional()
|
|
393
501
|
});
|
|
394
502
|
var multipleChoiceElementSchema = baseElementSchema.extend({
|
|
395
|
-
type:
|
|
396
|
-
question:
|
|
397
|
-
options:
|
|
398
|
-
defaultValues:
|
|
503
|
+
type: import_zod2.z.literal("multiple_choice" /* MULTIPLE_CHOICE */),
|
|
504
|
+
question: import_zod2.z.string().min(1).max(500),
|
|
505
|
+
options: import_zod2.z.array(import_zod2.z.string().min(1).max(200)).min(2).max(50),
|
|
506
|
+
defaultValues: import_zod2.z.array(import_zod2.z.string()).optional()
|
|
399
507
|
});
|
|
400
508
|
var singleChoiceElementSchema = baseElementSchema.extend({
|
|
401
|
-
type:
|
|
402
|
-
question:
|
|
403
|
-
options:
|
|
404
|
-
defaultValue:
|
|
509
|
+
type: import_zod2.z.literal("single_choice" /* SINGLE_CHOICE */),
|
|
510
|
+
question: import_zod2.z.string().min(1).max(500),
|
|
511
|
+
options: import_zod2.z.array(import_zod2.z.string().min(1).max(200)).min(2).max(50),
|
|
512
|
+
defaultValue: import_zod2.z.string().optional()
|
|
405
513
|
});
|
|
406
514
|
var ratingScaleElementSchema = baseElementSchema.extend({
|
|
407
|
-
type:
|
|
408
|
-
question:
|
|
409
|
-
min:
|
|
410
|
-
max:
|
|
411
|
-
labels:
|
|
412
|
-
defaultValue:
|
|
515
|
+
type: import_zod2.z.literal("rating_scale" /* RATING_SCALE */),
|
|
516
|
+
question: import_zod2.z.string().min(1).max(500),
|
|
517
|
+
min: import_zod2.z.number().int().min(0).max(10),
|
|
518
|
+
max: import_zod2.z.number().int().min(1).max(10),
|
|
519
|
+
labels: import_zod2.z.record(import_zod2.z.string()).optional(),
|
|
520
|
+
defaultValue: import_zod2.z.number().int().optional()
|
|
413
521
|
});
|
|
414
522
|
var textInputElementSchema = baseElementSchema.extend({
|
|
415
|
-
type:
|
|
416
|
-
label:
|
|
417
|
-
placeholder:
|
|
418
|
-
multiline:
|
|
419
|
-
defaultValue:
|
|
523
|
+
type: import_zod2.z.literal("text_input" /* TEXT_INPUT */),
|
|
524
|
+
label: import_zod2.z.string().min(1).max(200),
|
|
525
|
+
placeholder: import_zod2.z.string().max(200).optional(),
|
|
526
|
+
multiline: import_zod2.z.boolean().optional(),
|
|
527
|
+
defaultValue: import_zod2.z.string().optional()
|
|
420
528
|
});
|
|
421
529
|
var datePickerElementSchema = baseElementSchema.extend({
|
|
422
|
-
type:
|
|
423
|
-
label:
|
|
424
|
-
defaultValue:
|
|
530
|
+
type: import_zod2.z.literal("date_picker" /* DATE_PICKER */),
|
|
531
|
+
label: import_zod2.z.string().min(1).max(200),
|
|
532
|
+
defaultValue: import_zod2.z.string().optional()
|
|
425
533
|
// ISO date string
|
|
426
534
|
});
|
|
427
535
|
var signatureElementSchema = baseElementSchema.extend({
|
|
428
|
-
type:
|
|
429
|
-
label:
|
|
536
|
+
type: import_zod2.z.literal("signature" /* SIGNATURE */),
|
|
537
|
+
label: import_zod2.z.string().min(1).max(200)
|
|
430
538
|
});
|
|
431
539
|
var fileUploadElementSchema = baseElementSchema.extend({
|
|
432
|
-
type:
|
|
433
|
-
label:
|
|
434
|
-
allowedFileTypes:
|
|
435
|
-
maxFileSizeMB:
|
|
540
|
+
type: import_zod2.z.literal("file_upload" /* FILE_UPLOAD */),
|
|
541
|
+
label: import_zod2.z.string().min(1).max(200),
|
|
542
|
+
allowedFileTypes: import_zod2.z.array(import_zod2.z.string()).optional(),
|
|
543
|
+
maxFileSizeMB: import_zod2.z.number().positive().optional()
|
|
436
544
|
});
|
|
437
|
-
var documentElementSchema =
|
|
545
|
+
var documentElementSchema = import_zod2.z.discriminatedUnion("type", [
|
|
438
546
|
headingElementSchema,
|
|
439
547
|
paragraphElementSchema,
|
|
440
548
|
listElementSchema,
|
|
@@ -448,7 +556,7 @@ var documentElementSchema = import_zod.z.discriminatedUnion("type", [
|
|
|
448
556
|
signatureElementSchema,
|
|
449
557
|
fileUploadElementSchema
|
|
450
558
|
]);
|
|
451
|
-
var documentElementWithoutIdSchema =
|
|
559
|
+
var documentElementWithoutIdSchema = import_zod2.z.discriminatedUnion("type", [
|
|
452
560
|
headingElementSchema.omit({ id: true }),
|
|
453
561
|
paragraphElementSchema.omit({ id: true }),
|
|
454
562
|
listElementSchema.omit({ id: true }),
|
|
@@ -462,50 +570,50 @@ var documentElementWithoutIdSchema = import_zod.z.discriminatedUnion("type", [
|
|
|
462
570
|
signatureElementSchema.omit({ id: true }),
|
|
463
571
|
fileUploadElementSchema.omit({ id: true })
|
|
464
572
|
]);
|
|
465
|
-
var createDocumentTemplateSchema =
|
|
466
|
-
title:
|
|
467
|
-
description:
|
|
468
|
-
elements:
|
|
469
|
-
tags:
|
|
573
|
+
var createDocumentTemplateSchema = import_zod2.z.object({
|
|
574
|
+
title: import_zod2.z.string().min(1).max(200),
|
|
575
|
+
description: import_zod2.z.string().max(1e3).optional(),
|
|
576
|
+
elements: import_zod2.z.array(documentElementWithoutIdSchema).min(1).max(100),
|
|
577
|
+
tags: import_zod2.z.array(import_zod2.z.string().min(1).max(50)).max(20).optional()
|
|
470
578
|
});
|
|
471
|
-
var updateDocumentTemplateSchema =
|
|
472
|
-
title:
|
|
473
|
-
description:
|
|
474
|
-
elements:
|
|
475
|
-
tags:
|
|
476
|
-
isActive:
|
|
579
|
+
var updateDocumentTemplateSchema = import_zod2.z.object({
|
|
580
|
+
title: import_zod2.z.string().min(1).max(200).optional(),
|
|
581
|
+
description: import_zod2.z.string().max(1e3).optional(),
|
|
582
|
+
elements: import_zod2.z.array(documentElementWithoutIdSchema).min(1).max(100).optional(),
|
|
583
|
+
tags: import_zod2.z.array(import_zod2.z.string().min(1).max(50)).max(20).optional(),
|
|
584
|
+
isActive: import_zod2.z.boolean().optional()
|
|
477
585
|
});
|
|
478
|
-
var documentTemplateSchema =
|
|
479
|
-
id:
|
|
480
|
-
title:
|
|
481
|
-
description:
|
|
482
|
-
createdAt:
|
|
483
|
-
updatedAt:
|
|
484
|
-
createdBy:
|
|
485
|
-
elements:
|
|
486
|
-
tags:
|
|
487
|
-
version:
|
|
488
|
-
isActive:
|
|
586
|
+
var documentTemplateSchema = import_zod2.z.object({
|
|
587
|
+
id: import_zod2.z.string(),
|
|
588
|
+
title: import_zod2.z.string().min(1).max(200),
|
|
589
|
+
description: import_zod2.z.string().max(1e3).optional(),
|
|
590
|
+
createdAt: import_zod2.z.number(),
|
|
591
|
+
updatedAt: import_zod2.z.number(),
|
|
592
|
+
createdBy: import_zod2.z.string(),
|
|
593
|
+
elements: import_zod2.z.array(documentElementSchema),
|
|
594
|
+
tags: import_zod2.z.array(import_zod2.z.string().min(1).max(50)).max(20).optional(),
|
|
595
|
+
version: import_zod2.z.number().int().positive(),
|
|
596
|
+
isActive: import_zod2.z.boolean()
|
|
489
597
|
});
|
|
490
598
|
|
|
491
599
|
// src/validations/schemas.ts
|
|
492
|
-
var emailSchema =
|
|
493
|
-
var passwordSchema =
|
|
600
|
+
var emailSchema = import_zod3.z.string().email("Invalid email format").min(5, "Email must be at least 5 characters").max(255, "Email must be less than 255 characters");
|
|
601
|
+
var passwordSchema = import_zod3.z.string().min(8, "Password must be at least 8 characters").max(100, "Password must be less than 100 characters").regex(
|
|
494
602
|
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d\w\W]{8,}$/,
|
|
495
603
|
"Password must contain at least one uppercase letter, one lowercase letter, and one number"
|
|
496
604
|
);
|
|
497
|
-
var userRoleSchema =
|
|
498
|
-
var userRolesSchema =
|
|
499
|
-
var timestampSchema =
|
|
605
|
+
var userRoleSchema = import_zod3.z.nativeEnum(UserRole);
|
|
606
|
+
var userRolesSchema = import_zod3.z.array(userRoleSchema).min(1, "User must have at least one role").max(3, "User cannot have more than 3 roles");
|
|
607
|
+
var timestampSchema = import_zod3.z.custom((data) => {
|
|
500
608
|
if (data && typeof data === "object" && "isEqual" in data) {
|
|
501
609
|
return true;
|
|
502
610
|
}
|
|
503
611
|
return data && typeof data === "object" && "toDate" in data && "seconds" in data && "nanoseconds" in data;
|
|
504
612
|
}, "Must be a Timestamp object or serverTimestamp");
|
|
505
|
-
var clinicAdminOptionsSchema =
|
|
506
|
-
isGroupOwner:
|
|
507
|
-
groupToken:
|
|
508
|
-
groupId:
|
|
613
|
+
var clinicAdminOptionsSchema = import_zod3.z.object({
|
|
614
|
+
isGroupOwner: import_zod3.z.boolean(),
|
|
615
|
+
groupToken: import_zod3.z.string().optional(),
|
|
616
|
+
groupId: import_zod3.z.string().optional()
|
|
509
617
|
}).refine(
|
|
510
618
|
(data) => {
|
|
511
619
|
if (!data.isGroupOwner && (!data.groupToken || !data.groupId)) {
|
|
@@ -520,20 +628,20 @@ var clinicAdminOptionsSchema = import_zod2.z.object({
|
|
|
520
628
|
message: "Invalid clinic admin options configuration"
|
|
521
629
|
}
|
|
522
630
|
);
|
|
523
|
-
var createUserOptionsSchema =
|
|
631
|
+
var createUserOptionsSchema = import_zod3.z.object({
|
|
524
632
|
clinicAdminData: clinicAdminOptionsSchema.optional()
|
|
525
633
|
});
|
|
526
|
-
var userSchema =
|
|
527
|
-
uid:
|
|
528
|
-
email:
|
|
529
|
-
roles:
|
|
530
|
-
isAnonymous:
|
|
634
|
+
var userSchema = import_zod3.z.object({
|
|
635
|
+
uid: import_zod3.z.string(),
|
|
636
|
+
email: import_zod3.z.string().email().nullable(),
|
|
637
|
+
roles: import_zod3.z.array(userRoleSchema),
|
|
638
|
+
isAnonymous: import_zod3.z.boolean(),
|
|
531
639
|
createdAt: timestampSchema,
|
|
532
640
|
updatedAt: timestampSchema,
|
|
533
641
|
lastLoginAt: timestampSchema,
|
|
534
|
-
patientProfile:
|
|
535
|
-
practitionerProfile:
|
|
536
|
-
adminProfile:
|
|
642
|
+
patientProfile: import_zod3.z.string().optional(),
|
|
643
|
+
practitionerProfile: import_zod3.z.string().optional(),
|
|
644
|
+
adminProfile: import_zod3.z.string().optional()
|
|
537
645
|
});
|
|
538
646
|
|
|
539
647
|
// src/errors/auth.errors.ts
|
|
@@ -880,7 +988,7 @@ var USER_ERRORS = {
|
|
|
880
988
|
};
|
|
881
989
|
|
|
882
990
|
// src/services/user.service.ts
|
|
883
|
-
var
|
|
991
|
+
var import_zod14 = require("zod");
|
|
884
992
|
|
|
885
993
|
// src/services/patient/patient.service.ts
|
|
886
994
|
var import_firestore9 = require("firebase/firestore");
|
|
@@ -888,7 +996,7 @@ var import_firestore9 = require("firebase/firestore");
|
|
|
888
996
|
// src/services/patient/utils/profile.utils.ts
|
|
889
997
|
var import_firestore6 = require("firebase/firestore");
|
|
890
998
|
var import_storage2 = require("firebase/storage");
|
|
891
|
-
var
|
|
999
|
+
var import_zod8 = require("zod");
|
|
892
1000
|
|
|
893
1001
|
// src/types/patient/medical-info.types.ts
|
|
894
1002
|
var PATIENT_MEDICAL_INFO_COLLECTION = "medical_info";
|
|
@@ -917,11 +1025,11 @@ var Gender = /* @__PURE__ */ ((Gender2) => {
|
|
|
917
1025
|
})(Gender || {});
|
|
918
1026
|
|
|
919
1027
|
// src/validations/patient.schema.ts
|
|
920
|
-
var
|
|
1028
|
+
var import_zod6 = require("zod");
|
|
921
1029
|
var import_firestore2 = require("firebase/firestore");
|
|
922
1030
|
|
|
923
1031
|
// src/validations/patient/medical-info.schema.ts
|
|
924
|
-
var
|
|
1032
|
+
var import_zod5 = require("zod");
|
|
925
1033
|
|
|
926
1034
|
// src/types/patient/allergies.ts
|
|
927
1035
|
var AllergyType = /* @__PURE__ */ ((AllergyType2) => {
|
|
@@ -1010,71 +1118,71 @@ var Contraindication = /* @__PURE__ */ ((Contraindication2) => {
|
|
|
1010
1118
|
})(Contraindication || {});
|
|
1011
1119
|
|
|
1012
1120
|
// src/validations/common.schema.ts
|
|
1013
|
-
var
|
|
1014
|
-
var timestampSchema2 =
|
|
1015
|
-
seconds:
|
|
1016
|
-
nanoseconds:
|
|
1121
|
+
var import_zod4 = require("zod");
|
|
1122
|
+
var timestampSchema2 = import_zod4.z.object({
|
|
1123
|
+
seconds: import_zod4.z.number(),
|
|
1124
|
+
nanoseconds: import_zod4.z.number()
|
|
1017
1125
|
});
|
|
1018
1126
|
|
|
1019
1127
|
// src/validations/patient/medical-info.schema.ts
|
|
1020
|
-
var allergySubtypeSchema =
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1128
|
+
var allergySubtypeSchema = import_zod5.z.union([
|
|
1129
|
+
import_zod5.z.nativeEnum(MedicationAllergySubtype),
|
|
1130
|
+
import_zod5.z.nativeEnum(FoodAllergySubtype),
|
|
1131
|
+
import_zod5.z.nativeEnum(EnvironmentalAllergySubtype),
|
|
1132
|
+
import_zod5.z.nativeEnum(CosmeticAllergySubtype),
|
|
1133
|
+
import_zod5.z.literal("other")
|
|
1026
1134
|
]);
|
|
1027
|
-
var allergySchema =
|
|
1028
|
-
type:
|
|
1135
|
+
var allergySchema = import_zod5.z.object({
|
|
1136
|
+
type: import_zod5.z.nativeEnum(AllergyType),
|
|
1029
1137
|
subtype: allergySubtypeSchema,
|
|
1030
|
-
name:
|
|
1031
|
-
severity:
|
|
1032
|
-
reaction:
|
|
1138
|
+
name: import_zod5.z.string().optional(),
|
|
1139
|
+
severity: import_zod5.z.enum(["mild", "moderate", "severe"]).optional(),
|
|
1140
|
+
reaction: import_zod5.z.string().optional(),
|
|
1033
1141
|
diagnosed: timestampSchema2.optional(),
|
|
1034
|
-
notes:
|
|
1142
|
+
notes: import_zod5.z.string().optional()
|
|
1035
1143
|
});
|
|
1036
|
-
var vitalStatsSchema =
|
|
1037
|
-
height:
|
|
1038
|
-
weight:
|
|
1039
|
-
bloodType:
|
|
1040
|
-
bloodPressure:
|
|
1041
|
-
systolic:
|
|
1042
|
-
diastolic:
|
|
1144
|
+
var vitalStatsSchema = import_zod5.z.object({
|
|
1145
|
+
height: import_zod5.z.number().positive().optional(),
|
|
1146
|
+
weight: import_zod5.z.number().positive().optional(),
|
|
1147
|
+
bloodType: import_zod5.z.enum(["A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-"]).optional(),
|
|
1148
|
+
bloodPressure: import_zod5.z.object({
|
|
1149
|
+
systolic: import_zod5.z.number().min(70).max(200),
|
|
1150
|
+
diastolic: import_zod5.z.number().min(40).max(130),
|
|
1043
1151
|
lastMeasured: timestampSchema2
|
|
1044
1152
|
}).optional()
|
|
1045
1153
|
});
|
|
1046
|
-
var blockingConditionSchema =
|
|
1047
|
-
condition:
|
|
1154
|
+
var blockingConditionSchema = import_zod5.z.object({
|
|
1155
|
+
condition: import_zod5.z.nativeEnum(BlockingCondition),
|
|
1048
1156
|
diagnosedAt: timestampSchema2,
|
|
1049
|
-
notes:
|
|
1050
|
-
isActive:
|
|
1157
|
+
notes: import_zod5.z.string().optional(),
|
|
1158
|
+
isActive: import_zod5.z.boolean()
|
|
1051
1159
|
});
|
|
1052
|
-
var contraindicationSchema =
|
|
1053
|
-
condition:
|
|
1160
|
+
var contraindicationSchema = import_zod5.z.object({
|
|
1161
|
+
condition: import_zod5.z.nativeEnum(Contraindication),
|
|
1054
1162
|
lastOccurrence: timestampSchema2,
|
|
1055
|
-
frequency:
|
|
1056
|
-
notes:
|
|
1057
|
-
isActive:
|
|
1163
|
+
frequency: import_zod5.z.enum(["rare", "occasional", "frequent"]),
|
|
1164
|
+
notes: import_zod5.z.string().optional(),
|
|
1165
|
+
isActive: import_zod5.z.boolean()
|
|
1058
1166
|
});
|
|
1059
|
-
var medicationSchema =
|
|
1060
|
-
name:
|
|
1061
|
-
dosage:
|
|
1062
|
-
frequency:
|
|
1167
|
+
var medicationSchema = import_zod5.z.object({
|
|
1168
|
+
name: import_zod5.z.string().min(1),
|
|
1169
|
+
dosage: import_zod5.z.string().min(1),
|
|
1170
|
+
frequency: import_zod5.z.string().min(1),
|
|
1063
1171
|
startDate: timestampSchema2,
|
|
1064
1172
|
endDate: timestampSchema2.optional(),
|
|
1065
|
-
prescribedBy:
|
|
1173
|
+
prescribedBy: import_zod5.z.string().optional()
|
|
1066
1174
|
});
|
|
1067
|
-
var patientMedicalInfoSchema =
|
|
1068
|
-
patientId:
|
|
1175
|
+
var patientMedicalInfoSchema = import_zod5.z.object({
|
|
1176
|
+
patientId: import_zod5.z.string(),
|
|
1069
1177
|
vitalStats: vitalStatsSchema,
|
|
1070
|
-
blockingConditions:
|
|
1071
|
-
contraindications:
|
|
1072
|
-
allergies:
|
|
1073
|
-
currentMedications:
|
|
1074
|
-
emergencyNotes:
|
|
1178
|
+
blockingConditions: import_zod5.z.array(blockingConditionSchema),
|
|
1179
|
+
contraindications: import_zod5.z.array(contraindicationSchema),
|
|
1180
|
+
allergies: import_zod5.z.array(allergySchema),
|
|
1181
|
+
currentMedications: import_zod5.z.array(medicationSchema),
|
|
1182
|
+
emergencyNotes: import_zod5.z.string().optional(),
|
|
1075
1183
|
lastUpdated: timestampSchema2,
|
|
1076
|
-
updatedBy:
|
|
1077
|
-
verifiedBy:
|
|
1184
|
+
updatedBy: import_zod5.z.string(),
|
|
1185
|
+
verifiedBy: import_zod5.z.string().optional(),
|
|
1078
1186
|
verifiedAt: timestampSchema2.optional()
|
|
1079
1187
|
});
|
|
1080
1188
|
var createPatientMedicalInfoSchema = patientMedicalInfoSchema.omit({
|
|
@@ -1088,141 +1196,141 @@ var updatePatientMedicalInfoSchema = createPatientMedicalInfoSchema.partial();
|
|
|
1088
1196
|
var updateVitalStatsSchema = vitalStatsSchema;
|
|
1089
1197
|
var addAllergySchema = allergySchema;
|
|
1090
1198
|
var updateAllergySchema = allergySchema.partial().extend({
|
|
1091
|
-
allergyIndex:
|
|
1199
|
+
allergyIndex: import_zod5.z.number().min(0)
|
|
1092
1200
|
});
|
|
1093
1201
|
var addBlockingConditionSchema = blockingConditionSchema;
|
|
1094
1202
|
var updateBlockingConditionSchema = blockingConditionSchema.partial().extend({
|
|
1095
|
-
conditionIndex:
|
|
1203
|
+
conditionIndex: import_zod5.z.number().min(0)
|
|
1096
1204
|
});
|
|
1097
1205
|
var addContraindicationSchema = contraindicationSchema;
|
|
1098
1206
|
var updateContraindicationSchema = contraindicationSchema.partial().extend({
|
|
1099
|
-
contraindicationIndex:
|
|
1207
|
+
contraindicationIndex: import_zod5.z.number().min(0)
|
|
1100
1208
|
});
|
|
1101
1209
|
var addMedicationSchema = medicationSchema;
|
|
1102
1210
|
var updateMedicationSchema = medicationSchema.partial().extend({
|
|
1103
|
-
medicationIndex:
|
|
1211
|
+
medicationIndex: import_zod5.z.number().min(0)
|
|
1104
1212
|
});
|
|
1105
1213
|
|
|
1106
1214
|
// src/validations/patient.schema.ts
|
|
1107
|
-
var locationDataSchema =
|
|
1108
|
-
latitude:
|
|
1109
|
-
longitude:
|
|
1110
|
-
geohash:
|
|
1215
|
+
var locationDataSchema = import_zod6.z.object({
|
|
1216
|
+
latitude: import_zod6.z.number().min(-90).max(90),
|
|
1217
|
+
longitude: import_zod6.z.number().min(-180).max(180),
|
|
1218
|
+
geohash: import_zod6.z.string().optional()
|
|
1111
1219
|
});
|
|
1112
|
-
var addressDataSchema =
|
|
1113
|
-
address:
|
|
1114
|
-
city:
|
|
1115
|
-
country:
|
|
1116
|
-
postalCode:
|
|
1220
|
+
var addressDataSchema = import_zod6.z.object({
|
|
1221
|
+
address: import_zod6.z.string(),
|
|
1222
|
+
city: import_zod6.z.string(),
|
|
1223
|
+
country: import_zod6.z.string(),
|
|
1224
|
+
postalCode: import_zod6.z.string()
|
|
1117
1225
|
});
|
|
1118
|
-
var emergencyContactSchema =
|
|
1119
|
-
name:
|
|
1120
|
-
relationship:
|
|
1121
|
-
phoneNumber:
|
|
1122
|
-
isNotifiable:
|
|
1226
|
+
var emergencyContactSchema = import_zod6.z.object({
|
|
1227
|
+
name: import_zod6.z.string(),
|
|
1228
|
+
relationship: import_zod6.z.string(),
|
|
1229
|
+
phoneNumber: import_zod6.z.string(),
|
|
1230
|
+
isNotifiable: import_zod6.z.boolean()
|
|
1123
1231
|
});
|
|
1124
|
-
var gamificationSchema =
|
|
1125
|
-
level:
|
|
1126
|
-
points:
|
|
1232
|
+
var gamificationSchema = import_zod6.z.object({
|
|
1233
|
+
level: import_zod6.z.number(),
|
|
1234
|
+
points: import_zod6.z.number()
|
|
1127
1235
|
});
|
|
1128
|
-
var patientLocationInfoSchema =
|
|
1129
|
-
patientId:
|
|
1130
|
-
userRef:
|
|
1236
|
+
var patientLocationInfoSchema = import_zod6.z.object({
|
|
1237
|
+
patientId: import_zod6.z.string(),
|
|
1238
|
+
userRef: import_zod6.z.string(),
|
|
1131
1239
|
locationData: locationDataSchema,
|
|
1132
|
-
createdAt:
|
|
1133
|
-
updatedAt:
|
|
1240
|
+
createdAt: import_zod6.z.instanceof(import_firestore2.Timestamp),
|
|
1241
|
+
updatedAt: import_zod6.z.instanceof(import_firestore2.Timestamp)
|
|
1134
1242
|
});
|
|
1135
|
-
var createPatientLocationInfoSchema =
|
|
1136
|
-
patientId:
|
|
1137
|
-
userRef:
|
|
1243
|
+
var createPatientLocationInfoSchema = import_zod6.z.object({
|
|
1244
|
+
patientId: import_zod6.z.string(),
|
|
1245
|
+
userRef: import_zod6.z.string(),
|
|
1138
1246
|
locationData: locationDataSchema
|
|
1139
1247
|
});
|
|
1140
|
-
var patientSensitiveInfoSchema =
|
|
1141
|
-
patientId:
|
|
1142
|
-
userRef:
|
|
1143
|
-
photoUrl:
|
|
1144
|
-
firstName:
|
|
1145
|
-
lastName:
|
|
1146
|
-
dateOfBirth:
|
|
1147
|
-
gender:
|
|
1148
|
-
email:
|
|
1149
|
-
phoneNumber:
|
|
1150
|
-
alternativePhoneNumber:
|
|
1248
|
+
var patientSensitiveInfoSchema = import_zod6.z.object({
|
|
1249
|
+
patientId: import_zod6.z.string(),
|
|
1250
|
+
userRef: import_zod6.z.string(),
|
|
1251
|
+
photoUrl: import_zod6.z.string().optional(),
|
|
1252
|
+
firstName: import_zod6.z.string().min(2),
|
|
1253
|
+
lastName: import_zod6.z.string().min(2),
|
|
1254
|
+
dateOfBirth: import_zod6.z.instanceof(import_firestore2.Timestamp).nullable(),
|
|
1255
|
+
gender: import_zod6.z.nativeEnum(Gender),
|
|
1256
|
+
email: import_zod6.z.string().email().optional(),
|
|
1257
|
+
phoneNumber: import_zod6.z.string().optional(),
|
|
1258
|
+
alternativePhoneNumber: import_zod6.z.string().optional(),
|
|
1151
1259
|
addressData: addressDataSchema.optional(),
|
|
1152
|
-
emergencyContacts:
|
|
1153
|
-
createdAt:
|
|
1154
|
-
updatedAt:
|
|
1260
|
+
emergencyContacts: import_zod6.z.array(emergencyContactSchema).optional(),
|
|
1261
|
+
createdAt: import_zod6.z.instanceof(import_firestore2.Timestamp),
|
|
1262
|
+
updatedAt: import_zod6.z.instanceof(import_firestore2.Timestamp)
|
|
1155
1263
|
});
|
|
1156
|
-
var patientDoctorSchema =
|
|
1157
|
-
userRef:
|
|
1158
|
-
assignedAt:
|
|
1159
|
-
assignedBy:
|
|
1160
|
-
isActive:
|
|
1161
|
-
notes:
|
|
1264
|
+
var patientDoctorSchema = import_zod6.z.object({
|
|
1265
|
+
userRef: import_zod6.z.string(),
|
|
1266
|
+
assignedAt: import_zod6.z.instanceof(import_firestore2.Timestamp),
|
|
1267
|
+
assignedBy: import_zod6.z.string().optional(),
|
|
1268
|
+
isActive: import_zod6.z.boolean(),
|
|
1269
|
+
notes: import_zod6.z.string().optional()
|
|
1162
1270
|
});
|
|
1163
|
-
var patientClinicSchema =
|
|
1164
|
-
clinicId:
|
|
1165
|
-
assignedAt:
|
|
1166
|
-
assignedBy:
|
|
1167
|
-
isActive:
|
|
1168
|
-
notes:
|
|
1271
|
+
var patientClinicSchema = import_zod6.z.object({
|
|
1272
|
+
clinicId: import_zod6.z.string(),
|
|
1273
|
+
assignedAt: import_zod6.z.instanceof(import_firestore2.Timestamp),
|
|
1274
|
+
assignedBy: import_zod6.z.string().optional(),
|
|
1275
|
+
isActive: import_zod6.z.boolean(),
|
|
1276
|
+
notes: import_zod6.z.string().optional()
|
|
1169
1277
|
});
|
|
1170
|
-
var patientProfileSchema =
|
|
1171
|
-
id:
|
|
1172
|
-
userRef:
|
|
1173
|
-
displayName:
|
|
1174
|
-
profilePhoto:
|
|
1278
|
+
var patientProfileSchema = import_zod6.z.object({
|
|
1279
|
+
id: import_zod6.z.string(),
|
|
1280
|
+
userRef: import_zod6.z.string(),
|
|
1281
|
+
displayName: import_zod6.z.string(),
|
|
1282
|
+
profilePhoto: import_zod6.z.string().url().nullable(),
|
|
1175
1283
|
gamification: gamificationSchema,
|
|
1176
|
-
expoTokens:
|
|
1177
|
-
isActive:
|
|
1178
|
-
isVerified:
|
|
1179
|
-
doctors:
|
|
1180
|
-
clinics:
|
|
1181
|
-
doctorIds:
|
|
1182
|
-
clinicIds:
|
|
1183
|
-
createdAt:
|
|
1184
|
-
updatedAt:
|
|
1284
|
+
expoTokens: import_zod6.z.array(import_zod6.z.string()),
|
|
1285
|
+
isActive: import_zod6.z.boolean(),
|
|
1286
|
+
isVerified: import_zod6.z.boolean(),
|
|
1287
|
+
doctors: import_zod6.z.array(patientDoctorSchema),
|
|
1288
|
+
clinics: import_zod6.z.array(patientClinicSchema),
|
|
1289
|
+
doctorIds: import_zod6.z.array(import_zod6.z.string()),
|
|
1290
|
+
clinicIds: import_zod6.z.array(import_zod6.z.string()),
|
|
1291
|
+
createdAt: import_zod6.z.instanceof(import_firestore2.Timestamp),
|
|
1292
|
+
updatedAt: import_zod6.z.instanceof(import_firestore2.Timestamp)
|
|
1185
1293
|
});
|
|
1186
|
-
var createPatientProfileSchema =
|
|
1187
|
-
userRef:
|
|
1188
|
-
displayName:
|
|
1189
|
-
profilePhoto:
|
|
1190
|
-
expoTokens:
|
|
1294
|
+
var createPatientProfileSchema = import_zod6.z.object({
|
|
1295
|
+
userRef: import_zod6.z.string(),
|
|
1296
|
+
displayName: import_zod6.z.string(),
|
|
1297
|
+
profilePhoto: import_zod6.z.string().url().nullable().optional(),
|
|
1298
|
+
expoTokens: import_zod6.z.array(import_zod6.z.string()),
|
|
1191
1299
|
gamification: gamificationSchema.optional(),
|
|
1192
|
-
isActive:
|
|
1193
|
-
isVerified:
|
|
1194
|
-
doctors:
|
|
1195
|
-
clinics:
|
|
1196
|
-
doctorIds:
|
|
1197
|
-
clinicIds:
|
|
1300
|
+
isActive: import_zod6.z.boolean(),
|
|
1301
|
+
isVerified: import_zod6.z.boolean(),
|
|
1302
|
+
doctors: import_zod6.z.array(patientDoctorSchema).optional(),
|
|
1303
|
+
clinics: import_zod6.z.array(patientClinicSchema).optional(),
|
|
1304
|
+
doctorIds: import_zod6.z.array(import_zod6.z.string()).optional(),
|
|
1305
|
+
clinicIds: import_zod6.z.array(import_zod6.z.string()).optional()
|
|
1198
1306
|
});
|
|
1199
|
-
var createPatientSensitiveInfoSchema =
|
|
1200
|
-
patientId:
|
|
1201
|
-
userRef:
|
|
1202
|
-
photoUrl:
|
|
1203
|
-
firstName:
|
|
1204
|
-
lastName:
|
|
1205
|
-
dateOfBirth:
|
|
1206
|
-
gender:
|
|
1207
|
-
email:
|
|
1208
|
-
phoneNumber:
|
|
1209
|
-
alternativePhoneNumber:
|
|
1307
|
+
var createPatientSensitiveInfoSchema = import_zod6.z.object({
|
|
1308
|
+
patientId: import_zod6.z.string(),
|
|
1309
|
+
userRef: import_zod6.z.string(),
|
|
1310
|
+
photoUrl: import_zod6.z.string().optional(),
|
|
1311
|
+
firstName: import_zod6.z.string().min(2),
|
|
1312
|
+
lastName: import_zod6.z.string().min(2),
|
|
1313
|
+
dateOfBirth: import_zod6.z.instanceof(import_firestore2.Timestamp).nullable(),
|
|
1314
|
+
gender: import_zod6.z.nativeEnum(Gender),
|
|
1315
|
+
email: import_zod6.z.string().email().optional(),
|
|
1316
|
+
phoneNumber: import_zod6.z.string().optional(),
|
|
1317
|
+
alternativePhoneNumber: import_zod6.z.string().optional(),
|
|
1210
1318
|
addressData: addressDataSchema.optional(),
|
|
1211
|
-
emergencyContacts:
|
|
1319
|
+
emergencyContacts: import_zod6.z.array(emergencyContactSchema).optional()
|
|
1212
1320
|
});
|
|
1213
|
-
var searchPatientsSchema =
|
|
1214
|
-
clinicId:
|
|
1215
|
-
practitionerId:
|
|
1321
|
+
var searchPatientsSchema = import_zod6.z.object({
|
|
1322
|
+
clinicId: import_zod6.z.string().optional(),
|
|
1323
|
+
practitionerId: import_zod6.z.string().optional()
|
|
1216
1324
|
}).refine((data) => data.clinicId || data.practitionerId, {
|
|
1217
1325
|
message: "At least one of clinicId or practitionerId must be provided",
|
|
1218
1326
|
path: []
|
|
1219
1327
|
// Optional: specify a path like ['clinicId'] or ['practitionerId']
|
|
1220
1328
|
});
|
|
1221
|
-
var requesterInfoSchema =
|
|
1222
|
-
id:
|
|
1223
|
-
role:
|
|
1224
|
-
associatedClinicId:
|
|
1225
|
-
associatedPractitionerId:
|
|
1329
|
+
var requesterInfoSchema = import_zod6.z.object({
|
|
1330
|
+
id: import_zod6.z.string(),
|
|
1331
|
+
role: import_zod6.z.enum(["clinic_admin", "practitioner"]),
|
|
1332
|
+
associatedClinicId: import_zod6.z.string().optional(),
|
|
1333
|
+
associatedPractitionerId: import_zod6.z.string().optional()
|
|
1226
1334
|
}).refine(
|
|
1227
1335
|
(data) => {
|
|
1228
1336
|
if (data.role === "clinic_admin") {
|
|
@@ -1243,7 +1351,7 @@ var import_firestore4 = require("firebase/firestore");
|
|
|
1243
1351
|
|
|
1244
1352
|
// src/services/patient/utils/sensitive.utils.ts
|
|
1245
1353
|
var import_firestore3 = require("firebase/firestore");
|
|
1246
|
-
var
|
|
1354
|
+
var import_zod7 = require("zod");
|
|
1247
1355
|
var createSensitiveInfoUtil = async (db, data, requesterUserId) => {
|
|
1248
1356
|
try {
|
|
1249
1357
|
if (data.userRef !== requesterUserId) {
|
|
@@ -1268,7 +1376,7 @@ var createSensitiveInfoUtil = async (db, data, requesterUserId) => {
|
|
|
1268
1376
|
}
|
|
1269
1377
|
return createdDoc.data();
|
|
1270
1378
|
} catch (error) {
|
|
1271
|
-
if (error instanceof
|
|
1379
|
+
if (error instanceof import_zod7.z.ZodError) {
|
|
1272
1380
|
throw new Error("Invalid sensitive info data: " + error.message);
|
|
1273
1381
|
}
|
|
1274
1382
|
throw error;
|
|
@@ -1501,9 +1609,9 @@ var addAllergyUtil = async (db, patientId, data, userRef) => {
|
|
|
1501
1609
|
var updateAllergyUtil = async (db, patientId, data, userRef) => {
|
|
1502
1610
|
const validatedData = updateAllergySchema.parse(data);
|
|
1503
1611
|
const { allergyIndex, ...updateData } = validatedData;
|
|
1504
|
-
const
|
|
1505
|
-
if (!
|
|
1506
|
-
const medicalInfo =
|
|
1612
|
+
const doc30 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1613
|
+
if (!doc30.exists()) throw new Error("Medical info not found");
|
|
1614
|
+
const medicalInfo = doc30.data();
|
|
1507
1615
|
if (allergyIndex >= medicalInfo.allergies.length) {
|
|
1508
1616
|
throw new Error("Invalid allergy index");
|
|
1509
1617
|
}
|
|
@@ -1519,9 +1627,9 @@ var updateAllergyUtil = async (db, patientId, data, userRef) => {
|
|
|
1519
1627
|
});
|
|
1520
1628
|
};
|
|
1521
1629
|
var removeAllergyUtil = async (db, patientId, allergyIndex, userRef) => {
|
|
1522
|
-
const
|
|
1523
|
-
if (!
|
|
1524
|
-
const medicalInfo =
|
|
1630
|
+
const doc30 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1631
|
+
if (!doc30.exists()) throw new Error("Medical info not found");
|
|
1632
|
+
const medicalInfo = doc30.data();
|
|
1525
1633
|
if (allergyIndex >= medicalInfo.allergies.length) {
|
|
1526
1634
|
throw new Error("Invalid allergy index");
|
|
1527
1635
|
}
|
|
@@ -1546,9 +1654,9 @@ var addBlockingConditionUtil = async (db, patientId, data, userRef) => {
|
|
|
1546
1654
|
var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
|
|
1547
1655
|
const validatedData = updateBlockingConditionSchema.parse(data);
|
|
1548
1656
|
const { conditionIndex, ...updateData } = validatedData;
|
|
1549
|
-
const
|
|
1550
|
-
if (!
|
|
1551
|
-
const medicalInfo =
|
|
1657
|
+
const doc30 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1658
|
+
if (!doc30.exists()) throw new Error("Medical info not found");
|
|
1659
|
+
const medicalInfo = doc30.data();
|
|
1552
1660
|
if (conditionIndex >= medicalInfo.blockingConditions.length) {
|
|
1553
1661
|
throw new Error("Invalid blocking condition index");
|
|
1554
1662
|
}
|
|
@@ -1564,9 +1672,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, userRef) => {
|
|
|
1564
1672
|
});
|
|
1565
1673
|
};
|
|
1566
1674
|
var removeBlockingConditionUtil = async (db, patientId, conditionIndex, userRef) => {
|
|
1567
|
-
const
|
|
1568
|
-
if (!
|
|
1569
|
-
const medicalInfo =
|
|
1675
|
+
const doc30 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1676
|
+
if (!doc30.exists()) throw new Error("Medical info not found");
|
|
1677
|
+
const medicalInfo = doc30.data();
|
|
1570
1678
|
if (conditionIndex >= medicalInfo.blockingConditions.length) {
|
|
1571
1679
|
throw new Error("Invalid blocking condition index");
|
|
1572
1680
|
}
|
|
@@ -1591,9 +1699,9 @@ var addContraindicationUtil = async (db, patientId, data, userRef) => {
|
|
|
1591
1699
|
var updateContraindicationUtil = async (db, patientId, data, userRef) => {
|
|
1592
1700
|
const validatedData = updateContraindicationSchema.parse(data);
|
|
1593
1701
|
const { contraindicationIndex, ...updateData } = validatedData;
|
|
1594
|
-
const
|
|
1595
|
-
if (!
|
|
1596
|
-
const medicalInfo =
|
|
1702
|
+
const doc30 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1703
|
+
if (!doc30.exists()) throw new Error("Medical info not found");
|
|
1704
|
+
const medicalInfo = doc30.data();
|
|
1597
1705
|
if (contraindicationIndex >= medicalInfo.contraindications.length) {
|
|
1598
1706
|
throw new Error("Invalid contraindication index");
|
|
1599
1707
|
}
|
|
@@ -1609,9 +1717,9 @@ var updateContraindicationUtil = async (db, patientId, data, userRef) => {
|
|
|
1609
1717
|
});
|
|
1610
1718
|
};
|
|
1611
1719
|
var removeContraindicationUtil = async (db, patientId, contraindicationIndex, userRef) => {
|
|
1612
|
-
const
|
|
1613
|
-
if (!
|
|
1614
|
-
const medicalInfo =
|
|
1720
|
+
const doc30 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1721
|
+
if (!doc30.exists()) throw new Error("Medical info not found");
|
|
1722
|
+
const medicalInfo = doc30.data();
|
|
1615
1723
|
if (contraindicationIndex >= medicalInfo.contraindications.length) {
|
|
1616
1724
|
throw new Error("Invalid contraindication index");
|
|
1617
1725
|
}
|
|
@@ -1636,9 +1744,9 @@ var addMedicationUtil = async (db, patientId, data, userRef) => {
|
|
|
1636
1744
|
var updateMedicationUtil = async (db, patientId, data, userRef) => {
|
|
1637
1745
|
const validatedData = updateMedicationSchema.parse(data);
|
|
1638
1746
|
const { medicationIndex, ...updateData } = validatedData;
|
|
1639
|
-
const
|
|
1640
|
-
if (!
|
|
1641
|
-
const medicalInfo =
|
|
1747
|
+
const doc30 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1748
|
+
if (!doc30.exists()) throw new Error("Medical info not found");
|
|
1749
|
+
const medicalInfo = doc30.data();
|
|
1642
1750
|
if (medicationIndex >= medicalInfo.currentMedications.length) {
|
|
1643
1751
|
throw new Error("Invalid medication index");
|
|
1644
1752
|
}
|
|
@@ -1654,9 +1762,9 @@ var updateMedicationUtil = async (db, patientId, data, userRef) => {
|
|
|
1654
1762
|
});
|
|
1655
1763
|
};
|
|
1656
1764
|
var removeMedicationUtil = async (db, patientId, medicationIndex, userRef) => {
|
|
1657
|
-
const
|
|
1658
|
-
if (!
|
|
1659
|
-
const medicalInfo =
|
|
1765
|
+
const doc30 = await (0, import_firestore5.getDoc)(getMedicalInfoDocRef(db, patientId));
|
|
1766
|
+
if (!doc30.exists()) throw new Error("Medical info not found");
|
|
1767
|
+
const medicalInfo = doc30.data();
|
|
1660
1768
|
if (medicationIndex >= medicalInfo.currentMedications.length) {
|
|
1661
1769
|
throw new Error("Invalid medication index");
|
|
1662
1770
|
}
|
|
@@ -1746,7 +1854,7 @@ var createPatientProfileUtil = async (db, data, generateId2) => {
|
|
|
1746
1854
|
return patientDoc.data();
|
|
1747
1855
|
} catch (error) {
|
|
1748
1856
|
console.error(`[createPatientProfileUtil] Error in patient profile creation:`, error);
|
|
1749
|
-
if (error instanceof
|
|
1857
|
+
if (error instanceof import_zod8.z.ZodError) {
|
|
1750
1858
|
throw new Error("Invalid patient data: " + error.message);
|
|
1751
1859
|
}
|
|
1752
1860
|
throw error;
|
|
@@ -1934,7 +2042,7 @@ var searchPatientsUtil = async (db, params, requester) => {
|
|
|
1934
2042
|
try {
|
|
1935
2043
|
const finalQuery = (0, import_firestore6.query)(patientsCollectionRef, ...constraints);
|
|
1936
2044
|
const querySnapshot = await (0, import_firestore6.getDocs)(finalQuery);
|
|
1937
|
-
const patients = querySnapshot.docs.map((
|
|
2045
|
+
const patients = querySnapshot.docs.map((doc30) => doc30.data());
|
|
1938
2046
|
console.log(`[searchPatientsUtil] Found ${patients.length} patients matching criteria.`);
|
|
1939
2047
|
return patients;
|
|
1940
2048
|
} catch (error) {
|
|
@@ -1958,8 +2066,8 @@ var getAllPatientsUtil = async (db, options) => {
|
|
|
1958
2066
|
}
|
|
1959
2067
|
const patientsSnapshot = await (0, import_firestore6.getDocs)(q);
|
|
1960
2068
|
const patients = [];
|
|
1961
|
-
patientsSnapshot.forEach((
|
|
1962
|
-
patients.push(
|
|
2069
|
+
patientsSnapshot.forEach((doc30) => {
|
|
2070
|
+
patients.push(doc30.data());
|
|
1963
2071
|
});
|
|
1964
2072
|
console.log(`[getAllPatientsUtil] Found ${patients.length} patients`);
|
|
1965
2073
|
return patients;
|
|
@@ -1973,7 +2081,7 @@ var getAllPatientsUtil = async (db, options) => {
|
|
|
1973
2081
|
|
|
1974
2082
|
// src/services/patient/utils/location.utils.ts
|
|
1975
2083
|
var import_firestore7 = require("firebase/firestore");
|
|
1976
|
-
var
|
|
2084
|
+
var import_zod9 = require("zod");
|
|
1977
2085
|
var import_geofire_common = require("geofire-common");
|
|
1978
2086
|
var updatePatientLocationUtil = async (db, patientId, latitude, longitude) => {
|
|
1979
2087
|
const locationData = {
|
|
@@ -2012,7 +2120,7 @@ var createLocationInfoUtil = async (db, data, requesterId) => {
|
|
|
2012
2120
|
}
|
|
2013
2121
|
return locationDoc.data();
|
|
2014
2122
|
} catch (error) {
|
|
2015
|
-
if (error instanceof
|
|
2123
|
+
if (error instanceof import_zod9.z.ZodError) {
|
|
2016
2124
|
throw new Error("Invalid location data: " + error.message);
|
|
2017
2125
|
}
|
|
2018
2126
|
throw error;
|
|
@@ -2506,11 +2614,11 @@ var SubscriptionModel = /* @__PURE__ */ ((SubscriptionModel2) => {
|
|
|
2506
2614
|
})(SubscriptionModel || {});
|
|
2507
2615
|
|
|
2508
2616
|
// src/validations/clinic.schema.ts
|
|
2509
|
-
var
|
|
2617
|
+
var import_zod12 = require("zod");
|
|
2510
2618
|
var import_firestore11 = require("firebase/firestore");
|
|
2511
2619
|
|
|
2512
2620
|
// src/validations/practitioner.schema.ts
|
|
2513
|
-
var
|
|
2621
|
+
var import_zod11 = require("zod");
|
|
2514
2622
|
var import_firestore10 = require("firebase/firestore");
|
|
2515
2623
|
|
|
2516
2624
|
// src/backoffice/types/static/certification.types.ts
|
|
@@ -2554,128 +2662,128 @@ var PractitionerTokenStatus = /* @__PURE__ */ ((PractitionerTokenStatus2) => {
|
|
|
2554
2662
|
})(PractitionerTokenStatus || {});
|
|
2555
2663
|
|
|
2556
2664
|
// src/validations/reviews.schema.ts
|
|
2557
|
-
var
|
|
2558
|
-
var baseReviewSchema =
|
|
2559
|
-
id:
|
|
2560
|
-
patientId:
|
|
2561
|
-
fullReviewId:
|
|
2562
|
-
createdAt:
|
|
2563
|
-
updatedAt:
|
|
2564
|
-
comment:
|
|
2565
|
-
isVerified:
|
|
2566
|
-
isPublished:
|
|
2665
|
+
var import_zod10 = require("zod");
|
|
2666
|
+
var baseReviewSchema = import_zod10.z.object({
|
|
2667
|
+
id: import_zod10.z.string().min(1),
|
|
2668
|
+
patientId: import_zod10.z.string().min(1),
|
|
2669
|
+
fullReviewId: import_zod10.z.string().min(1),
|
|
2670
|
+
createdAt: import_zod10.z.date(),
|
|
2671
|
+
updatedAt: import_zod10.z.date(),
|
|
2672
|
+
comment: import_zod10.z.string().min(1).max(2e3),
|
|
2673
|
+
isVerified: import_zod10.z.boolean(),
|
|
2674
|
+
isPublished: import_zod10.z.boolean()
|
|
2567
2675
|
});
|
|
2568
|
-
var baseReviewCreateSchema =
|
|
2569
|
-
patientId:
|
|
2570
|
-
comment:
|
|
2571
|
-
isVerified:
|
|
2572
|
-
isPublished:
|
|
2676
|
+
var baseReviewCreateSchema = import_zod10.z.object({
|
|
2677
|
+
patientId: import_zod10.z.string().min(1),
|
|
2678
|
+
comment: import_zod10.z.string().min(1).max(2e3),
|
|
2679
|
+
isVerified: import_zod10.z.boolean().default(false),
|
|
2680
|
+
isPublished: import_zod10.z.boolean().default(true)
|
|
2573
2681
|
});
|
|
2574
2682
|
var clinicReviewSchema = baseReviewSchema.extend({
|
|
2575
|
-
clinicId:
|
|
2576
|
-
cleanliness:
|
|
2577
|
-
facilities:
|
|
2578
|
-
staffFriendliness:
|
|
2579
|
-
waitingTime:
|
|
2580
|
-
accessibility:
|
|
2581
|
-
overallRating:
|
|
2582
|
-
wouldRecommend:
|
|
2683
|
+
clinicId: import_zod10.z.string().min(1),
|
|
2684
|
+
cleanliness: import_zod10.z.number().min(1).max(5),
|
|
2685
|
+
facilities: import_zod10.z.number().min(1).max(5),
|
|
2686
|
+
staffFriendliness: import_zod10.z.number().min(1).max(5),
|
|
2687
|
+
waitingTime: import_zod10.z.number().min(1).max(5),
|
|
2688
|
+
accessibility: import_zod10.z.number().min(1).max(5),
|
|
2689
|
+
overallRating: import_zod10.z.number().min(1).max(5),
|
|
2690
|
+
wouldRecommend: import_zod10.z.boolean()
|
|
2583
2691
|
});
|
|
2584
2692
|
var createClinicReviewSchema = baseReviewCreateSchema.extend({
|
|
2585
|
-
clinicId:
|
|
2586
|
-
cleanliness:
|
|
2587
|
-
facilities:
|
|
2588
|
-
staffFriendliness:
|
|
2589
|
-
waitingTime:
|
|
2590
|
-
accessibility:
|
|
2591
|
-
wouldRecommend:
|
|
2693
|
+
clinicId: import_zod10.z.string().min(1),
|
|
2694
|
+
cleanliness: import_zod10.z.number().min(1).max(5),
|
|
2695
|
+
facilities: import_zod10.z.number().min(1).max(5),
|
|
2696
|
+
staffFriendliness: import_zod10.z.number().min(1).max(5),
|
|
2697
|
+
waitingTime: import_zod10.z.number().min(1).max(5),
|
|
2698
|
+
accessibility: import_zod10.z.number().min(1).max(5),
|
|
2699
|
+
wouldRecommend: import_zod10.z.boolean()
|
|
2592
2700
|
});
|
|
2593
2701
|
var practitionerReviewSchema = baseReviewSchema.extend({
|
|
2594
|
-
practitionerId:
|
|
2595
|
-
knowledgeAndExpertise:
|
|
2596
|
-
communicationSkills:
|
|
2597
|
-
bedSideManner:
|
|
2598
|
-
thoroughness:
|
|
2599
|
-
trustworthiness:
|
|
2600
|
-
overallRating:
|
|
2601
|
-
wouldRecommend:
|
|
2702
|
+
practitionerId: import_zod10.z.string().min(1),
|
|
2703
|
+
knowledgeAndExpertise: import_zod10.z.number().min(1).max(5),
|
|
2704
|
+
communicationSkills: import_zod10.z.number().min(1).max(5),
|
|
2705
|
+
bedSideManner: import_zod10.z.number().min(1).max(5),
|
|
2706
|
+
thoroughness: import_zod10.z.number().min(1).max(5),
|
|
2707
|
+
trustworthiness: import_zod10.z.number().min(1).max(5),
|
|
2708
|
+
overallRating: import_zod10.z.number().min(1).max(5),
|
|
2709
|
+
wouldRecommend: import_zod10.z.boolean()
|
|
2602
2710
|
});
|
|
2603
2711
|
var createPractitionerReviewSchema = baseReviewCreateSchema.extend({
|
|
2604
|
-
practitionerId:
|
|
2605
|
-
knowledgeAndExpertise:
|
|
2606
|
-
communicationSkills:
|
|
2607
|
-
bedSideManner:
|
|
2608
|
-
thoroughness:
|
|
2609
|
-
trustworthiness:
|
|
2610
|
-
wouldRecommend:
|
|
2712
|
+
practitionerId: import_zod10.z.string().min(1),
|
|
2713
|
+
knowledgeAndExpertise: import_zod10.z.number().min(1).max(5),
|
|
2714
|
+
communicationSkills: import_zod10.z.number().min(1).max(5),
|
|
2715
|
+
bedSideManner: import_zod10.z.number().min(1).max(5),
|
|
2716
|
+
thoroughness: import_zod10.z.number().min(1).max(5),
|
|
2717
|
+
trustworthiness: import_zod10.z.number().min(1).max(5),
|
|
2718
|
+
wouldRecommend: import_zod10.z.boolean()
|
|
2611
2719
|
});
|
|
2612
2720
|
var procedureReviewSchema = baseReviewSchema.extend({
|
|
2613
|
-
procedureId:
|
|
2614
|
-
effectivenessOfTreatment:
|
|
2615
|
-
outcomeExplanation:
|
|
2616
|
-
painManagement:
|
|
2617
|
-
followUpCare:
|
|
2618
|
-
valueForMoney:
|
|
2619
|
-
overallRating:
|
|
2620
|
-
wouldRecommend:
|
|
2721
|
+
procedureId: import_zod10.z.string().min(1),
|
|
2722
|
+
effectivenessOfTreatment: import_zod10.z.number().min(1).max(5),
|
|
2723
|
+
outcomeExplanation: import_zod10.z.number().min(1).max(5),
|
|
2724
|
+
painManagement: import_zod10.z.number().min(1).max(5),
|
|
2725
|
+
followUpCare: import_zod10.z.number().min(1).max(5),
|
|
2726
|
+
valueForMoney: import_zod10.z.number().min(1).max(5),
|
|
2727
|
+
overallRating: import_zod10.z.number().min(1).max(5),
|
|
2728
|
+
wouldRecommend: import_zod10.z.boolean()
|
|
2621
2729
|
});
|
|
2622
2730
|
var createProcedureReviewSchema = baseReviewCreateSchema.extend({
|
|
2623
|
-
procedureId:
|
|
2624
|
-
effectivenessOfTreatment:
|
|
2625
|
-
outcomeExplanation:
|
|
2626
|
-
painManagement:
|
|
2627
|
-
followUpCare:
|
|
2628
|
-
valueForMoney:
|
|
2629
|
-
wouldRecommend:
|
|
2731
|
+
procedureId: import_zod10.z.string().min(1),
|
|
2732
|
+
effectivenessOfTreatment: import_zod10.z.number().min(1).max(5),
|
|
2733
|
+
outcomeExplanation: import_zod10.z.number().min(1).max(5),
|
|
2734
|
+
painManagement: import_zod10.z.number().min(1).max(5),
|
|
2735
|
+
followUpCare: import_zod10.z.number().min(1).max(5),
|
|
2736
|
+
valueForMoney: import_zod10.z.number().min(1).max(5),
|
|
2737
|
+
wouldRecommend: import_zod10.z.boolean()
|
|
2630
2738
|
});
|
|
2631
|
-
var clinicReviewInfoSchema =
|
|
2632
|
-
totalReviews:
|
|
2633
|
-
averageRating:
|
|
2634
|
-
cleanliness:
|
|
2635
|
-
facilities:
|
|
2636
|
-
staffFriendliness:
|
|
2637
|
-
waitingTime:
|
|
2638
|
-
accessibility:
|
|
2639
|
-
recommendationPercentage:
|
|
2739
|
+
var clinicReviewInfoSchema = import_zod10.z.object({
|
|
2740
|
+
totalReviews: import_zod10.z.number().min(0),
|
|
2741
|
+
averageRating: import_zod10.z.number().min(0).max(5),
|
|
2742
|
+
cleanliness: import_zod10.z.number().min(0).max(5),
|
|
2743
|
+
facilities: import_zod10.z.number().min(0).max(5),
|
|
2744
|
+
staffFriendliness: import_zod10.z.number().min(0).max(5),
|
|
2745
|
+
waitingTime: import_zod10.z.number().min(0).max(5),
|
|
2746
|
+
accessibility: import_zod10.z.number().min(0).max(5),
|
|
2747
|
+
recommendationPercentage: import_zod10.z.number().min(0).max(100)
|
|
2640
2748
|
});
|
|
2641
|
-
var practitionerReviewInfoSchema =
|
|
2642
|
-
totalReviews:
|
|
2643
|
-
averageRating:
|
|
2644
|
-
knowledgeAndExpertise:
|
|
2645
|
-
communicationSkills:
|
|
2646
|
-
bedSideManner:
|
|
2647
|
-
thoroughness:
|
|
2648
|
-
trustworthiness:
|
|
2649
|
-
recommendationPercentage:
|
|
2749
|
+
var practitionerReviewInfoSchema = import_zod10.z.object({
|
|
2750
|
+
totalReviews: import_zod10.z.number().min(0),
|
|
2751
|
+
averageRating: import_zod10.z.number().min(0).max(5),
|
|
2752
|
+
knowledgeAndExpertise: import_zod10.z.number().min(0).max(5),
|
|
2753
|
+
communicationSkills: import_zod10.z.number().min(0).max(5),
|
|
2754
|
+
bedSideManner: import_zod10.z.number().min(0).max(5),
|
|
2755
|
+
thoroughness: import_zod10.z.number().min(0).max(5),
|
|
2756
|
+
trustworthiness: import_zod10.z.number().min(0).max(5),
|
|
2757
|
+
recommendationPercentage: import_zod10.z.number().min(0).max(100)
|
|
2650
2758
|
});
|
|
2651
|
-
var procedureReviewInfoSchema =
|
|
2652
|
-
totalReviews:
|
|
2653
|
-
averageRating:
|
|
2654
|
-
effectivenessOfTreatment:
|
|
2655
|
-
outcomeExplanation:
|
|
2656
|
-
painManagement:
|
|
2657
|
-
followUpCare:
|
|
2658
|
-
valueForMoney:
|
|
2659
|
-
recommendationPercentage:
|
|
2759
|
+
var procedureReviewInfoSchema = import_zod10.z.object({
|
|
2760
|
+
totalReviews: import_zod10.z.number().min(0),
|
|
2761
|
+
averageRating: import_zod10.z.number().min(0).max(5),
|
|
2762
|
+
effectivenessOfTreatment: import_zod10.z.number().min(0).max(5),
|
|
2763
|
+
outcomeExplanation: import_zod10.z.number().min(0).max(5),
|
|
2764
|
+
painManagement: import_zod10.z.number().min(0).max(5),
|
|
2765
|
+
followUpCare: import_zod10.z.number().min(0).max(5),
|
|
2766
|
+
valueForMoney: import_zod10.z.number().min(0).max(5),
|
|
2767
|
+
recommendationPercentage: import_zod10.z.number().min(0).max(100)
|
|
2660
2768
|
});
|
|
2661
|
-
var reviewSchema =
|
|
2662
|
-
id:
|
|
2663
|
-
appointmentId:
|
|
2664
|
-
patientId:
|
|
2665
|
-
createdAt:
|
|
2666
|
-
updatedAt:
|
|
2769
|
+
var reviewSchema = import_zod10.z.object({
|
|
2770
|
+
id: import_zod10.z.string().min(1),
|
|
2771
|
+
appointmentId: import_zod10.z.string().min(1),
|
|
2772
|
+
patientId: import_zod10.z.string().min(1),
|
|
2773
|
+
createdAt: import_zod10.z.date(),
|
|
2774
|
+
updatedAt: import_zod10.z.date(),
|
|
2667
2775
|
clinicReview: clinicReviewSchema.optional(),
|
|
2668
2776
|
practitionerReview: practitionerReviewSchema.optional(),
|
|
2669
2777
|
procedureReview: procedureReviewSchema.optional(),
|
|
2670
|
-
overallComment:
|
|
2671
|
-
overallRating:
|
|
2778
|
+
overallComment: import_zod10.z.string().min(1).max(2e3),
|
|
2779
|
+
overallRating: import_zod10.z.number().min(1).max(5)
|
|
2672
2780
|
});
|
|
2673
|
-
var createReviewSchema =
|
|
2674
|
-
patientId:
|
|
2781
|
+
var createReviewSchema = import_zod10.z.object({
|
|
2782
|
+
patientId: import_zod10.z.string().min(1),
|
|
2675
2783
|
clinicReview: createClinicReviewSchema.optional(),
|
|
2676
2784
|
practitionerReview: createPractitionerReviewSchema.optional(),
|
|
2677
2785
|
procedureReview: createProcedureReviewSchema.optional(),
|
|
2678
|
-
overallComment:
|
|
2786
|
+
overallComment: import_zod10.z.string().min(1).max(2e3)
|
|
2679
2787
|
}).refine(
|
|
2680
2788
|
(data) => {
|
|
2681
2789
|
return data.clinicReview || data.practitionerReview || data.procedureReview;
|
|
@@ -2713,34 +2821,34 @@ var Currency = /* @__PURE__ */ ((Currency2) => {
|
|
|
2713
2821
|
})(Currency || {});
|
|
2714
2822
|
|
|
2715
2823
|
// src/validations/practitioner.schema.ts
|
|
2716
|
-
var practitionerBasicInfoSchema =
|
|
2717
|
-
firstName:
|
|
2718
|
-
lastName:
|
|
2719
|
-
title:
|
|
2720
|
-
email:
|
|
2721
|
-
phoneNumber:
|
|
2722
|
-
dateOfBirth:
|
|
2723
|
-
gender:
|
|
2724
|
-
profileImageUrl:
|
|
2725
|
-
bio:
|
|
2726
|
-
languages:
|
|
2824
|
+
var practitionerBasicInfoSchema = import_zod11.z.object({
|
|
2825
|
+
firstName: import_zod11.z.string().min(2).max(50),
|
|
2826
|
+
lastName: import_zod11.z.string().min(2).max(50),
|
|
2827
|
+
title: import_zod11.z.string().min(2).max(100),
|
|
2828
|
+
email: import_zod11.z.string().email(),
|
|
2829
|
+
phoneNumber: import_zod11.z.string().regex(/^\+?[1-9]\d{1,14}$/, "Invalid phone number"),
|
|
2830
|
+
dateOfBirth: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()),
|
|
2831
|
+
gender: import_zod11.z.enum(["male", "female", "other"]),
|
|
2832
|
+
profileImageUrl: import_zod11.z.string().url().optional(),
|
|
2833
|
+
bio: import_zod11.z.string().max(1e3).optional(),
|
|
2834
|
+
languages: import_zod11.z.array(import_zod11.z.string()).min(1)
|
|
2727
2835
|
});
|
|
2728
|
-
var practitionerCertificationSchema =
|
|
2729
|
-
level:
|
|
2730
|
-
specialties:
|
|
2731
|
-
licenseNumber:
|
|
2732
|
-
issuingAuthority:
|
|
2733
|
-
issueDate:
|
|
2734
|
-
expiryDate:
|
|
2735
|
-
verificationStatus:
|
|
2836
|
+
var practitionerCertificationSchema = import_zod11.z.object({
|
|
2837
|
+
level: import_zod11.z.nativeEnum(CertificationLevel),
|
|
2838
|
+
specialties: import_zod11.z.array(import_zod11.z.nativeEnum(CertificationSpecialty)),
|
|
2839
|
+
licenseNumber: import_zod11.z.string().min(3).max(50),
|
|
2840
|
+
issuingAuthority: import_zod11.z.string().min(2).max(100),
|
|
2841
|
+
issueDate: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()),
|
|
2842
|
+
expiryDate: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()).optional(),
|
|
2843
|
+
verificationStatus: import_zod11.z.enum(["pending", "verified", "rejected"])
|
|
2736
2844
|
});
|
|
2737
|
-
var timeSlotSchema =
|
|
2738
|
-
start:
|
|
2739
|
-
end:
|
|
2845
|
+
var timeSlotSchema = import_zod11.z.object({
|
|
2846
|
+
start: import_zod11.z.string().regex(/^([01]\d|2[0-3]):([0-5]\d)$/, "Invalid time format"),
|
|
2847
|
+
end: import_zod11.z.string().regex(/^([01]\d|2[0-3]):([0-5]\d)$/, "Invalid time format")
|
|
2740
2848
|
}).nullable();
|
|
2741
|
-
var practitionerWorkingHoursSchema =
|
|
2742
|
-
practitionerId:
|
|
2743
|
-
clinicId:
|
|
2849
|
+
var practitionerWorkingHoursSchema = import_zod11.z.object({
|
|
2850
|
+
practitionerId: import_zod11.z.string().min(1),
|
|
2851
|
+
clinicId: import_zod11.z.string().min(1),
|
|
2744
2852
|
monday: timeSlotSchema,
|
|
2745
2853
|
tuesday: timeSlotSchema,
|
|
2746
2854
|
wednesday: timeSlotSchema,
|
|
@@ -2748,12 +2856,12 @@ var practitionerWorkingHoursSchema = import_zod10.z.object({
|
|
|
2748
2856
|
friday: timeSlotSchema,
|
|
2749
2857
|
saturday: timeSlotSchema,
|
|
2750
2858
|
sunday: timeSlotSchema,
|
|
2751
|
-
createdAt:
|
|
2752
|
-
updatedAt:
|
|
2859
|
+
createdAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()),
|
|
2860
|
+
updatedAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date())
|
|
2753
2861
|
});
|
|
2754
|
-
var practitionerClinicWorkingHoursSchema =
|
|
2755
|
-
clinicId:
|
|
2756
|
-
workingHours:
|
|
2862
|
+
var practitionerClinicWorkingHoursSchema = import_zod11.z.object({
|
|
2863
|
+
clinicId: import_zod11.z.string().min(1),
|
|
2864
|
+
workingHours: import_zod11.z.object({
|
|
2757
2865
|
monday: timeSlotSchema,
|
|
2758
2866
|
tuesday: timeSlotSchema,
|
|
2759
2867
|
wednesday: timeSlotSchema,
|
|
@@ -2762,114 +2870,114 @@ var practitionerClinicWorkingHoursSchema = import_zod10.z.object({
|
|
|
2762
2870
|
saturday: timeSlotSchema,
|
|
2763
2871
|
sunday: timeSlotSchema
|
|
2764
2872
|
}),
|
|
2765
|
-
isActive:
|
|
2766
|
-
createdAt:
|
|
2767
|
-
updatedAt:
|
|
2873
|
+
isActive: import_zod11.z.boolean(),
|
|
2874
|
+
createdAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()),
|
|
2875
|
+
updatedAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date())
|
|
2768
2876
|
});
|
|
2769
|
-
var procedureSummaryInfoSchema =
|
|
2770
|
-
id:
|
|
2771
|
-
name:
|
|
2772
|
-
description:
|
|
2773
|
-
photo:
|
|
2774
|
-
family:
|
|
2775
|
-
categoryName:
|
|
2776
|
-
subcategoryName:
|
|
2777
|
-
technologyName:
|
|
2778
|
-
price:
|
|
2779
|
-
pricingMeasure:
|
|
2780
|
-
currency:
|
|
2781
|
-
duration:
|
|
2782
|
-
clinicId:
|
|
2783
|
-
clinicName:
|
|
2784
|
-
practitionerId:
|
|
2785
|
-
practitionerName:
|
|
2877
|
+
var procedureSummaryInfoSchema = import_zod11.z.object({
|
|
2878
|
+
id: import_zod11.z.string().min(1),
|
|
2879
|
+
name: import_zod11.z.string().min(1),
|
|
2880
|
+
description: import_zod11.z.string().optional(),
|
|
2881
|
+
photo: import_zod11.z.string().optional(),
|
|
2882
|
+
family: import_zod11.z.nativeEnum(ProcedureFamily),
|
|
2883
|
+
categoryName: import_zod11.z.string(),
|
|
2884
|
+
subcategoryName: import_zod11.z.string(),
|
|
2885
|
+
technologyName: import_zod11.z.string(),
|
|
2886
|
+
price: import_zod11.z.number().nonnegative(),
|
|
2887
|
+
pricingMeasure: import_zod11.z.nativeEnum(PricingMeasure),
|
|
2888
|
+
currency: import_zod11.z.nativeEnum(Currency),
|
|
2889
|
+
duration: import_zod11.z.number().int().positive(),
|
|
2890
|
+
clinicId: import_zod11.z.string().min(1),
|
|
2891
|
+
clinicName: import_zod11.z.string().min(1),
|
|
2892
|
+
practitionerId: import_zod11.z.string().min(1),
|
|
2893
|
+
practitionerName: import_zod11.z.string().min(1)
|
|
2786
2894
|
});
|
|
2787
|
-
var practitionerSchema =
|
|
2788
|
-
id:
|
|
2789
|
-
userRef:
|
|
2895
|
+
var practitionerSchema = import_zod11.z.object({
|
|
2896
|
+
id: import_zod11.z.string().min(1),
|
|
2897
|
+
userRef: import_zod11.z.string().min(1),
|
|
2790
2898
|
basicInfo: practitionerBasicInfoSchema,
|
|
2791
2899
|
certification: practitionerCertificationSchema,
|
|
2792
|
-
clinics:
|
|
2793
|
-
clinicWorkingHours:
|
|
2794
|
-
clinicsInfo:
|
|
2795
|
-
procedures:
|
|
2796
|
-
proceduresInfo:
|
|
2900
|
+
clinics: import_zod11.z.array(import_zod11.z.string()),
|
|
2901
|
+
clinicWorkingHours: import_zod11.z.array(practitionerClinicWorkingHoursSchema),
|
|
2902
|
+
clinicsInfo: import_zod11.z.array(clinicInfoSchema),
|
|
2903
|
+
procedures: import_zod11.z.array(import_zod11.z.string()),
|
|
2904
|
+
proceduresInfo: import_zod11.z.array(procedureSummaryInfoSchema),
|
|
2797
2905
|
reviewInfo: practitionerReviewInfoSchema,
|
|
2798
|
-
isActive:
|
|
2799
|
-
isVerified:
|
|
2800
|
-
status:
|
|
2801
|
-
createdAt:
|
|
2802
|
-
updatedAt:
|
|
2906
|
+
isActive: import_zod11.z.boolean(),
|
|
2907
|
+
isVerified: import_zod11.z.boolean(),
|
|
2908
|
+
status: import_zod11.z.nativeEnum(PractitionerStatus),
|
|
2909
|
+
createdAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()),
|
|
2910
|
+
updatedAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date())
|
|
2803
2911
|
});
|
|
2804
|
-
var createPractitionerSchema =
|
|
2805
|
-
userRef:
|
|
2912
|
+
var createPractitionerSchema = import_zod11.z.object({
|
|
2913
|
+
userRef: import_zod11.z.string().min(1),
|
|
2806
2914
|
basicInfo: practitionerBasicInfoSchema,
|
|
2807
2915
|
certification: practitionerCertificationSchema,
|
|
2808
|
-
clinics:
|
|
2809
|
-
clinicWorkingHours:
|
|
2810
|
-
clinicsInfo:
|
|
2811
|
-
proceduresInfo:
|
|
2812
|
-
isActive:
|
|
2813
|
-
isVerified:
|
|
2814
|
-
status:
|
|
2916
|
+
clinics: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
2917
|
+
clinicWorkingHours: import_zod11.z.array(practitionerClinicWorkingHoursSchema).optional(),
|
|
2918
|
+
clinicsInfo: import_zod11.z.array(clinicInfoSchema).optional(),
|
|
2919
|
+
proceduresInfo: import_zod11.z.array(procedureSummaryInfoSchema).optional(),
|
|
2920
|
+
isActive: import_zod11.z.boolean(),
|
|
2921
|
+
isVerified: import_zod11.z.boolean(),
|
|
2922
|
+
status: import_zod11.z.nativeEnum(PractitionerStatus).optional()
|
|
2815
2923
|
});
|
|
2816
|
-
var createDraftPractitionerSchema =
|
|
2924
|
+
var createDraftPractitionerSchema = import_zod11.z.object({
|
|
2817
2925
|
basicInfo: practitionerBasicInfoSchema,
|
|
2818
2926
|
certification: practitionerCertificationSchema,
|
|
2819
|
-
clinics:
|
|
2820
|
-
clinicWorkingHours:
|
|
2821
|
-
clinicsInfo:
|
|
2822
|
-
proceduresInfo:
|
|
2823
|
-
isActive:
|
|
2824
|
-
isVerified:
|
|
2927
|
+
clinics: import_zod11.z.array(import_zod11.z.string()).optional(),
|
|
2928
|
+
clinicWorkingHours: import_zod11.z.array(practitionerClinicWorkingHoursSchema).optional(),
|
|
2929
|
+
clinicsInfo: import_zod11.z.array(clinicInfoSchema).optional(),
|
|
2930
|
+
proceduresInfo: import_zod11.z.array(procedureSummaryInfoSchema).optional(),
|
|
2931
|
+
isActive: import_zod11.z.boolean().optional().default(false),
|
|
2932
|
+
isVerified: import_zod11.z.boolean().optional().default(false)
|
|
2825
2933
|
});
|
|
2826
|
-
var practitionerTokenSchema =
|
|
2827
|
-
id:
|
|
2828
|
-
token:
|
|
2829
|
-
practitionerId:
|
|
2830
|
-
email:
|
|
2831
|
-
clinicId:
|
|
2832
|
-
status:
|
|
2833
|
-
createdBy:
|
|
2834
|
-
createdAt:
|
|
2835
|
-
expiresAt:
|
|
2836
|
-
usedBy:
|
|
2837
|
-
usedAt:
|
|
2934
|
+
var practitionerTokenSchema = import_zod11.z.object({
|
|
2935
|
+
id: import_zod11.z.string().min(1),
|
|
2936
|
+
token: import_zod11.z.string().min(6),
|
|
2937
|
+
practitionerId: import_zod11.z.string().min(1),
|
|
2938
|
+
email: import_zod11.z.string().email(),
|
|
2939
|
+
clinicId: import_zod11.z.string().min(1),
|
|
2940
|
+
status: import_zod11.z.nativeEnum(PractitionerTokenStatus),
|
|
2941
|
+
createdBy: import_zod11.z.string().min(1),
|
|
2942
|
+
createdAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()),
|
|
2943
|
+
expiresAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()),
|
|
2944
|
+
usedBy: import_zod11.z.string().optional(),
|
|
2945
|
+
usedAt: import_zod11.z.instanceof(import_firestore10.Timestamp).or(import_zod11.z.date()).optional()
|
|
2838
2946
|
});
|
|
2839
|
-
var createPractitionerTokenSchema =
|
|
2840
|
-
practitionerId:
|
|
2841
|
-
email:
|
|
2842
|
-
clinicId:
|
|
2843
|
-
expiresAt:
|
|
2947
|
+
var createPractitionerTokenSchema = import_zod11.z.object({
|
|
2948
|
+
practitionerId: import_zod11.z.string().min(1),
|
|
2949
|
+
email: import_zod11.z.string().email(),
|
|
2950
|
+
clinicId: import_zod11.z.string().min(1),
|
|
2951
|
+
expiresAt: import_zod11.z.date().optional()
|
|
2844
2952
|
});
|
|
2845
2953
|
|
|
2846
2954
|
// src/validations/clinic.schema.ts
|
|
2847
|
-
var clinicContactInfoSchema =
|
|
2848
|
-
email:
|
|
2849
|
-
phoneNumber:
|
|
2850
|
-
alternativePhoneNumber:
|
|
2851
|
-
website:
|
|
2955
|
+
var clinicContactInfoSchema = import_zod12.z.object({
|
|
2956
|
+
email: import_zod12.z.string().email(),
|
|
2957
|
+
phoneNumber: import_zod12.z.string(),
|
|
2958
|
+
alternativePhoneNumber: import_zod12.z.string().nullable().optional(),
|
|
2959
|
+
website: import_zod12.z.string().nullable().optional()
|
|
2852
2960
|
});
|
|
2853
|
-
var clinicLocationSchema =
|
|
2854
|
-
address:
|
|
2855
|
-
city:
|
|
2856
|
-
country:
|
|
2857
|
-
postalCode:
|
|
2858
|
-
latitude:
|
|
2859
|
-
longitude:
|
|
2860
|
-
geohash:
|
|
2961
|
+
var clinicLocationSchema = import_zod12.z.object({
|
|
2962
|
+
address: import_zod12.z.string(),
|
|
2963
|
+
city: import_zod12.z.string(),
|
|
2964
|
+
country: import_zod12.z.string(),
|
|
2965
|
+
postalCode: import_zod12.z.string(),
|
|
2966
|
+
latitude: import_zod12.z.number().min(-90).max(90),
|
|
2967
|
+
longitude: import_zod12.z.number().min(-180).max(180),
|
|
2968
|
+
geohash: import_zod12.z.string().nullable().optional()
|
|
2861
2969
|
});
|
|
2862
|
-
var workingHoursTimeSchema =
|
|
2863
|
-
open:
|
|
2864
|
-
close:
|
|
2865
|
-
breaks:
|
|
2866
|
-
|
|
2867
|
-
start:
|
|
2868
|
-
end:
|
|
2970
|
+
var workingHoursTimeSchema = import_zod12.z.object({
|
|
2971
|
+
open: import_zod12.z.string(),
|
|
2972
|
+
close: import_zod12.z.string(),
|
|
2973
|
+
breaks: import_zod12.z.array(
|
|
2974
|
+
import_zod12.z.object({
|
|
2975
|
+
start: import_zod12.z.string(),
|
|
2976
|
+
end: import_zod12.z.string()
|
|
2869
2977
|
})
|
|
2870
2978
|
).optional()
|
|
2871
2979
|
});
|
|
2872
|
-
var workingHoursSchema =
|
|
2980
|
+
var workingHoursSchema = import_zod12.z.object({
|
|
2873
2981
|
monday: workingHoursTimeSchema.nullable(),
|
|
2874
2982
|
tuesday: workingHoursTimeSchema.nullable(),
|
|
2875
2983
|
wednesday: workingHoursTimeSchema.nullable(),
|
|
@@ -2878,235 +2986,235 @@ var workingHoursSchema = import_zod11.z.object({
|
|
|
2878
2986
|
saturday: workingHoursTimeSchema.nullable(),
|
|
2879
2987
|
sunday: workingHoursTimeSchema.nullable()
|
|
2880
2988
|
});
|
|
2881
|
-
var clinicTagsSchema =
|
|
2882
|
-
tags:
|
|
2989
|
+
var clinicTagsSchema = import_zod12.z.object({
|
|
2990
|
+
tags: import_zod12.z.array(import_zod12.z.nativeEnum(ClinicTag))
|
|
2883
2991
|
});
|
|
2884
|
-
var contactPersonSchema =
|
|
2885
|
-
firstName:
|
|
2886
|
-
lastName:
|
|
2887
|
-
title:
|
|
2888
|
-
email:
|
|
2889
|
-
phoneNumber:
|
|
2992
|
+
var contactPersonSchema = import_zod12.z.object({
|
|
2993
|
+
firstName: import_zod12.z.string(),
|
|
2994
|
+
lastName: import_zod12.z.string(),
|
|
2995
|
+
title: import_zod12.z.string().nullable().optional(),
|
|
2996
|
+
email: import_zod12.z.string().email(),
|
|
2997
|
+
phoneNumber: import_zod12.z.string().nullable().optional()
|
|
2890
2998
|
});
|
|
2891
|
-
var adminInfoSchema =
|
|
2892
|
-
id:
|
|
2893
|
-
name:
|
|
2894
|
-
email:
|
|
2999
|
+
var adminInfoSchema = import_zod12.z.object({
|
|
3000
|
+
id: import_zod12.z.string(),
|
|
3001
|
+
name: import_zod12.z.string(),
|
|
3002
|
+
email: import_zod12.z.string().email()
|
|
2895
3003
|
});
|
|
2896
|
-
var clinicInfoSchema =
|
|
2897
|
-
id:
|
|
2898
|
-
featuredPhoto:
|
|
2899
|
-
name:
|
|
2900
|
-
description:
|
|
3004
|
+
var clinicInfoSchema = import_zod12.z.object({
|
|
3005
|
+
id: import_zod12.z.string(),
|
|
3006
|
+
featuredPhoto: import_zod12.z.string(),
|
|
3007
|
+
name: import_zod12.z.string(),
|
|
3008
|
+
description: import_zod12.z.string().nullable().optional(),
|
|
2901
3009
|
location: clinicLocationSchema,
|
|
2902
3010
|
contactInfo: clinicContactInfoSchema
|
|
2903
3011
|
});
|
|
2904
|
-
var doctorInfoSchema =
|
|
2905
|
-
id:
|
|
2906
|
-
name:
|
|
2907
|
-
description:
|
|
2908
|
-
photo:
|
|
2909
|
-
rating:
|
|
2910
|
-
services:
|
|
3012
|
+
var doctorInfoSchema = import_zod12.z.object({
|
|
3013
|
+
id: import_zod12.z.string(),
|
|
3014
|
+
name: import_zod12.z.string(),
|
|
3015
|
+
description: import_zod12.z.string().nullable().optional(),
|
|
3016
|
+
photo: import_zod12.z.string(),
|
|
3017
|
+
rating: import_zod12.z.number().min(0).max(5),
|
|
3018
|
+
services: import_zod12.z.array(import_zod12.z.string())
|
|
2911
3019
|
// List of procedure IDs practitioner offers
|
|
2912
3020
|
});
|
|
2913
|
-
var clinicAdminSchema =
|
|
2914
|
-
id:
|
|
2915
|
-
userRef:
|
|
2916
|
-
clinicGroupId:
|
|
2917
|
-
isGroupOwner:
|
|
2918
|
-
clinicsManaged:
|
|
2919
|
-
clinicsManagedInfo:
|
|
3021
|
+
var clinicAdminSchema = import_zod12.z.object({
|
|
3022
|
+
id: import_zod12.z.string(),
|
|
3023
|
+
userRef: import_zod12.z.string(),
|
|
3024
|
+
clinicGroupId: import_zod12.z.string(),
|
|
3025
|
+
isGroupOwner: import_zod12.z.boolean(),
|
|
3026
|
+
clinicsManaged: import_zod12.z.array(import_zod12.z.string()),
|
|
3027
|
+
clinicsManagedInfo: import_zod12.z.array(clinicInfoSchema),
|
|
2920
3028
|
contactInfo: contactPersonSchema,
|
|
2921
|
-
roleTitle:
|
|
2922
|
-
createdAt:
|
|
2923
|
-
updatedAt:
|
|
2924
|
-
isActive:
|
|
3029
|
+
roleTitle: import_zod12.z.string(),
|
|
3030
|
+
createdAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore11.Timestamp)),
|
|
3031
|
+
updatedAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore11.Timestamp)),
|
|
3032
|
+
isActive: import_zod12.z.boolean()
|
|
2925
3033
|
});
|
|
2926
|
-
var adminTokenSchema =
|
|
2927
|
-
id:
|
|
2928
|
-
token:
|
|
2929
|
-
email:
|
|
2930
|
-
status:
|
|
2931
|
-
usedByUserRef:
|
|
2932
|
-
createdAt:
|
|
3034
|
+
var adminTokenSchema = import_zod12.z.object({
|
|
3035
|
+
id: import_zod12.z.string(),
|
|
3036
|
+
token: import_zod12.z.string(),
|
|
3037
|
+
email: import_zod12.z.string().email().optional().nullable(),
|
|
3038
|
+
status: import_zod12.z.nativeEnum(AdminTokenStatus),
|
|
3039
|
+
usedByUserRef: import_zod12.z.string().optional(),
|
|
3040
|
+
createdAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore11.Timestamp)),
|
|
2933
3041
|
// Timestamp
|
|
2934
|
-
expiresAt:
|
|
3042
|
+
expiresAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore11.Timestamp))
|
|
2935
3043
|
// Timestamp
|
|
2936
3044
|
});
|
|
2937
|
-
var createAdminTokenSchema =
|
|
2938
|
-
expiresInDays:
|
|
2939
|
-
email:
|
|
3045
|
+
var createAdminTokenSchema = import_zod12.z.object({
|
|
3046
|
+
expiresInDays: import_zod12.z.number().min(1).max(30).optional(),
|
|
3047
|
+
email: import_zod12.z.string().email().optional().nullable()
|
|
2940
3048
|
});
|
|
2941
|
-
var clinicGroupSchema =
|
|
2942
|
-
id:
|
|
2943
|
-
name:
|
|
2944
|
-
description:
|
|
3049
|
+
var clinicGroupSchema = import_zod12.z.object({
|
|
3050
|
+
id: import_zod12.z.string(),
|
|
3051
|
+
name: import_zod12.z.string(),
|
|
3052
|
+
description: import_zod12.z.string().nullable().optional(),
|
|
2945
3053
|
hqLocation: clinicLocationSchema,
|
|
2946
3054
|
contactInfo: clinicContactInfoSchema,
|
|
2947
3055
|
contactPerson: contactPersonSchema,
|
|
2948
|
-
clinics:
|
|
2949
|
-
clinicsInfo:
|
|
2950
|
-
admins:
|
|
2951
|
-
adminsInfo:
|
|
2952
|
-
adminTokens:
|
|
2953
|
-
ownerId:
|
|
2954
|
-
createdAt:
|
|
3056
|
+
clinics: import_zod12.z.array(import_zod12.z.string()),
|
|
3057
|
+
clinicsInfo: import_zod12.z.array(clinicInfoSchema),
|
|
3058
|
+
admins: import_zod12.z.array(import_zod12.z.string()),
|
|
3059
|
+
adminsInfo: import_zod12.z.array(adminInfoSchema),
|
|
3060
|
+
adminTokens: import_zod12.z.array(adminTokenSchema),
|
|
3061
|
+
ownerId: import_zod12.z.string().nullable(),
|
|
3062
|
+
createdAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore11.Timestamp)),
|
|
2955
3063
|
// Timestamp
|
|
2956
|
-
updatedAt:
|
|
3064
|
+
updatedAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore11.Timestamp)),
|
|
2957
3065
|
// Timestamp
|
|
2958
|
-
isActive:
|
|
2959
|
-
logo:
|
|
2960
|
-
practiceType:
|
|
2961
|
-
languages:
|
|
2962
|
-
subscriptionModel:
|
|
2963
|
-
calendarSyncEnabled:
|
|
2964
|
-
autoConfirmAppointments:
|
|
2965
|
-
businessIdentificationNumber:
|
|
3066
|
+
isActive: import_zod12.z.boolean(),
|
|
3067
|
+
logo: import_zod12.z.string().optional().nullable(),
|
|
3068
|
+
practiceType: import_zod12.z.nativeEnum(PracticeType).optional(),
|
|
3069
|
+
languages: import_zod12.z.array(import_zod12.z.nativeEnum(Language)).optional(),
|
|
3070
|
+
subscriptionModel: import_zod12.z.nativeEnum(SubscriptionModel),
|
|
3071
|
+
calendarSyncEnabled: import_zod12.z.boolean().optional(),
|
|
3072
|
+
autoConfirmAppointments: import_zod12.z.boolean().optional(),
|
|
3073
|
+
businessIdentificationNumber: import_zod12.z.string().optional().nullable()
|
|
2966
3074
|
});
|
|
2967
|
-
var clinicSchema =
|
|
2968
|
-
id:
|
|
2969
|
-
clinicGroupId:
|
|
2970
|
-
name:
|
|
2971
|
-
description:
|
|
3075
|
+
var clinicSchema = import_zod12.z.object({
|
|
3076
|
+
id: import_zod12.z.string(),
|
|
3077
|
+
clinicGroupId: import_zod12.z.string(),
|
|
3078
|
+
name: import_zod12.z.string(),
|
|
3079
|
+
description: import_zod12.z.string().nullable().optional(),
|
|
2972
3080
|
location: clinicLocationSchema,
|
|
2973
3081
|
contactInfo: clinicContactInfoSchema,
|
|
2974
3082
|
workingHours: workingHoursSchema,
|
|
2975
|
-
tags:
|
|
2976
|
-
featuredPhotos:
|
|
2977
|
-
coverPhoto:
|
|
2978
|
-
photosWithTags:
|
|
2979
|
-
|
|
2980
|
-
url:
|
|
2981
|
-
tag:
|
|
3083
|
+
tags: import_zod12.z.array(import_zod12.z.nativeEnum(ClinicTag)),
|
|
3084
|
+
featuredPhotos: import_zod12.z.array(import_zod12.z.string()),
|
|
3085
|
+
coverPhoto: import_zod12.z.string().nullable(),
|
|
3086
|
+
photosWithTags: import_zod12.z.array(
|
|
3087
|
+
import_zod12.z.object({
|
|
3088
|
+
url: import_zod12.z.string(),
|
|
3089
|
+
tag: import_zod12.z.string()
|
|
2982
3090
|
})
|
|
2983
3091
|
).optional(),
|
|
2984
|
-
doctors:
|
|
3092
|
+
doctors: import_zod12.z.array(import_zod12.z.string()),
|
|
2985
3093
|
// List of practitioner IDs
|
|
2986
|
-
doctorsInfo:
|
|
3094
|
+
doctorsInfo: import_zod12.z.array(doctorInfoSchema),
|
|
2987
3095
|
// Aggregated doctor info
|
|
2988
|
-
procedures:
|
|
3096
|
+
procedures: import_zod12.z.array(import_zod12.z.string()),
|
|
2989
3097
|
// List of procedure IDs offered by clinic
|
|
2990
|
-
proceduresInfo:
|
|
3098
|
+
proceduresInfo: import_zod12.z.array(procedureSummaryInfoSchema),
|
|
2991
3099
|
// Use the correct schema for aggregated procedure info
|
|
2992
3100
|
// services: z.array(z.string()), // Likely deprecated, procedures covers this
|
|
2993
3101
|
// servicesInfo: z.array(serviceInfoSchema), // Deprecated, use proceduresInfo
|
|
2994
3102
|
reviewInfo: clinicReviewInfoSchema,
|
|
2995
|
-
admins:
|
|
2996
|
-
createdAt:
|
|
3103
|
+
admins: import_zod12.z.array(import_zod12.z.string()),
|
|
3104
|
+
createdAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore11.Timestamp)),
|
|
2997
3105
|
// Timestamp
|
|
2998
|
-
updatedAt:
|
|
3106
|
+
updatedAt: import_zod12.z.instanceof(Date).or(import_zod12.z.instanceof(import_firestore11.Timestamp)),
|
|
2999
3107
|
// Timestamp
|
|
3000
|
-
isActive:
|
|
3001
|
-
isVerified:
|
|
3002
|
-
logo:
|
|
3108
|
+
isActive: import_zod12.z.boolean(),
|
|
3109
|
+
isVerified: import_zod12.z.boolean(),
|
|
3110
|
+
logo: import_zod12.z.string().optional()
|
|
3003
3111
|
});
|
|
3004
|
-
var createClinicAdminSchema =
|
|
3005
|
-
userRef:
|
|
3006
|
-
clinicGroupId:
|
|
3007
|
-
isGroupOwner:
|
|
3008
|
-
clinicsManaged:
|
|
3112
|
+
var createClinicAdminSchema = import_zod12.z.object({
|
|
3113
|
+
userRef: import_zod12.z.string(),
|
|
3114
|
+
clinicGroupId: import_zod12.z.string().optional(),
|
|
3115
|
+
isGroupOwner: import_zod12.z.boolean(),
|
|
3116
|
+
clinicsManaged: import_zod12.z.array(import_zod12.z.string()),
|
|
3009
3117
|
contactInfo: contactPersonSchema,
|
|
3010
|
-
roleTitle:
|
|
3011
|
-
isActive:
|
|
3118
|
+
roleTitle: import_zod12.z.string(),
|
|
3119
|
+
isActive: import_zod12.z.boolean()
|
|
3012
3120
|
// clinicsManagedInfo is aggregated, not provided on creation
|
|
3013
3121
|
});
|
|
3014
|
-
var createClinicGroupSchema =
|
|
3015
|
-
name:
|
|
3016
|
-
description:
|
|
3122
|
+
var createClinicGroupSchema = import_zod12.z.object({
|
|
3123
|
+
name: import_zod12.z.string(),
|
|
3124
|
+
description: import_zod12.z.string().optional(),
|
|
3017
3125
|
hqLocation: clinicLocationSchema,
|
|
3018
3126
|
contactInfo: clinicContactInfoSchema,
|
|
3019
3127
|
contactPerson: contactPersonSchema,
|
|
3020
|
-
ownerId:
|
|
3021
|
-
isActive:
|
|
3022
|
-
logo:
|
|
3023
|
-
practiceType:
|
|
3024
|
-
languages:
|
|
3025
|
-
subscriptionModel:
|
|
3026
|
-
calendarSyncEnabled:
|
|
3027
|
-
autoConfirmAppointments:
|
|
3028
|
-
businessIdentificationNumber:
|
|
3128
|
+
ownerId: import_zod12.z.string().nullable(),
|
|
3129
|
+
isActive: import_zod12.z.boolean(),
|
|
3130
|
+
logo: import_zod12.z.string().optional().nullable(),
|
|
3131
|
+
practiceType: import_zod12.z.nativeEnum(PracticeType).optional(),
|
|
3132
|
+
languages: import_zod12.z.array(import_zod12.z.nativeEnum(Language)).optional(),
|
|
3133
|
+
subscriptionModel: import_zod12.z.nativeEnum(SubscriptionModel).optional().default("no_subscription" /* NO_SUBSCRIPTION */),
|
|
3134
|
+
calendarSyncEnabled: import_zod12.z.boolean().optional(),
|
|
3135
|
+
autoConfirmAppointments: import_zod12.z.boolean().optional(),
|
|
3136
|
+
businessIdentificationNumber: import_zod12.z.string().optional().nullable()
|
|
3029
3137
|
// clinics, clinicsInfo, admins, adminsInfo, adminTokens are managed internally
|
|
3030
3138
|
});
|
|
3031
|
-
var createClinicSchema =
|
|
3032
|
-
clinicGroupId:
|
|
3033
|
-
name:
|
|
3034
|
-
description:
|
|
3139
|
+
var createClinicSchema = import_zod12.z.object({
|
|
3140
|
+
clinicGroupId: import_zod12.z.string(),
|
|
3141
|
+
name: import_zod12.z.string(),
|
|
3142
|
+
description: import_zod12.z.string().optional(),
|
|
3035
3143
|
location: clinicLocationSchema,
|
|
3036
3144
|
contactInfo: clinicContactInfoSchema,
|
|
3037
3145
|
workingHours: workingHoursSchema,
|
|
3038
|
-
tags:
|
|
3039
|
-
coverPhoto:
|
|
3040
|
-
photosWithTags:
|
|
3041
|
-
|
|
3042
|
-
url:
|
|
3043
|
-
tag:
|
|
3146
|
+
tags: import_zod12.z.array(import_zod12.z.nativeEnum(ClinicTag)),
|
|
3147
|
+
coverPhoto: import_zod12.z.string().nullable(),
|
|
3148
|
+
photosWithTags: import_zod12.z.array(
|
|
3149
|
+
import_zod12.z.object({
|
|
3150
|
+
url: import_zod12.z.string(),
|
|
3151
|
+
tag: import_zod12.z.string()
|
|
3044
3152
|
})
|
|
3045
3153
|
).optional(),
|
|
3046
3154
|
// doctors, doctorsInfo, procedures, proceduresInfo are managed internally/aggregated
|
|
3047
3155
|
// doctors: z.array(z.string()),
|
|
3048
3156
|
// services: z.array(z.string()), // Deprecated
|
|
3049
|
-
admins:
|
|
3157
|
+
admins: import_zod12.z.array(import_zod12.z.string()),
|
|
3050
3158
|
// Should likely just be creator ID initially
|
|
3051
|
-
isActive:
|
|
3052
|
-
isVerified:
|
|
3053
|
-
logo:
|
|
3054
|
-
featuredPhotos:
|
|
3159
|
+
isActive: import_zod12.z.boolean(),
|
|
3160
|
+
isVerified: import_zod12.z.boolean(),
|
|
3161
|
+
logo: import_zod12.z.string().optional(),
|
|
3162
|
+
featuredPhotos: import_zod12.z.array(import_zod12.z.string()).optional()
|
|
3055
3163
|
});
|
|
3056
|
-
var createDefaultClinicGroupSchema =
|
|
3057
|
-
name:
|
|
3058
|
-
ownerId:
|
|
3164
|
+
var createDefaultClinicGroupSchema = import_zod12.z.object({
|
|
3165
|
+
name: import_zod12.z.string(),
|
|
3166
|
+
ownerId: import_zod12.z.string().nullable(),
|
|
3059
3167
|
contactPerson: contactPersonSchema,
|
|
3060
3168
|
contactInfo: clinicContactInfoSchema,
|
|
3061
3169
|
hqLocation: clinicLocationSchema,
|
|
3062
|
-
isActive:
|
|
3063
|
-
logo:
|
|
3064
|
-
practiceType:
|
|
3065
|
-
languages:
|
|
3066
|
-
subscriptionModel:
|
|
3170
|
+
isActive: import_zod12.z.boolean(),
|
|
3171
|
+
logo: import_zod12.z.string().optional().nullable(),
|
|
3172
|
+
practiceType: import_zod12.z.nativeEnum(PracticeType).optional(),
|
|
3173
|
+
languages: import_zod12.z.array(import_zod12.z.nativeEnum(Language)).optional(),
|
|
3174
|
+
subscriptionModel: import_zod12.z.nativeEnum(SubscriptionModel).optional().default("no_subscription" /* NO_SUBSCRIPTION */)
|
|
3067
3175
|
});
|
|
3068
|
-
var clinicAdminSignupSchema =
|
|
3069
|
-
email:
|
|
3070
|
-
password:
|
|
3071
|
-
firstName:
|
|
3072
|
-
lastName:
|
|
3073
|
-
title:
|
|
3074
|
-
phoneNumber:
|
|
3075
|
-
isCreatingNewGroup:
|
|
3076
|
-
inviteToken:
|
|
3077
|
-
clinicGroupData:
|
|
3078
|
-
name:
|
|
3176
|
+
var clinicAdminSignupSchema = import_zod12.z.object({
|
|
3177
|
+
email: import_zod12.z.string().email(),
|
|
3178
|
+
password: import_zod12.z.string().min(8),
|
|
3179
|
+
firstName: import_zod12.z.string(),
|
|
3180
|
+
lastName: import_zod12.z.string(),
|
|
3181
|
+
title: import_zod12.z.string(),
|
|
3182
|
+
phoneNumber: import_zod12.z.string(),
|
|
3183
|
+
isCreatingNewGroup: import_zod12.z.boolean(),
|
|
3184
|
+
inviteToken: import_zod12.z.string().optional(),
|
|
3185
|
+
clinicGroupData: import_zod12.z.object({
|
|
3186
|
+
name: import_zod12.z.string(),
|
|
3079
3187
|
hqLocation: clinicLocationSchema,
|
|
3080
|
-
logo:
|
|
3188
|
+
logo: import_zod12.z.string().optional(),
|
|
3081
3189
|
contactInfo: clinicContactInfoSchema,
|
|
3082
|
-
subscriptionModel:
|
|
3190
|
+
subscriptionModel: import_zod12.z.nativeEnum(SubscriptionModel).optional().default("no_subscription" /* NO_SUBSCRIPTION */)
|
|
3083
3191
|
}).optional()
|
|
3084
3192
|
});
|
|
3085
|
-
var clinicGroupSetupSchema =
|
|
3086
|
-
languages:
|
|
3087
|
-
practiceType:
|
|
3088
|
-
description:
|
|
3089
|
-
logo:
|
|
3090
|
-
calendarSyncEnabled:
|
|
3091
|
-
autoConfirmAppointments:
|
|
3092
|
-
businessIdentificationNumber:
|
|
3193
|
+
var clinicGroupSetupSchema = import_zod12.z.object({
|
|
3194
|
+
languages: import_zod12.z.array(import_zod12.z.nativeEnum(Language)),
|
|
3195
|
+
practiceType: import_zod12.z.nativeEnum(PracticeType),
|
|
3196
|
+
description: import_zod12.z.string(),
|
|
3197
|
+
logo: import_zod12.z.string(),
|
|
3198
|
+
calendarSyncEnabled: import_zod12.z.boolean(),
|
|
3199
|
+
autoConfirmAppointments: import_zod12.z.boolean(),
|
|
3200
|
+
businessIdentificationNumber: import_zod12.z.string().optional().nullable()
|
|
3093
3201
|
});
|
|
3094
|
-
var clinicBranchSetupSchema =
|
|
3095
|
-
name:
|
|
3202
|
+
var clinicBranchSetupSchema = import_zod12.z.object({
|
|
3203
|
+
name: import_zod12.z.string(),
|
|
3096
3204
|
location: clinicLocationSchema,
|
|
3097
|
-
description:
|
|
3205
|
+
description: import_zod12.z.string().optional(),
|
|
3098
3206
|
contactInfo: clinicContactInfoSchema,
|
|
3099
3207
|
workingHours: workingHoursSchema,
|
|
3100
|
-
tags:
|
|
3101
|
-
logo:
|
|
3102
|
-
coverPhoto:
|
|
3103
|
-
photosWithTags:
|
|
3104
|
-
|
|
3105
|
-
url:
|
|
3106
|
-
tag:
|
|
3208
|
+
tags: import_zod12.z.array(import_zod12.z.nativeEnum(ClinicTag)),
|
|
3209
|
+
logo: import_zod12.z.string().optional(),
|
|
3210
|
+
coverPhoto: import_zod12.z.string().nullable(),
|
|
3211
|
+
photosWithTags: import_zod12.z.array(
|
|
3212
|
+
import_zod12.z.object({
|
|
3213
|
+
url: import_zod12.z.string(),
|
|
3214
|
+
tag: import_zod12.z.string()
|
|
3107
3215
|
})
|
|
3108
3216
|
).optional(),
|
|
3109
|
-
featuredPhotos:
|
|
3217
|
+
featuredPhotos: import_zod12.z.array(import_zod12.z.string()).optional()
|
|
3110
3218
|
});
|
|
3111
3219
|
var updateClinicAdminSchema = createClinicAdminSchema.partial();
|
|
3112
3220
|
var updateClinicGroupSchema = createClinicGroupSchema.partial();
|
|
@@ -3293,7 +3401,7 @@ async function getClinicAdminsByGroup(db, clinicGroupId) {
|
|
|
3293
3401
|
(0, import_firestore12.where)("clinicGroupId", "==", clinicGroupId)
|
|
3294
3402
|
);
|
|
3295
3403
|
const querySnapshot = await (0, import_firestore12.getDocs)(q);
|
|
3296
|
-
return querySnapshot.docs.map((
|
|
3404
|
+
return querySnapshot.docs.map((doc30) => doc30.data());
|
|
3297
3405
|
}
|
|
3298
3406
|
async function updateClinicAdmin(db, adminId, data) {
|
|
3299
3407
|
const admin = await getClinicAdmin(db, adminId);
|
|
@@ -3558,7 +3666,7 @@ var ClinicAdminService = class extends BaseService {
|
|
|
3558
3666
|
|
|
3559
3667
|
// src/services/practitioner/practitioner.service.ts
|
|
3560
3668
|
var import_firestore13 = require("firebase/firestore");
|
|
3561
|
-
var
|
|
3669
|
+
var import_zod13 = require("zod");
|
|
3562
3670
|
var import_geofire_common2 = require("geofire-common");
|
|
3563
3671
|
var PractitionerService = class extends BaseService {
|
|
3564
3672
|
constructor(db, auth, app, clinicService) {
|
|
@@ -3627,7 +3735,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3627
3735
|
}
|
|
3628
3736
|
return createdPractitioner;
|
|
3629
3737
|
} catch (error) {
|
|
3630
|
-
if (error instanceof
|
|
3738
|
+
if (error instanceof import_zod13.z.ZodError) {
|
|
3631
3739
|
throw new Error(`Invalid practitioner data: ${error.message}`);
|
|
3632
3740
|
}
|
|
3633
3741
|
console.error("Error creating practitioner:", error);
|
|
@@ -3723,7 +3831,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3723
3831
|
await (0, import_firestore13.setDoc)((0, import_firestore13.doc)(this.db, tokenPath), token);
|
|
3724
3832
|
return { practitioner: savedPractitioner, token };
|
|
3725
3833
|
} catch (error) {
|
|
3726
|
-
if (error instanceof
|
|
3834
|
+
if (error instanceof import_zod13.z.ZodError) {
|
|
3727
3835
|
throw new Error("Invalid practitioner data: " + error.message);
|
|
3728
3836
|
}
|
|
3729
3837
|
throw error;
|
|
@@ -3776,7 +3884,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3776
3884
|
await (0, import_firestore13.setDoc)((0, import_firestore13.doc)(this.db, tokenPath), token);
|
|
3777
3885
|
return token;
|
|
3778
3886
|
} catch (error) {
|
|
3779
|
-
if (error instanceof
|
|
3887
|
+
if (error instanceof import_zod13.z.ZodError) {
|
|
3780
3888
|
throw new Error("Invalid token data: " + error.message);
|
|
3781
3889
|
}
|
|
3782
3890
|
throw error;
|
|
@@ -3798,7 +3906,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3798
3906
|
(0, import_firestore13.where)("expiresAt", ">", import_firestore13.Timestamp.now())
|
|
3799
3907
|
);
|
|
3800
3908
|
const querySnapshot = await (0, import_firestore13.getDocs)(q);
|
|
3801
|
-
return querySnapshot.docs.map((
|
|
3909
|
+
return querySnapshot.docs.map((doc30) => doc30.data());
|
|
3802
3910
|
}
|
|
3803
3911
|
/**
|
|
3804
3912
|
* Gets a token by its string value and validates it
|
|
@@ -3881,7 +3989,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3881
3989
|
(0, import_firestore13.where)("status", "==", "active" /* ACTIVE */)
|
|
3882
3990
|
);
|
|
3883
3991
|
const querySnapshot = await (0, import_firestore13.getDocs)(q);
|
|
3884
|
-
return querySnapshot.docs.map((
|
|
3992
|
+
return querySnapshot.docs.map((doc30) => doc30.data());
|
|
3885
3993
|
}
|
|
3886
3994
|
/**
|
|
3887
3995
|
* Dohvata sve zdravstvene radnike za određenu kliniku
|
|
@@ -3893,7 +4001,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3893
4001
|
(0, import_firestore13.where)("isActive", "==", true)
|
|
3894
4002
|
);
|
|
3895
4003
|
const querySnapshot = await (0, import_firestore13.getDocs)(q);
|
|
3896
|
-
return querySnapshot.docs.map((
|
|
4004
|
+
return querySnapshot.docs.map((doc30) => doc30.data());
|
|
3897
4005
|
}
|
|
3898
4006
|
/**
|
|
3899
4007
|
* Dohvata sve draft zdravstvene radnike za određenu kliniku sa statusom DRAFT
|
|
@@ -3905,7 +4013,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3905
4013
|
(0, import_firestore13.where)("status", "==", "draft" /* DRAFT */)
|
|
3906
4014
|
);
|
|
3907
4015
|
const querySnapshot = await (0, import_firestore13.getDocs)(q);
|
|
3908
|
-
return querySnapshot.docs.map((
|
|
4016
|
+
return querySnapshot.docs.map((doc30) => doc30.data());
|
|
3909
4017
|
}
|
|
3910
4018
|
/**
|
|
3911
4019
|
* Updates a practitioner
|
|
@@ -3936,7 +4044,7 @@ var PractitionerService = class extends BaseService {
|
|
|
3936
4044
|
}
|
|
3937
4045
|
return updatedPractitioner;
|
|
3938
4046
|
} catch (error) {
|
|
3939
|
-
if (error instanceof
|
|
4047
|
+
if (error instanceof import_zod13.z.ZodError) {
|
|
3940
4048
|
throw new Error(`Invalid practitioner update data: ${error.message}`);
|
|
3941
4049
|
}
|
|
3942
4050
|
console.error(`Error updating practitioner ${practitionerId}:`, error);
|
|
@@ -4087,7 +4195,7 @@ var PractitionerService = class extends BaseService {
|
|
|
4087
4195
|
);
|
|
4088
4196
|
const querySnapshot = await (0, import_firestore13.getDocs)(q);
|
|
4089
4197
|
const practitioners = querySnapshot.docs.map(
|
|
4090
|
-
(
|
|
4198
|
+
(doc30) => doc30.data()
|
|
4091
4199
|
);
|
|
4092
4200
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
4093
4201
|
return {
|
|
@@ -4158,8 +4266,8 @@ var PractitionerService = class extends BaseService {
|
|
|
4158
4266
|
console.log(
|
|
4159
4267
|
`[PRACTITIONER_SERVICE] Found ${querySnapshot.docs.length} practitioners with base query`
|
|
4160
4268
|
);
|
|
4161
|
-
let practitioners = querySnapshot.docs.map((
|
|
4162
|
-
return { ...
|
|
4269
|
+
let practitioners = querySnapshot.docs.map((doc30) => {
|
|
4270
|
+
return { ...doc30.data(), id: doc30.id };
|
|
4163
4271
|
});
|
|
4164
4272
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
4165
4273
|
if (filters.nameSearch && filters.nameSearch.trim() !== "") {
|
|
@@ -4413,7 +4521,7 @@ var UserService = class extends BaseService {
|
|
|
4413
4521
|
];
|
|
4414
4522
|
const q = (0, import_firestore14.query)((0, import_firestore14.collection)(this.db, USERS_COLLECTION), ...constraints);
|
|
4415
4523
|
const querySnapshot = await (0, import_firestore14.getDocs)(q);
|
|
4416
|
-
const users = querySnapshot.docs.map((
|
|
4524
|
+
const users = querySnapshot.docs.map((doc30) => doc30.data());
|
|
4417
4525
|
return Promise.all(users.map((userData) => userSchema.parse(userData)));
|
|
4418
4526
|
}
|
|
4419
4527
|
/**
|
|
@@ -4464,7 +4572,7 @@ var UserService = class extends BaseService {
|
|
|
4464
4572
|
});
|
|
4465
4573
|
return this.getUserById(uid);
|
|
4466
4574
|
} catch (error) {
|
|
4467
|
-
if (error instanceof
|
|
4575
|
+
if (error instanceof import_zod14.z.ZodError) {
|
|
4468
4576
|
throw USER_ERRORS.VALIDATION_ERROR;
|
|
4469
4577
|
}
|
|
4470
4578
|
throw error;
|
|
@@ -4551,7 +4659,7 @@ var UserService = class extends BaseService {
|
|
|
4551
4659
|
// src/services/clinic/utils/clinic-group.utils.ts
|
|
4552
4660
|
var import_firestore15 = require("firebase/firestore");
|
|
4553
4661
|
var import_geofire_common3 = require("geofire-common");
|
|
4554
|
-
var
|
|
4662
|
+
var import_zod15 = require("zod");
|
|
4555
4663
|
|
|
4556
4664
|
// src/services/clinic/utils/photos.utils.ts
|
|
4557
4665
|
var import_storage3 = require("firebase/storage");
|
|
@@ -4749,7 +4857,7 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
|
|
|
4749
4857
|
});
|
|
4750
4858
|
return groupData;
|
|
4751
4859
|
} catch (error) {
|
|
4752
|
-
if (error instanceof
|
|
4860
|
+
if (error instanceof import_zod15.z.ZodError) {
|
|
4753
4861
|
console.error(
|
|
4754
4862
|
"[CLINIC_GROUP] Zod validation error:",
|
|
4755
4863
|
JSON.stringify(error.errors, null, 2)
|
|
@@ -4777,7 +4885,7 @@ async function getAllActiveGroups(db) {
|
|
|
4777
4885
|
(0, import_firestore15.where)("isActive", "==", true)
|
|
4778
4886
|
);
|
|
4779
4887
|
const querySnapshot = await (0, import_firestore15.getDocs)(q);
|
|
4780
|
-
return querySnapshot.docs.map((
|
|
4888
|
+
return querySnapshot.docs.map((doc30) => doc30.data());
|
|
4781
4889
|
}
|
|
4782
4890
|
async function updateClinicGroup(db, groupId, data, app) {
|
|
4783
4891
|
console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
|
|
@@ -5154,12 +5262,12 @@ var ClinicGroupService = class extends BaseService {
|
|
|
5154
5262
|
// src/services/clinic/clinic.service.ts
|
|
5155
5263
|
var import_firestore19 = require("firebase/firestore");
|
|
5156
5264
|
var import_geofire_common7 = require("geofire-common");
|
|
5157
|
-
var
|
|
5265
|
+
var import_zod17 = require("zod");
|
|
5158
5266
|
|
|
5159
5267
|
// src/services/clinic/utils/clinic.utils.ts
|
|
5160
5268
|
var import_firestore16 = require("firebase/firestore");
|
|
5161
5269
|
var import_geofire_common4 = require("geofire-common");
|
|
5162
|
-
var
|
|
5270
|
+
var import_zod16 = require("zod");
|
|
5163
5271
|
async function getClinic(db, clinicId) {
|
|
5164
5272
|
const docRef = (0, import_firestore16.doc)(db, CLINICS_COLLECTION, clinicId);
|
|
5165
5273
|
const docSnap = await (0, import_firestore16.getDoc)(docRef);
|
|
@@ -5175,7 +5283,7 @@ async function getClinicsByGroup(db, groupId) {
|
|
|
5175
5283
|
(0, import_firestore16.where)("isActive", "==", true)
|
|
5176
5284
|
);
|
|
5177
5285
|
const querySnapshot = await (0, import_firestore16.getDocs)(q);
|
|
5178
|
-
return querySnapshot.docs.map((
|
|
5286
|
+
return querySnapshot.docs.map((doc30) => doc30.data());
|
|
5179
5287
|
}
|
|
5180
5288
|
async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app) {
|
|
5181
5289
|
console.log("[CLINIC] Starting clinic update", { clinicId, adminId });
|
|
@@ -5369,7 +5477,7 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
|
|
|
5369
5477
|
}
|
|
5370
5478
|
const q = (0, import_firestore16.query)((0, import_firestore16.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
5371
5479
|
const querySnapshot = await (0, import_firestore16.getDocs)(q);
|
|
5372
|
-
return querySnapshot.docs.map((
|
|
5480
|
+
return querySnapshot.docs.map((doc30) => doc30.data());
|
|
5373
5481
|
}
|
|
5374
5482
|
async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
|
|
5375
5483
|
return getClinicsByAdmin(
|
|
@@ -5414,11 +5522,11 @@ async function getAllClinics(db, pagination, lastDoc) {
|
|
|
5414
5522
|
}
|
|
5415
5523
|
const clinicsSnapshot = await (0, import_firestore16.getDocs)(clinicsQuery);
|
|
5416
5524
|
const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
|
|
5417
|
-
const clinics = clinicsSnapshot.docs.map((
|
|
5418
|
-
const data =
|
|
5525
|
+
const clinics = clinicsSnapshot.docs.map((doc30) => {
|
|
5526
|
+
const data = doc30.data();
|
|
5419
5527
|
return {
|
|
5420
5528
|
...data,
|
|
5421
|
-
id:
|
|
5529
|
+
id: doc30.id
|
|
5422
5530
|
};
|
|
5423
5531
|
});
|
|
5424
5532
|
return {
|
|
@@ -5445,8 +5553,8 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc)
|
|
|
5445
5553
|
];
|
|
5446
5554
|
const q = (0, import_firestore16.query)((0, import_firestore16.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
5447
5555
|
const querySnapshot = await (0, import_firestore16.getDocs)(q);
|
|
5448
|
-
for (const
|
|
5449
|
-
const clinic =
|
|
5556
|
+
for (const doc30 of querySnapshot.docs) {
|
|
5557
|
+
const clinic = doc30.data();
|
|
5450
5558
|
const distance = (0, import_geofire_common4.distanceBetween)(
|
|
5451
5559
|
[center.latitude, center.longitude],
|
|
5452
5560
|
[clinic.location.latitude, clinic.location.longitude]
|
|
@@ -5563,8 +5671,8 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
|
|
|
5563
5671
|
}
|
|
5564
5672
|
const q = (0, import_firestore17.query)((0, import_firestore17.collection)(db, CLINICS_COLLECTION), ...constraints);
|
|
5565
5673
|
const querySnapshot = await (0, import_firestore17.getDocs)(q);
|
|
5566
|
-
for (const
|
|
5567
|
-
const clinic =
|
|
5674
|
+
for (const doc30 of querySnapshot.docs) {
|
|
5675
|
+
const clinic = doc30.data();
|
|
5568
5676
|
const distance = (0, import_geofire_common5.distanceBetween)(
|
|
5569
5677
|
[center.latitude, center.longitude],
|
|
5570
5678
|
[clinic.location.latitude, clinic.location.longitude]
|
|
@@ -5652,8 +5760,8 @@ async function getClinicsByFilters(db, filters) {
|
|
|
5652
5760
|
console.log(
|
|
5653
5761
|
`[FILTER_UTILS] Found ${querySnapshot.docs.length} clinics in geo bound`
|
|
5654
5762
|
);
|
|
5655
|
-
for (const
|
|
5656
|
-
const clinic = { ...
|
|
5763
|
+
for (const doc30 of querySnapshot.docs) {
|
|
5764
|
+
const clinic = { ...doc30.data(), id: doc30.id };
|
|
5657
5765
|
const distance = (0, import_geofire_common6.distanceBetween)(
|
|
5658
5766
|
[center.latitude, center.longitude],
|
|
5659
5767
|
[clinic.location.latitude, clinic.location.longitude]
|
|
@@ -5709,8 +5817,8 @@ async function getClinicsByFilters(db, filters) {
|
|
|
5709
5817
|
console.log(
|
|
5710
5818
|
`[FILTER_UTILS] Found ${querySnapshot.docs.length} clinics with regular query`
|
|
5711
5819
|
);
|
|
5712
|
-
const clinics = querySnapshot.docs.map((
|
|
5713
|
-
return { ...
|
|
5820
|
+
const clinics = querySnapshot.docs.map((doc30) => {
|
|
5821
|
+
return { ...doc30.data(), id: doc30.id };
|
|
5714
5822
|
});
|
|
5715
5823
|
let filteredClinics = clinics;
|
|
5716
5824
|
if (filters.center) {
|
|
@@ -5831,7 +5939,7 @@ var ClinicService = class extends BaseService {
|
|
|
5831
5939
|
if (!savedClinic) throw new Error("Failed to retrieve created clinic");
|
|
5832
5940
|
return savedClinic;
|
|
5833
5941
|
} catch (error) {
|
|
5834
|
-
if (error instanceof
|
|
5942
|
+
if (error instanceof import_zod17.z.ZodError) {
|
|
5835
5943
|
throw new Error("Invalid clinic data: " + error.message);
|
|
5836
5944
|
}
|
|
5837
5945
|
console.error("Error creating clinic:", error);
|
|
@@ -5879,7 +5987,7 @@ var ClinicService = class extends BaseService {
|
|
|
5879
5987
|
if (!updatedClinic) throw new Error("Failed to retrieve updated clinic");
|
|
5880
5988
|
return updatedClinic;
|
|
5881
5989
|
} catch (error) {
|
|
5882
|
-
if (error instanceof
|
|
5990
|
+
if (error instanceof import_zod17.z.ZodError) {
|
|
5883
5991
|
throw new Error(
|
|
5884
5992
|
"Invalid clinic update data: " + error.errors.map((e) => `${e.path.join(".")} - ${e.message}`).join(", ")
|
|
5885
5993
|
);
|
|
@@ -6338,7 +6446,7 @@ var AuthService = class extends BaseService {
|
|
|
6338
6446
|
clinicAdmin: adminProfile
|
|
6339
6447
|
};
|
|
6340
6448
|
} catch (error) {
|
|
6341
|
-
if (error instanceof
|
|
6449
|
+
if (error instanceof import_zod18.z.ZodError) {
|
|
6342
6450
|
console.error(
|
|
6343
6451
|
"[AUTH] Zod validation error in signUpClinicAdmin:",
|
|
6344
6452
|
JSON.stringify(error.errors, null, 2)
|
|
@@ -6511,7 +6619,7 @@ var AuthService = class extends BaseService {
|
|
|
6511
6619
|
email
|
|
6512
6620
|
);
|
|
6513
6621
|
} catch (error) {
|
|
6514
|
-
if (error instanceof
|
|
6622
|
+
if (error instanceof import_zod18.z.ZodError) {
|
|
6515
6623
|
throw AUTH_ERRORS.VALIDATION_ERROR;
|
|
6516
6624
|
}
|
|
6517
6625
|
const firebaseError = error;
|
|
@@ -6634,7 +6742,7 @@ var AuthService = class extends BaseService {
|
|
|
6634
6742
|
await emailSchema.parseAsync(email);
|
|
6635
6743
|
await (0, import_auth5.sendPasswordResetEmail)(this.auth, email);
|
|
6636
6744
|
} catch (error) {
|
|
6637
|
-
if (error instanceof
|
|
6745
|
+
if (error instanceof import_zod18.z.ZodError) {
|
|
6638
6746
|
throw AUTH_ERRORS.VALIDATION_ERROR;
|
|
6639
6747
|
}
|
|
6640
6748
|
const firebaseError = error;
|
|
@@ -6673,7 +6781,7 @@ var AuthService = class extends BaseService {
|
|
|
6673
6781
|
await passwordSchema.parseAsync(newPassword);
|
|
6674
6782
|
await (0, import_auth5.confirmPasswordReset)(this.auth, oobCode, newPassword);
|
|
6675
6783
|
} catch (error) {
|
|
6676
|
-
if (error instanceof
|
|
6784
|
+
if (error instanceof import_zod18.z.ZodError) {
|
|
6677
6785
|
throw AUTH_ERRORS.VALIDATION_ERROR;
|
|
6678
6786
|
}
|
|
6679
6787
|
const firebaseError = error;
|
|
@@ -6760,9 +6868,9 @@ var NotificationService = class extends BaseService {
|
|
|
6760
6868
|
(0, import_firestore21.orderBy)("notificationTime", "desc")
|
|
6761
6869
|
);
|
|
6762
6870
|
const querySnapshot = await (0, import_firestore21.getDocs)(q);
|
|
6763
|
-
return querySnapshot.docs.map((
|
|
6764
|
-
id:
|
|
6765
|
-
...
|
|
6871
|
+
return querySnapshot.docs.map((doc30) => ({
|
|
6872
|
+
id: doc30.id,
|
|
6873
|
+
...doc30.data()
|
|
6766
6874
|
}));
|
|
6767
6875
|
}
|
|
6768
6876
|
/**
|
|
@@ -6776,9 +6884,9 @@ var NotificationService = class extends BaseService {
|
|
|
6776
6884
|
(0, import_firestore21.orderBy)("notificationTime", "desc")
|
|
6777
6885
|
);
|
|
6778
6886
|
const querySnapshot = await (0, import_firestore21.getDocs)(q);
|
|
6779
|
-
return querySnapshot.docs.map((
|
|
6780
|
-
id:
|
|
6781
|
-
...
|
|
6887
|
+
return querySnapshot.docs.map((doc30) => ({
|
|
6888
|
+
id: doc30.id,
|
|
6889
|
+
...doc30.data()
|
|
6782
6890
|
}));
|
|
6783
6891
|
}
|
|
6784
6892
|
/**
|
|
@@ -6850,9 +6958,9 @@ var NotificationService = class extends BaseService {
|
|
|
6850
6958
|
(0, import_firestore21.orderBy)("notificationTime", "desc")
|
|
6851
6959
|
);
|
|
6852
6960
|
const querySnapshot = await (0, import_firestore21.getDocs)(q);
|
|
6853
|
-
return querySnapshot.docs.map((
|
|
6854
|
-
id:
|
|
6855
|
-
...
|
|
6961
|
+
return querySnapshot.docs.map((doc30) => ({
|
|
6962
|
+
id: doc30.id,
|
|
6963
|
+
...doc30.data()
|
|
6856
6964
|
}));
|
|
6857
6965
|
}
|
|
6858
6966
|
/**
|
|
@@ -6865,9 +6973,9 @@ var NotificationService = class extends BaseService {
|
|
|
6865
6973
|
(0, import_firestore21.orderBy)("notificationTime", "desc")
|
|
6866
6974
|
);
|
|
6867
6975
|
const querySnapshot = await (0, import_firestore21.getDocs)(q);
|
|
6868
|
-
return querySnapshot.docs.map((
|
|
6869
|
-
id:
|
|
6870
|
-
...
|
|
6976
|
+
return querySnapshot.docs.map((doc30) => ({
|
|
6977
|
+
id: doc30.id,
|
|
6978
|
+
...doc30.data()
|
|
6871
6979
|
}));
|
|
6872
6980
|
}
|
|
6873
6981
|
};
|
|
@@ -6879,59 +6987,59 @@ var import_firestore22 = require("firebase/firestore");
|
|
|
6879
6987
|
var PROCEDURES_COLLECTION = "procedures";
|
|
6880
6988
|
|
|
6881
6989
|
// src/validations/procedure.schema.ts
|
|
6882
|
-
var
|
|
6883
|
-
var createProcedureSchema =
|
|
6884
|
-
name:
|
|
6885
|
-
description:
|
|
6886
|
-
family:
|
|
6887
|
-
categoryId:
|
|
6888
|
-
subcategoryId:
|
|
6889
|
-
technologyId:
|
|
6890
|
-
productId:
|
|
6891
|
-
price:
|
|
6892
|
-
currency:
|
|
6893
|
-
pricingMeasure:
|
|
6894
|
-
duration:
|
|
6990
|
+
var import_zod19 = require("zod");
|
|
6991
|
+
var createProcedureSchema = import_zod19.z.object({
|
|
6992
|
+
name: import_zod19.z.string().min(1).max(200),
|
|
6993
|
+
description: import_zod19.z.string().min(1).max(2e3),
|
|
6994
|
+
family: import_zod19.z.nativeEnum(ProcedureFamily),
|
|
6995
|
+
categoryId: import_zod19.z.string().min(1),
|
|
6996
|
+
subcategoryId: import_zod19.z.string().min(1),
|
|
6997
|
+
technologyId: import_zod19.z.string().min(1),
|
|
6998
|
+
productId: import_zod19.z.string().min(1),
|
|
6999
|
+
price: import_zod19.z.number().min(0),
|
|
7000
|
+
currency: import_zod19.z.nativeEnum(Currency),
|
|
7001
|
+
pricingMeasure: import_zod19.z.nativeEnum(PricingMeasure),
|
|
7002
|
+
duration: import_zod19.z.number().min(1).max(480),
|
|
6895
7003
|
// Max 8 hours
|
|
6896
|
-
practitionerId:
|
|
6897
|
-
clinicBranchId:
|
|
7004
|
+
practitionerId: import_zod19.z.string().min(1),
|
|
7005
|
+
clinicBranchId: import_zod19.z.string().min(1)
|
|
6898
7006
|
});
|
|
6899
|
-
var updateProcedureSchema =
|
|
6900
|
-
name:
|
|
6901
|
-
description:
|
|
6902
|
-
price:
|
|
6903
|
-
currency:
|
|
6904
|
-
pricingMeasure:
|
|
6905
|
-
duration:
|
|
6906
|
-
isActive:
|
|
6907
|
-
practitionerId:
|
|
6908
|
-
categoryId:
|
|
6909
|
-
subcategoryId:
|
|
6910
|
-
technologyId:
|
|
6911
|
-
productId:
|
|
6912
|
-
clinicBranchId:
|
|
7007
|
+
var updateProcedureSchema = import_zod19.z.object({
|
|
7008
|
+
name: import_zod19.z.string().min(3).max(100).optional(),
|
|
7009
|
+
description: import_zod19.z.string().min(3).max(1e3).optional(),
|
|
7010
|
+
price: import_zod19.z.number().min(0).optional(),
|
|
7011
|
+
currency: import_zod19.z.nativeEnum(Currency).optional(),
|
|
7012
|
+
pricingMeasure: import_zod19.z.nativeEnum(PricingMeasure).optional(),
|
|
7013
|
+
duration: import_zod19.z.number().min(0).optional(),
|
|
7014
|
+
isActive: import_zod19.z.boolean().optional(),
|
|
7015
|
+
practitionerId: import_zod19.z.string().optional(),
|
|
7016
|
+
categoryId: import_zod19.z.string().optional(),
|
|
7017
|
+
subcategoryId: import_zod19.z.string().optional(),
|
|
7018
|
+
technologyId: import_zod19.z.string().optional(),
|
|
7019
|
+
productId: import_zod19.z.string().optional(),
|
|
7020
|
+
clinicBranchId: import_zod19.z.string().optional()
|
|
6913
7021
|
});
|
|
6914
7022
|
var procedureSchema = createProcedureSchema.extend({
|
|
6915
|
-
id:
|
|
6916
|
-
category:
|
|
7023
|
+
id: import_zod19.z.string().min(1),
|
|
7024
|
+
category: import_zod19.z.any(),
|
|
6917
7025
|
// We'll validate the full category object separately
|
|
6918
|
-
subcategory:
|
|
7026
|
+
subcategory: import_zod19.z.any(),
|
|
6919
7027
|
// We'll validate the full subcategory object separately
|
|
6920
|
-
technology:
|
|
7028
|
+
technology: import_zod19.z.any(),
|
|
6921
7029
|
// We'll validate the full technology object separately
|
|
6922
|
-
product:
|
|
7030
|
+
product: import_zod19.z.any(),
|
|
6923
7031
|
// We'll validate the full product object separately
|
|
6924
|
-
blockingConditions:
|
|
7032
|
+
blockingConditions: import_zod19.z.array(import_zod19.z.any()),
|
|
6925
7033
|
// We'll validate blocking conditions separately
|
|
6926
|
-
treatmentBenefits:
|
|
7034
|
+
treatmentBenefits: import_zod19.z.array(import_zod19.z.any()),
|
|
6927
7035
|
// We'll validate treatment benefits separately
|
|
6928
|
-
preRequirements:
|
|
7036
|
+
preRequirements: import_zod19.z.array(import_zod19.z.any()),
|
|
6929
7037
|
// We'll validate requirements separately
|
|
6930
|
-
postRequirements:
|
|
7038
|
+
postRequirements: import_zod19.z.array(import_zod19.z.any()),
|
|
6931
7039
|
// We'll validate requirements separately
|
|
6932
|
-
certificationRequirement:
|
|
7040
|
+
certificationRequirement: import_zod19.z.any(),
|
|
6933
7041
|
// We'll validate certification requirement separately
|
|
6934
|
-
documentationTemplates:
|
|
7042
|
+
documentationTemplates: import_zod19.z.array(import_zod19.z.any()),
|
|
6935
7043
|
// We'll validate documentation templates separately
|
|
6936
7044
|
clinicInfo: clinicInfoSchema,
|
|
6937
7045
|
// Clinic info validation
|
|
@@ -6939,9 +7047,9 @@ var procedureSchema = createProcedureSchema.extend({
|
|
|
6939
7047
|
// Doctor info validation
|
|
6940
7048
|
reviewInfo: procedureReviewInfoSchema,
|
|
6941
7049
|
// Procedure review info validation
|
|
6942
|
-
isActive:
|
|
6943
|
-
createdAt:
|
|
6944
|
-
updatedAt:
|
|
7050
|
+
isActive: import_zod19.z.boolean(),
|
|
7051
|
+
createdAt: import_zod19.z.date(),
|
|
7052
|
+
updatedAt: import_zod19.z.date()
|
|
6945
7053
|
});
|
|
6946
7054
|
|
|
6947
7055
|
// src/services/procedure/procedure.service.ts
|
|
@@ -7084,7 +7192,7 @@ var ProcedureService = class extends BaseService {
|
|
|
7084
7192
|
(0, import_firestore22.where)("isActive", "==", true)
|
|
7085
7193
|
);
|
|
7086
7194
|
const snapshot = await (0, import_firestore22.getDocs)(q);
|
|
7087
|
-
return snapshot.docs.map((
|
|
7195
|
+
return snapshot.docs.map((doc30) => doc30.data());
|
|
7088
7196
|
}
|
|
7089
7197
|
/**
|
|
7090
7198
|
* Gets all procedures for a practitioner
|
|
@@ -7098,7 +7206,7 @@ var ProcedureService = class extends BaseService {
|
|
|
7098
7206
|
(0, import_firestore22.where)("isActive", "==", true)
|
|
7099
7207
|
);
|
|
7100
7208
|
const snapshot = await (0, import_firestore22.getDocs)(q);
|
|
7101
|
-
return snapshot.docs.map((
|
|
7209
|
+
return snapshot.docs.map((doc30) => doc30.data());
|
|
7102
7210
|
}
|
|
7103
7211
|
/**
|
|
7104
7212
|
* Updates a procedure
|
|
@@ -7281,20 +7389,20 @@ var ProcedureService = class extends BaseService {
|
|
|
7281
7389
|
const proceduresCollection = (0, import_firestore22.collection)(this.db, PROCEDURES_COLLECTION);
|
|
7282
7390
|
let proceduresQuery = (0, import_firestore22.query)(proceduresCollection);
|
|
7283
7391
|
if (pagination && pagination > 0) {
|
|
7284
|
-
const { limit:
|
|
7392
|
+
const { limit: limit9, startAfter: startAfter9 } = await import("firebase/firestore");
|
|
7285
7393
|
if (lastDoc) {
|
|
7286
7394
|
proceduresQuery = (0, import_firestore22.query)(
|
|
7287
7395
|
proceduresCollection,
|
|
7288
7396
|
(0, import_firestore22.orderBy)("name"),
|
|
7289
7397
|
// Use imported orderBy
|
|
7290
|
-
|
|
7291
|
-
|
|
7398
|
+
startAfter9(lastDoc),
|
|
7399
|
+
limit9(pagination)
|
|
7292
7400
|
);
|
|
7293
7401
|
} else {
|
|
7294
7402
|
proceduresQuery = (0, import_firestore22.query)(
|
|
7295
7403
|
proceduresCollection,
|
|
7296
7404
|
(0, import_firestore22.orderBy)("name"),
|
|
7297
|
-
|
|
7405
|
+
limit9(pagination)
|
|
7298
7406
|
);
|
|
7299
7407
|
}
|
|
7300
7408
|
} else {
|
|
@@ -7302,11 +7410,11 @@ var ProcedureService = class extends BaseService {
|
|
|
7302
7410
|
}
|
|
7303
7411
|
const proceduresSnapshot = await (0, import_firestore22.getDocs)(proceduresQuery);
|
|
7304
7412
|
const lastVisible = proceduresSnapshot.docs[proceduresSnapshot.docs.length - 1];
|
|
7305
|
-
const procedures = proceduresSnapshot.docs.map((
|
|
7306
|
-
const data =
|
|
7413
|
+
const procedures = proceduresSnapshot.docs.map((doc30) => {
|
|
7414
|
+
const data = doc30.data();
|
|
7307
7415
|
return {
|
|
7308
7416
|
...data,
|
|
7309
|
-
id:
|
|
7417
|
+
id: doc30.id
|
|
7310
7418
|
// Ensure ID is present
|
|
7311
7419
|
};
|
|
7312
7420
|
});
|
|
@@ -7388,8 +7496,8 @@ var ProcedureService = class extends BaseService {
|
|
|
7388
7496
|
console.log(
|
|
7389
7497
|
`[PROCEDURE_SERVICE] Found ${querySnapshot.docs.length} procedures in geo bound`
|
|
7390
7498
|
);
|
|
7391
|
-
for (const
|
|
7392
|
-
const procedure = { ...
|
|
7499
|
+
for (const doc30 of querySnapshot.docs) {
|
|
7500
|
+
const procedure = { ...doc30.data(), id: doc30.id };
|
|
7393
7501
|
const distance = (0, import_geofire_common8.distanceBetween)(
|
|
7394
7502
|
[center.latitude, center.longitude],
|
|
7395
7503
|
[
|
|
@@ -7440,8 +7548,8 @@ var ProcedureService = class extends BaseService {
|
|
|
7440
7548
|
console.log(
|
|
7441
7549
|
`[PROCEDURE_SERVICE] Found ${querySnapshot.docs.length} procedures with regular query`
|
|
7442
7550
|
);
|
|
7443
|
-
const procedures = querySnapshot.docs.map((
|
|
7444
|
-
return { ...
|
|
7551
|
+
const procedures = querySnapshot.docs.map((doc30) => {
|
|
7552
|
+
return { ...doc30.data(), id: doc30.id };
|
|
7445
7553
|
});
|
|
7446
7554
|
if (filters.location) {
|
|
7447
7555
|
const center = filters.location;
|
|
@@ -7659,9 +7767,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
7659
7767
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
7660
7768
|
const templates = [];
|
|
7661
7769
|
let lastVisible = null;
|
|
7662
|
-
querySnapshot.forEach((
|
|
7663
|
-
templates.push(
|
|
7664
|
-
lastVisible =
|
|
7770
|
+
querySnapshot.forEach((doc30) => {
|
|
7771
|
+
templates.push(doc30.data());
|
|
7772
|
+
lastVisible = doc30;
|
|
7665
7773
|
});
|
|
7666
7774
|
return {
|
|
7667
7775
|
templates,
|
|
@@ -7689,9 +7797,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
7689
7797
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
7690
7798
|
const templates = [];
|
|
7691
7799
|
let lastVisible = null;
|
|
7692
|
-
querySnapshot.forEach((
|
|
7693
|
-
templates.push(
|
|
7694
|
-
lastVisible =
|
|
7800
|
+
querySnapshot.forEach((doc30) => {
|
|
7801
|
+
templates.push(doc30.data());
|
|
7802
|
+
lastVisible = doc30;
|
|
7695
7803
|
});
|
|
7696
7804
|
return {
|
|
7697
7805
|
templates,
|
|
@@ -7718,9 +7826,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
7718
7826
|
const querySnapshot = await (0, import_firestore23.getDocs)(q);
|
|
7719
7827
|
const templates = [];
|
|
7720
7828
|
let lastVisible = null;
|
|
7721
|
-
querySnapshot.forEach((
|
|
7722
|
-
templates.push(
|
|
7723
|
-
lastVisible =
|
|
7829
|
+
querySnapshot.forEach((doc30) => {
|
|
7830
|
+
templates.push(doc30.data());
|
|
7831
|
+
lastVisible = doc30;
|
|
7724
7832
|
});
|
|
7725
7833
|
return {
|
|
7726
7834
|
templates,
|
|
@@ -7833,9 +7941,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
7833
7941
|
const querySnapshot = await (0, import_firestore24.getDocs)(q);
|
|
7834
7942
|
const documents = [];
|
|
7835
7943
|
let lastVisible = null;
|
|
7836
|
-
querySnapshot.forEach((
|
|
7837
|
-
documents.push(
|
|
7838
|
-
lastVisible =
|
|
7944
|
+
querySnapshot.forEach((doc30) => {
|
|
7945
|
+
documents.push(doc30.data());
|
|
7946
|
+
lastVisible = doc30;
|
|
7839
7947
|
});
|
|
7840
7948
|
return {
|
|
7841
7949
|
documents,
|
|
@@ -7862,9 +7970,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
7862
7970
|
const querySnapshot = await (0, import_firestore24.getDocs)(q);
|
|
7863
7971
|
const documents = [];
|
|
7864
7972
|
let lastVisible = null;
|
|
7865
|
-
querySnapshot.forEach((
|
|
7866
|
-
documents.push(
|
|
7867
|
-
lastVisible =
|
|
7973
|
+
querySnapshot.forEach((doc30) => {
|
|
7974
|
+
documents.push(doc30.data());
|
|
7975
|
+
lastVisible = doc30;
|
|
7868
7976
|
});
|
|
7869
7977
|
return {
|
|
7870
7978
|
documents,
|
|
@@ -7891,9 +7999,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
7891
7999
|
const querySnapshot = await (0, import_firestore24.getDocs)(q);
|
|
7892
8000
|
const documents = [];
|
|
7893
8001
|
let lastVisible = null;
|
|
7894
|
-
querySnapshot.forEach((
|
|
7895
|
-
documents.push(
|
|
7896
|
-
lastVisible =
|
|
8002
|
+
querySnapshot.forEach((doc30) => {
|
|
8003
|
+
documents.push(doc30.data());
|
|
8004
|
+
lastVisible = doc30;
|
|
7897
8005
|
});
|
|
7898
8006
|
return {
|
|
7899
8007
|
documents,
|
|
@@ -7920,9 +8028,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
7920
8028
|
const querySnapshot = await (0, import_firestore24.getDocs)(q);
|
|
7921
8029
|
const documents = [];
|
|
7922
8030
|
let lastVisible = null;
|
|
7923
|
-
querySnapshot.forEach((
|
|
7924
|
-
documents.push(
|
|
7925
|
-
lastVisible =
|
|
8031
|
+
querySnapshot.forEach((doc30) => {
|
|
8032
|
+
documents.push(doc30.data());
|
|
8033
|
+
lastVisible = doc30;
|
|
7926
8034
|
});
|
|
7927
8035
|
return {
|
|
7928
8036
|
documents,
|
|
@@ -7949,9 +8057,9 @@ var FilledDocumentService = class extends BaseService {
|
|
|
7949
8057
|
const querySnapshot = await (0, import_firestore24.getDocs)(q);
|
|
7950
8058
|
const documents = [];
|
|
7951
8059
|
let lastVisible = null;
|
|
7952
|
-
querySnapshot.forEach((
|
|
7953
|
-
documents.push(
|
|
7954
|
-
lastVisible =
|
|
8060
|
+
querySnapshot.forEach((doc30) => {
|
|
8061
|
+
documents.push(doc30.data());
|
|
8062
|
+
lastVisible = doc30;
|
|
7955
8063
|
});
|
|
7956
8064
|
return {
|
|
7957
8065
|
documents,
|
|
@@ -7976,42 +8084,42 @@ var SYNCED_CALENDARS_COLLECTION = "syncedCalendars";
|
|
|
7976
8084
|
var import_firestore35 = require("firebase/firestore");
|
|
7977
8085
|
|
|
7978
8086
|
// src/validations/calendar.schema.ts
|
|
7979
|
-
var
|
|
8087
|
+
var import_zod21 = require("zod");
|
|
7980
8088
|
var import_firestore26 = require("firebase/firestore");
|
|
7981
8089
|
|
|
7982
8090
|
// src/validations/profile-info.schema.ts
|
|
7983
|
-
var
|
|
8091
|
+
var import_zod20 = require("zod");
|
|
7984
8092
|
var import_firestore25 = require("firebase/firestore");
|
|
7985
|
-
var clinicInfoSchema2 =
|
|
7986
|
-
id:
|
|
7987
|
-
featuredPhoto:
|
|
7988
|
-
name:
|
|
7989
|
-
description:
|
|
8093
|
+
var clinicInfoSchema2 = import_zod20.z.object({
|
|
8094
|
+
id: import_zod20.z.string(),
|
|
8095
|
+
featuredPhoto: import_zod20.z.string(),
|
|
8096
|
+
name: import_zod20.z.string(),
|
|
8097
|
+
description: import_zod20.z.string(),
|
|
7990
8098
|
location: clinicLocationSchema,
|
|
7991
8099
|
contactInfo: clinicContactInfoSchema
|
|
7992
8100
|
});
|
|
7993
|
-
var practitionerProfileInfoSchema =
|
|
7994
|
-
id:
|
|
7995
|
-
practitionerPhoto:
|
|
7996
|
-
name:
|
|
7997
|
-
email:
|
|
7998
|
-
phone:
|
|
8101
|
+
var practitionerProfileInfoSchema = import_zod20.z.object({
|
|
8102
|
+
id: import_zod20.z.string(),
|
|
8103
|
+
practitionerPhoto: import_zod20.z.string().nullable(),
|
|
8104
|
+
name: import_zod20.z.string(),
|
|
8105
|
+
email: import_zod20.z.string().email(),
|
|
8106
|
+
phone: import_zod20.z.string().nullable(),
|
|
7999
8107
|
certification: practitionerCertificationSchema
|
|
8000
8108
|
});
|
|
8001
|
-
var patientProfileInfoSchema =
|
|
8002
|
-
id:
|
|
8003
|
-
fullName:
|
|
8004
|
-
email:
|
|
8005
|
-
phone:
|
|
8006
|
-
dateOfBirth:
|
|
8007
|
-
gender:
|
|
8109
|
+
var patientProfileInfoSchema = import_zod20.z.object({
|
|
8110
|
+
id: import_zod20.z.string(),
|
|
8111
|
+
fullName: import_zod20.z.string(),
|
|
8112
|
+
email: import_zod20.z.string().email(),
|
|
8113
|
+
phone: import_zod20.z.string().nullable(),
|
|
8114
|
+
dateOfBirth: import_zod20.z.instanceof(import_firestore25.Timestamp),
|
|
8115
|
+
gender: import_zod20.z.nativeEnum(Gender)
|
|
8008
8116
|
});
|
|
8009
8117
|
|
|
8010
8118
|
// src/validations/calendar.schema.ts
|
|
8011
8119
|
var MIN_APPOINTMENT_DURATION = 15;
|
|
8012
|
-
var calendarEventTimeSchema =
|
|
8013
|
-
start:
|
|
8014
|
-
end:
|
|
8120
|
+
var calendarEventTimeSchema = import_zod21.z.object({
|
|
8121
|
+
start: import_zod21.z.instanceof(Date).or(import_zod21.z.instanceof(import_firestore26.Timestamp)),
|
|
8122
|
+
end: import_zod21.z.instanceof(Date).or(import_zod21.z.instanceof(import_firestore26.Timestamp))
|
|
8015
8123
|
}).refine(
|
|
8016
8124
|
(data) => {
|
|
8017
8125
|
const startDate = data.start instanceof import_firestore26.Timestamp ? data.start.toDate() : data.start;
|
|
@@ -8032,46 +8140,46 @@ var calendarEventTimeSchema = import_zod20.z.object({
|
|
|
8032
8140
|
path: ["start"]
|
|
8033
8141
|
}
|
|
8034
8142
|
);
|
|
8035
|
-
var timeSlotSchema2 =
|
|
8036
|
-
start:
|
|
8037
|
-
end:
|
|
8038
|
-
isAvailable:
|
|
8143
|
+
var timeSlotSchema2 = import_zod21.z.object({
|
|
8144
|
+
start: import_zod21.z.date(),
|
|
8145
|
+
end: import_zod21.z.date(),
|
|
8146
|
+
isAvailable: import_zod21.z.boolean()
|
|
8039
8147
|
}).refine((data) => data.start < data.end, {
|
|
8040
8148
|
message: "End time must be after start time",
|
|
8041
8149
|
path: ["end"]
|
|
8042
8150
|
});
|
|
8043
|
-
var syncedCalendarEventSchema =
|
|
8044
|
-
eventId:
|
|
8045
|
-
syncedCalendarProvider:
|
|
8046
|
-
syncedAt:
|
|
8151
|
+
var syncedCalendarEventSchema = import_zod21.z.object({
|
|
8152
|
+
eventId: import_zod21.z.string(),
|
|
8153
|
+
syncedCalendarProvider: import_zod21.z.nativeEnum(SyncedCalendarProvider),
|
|
8154
|
+
syncedAt: import_zod21.z.instanceof(Date).or(import_zod21.z.instanceof(import_firestore26.Timestamp))
|
|
8047
8155
|
});
|
|
8048
|
-
var procedureInfoSchema =
|
|
8049
|
-
name:
|
|
8050
|
-
description:
|
|
8051
|
-
duration:
|
|
8052
|
-
price:
|
|
8053
|
-
currency:
|
|
8156
|
+
var procedureInfoSchema = import_zod21.z.object({
|
|
8157
|
+
name: import_zod21.z.string(),
|
|
8158
|
+
description: import_zod21.z.string(),
|
|
8159
|
+
duration: import_zod21.z.number().min(MIN_APPOINTMENT_DURATION),
|
|
8160
|
+
price: import_zod21.z.number().min(0),
|
|
8161
|
+
currency: import_zod21.z.nativeEnum(Currency)
|
|
8054
8162
|
});
|
|
8055
|
-
var procedureCategorizationSchema =
|
|
8056
|
-
procedureFamily:
|
|
8163
|
+
var procedureCategorizationSchema = import_zod21.z.object({
|
|
8164
|
+
procedureFamily: import_zod21.z.string(),
|
|
8057
8165
|
// Replace with proper enum when available
|
|
8058
|
-
procedureCategory:
|
|
8166
|
+
procedureCategory: import_zod21.z.string(),
|
|
8059
8167
|
// Replace with proper enum when available
|
|
8060
|
-
procedureSubcategory:
|
|
8168
|
+
procedureSubcategory: import_zod21.z.string(),
|
|
8061
8169
|
// Replace with proper enum when available
|
|
8062
|
-
procedureTechnology:
|
|
8170
|
+
procedureTechnology: import_zod21.z.string(),
|
|
8063
8171
|
// Replace with proper enum when available
|
|
8064
|
-
procedureProduct:
|
|
8172
|
+
procedureProduct: import_zod21.z.string()
|
|
8065
8173
|
// Replace with proper enum when available
|
|
8066
8174
|
});
|
|
8067
|
-
var
|
|
8068
|
-
clinicId:
|
|
8069
|
-
doctorId:
|
|
8070
|
-
patientId:
|
|
8071
|
-
procedureId:
|
|
8175
|
+
var createAppointmentSchema2 = import_zod21.z.object({
|
|
8176
|
+
clinicId: import_zod21.z.string().min(1, "Clinic ID is required"),
|
|
8177
|
+
doctorId: import_zod21.z.string().min(1, "Doctor ID is required"),
|
|
8178
|
+
patientId: import_zod21.z.string().min(1, "Patient ID is required"),
|
|
8179
|
+
procedureId: import_zod21.z.string().min(1, "Procedure ID is required"),
|
|
8072
8180
|
eventLocation: clinicLocationSchema,
|
|
8073
8181
|
eventTime: calendarEventTimeSchema,
|
|
8074
|
-
description:
|
|
8182
|
+
description: import_zod21.z.string().optional()
|
|
8075
8183
|
}).refine(
|
|
8076
8184
|
(data) => {
|
|
8077
8185
|
return true;
|
|
@@ -8080,73 +8188,73 @@ var createAppointmentSchema = import_zod20.z.object({
|
|
|
8080
8188
|
message: "Invalid appointment parameters"
|
|
8081
8189
|
}
|
|
8082
8190
|
);
|
|
8083
|
-
var
|
|
8084
|
-
appointmentId:
|
|
8085
|
-
clinicId:
|
|
8086
|
-
doctorId:
|
|
8087
|
-
patientId:
|
|
8191
|
+
var updateAppointmentSchema2 = import_zod21.z.object({
|
|
8192
|
+
appointmentId: import_zod21.z.string().min(1, "Appointment ID is required"),
|
|
8193
|
+
clinicId: import_zod21.z.string().min(1, "Clinic ID is required"),
|
|
8194
|
+
doctorId: import_zod21.z.string().min(1, "Doctor ID is required"),
|
|
8195
|
+
patientId: import_zod21.z.string().min(1, "Patient ID is required"),
|
|
8088
8196
|
eventTime: calendarEventTimeSchema.optional(),
|
|
8089
|
-
description:
|
|
8090
|
-
status:
|
|
8197
|
+
description: import_zod21.z.string().optional(),
|
|
8198
|
+
status: import_zod21.z.nativeEnum(CalendarEventStatus).optional()
|
|
8091
8199
|
});
|
|
8092
|
-
var createCalendarEventSchema =
|
|
8093
|
-
id:
|
|
8094
|
-
clinicBranchId:
|
|
8095
|
-
clinicBranchInfo:
|
|
8096
|
-
practitionerProfileId:
|
|
8200
|
+
var createCalendarEventSchema = import_zod21.z.object({
|
|
8201
|
+
id: import_zod21.z.string(),
|
|
8202
|
+
clinicBranchId: import_zod21.z.string().nullable().optional(),
|
|
8203
|
+
clinicBranchInfo: import_zod21.z.any().nullable().optional(),
|
|
8204
|
+
practitionerProfileId: import_zod21.z.string().nullable().optional(),
|
|
8097
8205
|
practitionerProfileInfo: practitionerProfileInfoSchema.nullable().optional(),
|
|
8098
|
-
patientProfileId:
|
|
8206
|
+
patientProfileId: import_zod21.z.string().nullable().optional(),
|
|
8099
8207
|
patientProfileInfo: patientProfileInfoSchema.nullable().optional(),
|
|
8100
|
-
procedureId:
|
|
8101
|
-
appointmentId:
|
|
8102
|
-
syncedCalendarEventId:
|
|
8103
|
-
eventName:
|
|
8208
|
+
procedureId: import_zod21.z.string().nullable().optional(),
|
|
8209
|
+
appointmentId: import_zod21.z.string().nullable().optional(),
|
|
8210
|
+
syncedCalendarEventId: import_zod21.z.array(syncedCalendarEventSchema).nullable().optional(),
|
|
8211
|
+
eventName: import_zod21.z.string().min(1, "Event name is required"),
|
|
8104
8212
|
eventLocation: clinicLocationSchema.optional(),
|
|
8105
8213
|
eventTime: calendarEventTimeSchema,
|
|
8106
|
-
description:
|
|
8107
|
-
status:
|
|
8108
|
-
syncStatus:
|
|
8109
|
-
eventType:
|
|
8110
|
-
createdAt:
|
|
8214
|
+
description: import_zod21.z.string().optional(),
|
|
8215
|
+
status: import_zod21.z.nativeEnum(CalendarEventStatus),
|
|
8216
|
+
syncStatus: import_zod21.z.nativeEnum(CalendarSyncStatus),
|
|
8217
|
+
eventType: import_zod21.z.nativeEnum(CalendarEventType),
|
|
8218
|
+
createdAt: import_zod21.z.any(),
|
|
8111
8219
|
// FieldValue for server timestamp
|
|
8112
|
-
updatedAt:
|
|
8220
|
+
updatedAt: import_zod21.z.any()
|
|
8113
8221
|
// FieldValue for server timestamp
|
|
8114
8222
|
});
|
|
8115
|
-
var updateCalendarEventSchema =
|
|
8116
|
-
syncedCalendarEventId:
|
|
8117
|
-
appointmentId:
|
|
8118
|
-
eventName:
|
|
8223
|
+
var updateCalendarEventSchema = import_zod21.z.object({
|
|
8224
|
+
syncedCalendarEventId: import_zod21.z.array(syncedCalendarEventSchema).nullable().optional(),
|
|
8225
|
+
appointmentId: import_zod21.z.string().nullable().optional(),
|
|
8226
|
+
eventName: import_zod21.z.string().optional(),
|
|
8119
8227
|
eventTime: calendarEventTimeSchema.optional(),
|
|
8120
|
-
description:
|
|
8121
|
-
status:
|
|
8122
|
-
syncStatus:
|
|
8123
|
-
eventType:
|
|
8124
|
-
updatedAt:
|
|
8228
|
+
description: import_zod21.z.string().optional(),
|
|
8229
|
+
status: import_zod21.z.nativeEnum(CalendarEventStatus).optional(),
|
|
8230
|
+
syncStatus: import_zod21.z.nativeEnum(CalendarSyncStatus).optional(),
|
|
8231
|
+
eventType: import_zod21.z.nativeEnum(CalendarEventType).optional(),
|
|
8232
|
+
updatedAt: import_zod21.z.any()
|
|
8125
8233
|
// FieldValue for server timestamp
|
|
8126
8234
|
});
|
|
8127
|
-
var calendarEventSchema =
|
|
8128
|
-
id:
|
|
8129
|
-
clinicBranchId:
|
|
8130
|
-
clinicBranchInfo:
|
|
8235
|
+
var calendarEventSchema = import_zod21.z.object({
|
|
8236
|
+
id: import_zod21.z.string(),
|
|
8237
|
+
clinicBranchId: import_zod21.z.string().nullable().optional(),
|
|
8238
|
+
clinicBranchInfo: import_zod21.z.any().nullable().optional(),
|
|
8131
8239
|
// Will be replaced with proper clinic info schema
|
|
8132
|
-
practitionerProfileId:
|
|
8240
|
+
practitionerProfileId: import_zod21.z.string().nullable().optional(),
|
|
8133
8241
|
practitionerProfileInfo: practitionerProfileInfoSchema.nullable().optional(),
|
|
8134
|
-
patientProfileId:
|
|
8242
|
+
patientProfileId: import_zod21.z.string().nullable().optional(),
|
|
8135
8243
|
patientProfileInfo: patientProfileInfoSchema.nullable().optional(),
|
|
8136
|
-
procedureId:
|
|
8244
|
+
procedureId: import_zod21.z.string().nullable().optional(),
|
|
8137
8245
|
procedureInfo: procedureInfoSchema.nullable().optional(),
|
|
8138
8246
|
procedureCategorization: procedureCategorizationSchema.nullable().optional(),
|
|
8139
|
-
appointmentId:
|
|
8140
|
-
syncedCalendarEventId:
|
|
8141
|
-
eventName:
|
|
8247
|
+
appointmentId: import_zod21.z.string().nullable().optional(),
|
|
8248
|
+
syncedCalendarEventId: import_zod21.z.array(syncedCalendarEventSchema).nullable().optional(),
|
|
8249
|
+
eventName: import_zod21.z.string(),
|
|
8142
8250
|
eventLocation: clinicLocationSchema.optional(),
|
|
8143
8251
|
eventTime: calendarEventTimeSchema,
|
|
8144
|
-
description:
|
|
8145
|
-
status:
|
|
8146
|
-
syncStatus:
|
|
8147
|
-
eventType:
|
|
8148
|
-
createdAt:
|
|
8149
|
-
updatedAt:
|
|
8252
|
+
description: import_zod21.z.string().optional(),
|
|
8253
|
+
status: import_zod21.z.nativeEnum(CalendarEventStatus),
|
|
8254
|
+
syncStatus: import_zod21.z.nativeEnum(CalendarSyncStatus),
|
|
8255
|
+
eventType: import_zod21.z.nativeEnum(CalendarEventType),
|
|
8256
|
+
createdAt: import_zod21.z.instanceof(Date).or(import_zod21.z.instanceof(import_firestore26.Timestamp)),
|
|
8257
|
+
updatedAt: import_zod21.z.instanceof(Date).or(import_zod21.z.instanceof(import_firestore26.Timestamp))
|
|
8150
8258
|
});
|
|
8151
8259
|
|
|
8152
8260
|
// src/services/calendar/utils/clinic.utils.ts
|
|
@@ -8448,7 +8556,7 @@ async function searchCalendarEventsUtil(db, params) {
|
|
|
8448
8556
|
const finalQuery = (0, import_firestore31.query)(collectionRef, ...constraints);
|
|
8449
8557
|
const querySnapshot = await (0, import_firestore31.getDocs)(finalQuery);
|
|
8450
8558
|
const events = querySnapshot.docs.map(
|
|
8451
|
-
(
|
|
8559
|
+
(doc30) => ({ id: doc30.id, ...doc30.data() })
|
|
8452
8560
|
);
|
|
8453
8561
|
return events;
|
|
8454
8562
|
} catch (error) {
|
|
@@ -8530,7 +8638,7 @@ async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
|
|
|
8530
8638
|
);
|
|
8531
8639
|
const q = (0, import_firestore32.query)(calendarsRef, (0, import_firestore32.orderBy)("createdAt", "desc"));
|
|
8532
8640
|
const querySnapshot = await (0, import_firestore32.getDocs)(q);
|
|
8533
|
-
return querySnapshot.docs.map((
|
|
8641
|
+
return querySnapshot.docs.map((doc30) => doc30.data());
|
|
8534
8642
|
}
|
|
8535
8643
|
async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
|
|
8536
8644
|
const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
|
|
@@ -8547,7 +8655,7 @@ async function getPatientSyncedCalendarsUtil(db, patientId) {
|
|
|
8547
8655
|
);
|
|
8548
8656
|
const q = (0, import_firestore32.query)(calendarsRef, (0, import_firestore32.orderBy)("createdAt", "desc"));
|
|
8549
8657
|
const querySnapshot = await (0, import_firestore32.getDocs)(q);
|
|
8550
|
-
return querySnapshot.docs.map((
|
|
8658
|
+
return querySnapshot.docs.map((doc30) => doc30.data());
|
|
8551
8659
|
}
|
|
8552
8660
|
async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
|
|
8553
8661
|
const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
|
|
@@ -8564,7 +8672,7 @@ async function getClinicSyncedCalendarsUtil(db, clinicId) {
|
|
|
8564
8672
|
);
|
|
8565
8673
|
const q = (0, import_firestore32.query)(calendarsRef, (0, import_firestore32.orderBy)("createdAt", "desc"));
|
|
8566
8674
|
const querySnapshot = await (0, import_firestore32.getDocs)(q);
|
|
8567
|
-
return querySnapshot.docs.map((
|
|
8675
|
+
return querySnapshot.docs.map((doc30) => doc30.data());
|
|
8568
8676
|
}
|
|
8569
8677
|
async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
|
|
8570
8678
|
const calendarRef = getPractitionerSyncedCalendarDocRef(
|
|
@@ -9919,9 +10027,9 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
9919
10027
|
(0, import_firestore35.where)("eventTime.start", "<=", import_firestore34.Timestamp.fromDate(endDate))
|
|
9920
10028
|
);
|
|
9921
10029
|
const eventsSnapshot = await (0, import_firestore35.getDocs)(q);
|
|
9922
|
-
const events = eventsSnapshot.docs.map((
|
|
9923
|
-
id:
|
|
9924
|
-
...
|
|
10030
|
+
const events = eventsSnapshot.docs.map((doc30) => ({
|
|
10031
|
+
id: doc30.id,
|
|
10032
|
+
...doc30.data()
|
|
9925
10033
|
}));
|
|
9926
10034
|
const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
|
|
9927
10035
|
doctorId
|
|
@@ -10188,7 +10296,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
10188
10296
|
* @throws Error if validation fails
|
|
10189
10297
|
*/
|
|
10190
10298
|
async validateAppointmentParams(params) {
|
|
10191
|
-
await
|
|
10299
|
+
await createAppointmentSchema2.parseAsync(params);
|
|
10192
10300
|
}
|
|
10193
10301
|
/**
|
|
10194
10302
|
* Validates if the event time falls within clinic working hours
|
|
@@ -10470,7 +10578,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
10470
10578
|
* @param params - Update parameters to validate
|
|
10471
10579
|
*/
|
|
10472
10580
|
async validateUpdatePermissions(params) {
|
|
10473
|
-
await
|
|
10581
|
+
await updateAppointmentSchema2.parseAsync(params);
|
|
10474
10582
|
}
|
|
10475
10583
|
/**
|
|
10476
10584
|
* Gets clinic working hours for a specific date
|
|
@@ -10553,7 +10661,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
10553
10661
|
])
|
|
10554
10662
|
);
|
|
10555
10663
|
const querySnapshot = await (0, import_firestore35.getDocs)(q);
|
|
10556
|
-
return querySnapshot.docs.map((
|
|
10664
|
+
return querySnapshot.docs.map((doc30) => doc30.data());
|
|
10557
10665
|
}
|
|
10558
10666
|
/**
|
|
10559
10667
|
* Calculates available time slots based on working hours, schedule and existing appointments
|
|
@@ -10684,7 +10792,7 @@ var import_firestore36 = require("firebase/firestore");
|
|
|
10684
10792
|
var REVIEWS_COLLECTION = "reviews";
|
|
10685
10793
|
|
|
10686
10794
|
// src/services/reviews/reviews.service.ts
|
|
10687
|
-
var
|
|
10795
|
+
var import_zod22 = require("zod");
|
|
10688
10796
|
var ReviewService = class extends BaseService {
|
|
10689
10797
|
constructor(db, auth, app) {
|
|
10690
10798
|
super(db, auth, app);
|
|
@@ -10790,7 +10898,7 @@ var ReviewService = class extends BaseService {
|
|
|
10790
10898
|
await Promise.all(updatePromises);
|
|
10791
10899
|
return review;
|
|
10792
10900
|
} catch (error) {
|
|
10793
|
-
if (error instanceof
|
|
10901
|
+
if (error instanceof import_zod22.z.ZodError) {
|
|
10794
10902
|
throw new Error(`Invalid review data: ${error.message}`);
|
|
10795
10903
|
}
|
|
10796
10904
|
throw error;
|
|
@@ -10820,7 +10928,7 @@ var ReviewService = class extends BaseService {
|
|
|
10820
10928
|
(0, import_firestore36.where)("patientId", "==", patientId)
|
|
10821
10929
|
);
|
|
10822
10930
|
const snapshot = await (0, import_firestore36.getDocs)(q);
|
|
10823
|
-
return snapshot.docs.map((
|
|
10931
|
+
return snapshot.docs.map((doc30) => doc30.data());
|
|
10824
10932
|
}
|
|
10825
10933
|
/**
|
|
10826
10934
|
* Gets all reviews for a specific clinic
|
|
@@ -10833,7 +10941,7 @@ var ReviewService = class extends BaseService {
|
|
|
10833
10941
|
(0, import_firestore36.where)("clinicReview.clinicId", "==", clinicId)
|
|
10834
10942
|
);
|
|
10835
10943
|
const snapshot = await (0, import_firestore36.getDocs)(q);
|
|
10836
|
-
return snapshot.docs.map((
|
|
10944
|
+
return snapshot.docs.map((doc30) => doc30.data());
|
|
10837
10945
|
}
|
|
10838
10946
|
/**
|
|
10839
10947
|
* Gets all reviews for a specific practitioner
|
|
@@ -10846,7 +10954,7 @@ var ReviewService = class extends BaseService {
|
|
|
10846
10954
|
(0, import_firestore36.where)("practitionerReview.practitionerId", "==", practitionerId)
|
|
10847
10955
|
);
|
|
10848
10956
|
const snapshot = await (0, import_firestore36.getDocs)(q);
|
|
10849
|
-
return snapshot.docs.map((
|
|
10957
|
+
return snapshot.docs.map((doc30) => doc30.data());
|
|
10850
10958
|
}
|
|
10851
10959
|
/**
|
|
10852
10960
|
* Gets all reviews for a specific procedure
|
|
@@ -10859,7 +10967,7 @@ var ReviewService = class extends BaseService {
|
|
|
10859
10967
|
(0, import_firestore36.where)("procedureReview.procedureId", "==", procedureId)
|
|
10860
10968
|
);
|
|
10861
10969
|
const snapshot = await (0, import_firestore36.getDocs)(q);
|
|
10862
|
-
return snapshot.docs.map((
|
|
10970
|
+
return snapshot.docs.map((doc30) => doc30.data());
|
|
10863
10971
|
}
|
|
10864
10972
|
/**
|
|
10865
10973
|
* Gets all reviews for a specific appointment
|
|
@@ -11286,94 +11394,923 @@ var ReviewService = class extends BaseService {
|
|
|
11286
11394
|
}
|
|
11287
11395
|
};
|
|
11288
11396
|
|
|
11289
|
-
// src/
|
|
11397
|
+
// src/services/appointment/appointment.service.ts
|
|
11398
|
+
var import_firestore38 = require("firebase/firestore");
|
|
11399
|
+
var import_functions = require("firebase/functions");
|
|
11400
|
+
|
|
11401
|
+
// src/services/appointment/utils/appointment.utils.ts
|
|
11290
11402
|
var import_firestore37 = require("firebase/firestore");
|
|
11291
11403
|
|
|
11292
|
-
// src/backoffice/types/
|
|
11293
|
-
var
|
|
11404
|
+
// src/backoffice/types/technology.types.ts
|
|
11405
|
+
var TECHNOLOGIES_COLLECTION = "technologies";
|
|
11294
11406
|
|
|
11295
|
-
// src/
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
|
|
11300
|
-
|
|
11301
|
-
|
|
11302
|
-
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11407
|
+
// src/services/appointment/utils/appointment.utils.ts
|
|
11408
|
+
async function fetchAggregatedInfoUtil(db, clinicId, practitionerId, patientId, procedureId) {
|
|
11409
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
11410
|
+
try {
|
|
11411
|
+
const [clinicDoc, practitionerDoc, patientDoc, procedureDoc] = await Promise.all([
|
|
11412
|
+
(0, import_firestore37.getDoc)((0, import_firestore37.doc)(db, CLINICS_COLLECTION, clinicId)),
|
|
11413
|
+
(0, import_firestore37.getDoc)((0, import_firestore37.doc)(db, PRACTITIONERS_COLLECTION, practitionerId)),
|
|
11414
|
+
(0, import_firestore37.getDoc)((0, import_firestore37.doc)(db, PATIENTS_COLLECTION, patientId)),
|
|
11415
|
+
(0, import_firestore37.getDoc)((0, import_firestore37.doc)(db, PROCEDURES_COLLECTION, procedureId))
|
|
11416
|
+
]);
|
|
11417
|
+
if (!clinicDoc.exists()) {
|
|
11418
|
+
throw new Error(`Clinic with ID ${clinicId} not found`);
|
|
11419
|
+
}
|
|
11420
|
+
if (!practitionerDoc.exists()) {
|
|
11421
|
+
throw new Error(`Practitioner with ID ${practitionerId} not found`);
|
|
11422
|
+
}
|
|
11423
|
+
if (!patientDoc.exists()) {
|
|
11424
|
+
throw new Error(`Patient with ID ${patientId} not found`);
|
|
11425
|
+
}
|
|
11426
|
+
if (!procedureDoc.exists()) {
|
|
11427
|
+
throw new Error(`Procedure with ID ${procedureId} not found`);
|
|
11428
|
+
}
|
|
11429
|
+
const clinicData = clinicDoc.data();
|
|
11430
|
+
const practitionerData = practitionerDoc.data();
|
|
11431
|
+
const patientData = patientDoc.data();
|
|
11432
|
+
const procedureData = procedureDoc.data();
|
|
11433
|
+
const clinicInfo = {
|
|
11434
|
+
id: clinicId,
|
|
11435
|
+
featuredPhoto: ((_a = clinicData.featuredPhotos) == null ? void 0 : _a[0]) || "",
|
|
11436
|
+
name: clinicData.name,
|
|
11437
|
+
description: clinicData.description || null,
|
|
11438
|
+
location: clinicData.location,
|
|
11439
|
+
contactInfo: clinicData.contactInfo
|
|
11313
11440
|
};
|
|
11314
|
-
const
|
|
11315
|
-
|
|
11316
|
-
|
|
11317
|
-
|
|
11318
|
-
|
|
11319
|
-
|
|
11320
|
-
|
|
11321
|
-
const q = (0, import_firestore37.query)(this.getBrandsRef(), (0, import_firestore37.where)("isActive", "==", true));
|
|
11322
|
-
const snapshot = await (0, import_firestore37.getDocs)(q);
|
|
11323
|
-
return snapshot.docs.map(
|
|
11324
|
-
(doc29) => ({
|
|
11325
|
-
id: doc29.id,
|
|
11326
|
-
...doc29.data()
|
|
11327
|
-
})
|
|
11328
|
-
);
|
|
11329
|
-
}
|
|
11330
|
-
/**
|
|
11331
|
-
* Updates a brand
|
|
11332
|
-
*/
|
|
11333
|
-
async update(brandId, brand) {
|
|
11334
|
-
const updateData = {
|
|
11335
|
-
...brand,
|
|
11336
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
11441
|
+
const practitionerInfo = {
|
|
11442
|
+
id: practitionerId,
|
|
11443
|
+
practitionerPhoto: ((_b = practitionerData.basicInfo) == null ? void 0 : _b.profileImageUrl) || null,
|
|
11444
|
+
name: `${((_c = practitionerData.basicInfo) == null ? void 0 : _c.firstName) || ""} ${((_d = practitionerData.basicInfo) == null ? void 0 : _d.lastName) || ""}`.trim(),
|
|
11445
|
+
email: ((_e = practitionerData.basicInfo) == null ? void 0 : _e.email) || "",
|
|
11446
|
+
phone: ((_f = practitionerData.basicInfo) == null ? void 0 : _f.phoneNumber) || null,
|
|
11447
|
+
certification: practitionerData.certification
|
|
11337
11448
|
};
|
|
11338
|
-
const
|
|
11339
|
-
|
|
11340
|
-
|
|
11449
|
+
const patientInfo = {
|
|
11450
|
+
id: patientId,
|
|
11451
|
+
fullName: patientData.displayName || "",
|
|
11452
|
+
email: patientData.email || "",
|
|
11453
|
+
phone: patientData.phoneNumber || null,
|
|
11454
|
+
dateOfBirth: patientData.dateOfBirth || import_firestore37.Timestamp.now(),
|
|
11455
|
+
gender: patientData.gender || "other"
|
|
11456
|
+
};
|
|
11457
|
+
const procedureInfo = {
|
|
11458
|
+
id: procedureId,
|
|
11459
|
+
name: procedureData.name,
|
|
11460
|
+
description: procedureData.description,
|
|
11461
|
+
photo: procedureData.photo || "",
|
|
11462
|
+
family: procedureData.family,
|
|
11463
|
+
categoryName: ((_g = procedureData.category) == null ? void 0 : _g.name) || "",
|
|
11464
|
+
subcategoryName: ((_h = procedureData.subcategory) == null ? void 0 : _h.name) || "",
|
|
11465
|
+
technologyName: ((_i = procedureData.technology) == null ? void 0 : _i.name) || "",
|
|
11466
|
+
brandName: ((_j = procedureData.product) == null ? void 0 : _j.brand) || "",
|
|
11467
|
+
productName: ((_k = procedureData.product) == null ? void 0 : _k.name) || "",
|
|
11468
|
+
price: procedureData.price || 0,
|
|
11469
|
+
pricingMeasure: procedureData.pricingMeasure,
|
|
11470
|
+
currency: procedureData.currency,
|
|
11471
|
+
duration: procedureData.duration || 0,
|
|
11472
|
+
clinicId,
|
|
11473
|
+
clinicName: clinicInfo.name,
|
|
11474
|
+
practitionerId,
|
|
11475
|
+
practitionerName: practitionerInfo.name
|
|
11476
|
+
};
|
|
11477
|
+
let technologyId = "";
|
|
11478
|
+
if ((_l = procedureData.technology) == null ? void 0 : _l.id) {
|
|
11479
|
+
technologyId = procedureData.technology.id;
|
|
11480
|
+
}
|
|
11481
|
+
let blockingConditions = [];
|
|
11482
|
+
let contraindications = [];
|
|
11483
|
+
let preProcedureRequirements = [];
|
|
11484
|
+
let postProcedureRequirements = [];
|
|
11485
|
+
if (technologyId) {
|
|
11486
|
+
const technologyDoc = await (0, import_firestore37.getDoc)(
|
|
11487
|
+
(0, import_firestore37.doc)(db, TECHNOLOGIES_COLLECTION, technologyId)
|
|
11488
|
+
);
|
|
11489
|
+
if (technologyDoc.exists()) {
|
|
11490
|
+
const technologyData = technologyDoc.data();
|
|
11491
|
+
blockingConditions = technologyData.blockingConditions || [];
|
|
11492
|
+
contraindications = technologyData.contraindications || [];
|
|
11493
|
+
preProcedureRequirements = ((_m = technologyData.requirements) == null ? void 0 : _m.pre) || [];
|
|
11494
|
+
postProcedureRequirements = ((_n = technologyData.requirements) == null ? void 0 : _n.post) || [];
|
|
11495
|
+
}
|
|
11496
|
+
} else {
|
|
11497
|
+
blockingConditions = procedureData.blockingConditions || [];
|
|
11498
|
+
contraindications = procedureData.contraindications || [];
|
|
11499
|
+
preProcedureRequirements = procedureData.preRequirements || [];
|
|
11500
|
+
postProcedureRequirements = procedureData.postRequirements || [];
|
|
11501
|
+
}
|
|
11502
|
+
return {
|
|
11503
|
+
clinicInfo,
|
|
11504
|
+
practitionerInfo,
|
|
11505
|
+
patientInfo,
|
|
11506
|
+
procedureInfo,
|
|
11507
|
+
blockingConditions,
|
|
11508
|
+
contraindications,
|
|
11509
|
+
preProcedureRequirements,
|
|
11510
|
+
postProcedureRequirements
|
|
11511
|
+
};
|
|
11512
|
+
} catch (error) {
|
|
11513
|
+
console.error("Error fetching aggregated info:", error);
|
|
11514
|
+
throw error;
|
|
11341
11515
|
}
|
|
11342
|
-
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
|
|
11346
|
-
|
|
11347
|
-
|
|
11516
|
+
}
|
|
11517
|
+
async function createAppointmentUtil2(db, data, aggregatedInfo, generateId2) {
|
|
11518
|
+
try {
|
|
11519
|
+
const appointmentId = generateId2();
|
|
11520
|
+
const appointment = {
|
|
11521
|
+
id: appointmentId,
|
|
11522
|
+
calendarEventId: data.calendarEventId,
|
|
11523
|
+
clinicBranchId: data.clinicBranchId,
|
|
11524
|
+
clinicInfo: aggregatedInfo.clinicInfo,
|
|
11525
|
+
practitionerId: data.practitionerId,
|
|
11526
|
+
practitionerInfo: aggregatedInfo.practitionerInfo,
|
|
11527
|
+
patientId: data.patientId,
|
|
11528
|
+
patientInfo: aggregatedInfo.patientInfo,
|
|
11529
|
+
procedureId: data.procedureId,
|
|
11530
|
+
procedureInfo: aggregatedInfo.procedureInfo,
|
|
11531
|
+
status: data.initialStatus,
|
|
11532
|
+
bookingTime: import_firestore37.Timestamp.now(),
|
|
11533
|
+
appointmentStartTime: data.appointmentStartTime,
|
|
11534
|
+
appointmentEndTime: data.appointmentEndTime,
|
|
11535
|
+
patientNotes: data.patientNotes || null,
|
|
11536
|
+
cost: data.cost,
|
|
11537
|
+
currency: data.currency,
|
|
11538
|
+
paymentStatus: data.initialPaymentStatus || "unpaid" /* UNPAID */,
|
|
11539
|
+
blockingConditions: aggregatedInfo.blockingConditions,
|
|
11540
|
+
contraindications: aggregatedInfo.contraindications,
|
|
11541
|
+
preProcedureRequirements: aggregatedInfo.preProcedureRequirements,
|
|
11542
|
+
postProcedureRequirements: aggregatedInfo.postProcedureRequirements,
|
|
11543
|
+
completedPreRequirements: [],
|
|
11544
|
+
completedPostRequirements: [],
|
|
11545
|
+
createdAt: (0, import_firestore37.serverTimestamp)(),
|
|
11546
|
+
updatedAt: (0, import_firestore37.serverTimestamp)()
|
|
11547
|
+
};
|
|
11548
|
+
if (data.initialStatus === "confirmed" /* CONFIRMED */) {
|
|
11549
|
+
appointment.confirmationTime = import_firestore37.Timestamp.now();
|
|
11550
|
+
}
|
|
11551
|
+
await (0, import_firestore37.setDoc)((0, import_firestore37.doc)(db, APPOINTMENTS_COLLECTION, appointmentId), appointment);
|
|
11552
|
+
const calendarEventRef = (0, import_firestore37.doc)(db, CALENDAR_COLLECTION, data.calendarEventId);
|
|
11553
|
+
await (0, import_firestore37.updateDoc)(calendarEventRef, {
|
|
11554
|
+
appointmentId,
|
|
11555
|
+
updatedAt: (0, import_firestore37.serverTimestamp)()
|
|
11348
11556
|
});
|
|
11349
|
-
|
|
11350
|
-
/**
|
|
11351
|
-
* Gets a brand by ID
|
|
11352
|
-
*/
|
|
11353
|
-
async getById(brandId) {
|
|
11354
|
-
const docRef = (0, import_firestore37.doc)(this.getBrandsRef(), brandId);
|
|
11355
|
-
const docSnap = await (0, import_firestore37.getDoc)(docRef);
|
|
11356
|
-
if (!docSnap.exists()) return null;
|
|
11557
|
+
const now = import_firestore37.Timestamp.now();
|
|
11357
11558
|
return {
|
|
11358
|
-
|
|
11359
|
-
|
|
11559
|
+
...appointment,
|
|
11560
|
+
createdAt: now,
|
|
11561
|
+
updatedAt: now
|
|
11360
11562
|
};
|
|
11563
|
+
} catch (error) {
|
|
11564
|
+
console.error("Error creating appointment:", error);
|
|
11565
|
+
throw error;
|
|
11566
|
+
}
|
|
11567
|
+
}
|
|
11568
|
+
async function updateAppointmentUtil2(db, appointmentId, data) {
|
|
11569
|
+
try {
|
|
11570
|
+
const appointmentRef = (0, import_firestore37.doc)(db, APPOINTMENTS_COLLECTION, appointmentId);
|
|
11571
|
+
const appointmentDoc = await (0, import_firestore37.getDoc)(appointmentRef);
|
|
11572
|
+
if (!appointmentDoc.exists()) {
|
|
11573
|
+
throw new Error(`Appointment with ID ${appointmentId} not found`);
|
|
11574
|
+
}
|
|
11575
|
+
const currentAppointment = appointmentDoc.data();
|
|
11576
|
+
let completedPreRequirements = currentAppointment.completedPreRequirements || [];
|
|
11577
|
+
let completedPostRequirements = currentAppointment.completedPostRequirements || [];
|
|
11578
|
+
if (data.completedPreRequirements) {
|
|
11579
|
+
const validPreReqIds = currentAppointment.preProcedureRequirements.map(
|
|
11580
|
+
(req) => req.id
|
|
11581
|
+
);
|
|
11582
|
+
const invalidPreReqIds = data.completedPreRequirements.filter(
|
|
11583
|
+
(id) => !validPreReqIds.includes(id)
|
|
11584
|
+
);
|
|
11585
|
+
if (invalidPreReqIds.length > 0) {
|
|
11586
|
+
throw new Error(
|
|
11587
|
+
`Invalid pre-requirement IDs: ${invalidPreReqIds.join(", ")}`
|
|
11588
|
+
);
|
|
11589
|
+
}
|
|
11590
|
+
completedPreRequirements = [
|
|
11591
|
+
.../* @__PURE__ */ new Set([
|
|
11592
|
+
...completedPreRequirements,
|
|
11593
|
+
...data.completedPreRequirements
|
|
11594
|
+
])
|
|
11595
|
+
];
|
|
11596
|
+
}
|
|
11597
|
+
if (data.completedPostRequirements) {
|
|
11598
|
+
const validPostReqIds = currentAppointment.postProcedureRequirements.map(
|
|
11599
|
+
(req) => req.id
|
|
11600
|
+
);
|
|
11601
|
+
const invalidPostReqIds = data.completedPostRequirements.filter(
|
|
11602
|
+
(id) => !validPostReqIds.includes(id)
|
|
11603
|
+
);
|
|
11604
|
+
if (invalidPostReqIds.length > 0) {
|
|
11605
|
+
throw new Error(
|
|
11606
|
+
`Invalid post-requirement IDs: ${invalidPostReqIds.join(", ")}`
|
|
11607
|
+
);
|
|
11608
|
+
}
|
|
11609
|
+
completedPostRequirements = [
|
|
11610
|
+
.../* @__PURE__ */ new Set([
|
|
11611
|
+
...completedPostRequirements,
|
|
11612
|
+
...data.completedPostRequirements
|
|
11613
|
+
])
|
|
11614
|
+
];
|
|
11615
|
+
}
|
|
11616
|
+
const updateData = {
|
|
11617
|
+
...data,
|
|
11618
|
+
completedPreRequirements,
|
|
11619
|
+
completedPostRequirements,
|
|
11620
|
+
updatedAt: (0, import_firestore37.serverTimestamp)()
|
|
11621
|
+
};
|
|
11622
|
+
Object.keys(updateData).forEach((key) => {
|
|
11623
|
+
if (updateData[key] === void 0) {
|
|
11624
|
+
delete updateData[key];
|
|
11625
|
+
}
|
|
11626
|
+
});
|
|
11627
|
+
if (data.status && data.status !== currentAppointment.status) {
|
|
11628
|
+
if (data.status === "confirmed" /* CONFIRMED */ && !updateData.confirmationTime) {
|
|
11629
|
+
updateData.confirmationTime = import_firestore37.Timestamp.now();
|
|
11630
|
+
}
|
|
11631
|
+
if (currentAppointment.calendarEventId) {
|
|
11632
|
+
await updateCalendarEventStatus(
|
|
11633
|
+
db,
|
|
11634
|
+
currentAppointment.calendarEventId,
|
|
11635
|
+
data.status
|
|
11636
|
+
);
|
|
11637
|
+
}
|
|
11638
|
+
}
|
|
11639
|
+
await (0, import_firestore37.updateDoc)(appointmentRef, updateData);
|
|
11640
|
+
const updatedAppointmentDoc = await (0, import_firestore37.getDoc)(appointmentRef);
|
|
11641
|
+
if (!updatedAppointmentDoc.exists()) {
|
|
11642
|
+
throw new Error(
|
|
11643
|
+
`Failed to retrieve updated appointment ${appointmentId}`
|
|
11644
|
+
);
|
|
11645
|
+
}
|
|
11646
|
+
return updatedAppointmentDoc.data();
|
|
11647
|
+
} catch (error) {
|
|
11648
|
+
console.error(`Error updating appointment ${appointmentId}:`, error);
|
|
11649
|
+
throw error;
|
|
11650
|
+
}
|
|
11651
|
+
}
|
|
11652
|
+
async function updateCalendarEventStatus(db, calendarEventId, appointmentStatus) {
|
|
11653
|
+
try {
|
|
11654
|
+
const calendarEventRef = (0, import_firestore37.doc)(db, CALENDAR_COLLECTION, calendarEventId);
|
|
11655
|
+
const calendarEventDoc = await (0, import_firestore37.getDoc)(calendarEventRef);
|
|
11656
|
+
if (!calendarEventDoc.exists()) {
|
|
11657
|
+
console.warn(`Calendar event with ID ${calendarEventId} not found`);
|
|
11658
|
+
return;
|
|
11659
|
+
}
|
|
11660
|
+
let calendarStatus;
|
|
11661
|
+
switch (appointmentStatus) {
|
|
11662
|
+
case "confirmed" /* CONFIRMED */:
|
|
11663
|
+
calendarStatus = "confirmed";
|
|
11664
|
+
break;
|
|
11665
|
+
case "canceled_patient" /* CANCELED_PATIENT */:
|
|
11666
|
+
case "canceled_clinic" /* CANCELED_CLINIC */:
|
|
11667
|
+
calendarStatus = "canceled";
|
|
11668
|
+
break;
|
|
11669
|
+
case "rescheduled" /* RESCHEDULED */:
|
|
11670
|
+
calendarStatus = "rescheduled";
|
|
11671
|
+
break;
|
|
11672
|
+
case "completed" /* COMPLETED */:
|
|
11673
|
+
calendarStatus = "completed";
|
|
11674
|
+
break;
|
|
11675
|
+
default:
|
|
11676
|
+
return;
|
|
11677
|
+
}
|
|
11678
|
+
await (0, import_firestore37.updateDoc)(calendarEventRef, {
|
|
11679
|
+
status: calendarStatus,
|
|
11680
|
+
updatedAt: (0, import_firestore37.serverTimestamp)()
|
|
11681
|
+
});
|
|
11682
|
+
} catch (error) {
|
|
11683
|
+
console.error(`Error updating calendar event ${calendarEventId}:`, error);
|
|
11684
|
+
}
|
|
11685
|
+
}
|
|
11686
|
+
async function getAppointmentByIdUtil(db, appointmentId) {
|
|
11687
|
+
try {
|
|
11688
|
+
const appointmentDoc = await (0, import_firestore37.getDoc)(
|
|
11689
|
+
(0, import_firestore37.doc)(db, APPOINTMENTS_COLLECTION, appointmentId)
|
|
11690
|
+
);
|
|
11691
|
+
if (!appointmentDoc.exists()) {
|
|
11692
|
+
return null;
|
|
11693
|
+
}
|
|
11694
|
+
return appointmentDoc.data();
|
|
11695
|
+
} catch (error) {
|
|
11696
|
+
console.error(`Error getting appointment ${appointmentId}:`, error);
|
|
11697
|
+
throw error;
|
|
11698
|
+
}
|
|
11699
|
+
}
|
|
11700
|
+
async function searchAppointmentsUtil(db, params) {
|
|
11701
|
+
try {
|
|
11702
|
+
const constraints = [];
|
|
11703
|
+
if (params.patientId) {
|
|
11704
|
+
constraints.push((0, import_firestore37.where)("patientId", "==", params.patientId));
|
|
11705
|
+
}
|
|
11706
|
+
if (params.practitionerId) {
|
|
11707
|
+
constraints.push((0, import_firestore37.where)("practitionerId", "==", params.practitionerId));
|
|
11708
|
+
}
|
|
11709
|
+
if (params.clinicBranchId) {
|
|
11710
|
+
constraints.push((0, import_firestore37.where)("clinicBranchId", "==", params.clinicBranchId));
|
|
11711
|
+
}
|
|
11712
|
+
if (params.startDate) {
|
|
11713
|
+
constraints.push(
|
|
11714
|
+
(0, import_firestore37.where)(
|
|
11715
|
+
"appointmentStartTime",
|
|
11716
|
+
">=",
|
|
11717
|
+
import_firestore37.Timestamp.fromDate(params.startDate)
|
|
11718
|
+
)
|
|
11719
|
+
);
|
|
11720
|
+
}
|
|
11721
|
+
if (params.endDate) {
|
|
11722
|
+
constraints.push(
|
|
11723
|
+
(0, import_firestore37.where)("appointmentStartTime", "<=", import_firestore37.Timestamp.fromDate(params.endDate))
|
|
11724
|
+
);
|
|
11725
|
+
}
|
|
11726
|
+
if (params.status) {
|
|
11727
|
+
if (Array.isArray(params.status)) {
|
|
11728
|
+
constraints.push((0, import_firestore37.where)("status", "in", params.status));
|
|
11729
|
+
} else {
|
|
11730
|
+
constraints.push((0, import_firestore37.where)("status", "==", params.status));
|
|
11731
|
+
}
|
|
11732
|
+
}
|
|
11733
|
+
constraints.push((0, import_firestore37.orderBy)("appointmentStartTime", "asc"));
|
|
11734
|
+
if (params.limit) {
|
|
11735
|
+
constraints.push((0, import_firestore37.limit)(params.limit));
|
|
11736
|
+
}
|
|
11737
|
+
if (params.startAfter) {
|
|
11738
|
+
constraints.push((0, import_firestore37.startAfter)(params.startAfter));
|
|
11739
|
+
}
|
|
11740
|
+
const q = (0, import_firestore37.query)((0, import_firestore37.collection)(db, APPOINTMENTS_COLLECTION), ...constraints);
|
|
11741
|
+
const querySnapshot = await (0, import_firestore37.getDocs)(q);
|
|
11742
|
+
const appointments = querySnapshot.docs.map(
|
|
11743
|
+
(doc30) => doc30.data()
|
|
11744
|
+
);
|
|
11745
|
+
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
11746
|
+
return { appointments, lastDoc };
|
|
11747
|
+
} catch (error) {
|
|
11748
|
+
console.error("Error searching appointments:", error);
|
|
11749
|
+
throw error;
|
|
11750
|
+
}
|
|
11751
|
+
}
|
|
11752
|
+
|
|
11753
|
+
// src/services/appointment/appointment.service.ts
|
|
11754
|
+
var AppointmentService = class extends BaseService {
|
|
11755
|
+
/**
|
|
11756
|
+
* Creates a new AppointmentService instance.
|
|
11757
|
+
*
|
|
11758
|
+
* @param db Firestore instance
|
|
11759
|
+
* @param auth Firebase Auth instance
|
|
11760
|
+
* @param app Firebase App instance
|
|
11761
|
+
* @param calendarService Calendar service instance
|
|
11762
|
+
* @param patientService Patient service instance
|
|
11763
|
+
* @param practitionerService Practitioner service instance
|
|
11764
|
+
* @param clinicService Clinic service instance
|
|
11765
|
+
*/
|
|
11766
|
+
constructor(db, auth, app, calendarService, patientService, practitionerService, clinicService) {
|
|
11767
|
+
super(db, auth, app);
|
|
11768
|
+
this.calendarService = calendarService;
|
|
11769
|
+
this.patientService = patientService;
|
|
11770
|
+
this.practitionerService = practitionerService;
|
|
11771
|
+
this.clinicService = clinicService;
|
|
11772
|
+
this.functions = (0, import_functions.getFunctions)(app, "europe-west6");
|
|
11773
|
+
}
|
|
11774
|
+
/**
|
|
11775
|
+
* Gets available booking slots for a specific clinic, practitioner, and procedure.
|
|
11776
|
+
*
|
|
11777
|
+
* @param clinicId ID of the clinic
|
|
11778
|
+
* @param practitionerId ID of the practitioner
|
|
11779
|
+
* @param procedureId ID of the procedure
|
|
11780
|
+
* @param startDate Start date of the time range to check
|
|
11781
|
+
* @param endDate End date of the time range to check
|
|
11782
|
+
* @returns Array of available booking slots
|
|
11783
|
+
*/
|
|
11784
|
+
async getAvailableBookingSlots(clinicId, practitionerId, procedureId, startDate, endDate) {
|
|
11785
|
+
try {
|
|
11786
|
+
console.log(
|
|
11787
|
+
`[APPOINTMENT_SERVICE] Getting available booking slots for clinic: ${clinicId}, practitioner: ${practitionerId}, procedure: ${procedureId}`
|
|
11788
|
+
);
|
|
11789
|
+
if (!clinicId || !practitionerId || !procedureId || !startDate || !endDate) {
|
|
11790
|
+
throw new Error(
|
|
11791
|
+
"Missing required parameters for booking slots calculation"
|
|
11792
|
+
);
|
|
11793
|
+
}
|
|
11794
|
+
if (endDate <= startDate) {
|
|
11795
|
+
throw new Error("End date must be after start date");
|
|
11796
|
+
}
|
|
11797
|
+
const currentUser = this.auth.currentUser;
|
|
11798
|
+
if (!currentUser) {
|
|
11799
|
+
throw new Error(
|
|
11800
|
+
"User must be authenticated to get available booking slots"
|
|
11801
|
+
);
|
|
11802
|
+
}
|
|
11803
|
+
const getAvailableBookingSlotsFunction = (0, import_functions.httpsCallable)(
|
|
11804
|
+
this.functions,
|
|
11805
|
+
"getAvailableBookingSlots"
|
|
11806
|
+
);
|
|
11807
|
+
const result = await getAvailableBookingSlotsFunction({
|
|
11808
|
+
clinicId,
|
|
11809
|
+
practitionerId,
|
|
11810
|
+
procedureId,
|
|
11811
|
+
timeframe: {
|
|
11812
|
+
start: startDate.getTime(),
|
|
11813
|
+
// Convert to timestamp
|
|
11814
|
+
end: endDate.getTime()
|
|
11815
|
+
}
|
|
11816
|
+
});
|
|
11817
|
+
const response = result.data;
|
|
11818
|
+
if (!response.success) {
|
|
11819
|
+
throw new Error(
|
|
11820
|
+
response.error || "Failed to get available booking slots"
|
|
11821
|
+
);
|
|
11822
|
+
}
|
|
11823
|
+
const slots = response.availableSlots.map((slot) => ({
|
|
11824
|
+
start: new Date(slot.start)
|
|
11825
|
+
}));
|
|
11826
|
+
console.log(
|
|
11827
|
+
`[APPOINTMENT_SERVICE] Found ${slots.length} available booking slots`
|
|
11828
|
+
);
|
|
11829
|
+
return slots;
|
|
11830
|
+
} catch (error) {
|
|
11831
|
+
console.error(
|
|
11832
|
+
"[APPOINTMENT_SERVICE] Error getting available booking slots:",
|
|
11833
|
+
error
|
|
11834
|
+
);
|
|
11835
|
+
throw error;
|
|
11836
|
+
}
|
|
11837
|
+
}
|
|
11838
|
+
/**
|
|
11839
|
+
* Creates a new appointment.
|
|
11840
|
+
*
|
|
11841
|
+
* @param data Data needed to create the appointment
|
|
11842
|
+
* @returns The created appointment
|
|
11843
|
+
*/
|
|
11844
|
+
async createAppointment(data) {
|
|
11845
|
+
try {
|
|
11846
|
+
console.log("[APPOINTMENT_SERVICE] Creating appointment");
|
|
11847
|
+
const validatedData = await createAppointmentSchema.parseAsync(data);
|
|
11848
|
+
const aggregatedInfo = await fetchAggregatedInfoUtil(
|
|
11849
|
+
this.db,
|
|
11850
|
+
validatedData.clinicBranchId,
|
|
11851
|
+
validatedData.practitionerId,
|
|
11852
|
+
validatedData.patientId,
|
|
11853
|
+
validatedData.procedureId
|
|
11854
|
+
);
|
|
11855
|
+
const appointment = await createAppointmentUtil2(
|
|
11856
|
+
this.db,
|
|
11857
|
+
validatedData,
|
|
11858
|
+
aggregatedInfo,
|
|
11859
|
+
this.generateId.bind(this)
|
|
11860
|
+
);
|
|
11861
|
+
console.log(
|
|
11862
|
+
`[APPOINTMENT_SERVICE] Appointment created with ID: ${appointment.id}`
|
|
11863
|
+
);
|
|
11864
|
+
return appointment;
|
|
11865
|
+
} catch (error) {
|
|
11866
|
+
console.error("[APPOINTMENT_SERVICE] Error creating appointment:", error);
|
|
11867
|
+
throw error;
|
|
11868
|
+
}
|
|
11869
|
+
}
|
|
11870
|
+
/**
|
|
11871
|
+
* Gets an appointment by ID.
|
|
11872
|
+
*
|
|
11873
|
+
* @param appointmentId ID of the appointment to retrieve
|
|
11874
|
+
* @returns The appointment or null if not found
|
|
11875
|
+
*/
|
|
11876
|
+
async getAppointmentById(appointmentId) {
|
|
11877
|
+
try {
|
|
11878
|
+
console.log(
|
|
11879
|
+
`[APPOINTMENT_SERVICE] Getting appointment with ID: ${appointmentId}`
|
|
11880
|
+
);
|
|
11881
|
+
const appointment = await getAppointmentByIdUtil(this.db, appointmentId);
|
|
11882
|
+
console.log(
|
|
11883
|
+
`[APPOINTMENT_SERVICE] Appointment ${appointmentId} ${appointment ? "found" : "not found"}`
|
|
11884
|
+
);
|
|
11885
|
+
return appointment;
|
|
11886
|
+
} catch (error) {
|
|
11887
|
+
console.error(
|
|
11888
|
+
`[APPOINTMENT_SERVICE] Error getting appointment ${appointmentId}:`,
|
|
11889
|
+
error
|
|
11890
|
+
);
|
|
11891
|
+
throw error;
|
|
11892
|
+
}
|
|
11893
|
+
}
|
|
11894
|
+
/**
|
|
11895
|
+
* Updates an existing appointment.
|
|
11896
|
+
*
|
|
11897
|
+
* @param appointmentId ID of the appointment to update
|
|
11898
|
+
* @param data Update data for the appointment
|
|
11899
|
+
* @returns The updated appointment
|
|
11900
|
+
*/
|
|
11901
|
+
async updateAppointment(appointmentId, data) {
|
|
11902
|
+
try {
|
|
11903
|
+
console.log(
|
|
11904
|
+
`[APPOINTMENT_SERVICE] Updating appointment with ID: ${appointmentId}`
|
|
11905
|
+
);
|
|
11906
|
+
const validatedData = await updateAppointmentSchema.parseAsync(data);
|
|
11907
|
+
const updatedAppointment = await updateAppointmentUtil2(
|
|
11908
|
+
this.db,
|
|
11909
|
+
appointmentId,
|
|
11910
|
+
validatedData
|
|
11911
|
+
);
|
|
11912
|
+
console.log(
|
|
11913
|
+
`[APPOINTMENT_SERVICE] Appointment ${appointmentId} updated successfully`
|
|
11914
|
+
);
|
|
11915
|
+
return updatedAppointment;
|
|
11916
|
+
} catch (error) {
|
|
11917
|
+
console.error(
|
|
11918
|
+
`[APPOINTMENT_SERVICE] Error updating appointment ${appointmentId}:`,
|
|
11919
|
+
error
|
|
11920
|
+
);
|
|
11921
|
+
throw error;
|
|
11922
|
+
}
|
|
11923
|
+
}
|
|
11924
|
+
/**
|
|
11925
|
+
* Searches for appointments based on various criteria.
|
|
11926
|
+
*
|
|
11927
|
+
* @param params Search parameters
|
|
11928
|
+
* @returns Found appointments and the last document for pagination
|
|
11929
|
+
*/
|
|
11930
|
+
async searchAppointments(params) {
|
|
11931
|
+
try {
|
|
11932
|
+
console.log(
|
|
11933
|
+
"[APPOINTMENT_SERVICE] Searching appointments with params:",
|
|
11934
|
+
params
|
|
11935
|
+
);
|
|
11936
|
+
await searchAppointmentsSchema.parseAsync(params);
|
|
11937
|
+
const result = await searchAppointmentsUtil(this.db, params);
|
|
11938
|
+
console.log(
|
|
11939
|
+
`[APPOINTMENT_SERVICE] Found ${result.appointments.length} appointments`
|
|
11940
|
+
);
|
|
11941
|
+
return result;
|
|
11942
|
+
} catch (error) {
|
|
11943
|
+
console.error(
|
|
11944
|
+
"[APPOINTMENT_SERVICE] Error searching appointments:",
|
|
11945
|
+
error
|
|
11946
|
+
);
|
|
11947
|
+
throw error;
|
|
11948
|
+
}
|
|
11949
|
+
}
|
|
11950
|
+
/**
|
|
11951
|
+
* Gets appointments for a specific patient.
|
|
11952
|
+
*
|
|
11953
|
+
* @param patientId ID of the patient
|
|
11954
|
+
* @param options Optional parameters for filtering and pagination
|
|
11955
|
+
* @returns Found appointments and the last document for pagination
|
|
11956
|
+
*/
|
|
11957
|
+
async getPatientAppointments(patientId, options) {
|
|
11958
|
+
console.log(
|
|
11959
|
+
`[APPOINTMENT_SERVICE] Getting appointments for patient: ${patientId}`
|
|
11960
|
+
);
|
|
11961
|
+
const searchParams = {
|
|
11962
|
+
patientId,
|
|
11963
|
+
startDate: options == null ? void 0 : options.startDate,
|
|
11964
|
+
endDate: options == null ? void 0 : options.endDate,
|
|
11965
|
+
status: options == null ? void 0 : options.status,
|
|
11966
|
+
limit: options == null ? void 0 : options.limit,
|
|
11967
|
+
startAfter: options == null ? void 0 : options.startAfter
|
|
11968
|
+
};
|
|
11969
|
+
return this.searchAppointments(searchParams);
|
|
11970
|
+
}
|
|
11971
|
+
/**
|
|
11972
|
+
* Gets appointments for a specific practitioner.
|
|
11973
|
+
*
|
|
11974
|
+
* @param practitionerId ID of the practitioner
|
|
11975
|
+
* @param options Optional parameters for filtering and pagination
|
|
11976
|
+
* @returns Found appointments and the last document for pagination
|
|
11977
|
+
*/
|
|
11978
|
+
async getPractitionerAppointments(practitionerId, options) {
|
|
11979
|
+
console.log(
|
|
11980
|
+
`[APPOINTMENT_SERVICE] Getting appointments for practitioner: ${practitionerId}`
|
|
11981
|
+
);
|
|
11982
|
+
const searchParams = {
|
|
11983
|
+
practitionerId,
|
|
11984
|
+
startDate: options == null ? void 0 : options.startDate,
|
|
11985
|
+
endDate: options == null ? void 0 : options.endDate,
|
|
11986
|
+
status: options == null ? void 0 : options.status,
|
|
11987
|
+
limit: options == null ? void 0 : options.limit,
|
|
11988
|
+
startAfter: options == null ? void 0 : options.startAfter
|
|
11989
|
+
};
|
|
11990
|
+
return this.searchAppointments(searchParams);
|
|
11991
|
+
}
|
|
11992
|
+
/**
|
|
11993
|
+
* Gets appointments for a specific clinic.
|
|
11994
|
+
*
|
|
11995
|
+
* @param clinicBranchId ID of the clinic branch
|
|
11996
|
+
* @param options Optional parameters for filtering and pagination
|
|
11997
|
+
* @returns Found appointments and the last document for pagination
|
|
11998
|
+
*/
|
|
11999
|
+
async getClinicAppointments(clinicBranchId, options) {
|
|
12000
|
+
console.log(
|
|
12001
|
+
`[APPOINTMENT_SERVICE] Getting appointments for clinic: ${clinicBranchId}`
|
|
12002
|
+
);
|
|
12003
|
+
const searchParams = {
|
|
12004
|
+
clinicBranchId,
|
|
12005
|
+
practitionerId: options == null ? void 0 : options.practitionerId,
|
|
12006
|
+
startDate: options == null ? void 0 : options.startDate,
|
|
12007
|
+
endDate: options == null ? void 0 : options.endDate,
|
|
12008
|
+
status: options == null ? void 0 : options.status,
|
|
12009
|
+
limit: options == null ? void 0 : options.limit,
|
|
12010
|
+
startAfter: options == null ? void 0 : options.startAfter
|
|
12011
|
+
};
|
|
12012
|
+
return this.searchAppointments(searchParams);
|
|
12013
|
+
}
|
|
12014
|
+
/**
|
|
12015
|
+
* Updates the status of an appointment.
|
|
12016
|
+
*
|
|
12017
|
+
* @param appointmentId ID of the appointment
|
|
12018
|
+
* @param newStatus New status to set
|
|
12019
|
+
* @param cancellationReason Required if canceling the appointment
|
|
12020
|
+
* @param canceledBy Required if canceling the appointment
|
|
12021
|
+
* @returns The updated appointment
|
|
12022
|
+
*/
|
|
12023
|
+
async updateAppointmentStatus(appointmentId, newStatus, cancellationReason, canceledBy) {
|
|
12024
|
+
console.log(
|
|
12025
|
+
`[APPOINTMENT_SERVICE] Updating status of appointment ${appointmentId} to ${newStatus}`
|
|
12026
|
+
);
|
|
12027
|
+
const updateData = { status: newStatus };
|
|
12028
|
+
if (newStatus === "canceled_clinic" /* CANCELED_CLINIC */ || newStatus === "canceled_patient" /* CANCELED_PATIENT */) {
|
|
12029
|
+
if (!cancellationReason) {
|
|
12030
|
+
throw new Error(
|
|
12031
|
+
"Cancellation reason is required when canceling an appointment"
|
|
12032
|
+
);
|
|
12033
|
+
}
|
|
12034
|
+
if (!canceledBy) {
|
|
12035
|
+
throw new Error(
|
|
12036
|
+
"Canceled by is required when canceling an appointment"
|
|
12037
|
+
);
|
|
12038
|
+
}
|
|
12039
|
+
updateData.cancellationReason = cancellationReason;
|
|
12040
|
+
updateData.canceledBy = canceledBy;
|
|
12041
|
+
}
|
|
12042
|
+
if (newStatus === "confirmed" /* CONFIRMED */) {
|
|
12043
|
+
updateData.confirmationTime = import_firestore38.Timestamp.now();
|
|
12044
|
+
}
|
|
12045
|
+
return this.updateAppointment(appointmentId, updateData);
|
|
12046
|
+
}
|
|
12047
|
+
/**
|
|
12048
|
+
* Confirms an appointment.
|
|
12049
|
+
*
|
|
12050
|
+
* @param appointmentId ID of the appointment to confirm
|
|
12051
|
+
* @returns The confirmed appointment
|
|
12052
|
+
*/
|
|
12053
|
+
async confirmAppointment(appointmentId) {
|
|
12054
|
+
console.log(
|
|
12055
|
+
`[APPOINTMENT_SERVICE] Confirming appointment: ${appointmentId}`
|
|
12056
|
+
);
|
|
12057
|
+
return this.updateAppointmentStatus(
|
|
12058
|
+
appointmentId,
|
|
12059
|
+
"confirmed" /* CONFIRMED */
|
|
12060
|
+
);
|
|
12061
|
+
}
|
|
12062
|
+
/**
|
|
12063
|
+
* Cancels an appointment from the clinic side.
|
|
12064
|
+
*
|
|
12065
|
+
* @param appointmentId ID of the appointment to cancel
|
|
12066
|
+
* @param reason Reason for cancellation
|
|
12067
|
+
* @returns The canceled appointment
|
|
12068
|
+
*/
|
|
12069
|
+
async cancelAppointmentByClinic(appointmentId, reason) {
|
|
12070
|
+
console.log(
|
|
12071
|
+
`[APPOINTMENT_SERVICE] Canceling appointment by clinic: ${appointmentId}`
|
|
12072
|
+
);
|
|
12073
|
+
return this.updateAppointmentStatus(
|
|
12074
|
+
appointmentId,
|
|
12075
|
+
"canceled_clinic" /* CANCELED_CLINIC */,
|
|
12076
|
+
reason,
|
|
12077
|
+
"clinic"
|
|
12078
|
+
);
|
|
12079
|
+
}
|
|
12080
|
+
/**
|
|
12081
|
+
* Cancels an appointment from the patient side.
|
|
12082
|
+
*
|
|
12083
|
+
* @param appointmentId ID of the appointment to cancel
|
|
12084
|
+
* @param reason Reason for cancellation
|
|
12085
|
+
* @returns The canceled appointment
|
|
12086
|
+
*/
|
|
12087
|
+
async cancelAppointmentByPatient(appointmentId, reason) {
|
|
12088
|
+
console.log(
|
|
12089
|
+
`[APPOINTMENT_SERVICE] Canceling appointment by patient: ${appointmentId}`
|
|
12090
|
+
);
|
|
12091
|
+
return this.updateAppointmentStatus(
|
|
12092
|
+
appointmentId,
|
|
12093
|
+
"canceled_patient" /* CANCELED_PATIENT */,
|
|
12094
|
+
reason,
|
|
12095
|
+
"patient"
|
|
12096
|
+
);
|
|
12097
|
+
}
|
|
12098
|
+
/**
|
|
12099
|
+
* Marks an appointment as checked in.
|
|
12100
|
+
*
|
|
12101
|
+
* @param appointmentId ID of the appointment
|
|
12102
|
+
* @returns The updated appointment
|
|
12103
|
+
*/
|
|
12104
|
+
async checkInAppointment(appointmentId) {
|
|
12105
|
+
console.log(
|
|
12106
|
+
`[APPOINTMENT_SERVICE] Checking in appointment: ${appointmentId}`
|
|
12107
|
+
);
|
|
12108
|
+
return this.updateAppointmentStatus(
|
|
12109
|
+
appointmentId,
|
|
12110
|
+
"checked_in" /* CHECKED_IN */
|
|
12111
|
+
);
|
|
12112
|
+
}
|
|
12113
|
+
/**
|
|
12114
|
+
* Marks an appointment as in progress.
|
|
12115
|
+
*
|
|
12116
|
+
* @param appointmentId ID of the appointment
|
|
12117
|
+
* @returns The updated appointment
|
|
12118
|
+
*/
|
|
12119
|
+
async startAppointment(appointmentId) {
|
|
12120
|
+
console.log(`[APPOINTMENT_SERVICE] Starting appointment: ${appointmentId}`);
|
|
12121
|
+
return this.updateAppointmentStatus(
|
|
12122
|
+
appointmentId,
|
|
12123
|
+
"in_progress" /* IN_PROGRESS */
|
|
12124
|
+
);
|
|
12125
|
+
}
|
|
12126
|
+
/**
|
|
12127
|
+
* Marks an appointment as completed.
|
|
12128
|
+
*
|
|
12129
|
+
* @param appointmentId ID of the appointment
|
|
12130
|
+
* @param actualDurationMinutes Actual duration of the appointment in minutes
|
|
12131
|
+
* @returns The updated appointment
|
|
12132
|
+
*/
|
|
12133
|
+
async completeAppointment(appointmentId, actualDurationMinutes) {
|
|
12134
|
+
console.log(
|
|
12135
|
+
`[APPOINTMENT_SERVICE] Completing appointment: ${appointmentId}`
|
|
12136
|
+
);
|
|
12137
|
+
const updateData = {
|
|
12138
|
+
status: "completed" /* COMPLETED */,
|
|
12139
|
+
actualDurationMinutes
|
|
12140
|
+
};
|
|
12141
|
+
return this.updateAppointment(appointmentId, updateData);
|
|
12142
|
+
}
|
|
12143
|
+
/**
|
|
12144
|
+
* Marks an appointment as no-show.
|
|
12145
|
+
*
|
|
12146
|
+
* @param appointmentId ID of the appointment
|
|
12147
|
+
* @returns The updated appointment
|
|
12148
|
+
*/
|
|
12149
|
+
async markNoShow(appointmentId) {
|
|
12150
|
+
console.log(
|
|
12151
|
+
`[APPOINTMENT_SERVICE] Marking appointment as no-show: ${appointmentId}`
|
|
12152
|
+
);
|
|
12153
|
+
return this.updateAppointmentStatus(
|
|
12154
|
+
appointmentId,
|
|
12155
|
+
"no_show" /* NO_SHOW */
|
|
12156
|
+
);
|
|
12157
|
+
}
|
|
12158
|
+
/**
|
|
12159
|
+
* Updates the payment status of an appointment.
|
|
12160
|
+
*
|
|
12161
|
+
* @param appointmentId ID of the appointment
|
|
12162
|
+
* @param paymentStatus New payment status
|
|
12163
|
+
* @param paymentTransactionId Optional transaction ID for the payment
|
|
12164
|
+
* @returns The updated appointment
|
|
12165
|
+
*/
|
|
12166
|
+
async updatePaymentStatus(appointmentId, paymentStatus, paymentTransactionId) {
|
|
12167
|
+
console.log(
|
|
12168
|
+
`[APPOINTMENT_SERVICE] Updating payment status of appointment ${appointmentId} to ${paymentStatus}`
|
|
12169
|
+
);
|
|
12170
|
+
const updateData = {
|
|
12171
|
+
paymentStatus,
|
|
12172
|
+
paymentTransactionId: paymentTransactionId || null
|
|
12173
|
+
};
|
|
12174
|
+
return this.updateAppointment(appointmentId, updateData);
|
|
12175
|
+
}
|
|
12176
|
+
/**
|
|
12177
|
+
* Marks pre-procedure requirements as completed.
|
|
12178
|
+
*
|
|
12179
|
+
* @param appointmentId ID of the appointment
|
|
12180
|
+
* @param requirementIds IDs of the requirements to mark as completed
|
|
12181
|
+
* @returns The updated appointment
|
|
12182
|
+
*/
|
|
12183
|
+
async completePreRequirements(appointmentId, requirementIds) {
|
|
12184
|
+
console.log(
|
|
12185
|
+
`[APPOINTMENT_SERVICE] Marking pre-requirements as completed for appointment: ${appointmentId}`
|
|
12186
|
+
);
|
|
12187
|
+
const updateData = {
|
|
12188
|
+
completedPreRequirements: requirementIds
|
|
12189
|
+
};
|
|
12190
|
+
return this.updateAppointment(appointmentId, updateData);
|
|
12191
|
+
}
|
|
12192
|
+
/**
|
|
12193
|
+
* Marks post-procedure requirements as completed.
|
|
12194
|
+
*
|
|
12195
|
+
* @param appointmentId ID of the appointment
|
|
12196
|
+
* @param requirementIds IDs of the requirements to mark as completed
|
|
12197
|
+
* @returns The updated appointment
|
|
12198
|
+
*/
|
|
12199
|
+
async completePostRequirements(appointmentId, requirementIds) {
|
|
12200
|
+
console.log(
|
|
12201
|
+
`[APPOINTMENT_SERVICE] Marking post-requirements as completed for appointment: ${appointmentId}`
|
|
12202
|
+
);
|
|
12203
|
+
const updateData = {
|
|
12204
|
+
completedPostRequirements: requirementIds
|
|
12205
|
+
};
|
|
12206
|
+
return this.updateAppointment(appointmentId, updateData);
|
|
12207
|
+
}
|
|
12208
|
+
/**
|
|
12209
|
+
* Updates the internal notes of an appointment.
|
|
12210
|
+
*
|
|
12211
|
+
* @param appointmentId ID of the appointment
|
|
12212
|
+
* @param notes Updated internal notes
|
|
12213
|
+
* @returns The updated appointment
|
|
12214
|
+
*/
|
|
12215
|
+
async updateInternalNotes(appointmentId, notes) {
|
|
12216
|
+
console.log(
|
|
12217
|
+
`[APPOINTMENT_SERVICE] Updating internal notes for appointment: ${appointmentId}`
|
|
12218
|
+
);
|
|
12219
|
+
const updateData = {
|
|
12220
|
+
internalNotes: notes
|
|
12221
|
+
};
|
|
12222
|
+
return this.updateAppointment(appointmentId, updateData);
|
|
12223
|
+
}
|
|
12224
|
+
};
|
|
12225
|
+
|
|
12226
|
+
// src/backoffice/services/brand.service.ts
|
|
12227
|
+
var import_firestore39 = require("firebase/firestore");
|
|
12228
|
+
|
|
12229
|
+
// src/backoffice/types/brand.types.ts
|
|
12230
|
+
var BRANDS_COLLECTION = "brands";
|
|
12231
|
+
|
|
12232
|
+
// src/backoffice/services/brand.service.ts
|
|
12233
|
+
var BrandService = class extends BaseService {
|
|
12234
|
+
/**
|
|
12235
|
+
* Gets reference to brands collection
|
|
12236
|
+
*/
|
|
12237
|
+
getBrandsRef() {
|
|
12238
|
+
return (0, import_firestore39.collection)(this.db, BRANDS_COLLECTION);
|
|
12239
|
+
}
|
|
12240
|
+
/**
|
|
12241
|
+
* Creates a new brand
|
|
12242
|
+
*/
|
|
12243
|
+
async create(brand) {
|
|
12244
|
+
const now = /* @__PURE__ */ new Date();
|
|
12245
|
+
const newBrand = {
|
|
12246
|
+
...brand,
|
|
12247
|
+
createdAt: now,
|
|
12248
|
+
updatedAt: now,
|
|
12249
|
+
isActive: true
|
|
12250
|
+
};
|
|
12251
|
+
const docRef = await (0, import_firestore39.addDoc)(this.getBrandsRef(), newBrand);
|
|
12252
|
+
return { id: docRef.id, ...newBrand };
|
|
11361
12253
|
}
|
|
11362
|
-
|
|
11363
|
-
|
|
11364
|
-
|
|
11365
|
-
|
|
11366
|
-
|
|
11367
|
-
|
|
11368
|
-
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
12254
|
+
/**
|
|
12255
|
+
* Gets all active brands
|
|
12256
|
+
*/
|
|
12257
|
+
async getAll() {
|
|
12258
|
+
const q = (0, import_firestore39.query)(this.getBrandsRef(), (0, import_firestore39.where)("isActive", "==", true));
|
|
12259
|
+
const snapshot = await (0, import_firestore39.getDocs)(q);
|
|
12260
|
+
return snapshot.docs.map(
|
|
12261
|
+
(doc30) => ({
|
|
12262
|
+
id: doc30.id,
|
|
12263
|
+
...doc30.data()
|
|
12264
|
+
})
|
|
12265
|
+
);
|
|
12266
|
+
}
|
|
12267
|
+
/**
|
|
12268
|
+
* Updates a brand
|
|
12269
|
+
*/
|
|
12270
|
+
async update(brandId, brand) {
|
|
12271
|
+
const updateData = {
|
|
12272
|
+
...brand,
|
|
12273
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
12274
|
+
};
|
|
12275
|
+
const docRef = (0, import_firestore39.doc)(this.getBrandsRef(), brandId);
|
|
12276
|
+
await (0, import_firestore39.updateDoc)(docRef, updateData);
|
|
12277
|
+
return this.getById(brandId);
|
|
12278
|
+
}
|
|
12279
|
+
/**
|
|
12280
|
+
* Soft deletes a brand
|
|
12281
|
+
*/
|
|
12282
|
+
async delete(brandId) {
|
|
12283
|
+
await this.update(brandId, {
|
|
12284
|
+
isActive: false
|
|
12285
|
+
});
|
|
12286
|
+
}
|
|
12287
|
+
/**
|
|
12288
|
+
* Gets a brand by ID
|
|
12289
|
+
*/
|
|
12290
|
+
async getById(brandId) {
|
|
12291
|
+
const docRef = (0, import_firestore39.doc)(this.getBrandsRef(), brandId);
|
|
12292
|
+
const docSnap = await (0, import_firestore39.getDoc)(docRef);
|
|
12293
|
+
if (!docSnap.exists()) return null;
|
|
12294
|
+
return {
|
|
12295
|
+
id: docSnap.id,
|
|
12296
|
+
...docSnap.data()
|
|
12297
|
+
};
|
|
12298
|
+
}
|
|
12299
|
+
};
|
|
12300
|
+
|
|
12301
|
+
// src/backoffice/services/category.service.ts
|
|
12302
|
+
var import_firestore40 = require("firebase/firestore");
|
|
12303
|
+
|
|
12304
|
+
// src/backoffice/types/category.types.ts
|
|
12305
|
+
var CATEGORIES_COLLECTION = "backoffice_categories";
|
|
12306
|
+
|
|
12307
|
+
// src/backoffice/services/category.service.ts
|
|
12308
|
+
var CategoryService = class extends BaseService {
|
|
11372
12309
|
/**
|
|
11373
12310
|
* Referenca na Firestore kolekciju kategorija
|
|
11374
12311
|
*/
|
|
11375
12312
|
get categoriesRef() {
|
|
11376
|
-
return (0,
|
|
12313
|
+
return (0, import_firestore40.collection)(this.db, CATEGORIES_COLLECTION);
|
|
11377
12314
|
}
|
|
11378
12315
|
/**
|
|
11379
12316
|
* Kreira novu kategoriju u sistemu
|
|
@@ -11388,7 +12325,7 @@ var CategoryService = class extends BaseService {
|
|
|
11388
12325
|
updatedAt: now,
|
|
11389
12326
|
isActive: true
|
|
11390
12327
|
};
|
|
11391
|
-
const docRef = await (0,
|
|
12328
|
+
const docRef = await (0, import_firestore40.addDoc)(this.categoriesRef, newCategory);
|
|
11392
12329
|
return { id: docRef.id, ...newCategory };
|
|
11393
12330
|
}
|
|
11394
12331
|
/**
|
|
@@ -11396,12 +12333,12 @@ var CategoryService = class extends BaseService {
|
|
|
11396
12333
|
* @returns Lista aktivnih kategorija
|
|
11397
12334
|
*/
|
|
11398
12335
|
async getAll() {
|
|
11399
|
-
const q = (0,
|
|
11400
|
-
const snapshot = await (0,
|
|
12336
|
+
const q = (0, import_firestore40.query)(this.categoriesRef, (0, import_firestore40.where)("isActive", "==", true));
|
|
12337
|
+
const snapshot = await (0, import_firestore40.getDocs)(q);
|
|
11401
12338
|
return snapshot.docs.map(
|
|
11402
|
-
(
|
|
11403
|
-
id:
|
|
11404
|
-
...
|
|
12339
|
+
(doc30) => ({
|
|
12340
|
+
id: doc30.id,
|
|
12341
|
+
...doc30.data()
|
|
11405
12342
|
})
|
|
11406
12343
|
);
|
|
11407
12344
|
}
|
|
@@ -11411,16 +12348,16 @@ var CategoryService = class extends BaseService {
|
|
|
11411
12348
|
* @returns Lista kategorija koje pripadaju traženoj familiji
|
|
11412
12349
|
*/
|
|
11413
12350
|
async getAllByFamily(family) {
|
|
11414
|
-
const q = (0,
|
|
12351
|
+
const q = (0, import_firestore40.query)(
|
|
11415
12352
|
this.categoriesRef,
|
|
11416
|
-
(0,
|
|
11417
|
-
(0,
|
|
12353
|
+
(0, import_firestore40.where)("family", "==", family),
|
|
12354
|
+
(0, import_firestore40.where)("isActive", "==", true)
|
|
11418
12355
|
);
|
|
11419
|
-
const snapshot = await (0,
|
|
12356
|
+
const snapshot = await (0, import_firestore40.getDocs)(q);
|
|
11420
12357
|
return snapshot.docs.map(
|
|
11421
|
-
(
|
|
11422
|
-
id:
|
|
11423
|
-
...
|
|
12358
|
+
(doc30) => ({
|
|
12359
|
+
id: doc30.id,
|
|
12360
|
+
...doc30.data()
|
|
11424
12361
|
})
|
|
11425
12362
|
);
|
|
11426
12363
|
}
|
|
@@ -11435,8 +12372,8 @@ var CategoryService = class extends BaseService {
|
|
|
11435
12372
|
...category,
|
|
11436
12373
|
updatedAt: /* @__PURE__ */ new Date()
|
|
11437
12374
|
};
|
|
11438
|
-
const docRef = (0,
|
|
11439
|
-
await (0,
|
|
12375
|
+
const docRef = (0, import_firestore40.doc)(this.categoriesRef, id);
|
|
12376
|
+
await (0, import_firestore40.updateDoc)(docRef, updateData);
|
|
11440
12377
|
return this.getById(id);
|
|
11441
12378
|
}
|
|
11442
12379
|
/**
|
|
@@ -11452,8 +12389,8 @@ var CategoryService = class extends BaseService {
|
|
|
11452
12389
|
* @returns Kategorija ili null ako ne postoji
|
|
11453
12390
|
*/
|
|
11454
12391
|
async getById(id) {
|
|
11455
|
-
const docRef = (0,
|
|
11456
|
-
const docSnap = await (0,
|
|
12392
|
+
const docRef = (0, import_firestore40.doc)(this.categoriesRef, id);
|
|
12393
|
+
const docSnap = await (0, import_firestore40.getDoc)(docRef);
|
|
11457
12394
|
if (!docSnap.exists()) return null;
|
|
11458
12395
|
return {
|
|
11459
12396
|
id: docSnap.id,
|
|
@@ -11463,7 +12400,7 @@ var CategoryService = class extends BaseService {
|
|
|
11463
12400
|
};
|
|
11464
12401
|
|
|
11465
12402
|
// src/backoffice/services/subcategory.service.ts
|
|
11466
|
-
var
|
|
12403
|
+
var import_firestore41 = require("firebase/firestore");
|
|
11467
12404
|
|
|
11468
12405
|
// src/backoffice/types/subcategory.types.ts
|
|
11469
12406
|
var SUBCATEGORIES_COLLECTION = "subcategories";
|
|
@@ -11475,7 +12412,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
11475
12412
|
* @param categoryId - ID roditeljske kategorije
|
|
11476
12413
|
*/
|
|
11477
12414
|
getSubcategoriesRef(categoryId) {
|
|
11478
|
-
return (0,
|
|
12415
|
+
return (0, import_firestore41.collection)(
|
|
11479
12416
|
this.db,
|
|
11480
12417
|
CATEGORIES_COLLECTION,
|
|
11481
12418
|
categoryId,
|
|
@@ -11497,7 +12434,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
11497
12434
|
updatedAt: now,
|
|
11498
12435
|
isActive: true
|
|
11499
12436
|
};
|
|
11500
|
-
const docRef = await (0,
|
|
12437
|
+
const docRef = await (0, import_firestore41.addDoc)(
|
|
11501
12438
|
this.getSubcategoriesRef(categoryId),
|
|
11502
12439
|
newSubcategory
|
|
11503
12440
|
);
|
|
@@ -11509,15 +12446,15 @@ var SubcategoryService = class extends BaseService {
|
|
|
11509
12446
|
* @returns Lista aktivnih podkategorija
|
|
11510
12447
|
*/
|
|
11511
12448
|
async getAllByCategoryId(categoryId) {
|
|
11512
|
-
const q = (0,
|
|
12449
|
+
const q = (0, import_firestore41.query)(
|
|
11513
12450
|
this.getSubcategoriesRef(categoryId),
|
|
11514
|
-
(0,
|
|
12451
|
+
(0, import_firestore41.where)("isActive", "==", true)
|
|
11515
12452
|
);
|
|
11516
|
-
const snapshot = await (0,
|
|
12453
|
+
const snapshot = await (0, import_firestore41.getDocs)(q);
|
|
11517
12454
|
return snapshot.docs.map(
|
|
11518
|
-
(
|
|
11519
|
-
id:
|
|
11520
|
-
...
|
|
12455
|
+
(doc30) => ({
|
|
12456
|
+
id: doc30.id,
|
|
12457
|
+
...doc30.data()
|
|
11521
12458
|
})
|
|
11522
12459
|
);
|
|
11523
12460
|
}
|
|
@@ -11533,8 +12470,8 @@ var SubcategoryService = class extends BaseService {
|
|
|
11533
12470
|
...subcategory,
|
|
11534
12471
|
updatedAt: /* @__PURE__ */ new Date()
|
|
11535
12472
|
};
|
|
11536
|
-
const docRef = (0,
|
|
11537
|
-
await (0,
|
|
12473
|
+
const docRef = (0, import_firestore41.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
12474
|
+
await (0, import_firestore41.updateDoc)(docRef, updateData);
|
|
11538
12475
|
return this.getById(categoryId, subcategoryId);
|
|
11539
12476
|
}
|
|
11540
12477
|
/**
|
|
@@ -11552,8 +12489,8 @@ var SubcategoryService = class extends BaseService {
|
|
|
11552
12489
|
* @returns Podkategorija ili null ako ne postoji
|
|
11553
12490
|
*/
|
|
11554
12491
|
async getById(categoryId, subcategoryId) {
|
|
11555
|
-
const docRef = (0,
|
|
11556
|
-
const docSnap = await (0,
|
|
12492
|
+
const docRef = (0, import_firestore41.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
12493
|
+
const docSnap = await (0, import_firestore41.getDoc)(docRef);
|
|
11557
12494
|
if (!docSnap.exists()) return null;
|
|
11558
12495
|
return {
|
|
11559
12496
|
id: docSnap.id,
|
|
@@ -11563,12 +12500,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
11563
12500
|
};
|
|
11564
12501
|
|
|
11565
12502
|
// src/backoffice/services/technology.service.ts
|
|
11566
|
-
var
|
|
11567
|
-
|
|
11568
|
-
// src/backoffice/types/technology.types.ts
|
|
11569
|
-
var TECHNOLOGIES_COLLECTION = "technologies";
|
|
11570
|
-
|
|
11571
|
-
// src/backoffice/services/technology.service.ts
|
|
12503
|
+
var import_firestore42 = require("firebase/firestore");
|
|
11572
12504
|
var DEFAULT_CERTIFICATION_REQUIREMENT = {
|
|
11573
12505
|
minimumLevel: "aesthetician" /* AESTHETICIAN */,
|
|
11574
12506
|
requiredSpecialties: []
|
|
@@ -11578,7 +12510,7 @@ var TechnologyService = class extends BaseService {
|
|
|
11578
12510
|
* Vraća referencu na Firestore kolekciju tehnologija
|
|
11579
12511
|
*/
|
|
11580
12512
|
getTechnologiesRef() {
|
|
11581
|
-
return (0,
|
|
12513
|
+
return (0, import_firestore42.collection)(this.db, TECHNOLOGIES_COLLECTION);
|
|
11582
12514
|
}
|
|
11583
12515
|
/**
|
|
11584
12516
|
* Kreira novu tehnologiju
|
|
@@ -11601,7 +12533,7 @@ var TechnologyService = class extends BaseService {
|
|
|
11601
12533
|
benefits: technology.benefits || [],
|
|
11602
12534
|
certificationRequirement: technology.certificationRequirement || DEFAULT_CERTIFICATION_REQUIREMENT
|
|
11603
12535
|
};
|
|
11604
|
-
const docRef = await (0,
|
|
12536
|
+
const docRef = await (0, import_firestore42.addDoc)(this.getTechnologiesRef(), newTechnology);
|
|
11605
12537
|
return { id: docRef.id, ...newTechnology };
|
|
11606
12538
|
}
|
|
11607
12539
|
/**
|
|
@@ -11609,12 +12541,12 @@ var TechnologyService = class extends BaseService {
|
|
|
11609
12541
|
* @returns Lista aktivnih tehnologija
|
|
11610
12542
|
*/
|
|
11611
12543
|
async getAll() {
|
|
11612
|
-
const q = (0,
|
|
11613
|
-
const snapshot = await (0,
|
|
12544
|
+
const q = (0, import_firestore42.query)(this.getTechnologiesRef(), (0, import_firestore42.where)("isActive", "==", true));
|
|
12545
|
+
const snapshot = await (0, import_firestore42.getDocs)(q);
|
|
11614
12546
|
return snapshot.docs.map(
|
|
11615
|
-
(
|
|
11616
|
-
id:
|
|
11617
|
-
...
|
|
12547
|
+
(doc30) => ({
|
|
12548
|
+
id: doc30.id,
|
|
12549
|
+
...doc30.data()
|
|
11618
12550
|
})
|
|
11619
12551
|
);
|
|
11620
12552
|
}
|
|
@@ -11624,16 +12556,16 @@ var TechnologyService = class extends BaseService {
|
|
|
11624
12556
|
* @returns Lista aktivnih tehnologija
|
|
11625
12557
|
*/
|
|
11626
12558
|
async getAllByFamily(family) {
|
|
11627
|
-
const q = (0,
|
|
12559
|
+
const q = (0, import_firestore42.query)(
|
|
11628
12560
|
this.getTechnologiesRef(),
|
|
11629
|
-
(0,
|
|
11630
|
-
(0,
|
|
12561
|
+
(0, import_firestore42.where)("isActive", "==", true),
|
|
12562
|
+
(0, import_firestore42.where)("family", "==", family)
|
|
11631
12563
|
);
|
|
11632
|
-
const snapshot = await (0,
|
|
12564
|
+
const snapshot = await (0, import_firestore42.getDocs)(q);
|
|
11633
12565
|
return snapshot.docs.map(
|
|
11634
|
-
(
|
|
11635
|
-
id:
|
|
11636
|
-
...
|
|
12566
|
+
(doc30) => ({
|
|
12567
|
+
id: doc30.id,
|
|
12568
|
+
...doc30.data()
|
|
11637
12569
|
})
|
|
11638
12570
|
);
|
|
11639
12571
|
}
|
|
@@ -11643,16 +12575,16 @@ var TechnologyService = class extends BaseService {
|
|
|
11643
12575
|
* @returns Lista aktivnih tehnologija
|
|
11644
12576
|
*/
|
|
11645
12577
|
async getAllByCategoryId(categoryId) {
|
|
11646
|
-
const q = (0,
|
|
12578
|
+
const q = (0, import_firestore42.query)(
|
|
11647
12579
|
this.getTechnologiesRef(),
|
|
11648
|
-
(0,
|
|
11649
|
-
(0,
|
|
12580
|
+
(0, import_firestore42.where)("isActive", "==", true),
|
|
12581
|
+
(0, import_firestore42.where)("categoryId", "==", categoryId)
|
|
11650
12582
|
);
|
|
11651
|
-
const snapshot = await (0,
|
|
12583
|
+
const snapshot = await (0, import_firestore42.getDocs)(q);
|
|
11652
12584
|
return snapshot.docs.map(
|
|
11653
|
-
(
|
|
11654
|
-
id:
|
|
11655
|
-
...
|
|
12585
|
+
(doc30) => ({
|
|
12586
|
+
id: doc30.id,
|
|
12587
|
+
...doc30.data()
|
|
11656
12588
|
})
|
|
11657
12589
|
);
|
|
11658
12590
|
}
|
|
@@ -11662,16 +12594,16 @@ var TechnologyService = class extends BaseService {
|
|
|
11662
12594
|
* @returns Lista aktivnih tehnologija
|
|
11663
12595
|
*/
|
|
11664
12596
|
async getAllBySubcategoryId(subcategoryId) {
|
|
11665
|
-
const q = (0,
|
|
12597
|
+
const q = (0, import_firestore42.query)(
|
|
11666
12598
|
this.getTechnologiesRef(),
|
|
11667
|
-
(0,
|
|
11668
|
-
(0,
|
|
12599
|
+
(0, import_firestore42.where)("isActive", "==", true),
|
|
12600
|
+
(0, import_firestore42.where)("subcategoryId", "==", subcategoryId)
|
|
11669
12601
|
);
|
|
11670
|
-
const snapshot = await (0,
|
|
12602
|
+
const snapshot = await (0, import_firestore42.getDocs)(q);
|
|
11671
12603
|
return snapshot.docs.map(
|
|
11672
|
-
(
|
|
11673
|
-
id:
|
|
11674
|
-
...
|
|
12604
|
+
(doc30) => ({
|
|
12605
|
+
id: doc30.id,
|
|
12606
|
+
...doc30.data()
|
|
11675
12607
|
})
|
|
11676
12608
|
);
|
|
11677
12609
|
}
|
|
@@ -11686,8 +12618,8 @@ var TechnologyService = class extends BaseService {
|
|
|
11686
12618
|
...technology,
|
|
11687
12619
|
updatedAt: /* @__PURE__ */ new Date()
|
|
11688
12620
|
};
|
|
11689
|
-
const docRef = (0,
|
|
11690
|
-
await (0,
|
|
12621
|
+
const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
|
|
12622
|
+
await (0, import_firestore42.updateDoc)(docRef, updateData);
|
|
11691
12623
|
return this.getById(technologyId);
|
|
11692
12624
|
}
|
|
11693
12625
|
/**
|
|
@@ -11705,8 +12637,8 @@ var TechnologyService = class extends BaseService {
|
|
|
11705
12637
|
* @returns Tehnologija ili null ako ne postoji
|
|
11706
12638
|
*/
|
|
11707
12639
|
async getById(technologyId) {
|
|
11708
|
-
const docRef = (0,
|
|
11709
|
-
const docSnap = await (0,
|
|
12640
|
+
const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
|
|
12641
|
+
const docSnap = await (0, import_firestore42.getDoc)(docRef);
|
|
11710
12642
|
if (!docSnap.exists()) return null;
|
|
11711
12643
|
return {
|
|
11712
12644
|
id: docSnap.id,
|
|
@@ -11720,10 +12652,10 @@ var TechnologyService = class extends BaseService {
|
|
|
11720
12652
|
* @returns Ažurirana tehnologija sa novim zahtevom
|
|
11721
12653
|
*/
|
|
11722
12654
|
async addRequirement(technologyId, requirement) {
|
|
11723
|
-
const docRef = (0,
|
|
12655
|
+
const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
|
|
11724
12656
|
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
11725
|
-
await (0,
|
|
11726
|
-
[requirementType]: (0,
|
|
12657
|
+
await (0, import_firestore42.updateDoc)(docRef, {
|
|
12658
|
+
[requirementType]: (0, import_firestore42.arrayUnion)(requirement),
|
|
11727
12659
|
updatedAt: /* @__PURE__ */ new Date()
|
|
11728
12660
|
});
|
|
11729
12661
|
return this.getById(technologyId);
|
|
@@ -11735,10 +12667,10 @@ var TechnologyService = class extends BaseService {
|
|
|
11735
12667
|
* @returns Ažurirana tehnologija bez uklonjenog zahteva
|
|
11736
12668
|
*/
|
|
11737
12669
|
async removeRequirement(technologyId, requirement) {
|
|
11738
|
-
const docRef = (0,
|
|
12670
|
+
const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
|
|
11739
12671
|
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
11740
|
-
await (0,
|
|
11741
|
-
[requirementType]: (0,
|
|
12672
|
+
await (0, import_firestore42.updateDoc)(docRef, {
|
|
12673
|
+
[requirementType]: (0, import_firestore42.arrayRemove)(requirement),
|
|
11742
12674
|
updatedAt: /* @__PURE__ */ new Date()
|
|
11743
12675
|
});
|
|
11744
12676
|
return this.getById(technologyId);
|
|
@@ -11775,9 +12707,9 @@ var TechnologyService = class extends BaseService {
|
|
|
11775
12707
|
* @returns Ažurirana tehnologija
|
|
11776
12708
|
*/
|
|
11777
12709
|
async addBlockingCondition(technologyId, condition) {
|
|
11778
|
-
const docRef = (0,
|
|
11779
|
-
await (0,
|
|
11780
|
-
blockingConditions: (0,
|
|
12710
|
+
const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
|
|
12711
|
+
await (0, import_firestore42.updateDoc)(docRef, {
|
|
12712
|
+
blockingConditions: (0, import_firestore42.arrayUnion)(condition),
|
|
11781
12713
|
updatedAt: /* @__PURE__ */ new Date()
|
|
11782
12714
|
});
|
|
11783
12715
|
return this.getById(technologyId);
|
|
@@ -11789,9 +12721,9 @@ var TechnologyService = class extends BaseService {
|
|
|
11789
12721
|
* @returns Ažurirana tehnologija
|
|
11790
12722
|
*/
|
|
11791
12723
|
async removeBlockingCondition(technologyId, condition) {
|
|
11792
|
-
const docRef = (0,
|
|
11793
|
-
await (0,
|
|
11794
|
-
blockingConditions: (0,
|
|
12724
|
+
const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
|
|
12725
|
+
await (0, import_firestore42.updateDoc)(docRef, {
|
|
12726
|
+
blockingConditions: (0, import_firestore42.arrayRemove)(condition),
|
|
11795
12727
|
updatedAt: /* @__PURE__ */ new Date()
|
|
11796
12728
|
});
|
|
11797
12729
|
return this.getById(technologyId);
|
|
@@ -11803,9 +12735,9 @@ var TechnologyService = class extends BaseService {
|
|
|
11803
12735
|
* @returns Ažurirana tehnologija
|
|
11804
12736
|
*/
|
|
11805
12737
|
async addContraindication(technologyId, contraindication) {
|
|
11806
|
-
const docRef = (0,
|
|
11807
|
-
await (0,
|
|
11808
|
-
contraindications: (0,
|
|
12738
|
+
const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
|
|
12739
|
+
await (0, import_firestore42.updateDoc)(docRef, {
|
|
12740
|
+
contraindications: (0, import_firestore42.arrayUnion)(contraindication),
|
|
11809
12741
|
updatedAt: /* @__PURE__ */ new Date()
|
|
11810
12742
|
});
|
|
11811
12743
|
return this.getById(technologyId);
|
|
@@ -11817,9 +12749,9 @@ var TechnologyService = class extends BaseService {
|
|
|
11817
12749
|
* @returns Ažurirana tehnologija
|
|
11818
12750
|
*/
|
|
11819
12751
|
async removeContraindication(technologyId, contraindication) {
|
|
11820
|
-
const docRef = (0,
|
|
11821
|
-
await (0,
|
|
11822
|
-
contraindications: (0,
|
|
12752
|
+
const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
|
|
12753
|
+
await (0, import_firestore42.updateDoc)(docRef, {
|
|
12754
|
+
contraindications: (0, import_firestore42.arrayRemove)(contraindication),
|
|
11823
12755
|
updatedAt: /* @__PURE__ */ new Date()
|
|
11824
12756
|
});
|
|
11825
12757
|
return this.getById(technologyId);
|
|
@@ -11831,9 +12763,9 @@ var TechnologyService = class extends BaseService {
|
|
|
11831
12763
|
* @returns Ažurirana tehnologija
|
|
11832
12764
|
*/
|
|
11833
12765
|
async addBenefit(technologyId, benefit) {
|
|
11834
|
-
const docRef = (0,
|
|
11835
|
-
await (0,
|
|
11836
|
-
benefits: (0,
|
|
12766
|
+
const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
|
|
12767
|
+
await (0, import_firestore42.updateDoc)(docRef, {
|
|
12768
|
+
benefits: (0, import_firestore42.arrayUnion)(benefit),
|
|
11837
12769
|
updatedAt: /* @__PURE__ */ new Date()
|
|
11838
12770
|
});
|
|
11839
12771
|
return this.getById(technologyId);
|
|
@@ -11845,9 +12777,9 @@ var TechnologyService = class extends BaseService {
|
|
|
11845
12777
|
* @returns Ažurirana tehnologija
|
|
11846
12778
|
*/
|
|
11847
12779
|
async removeBenefit(technologyId, benefit) {
|
|
11848
|
-
const docRef = (0,
|
|
11849
|
-
await (0,
|
|
11850
|
-
benefits: (0,
|
|
12780
|
+
const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
|
|
12781
|
+
await (0, import_firestore42.updateDoc)(docRef, {
|
|
12782
|
+
benefits: (0, import_firestore42.arrayRemove)(benefit),
|
|
11851
12783
|
updatedAt: /* @__PURE__ */ new Date()
|
|
11852
12784
|
});
|
|
11853
12785
|
return this.getById(technologyId);
|
|
@@ -11886,8 +12818,8 @@ var TechnologyService = class extends BaseService {
|
|
|
11886
12818
|
* @returns Ažurirana tehnologija
|
|
11887
12819
|
*/
|
|
11888
12820
|
async updateCertificationRequirement(technologyId, certificationRequirement) {
|
|
11889
|
-
const docRef = (0,
|
|
11890
|
-
await (0,
|
|
12821
|
+
const docRef = (0, import_firestore42.doc)(this.getTechnologiesRef(), technologyId);
|
|
12822
|
+
await (0, import_firestore42.updateDoc)(docRef, {
|
|
11891
12823
|
certificationRequirement,
|
|
11892
12824
|
updatedAt: /* @__PURE__ */ new Date()
|
|
11893
12825
|
});
|
|
@@ -11987,7 +12919,7 @@ var TechnologyService = class extends BaseService {
|
|
|
11987
12919
|
};
|
|
11988
12920
|
|
|
11989
12921
|
// src/backoffice/services/product.service.ts
|
|
11990
|
-
var
|
|
12922
|
+
var import_firestore43 = require("firebase/firestore");
|
|
11991
12923
|
|
|
11992
12924
|
// src/backoffice/types/product.types.ts
|
|
11993
12925
|
var PRODUCTS_COLLECTION = "products";
|
|
@@ -12000,7 +12932,7 @@ var ProductService = class extends BaseService {
|
|
|
12000
12932
|
* @returns Firestore collection reference
|
|
12001
12933
|
*/
|
|
12002
12934
|
getProductsRef(technologyId) {
|
|
12003
|
-
return (0,
|
|
12935
|
+
return (0, import_firestore43.collection)(
|
|
12004
12936
|
this.db,
|
|
12005
12937
|
TECHNOLOGIES_COLLECTION,
|
|
12006
12938
|
technologyId,
|
|
@@ -12020,7 +12952,7 @@ var ProductService = class extends BaseService {
|
|
|
12020
12952
|
updatedAt: now,
|
|
12021
12953
|
isActive: true
|
|
12022
12954
|
};
|
|
12023
|
-
const productRef = await (0,
|
|
12955
|
+
const productRef = await (0, import_firestore43.addDoc)(
|
|
12024
12956
|
this.getProductsRef(technologyId),
|
|
12025
12957
|
newProduct
|
|
12026
12958
|
);
|
|
@@ -12030,15 +12962,15 @@ var ProductService = class extends BaseService {
|
|
|
12030
12962
|
* Gets all products for a technology
|
|
12031
12963
|
*/
|
|
12032
12964
|
async getAllByTechnology(technologyId) {
|
|
12033
|
-
const q = (0,
|
|
12965
|
+
const q = (0, import_firestore43.query)(
|
|
12034
12966
|
this.getProductsRef(technologyId),
|
|
12035
|
-
(0,
|
|
12967
|
+
(0, import_firestore43.where)("isActive", "==", true)
|
|
12036
12968
|
);
|
|
12037
|
-
const snapshot = await (0,
|
|
12969
|
+
const snapshot = await (0, import_firestore43.getDocs)(q);
|
|
12038
12970
|
return snapshot.docs.map(
|
|
12039
|
-
(
|
|
12040
|
-
id:
|
|
12041
|
-
...
|
|
12971
|
+
(doc30) => ({
|
|
12972
|
+
id: doc30.id,
|
|
12973
|
+
...doc30.data()
|
|
12042
12974
|
})
|
|
12043
12975
|
);
|
|
12044
12976
|
}
|
|
@@ -12046,21 +12978,21 @@ var ProductService = class extends BaseService {
|
|
|
12046
12978
|
* Gets all products for a brand by filtering through all technologies
|
|
12047
12979
|
*/
|
|
12048
12980
|
async getAllByBrand(brandId) {
|
|
12049
|
-
const allTechnologiesRef = (0,
|
|
12050
|
-
const technologiesSnapshot = await (0,
|
|
12981
|
+
const allTechnologiesRef = (0, import_firestore43.collection)(this.db, TECHNOLOGIES_COLLECTION);
|
|
12982
|
+
const technologiesSnapshot = await (0, import_firestore43.getDocs)(allTechnologiesRef);
|
|
12051
12983
|
const products = [];
|
|
12052
12984
|
for (const techDoc of technologiesSnapshot.docs) {
|
|
12053
|
-
const q = (0,
|
|
12985
|
+
const q = (0, import_firestore43.query)(
|
|
12054
12986
|
this.getProductsRef(techDoc.id),
|
|
12055
|
-
(0,
|
|
12056
|
-
(0,
|
|
12987
|
+
(0, import_firestore43.where)("brandId", "==", brandId),
|
|
12988
|
+
(0, import_firestore43.where)("isActive", "==", true)
|
|
12057
12989
|
);
|
|
12058
|
-
const snapshot = await (0,
|
|
12990
|
+
const snapshot = await (0, import_firestore43.getDocs)(q);
|
|
12059
12991
|
products.push(
|
|
12060
12992
|
...snapshot.docs.map(
|
|
12061
|
-
(
|
|
12062
|
-
id:
|
|
12063
|
-
...
|
|
12993
|
+
(doc30) => ({
|
|
12994
|
+
id: doc30.id,
|
|
12995
|
+
...doc30.data()
|
|
12064
12996
|
})
|
|
12065
12997
|
)
|
|
12066
12998
|
);
|
|
@@ -12075,8 +13007,8 @@ var ProductService = class extends BaseService {
|
|
|
12075
13007
|
...product,
|
|
12076
13008
|
updatedAt: /* @__PURE__ */ new Date()
|
|
12077
13009
|
};
|
|
12078
|
-
const docRef = (0,
|
|
12079
|
-
await (0,
|
|
13010
|
+
const docRef = (0, import_firestore43.doc)(this.getProductsRef(technologyId), productId);
|
|
13011
|
+
await (0, import_firestore43.updateDoc)(docRef, updateData);
|
|
12080
13012
|
return this.getById(technologyId, productId);
|
|
12081
13013
|
}
|
|
12082
13014
|
/**
|
|
@@ -12091,8 +13023,8 @@ var ProductService = class extends BaseService {
|
|
|
12091
13023
|
* Gets a product by ID
|
|
12092
13024
|
*/
|
|
12093
13025
|
async getById(technologyId, productId) {
|
|
12094
|
-
const docRef = (0,
|
|
12095
|
-
const docSnap = await (0,
|
|
13026
|
+
const docRef = (0, import_firestore43.doc)(this.getProductsRef(technologyId), productId);
|
|
13027
|
+
const docSnap = await (0, import_firestore43.getDoc)(docRef);
|
|
12096
13028
|
if (!docSnap.exists()) return null;
|
|
12097
13029
|
return {
|
|
12098
13030
|
id: docSnap.id,
|
|
@@ -12102,54 +13034,54 @@ var ProductService = class extends BaseService {
|
|
|
12102
13034
|
};
|
|
12103
13035
|
|
|
12104
13036
|
// src/validations/notification.schema.ts
|
|
12105
|
-
var
|
|
12106
|
-
var baseNotificationSchema =
|
|
12107
|
-
id:
|
|
12108
|
-
userId:
|
|
12109
|
-
notificationTime:
|
|
13037
|
+
var import_zod23 = require("zod");
|
|
13038
|
+
var baseNotificationSchema = import_zod23.z.object({
|
|
13039
|
+
id: import_zod23.z.string().optional(),
|
|
13040
|
+
userId: import_zod23.z.string(),
|
|
13041
|
+
notificationTime: import_zod23.z.any(),
|
|
12110
13042
|
// Timestamp
|
|
12111
|
-
notificationType:
|
|
12112
|
-
notificationTokens:
|
|
12113
|
-
status:
|
|
12114
|
-
createdAt:
|
|
13043
|
+
notificationType: import_zod23.z.nativeEnum(NotificationType),
|
|
13044
|
+
notificationTokens: import_zod23.z.array(import_zod23.z.string()),
|
|
13045
|
+
status: import_zod23.z.nativeEnum(NotificationStatus),
|
|
13046
|
+
createdAt: import_zod23.z.any().optional(),
|
|
12115
13047
|
// Timestamp
|
|
12116
|
-
updatedAt:
|
|
13048
|
+
updatedAt: import_zod23.z.any().optional(),
|
|
12117
13049
|
// Timestamp
|
|
12118
|
-
title:
|
|
12119
|
-
body:
|
|
12120
|
-
isRead:
|
|
12121
|
-
userRole:
|
|
13050
|
+
title: import_zod23.z.string(),
|
|
13051
|
+
body: import_zod23.z.string(),
|
|
13052
|
+
isRead: import_zod23.z.boolean(),
|
|
13053
|
+
userRole: import_zod23.z.nativeEnum(UserRole)
|
|
12122
13054
|
});
|
|
12123
13055
|
var preRequirementNotificationSchema = baseNotificationSchema.extend({
|
|
12124
|
-
notificationType:
|
|
12125
|
-
treatmentId:
|
|
12126
|
-
requirements:
|
|
12127
|
-
deadline:
|
|
13056
|
+
notificationType: import_zod23.z.literal("preRequirement" /* PRE_REQUIREMENT */),
|
|
13057
|
+
treatmentId: import_zod23.z.string(),
|
|
13058
|
+
requirements: import_zod23.z.array(import_zod23.z.string()),
|
|
13059
|
+
deadline: import_zod23.z.any()
|
|
12128
13060
|
// Timestamp
|
|
12129
13061
|
});
|
|
12130
13062
|
var postRequirementNotificationSchema = baseNotificationSchema.extend({
|
|
12131
|
-
notificationType:
|
|
12132
|
-
treatmentId:
|
|
12133
|
-
requirements:
|
|
12134
|
-
deadline:
|
|
13063
|
+
notificationType: import_zod23.z.literal("postRequirement" /* POST_REQUIREMENT */),
|
|
13064
|
+
treatmentId: import_zod23.z.string(),
|
|
13065
|
+
requirements: import_zod23.z.array(import_zod23.z.string()),
|
|
13066
|
+
deadline: import_zod23.z.any()
|
|
12135
13067
|
// Timestamp
|
|
12136
13068
|
});
|
|
12137
13069
|
var appointmentReminderNotificationSchema = baseNotificationSchema.extend({
|
|
12138
|
-
notificationType:
|
|
12139
|
-
appointmentId:
|
|
12140
|
-
appointmentTime:
|
|
13070
|
+
notificationType: import_zod23.z.literal("appointmentReminder" /* APPOINTMENT_REMINDER */),
|
|
13071
|
+
appointmentId: import_zod23.z.string(),
|
|
13072
|
+
appointmentTime: import_zod23.z.any(),
|
|
12141
13073
|
// Timestamp
|
|
12142
|
-
treatmentType:
|
|
12143
|
-
doctorName:
|
|
13074
|
+
treatmentType: import_zod23.z.string(),
|
|
13075
|
+
doctorName: import_zod23.z.string()
|
|
12144
13076
|
});
|
|
12145
13077
|
var appointmentNotificationSchema = baseNotificationSchema.extend({
|
|
12146
|
-
notificationType:
|
|
12147
|
-
appointmentId:
|
|
12148
|
-
appointmentStatus:
|
|
12149
|
-
previousStatus:
|
|
12150
|
-
reason:
|
|
13078
|
+
notificationType: import_zod23.z.literal("appointmentNotification" /* APPOINTMENT_NOTIFICATION */),
|
|
13079
|
+
appointmentId: import_zod23.z.string(),
|
|
13080
|
+
appointmentStatus: import_zod23.z.string(),
|
|
13081
|
+
previousStatus: import_zod23.z.string(),
|
|
13082
|
+
reason: import_zod23.z.string().optional()
|
|
12151
13083
|
});
|
|
12152
|
-
var notificationSchema =
|
|
13084
|
+
var notificationSchema = import_zod23.z.discriminatedUnion("notificationType", [
|
|
12153
13085
|
preRequirementNotificationSchema,
|
|
12154
13086
|
postRequirementNotificationSchema,
|
|
12155
13087
|
appointmentReminderNotificationSchema,
|
|
@@ -12189,9 +13121,12 @@ var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
|
|
|
12189
13121
|
})(RequirementType || {});
|
|
12190
13122
|
// Annotate the CommonJS export names for ESM import in node:
|
|
12191
13123
|
0 && (module.exports = {
|
|
13124
|
+
APPOINTMENTS_COLLECTION,
|
|
12192
13125
|
AUTH_ERRORS,
|
|
12193
13126
|
AdminTokenStatus,
|
|
12194
13127
|
AllergyType,
|
|
13128
|
+
AppointmentService,
|
|
13129
|
+
AppointmentStatus,
|
|
12195
13130
|
AuthService,
|
|
12196
13131
|
BlockingCondition,
|
|
12197
13132
|
BrandService,
|
|
@@ -12241,6 +13176,7 @@ var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
|
|
|
12241
13176
|
PRACTITIONERS_COLLECTION,
|
|
12242
13177
|
PROCEDURES_COLLECTION,
|
|
12243
13178
|
PatientService,
|
|
13179
|
+
PaymentStatus,
|
|
12244
13180
|
PracticeType,
|
|
12245
13181
|
PractitionerService,
|
|
12246
13182
|
PractitionerStatus,
|
|
@@ -12355,6 +13291,7 @@ var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
|
|
|
12355
13291
|
procedureSummaryInfoSchema,
|
|
12356
13292
|
requesterInfoSchema,
|
|
12357
13293
|
reviewSchema,
|
|
13294
|
+
searchAppointmentsSchema,
|
|
12358
13295
|
searchPatientsSchema,
|
|
12359
13296
|
syncedCalendarEventSchema,
|
|
12360
13297
|
timeSlotSchema,
|