@blackcode_sa/metaestetics-api 1.6.2 → 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/admin/index.d.mts +228 -25
  2. package/dist/admin/index.d.ts +228 -25
  3. package/dist/admin/index.js +35867 -2493
  4. package/dist/admin/index.mjs +35856 -2464
  5. package/dist/backoffice/index.d.mts +252 -1
  6. package/dist/backoffice/index.d.ts +252 -1
  7. package/dist/backoffice/index.js +86 -12
  8. package/dist/backoffice/index.mjs +86 -13
  9. package/dist/index.d.mts +1417 -554
  10. package/dist/index.d.ts +1417 -554
  11. package/dist/index.js +1393 -687
  12. package/dist/index.mjs +1423 -711
  13. package/package.json +1 -1
  14. package/src/admin/index.ts +15 -1
  15. package/src/admin/notifications/notifications.admin.ts +1 -1
  16. package/src/admin/requirements/README.md +128 -0
  17. package/src/admin/requirements/patient-requirements.admin.service.ts +482 -0
  18. package/src/index.ts +16 -1
  19. package/src/services/appointment/appointment.service.ts +315 -86
  20. package/src/services/clinic/clinic-admin.service.ts +3 -0
  21. package/src/services/clinic/clinic-group.service.ts +8 -0
  22. package/src/services/documentation-templates/documentation-template.service.ts +24 -16
  23. package/src/services/documentation-templates/filled-document.service.ts +253 -136
  24. package/src/services/patient/patient.service.ts +31 -1
  25. package/src/services/patient/patientRequirements.service.ts +285 -0
  26. package/src/services/patient/utils/practitioner.utils.ts +79 -1
  27. package/src/types/appointment/index.ts +134 -10
  28. package/src/types/documentation-templates/index.ts +34 -2
  29. package/src/types/notifications/README.md +77 -0
  30. package/src/types/notifications/index.ts +154 -27
  31. package/src/types/patient/index.ts +6 -0
  32. package/src/types/patient/patient-requirements.ts +81 -0
  33. package/src/validations/appointment.schema.ts +300 -62
  34. package/src/validations/documentation-templates/template.schema.ts +55 -0
  35. package/src/validations/documentation-templates.schema.ts +9 -14
  36. package/src/validations/notification.schema.ts +3 -3
  37. package/src/validations/patient/patient-requirements.schema.ts +75 -0
@@ -220,6 +220,7 @@ var DocumentElementType = /* @__PURE__ */ ((DocumentElementType2) => {
220
220
  DocumentElementType2["TEXT_INPUT"] = "text_input";
221
221
  DocumentElementType2["DATE_PICKER"] = "date_picker";
222
222
  DocumentElementType2["SIGNATURE"] = "signature";
223
+ DocumentElementType2["DITIGAL_SIGNATURE"] = "digital_signature";
223
224
  DocumentElementType2["FILE_UPLOAD"] = "file_upload";
224
225
  return DocumentElementType2;
225
226
  })(DocumentElementType || {});
@@ -244,8 +245,22 @@ var DynamicVariable = /* @__PURE__ */ ((DynamicVariable2) => {
244
245
  DynamicVariable2["PATIENT_BIRTHDAY"] = "[PATIENT_BIRTHDAY]";
245
246
  DynamicVariable2["APPOINTMENT_DATE"] = "[APPOINTMENT_DATE]";
246
247
  DynamicVariable2["CURRENT_DATE"] = "[CURRENT_DATE]";
248
+ DynamicVariable2["PROCEDURE_NAME"] = "[PROCEDURE_NAME]";
249
+ DynamicVariable2["PROCEDURE_DESCRIPTION"] = "[PROCEDURE_DESCRIPTION]";
250
+ DynamicVariable2["PROCEDURE_COST"] = "[PROCEDURE_COST]";
251
+ DynamicVariable2["PROCEDURE_DURATION"] = "[PROCEDURE_DURATION]";
252
+ DynamicVariable2["PROCEDURE_RISK"] = "[PROCEDURE_RISK]";
247
253
  return DynamicVariable2;
248
254
  })(DynamicVariable || {});
