I created a drop down list of users that have NPI numbers in their accounts. This selected user will then automatically populate in the 'Authorized by' field of lab orders created during the encounter. Saves the user time so they don't have to change the authorizing provider in every lab order.
The problem is that there is a delay every time we use this drop down list. I also use this to automatically send a flag to the selected user and we get the same delay. The EHR freezes for several seconds after selecting a user from the list.
Is there a way to remove this delay? Is there something going on in my code that is causing it?
This is the two functions I used. One to populate the list and the other to pull the login id so it can be used to create the orders.
// Creates a list of Users with NPI numbers
{! fn fnAuthProvList(strUser)
{
local i
local UserList
local strAuth
local strAuthProvList = ""
local strArray = Array()
UserList = getfield(strUser, "|", "")
for i = 1, i <= size(UserList), i = i + 1 do
UserList[i] = getfield(UserList[i], "^", "")
strAuth = UserList[i][2]
strAuth = ReplaceStr(strAuth, ",", numtoascii(130))
if UserList[i][9] <> "" then
insert(strArray,1,strAuth)
endif
endfor
return sort(strArray, TRUE)
}}
// Sets gAuthProvName value to login ID from name selected
{fnAuthProvID(DOCUMENT.AUTHPROV)}
{! fn fnAuthProvID(strID)
{
local i
local IDList
local ID
local strAuth
local strAuthID
local List = GET_USER_LIST("ALL","","delimited")
IDList = getfield(List, "|", "")
for i = 1, i <= size(IDList), i = i + 1 do
IDList[i] = getfield(IDList[i], "^", "")
strAuth = IDList[i][2]
strAuthID = IDList[i][1]
strAuth = ReplaceStr(strAuth, ",", numtoascii(130))
if strID == strAuth then
gAuthProvName = strAuthID
BREAK
endif
endfor
return ""
}}
It's called using this in the drop down component:
{fnAuthProvList(GET_USER_LIST("ALL","","delimited"))}
Have you done a MEL trace and looked at the timestamps to see where your delay is in the first function? How long is your user list? It may be the sort is the slow part. Have you tried it without the sort to see if there is any improvement?
It looks to me like you are using the function as a watcher expression so it is having to repeatedly run. I would set it up to call the function one time, write the result to a local variable, and then use that. That way, it only calls the function once and then uses a static list thereafter. A similar issue can occur when you are consistently calling historical information from observation terms. You really only need to generate the list once, but the system is having to do the work of generating it every time.
This worked perfectly! Thank you. It makes total sense.
Thank you. I did try but it took just as long without sorting it or looking for just users with NPI numbers. I did notice that it pulled the list, which takes a while, each time I selected a name so it did slow it down.