Query for Active Patients

For users or potential users.
Post Reply
Nate
Posts: 164
Joined: Wed Jun 27, 2007 1:36 pm
Location: Kansas City, MO

Query for Active Patients

Post by Nate » Thu Jun 07, 2012 7:57 am

I would appreciate if anyone can give me the basic query to count the number of active patients in a certain time frame. I am looking for the number of patients that have been in within the last 18 months. If they have had 2 prophys or several visits in the past 18 months I would only want to count them once.
Thanks for any help!

atd
Posts: 404
Joined: Thu Mar 27, 2008 2:28 pm
Location: Minneapolis, MN

Re: Query for Active Patients

Post by atd » Tue Jun 26, 2012 11:38 am

This query will count how many patients were seen in a given date range (just change it to be the last 18 months).
SELECT COUNT(DISTINCT PatNum) FROM procedurelog
WHERE ProcStatus=2 AND
ProcDate>='2012-01-01' AND
ProcDate<'2012-04-01'

If you want to check that their status is still active, then you'd need this:
SELECT COUNT(DISTINCT procedurelog.PatNum) FROM procedurelog
LEFT JOIN patient ON procedurelog.PatNum=patient.PatNum
WHERE ProcStatus=2 AND
ProcDate>='2012-01-01' AND
ProcDate<'2012-04-01' AND
PatStatus = 0

Post Reply