I took the report provide by GE in SP10, removed the patient information, and appointment information to give me a query of all problems that are good enough. If you see anything wrong or any suggestions to improve, let me know.
Next, need a query to fix this, so they don't have to open every chart and do a dumb pre-load update.
select count(p.pid),p.Code,p.DESCRIPTION, md9.Code as md9Code, md10.Code as md10Code, i9.leaf as leaf9, i10.leaf as leaf10
from
PERSON patient
JOIN PROBLEM p on patient.PID = p.PID
left join MasterDiagnosis md9 on p.ICD9MASTERDIAGNOSISID=md9.MasterDiagnosisId
left join MasterDiagnosis md10 on p.ICD10MasterDiagnosisId=md10.MasterDiagnosisId
left join ICDstructure i9 on i9.codeMasterDiagnosisId=md9.MasterDiagnosisId
left join ICDstructure i10 on i10.codeMasterDiagnosisId=md10.MasterDiagnosisId
where(NOT p.code LIKE '%CPT%' or p.code is null)
and p.change in (0,1,2,4,5,6)
and (p.stopreason is null or p.stopreason <> 'E')
and (p.stopdate >= SYSDATE)
and ((i9.leaf is null or i9.leaf =0 or md9.MasterDiagnosisId is null) or (i10.leaf is null or i10.leaf =0 or md10.MasterDiagnosisId is null))
group by (p.Code),p.DESCRIPTION, md9.Code, md10.Code, i9.leaf, i10.leaf
order by count(p.pid) desc
This query works in CPS if you change "SYSDATE" to "GETDATE()".
I'm combing through the output now. I have a few more rows than I'd hoped.