Query for Long-time Patients

For users or potential users.
Post Reply
KevinRossen
Posts: 293
Joined: Mon Apr 22, 2013 8:49 am
Location: Dallas, TX
Contact:

Query for Long-time Patients

Post by KevinRossen » Wed Aug 13, 2014 2:17 pm

I built a query for finding patients who have been part of our practice for over 25 years. It's limited to ones who have been in for an appointment in the past year and have a future appointment scheduled. I'm finding ways to recognize and thank them for their commitment to our practice. I thought others might find it useful, too. You can set the timeframe you would like at the top.

Code: Select all

SET	@FirstVisit='1989-01-01',
	@LastProc='2013-09-01',
	@NextAppt='2014-08-14';
SELECT p.PatNum,p.BirthDate,p.DateFirstVisit,a.AptDateTime AS 'NextApt'
FROM patient p LEFT JOIN procedurelog pl ON p.PatNum=pl.PatNum LEFT JOIN appointment a ON p.PatNum=a.PatNum
WHERE (DATE(p.DateFirstVisit)<@FirstVisit AND DATE(p.DateFirstVisit)>'0001-01-01') AND p.PatStatus=0 AND (DATE(pl.ProcDate)>@LastProc AND pl.ProcStatus=2) AND a.AptStatus IN(1,4)
GROUP BY p.PatNum ORDER BY NextApt;
Kevin Rossen
Office Manager, Rossen Dental
Founder, DivergentDental.com
Image

MKM
Posts: 30
Joined: Wed Mar 16, 2011 4:07 am

Re: Query for Long-time Patients

Post by MKM » Thu Aug 14, 2014 11:33 am

This is excellent! What a great idea! Thank you for sharing this!
Mary Kay
Practice Administrator
Medina, Ohio

Post Reply