Page 1 of 1

Query for Active Patients

Posted: Thu Jun 07, 2012 7:57 am
by Nate
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!

Re: Query for Active Patients

Posted: Tue Jun 26, 2012 11:38 am
by atd
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