New Patient query

For users or potential users.
Post Reply
bstoute
Posts: 1
Joined: Thu Dec 30, 2010 7:12 am

New Patient query

Post by bstoute » Thu Dec 30, 2010 7:13 am

Any assistance will be greatly appreciated, my MYSQL skills are lacking. I would like to have a query that gives a List of new patients within a given date range along with insurance carrier. It basically is a merger of the following queries.



/*323 Active Patients listed with Insurance Carrier, blank if they do not */
SELECT * FROM patient,p.PatNum,carrier.CarrierName
FROM carrier
WHERE DateFirstVisit >= '2010-12-01'
AND DateFirstVisit < '2010-12-31'
AND patient.patstatus = '0'
INNER JOIN insplan ip ON carrier.CarrierNum=ip.CarrierNum
INNER JOIN patplan pp ON ip.PlanNum=pp.PlanNum
INNER JOIN patient p ON pp.PatNum=p.PatNum

===================
List of new patients for a given date range

SELECT * FROM patient
WHERE DateFirstVisit >= '2010-12-01'
AND DateFirstVisit < '2010-12-31'
AND patient.patstatus = '0'


Thank you
Brian Stoute, DDS

excelalbertville
Posts: 1
Joined: Thu Dec 30, 2010 2:45 pm

Re: New Patient query

Post by excelalbertville » Thu Dec 30, 2010 3:28 pm

I am needing the exact same thing. I've tried multiple things on my own, but to no avail. Any help is appreciated.

Thanks,
Tiffany Morgan
Office Manager
Excel Dentistry

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

Re: New Patient query

Post by atd » Mon Jan 17, 2011 1:45 pm

How about this?

SELECT p.patNum, carrier.CarrierName, DateFirstVisit FROM patient p
LEFT JOIN patplan pp on pp.PatNum=p.PatNum
LEFT JOIN insplan ip on pp.PlanNum=ip.PlanNum
LEFT JOIN carrier on ip.CarrierNum=carrier.CarrierNum
WHERE DateFirstVisit >= '2010-12-01'
AND DateFirstVisit < '2010-12-31'
AND p.patstatus = 0
ORDER BY Carrier.CarrierName

Post Reply