Page 1 of 1

Unscheduled TP summary query

Posted: Wed Apr 16, 2008 10:46 am
by wjstarck
Can anyone suggest a query that will print out a summary $ total of uncscheduled treatment plans, the date of the plan(s), along with patient name and phone number?

Something like:

Patient name.........Unscheduled TP...........TP date.............Patient phone #
Joe Smith.................$5300.00 ...............01/01/2008...........817-555-1111
Sandy Jones..............$4722.00................02/20/2008...........817-555-1112
Darren Johns.............$ 900.00.................02/23/2008...........817-555-0007
...

Oh, and TPs equaling $0 should be excluded.

Re: Unscheduled TP summary query

Posted: Fri Apr 18, 2008 7:37 am
by jamesx2
Here is something I have written up for you, but I have not been able to test it out as I am using my laptop with a limited database. Try it out and see if it is what you need.


CREATE temporary table tp
SELECT patnum, (sum(procfee))as $Unscheduled, Date_format(datetp,'%m/%d/%Y') as TP_Date from procedurelog
WHERE (procstatus)=1
GROUP by datetp;
SELECT patient.patnum, $Unscheduled, TP_Date, HMphone as Phone from patient
left join tp on tp.patnum=patient.patnum
WHERE $Unscheduled>0
Group by patient.patnum

Re: Unscheduled TP summary query

Posted: Fri Apr 18, 2008 8:48 am
by wjstarck
Great, thanks James, that works.

If you have time, could you add the ability to show only certain date ranges?

Thanks, I owe you one..... :)

Re: Unscheduled TP summary query

Posted: Sat Apr 19, 2008 5:21 pm
by jamesx2
Here is report with date option. I had also realized that the previous report was giving you treatment planned items that may be scheduled. This one will not include treatment planned and scheduled, only treatment planned and unscheduled.

Set @StartDate='03/01/2008', @EndDate='04/31/2008';

CREATE temporary table tp
SELECT patnum, (sum(procfee))as $Unscheduled, Date_format(datetp,'%m/%d/%Y') as TP_Date from procedurelog
WHERE (procstatus)=1
AND aptnum=0
GROUP by datetp;
SELECT patient.patnum, $Unscheduled, TP_Date from patient
left join tp on tp.patnum=patient.patnum
WHERE $Unscheduled>0
AND TP_Date>@StartDate
AND TP_Date<@EndDate
Group by patient.patnum

Re: Unscheduled TP summary query

Posted: Mon Apr 21, 2008 7:18 am
by wjstarck
Thank you very much.

That has weeded out the $0 treatment plans very nicely. I'm still seeing treatment plans that date back to 2001 though.

But, if I change it to the following, it does what I want:

Code: Select all

Set @StartDate='2007-01-01', @EndDate='2008-04-31';

CREATE temporary table tp
SELECT patnum, (sum(procfee))as $Unscheduled, Date_format(datetp,'%Y-%m-%d') as TP_Date from procedurelog
WHERE (procstatus)=1
AND aptnum=0
GROUP by datetp;
SELECT patient.patnum, $Unscheduled, TP_Date from patient
left join tp on tp.patnum=patient.patnum
WHERE $Unscheduled>0
AND TP_Date>@StartDate
AND TP_Date<@EndDate
Group by patient.patnum
Thank you again for you help!