/**
 * Given a nested dictionary containing patient records,
 * extract a specific piece of data and append all values to a list.
 *
 * @param patientRecords A nested dictionary containing patient records.
 * @return A list of extracted data values.
 *
 * Example:
 * extractData(mapOf(
 *     "patient1" to mapOf("age" to 30, "diagnosis" to "Hypertension"),
 *     "patient2" to mapOf("age" to 40, "diagnosis" to "Diabetes"),
 *     "patient3" to mapOf("age" to 50, "diagnosis" to "Arthritis")
 * ))
 * Output: [30, 40, 50]
 */
fun extractData(patientRecords: Map<String, Map<String, Any>>): List<Int> {

    val extractedData = mutableListOf<Int>()

    // Iterate over each patient in the records
    for (patient in patientRecords.values) {
        // Iterate over each data field in the patient's record
        for ((field, value) in patient) {
            // Check if the field is 'age'
            if (field == "age") {
                // Append the value to the extracted data list
                extractedData.add(value as Int)
            }
        }
    }

    return extractedData
}
/**
 * Given a nested dictionary containing patient records,
 * extract a specific piece of data and append all values to a list.
 *
 * @param patientRecords A nested dictionary containing patient records.
 * @return A list of extracted data values.
 *
 * Example:
 * extractData(mapOf(
 *     "patient1" to mapOf("age" to 30, "diagnosis" to "Hypertension"),
 *     "patient2" to mapOf("age" to 40, "diagnosis" to "Diabetes"),
 *     "patient3" to mapOf("age" to 50, "diagnosis" to "Arthritis")
 * ))
 * Output: [30, 40, 50]
 */
fun extractData(patientRecords: Map<String, Map<String, Any>>): List<Int> {
/**
 * Given a nested dictionary containing patient records,
 * extract a specific piece of data and append all values to a list.
 *
 * @param patientRecords A nested dictionary containing patient records.
 * @return A list of extracted data values.
 *
 * Example:
 * extractData(mapOf(
 *     "patient1" to mapOf("age" to 30, "diagnosis" to "Hypertension"),
 *     "patient2" to mapOf("age" to 40, "diagnosis" to "Diabetes"),
 *     "patient3" to mapOf("age" to 50, "diagnosis" to "Arthritis")
 * ))
 * Output: [30, 40, 50]
 */
fun extractData(patientRecords: Map<String, Map<String, Any>>): List<Int> {

    val extractedData = mutableListOf<Int>()

    // Iterate over each patient in the records
    for (patient in patientRecords.values) {
        // Iterate over each data field in the patient's record
        for ((field, value) in patient) {
            // Check if the field is 'age'
            if (field == "age") {
                // Append the value to the extracted data list
                extractedData.add(value as Int)
            }
        }
    }

    return extractedData
}