Si I'm trying to make a dynamic choice drop down that pulls users with the role of Physician into a drop down in which users can select with the providers NPI beside it. I'm trying to use a function that wroks with most getfield type of thing (meds,probs,orders) but I can't seem to get it to work with this. Here's what I got so far:
{!fn GetProvName() {
local hold = GET_USER_LIST("PHYSICIA","Physicians","delimited")
local temp
local rslt = ""
for i = 1, i <= size(hold), i = i + 1 do
temp = getfield(hold[i], "^", "")
if (rslt <> "") then
rslt = rslt
endif
rslt = temp[2]
endfor
return rslt
}}
This gives me a blank dropdown. Any suggestions?
I reworked the code (had some minor errors in processing) and it seems to work. here is the function.
{!fn GetProvName() {
local hold = getfield(GET_USER_LIST("ALL","Centricity_Providers","delimited"),"|","")
local temp = ""
local rslt = ""
for i = 1, i <= size(hold), i = i + 1 do
temp = getfield(hold[i], "^", "")
temp[2] = replacestr(temp[2],",","\,")
if (rslt <> "") then
rslt = rslt + "," + temp[2]
else
rslt = temp[2]
endif
endfor
return rslt
}}
The key factor is to make sure that the GET_USER_LIST(LOC, roles,list_type) code is returning values. I found that if I had the wrong LOC or roles, the function would return a blank.
Double check your roles by going to:
Administration ->
System ->
User and Resource Management - >
Users ->
Security ->
Security Groups
The security groups are what the roles section is looking for. When I used "Physician", I got a blank list, but changing it to "Centricity_Providers" gave me a list of all my providers in that security group.
You can always add more logic to specify what kind of providers to return based on job-title, but this should get you started. Let me know if you need any further help with it.
dcarpenter, Thanks! I think this uncovered my real issue, so we have providers roles as: "Physician (MD, DO, PA-C, NP)" this seems to break the funtion, because If I use a role that doesn't have a comma or a special character such as "Radiolologist" I get results.
My end goal to all of this is to pull the list with the name and the NPI. My other option is a long If then statement which I dread going down that route.
I definitely understand the pain of endless if statements. before you give up on this route, try using this modified code. I added the role you gave me, and appended the NPI number to each providers name. The backslashes before each comma should make the code recognize it as one role.
{!fn GetProvName() {
local hold = getfield(GET_USER_LIST("ALL",""Physician (MD\, DO\, PA-C\, NP)"","delimited"),"|","")
local temp = ""
local rslt = ""
for i = 1, i <= size(hold), i = i + 1 do
temp = getfield(hold[i], "^", "")
temp[2] = replacestr(temp[2],",","\,")
if (rslt <> "") then
rslt = rslt + "," + temp[2] + " " + temp[9]
else
rslt = temp[2] + " " + temp[9]
endif
endfor
return rslt
}}
Also, I noticed that some of my providers did not have their NPI listed in this code, even though they have one in Administration. If you see the same issue (some providers with NPI, some without) please let me know and I will let GE know it is an issue on other client's software.
Thank you,
For this line local hold = getfield(GET_USER_LIST("ALL",""Physician (MD\, DO\, PA-C\, NP)"","delimited"),"|","") do the quad quates need to be there enclosing the role?
I got to be missing something:
{!fn GetProvName(){
local hold = getfield(GET_USER_LIST("PHYSICIA",""Physician (MD, DO, PA-C, NP)"","delimited"),"|","")
local temp = ""
local rslt = ""
for i = 1, i <= size(hold), i = i + 1 do
temp = getfield(hold[i], "^", "")
temp[2] = replacestr(temp[2],",","\,")
if (rslt <> "") then
rslt = rslt + "," + temp[2] + " " + temp[9]
else
rslt = temp[2] + " " + temp[9]
endif
endfor
return rslt
}}
Tried with the ""Physician (MD, DO, PA-C, NP)"" and "Physician (MD, DO, PA-C, NP)" still a blank dropdown yet once again I use a role that doesnt have , or () I get the users.
Whoops! the quad quotes should not be there. darn typos! my apologies. The line should look like this:
{!fn GetProvName(){
local hold = getfield(GET_USER_LIST("PHYSICIA","Physician (MD\, DO\, PA-C\, NP)","delimited"),"|","")
local temp = ""
local rslt = ""
for i = 1, i <= size(hold), i = i + 1 do
temp = getfield(hold[i], "^", "")
temp[2] = replacestr(temp[2],",","\,")
if (rslt <> "") then
rslt = rslt + "," + temp[2] + " " + temp[9]
else
rslt = temp[2] + " " + temp[9]
endif
endfor
return rslt
}}
you can stick this line into a quick text, and if it gives you results, then the function will work.
{GET_USER_LIST("PHYSICIA","Physician (MD\, DO\, PA-C\, NP)","delimited")}
I get the {GET_USER_LIST("PHYSICIA","Physician (MD\, DO\, PA-C\, NP)","delimited") <-BAD VALUE OR BAD INDEX error
So that's what I was getting before. I wonder why centricity is having a hard time evaluating those characters.
I think I have the Answer! try replacing the location of care "PHYSICIA" with "ALL". (or if you renamed the folder that holds all of your locations of care, change the name to that LOC. ours is ALL)
if you get results, then it is a bad LOC in that field. I was able to get a blank list (which means the code ran) using your role with all the commas, but changing the LOC. when I used PYSHICIA, it gave me the bad value or index error.
give this a whirl in your quicktext:
{GET_USER_LIST("ALL","Physician (MD\, DO\, PA-C\, NP)","delimited")
good luck!
PHYSICIA is our ALL, I'll keep messing with it I'm just stumped, like I was saying above I can swap the role to any other role and it works fine. I'm copying the role straight off the setup in centricity. Thanks for this piece, i've been messing with GET_USER_LIST for awhile and haven't gotten it right! So you can imagine my relief.
Glad I can be a fellow sufferer with ya. 🙂
My best guess on this is that the commas are throwing the code off. If you had 3 security groups: MA,NURSE and PA-C, you could get all 3 groups of users by writing the code like this:
{GET_USER_LIST("PHYSICIA","MA,NURSE,PA-C","delimited")}
If you guys are able to, changing the security role for providers to a name without comma's might be the fix. Especially since you said it was working on other specialties without commas.
If that is not an option, you'll have to get everyone in the clinic and sort them by job title. not impossible, but not quite as easy.
Have a great Friday!
Any thoughts on getting function to work in VFE? I think only comma separated values will work.