@blackcode_sa/metaestetics-api 1.12.0 → 1.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/index.d.mts +36 -3
- package/dist/admin/index.d.ts +36 -3
- package/dist/backoffice/index.d.mts +33 -1
- package/dist/backoffice/index.d.ts +33 -1
- package/dist/index.d.mts +60 -6
- package/dist/index.d.ts +60 -6
- package/dist/index.js +394 -293
- package/dist/index.mjs +394 -293
- package/package.json +1 -1
- package/src/backoffice/expo-safe/index.ts +1 -0
- package/src/backoffice/types/index.ts +1 -0
- package/src/backoffice/types/procedure-product.types.ts +38 -0
- package/src/services/practitioner/practitioner.service.ts +201 -83
- package/src/services/procedure/README.md +76 -1
- package/src/services/procedure/procedure.service.ts +346 -442
- package/src/types/procedure/index.ts +19 -3
- package/src/validations/procedure-product.schema.ts +41 -0
- package/src/validations/procedure.schema.ts +59 -8
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
Currency,
|
|
21
21
|
} from "../../backoffice/types/static/pricing.types";
|
|
22
22
|
import { MediaResource } from "../../services/media/media.service";
|
|
23
|
+
import type { ProcedureProduct } from "../../backoffice/types/procedure-product.types";
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Procedure represents a specific medical procedure that can be performed by a practitioner in a clinic
|
|
@@ -44,15 +45,16 @@ export interface Procedure {
|
|
|
44
45
|
subcategory: Subcategory;
|
|
45
46
|
/** Technology used in this procedure */
|
|
46
47
|
technology: Technology;
|
|
47
|
-
/**
|
|
48
|
+
/** Default product used in this procedure */
|
|
48
49
|
product: Product;
|
|
49
|
-
/**
|
|
50
|
+
/** Default price of the procedure */
|
|
50
51
|
price: number;
|
|
51
52
|
/** Currency for the price */
|
|
52
53
|
currency: Currency;
|
|
53
|
-
/** How the price is measured (per ml, per zone, etc.) */
|
|
54
|
+
/** How the price is measured (per ml, per zone, etc.) - for default product*/
|
|
54
55
|
pricingMeasure: PricingMeasure;
|
|
55
56
|
/** Duration of the procedure in minutes */
|
|
57
|
+
productsMetadata: ProcedureProduct[];
|
|
56
58
|
duration: number;
|
|
57
59
|
/** Blocking conditions that prevent this procedure */
|
|
58
60
|
blockingConditions: BlockingCondition[];
|
|
@@ -104,6 +106,13 @@ export interface CreateProcedureData {
|
|
|
104
106
|
technologyId: string;
|
|
105
107
|
productId: string;
|
|
106
108
|
price: number;
|
|
109
|
+
productsMetadata: {
|
|
110
|
+
productId: string;
|
|
111
|
+
price: number;
|
|
112
|
+
currency: Currency;
|
|
113
|
+
pricingMeasure: PricingMeasure;
|
|
114
|
+
isDefault?: boolean;
|
|
115
|
+
}[];
|
|
107
116
|
currency: Currency;
|
|
108
117
|
pricingMeasure: PricingMeasure;
|
|
109
118
|
duration: number;
|
|
@@ -123,6 +132,13 @@ export interface UpdateProcedureData {
|
|
|
123
132
|
price?: number;
|
|
124
133
|
currency?: Currency;
|
|
125
134
|
pricingMeasure?: PricingMeasure;
|
|
135
|
+
productsMetadata?: {
|
|
136
|
+
productId: string;
|
|
137
|
+
price: number;
|
|
138
|
+
currency: Currency;
|
|
139
|
+
pricingMeasure: PricingMeasure;
|
|
140
|
+
isDefault?: boolean;
|
|
141
|
+
}[];
|
|
126
142
|
duration?: number;
|
|
127
143
|
isActive?: boolean;
|
|
128
144
|
practitionerId?: string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
Currency,
|
|
4
|
+
PricingMeasure,
|
|
5
|
+
} from "../backoffice/types/static/pricing.types";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Schema for validating procedure product data.
|
|
9
|
+
* This is used when creating or updating a procedure to validate the products associated with it.
|
|
10
|
+
*/
|
|
11
|
+
export const procedureProductDataSchema = z.object({
|
|
12
|
+
/**
|
|
13
|
+
* The ID of the product. Must be a non-empty string.
|
|
14
|
+
* @validation
|
|
15
|
+
*/
|
|
16
|
+
productId: z.string().min(1, "Product ID is required"),
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The price of the product. Must be a non-negative number.
|
|
20
|
+
* @validation
|
|
21
|
+
*/
|
|
22
|
+
price: z.number().min(0, "Price must be a non-negative number"),
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The currency for the price. Must be one of the values from the Currency enum.
|
|
26
|
+
* @validation
|
|
27
|
+
*/
|
|
28
|
+
currency: z.nativeEnum(Currency),
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The pricing measure for the product. Must be one of the values from the PricingMeasure enum.
|
|
32
|
+
* @validation
|
|
33
|
+
*/
|
|
34
|
+
pricingMeasure: z.nativeEnum(PricingMeasure),
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Whether this is the default product for the procedure.
|
|
38
|
+
* @validation
|
|
39
|
+
*/
|
|
40
|
+
isDefault: z.boolean().optional(),
|
|
41
|
+
});
|
|
@@ -1,9 +1,45 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { ProcedureFamily } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ProcedureFamily } from "../backoffice/types/static/procedure-family.types";
|
|
3
|
+
import {
|
|
4
|
+
Currency,
|
|
5
|
+
PricingMeasure,
|
|
6
|
+
} from "../backoffice/types/static/pricing.types";
|
|
7
|
+
import { clinicInfoSchema, doctorInfoSchema } from "./shared.schema";
|
|
8
|
+
import { procedureReviewInfoSchema } from "./reviews.schema";
|
|
9
|
+
import { mediaResourceSchema } from "./media.schema";
|
|
10
|
+
import { procedureProductDataSchema } from "./procedure-product.schema";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Schema for validating stored procedure product data (with full product objects).
|
|
14
|
+
* This is used when validating complete procedure documents from Firestore.
|
|
15
|
+
*/
|
|
16
|
+
export const storedProcedureProductSchema = z.object({
|
|
17
|
+
/**
|
|
18
|
+
* The full product object used in the procedure.
|
|
19
|
+
*/
|
|
20
|
+
product: z.any(), // We'll validate the full product object separately
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The price of the procedure when using this specific product.
|
|
24
|
+
*/
|
|
25
|
+
price: z.number().min(0, "Price must be a non-negative number"),
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The currency for the price of this product.
|
|
29
|
+
*/
|
|
30
|
+
currency: z.nativeEnum(Currency),
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* How the price is measured (e.g., per ml, per zone).
|
|
34
|
+
*/
|
|
35
|
+
pricingMeasure: z.nativeEnum(PricingMeasure),
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Whether this is the default product for the procedure.
|
|
39
|
+
*/
|
|
40
|
+
isDefault: z.boolean().optional(),
|
|
41
|
+
});
|
|
42
|
+
|
|
7
43
|
/**
|
|
8
44
|
* Schema for creating a new procedure
|
|
9
45
|
*/
|
|
@@ -20,6 +56,7 @@ export const createProcedureSchema = z.object({
|
|
|
20
56
|
price: z.number().min(0),
|
|
21
57
|
currency: z.nativeEnum(Currency),
|
|
22
58
|
pricingMeasure: z.nativeEnum(PricingMeasure),
|
|
59
|
+
productsMetadata: z.array(procedureProductDataSchema).min(1),
|
|
23
60
|
duration: z.number().min(1).max(480), // Max 8 hours
|
|
24
61
|
practitionerId: z.string().min(1),
|
|
25
62
|
clinicBranchId: z.string().min(1),
|
|
@@ -36,6 +73,7 @@ export const updateProcedureSchema = z.object({
|
|
|
36
73
|
price: z.number().min(0).optional(),
|
|
37
74
|
currency: z.nativeEnum(Currency).optional(),
|
|
38
75
|
pricingMeasure: z.nativeEnum(PricingMeasure).optional(),
|
|
76
|
+
productsMetadata: z.array(procedureProductDataSchema).min(1).optional(),
|
|
39
77
|
duration: z.number().min(0).optional(),
|
|
40
78
|
isActive: z.boolean().optional(),
|
|
41
79
|
practitionerId: z.string().optional(),
|
|
@@ -48,18 +86,31 @@ export const updateProcedureSchema = z.object({
|
|
|
48
86
|
});
|
|
49
87
|
|
|
50
88
|
/**
|
|
51
|
-
* Schema for validating a complete procedure object
|
|
89
|
+
* Schema for validating a complete procedure object (as stored in Firestore)
|
|
52
90
|
*/
|
|
53
|
-
export const procedureSchema =
|
|
91
|
+
export const procedureSchema = z.object({
|
|
54
92
|
id: z.string().min(1),
|
|
93
|
+
name: z.string().min(1).max(200),
|
|
55
94
|
nameLower: z.string().min(1).max(200),
|
|
95
|
+
description: z.string().min(1).max(2000),
|
|
96
|
+
family: z.nativeEnum(ProcedureFamily),
|
|
56
97
|
category: z.any(), // We'll validate the full category object separately
|
|
57
98
|
subcategory: z.any(), // We'll validate the full subcategory object separately
|
|
58
99
|
technology: z.any(), // We'll validate the full technology object separately
|
|
59
100
|
product: z.any(), // We'll validate the full product object separately
|
|
101
|
+
productsMetadata: z.array(storedProcedureProductSchema).min(1), // Use stored format schema
|
|
102
|
+
price: z.number().min(0),
|
|
103
|
+
currency: z.nativeEnum(Currency),
|
|
104
|
+
pricingMeasure: z.nativeEnum(PricingMeasure),
|
|
105
|
+
duration: z.number().min(1).max(480),
|
|
106
|
+
practitionerId: z.string().min(1),
|
|
107
|
+
clinicBranchId: z.string().min(1),
|
|
108
|
+
photos: z.array(z.string()).optional(), // Stored as URL strings
|
|
60
109
|
blockingConditions: z.array(z.any()), // We'll validate blocking conditions separately
|
|
61
110
|
contraindications: z.array(z.any()), // We'll validate contraindications separately
|
|
111
|
+
contraindicationIds: z.array(z.string()), // Array of IDs for efficient querying
|
|
62
112
|
treatmentBenefits: z.array(z.any()), // We'll validate treatment benefits separately
|
|
113
|
+
treatmentBenefitIds: z.array(z.string()), // Array of IDs for efficient querying
|
|
63
114
|
preRequirements: z.array(z.any()), // We'll validate requirements separately
|
|
64
115
|
postRequirements: z.array(z.any()), // We'll validate requirements separately
|
|
65
116
|
certificationRequirement: z.any(), // We'll validate certification requirement separately
|