I would like to create a dynamic dropdown list of our users. Any ideas on how to do this?
I use this function to create three lists, one list for all clinical staff, one list for RN's and one for MA's. I declare the document variables in whatever form i use it in and then call the function when the form opens with {!fnSTAFFLIST()}. The job title ID numbers may be unique to our database though, you would have to check your user table and I don't remember the name of it right off hand. Then in your dropdown just check the dynamic dropdown box and in the mel statement write {document.sstaffall} or whichever one you want to use.
{fn fnSTAFFLIST(){
local iTotal = GETROWCOUNT("_UserSearch")
local i = 1
local lusers
global sstaffall = ""
global sstaffrn = ""
global sstaffma = ""
while i < iTotal do
lusers = GETROW("_UserSearch",i,"RealName","JobTitle")
/* Jobtitle 2.00 is for MA position and other is for RN position*/
if (lusers[2] == 2.00) or (lusers[2] == 1114353039000020.00) then
sstaffall = sstaffall + "," + lusers[1]
endif
if (lusers[2] == 1114353039000020.00) then
sstaffrn = sstaffrn + "," + lusers[1]
endif
if (lusers[2] == 2.00) then
sstaffma = sstaffma + "," + lusers[1]
endif
i = i + 1
endwhile
DOCUMENT.SSTAFFMA = sstaffma
DOCUMENT.SSTAFFALL = sstaffall
DOCUMENT.SSTAFFRN = sstaffrn
}}
This is what I have in the form and I am not getting anything in the dropdown. I will assume for now that the ID's are different, and I will find out what they are. Until I find out the id numbers, is there a way to test everything else by pulling in all users?
{!fnSTAFFLIST()}
?
{fn fnSTAFFLIST(){
local iTotal = GETROWCOUNT("_UserSearch")
local i = 1
local lusers
global sstaffall = ""
global sstaffrn = ""
global sstaffma = ""
while i < iTotal do
lusers = GETROW("_UserSearch",i,"RealName","JobTitle")
/* Jobtitle 2.00 is for MA position and other is for RN position*/
if (lusers[2] == 2.00) or (lusers[2] == 1114353039000020.00) then
sstaffall = sstaffall + "," + lusers[1]
endif
if (lusers[2] == 1114353039000020.00) then
sstaffrn = sstaffrn + "," + lusers[1]
endif
if (lusers[2] == 2.00) then
sstaffma = sstaffma + "," + lusers[1]
endif
i = i + 1
endwhile
DOCUMENT.SSTAFFMA = sstaffma
DOCUMENT.SSTAFFALL = sstaffall
DOCUMENT.SSTAFFRN = sstaffrn
}}
This is in the dropdown mel code
{DOCUMENT.SSTAFFALL}
Try this if you want all staff, did you place the function in the whitespace of the form? When I started using this the I had a hard time getting it to call properly and ended up putting the function in a usrlib.txt file, might be the issue... To test that you could put the {fnSTAFFLIST()} in an action button and see if that populates the dropdown.
{fn fnSTAFFLIST(){
local iTotal = GETROWCOUNT("_UserSearch")
local i = 1
local lusers
global sstaffall = ""
while i < iTotal do
lusers = GETROW("_UserSearch",i,"RealName","JobTitle")
sstaffall = sstaffall + "," + lusers[1]
i = i + 1
endwhile
DOCUMENT.SSTAFFALL = sstaffall
}}
It works with a button, and that was my issue to begin with. I will take care of that problem. I do have one slight issue though. It is pulling in users that have been marked as inactive. Is there a way to prevent those from being pulled in? I am also going to try to find out why we inactivate users when they leave instead of deleting them, but in the meantime I would like to exclude those users. Thanks again for your help!
This should do it...
{fn fnSTAFFLIST(){
local iTotal = GETROWCOUNT("_UserSearch")
local i = 1
local lusers
global sstaffall = ""
while i < iTotal do
lusers = GETROW("_UserSearch",i,"RealName","JobTitle","Status")
if (lusers[3] == "A") then
sstaffall = sstaffall + "," + lusers[1]
else "" endif
i = i + 1
endwhile
DOCUMENT.SSTAFFALL = sstaffall
}}
Sorry to jump in late. Does this show the users currently logged in or simpy all users registered in the system with a specific job title?
I created the following so our physicians would see who is actually in the office and coupled it with the MEL_SEND_FLAG functionality.
function
!fn uloggedin(userlist)
{local totalu, count, user1
totalu = getRowCount('_U_Logged_In')
count = 0
results= ""
user1 = ""
while count < totalu
do
user1 = getRow('_U_Logged_In',count,'WSID','LoginName')
if match(userlist,user1[2])>0 then
results=results+user1[2]+","
endif
count = count +1
endwhile
return results}
Dynamic list box that populates the DOCUMENT.SCHEDULERS variable
{uloggedin("user1user2user3user4user5user6")} /user1user2user3 is exchanged for actual usernames to parse
action button
MEL_SEND_FLAG("Flag",DOCUMENT.SCHEDULERS, "Normal", str(._todaysdate), "","Therapy order", "Orders")
The list box works perfectly and the send flag work perfectly, my problem is once the SEND_FLAG functionality is envoked. All of our orders(for the rest of the day) that are entered using the MEL_ADD_ORDER symbol have a authorizing provider of our Administrative assistant, not the ordering provider.
My physicians wanted to know who was actively in the office, not at lunch or on a break.
It does help to give them that information, it would be nice if it didn't break our orders.
Has anyone else experienced this with the MEL_SEND_FLAG and MEL_ADD_ORDERS. It does not appear to be related to the mel defs _u_logged_in call.
Thanks,
Tom
Tom, another late jump in I would think that possibly there is maybe a variable name conflict. You might try changing your variable names to something that couldn't possibly have been used before and see if that does anything.
David Shower
OU Tulsa School of Community Medicine
Not sure if it's related or not, but there's some known issues with user information updating appropriately in the db. For ex: if a user is inactivated in Administration, the dbo.USR table does not update the STATUS column. So even though the user is inactive if you look in Administration>User Management, the name is still available in the chart for routing, document provider, etc.
You may just check the tables to see if the users are actually inactive in the database...
Thanks for the input. I've tried using this is a form all by itself.
Two action buttons, MEL_SEND_FLAG and the second is a MEL_ADD_ORDER.
The order comes back as a different user not even provider even though I've hard coded the provider username in the MEL_ADD_ORDER field 10.
These users are still active as they are still employed. 🙂 But our office administrator does not have any document signing privileges. There isn't a specific privilege for orders for me to disable. It originally started with our business manager being the authorizing provider (who never/seldom works in the EMR) and now our administrative assistant is who the order is populated with. Something to do the the _usersearch I believe from the DB trace during the event.
Thanks again for taking a look.