help with query
Posted: Wed Sep 04, 2013 10:24 am
posted on DT previously
Coming up to that time again - end of year letters and postcards.
My first year-end with OD.
Previously, with Dentrix, we'd run overdue recall report for patients with insurance, remind them of unused funds; and same for patients without insurance, remind them of flex benefits and next year planning.
there's query #384 that's close to what we need.
/*384 List of patients with addresses past due for recall of type prophy or perio
with recall type with insurance or without insurance with NO scheduled apt*/
SET @FromDate='2005-10-01' , @ToDate='2009-12-31';
SET @pos=0;
SELECT @pos:=@pos+1 AS 'Count', rt.description,r.DateDue, p.PatNum, p.Address, p.Address2, p.City, p.State, p.ZIP FROM recall r
INNER JOIN recalltype rt ON r.recalltypenum = rt.recalltypenum
INNER JOIN patient p ON p.PatNum=r.PatNum
LEFT JOIN appointment a ON a.PatNum=p.PatNum AND a.AptStatus=1
WHERE p.patstatus = 0 AND (DATE(r.datedue) BETWEEN @FromDate AND @ToDate) AND p.HasIns='I' /*has insurance, change to <>'I' for the uninsured*/
AND (rt.Description LIKE('%perio%') OR rt.Description LIKE('%prophy%')) AND NOT ISNULL(r.DateDue)
AND ISNULL(a.AptNum)/*no sched apt*/ ;
Adding p.Email for email list gets me real close, but I'd love to have the patient's Insurance name and benefits remaining.
I don't think recall and patient tables have CarrierName field, because p.CarrierName and r.CarrierName return errors.
I see this syntax for benefits remaining -- how do I add it into existing query?
SELECT patient.PatNum,tempannualmax.AnnualMax AS $AnnualMax,tempused.AmtUsed AS $AmountUsed,
(CASE WHEN ISNULL(tempused.AmtUsed) THEN (tempannualmax.AnnualMax) ELSE (tempannualmax.AnnualMax-tempused.AmtUsed) END) AS $AmtRemaining,
FROM patient
Thanks so much!
steve
Coming up to that time again - end of year letters and postcards.
My first year-end with OD.
Previously, with Dentrix, we'd run overdue recall report for patients with insurance, remind them of unused funds; and same for patients without insurance, remind them of flex benefits and next year planning.
there's query #384 that's close to what we need.
/*384 List of patients with addresses past due for recall of type prophy or perio
with recall type with insurance or without insurance with NO scheduled apt*/
SET @FromDate='2005-10-01' , @ToDate='2009-12-31';
SET @pos=0;
SELECT @pos:=@pos+1 AS 'Count', rt.description,r.DateDue, p.PatNum, p.Address, p.Address2, p.City, p.State, p.ZIP FROM recall r
INNER JOIN recalltype rt ON r.recalltypenum = rt.recalltypenum
INNER JOIN patient p ON p.PatNum=r.PatNum
LEFT JOIN appointment a ON a.PatNum=p.PatNum AND a.AptStatus=1
WHERE p.patstatus = 0 AND (DATE(r.datedue) BETWEEN @FromDate AND @ToDate) AND p.HasIns='I' /*has insurance, change to <>'I' for the uninsured*/
AND (rt.Description LIKE('%perio%') OR rt.Description LIKE('%prophy%')) AND NOT ISNULL(r.DateDue)
AND ISNULL(a.AptNum)/*no sched apt*/ ;
Adding p.Email for email list gets me real close, but I'd love to have the patient's Insurance name and benefits remaining.
I don't think recall and patient tables have CarrierName field, because p.CarrierName and r.CarrierName return errors.
I see this syntax for benefits remaining -- how do I add it into existing query?
SELECT patient.PatNum,tempannualmax.AnnualMax AS $AnnualMax,tempused.AmtUsed AS $AmountUsed,
(CASE WHEN ISNULL(tempused.AmtUsed) THEN (tempannualmax.AnnualMax) ELSE (tempannualmax.AnnualMax-tempused.AmtUsed) END) AS $AmtRemaining,
FROM patient
Thanks so much!
steve