Write a SQL query to find the latest lab result for each patient in a study, partitioned by patient ID and ordered by visit date.
Use the study identified by study_code = 'PMG-ONC-101'. Include enrolled patients without a lab result, and use result_id as the tie-breaker when a patient has multiple results on the same visit date.
Output
- One row per enrolled patient, ordered by
patient_id ascending.
- Columns:
patient_id, visit_date, lab_test, and result_value.
- Patients without results should have NULL values for the lab result columns.