Hello,
I need help with a script in SQL to come up with these following filters.
1. Encounters for patients 9 years and younger seen by Dr. in 2015-2018
2. Encounters for patients 65 years and older seen by Dr. in 2015-2018
Any help would be appreciated. Thanks.
Have you considered an inquiry in chart reports? It's pretty easy to do that way.
-dp
A follow-up... those ages... are they at time of visit or today's age?
1. Encounters for patients 9 years and younger seen by Dr. in 2015-2018
SELECT *
FROM DOCUMENT D INNER JOIN
PATIENTPROFILE PP ON D.PID = PP.PID
WHERE DOCTYPE = 1 AND (DATEDIFF(hour,PP.Birthdate, dbo.Convert_ID_to_date(D.CLINICALDATE))/8766) <= 9
AND YEAR(dbo.Convert_ID_to_date(D.CLINICALDATE)) BETWEEN 2015 AND 2018
AND USRID IN (SELECT PVID FROM USR WHERE LOGINNAME = 'doctor') --Change 'doctor' to doctor login
--2. Encounters for patients 65 years and older seen by Dr. in 2015-2018
SELECT *
FROM DOCUMENT D INNER JOIN
PATIENTPROFILE PP ON D.PID = PP.PID
WHERE DOCTYPE = 1 AND (DATEDIFF(hour,PP.Birthdate, dbo.Convert_ID_to_date(D.CLINICALDATE))/8766) >=65
AND YEAR(dbo.Convert_ID_to_date(D.CLINICALDATE)) BETWEEN 2015 AND 2018
AND USRID IN (SELECT PVID FROM USR WHERE LOGINNAME = 'doctor') --Change 'doctor' to doctor login
At the time of visit
Thank you so much Arnold!!
Anytime 🙂