Query question
Posted: Tue Oct 03, 2023 1:18 pm
I'm looking for a report for a date range and specific codes. I found this query:
/*508 Active patients who have a specific code in treatment plan, with addresses
like 304 with date range*/
/*Query code written/modified: 08/26/2016*/
SET @FromDate='2010-01-01';
SET @ToDate='2010-06-01';
SET @pos=0;
SELECT @pos:=@pos+1 AS COUNT, A.*
FROM (
SELECT pc.ProcCode,
p.LName,
p.FName,
p.Address,
p.Address2,
p.City,
p.State,
p.Zip
FROM patient p
INNER JOIN procedurelog pl ON p.PatNum=pl.PatNum
AND pl.ProcStatus=1 /*treatment planned*/
INNER JOIN procedurecode pc ON pc.CodeNum=pl.CodeNum
WHERE DATE(pl.DateTP) BETWEEN @FromDate AND @ToDate
AND pc.ProcCode IN('D0120') /* NOTE: put as many procedurecodes as you like, in single quotes separated by commas*/
)A;
However, when I enter my codes in the ('D0120') at the very bottom, nothing comes up. They are codes that we made up in our system, for example N1112, so we can track where we are referring patients to (endo, perio, os)
Thanks!
/*508 Active patients who have a specific code in treatment plan, with addresses
like 304 with date range*/
/*Query code written/modified: 08/26/2016*/
SET @FromDate='2010-01-01';
SET @ToDate='2010-06-01';
SET @pos=0;
SELECT @pos:=@pos+1 AS COUNT, A.*
FROM (
SELECT pc.ProcCode,
p.LName,
p.FName,
p.Address,
p.Address2,
p.City,
p.State,
p.Zip
FROM patient p
INNER JOIN procedurelog pl ON p.PatNum=pl.PatNum
AND pl.ProcStatus=1 /*treatment planned*/
INNER JOIN procedurecode pc ON pc.CodeNum=pl.CodeNum
WHERE DATE(pl.DateTP) BETWEEN @FromDate AND @ToDate
AND pc.ProcCode IN('D0120') /* NOTE: put as many procedurecodes as you like, in single quotes separated by commas*/
)A;
However, when I enter my codes in the ('D0120') at the very bottom, nothing comes up. They are codes that we made up in our system, for example N1112, so we can track where we are referring patients to (endo, perio, os)
Thanks!