Novo Nordisk's clinical analytics team needs a patient-level summary of diagnostic activity from its clinical data platform. Write a PostgreSQL query that joins patient records with diagnostic codes and aggregates confirmed diagnoses recorded during 2025.
Requirements
- Return every patient, including patients with no qualifying diagnoses.
- Count qualifying diagnosis records and count distinct diagnostic codes per patient.
- Return diagnostic codes as a comma-separated, alphabetically ordered list, or
NULL when no code matches.
- Return the most recent qualifying diagnosis date for each patient, ordered by patient ID.
Apply the date and status conditions without removing patients who have no qualifying records.