@blackcode_sa/metaestetics-api 1.14.61 → 1.14.65

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.
@@ -680,11 +680,23 @@ export class AppointmentService extends BaseService {
680
680
 
681
681
  /**
682
682
  * Cancels an appointment by an Admin/Clinic.
683
+ * @param appointmentId - The appointment ID to cancel
684
+ * @param reasonOrClinicId - Either a cancellation reason string, or clinicId (legacy parameter - will be ignored)
683
685
  */
684
- async cancelAppointmentAdmin(appointmentId: string, reason: string): Promise<Appointment> {
686
+ async cancelAppointmentAdmin(appointmentId: string, reasonOrClinicId?: string): Promise<Appointment> {
685
687
  console.log(`[APPOINTMENT_SERVICE] Admin canceling appointment: ${appointmentId}`);
688
+
689
+ // Detect if the second parameter looks like an ID rather than a reason
690
+ // IDs typically have no spaces and contain alphanumeric/dash/underscore patterns
691
+ const isLikelyId = reasonOrClinicId &&
692
+ !reasonOrClinicId.includes(' ') &&
693
+ /^[a-zA-Z0-9_-]+$/.test(reasonOrClinicId) &&
694
+ reasonOrClinicId.length > 15;
695
+
696
+ const cancellationReason = isLikelyId ? undefined : (reasonOrClinicId || undefined);
697
+
686
698
  return this.updateAppointmentStatus(appointmentId, AppointmentStatus.CANCELED_CLINIC, {
687
- cancellationReason: reason,
699
+ cancellationReason,
688
700
  canceledBy: 'clinic',
689
701
  });
690
702
  }