Wanted to write a quick MEL that would allow for a quicktext (or banner) display of the last usage of one of the CPE (complete physical exam) CPT codes. I know to look for CPT- 99385, 99386, 99387, 99395, 99396, 99397.
Has anyone ever done this?
I have started with:
{local hold = getfield(ORDERS_ALL("delimited", "S"), "|", "")
local temp
local rslt = ""
for i = 1, i <= size(hold), i = i + 1 do
temp = getfield(hold[i], "^", "")
rslt = rslt + temp[2] + " - " temp[3] + " on " + temp[4] + HRET
endfor
rslt
}
If you want the most recent order to show, here's the logic you want:
Add another variable to hold the date field of the order.
The first test you want is to look at the date for the order in the record. First time through, you won't have anything in that variable so you then do the next test, a match on field 2 to the codes you are looking for. If you find one, store the date as a separate variable and store the string you want in rslt. Next time through the loop, compare the date you stored to the date in the record. If the date you stored is more recent that the date in the current record, ignore that record and go on to the next. If the date is more recent, then see if it has one of the codes you are looking for. If so, replace the value in your date variable and replace the value in rslt. Repeat until you have looked at each record in the array.
Hi David,
That is exactly what I intended to do.
See if temp[3] is one of my six targeted CPT's, and then look at temp[4] to get the most recent date.
My struggle is that the array logic I have so far does not appear to be processing - or, at least it is not printing out the temp variables to the screen so I can see them.
Are you using "return rslt" at the end? In your code I just see "rslt".
Hi David.
I always thought the 'return' was when a function (or simliar).
Instead of simply 'rslt' I tried 'return rslt' and got a MEL error
return <-COMPILER ERROR NEARBY: RETURN was unexpected after ENDFOR KEYWORD
Orders_All() will return all orders for the patient. Use "delimited" and filter on the codes you are interested in. See the Help Files for details.
Sorry, I thought you had that wrapped in a function. You might try wrapping result in a FMT statement.
Hi Joe, I'm looking to do the same thing in the patient banner. Did you ever get this to work? If so, would you mind please sharing the coding? Thanks!
I placed the following in my banner logic. Note, you don't see the { } because I have several routines like this to determine variables that I later use in my banner. Found it easier to determine variables at the beginning, and then can simply later display all the outputs.
global PEdate = ""
local Cnt
local Row
local OL
local OA
local Osz
local Cd
OL = ORDERS_ALL('DELIMITED','S')
OA = getfield(OL,"|","")
Osz = size(OA)
for Cnt=1, Cnt<=Osz, Cnt=Cnt+1 do
Row = getfield(OA[Cnt],"^","")
Cd = str(Row[3])
If (Cd = "CPT-99385" or Cd = "CPT-99386" or Cd = "CPT-99387" or Cd = "CPT-99395" or Cd = "CPT-99396" or Cd = "CPT-99397" )
then PEdate = str(Row[4])
Else ""
Endif
Endfor
And then later have the following to display it.
Last PE: {if PEdate = "" then "None" else PEdate endif}
Thanks so much, so I entered the below code into the banner and tested it on some patients who have those CPT codes. For some reason its returning "FALSE"? Did I leave anything out?
Thanks again!
{global PEdate = ""
local Cnt
local Row
local OL
local OA
local Osz
local Cd
OL = ORDERS_ALL("DELIMITED","S")
OA = getfield(OL,"|","")
Osz = size(OA)
for Cnt=1, Cnt<=Osz, Cnt=Cnt+1 do
Row = getfield(OA[Cnt],"^","")
Cd = str(Row[3])
if (Cd = "99381" or Cd = "99382" or Cd = "99383" or Cd = "99384" or Cd = "99385" or Cd = "99386") then PEdate = str(Row[4])
else ""
endif
endfor}
Last PE: {if PEdate = "" then "None" else PEdate endif}