@blackcode_sa/metaestetics-api 1.7.30 → 1.7.31

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 CHANGED
@@ -6058,6 +6058,12 @@ declare class ProcedureService extends BaseService {
6058
6058
  * @returns List of procedures
6059
6059
  */
6060
6060
  getProceduresByPractitioner(practitionerId: string): Promise<Procedure[]>;
6061
+ /**
6062
+ * Gets all inactive procedures for a practitioner
6063
+ * @param practitionerId - The ID of the practitioner
6064
+ * @returns List of inactive procedures
6065
+ */
6066
+ getInactiveProceduresByPractitioner(practitionerId: string): Promise<Procedure[]>;
6061
6067
  /**
6062
6068
  * Updates a procedure
6063
6069
  * @param id - The ID of the procedure to update
@@ -6345,6 +6351,11 @@ declare class PractitionerService extends BaseService {
6345
6351
  * @returns The created consultation procedure
6346
6352
  */
6347
6353
  EnableFreeConsultation(practitionerId: string, clinicId: string): Promise<void>;
6354
+ /**
6355
+ * Ensures that the free consultation infrastructure exists by calling the Cloud Function
6356
+ * @returns Promise<boolean> - True if infrastructure exists or was created successfully
6357
+ */
6358
+ ensureFreeConsultationInfrastructure(): Promise<boolean>;
6348
6359
  /**
6349
6360
  * Disables free consultation for a practitioner in a specific clinic
6350
6361
  * Finds and deactivates the existing free consultation procedure
package/dist/index.d.ts CHANGED
@@ -6058,6 +6058,12 @@ declare class ProcedureService extends BaseService {
6058
6058
  * @returns List of procedures
6059
6059
  */
6060
6060
  getProceduresByPractitioner(practitionerId: string): Promise<Procedure[]>;
6061
+ /**
6062
+ * Gets all inactive procedures for a practitioner
6063
+ * @param practitionerId - The ID of the practitioner
6064
+ * @returns List of inactive procedures
6065
+ */
6066
+ getInactiveProceduresByPractitioner(practitionerId: string): Promise<Procedure[]>;
6061
6067
  /**
6062
6068
  * Updates a procedure
6063
6069
  * @param id - The ID of the procedure to update
@@ -6345,6 +6351,11 @@ declare class PractitionerService extends BaseService {
6345
6351
  * @returns The created consultation procedure
6346
6352
  */
6347
6353
  EnableFreeConsultation(practitionerId: string, clinicId: string): Promise<void>;
6354
+ /**
6355
+ * Ensures that the free consultation infrastructure exists by calling the Cloud Function
6356
+ * @returns Promise<boolean> - True if infrastructure exists or was created successfully
6357
+ */
6358
+ ensureFreeConsultationInfrastructure(): Promise<boolean>;
6348
6359
  /**
6349
6360
  * Disables free consultation for a practitioner in a specific clinic
6350
6361
  * Finds and deactivates the existing free consultation procedure
package/dist/index.js CHANGED
@@ -5543,6 +5543,7 @@ var PractitionerService = class extends BaseService {
5543
5543
  */
5544
5544
  async EnableFreeConsultation(practitionerId, clinicId) {
5545
5545
  try {
5546
+ await this.ensureFreeConsultationInfrastructure();
5546
5547
  const practitioner = await this.getPractitioner(practitionerId);
5547
5548
  if (!practitioner) {
5548
5549
  throw new Error(`Practitioner ${practitionerId} not found`);
@@ -5559,17 +5560,32 @@ var PractitionerService = class extends BaseService {
5559
5560
  `Practitioner ${practitionerId} is not associated with clinic ${clinicId}`
5560
5561
  );
5561
5562
  }
5562
- const existingProcedures = await this.getProcedureService().getProceduresByPractitioner(
5563
- practitionerId
5564
- );
5565
- const existingConsultation = existingProcedures.find(
5566
- (procedure) => procedure.name === "Free Consultation" && procedure.clinicBranchId === clinicId && procedure.isActive
5563
+ const [activeProcedures, inactiveProcedures] = await Promise.all([
5564
+ this.getProcedureService().getProceduresByPractitioner(practitionerId),
5565
+ this.getProcedureService().getInactiveProceduresByPractitioner(
5566
+ practitionerId
5567
+ )
5568
+ ]);
5569
+ const allProcedures = [...activeProcedures, ...inactiveProcedures];
5570
+ const existingConsultation = allProcedures.find(
5571
+ (procedure) => procedure.technology.id === "free-consultation-tech" && procedure.clinicBranchId === clinicId
5567
5572
  );
5568
5573
  if (existingConsultation) {
5569
- console.log(
5570
- `Free consultation already exists for practitioner ${practitionerId} in clinic ${clinicId}`
5571
- );
5572
- return;
5574
+ if (existingConsultation.isActive) {
5575
+ console.log(
5576
+ `Free consultation already active for practitioner ${practitionerId} in clinic ${clinicId}`
5577
+ );
5578
+ return;
5579
+ } else {
5580
+ await this.getProcedureService().updateProcedure(
5581
+ existingConsultation.id,
5582
+ { isActive: true }
5583
+ );
5584
+ console.log(
5585
+ `Reactivated existing free consultation for practitioner ${practitionerId} in clinic ${clinicId}`
5586
+ );
5587
+ return;
5588
+ }
5573
5589
  }
5574
5590
  const consultationData = {
5575
5591
  name: "Free Consultation",
@@ -5602,6 +5618,74 @@ var PractitionerService = class extends BaseService {
5602
5618
  throw error;
5603
5619
  }
5604
5620
  }
5621
+ /**
5622
+ * Ensures that the free consultation infrastructure exists by calling the Cloud Function
5623
+ * @returns Promise<boolean> - True if infrastructure exists or was created successfully
5624
+ */
5625
+ async ensureFreeConsultationInfrastructure() {
5626
+ try {
5627
+ console.log(
5628
+ "[PRACTITIONER_SERVICE] Ensuring free consultation infrastructure via HTTP"
5629
+ );
5630
+ const currentUser = this.auth.currentUser;
5631
+ if (!currentUser) {
5632
+ throw new Error(
5633
+ "User must be authenticated to ensure free consultation infrastructure"
5634
+ );
5635
+ }
5636
+ const functionUrl = `https://europe-west6-metaestetics.cloudfunctions.net/bookingApi/ensureFreeConsultationInfrastructure`;
5637
+ const idToken = await currentUser.getIdToken();
5638
+ console.log(
5639
+ `[PRACTITIONER_SERVICE] Making fetch request to ${functionUrl}`
5640
+ );
5641
+ const response = await fetch(functionUrl, {
5642
+ method: "POST",
5643
+ mode: "cors",
5644
+ cache: "no-cache",
5645
+ credentials: "omit",
5646
+ headers: {
5647
+ "Content-Type": "application/json",
5648
+ Authorization: `Bearer ${idToken}`
5649
+ },
5650
+ redirect: "follow",
5651
+ referrerPolicy: "no-referrer",
5652
+ body: JSON.stringify({})
5653
+ // Empty body as no parameters needed
5654
+ });
5655
+ console.log(
5656
+ `[PRACTITIONER_SERVICE] Received response ${response.status}: ${response.statusText}`
5657
+ );
5658
+ if (!response.ok) {
5659
+ const errorText = await response.text();
5660
+ console.error(
5661
+ `[PRACTITIONER_SERVICE] Error response details: ${errorText}`
5662
+ );
5663
+ throw new Error(
5664
+ `Failed to ensure free consultation infrastructure: ${response.status} ${response.statusText} - ${errorText}`
5665
+ );
5666
+ }
5667
+ const result = await response.json();
5668
+ console.log(
5669
+ `[PRACTITIONER_SERVICE] Infrastructure check response:`,
5670
+ result
5671
+ );
5672
+ if (!result.success) {
5673
+ throw new Error(
5674
+ result.error || "Failed to ensure free consultation infrastructure"
5675
+ );
5676
+ }
5677
+ console.log(
5678
+ `[PRACTITIONER_SERVICE] Free consultation infrastructure ensured successfully`
5679
+ );
5680
+ return result.infrastructureExists;
5681
+ } catch (error) {
5682
+ console.error(
5683
+ "[PRACTITIONER_SERVICE] Error ensuring free consultation infrastructure:",
5684
+ error
5685
+ );
5686
+ throw error;
5687
+ }
5688
+ }
5605
5689
  /**
5606
5690
  * Disables free consultation for a practitioner in a specific clinic
5607
5691
  * Finds and deactivates the existing free consultation procedure
@@ -5627,7 +5711,7 @@ var PractitionerService = class extends BaseService {
5627
5711
  practitionerId
5628
5712
  );
5629
5713
  const freeConsultation = existingProcedures.find(
5630
- (procedure) => procedure.name === "Free Consultation" && procedure.clinicBranchId === clinicId && procedure.isActive
5714
+ (procedure) => procedure.technology.id === "free-consultation-tech" && procedure.clinicBranchId === clinicId && procedure.isActive
5631
5715
  );
5632
5716
  if (!freeConsultation) {
5633
5717
  console.log(
@@ -9001,6 +9085,20 @@ var ProcedureService = class extends BaseService {
9001
9085
  const snapshot = await (0, import_firestore27.getDocs)(q);
9002
9086
  return snapshot.docs.map((doc36) => doc36.data());
9003
9087
  }
9088
+ /**
9089
+ * Gets all inactive procedures for a practitioner
9090
+ * @param practitionerId - The ID of the practitioner
9091
+ * @returns List of inactive procedures
9092
+ */
9093
+ async getInactiveProceduresByPractitioner(practitionerId) {
9094
+ const q = (0, import_firestore27.query)(
9095
+ (0, import_firestore27.collection)(this.db, PROCEDURES_COLLECTION),
9096
+ (0, import_firestore27.where)("practitionerId", "==", practitionerId),
9097
+ (0, import_firestore27.where)("isActive", "==", false)
9098
+ );
9099
+ const snapshot = await (0, import_firestore27.getDocs)(q);
9100
+ return snapshot.docs.map((doc36) => doc36.data());
9101
+ }
9004
9102
  /**
9005
9103
  * Updates a procedure
9006
9104
  * @param id - The ID of the procedure to update
package/dist/index.mjs CHANGED
@@ -5447,6 +5447,7 @@ var PractitionerService = class extends BaseService {
5447
5447
  */
5448
5448
  async EnableFreeConsultation(practitionerId, clinicId) {
5449
5449
  try {
5450
+ await this.ensureFreeConsultationInfrastructure();
5450
5451
  const practitioner = await this.getPractitioner(practitionerId);
5451
5452
  if (!practitioner) {
5452
5453
  throw new Error(`Practitioner ${practitionerId} not found`);
@@ -5463,17 +5464,32 @@ var PractitionerService = class extends BaseService {
5463
5464
  `Practitioner ${practitionerId} is not associated with clinic ${clinicId}`
5464
5465
  );
5465
5466
  }
5466
- const existingProcedures = await this.getProcedureService().getProceduresByPractitioner(
5467
- practitionerId
5468
- );
5469
- const existingConsultation = existingProcedures.find(
5470
- (procedure) => procedure.name === "Free Consultation" && procedure.clinicBranchId === clinicId && procedure.isActive
5467
+ const [activeProcedures, inactiveProcedures] = await Promise.all([
5468
+ this.getProcedureService().getProceduresByPractitioner(practitionerId),
5469
+ this.getProcedureService().getInactiveProceduresByPractitioner(
5470
+ practitionerId
5471
+ )
5472
+ ]);
5473
+ const allProcedures = [...activeProcedures, ...inactiveProcedures];
5474
+ const existingConsultation = allProcedures.find(
5475
+ (procedure) => procedure.technology.id === "free-consultation-tech" && procedure.clinicBranchId === clinicId
5471
5476
  );
5472
5477
  if (existingConsultation) {
5473
- console.log(
5474
- `Free consultation already exists for practitioner ${practitionerId} in clinic ${clinicId}`
5475
- );
5476
- return;
5478
+ if (existingConsultation.isActive) {
5479
+ console.log(
5480
+ `Free consultation already active for practitioner ${practitionerId} in clinic ${clinicId}`
5481
+ );
5482
+ return;
5483
+ } else {
5484
+ await this.getProcedureService().updateProcedure(
5485
+ existingConsultation.id,
5486
+ { isActive: true }
5487
+ );
5488
+ console.log(
5489
+ `Reactivated existing free consultation for practitioner ${practitionerId} in clinic ${clinicId}`
5490
+ );
5491
+ return;
5492
+ }
5477
5493
  }
5478
5494
  const consultationData = {
5479
5495
  name: "Free Consultation",
@@ -5506,6 +5522,74 @@ var PractitionerService = class extends BaseService {
5506
5522
  throw error;
5507
5523
  }
5508
5524
  }
5525
+ /**
5526
+ * Ensures that the free consultation infrastructure exists by calling the Cloud Function
5527
+ * @returns Promise<boolean> - True if infrastructure exists or was created successfully
5528
+ */
5529
+ async ensureFreeConsultationInfrastructure() {
5530
+ try {
5531
+ console.log(
5532
+ "[PRACTITIONER_SERVICE] Ensuring free consultation infrastructure via HTTP"
5533
+ );
5534
+ const currentUser = this.auth.currentUser;
5535
+ if (!currentUser) {
5536
+ throw new Error(
5537
+ "User must be authenticated to ensure free consultation infrastructure"
5538
+ );
5539
+ }
5540
+ const functionUrl = `https://europe-west6-metaestetics.cloudfunctions.net/bookingApi/ensureFreeConsultationInfrastructure`;
5541
+ const idToken = await currentUser.getIdToken();
5542
+ console.log(
5543
+ `[PRACTITIONER_SERVICE] Making fetch request to ${functionUrl}`
5544
+ );
5545
+ const response = await fetch(functionUrl, {
5546
+ method: "POST",
5547
+ mode: "cors",
5548
+ cache: "no-cache",
5549
+ credentials: "omit",
5550
+ headers: {
5551
+ "Content-Type": "application/json",
5552
+ Authorization: `Bearer ${idToken}`
5553
+ },
5554
+ redirect: "follow",
5555
+ referrerPolicy: "no-referrer",
5556
+ body: JSON.stringify({})
5557
+ // Empty body as no parameters needed
5558
+ });
5559
+ console.log(
5560
+ `[PRACTITIONER_SERVICE] Received response ${response.status}: ${response.statusText}`
5561
+ );
5562
+ if (!response.ok) {
5563
+ const errorText = await response.text();
5564
+ console.error(
5565
+ `[PRACTITIONER_SERVICE] Error response details: ${errorText}`
5566
+ );
5567
+ throw new Error(
5568
+ `Failed to ensure free consultation infrastructure: ${response.status} ${response.statusText} - ${errorText}`
5569
+ );
5570
+ }
5571
+ const result = await response.json();
5572
+ console.log(
5573
+ `[PRACTITIONER_SERVICE] Infrastructure check response:`,
5574
+ result
5575
+ );
5576
+ if (!result.success) {
5577
+ throw new Error(
5578
+ result.error || "Failed to ensure free consultation infrastructure"
5579
+ );
5580
+ }
5581
+ console.log(
5582
+ `[PRACTITIONER_SERVICE] Free consultation infrastructure ensured successfully`
5583
+ );
5584
+ return result.infrastructureExists;
5585
+ } catch (error) {
5586
+ console.error(
5587
+ "[PRACTITIONER_SERVICE] Error ensuring free consultation infrastructure:",
5588
+ error
5589
+ );
5590
+ throw error;
5591
+ }
5592
+ }
5509
5593
  /**
5510
5594
  * Disables free consultation for a practitioner in a specific clinic
5511
5595
  * Finds and deactivates the existing free consultation procedure
@@ -5531,7 +5615,7 @@ var PractitionerService = class extends BaseService {
5531
5615
  practitionerId
5532
5616
  );
5533
5617
  const freeConsultation = existingProcedures.find(
5534
- (procedure) => procedure.name === "Free Consultation" && procedure.clinicBranchId === clinicId && procedure.isActive
5618
+ (procedure) => procedure.technology.id === "free-consultation-tech" && procedure.clinicBranchId === clinicId && procedure.isActive
5535
5619
  );
5536
5620
  if (!freeConsultation) {
5537
5621
  console.log(
@@ -8986,6 +9070,20 @@ var ProcedureService = class extends BaseService {
8986
9070
  const snapshot = await getDocs16(q);
8987
9071
  return snapshot.docs.map((doc36) => doc36.data());
8988
9072
  }
9073
+ /**
9074
+ * Gets all inactive procedures for a practitioner
9075
+ * @param practitionerId - The ID of the practitioner
9076
+ * @returns List of inactive procedures
9077
+ */
9078
+ async getInactiveProceduresByPractitioner(practitionerId) {
9079
+ const q = query16(
9080
+ collection16(this.db, PROCEDURES_COLLECTION),
9081
+ where16("practitionerId", "==", practitionerId),
9082
+ where16("isActive", "==", false)
9083
+ );
9084
+ const snapshot = await getDocs16(q);
9085
+ return snapshot.docs.map((doc36) => doc36.data());
9086
+ }
8989
9087
  /**
8990
9088
  * Updates a procedure
8991
9089
  * @param id - The ID of the procedure to update
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.7.30",
4
+ "version": "1.7.31",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -1217,6 +1217,9 @@ export class PractitionerService extends BaseService {
1217
1217
  clinicId: string
1218
1218
  ): Promise<void> {
1219
1219
  try {
1220
+ // First, ensure the free consultation infrastructure exists
1221
+ await this.ensureFreeConsultationInfrastructure();
1222
+
1220
1223
  // Validate that practitioner exists and is active
1221
1224
  const practitioner = await this.getPractitioner(practitionerId);
1222
1225
  if (!practitioner) {
@@ -1243,23 +1246,41 @@ export class PractitionerService extends BaseService {
1243
1246
  );
1244
1247
  }
1245
1248
 
1246
- // Check if free consultation already exists for this practitioner in this clinic
1247
- const existingProcedures =
1248
- await this.getProcedureService().getProceduresByPractitioner(
1249
+ // Get all procedures for this practitioner (including inactive ones)
1250
+ const [activeProcedures, inactiveProcedures] = await Promise.all([
1251
+ this.getProcedureService().getProceduresByPractitioner(practitionerId),
1252
+ this.getProcedureService().getInactiveProceduresByPractitioner(
1249
1253
  practitionerId
1250
- );
1251
- const existingConsultation = existingProcedures.find(
1254
+ ),
1255
+ ]);
1256
+
1257
+ // Combine active and inactive procedures
1258
+ const allProcedures = [...activeProcedures, ...inactiveProcedures];
1259
+
1260
+ // Check if free consultation already exists (active or inactive)
1261
+ const existingConsultation = allProcedures.find(
1252
1262
  (procedure) =>
1253
- procedure.name === "Free Consultation" &&
1254
- procedure.clinicBranchId === clinicId &&
1255
- procedure.isActive
1263
+ procedure.technology.id === "free-consultation-tech" &&
1264
+ procedure.clinicBranchId === clinicId
1256
1265
  );
1257
1266
 
1258
1267
  if (existingConsultation) {
1259
- console.log(
1260
- `Free consultation already exists for practitioner ${practitionerId} in clinic ${clinicId}`
1261
- );
1262
- return;
1268
+ if (existingConsultation.isActive) {
1269
+ console.log(
1270
+ `Free consultation already active for practitioner ${practitionerId} in clinic ${clinicId}`
1271
+ );
1272
+ return;
1273
+ } else {
1274
+ // Reactivate the existing disabled consultation
1275
+ await this.getProcedureService().updateProcedure(
1276
+ existingConsultation.id,
1277
+ { isActive: true }
1278
+ );
1279
+ console.log(
1280
+ `Reactivated existing free consultation for practitioner ${practitionerId} in clinic ${clinicId}`
1281
+ );
1282
+ return;
1283
+ }
1263
1284
  }
1264
1285
 
1265
1286
  // Create procedure data for free consultation (without productId)
@@ -1297,6 +1318,91 @@ export class PractitionerService extends BaseService {
1297
1318
  }
1298
1319
  }
1299
1320
 
1321
+ /**
1322
+ * Ensures that the free consultation infrastructure exists by calling the Cloud Function
1323
+ * @returns Promise<boolean> - True if infrastructure exists or was created successfully
1324
+ */
1325
+ async ensureFreeConsultationInfrastructure(): Promise<boolean> {
1326
+ try {
1327
+ console.log(
1328
+ "[PRACTITIONER_SERVICE] Ensuring free consultation infrastructure via HTTP"
1329
+ );
1330
+
1331
+ // Check if user is authenticated
1332
+ const currentUser = this.auth.currentUser;
1333
+ if (!currentUser) {
1334
+ throw new Error(
1335
+ "User must be authenticated to ensure free consultation infrastructure"
1336
+ );
1337
+ }
1338
+
1339
+ // Construct the function URL for the Express app endpoint
1340
+ const functionUrl = `https://europe-west6-metaestetics.cloudfunctions.net/bookingApi/ensureFreeConsultationInfrastructure`;
1341
+
1342
+ // Get the authenticated user's ID token
1343
+ const idToken = await currentUser.getIdToken();
1344
+
1345
+ console.log(
1346
+ `[PRACTITIONER_SERVICE] Making fetch request to ${functionUrl}`
1347
+ );
1348
+
1349
+ // Make the HTTP request
1350
+ const response = await fetch(functionUrl, {
1351
+ method: "POST",
1352
+ mode: "cors",
1353
+ cache: "no-cache",
1354
+ credentials: "omit",
1355
+ headers: {
1356
+ "Content-Type": "application/json",
1357
+ Authorization: `Bearer ${idToken}`,
1358
+ },
1359
+ redirect: "follow",
1360
+ referrerPolicy: "no-referrer",
1361
+ body: JSON.stringify({}), // Empty body as no parameters needed
1362
+ });
1363
+
1364
+ console.log(
1365
+ `[PRACTITIONER_SERVICE] Received response ${response.status}: ${response.statusText}`
1366
+ );
1367
+
1368
+ // Check if the request was successful
1369
+ if (!response.ok) {
1370
+ const errorText = await response.text();
1371
+ console.error(
1372
+ `[PRACTITIONER_SERVICE] Error response details: ${errorText}`
1373
+ );
1374
+ throw new Error(
1375
+ `Failed to ensure free consultation infrastructure: ${response.status} ${response.statusText} - ${errorText}`
1376
+ );
1377
+ }
1378
+
1379
+ // Parse the response
1380
+ const result = await response.json();
1381
+ console.log(
1382
+ `[PRACTITIONER_SERVICE] Infrastructure check response:`,
1383
+ result
1384
+ );
1385
+
1386
+ if (!result.success) {
1387
+ throw new Error(
1388
+ result.error || "Failed to ensure free consultation infrastructure"
1389
+ );
1390
+ }
1391
+
1392
+ console.log(
1393
+ `[PRACTITIONER_SERVICE] Free consultation infrastructure ensured successfully`
1394
+ );
1395
+
1396
+ return result.infrastructureExists;
1397
+ } catch (error) {
1398
+ console.error(
1399
+ "[PRACTITIONER_SERVICE] Error ensuring free consultation infrastructure:",
1400
+ error
1401
+ );
1402
+ throw error;
1403
+ }
1404
+ }
1405
+
1300
1406
  /**
1301
1407
  * Disables free consultation for a practitioner in a specific clinic
1302
1408
  * Finds and deactivates the existing free consultation procedure
@@ -1328,13 +1434,14 @@ export class PractitionerService extends BaseService {
1328
1434
  }
1329
1435
 
1330
1436
  // Find the free consultation procedure for this practitioner in this clinic
1437
+ // Use the more specific search by technology ID instead of name
1331
1438
  const existingProcedures =
1332
1439
  await this.getProcedureService().getProceduresByPractitioner(
1333
1440
  practitionerId
1334
1441
  );
1335
1442
  const freeConsultation = existingProcedures.find(
1336
1443
  (procedure) =>
1337
- procedure.name === "Free Consultation" &&
1444
+ procedure.technology.id === "free-consultation-tech" &&
1338
1445
  procedure.clinicBranchId === clinicId &&
1339
1446
  procedure.isActive
1340
1447
  );
@@ -354,6 +354,23 @@ export class ProcedureService extends BaseService {
354
354
  return snapshot.docs.map((doc) => doc.data() as Procedure);
355
355
  }
356
356
 
357
+ /**
358
+ * Gets all inactive procedures for a practitioner
359
+ * @param practitionerId - The ID of the practitioner
360
+ * @returns List of inactive procedures
361
+ */
362
+ async getInactiveProceduresByPractitioner(
363
+ practitionerId: string
364
+ ): Promise<Procedure[]> {
365
+ const q = query(
366
+ collection(this.db, PROCEDURES_COLLECTION),
367
+ where("practitionerId", "==", practitionerId),
368
+ where("isActive", "==", false)
369
+ );
370
+ const snapshot = await getDocs(q);
371
+ return snapshot.docs.map((doc) => doc.data() as Procedure);
372
+ }
373
+
357
374
  /**
358
375
  * Updates a procedure
359
376
  * @param id - The ID of the procedure to update