Question: python Q4 Write the following function: Function name get_patient_statistics Parameter(s) argument(s) 1. List of Patient class instances. i.e. type list[Patient] The definition of the Patient
python

![List of Patient class instances. i.e. type list[Patient] The definition of the](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f32d6275755_89866f32d62220f0.jpg)
Q4 Write the following function: Function name get_patient_statistics Parameter(s) argument(s) 1. List of Patient class instances. i.e. type list[Patient] The definition of the Patient class is shown in your submission template Return value A patient's medical conditions are recorded as str type objects in a list that is stored in the instance attribute self._medical_conditions Return a dictionary with str for keys and integer for values i.e. type dict[str, int] There should be 4 key-value pairs: 1. Key: "high_risk_count" Value: Number of patients with 2 or more medical conditions 2. Key: "low_risk_count" Value: Number of patients with less than 2 medical conditions 3. Key: "no_risk_count" Value: Number of patients with no medical condition 4. Key: "invalid_count", Value: Number of patients with no medical conditions The function must handle No Records Error. The definition of the Error is provided in the template. The function must not raise any exceptions. Error handling Detailed description Notes: The function should not write to stdout i.e. do not use print(). The Patient class definition is given below and in the submission template. You HAVE to use Patient's instance method get_med_cond() to access the Patient instance attribute self._medical_conditions. The value for the key-value pair is O if none of the Patient instances meets the stated condition Example usage patients = 1 Patient("Tom"), # Invalid Patient("Dick", ("hbp", "Type 1 diabetic", "high cholesterol"]), # High risk Patient("Harry", ["hbp", "diabetic"]), # High risk Patient("Jane", []), # No risk Patient("John", ["1bp"]), # Low risk ] print(get_patient_statistics(patients)) Example usage's console output {"high_risk_count": 2, "low_risk_count": 1, "no_risk_count": 1, "invalid_count": 1}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
