The below query doesn’t filter by currently enrolled programs but returns the last two weeks of clinician notes entered. Optional search by clinician’s email address to limit the return to one clinician.
/*Two weeks of clinician notes. Doesn't filter for currently enrolled programs for patient. Returns all clinician notes delivered in the last two weeks with option to filter limit to one provider*/ Select pr.name as clinician,p.patient_id,pi.name as program_name,c.category,c.note,c.time_spent_minutes,c.created_at From patient_program_history as h Inner Join patient_info as p on p.user_program_id = h.user_program_id Inner Join program_info as pi on pi.program_id = h.program_id Inner Join clinician_notes as c on c.patient_id = p.patient_id Inner Join provider_info as pr on pr.provider_id = c.created_by /*Below limits to last 14 days*/ Where c.created_at > current_timestamp - interval '14 day' /*Use providers email to isolate to one clinician or comment out to get all in the last two weeks*/ AND pr.email = '<clinician's email address>' Group by pr.name,p.patient_id,c.category,c.note,c.time_spent_minutes,c.created_at,pi.name