Page 1 of 1

query

Posted: Fri Dec 19, 2008 4:35 am
by fschiopu
Is there a query to see the patients that have a certain insurance carrier and have been seen in a certain period of time (like last year, or last 2 years)?

Re: query

Posted: Fri Dec 19, 2008 11:34 am
by fschiopu
Hi,

I came up with the following query (based on one found in the query section) which seems to work, but I don't know how accurate it is. Any input is appreciated.

SELECT carrier.CarrierName,patient.*
FROM patient,carrier,insplan
WHERE patient.PatNum=insplan.Subscriber
AND insplan.CarrierNum=carrier.CarrierNum
AND carrier.CarrierName LIKE '%Aetna%'
/*only patients with procedures within the last year*/
AND EXISTS(SELECT * FROM procedurelog
WHERE procedurelog.PatNum=patient.PatNum
AND procedurelog.ProcDate > CURDATE() - INTERVAL 1 YEAR)
ORDER BY LName, FName

Re: query

Posted: Fri Dec 19, 2008 4:04 pm
by jordansparks
That's a good query. Keep in mind that it's only pulling subscribers, not other family members.