255
+ var FilledDocumentStatus = /* @__PURE__ */ ((FilledDocumentStatus2) => {
256
+ FilledDocumentStatus2["DRAFT"] = "draft";
257
+ FilledDocumentStatus2["SKIPPED"] = "skipped";
258
+ FilledDocumentStatus2["PENDING"] = "pending";
259
+ FilledDocumentStatus2["COMPLETED"] = "completed";
260
+ FilledDocumentStatus2["SIGNED"] = "signed";
261
+ FilledDocumentStatus2["REJECTED"] = "rejected";
262
+ return FilledDocumentStatus2;
263
+ })(FilledDocumentStatus || {});
249
264
 
250
265
  // src/backoffice/constants/certification.constants.ts
251
266
  var DEFAULT_CERTIFICATION_REQUIREMENT = {
@@ -464,6 +479,11 @@ var signatureElementSchema = baseElementSchema.extend({
464
479
  type: import_zod.z.literal("signature" /* SIGNATURE */),
465
480
  label: import_zod.z.string().min(1).max(200)
466
481
  });
482
+ var digitalSignatureElementSchema = baseElementSchema.extend({
483
+ type: import_zod.z.literal("digital_signature" /* DITIGAL_SIGNATURE */),
484
+ // Matching your type enum
485
+ label: import_zod.z.string().min(1).max(200)
486
+ });
467
487
  var fileUploadElementSchema = baseElementSchema.extend({
468
488
  type: import_zod.z.literal("file_upload" /* FILE_UPLOAD */),
469
489
  label: import_zod.z.string().min(1).max(200),
@@ -482,6 +502,7 @@ var documentElementSchema = import_zod.z.discriminatedUnion("type", [
482
502
  textInputElementSchema,
483
503
  datePickerElementSchema,
484
504
  signatureElementSchema,
505
+ digitalSignatureElementSchema,
485
506
  fileUploadElementSchema
486
507
  ]);
487
508
  var documentElementWithoutIdSchema = import_zod.z.discriminatedUnion("type", [
@@ -496,20 +517,27 @@ var documentElementWithoutIdSchema = import_zod.z.discriminatedUnion("type", [
496
517
  textInputElementSchema.omit({ id: true }),
497
518
  datePickerElementSchema.omit({ id: true }),
498
519
  signatureElementSchema.omit({ id: true }),
520
+ digitalSignatureElementSchema.omit({ id: true }),
499
521
  fileUploadElementSchema.omit({ id: true })
500
522
  ]);
501
523
  var createDocumentTemplateSchema = import_zod.z.object({
502
524
  title: import_zod.z.string().min(1).max(200),
503
525
  description: import_zod.z.string().max(1e3).optional(),
504
526
  elements: import_zod.z.array(documentElementWithoutIdSchema).min(1).max(100),
505
- tags: import_zod.z.array(import_zod.z.string().min(1).max(50)).max(20).optional()
527
+ tags: import_zod.z.array(import_zod.z.string().min(1).max(50)).max(20).optional(),
528
+ isUserForm: import_zod.z.boolean().optional().default(false),
529
+ isRequired: import_zod.z.boolean().optional().default(false),
530
+ sortingOrder: import_zod.z.number().int().optional().default(0)
506
531
  });
507
532
  var updateDocumentTemplateSchema = import_zod.z.object({
508
533
  title: import_zod.z.string().min(1).max(200).optional(),
509
534
  description: import_zod.z.string().max(1e3).optional(),
510
535
  elements: import_zod.z.array(documentElementWithoutIdSchema).min(1).max(100).optional(),
511
536
  tags: import_zod.z.array(import_zod.z.string().min(1).max(50)).max(20).optional(),
512
- isActive: import_zod.z.boolean().optional()
537
+ isActive: import_zod.z.boolean().optional(),
538
+ isUserForm: import_zod.z.boolean().optional(),
539
+ isRequired: import_zod.z.boolean().optional(),
540
+ sortingOrder: import_zod.z.number().int().optional()
513
541
  });
514
542
  var documentTemplateSchema = import_zod.z.object({
515
543
  id: import_zod.z.string(),
@@ -521,7 +549,40 @@ var documentTemplateSchema = import_zod.z.object({
521
549
  elements: import_zod.z.array(documentElementSchema),
522
550
  tags: import_zod.z.array(import_zod.z.string().min(1).max(50)).max(20).optional(),
523
551
  version: import_zod.z.number().int().positive(),
524
- isActive: import_zod.z.boolean()
552
+ isActive: import_zod.z.boolean(),
553
+ isUserForm: import_zod.z.boolean().optional().default(false),
554
+ isRequired: import_zod.z.boolean().optional().default(false),
555
+ sortingOrder: import_zod.z.number().int().optional().default(0)
556
+ });
557
+ var filledDocumentStatusSchema = import_zod.z.nativeEnum(FilledDocumentStatus);
558
+ var filledDocumentSchema = import_zod.z.object({
559
+ id: import_zod.z.string(),
560
+ templateId: import_zod.z.string(),
561
+ templateVersion: import_zod.z.number(),
562
+ isUserForm: import_zod.z.boolean(),
563
+ procedureId: import_zod.z.string(),
564
+ appointmentId: import_zod.z.string(),
565
+ patientId: import_zod.z.string(),
566
+ practitionerId: import_zod.z.string(),
567
+ clinicId: import_zod.z.string(),
568
+ createdAt: import_zod.z.number(),
569
+ updatedAt: import_zod.z.number(),
570
+ values: import_zod.z.record(import_zod.z.string(), import_zod.z.any()),
571
+ status: filledDocumentStatusSchema
572
+ });
573
+ var createFilledDocumentDataSchema = import_zod.z.object({
574
+ templateId: import_zod.z.string(),
575
+ procedureId: import_zod.z.string(),
576
+ appointmentId: import_zod.z.string(),
577
+ patientId: import_zod.z.string(),
578
+ practitionerId: import_zod.z.string(),
579
+ clinicId: import_zod.z.string(),
580
+ values: import_zod.z.record(import_zod.z.string(), import_zod.z.any()).optional().default({}),
581
+ status: filledDocumentStatusSchema.optional().default("draft" /* DRAFT */)
582
+ });
583
+ var updateFilledDocumentDataSchema = import_zod.z.object({
584
+ values: import_zod.z.record(import_zod.z.string(), import_zod.z.any()).optional(),
585
+ status: filledDocumentStatusSchema.optional()
525
586
  });
526
587
 
527
588
  // src/backoffice/validations/schemas.ts
@@ -1538,7 +1599,10 @@ var DocumentationTemplateService = class extends BaseService {
1538
1599
  createdBy: userId,
1539
1600
  version: 1,
1540
1601
  isActive: true,
1541
- tags: validatedData.tags || []
1602
+ tags: validatedData.tags || [],
1603
+ isUserForm: validatedData.isUserForm || false,
1604
+ isRequired: validatedData.isRequired || false,
1605
+ sortingOrder: validatedData.sortingOrder || 0
1542
1606
  };
1543
1607
  const docRef = (0, import_firestore7.doc)(this.collectionRef, templateId);
1544
1608
  await (0, import_firestore7.setDoc)(docRef, template);
@@ -1573,21 +1637,31 @@ var DocumentationTemplateService = class extends BaseService {
1573
1637
  if (validatedData.elements) {
1574
1638
  updatedElements = validatedData.elements.map((element) => ({
1575
1639
  ...element,
1576
- id: this.generateId()
1640
+ id: element.id || this.generateId()
1577
1641
  }));
1578
1642
  }
1579
- const updateData = {
1580
- ...validatedData,
1643
+ const updatePayload = {
1581
1644
  elements: updatedElements,
1582
1645
  updatedAt: Date.now(),
1583
1646
  version: template.version + 1
1584
1647
  };
1648
+ if (validatedData.title !== void 0)
1649
+ updatePayload.title = validatedData.title;
1650
+ if (validatedData.description !== void 0)
1651
+ updatePayload.description = validatedData.description;
1652
+ if (validatedData.isActive !== void 0)
1653
+ updatePayload.isActive = validatedData.isActive;
1654
+ if (validatedData.tags !== void 0)
1655
+ updatePayload.tags = validatedData.tags;
1656
+ if (validatedData.isUserForm !== void 0)
1657
+ updatePayload.isUserForm = validatedData.isUserForm;
1658
+ if (validatedData.isRequired !== void 0)
1659
+ updatePayload.isRequired = validatedData.isRequired;
1660
+ if (validatedData.sortingOrder !== void 0)
1661
+ updatePayload.sortingOrder = validatedData.sortingOrder;
1585
1662
  const docRef = (0, import_firestore7.doc)(this.collectionRef, templateId);
1586
- await (0, import_firestore7.updateDoc)(docRef, updateData);
1587
- return {
1588
- ...template,
1589
- ...updateData
1590
- };
1663
+ await (0, import_firestore7.updateDoc)(docRef, updatePayload);
1664
+ return { ...template, ...updatePayload };
1591
1665
  }
1592
1666
  /**
1593
1667
  * Delete a document template
@@ -128,6 +128,7 @@ var DocumentElementType = /* @__PURE__ */ ((DocumentElementType2) => {
128
128
  DocumentElementType2["TEXT_INPUT"] = "text_input";
129
129
  DocumentElementType2["DATE_PICKER"] = "date_picker";
130
130
  DocumentElementType2["SIGNATURE"] = "signature";
131
+ DocumentElementType2["DITIGAL_SIGNATURE"] = "digital_signature";
131
132
  DocumentElementType2["FILE_UPLOAD"] = "file_upload";
132
133
  return DocumentElementType2;
133
134
  })(DocumentElementType || {});
@@ -152,8 +153,22 @@ var DynamicVariable = /* @__PURE__ */ ((DynamicVariable2) => {
152
153
  DynamicVariable2["PATIENT_BIRTHDAY"] = "[PATIENT_BIRTHDAY]";
153
154
  DynamicVariable2["APPOINTMENT_DATE"] = "[APPOINTMENT_DATE]";
154
155
  DynamicVariable2["CURRENT_DATE"] = "[CURRENT_DATE]";
156
+ DynamicVariable2["PROCEDURE_NAME"] = "[PROCEDURE_NAME]";
157
+ DynamicVariable2["PROCEDURE_DESCRIPTION"] = "[PROCEDURE_DESCRIPTION]";
158
+ DynamicVariable2["PROCEDURE_COST"] = "[PROCEDURE_COST]";
159
+ DynamicVariable2["PROCEDURE_DURATION"] = "[PROCEDURE_DURATION]";
160
+ DynamicVariable2["PROCEDURE_RISK"] = "[PROCEDURE_RISK]";
155
161
  return DynamicVariable2;
156
162
  })(DynamicVariable || {});
163
+ var FilledDocumentStatus = /* @__PURE__ */ ((FilledDocumentStatus2) => {
164
+ FilledDocumentStatus2["DRAFT"] = "draft";
165
+ FilledDocumentStatus2["SKIPPED"] = "skipped";
166
+ FilledDocumentStatus2["PENDING"] = "pending";
167
+ FilledDocumentStatus2["COMPLETED"] = "completed";
168
+ FilledDocumentStatus2["SIGNED"] = "signed";
169
+ FilledDocumentStatus2["REJECTED"] = "rejected";
170
+ return FilledDocumentStatus2;
171
+ })(FilledDocumentStatus || {});
157
172
 
158
173
  // src/backoffice/constants/certification.constants.ts
159
174
  var DEFAULT_CERTIFICATION_REQUIREMENT = {
@@ -372,6 +387,11 @@ var signatureElementSchema = baseElementSchema.extend({
372
387
  type: z.literal("signature" /* SIGNATURE */),
373
388
  label: z.string().min(1).max(200)
374
389
  });
390
+ var digitalSignatureElementSchema = baseElementSchema.extend({
391
+ type: z.literal("digital_signature" /* DITIGAL_SIGNATURE */),
392
+ // Matching your type enum
393
+ label: z.string().min(1).max(200)
394
+ });
375
395
  var fileUploadElementSchema = baseElementSchema.extend({
376
396
  type: z.literal("file_upload" /* FILE_UPLOAD */),
377
397
  label: z.string().min(1).max(200),
@@ -390,6 +410,7 @@ var documentElementSchema = z.discriminatedUnion("type", [
390
410
  textInputElementSchema,
391
411
  datePickerElementSchema,
392
412
  signatureElementSchema,
413
+ digitalSignatureElementSchema,
393
414
  fileUploadElementSchema
394
415
  ]);
395
416
  var documentElementWithoutIdSchema = z.discriminatedUnion("type", [
@@ -404,20 +425,27 @@ var documentElementWithoutIdSchema = z.discriminatedUnion("type", [
404
425
  textInputElementSchema.omit({ id: true }),
405
426
  datePickerElementSchema.omit({ id: true }),
406
427
  signatureElementSchema.omit({ id: true }),
428
+ digitalSignatureElementSchema.omit({ id: true }),
407
429
  fileUploadElementSchema.omit({ id: true })
408
430
  ]);
409
431
  var createDocumentTemplateSchema = z.object({
410
432
  title: z.string().min(1).max(200),
411
433
  description: z.string().max(1e3).optional(),
412
434
  elements: z.array(documentElementWithoutIdSchema).min(1).max(100),
413
- tags: z.array(z.string().min(1).max(50)).max(20).optional()
435
+ tags: z.array(z.string().min(1).max(50)).max(20).optional(),
436
+ isUserForm: z.boolean().optional().default(false),
437
+ isRequired: z.boolean().optional().default(false),
438
+ sortingOrder: z.number().int().optional().default(0)
414
439
  });
415
440
  var updateDocumentTemplateSchema = z.object({
416
441
  title: z.string().min(1).max(200).optional(),
417
442
  description: z.string().max(1e3).optional(),
418
443
  elements: z.array(documentElementWithoutIdSchema).min(1).max(100).optional(),
419
444
  tags: z.array(z.string().min(1).max(50)).max(20).optional(),
420
- isActive: z.boolean().optional()
445
+ isActive: z.boolean().optional(),
446
+ isUserForm: z.boolean().optional(),
447
+ isRequired: z.boolean().optional(),
448
+ sortingOrder: z.number().int().optional()
421
449
  });
422
450
  var documentTemplateSchema = z.object({
423
451
  id: z.string(),
@@ -429,7 +457,40 @@ var documentTemplateSchema = z.object({
429
457
  elements: z.array(documentElementSchema),
430
458
  tags: z.array(z.string().min(1).max(50)).max(20).optional(),
431
459
  version: z.number().int().positive(),
432
- isActive: z.boolean()
460
+ isActive: z.boolean(),
461
+ isUserForm: z.boolean().optional().default(false),
462
+ isRequired: z.boolean().optional().default(false),
463
+ sortingOrder: z.number().int().optional().default(0)
464
+ });
465
+ var filledDocumentStatusSchema = z.nativeEnum(FilledDocumentStatus);
466
+ var filledDocumentSchema = z.object({
467
+ id: z.string(),
468
+ templateId: z.string(),
469
+ templateVersion: z.number(),
470
+ isUserForm: z.boolean(),
471
+ procedureId: z.string(),
472
+ appointmentId: z.string(),
473
+ patientId: z.string(),
474
+ practitionerId: z.string(),
475
+ clinicId: z.string(),
476
+ createdAt: z.number(),
477
+ updatedAt: z.number(),
478
+ values: z.record(z.string(), z.any()),
479
+ status: filledDocumentStatusSchema
480
+ });
481
+ var createFilledDocumentDataSchema = z.object({
482
+ templateId: z.string(),
483
+ procedureId: z.string(),
484
+ appointmentId: z.string(),
485
+ patientId: z.string(),
486
+ practitionerId: z.string(),
487
+ clinicId: z.string(),
488
+ values: z.record(z.string(), z.any()).optional().default({}),
489
+ status: filledDocumentStatusSchema.optional().default("draft" /* DRAFT */)
490
+ });
491
+ var updateFilledDocumentDataSchema = z.object({
492
+ values: z.record(z.string(), z.any()).optional(),
493
+ status: filledDocumentStatusSchema.optional()
433
494
  });
434
495
 
435
496
  // src/backoffice/validations/schemas.ts
@@ -1515,7 +1576,10 @@ var DocumentationTemplateService = class extends BaseService {
1515
1576
  createdBy: userId,
1516
1577
  version: 1,
1517
1578
  isActive: true,
1518
- tags: validatedData.tags || []
1579
+ tags: validatedData.tags || [],
1580
+ isUserForm: validatedData.isUserForm || false,
1581
+ isRequired: validatedData.isRequired || false,
1582
+ sortingOrder: validatedData.sortingOrder || 0
1519
1583
  };
1520
1584
  const docRef = doc7(this.collectionRef, templateId);
1521
1585
  await setDoc(docRef, template);
@@ -1550,21 +1614,31 @@ var DocumentationTemplateService = class extends BaseService {
1550
1614
  if (validatedData.elements) {
1551
1615
  updatedElements = validatedData.elements.map((element) => ({
1552
1616
  ...element,
1553
- id: this.generateId()
1617
+ id: element.id || this.generateId()
1554
1618
  }));
1555
1619
  }
1556
- const updateData = {
1557
- ...validatedData,
1620
+ const updatePayload = {
1558
1621
  elements: updatedElements,
1559
1622
  updatedAt: Date.now(),
1560
1623
  version: template.version + 1
1561
1624
  };
1625
+ if (validatedData.title !== void 0)
1626
+ updatePayload.title = validatedData.title;
1627
+ if (validatedData.description !== void 0)
1628
+ updatePayload.description = validatedData.description;
1629
+ if (validatedData.isActive !== void 0)
1630
+ updatePayload.isActive = validatedData.isActive;
1631
+ if (validatedData.tags !== void 0)
1632
+ updatePayload.tags = validatedData.tags;
1633
+ if (validatedData.isUserForm !== void 0)
1634
+ updatePayload.isUserForm = validatedData.isUserForm;
1635
+ if (validatedData.isRequired !== void 0)
1636
+ updatePayload.isRequired = validatedData.isRequired;
1637
+ if (validatedData.sortingOrder !== void 0)
1638
+ updatePayload.sortingOrder = validatedData.sortingOrder;
1562
1639
  const docRef = doc7(this.collectionRef, templateId);
1563
- await updateDoc7(docRef, updateData);
1564
- return {
1565
- ...template,
1566
- ...updateData
1567
- };
1640
+ await updateDoc7(docRef, updatePayload);
1641
+ return { ...template, ...updatePayload };
1568
1642
  }
1569
1643
  /**
1570
1644
  * Delete a document template
@@ -1672,7 +1746,6 @@ import {
1672
1746
  setDoc as setDoc2,
1673
1747
  updateDoc as updateDoc8,
1674
1748
  query as query8,
1675
- where as where8,
1676
1749
  orderBy as orderBy2,
1677
1750
  limit as limit2,
1678
1751
  startAfter as startAfter2