SQL: Active Patients with F Category Diagnoses

About

This report shows all active patients with any "F" category diagnosis of Mental, Behavioral, and Neurodevelopmental disorders.

A sample image of this SQL report run in the Database Viewer is shown below:

Caveats

None.

SQL Code: Firebird

To highlight and copy the code below to your clipboard, simply click the Copy button.

select a.* , fname, lname from (
select patno, max(dx_date) as last_dx_date, cast(list(distinct dxcode, ', ') as char(2000)) as dxes from dx_attach where dx_date >= cast('today' as date)-(365.25*5) and attach_table in ('ENC_NOTE','PHYSICAL') and dxcode_Type = 'ICD10'
and dxcode like 'F%' and patno >99 group by patno)
a  inner join register on register.patno = a.patno
where status_pat = 'ACTIVE'


SQL Code: MySQL

To highlight and copy the code below to your clipboard, simply click the Copy button.

select a.* , fname, lname from (
select patno, max(dx_date) as last_dx_date, group_concat(distinct dxcode, ', ') as dxes from dx_attach where dx_date >=  date_add(curdate(), interval -(365.25*5) day) and attach_table in ('ENC_NOTE','PHYSICAL') and dxcode_Type = 'ICD10'
and dxcode like 'F%' and patno >99 group by patno)
a  inner join register on register.patno = a.patno
where status_pat = 'ACTIVE'