/**
 * Given patient data, calculate the appropriate dosage of medication based on their age and weight.
 * - The patientData map contains the following keys:
 *   - 'age': represents the patient's age in years
 *   - 'weight': represents the patient's weight in kilograms
 * - The dosage is determined as follows:
 *   - If the patient is 2 years old or younger, double the weight and return the result
 *   - If the patient is older than 2 years but younger than 6 years, add 1 to the weight and multiply it by 2, then return the result
 *   - If the patient is 6 years old or older, subtract 2 from the weight and multiply it by 3, then return the result
 */
fun calculateDosage(patientData: Map<String, Any>): Int {

    val age = patientData["age"] as Int
    val weight = patientData["weight"] as Int

    return when {
        age <= 2 -> weight * 2
        age > 2 && age < 6 -> (weight + 1) * 2
        age >= 6 -> (weight - 2) * 3
        else -> throw IllegalArgumentException("Invalid age")
    }
}
/**
 * Given patient data, calculate the appropriate dosage of medication based on their age and weight.
 * - The patientData map contains the following keys:
 *   - 'age': represents the patient's age in years
 *   - 'weight': represents the patient's weight in kilograms
 * - The dosage is determined as follows:
 *   - If the patient is 2 years old or younger, double the weight and return the result
 *   - If the patient is older than 2 years but younger than 6 years, add 1 to the weight and multiply it by 2, then return the result
 *   - If the patient is 6 years old or older, subtract 2 from the weight and multiply it by 3, then return the result
 */
fun calculateDosage(patientData: Map<String, Any>): Int {
/**
 * Given patient data, calculate the appropriate dosage of medication based on their age and weight.
 * - The patientData map contains the following keys:
 *   - 'age': represents the patient's age in years
 *   - 'weight': represents the patient's weight in kilograms
 * - The dosage is determined as follows:
 *   - If the patient is 2 years old or younger, double the weight and return the result
 *   - If the patient is older than 2 years but younger than 6 years, add 1 to the weight and multiply it by 2, then return the result
 *   - If the patient is 6 years old or older, subtract 2 from the weight and multiply it by 3, then return the result
 */
fun calculateDosage(patientData: Map<String, Any>): Int {

    val age = patientData["age"] as Int
    val weight = patientData["weight"] as Int

    return when {
        age <= 2 -> weight * 2
        age > 2 && age < 6 -> (weight + 1) * 2
        age >= 6 -> (weight - 2) * 3
        else -> throw IllegalArgumentException("Invalid age")
    }
}