@blackcode_sa/metaestetics-api 1.6.25 → 1.6.26

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.
@@ -5007,7 +5007,6 @@ var BookingAdmin = class {
5007
5007
  * @returns Promise resolving to an object indicating success, and appointmentId or an error message.
5008
5008
  */
5009
5009
  async orchestrateAppointmentCreation(data, authenticatedUserId) {
5010
- var _a;
5011
5010
  console.log(
5012
5011
  `[BookingAdmin] Orchestrating appointment creation for patient ${data.patientId} by user ${authenticatedUserId}`
5013
5012
  );
@@ -5113,60 +5112,6 @@ var BookingAdmin = class {
5113
5112
  dateOfBirth: (patientSensitiveData == null ? void 0 : patientSensitiveData.dateOfBirth) || patientProfileData.dateOfBirth || admin12.firestore.Timestamp.now(),
5114
5113
  gender: (patientSensitiveData == null ? void 0 : patientSensitiveData.gender) || "other" /* OTHER */
5115
5114
  };
5116
- const procedureCategory = procedure.category;
5117
- const procedureSubCategory = procedure.subcategory;
5118
- const procedureTechnology = procedure.technology;
5119
- const procedureProduct = procedure.product;
5120
- const procedureInfo = {
5121
- id: procedure.id,
5122
- name: procedure.name,
5123
- description: procedure.description,
5124
- family: procedure.family,
5125
- categoryName: (procedureCategory == null ? void 0 : procedureCategory.name) || "",
5126
- subcategoryName: (procedureSubCategory == null ? void 0 : procedureSubCategory.name) || "",
5127
- technologyName: (procedureTechnology == null ? void 0 : procedureTechnology.name) || "",
5128
- price: procedure.price,
5129
- pricingMeasure: procedure.pricingMeasure,
5130
- currency: procedure.currency,
5131
- duration: procedure.duration,
5132
- clinicId: procedure.clinicBranchId,
5133
- clinicName: clinicData.name,
5134
- practitionerId: procedure.practitionerId,
5135
- practitionerName: `${practitionerData.basicInfo.firstName} ${practitionerData.basicInfo.lastName}`,
5136
- photo: ((_a = procedure.photos) == null ? void 0 : _a[0]) || "",
5137
- brandName: (procedureProduct == null ? void 0 : procedureProduct.brandName) || "",
5138
- productName: (procedureProduct == null ? void 0 : procedureProduct.name) || ""
5139
- };
5140
- const procedureExtendedInfo = {
5141
- id: procedure.id,
5142
- name: procedure.name,
5143
- description: procedure.description,
5144
- cost: procedure.price,
5145
- duration: procedure.duration,
5146
- procedureFamily: procedure.family,
5147
- procedureCategoryId: (procedureCategory == null ? void 0 : procedureCategory.id) || "",
5148
- procedureCategoryName: (procedureCategory == null ? void 0 : procedureCategory.name) || "",
5149
- procedureSubCategoryId: (procedureSubCategory == null ? void 0 : procedureSubCategory.id) || "",
5150
- procedureSubCategoryName: (procedureSubCategory == null ? void 0 : procedureSubCategory.name) || "",
5151
- procedureTechnologyId: (procedureTechnology == null ? void 0 : procedureTechnology.id) || "",
5152
- procedureTechnologyName: (procedureTechnology == null ? void 0 : procedureTechnology.name) || "",
5153
- procedureProductBrandId: procedureProduct.brandId || "",
5154
- procedureProductBrandName: procedureProduct.brandName || "",
5155
- procedureProductId: procedureProduct.id || "",
5156
- procedureProductName: procedureProduct.name || ""
5157
- };
5158
- let pendingUserFormsIds = [];
5159
- let linkedFormIds = [];
5160
- if (procedure.documentationTemplates && Array.isArray(procedure.documentationTemplates)) {
5161
- pendingUserFormsIds = procedure.documentationTemplates.filter(
5162
- (template) => template.isUserForm && template.isRequired
5163
- ).map(
5164
- (template) => template.templateId
5165
- );
5166
- linkedFormIds = procedure.documentationTemplates.map(
5167
- (template) => template.templateId
5168
- );
5169
- }
5170
5115
  const newAppointmentId = this.db.collection(APPOINTMENTS_COLLECTION).doc().id;
5171
5116
  const eventTimeForCalendarEvents = {
5172
5117
  start: data.appointmentStartTime,
@@ -4952,7 +4952,6 @@ var BookingAdmin = class {
4952
4952
  * @returns Promise resolving to an object indicating success, and appointmentId or an error message.
4953
4953
  */
4954
4954
  async orchestrateAppointmentCreation(data, authenticatedUserId) {
4955
- var _a;
4956
4955
  console.log(
4957
4956
  `[BookingAdmin] Orchestrating appointment creation for patient ${data.patientId} by user ${authenticatedUserId}`
4958
4957
  );
@@ -5058,60 +5057,6 @@ var BookingAdmin = class {
5058
5057
  dateOfBirth: (patientSensitiveData == null ? void 0 : patientSensitiveData.dateOfBirth) || patientProfileData.dateOfBirth || admin12.firestore.Timestamp.now(),
5059
5058
  gender: (patientSensitiveData == null ? void 0 : patientSensitiveData.gender) || "other" /* OTHER */
5060
5059
  };
5061
- const procedureCategory = procedure.category;
5062
- const procedureSubCategory = procedure.subcategory;
5063
- const procedureTechnology = procedure.technology;
5064
- const procedureProduct = procedure.product;
5065
- const procedureInfo = {
5066
- id: procedure.id,
5067
- name: procedure.name,
5068
- description: procedure.description,
5069
- family: procedure.family,
5070
- categoryName: (procedureCategory == null ? void 0 : procedureCategory.name) || "",
5071
- subcategoryName: (procedureSubCategory == null ? void 0 : procedureSubCategory.name) || "",
5072
- technologyName: (procedureTechnology == null ? void 0 : procedureTechnology.name) || "",
5073
- price: procedure.price,
5074
- pricingMeasure: procedure.pricingMeasure,
5075
- currency: procedure.currency,
5076
- duration: procedure.duration,
5077
- clinicId: procedure.clinicBranchId,
5078
- clinicName: clinicData.name,
5079
- practitionerId: procedure.practitionerId,
5080
- practitionerName: `${practitionerData.basicInfo.firstName} ${practitionerData.basicInfo.lastName}`,
5081
- photo: ((_a = procedure.photos) == null ? void 0 : _a[0]) || "",
5082
- brandName: (procedureProduct == null ? void 0 : procedureProduct.brandName) || "",
5083
- productName: (procedureProduct == null ? void 0 : procedureProduct.name) || ""
5084
- };
5085
- const procedureExtendedInfo = {
5086
- id: procedure.id,
5087
- name: procedure.name,
5088
- description: procedure.description,
5089
- cost: procedure.price,
5090
- duration: procedure.duration,
5091
- procedureFamily: procedure.family,
5092
- procedureCategoryId: (procedureCategory == null ? void 0 : procedureCategory.id) || "",
5093
- procedureCategoryName: (procedureCategory == null ? void 0 : procedureCategory.name) || "",
5094
- procedureSubCategoryId: (procedureSubCategory == null ? void 0 : procedureSubCategory.id) || "",
5095
- procedureSubCategoryName: (procedureSubCategory == null ? void 0 : procedureSubCategory.name) || "",
5096
- procedureTechnologyId: (procedureTechnology == null ? void 0 : procedureTechnology.id) || "",
5097
- procedureTechnologyName: (procedureTechnology == null ? void 0 : procedureTechnology.name) || "",
5098
- procedureProductBrandId: procedureProduct.brandId || "",
5099
- procedureProductBrandName: procedureProduct.brandName || "",
5100
- procedureProductId: procedureProduct.id || "",
5101
- procedureProductName: procedureProduct.name || ""
5102
- };
5103
- let pendingUserFormsIds = [];
5104
- let linkedFormIds = [];
5105
- if (procedure.documentationTemplates && Array.isArray(procedure.documentationTemplates)) {
5106
- pendingUserFormsIds = procedure.documentationTemplates.filter(
5107
- (template) => template.isUserForm && template.isRequired
5108
- ).map(
5109
- (template) => template.templateId
5110
- );
5111
- linkedFormIds = procedure.documentationTemplates.map(
5112
- (template) => template.templateId
5113
- );
5114
- }
5115
5060
  const newAppointmentId = this.db.collection(APPOINTMENTS_COLLECTION).doc().id;
5116
5061
  const eventTimeForCalendarEvents = {
5117
5062
  start: data.appointmentStartTime,
package/dist/index.d.mts CHANGED
@@ -6504,6 +6504,7 @@ declare class FilledDocumentService extends BaseService {
6504
6504
  /**
6505
6505
  * Create a new filled document within an appointment's subcollection.
6506
6506
  * @param templateId - ID of the template to use.
6507
+ * @param templateVersion - Version of the template to use.
6507
6508
  * @param appointmentId - ID of the appointment this form belongs to.
6508
6509
  * @param procedureId - ID of the procedure associated with this form.
6509
6510
  * @param patientId - ID of the patient.
@@ -6513,7 +6514,7 @@ declare class FilledDocumentService extends BaseService {
6513
6514
  * @param initialStatus - Optional initial status for the form.
6514
6515
  * @returns The created filled document.
6515
6516
  */
6516
- createFilledDocumentForAppointment(templateId: string, appointmentId: string, procedureId: string, patientId: string, practitionerId: string, // Consider if this is always available or if a placeholder is needed
6517
+ createFilledDocumentForAppointment(templateId: string, templateVersion: number, appointmentId: string, procedureId: string, patientId: string, practitionerId: string, // Consider if this is always available or if a placeholder is needed
6517
6518
  clinicId: string, // Same consideration as practitionerId
6518
6519
  initialValues?: {
6519
6520
  [elementId: string]: any;
package/dist/index.d.ts CHANGED
@@ -6504,6 +6504,7 @@ declare class FilledDocumentService extends BaseService {
6504
6504
  /**
6505
6505
  * Create a new filled document within an appointment's subcollection.
6506
6506
  * @param templateId - ID of the template to use.
6507
+ * @param templateVersion - Version of the template to use.
6507
6508
  * @param appointmentId - ID of the appointment this form belongs to.
6508
6509
  * @param procedureId - ID of the procedure associated with this form.
6509
6510
  * @param patientId - ID of the patient.
@@ -6513,7 +6514,7 @@ declare class FilledDocumentService extends BaseService {
6513
6514
  * @param initialStatus - Optional initial status for the form.
6514
6515
  * @returns The created filled document.
6515
6516
  */
6516
- createFilledDocumentForAppointment(templateId: string, appointmentId: string, procedureId: string, patientId: string, practitionerId: string, // Consider if this is always available or if a placeholder is needed
6517
+ createFilledDocumentForAppointment(templateId: string, templateVersion: number, appointmentId: string, procedureId: string, patientId: string, practitionerId: string, // Consider if this is always available or if a placeholder is needed
6517
6518
  clinicId: string, // Same consideration as practitionerId
6518
6519
  initialValues?: {
6519
6520
  [elementId: string]: any;
package/dist/index.js CHANGED
@@ -8675,6 +8675,7 @@ var FilledDocumentService = class extends BaseService {
8675
8675
  /**
8676
8676
  * Create a new filled document within an appointment's subcollection.
8677
8677
  * @param templateId - ID of the template to use.
8678
+ * @param templateVersion - Version of the template to use.
8678
8679
  * @param appointmentId - ID of the appointment this form belongs to.
8679
8680
  * @param procedureId - ID of the procedure associated with this form.
8680
8681
  * @param patientId - ID of the patient.
@@ -8684,8 +8685,11 @@ var FilledDocumentService = class extends BaseService {
8684
8685
  * @param initialStatus - Optional initial status for the form.
8685
8686
  * @returns The created filled document.
8686
8687
  */
8687
- async createFilledDocumentForAppointment(templateId, appointmentId, procedureId, patientId, practitionerId, clinicId, initialValues = {}, initialStatus = "draft" /* DRAFT */) {
8688
- const template = await this.templateService.getTemplateById(templateId);
8688
+ async createFilledDocumentForAppointment(templateId, templateVersion, appointmentId, procedureId, patientId, practitionerId, clinicId, initialValues = {}, initialStatus = "draft" /* DRAFT */) {
8689
+ const template = await this.templateService.getTemplateById(
8690
+ templateId,
8691
+ templateVersion
8692
+ );
8689
8693
  if (!template) {
8690
8694
  throw new Error(`Template with ID ${templateId} not found`);
8691
8695
  }
package/dist/index.mjs CHANGED
@@ -8674,6 +8674,7 @@ var FilledDocumentService = class extends BaseService {
8674
8674
  /**
8675
8675
  * Create a new filled document within an appointment's subcollection.
8676
8676
  * @param templateId - ID of the template to use.
8677
+ * @param templateVersion - Version of the template to use.
8677
8678
  * @param appointmentId - ID of the appointment this form belongs to.
8678
8679
  * @param procedureId - ID of the procedure associated with this form.
8679
8680
  * @param patientId - ID of the patient.
@@ -8683,8 +8684,11 @@ var FilledDocumentService = class extends BaseService {
8683
8684
  * @param initialStatus - Optional initial status for the form.
8684
8685
  * @returns The created filled document.
8685
8686
  */
8686
- async createFilledDocumentForAppointment(templateId, appointmentId, procedureId, patientId, practitionerId, clinicId, initialValues = {}, initialStatus = "draft" /* DRAFT */) {
8687
- const template = await this.templateService.getTemplateById(templateId);
8687
+ async createFilledDocumentForAppointment(templateId, templateVersion, appointmentId, procedureId, patientId, practitionerId, clinicId, initialValues = {}, initialStatus = "draft" /* DRAFT */) {
8688
+ const template = await this.templateService.getTemplateById(
8689
+ templateId,
8690
+ templateVersion
8691
+ );
8688
8692
  if (!template) {
8689
8693
  throw new Error(`Template with ID ${templateId} not found`);
8690
8694
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.6.25",
4
+ "version": "1.6.26",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -487,69 +487,49 @@ export class BookingAdmin {
487
487
  admin.firestore.Timestamp.now(),
488
488
  gender: patientSensitiveData?.gender || Gender.OTHER,
489
489
  };
490
- const procedureCategory = procedure.category as Category;
491
- const procedureSubCategory = procedure.subcategory as Subcategory;
492
- const procedureTechnology = procedure.technology as Technology;
493
- const procedureProduct = procedure.product as Product;
494
-
495
- const procedureInfo: ProcedureSummaryInfo = {
496
- id: procedure.id,
497
- name: procedure.name,
498
- description: procedure.description,
499
- family: procedure.family,
500
- categoryName: procedureCategory?.name || "",
501
- subcategoryName: procedureSubCategory?.name || "",
502
- technologyName: procedureTechnology?.name || "",
503
- price: procedure.price,
504
- pricingMeasure: procedure.pricingMeasure,
505
- currency: procedure.currency,
506
- duration: procedure.duration,
507
- clinicId: procedure.clinicBranchId,
508
- clinicName: clinicData.name,
509
- practitionerId: procedure.practitionerId,
510
- practitionerName: `${practitionerData.basicInfo.firstName} ${practitionerData.basicInfo.lastName}`,
511
- photo: procedure.photos?.[0] || "",
512
- brandName: procedureProduct?.brandName || "",
513
- productName: procedureProduct?.name || "",
514
- };
515
- const procedureExtendedInfo: ProcedureExtendedInfo = {
516
- id: procedure.id,
517
- name: procedure.name,
518
- description: procedure.description,
519
- cost: procedure.price,
520
- duration: procedure.duration,
521
- procedureFamily: procedure.family,
522
- procedureCategoryId: procedureCategory?.id || "",
523
- procedureCategoryName: procedureCategory?.name || "",
524
- procedureSubCategoryId: procedureSubCategory?.id || "",
525
- procedureSubCategoryName: procedureSubCategory?.name || "",
526
- procedureTechnologyId: procedureTechnology?.id || "",
527
- procedureTechnologyName: procedureTechnology?.name || "",
528
- procedureProductBrandId: procedureProduct.brandId || "",
529
- procedureProductBrandName: procedureProduct.brandName || "",
530
- procedureProductId: procedureProduct.id || "",
531
- procedureProductName: procedureProduct.name || "",
532
- };
533
-
534
- // --- 6. Determine pendingUserFormsIds and linkedFormIds ---
535
- let pendingUserFormsIds: string[] = [];
536
- let linkedFormIds: string[] = [];
537
- if (
538
- procedure.documentationTemplates &&
539
- Array.isArray(procedure.documentationTemplates)
540
- ) {
541
- pendingUserFormsIds = procedure.documentationTemplates
542
- .filter(
543
- (template: TechnologyDocumentationTemplate) =>
544
- template.isUserForm && template.isRequired
545
- )
546
- .map(
547
- (template: TechnologyDocumentationTemplate) => template.templateId
548
- );
549
- linkedFormIds = procedure.documentationTemplates.map(
550
- (template: TechnologyDocumentationTemplate) => template.templateId
551
- );
552
- }
490
+ // const procedureCategory = procedure.category as Category;
491
+ // const procedureSubCategory = procedure.subcategory as Subcategory;
492
+ // const procedureTechnology = procedure.technology as Technology;
493
+ // const procedureProduct = procedure.product as Product;
494
+
495
+ // const procedureExtendedInfo: ProcedureExtendedInfo = {
496
+ // id: procedure.id,
497
+ // name: procedure.name,
498
+ // description: procedure.description,
499
+ // cost: procedure.price,
500
+ // duration: procedure.duration,
501
+ // procedureFamily: procedure.family,
502
+ // procedureCategoryId: procedureCategory?.id || "",
503
+ // procedureCategoryName: procedureCategory?.name || "",
504
+ // procedureSubCategoryId: procedureSubCategory?.id || "",
505
+ // procedureSubCategoryName: procedureSubCategory?.name || "",
506
+ // procedureTechnologyId: procedureTechnology?.id || "",
507
+ // procedureTechnologyName: procedureTechnology?.name || "",
508
+ // procedureProductBrandId: procedureProduct.brandId || "",
509
+ // procedureProductBrandName: procedureProduct.brandName || "",
510
+ // procedureProductId: procedureProduct.id || "",
511
+ // procedureProductName: procedureProduct.name || "",
512
+ // };
513
+
514
+ // // --- 6. Determine pendingUserFormsIds and linkedFormIds ---
515
+ // let pendingUserFormsIds: string[] = [];
516
+ // let linkedFormIds: string[] = [];
517
+ // if (
518
+ // procedure.documentationTemplates &&
519
+ // Array.isArray(procedure.documentationTemplates)
520
+ // ) {
521
+ // pendingUserFormsIds = procedure.documentationTemplates
522
+ // .filter(
523
+ // (template: TechnologyDocumentationTemplate) =>
524
+ // template.isUserForm && template.isRequired
525
+ // )
526
+ // .map(
527
+ // (template: TechnologyDocumentationTemplate) => template.templateId
528
+ // );
529
+ // linkedFormIds = procedure.documentationTemplates.map(
530
+ // (template: TechnologyDocumentationTemplate) => template.templateId
531
+ // );
532
+ // }
553
533
 
554
534
  // --- 7. Construct New Appointment Object ---
555
535
  const newAppointmentId = this.db
@@ -48,6 +48,7 @@ export class FilledDocumentService extends BaseService {
48
48
  /**
49
49
  * Create a new filled document within an appointment's subcollection.
50
50
  * @param templateId - ID of the template to use.
51
+ * @param templateVersion - Version of the template to use.
51
52
  * @param appointmentId - ID of the appointment this form belongs to.
52
53
  * @param procedureId - ID of the procedure associated with this form.
53
54
  * @param patientId - ID of the patient.
@@ -59,6 +60,7 @@ export class FilledDocumentService extends BaseService {
59
60
  */
60
61
  async createFilledDocumentForAppointment(
61
62
  templateId: string,
63
+ templateVersion: number,
62
64
  appointmentId: string,
63
65
  procedureId: string,
64
66
  patientId: string,
@@ -67,7 +69,10 @@ export class FilledDocumentService extends BaseService {
67
69
  initialValues: { [elementId: string]: any } = {},
68
70
  initialStatus: FilledDocumentStatus = FilledDocumentStatus.DRAFT
69
71
  ): Promise<FilledDocument> {
70
- const template = await this.templateService.getTemplateById(templateId);
72
+ const template = await this.templateService.getTemplateById(
73
+ templateId,
74
+ templateVersion
75
+ );
71
76
  if (!template) {
72
77
  throw new Error(`Template with ID ${templateId} not found`);
73
78
  }