Chapter 9 · Interview Level
60. Patient Risk Categorization
Hard40 XPHealthcare
Categorize patients into risk levels based on multiple criteria. A patient is 'High Risk' if they have more than 3 visits with abnormal lab results, 'Medium Risk' if 1-3, and 'Low Risk' if none. Return patient full name, abnormal_visit_count, and risk_level. Include all patients who have had visits. Order by abnormal_visit_count descending.
Tables
- PKidINT
- first_nameTEXT
- last_nameTEXT
- date_of_birthTEXT
- genderTEXT
- emailTEXT
- phoneTEXT
- blood_typeTEXT
- cityTEXT
- stateTEXT
- FKinsurance_id→ insurance.idINT
- created_atTIMESTAMP
- PKidINT
- FKpatient_id→ patients.idINT
- FKdoctor_id→ doctors.idINT
- visit_dateTEXT
- diagnosisTEXT
- notesTEXT
- follow_up_dateTEXT
- statusTEXT
- PKidINT
- FKvisit_id→ visits.idINT
- test_nameTEXT
- result_valueTEXT
- unitTEXT
- reference_rangeTEXT
- is_abnormalINT
- tested_atTEXT
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.