@blackcode_sa/metaestetics-api 1.12.40 โ†’ 1.12.42

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.
@@ -412,20 +412,44 @@ export class AppointmentService extends BaseService {
412
412
  }
413
413
 
414
414
  // AUTO-CLEANUP: Remove invalid recommendedProcedures with empty notes BEFORE validation
415
- if (data.metadata?.recommendedProcedures && Array.isArray(data.metadata.recommendedProcedures)) {
416
- const validRecommendations = data.metadata.recommendedProcedures.filter(
417
- (rec: any) => rec.note && typeof rec.note === 'string' && rec.note.trim().length > 0
418
- );
415
+ console.log(
416
+ '[APPOINTMENT_SERVICE] ๐Ÿ” BEFORE CLEANUP - recommendedProcedures:',
417
+ JSON.stringify(data.metadata?.recommendedProcedures, null, 2),
418
+ );
419
+
420
+ if (
421
+ data.metadata?.recommendedProcedures &&
422
+ Array.isArray(data.metadata.recommendedProcedures)
423
+ ) {
424
+ const validRecommendations = data.metadata.recommendedProcedures.filter((rec: any) => {
425
+ const isValid = rec.note && typeof rec.note === 'string' && rec.note.trim().length > 0;
426
+ if (!isValid) {
427
+ console.log('[APPOINTMENT_SERVICE] โŒ INVALID recommendation found:', rec);
428
+ }
429
+ return isValid;
430
+ });
431
+
419
432
  if (validRecommendations.length !== data.metadata.recommendedProcedures.length) {
420
433
  console.log(
421
- `[APPOINTMENT_SERVICE] Removing ${data.metadata.recommendedProcedures.length - validRecommendations.length} invalid recommended procedures with empty notes`
434
+ `[APPOINTMENT_SERVICE] ๐Ÿงน Removing ${
435
+ data.metadata.recommendedProcedures.length - validRecommendations.length
436
+ } invalid recommended procedures with empty notes`,
422
437
  );
423
438
  data.metadata.recommendedProcedures = validRecommendations;
439
+ } else {
440
+ console.log('[APPOINTMENT_SERVICE] โœ… All recommendedProcedures are valid');
424
441
  }
425
442
  }
426
443
 
444
+ console.log(
445
+ '[APPOINTMENT_SERVICE] ๐Ÿ” AFTER CLEANUP - recommendedProcedures:',
446
+ JSON.stringify(data.metadata?.recommendedProcedures, null, 2),
447
+ );
448
+
427
449
  // Validate input data
450
+ console.log('[APPOINTMENT_SERVICE] ๐Ÿ” Starting Zod validation...');
428
451
  const validatedData = await updateAppointmentSchema.parseAsync(data);
452
+ console.log('[APPOINTMENT_SERVICE] โœ… Zod validation passed!');
429
453
 
430
454
  // Update the appointment using the utility function
431
455
  const updatedAppointment = await updateAppointmentUtil(this.db, appointmentId, validatedData);