Hi everyone,
I am trying to test the getOrder() in a Letter template on EMR 9.12 where two of the same order were placed in the same day by different providers.
The getOrder() seems to only pull the most recent order of that code.
Is there a way to expand this to include the top 2 or so?
Or get all orders placed in that day with the same format of getOrder()?
Cannot seem to find this function in the reference guide to see the parameters.
Thank you for taking the time to answer this!
I suspect that getOrder() is a custom function set up within that Letter (either at the top or bottom) or it is set up in the usrlib.txt within the Client folder. Without seeing that function, I won't be able to really tell you how to modify it.
If you are needing to get orders from beyond the prior or current visit, you need to use ORDERS_ALL(). Here is an example of pulling all the 99214's ordered for a patient in descending date of service:
{
local ord_arr, ord_count, ord_list
ord_list = ""
ord_arr = getfield(ORDERS_ALL("delimited"), "|", "")
for ord_count = size(ord_arr), ord_count > 0, ord_count = ord_count - 1
do
local ord_item
ord_item = getfield(ord_arr[ord_count], "^", "")
if (match(tolower(ord_item[3]), "99214") > 0) then
ord_list = ord_list + HRET + ord_item[1] + " [" + ord_item[3] + "] (" + ord_item[4] + ")"
endif
endfor
ord_list
}
Hi Mike,
Thanks for getting back.
You were right, there was a custom function.
It uses similar logic to yours but we still have the same issue.
If two orders of the same name are placed on the same order number then it only displays the first ordered
This is the code I am using,
{
fn getOrder(cptcode)
{
results = ""
orderArray = getfield(ORDERS_ALL("Delimited"),"|","")
for c = size(orderArray), c > 0, c = c-1
do orderArray[c] = getfield(orderArray[c],"^","")
if (orderArray[c][3] == cptcode)
then
results = "Surgery (Order Description): " + orderArray[c][1] + HRET +
"Date: " + orderArray[c][4] + HRET +
"Surgeon: " + orderArray[c][21] + HRET +
"Diagnosis: " + orderArray[c][6]
endif
endfor
return results
}
}
We have a test patient with two of the same order placed on 2/20/20 under the same order number with one provider being set to my colleague, the other myself.
Only the first order shows up, so for example OrderNum 15038420-1 will show the Authorizing Provider which is my colleague but 15038420-2 which is an order of the same name will not show with my name.
The reason behind this request is if surgeons are performing the same procedure and put in the same update, adding both orders there with the performing and physician assistant will show up, but it only shows whoever was first on the order.
Any other ideas would be helpful.
Thank you!
Change
results = "Surgery (Order Description): " + orderArray[c][1] + HRET +
to
results = results + hret + "Surgery (Order Description): " + orderArray[c][1] + HRET +