Is there a way to display in a letter only certain orders that are ordered?
For example if a doctor orders the service order "CPT 23456," is there a way to display that order in a letter, with its start date, order description and authorizing provider? Thanks!
You can look up the ORDERS_ALL for more info on what is available, but you can certainly use it to get certain orders. if you know the specific CPT code, even better!
Put this code in the top of your letter:
{fn getOrder(cptcode){
results = ""
orderArray = getfield(ORDERS_ALL("Delimited"),"|","")
for c = 1, c <= size(orderArray), c = c+1 do
orderArray[c] = getfield(orderArray[c],"^","")
if (orderArray[c][3] == cptcode) then
results = "Details: " + orderArray[c][1] + HRET + "Date: " + orderArray[c][4] + HRET + "Authorizing Provider: " + orderArray[c][21]
endif
endfor
return results
}}
Then, in the letter body where you want this info, put
{getOrder("CPT-23456")}
and as long as the CPT matches the code you typed in, you will get the following:
Details: Colonoscopy Referral
Date: 04/21/2015
Authorizing Provider: Allen Noble PA-C
Please let me know if you have any questions on how this works, or how to tweak it.
Thank you,
Daniel
You are the best!!! Works perfectly, thanks so much!
Hi Dan, I just emailed you but I'm unsure if you got it. Is there a way to manipulate it to look for multiple CPT codes? I'm trying to display the last Physical Orders (CPT 99308, CPT 99309, CPT 99310, etc) Thank you!
Hello Courtney,
I have not received your email, but I saw that you update your post here on CHUG. if you reply to this post, I get an email that the question was updated. so here is my thoughts on getting multiple CPT codes in a letter with this code.
You could modify the code to accept a comma delimited string, or an array of CPT codes, but I would rather do the following in my letter using the already built code I sent you:
{getOrder("CPT-99308")}
{getOrder("CPT-99309")}
{getOrder("CPT-993010")}
you can re-use the code and get as many orders as you want into a single letter. If you are wanting to only show the latest CPT code by date, you would have to do some comparisons, and that would require modifying the code
Hi Dan,
Thank you for your responses thus far. I am using your "{fn getOrder(cptcode)" displayed above within a data display.
It works. Yet, I am trying to add multiple CPT codes within the function and have it display the most recent CPT code ordered.
I was able to pull the most recent CPT code based off of 3 CPT codes listed within the data display, yet it is very glitchy.
Code: {getOrder("99383")};{getOrder("99382")};{getOrder("99381")} (THIS WORKS)
If I list 99381 first and 99383 as the last leg in the function, it doesn't show anything in the data display. ex: {getOrder("99381")};{getOrder("99382")};{getOrder("99383")} (WEIRD)
Essentially, I am trying to add a total of 17 CPT codes within 1 data display, showing its most recent CPT code ordered.
Do you have any insight on this?
Thank you so much in advance!
-Shereen
I have not seen this function do that. I will try it out in a letter my I would start by double checking the syntax of your code. I have often found that my code breaking after it works fine is due to my own mistake when changing things. Can you copy the letter you have built so I can test it on my end?
Thank you,
Daniel Carpenter
Hi Daniel,
I am using the coding below within a data display oppose to a letter.
MEL expression within the data display:
{getOrder("99383")};{getOrder("99382")};{getOrder("99381")}
Coding in MEL worksheet:
{fn getOrder(cptcode){
results = ""
orderArray = getfield(ORDERS_ALL("delimited"),"|","")
for c = 1, c <= size(orderArray), c = c+1 do
orderArray[c] = getfield(orderArray[c],"^","")
if (orderArray[c][3] == cptcode) then
results = " " + orderArray[c][1] + HRET + ", " + orderArray[c][4] + HRET + ", " + orderArray[c][21]
endif
endfor
return results
}}
This coding return the most recent CPT code, yet it is very glitchy. I have a total of 17 CPT codes to add essentially.
Thank you for all of your help!
-Shereen
Ah I found that on my version of the software, I had to add "CPT-" before my codes, and then they worked normally. so my code looks like this: {getOrder("CPT-99214")} and then it works, otherwise it is blank.
Let's look at the data we are working with. if you make a TEST letter and put the code below in, we can see what the data my function is grabbing looks like.
{ORDERS_ALL("delimited")}
If the patient you run this letter on has the orders in their chart that you are trying to pull, we should be able to see if there is a difference in what the code is expecting, and what it is getting.
Thank you,
Daniel Carpenter
Hi Daniel,
This is the coding I put within the letter:
Physical Exam Details:
{getOrder("99386")}
{getOrder("99387")}
{getOrder("99396")}
{getOrder("99397")}
{getOrder("99385")}
{ORDERS_ALL("delimited")}
...And it works in the letter. I just can't get it to work in a data display.
Any other suggestions?!
Thank you again!
Shereen
Oh I'm sorry, I didn't realize it was being used in a data display! sometimes the code from a data display and the code from a letter have to be slightly different to work.
If you have a data display with the connection type set to "MEL Expression", then you have to treat the text box you are typing into as if there is already an opening bracket and a closed bracket around the box. please try this code in the data display:
getOrder("99386") + HRET + getOrder("99387")+ HRET +getOrder("99396")+ HRET +getOrder("99397")+ HRET +getOrder("99385")
This should work in a data display. Make sure to build your function in the function window of the form you are making, or in a library.
Let me know how it goes.
Daniel C.
Hi Daniel,
IT WORKED!! Thank you so much. The only thing I removed for the code within the data display was "HRET". I preferred not to have the line break.
I am using this within the MEL worksheet:
{fn getOrder(cptcode){
results = ""
orderArray = getfield(ORDERS_ALL("delimited"),"|","")
for c = 1, c 0 and durationdays(orderArray[c][4], str(._todaysdate)) 0 and durationdays(orderArray[c][4], str(._todaysdate)) < 731
The only problem I have now is that it only displays the most recent order placed. I am trying to list all of the orders within 2 years.
Do you have any insight on this?
-Shereen