from constants.token_const import TokenGenerationStatus
from appointmentmanagement.models import Appointment  

def get_token(text):
    if text.lower()=='none':
        return None
    else:
        return TokenGenerationStatus(text.upper()).value
    
    


def get_next_token_number(doctor_id, session_id):
    try:
        total_appointments = Appointment.objects.filter(
            doctor_id=doctor_id,
            session_id=session_id,
        ).count()
        return total_appointments + 1
    except Exception as e:
        print(f"Error in get_next_token_number utility: {e}")
        return None  # Return None on error
