Verily’s clinical research workflows need to identify periods when a patient had no recorded treatment activity. Given a patient event log, write a PostgreSQL query that finds consecutive treatment events separated by more than 90 days.
event_type = 'treatment' and event_date is not NULL.patient_id, gap_start, gap_end, and gap_days, in that order.patient_id ascending, then gap_start ascending.event_date as ineligible preceding events.| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique clinical event identifier |
| patient_id | INT | Identifier of the patient associated with the event |
| event_type | VARCHAR(30) | Clinical event classification, such as treatment, visit, or lab |
| event_date | DATE | Date on which the clinical event occurred |