/**
 * This function takes a condition as input and returns a list of patient names who are diagnosed with that condition.
 *
 * @param selectedCondition The condition for which you want to get the list of patients.
 * @param allPatients A list of maps containing information about all the patients.
 * @return A list of patient names diagnosed with the selected condition.
 */
fun getPatientList(selectedCondition: String, allPatients: List<Map<String, Any>>): List<String> {

    val patientsWithCondition = mutableListOf<String>()
    
    // Iterate through each patient's information
    for (patient in allPatients) {
        // Check if the patient has the selected condition
        if ("condition" in patient && selectedCondition in (patient["condition"] as List<*>)) {
            // Add the patient's name to the list
            patientsWithCondition.add(patient["name"] as String)
        }
    }
    
    return patientsWithCondition
}

// Example usage
val allPatients = listOf(
    mapOf("name" to "John Doe", "age" to 45, "condition" to listOf("diabetes", "hypertension")),
    mapOf("name" to "Jane Smith", "age" to 32, "condition" to listOf("hypertension")),
    mapOf("name" to "Robert Johnson", "age" to 60, "condition" to listOf("arthritis"))
)
/**
 * This function takes a condition as input and returns a list of patient names who are diagnosed with that condition.
 *
 * @param selectedCondition The condition for which you want to get the list of patients.
 * @param allPatients A list of maps containing information about all the patients.
 * @return A list of patient names diagnosed with the selected condition.
 */
fun getPatientList(selectedCondition: String, allPatients: List<Map<String, Any>>): List<String> {
/**
 * This function takes a condition as input and returns a list of patient names who are diagnosed with that condition.
 *
 * @param selectedCondition The condition for which you want to get the list of patients.
 * @param allPatients A list of maps containing information about all the patients.
 * @return A list of patient names diagnosed with the selected condition.
 */
fun getPatientList(selectedCondition: String, allPatients: List<Map<String, Any>>): List<String> {

    val patientsWithCondition = mutableListOf<String>()
    
    // Iterate through each patient's information
    for (patient in allPatients) {
        // Check if the patient has the selected condition
        if ("condition" in patient && selectedCondition in (patient["condition"] as List<*>)) {
            // Add the patient's name to the list
            patientsWithCondition.add(patient["name"] as String)
        }
    }
    
    return patientsWithCondition
}

// Example usage
val allPatients = listOf(
    mapOf("name" to "John Doe", "age" to 45, "condition" to listOf("diabetes", "hypertension")),
    mapOf("name" to "Jane Smith", "age" to 32, "condition" to listOf("hypertension")),
    mapOf("name" to "Robert Johnson", "age" to 60, "condition" to listOf("arthritis"))
)