Query question

For users or potential users.
Post Reply
speeples
Posts: 27
Joined: Tue Feb 05, 2019 12:27 pm

Query question

Post by speeples » 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!

Tom Zaccaria
Posts: 353
Joined: Mon Feb 25, 2008 3:09 am

Re: Query question

Post by Tom Zaccaria » Wed Oct 04, 2023 2:15 am

Works. Use this format;

AND pc.ProcCode IN('D0120','D1110','D0210')

drtmz

speeples
Posts: 27
Joined: Tue Feb 05, 2019 12:27 pm

Re: Query question

Post by speeples » Wed Oct 04, 2023 4:39 am

That's what I was doing but it apparently only does codes that start with D. Do you know of another query for treatment planned codes that I can enter AND do a date range?

Tom Zaccaria
Posts: 353
Joined: Mon Feb 25, 2008 3:09 am

Re: Query question

Post by Tom Zaccaria » Wed Oct 04, 2023 11:03 am

Just tried it with 'N2010' a code we use for BW from another office and it picked it up.

drtmz

speeples
Posts: 27
Joined: Tue Feb 05, 2019 12:27 pm

Re: Query question

Post by speeples » Wed Oct 04, 2023 12:17 pm

AND pc.ProcCode IN('N1114') /* NOTE: put as many procedurecodes as you like, in single quotes separated by commas*/
)A;


There is the last little bit of that query. A patient that is scheduled tomorrow has that N1114 code in their treatment plan. Then I changed the dates to reflect this week. I tested the query leaving the D0120 code and it worked just fine. I am only changing what is in the (), other than the date. This is really starting to piss me off!!! I don't have anyone in the office to help me figure this out :?

speeples
Posts: 27
Joined: Tue Feb 05, 2019 12:27 pm

Re: Query question

Post by speeples » Thu Oct 05, 2023 12:16 pm

So I figured it out Tom! If you're still curious......it will only pull up those codes that were treatment plannED, not ACTIVE treatment. So on Monday when I want to look for my codes for the people that are scheduled this week, my codes won't show since the days haven't happened yet. And the Treatment Finder in OD won't work because those codes are zero codes. Apparently there isn't a report/query that can search a date range and enter specific codes that are active treatment.

Tom Zaccaria
Posts: 353
Joined: Mon Feb 25, 2008 3:09 am

Re: Query question

Post by Tom Zaccaria » Thu Oct 12, 2023 8:36 am

You mean scheduled treatment as in the patients have an appointment vs treatment planned as in it it in the treatment plan but no appointment on the books? If this is the case there are variables you can change to reflect this. I think!!

drtmz

Post Reply