Report Help

For users or potential users.
Post Reply
thinkortho
Posts: 19
Joined: Sun Jul 31, 2011 12:44 pm

Report Help

Post by thinkortho » Wed Mar 28, 2012 11:00 am

I got the following report from the favorites section on the open dental website.

/*303 List of active patients with no appointments in date range, includes phone numbers and address*/
SET @FromDate='2009-07-01' , @ToDate='2009-07-31';
SELECT CONCAT(p.LName, ', ',p.FName, ' ', p.MiddleI) AS Patient, CONCAT(" ", LEFT(p.HmPhone,13), "- ", LEFT(p.WkPhone,13), "- ",LEFT(p.WirelessPhone,13)) AS 'Phone Hm-Wk-Cell',
CONCAT(p.Address, " ", p.Address2, ", ", p.City, ", ",p.State, " ", p.ZIP) AS 'Full Address'
FROM patient p
LEFT JOIN appointment ap ON p.PatNum=ap.PatNum AND (DATE(ap.AptDateTime) BETWEEN @FromDate AND @ToDate) AND ap.AptStatus IN (1,2) /*sched or complete*/
WHERE ISNULL(ap.aptnum) AND
p.PatStatus=0
ORDER BY p.LName, p.FName ASC;

When i cut and paste it into the qury box I get the following error: Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MYSQL server for the right syntax to use near ANDp.PatStatus=0ORDER BY p.LName, p.FName ASC' at line 1

any advice or help would be great. I get the error message with a lot of the reports I try to cut and paste

nathansparks
Posts: 172
Joined: Mon Aug 04, 2008 12:39 pm

Re: Report Help

Post by nathansparks » Wed Mar 28, 2012 12:54 pm

What browser and operating sytem are you using? There are invisible characters at the end of each line that are being stripped by whatever method you are grabbing the query, try copying this and see if you have the same result, it works fine for me:
/*303 List of active patients with no appointments in date range, includes phone numbers and address*/
SET @FromDate='2009-07-01' , @ToDate='2009-07-31';
SELECT CONCAT(p.LName, ', ',p.FName, ' ', p.MiddleI) AS Patient, CONCAT(" ", LEFT(p.HmPhone,13), "- ", LEFT(p.WkPhone,13), "- ",LEFT(p.WirelessPhone,13)) AS 'Phone Hm-Wk-Cell',
CONCAT(p.Address, " ", p.Address2, ", ", p.City, ", ",p.State, " ", p.ZIP) AS 'Full Address'
FROM patient p
LEFT JOIN appointment ap ON p.PatNum=ap.PatNum AND (DATE(ap.AptDateTime) BETWEEN @FromDate AND @ToDate) AND ap.AptStatus IN (1,2) /*sched or complete*/
WHERE ISNULL(ap.aptnum) AND
p.PatStatus=0
ORDER BY p.LName, p.FName ASC;

if that does not work use this, I just added spaces at the end of each line

/*303 List of active patients with no appointments in date range, includes phone numbers and address*/
SET @FromDate='2009-07-01' , @ToDate='2009-07-31';
SELECT CONCAT(p.LName, ', ',p.FName, ' ', p.MiddleI) AS Patient, CONCAT(" ", LEFT(p.HmPhone,13), "- ", LEFT(p.WkPhone,13), "- ",LEFT(p.WirelessPhone,13)) AS 'Phone Hm-Wk-Cell',
CONCAT(p.Address, " ", p.Address2, ", ", p.City, ", ",p.State, " ", p.ZIP) AS 'Full Address'
FROM patient p
LEFT JOIN appointment ap ON p.PatNum=ap.PatNum AND (DATE(ap.AptDateTime) BETWEEN @FromDate AND @ToDate) AND ap.AptStatus IN (1,2) /*sched or complete*/
WHERE ISNULL(ap.aptnum) AND
p.PatStatus=0
ORDER BY p.LName, p.FName ASC;

Post Reply