// --- Regular Expression Definitions ---

/**
 * Regex for Session ID:
 * Matches a sequence of one or more letters (case-insensitive),
 * followed by a literal dot, followed by one or more digits.
 * Example: "itojj.1752147942925"
 */
const sessionIdRegex = /^[a-zA-Z0-9]+\.\d+$/;

/**
 * Regex for Patient ID:
 * Matches a string that starts with 1 to 10 digits,
 * followed by a forward slash,
 * followed by one or more alphanumeric characters,
 * followed by another forward slash,
 * and finally ends with a single letter.
 * Example: "12/2507/GOH" or "1234567890/ABC/Z"
 */
const patientIdRegex = /^\d{1,10}\/[a-zA-Z0-9]+\/[a-zA-Z]+$/; // Changed [a-zA-Z]$ to [a-zA-Z]+$

/**
 * Regex for Patient Phone Number:
 * Matches an 11-digit number that specifically starts with "090".
 * The `^` and `$` anchors ensure the entire string matches the pattern.
 * Example: "09012345678"
 */
const patientPhoneNumberRegex = /^090\d{8}$/;

// --- Function to determine type (exported for external use) ---
/**
 * A helper function to classify a given string based on the defined regex patterns.
 * @param {string} inputString The string to classify.
 * @returns {string} A description of the type ('Session ID', 'Patient ID', 'Patient Phone Number') or 'Unknown'.
 */
function determineType(inputString) {
  if (sessionIdRegex.test(inputString)) {
    return "Session ID";
  } else if (patientIdRegex.test(inputString)) {
    return "Patient ID";
  } else if (patientPhoneNumberRegex.test(inputString)) {
    return "Patient Phone Number";
  } else {
    return "Unknown";
  }
}

module.exports = {
  determineType,
};
