SQL: Patient Portal Null Problems

About

This report looks at all Problem List entries and returns a list where a SNOMED or ICD code has not been entered. This report will include Problem List entries with a status of Active, Tracking, or Resolved, including those that are marked as Hidden.

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

Caveats

None.

Code

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

select a.*, trim(coalesce(note,"") ) as words
from (
select cn.patno, fname,lname, section_subheading, chart_section, staffname as pcp, cast(left(cn.note1,5000) as char(5000)) as note,
case when cn.privacy_level = 'A' then 'public' when cn.privacy_level is null then 'public' else 'private' end as privacy
from chartnotes cn
inner join register r on r.patno = cn.patno
inner join staff1 s on s.staffid = r.addr_id
 where cn.section_subheading = 'PAST MEDICAL HISTORY'
and chart_section <> 'GENERAL'
and cn.patno > 99
and r.status_pat ='ACTIVE'
and r.lname <> 'TESTPATIENT'
and (cn.ICD_1 is null or cn.ICD_1 = '')
and (cn.SNOMED1 is null or cn.SNOMED1 = '')
order by cn.patno
) a