Patients who saw a certain provider?

For users or potential users.
Post Reply
khdilger
Posts: 112
Joined: Wed May 05, 2010 5:56 am

Patients who saw a certain provider?

Post by khdilger » Tue Aug 11, 2015 11:28 am

I am looking to generate a list of patients that are do for recall and saw a certain provider. Does anybody have a query example for that?

I found a query example that lists all patients that have seen a given provider and the date they last saw her, but I am really only wanting
the people who are do for recall and their last visit / procedure at the office is with this particular provider.

User avatar
dgraffeo
Posts: 147
Joined: Wed Sep 24, 2014 3:19 pm

Re: Patients who saw a certain provider?

Post by dgraffeo » Tue Aug 11, 2015 12:21 pm

Hey, this might work for you. It's a slightly modified query on the examples page. Just put the abbreviation of the provider between the quotation marks of @ProvAbbr= (make sure to keep the quotation marks)

SET @pos=0, @StartDate='2010-06-01' , @EndDate='2010-12-01', @ProvAbbr='';
SELECT @pos:=@pos+1 AS 'Count',p.LName, p.FName, r.DateDue, d.ItemName AS 'RecallStatus',
(SELECT DATE_FORMAT(MAX(ProcDate),'%m/%d/%Y') FROM patient INNER JOIN procedurelog
ON procedurelog.PatNum=patient.PatNum WHERE procedurelog.ProcStatus=2 AND patient.PatStatus=0 AND p.PatNum=patient.PatNum
GROUP BY procedurelog.PatNum) AS 'LastVisit(any)', provider.Abbr
FROM patient p
INNER JOIN recall r ON p.PatNum=r.PatNum
INNER JOIN provider ON provider.ProvNum=p.PriProv
AND provider.Abbr=@ProvAbbr
LEFT JOIN definition d ON r.RecallStatus=d.DefNum
WHERE (DateDue BETWEEN @StartDate AND @EndDate)
ORDER BY p.LName, p.FName;
"To understand what recursion is, you must first understand recursion."

David Graffeo
Open Dental Software
http://www.opendental.com

Post Reply