So i'm wondering if other users have experienced this and have a solution. When using replacestr to remove a comma and add it back there is no is doing so on a dropdown list, but on a listbox when choosing one of these with a comma the check sometimes doesn't stick and always falls off when selecting another choice. This wouldn't typically be an issue because I would just make it a "-" instead, but for this particular instance I need the comma there so the selected choice can pass through to the orders module. So i could change the choice in our custom list and just remove the commas and add a dash, but before I embarked on that task I was wondering if there is a solution to my little bug here. here's the particular piece I use: ReplaceStr(onep[2],",","\,")
Any advice is greatly appreciated!
As a matter of policy I don't use commas in order descriptions for precisely this reason. Where it unavoidable like the problem list I use replacestr(variable,",",";") to keep the commas out. There isn't a reliable way to go back but if I need to, like for MEL_ADD_ASSESSMENT(), I can fetch the exact description based on a matching ICD9 or ICD10 code that is attached to it. Hope that helps....
A long standing challenge and I agree, using '\,' can prove to be unreliable, though it should work for a dropdown list (it fails in other lists for different reasons).
Typically, I will change "," to either " -" (note the leading space) or "~" with replace string while handling data within the code (non-client facing). When it comes time to switch back, I simply put another replacestr statement with the characters swapped in front of the system facing code (ie. add problem or add order).
Note: I formerly used ';' and '-' but increasingly, these characters are appearing in data that I need to list so a non-standard character is really required. Since your need is client facing and if the '~' character is 'bothersome' to your users, turn to the ASCII Table for an alternative:
For example: replacestr(variable,",",numtoascii(130))
ASCII 130 is a 'single low 9 quotation mark' which the EMR does not see as a quotation mark. It shows up as '‚' which is different from the comma to the EMR, so it is often more aesthetically appealing to the users.
So now you have a unique character that you can swap in and out as a standard. Do it enough, and it will become automatic. 🙂
Lee - so the numtoascii(130) seems to do the trick thank you! Have you noticed it issue with this? It's seems to pass the dx and order on some (could always be user error by me) to the order module on the few test I've done.
There should be no issue with it if you convert it back before using the variable in MEL_ADD_ORDER. For example, if your Diagnosis variable is 'strDx', you would use:
strDx = replacestr(strDx,numtoascii(130),",")
You then would plug strDx into the MEL_ADD_ORDER in the appropriate location. The new strDx should be returned to the 'original characters'.
Of course, if you feel this may be an issue in your organization due to ASCII 130 being used elsewhere (I have yet to find it in use by the EMR), then you could choose a different ASCII character. The main goal here is to use a non-standard character the EMR accepts as the comma replacement. Doing so ensures that intentional characters won't be inadvertently replaced when converted back. For example, semi-colon does the same trick, but there is a high probability that a semi-colon would be used in the string, which makes it a poorer choice as a temporary replacement.
So here's what i'm currently using
{!fn LoadProblemListBox(prob_after){
local plist = ""
local parray = getfield(prob_after,"|","")
local psize = size(parray)
for countl = 1, countl <= psize, countl = countl + 1 do
local onep = getfield(parray[countl],"^","")
local tempp = ReplaceStr(onep[2],",","\,")
if plist = "" AND onep[1] == "Dx of" then
plist = tempp
else if plist <> "" and onep[1] == "Dx of" then plist = plist + "," + tempp
else ""
endif
endif
endfor
plist}}
Do I need to Have this line: local tempp = ReplaceStr(onep[2],",","\,")
Read: local tempp = ReplaceStr(onep[2],numtoascii(130),",") ?
What my form is doing is pulling the prob list, order list by custom order list. User can select there diagnosis, select there order, and click a button that will add for x amount of time over x amount of months/occurrences.
Here' s acutally the bare bones of the pulling and passing taking place:
{!fn LoadOrderListBox(customlist){
local folist = ""
local oarray = getfield(ORDER_CUST_LIST(customlist),"|","")
local osize = size(oarray)
for counto = 1, counto <= osize, counto = counto + 1 do
local oneord = getfield(oarray[counto],"^","")
local tempord = ReplaceStr(oneord[2],",","\,")
if (folist == "" and oneord[1] <> "R" and oneord[1] <> "H" and oneord[1] <> "P") then
folist = tempord
else if (oneord[1] <> "R" and oneord[1] <> "H" and oneord[1] <> "P") then
folist = folist + "," + tempord
else ""
endif
endif
endfor
return folist}}
{!fn LoadProblemListBox(prob_after){
local plist = ""
local parray = getfield(prob_after,"|","")
local psize = size(parray)
for countl = 1, countl <= psize, countl = countl + 1 do
local onep = getfield(parray[countl],"^","")
local tempp = ReplaceStr(onep[2],",","\,")
if plist = "" AND onep[1] == "Dx of" then
plist = tempp
else if plist <> "" and onep[1] == "Dx of" then plist = plist + "," + tempp
else ""
endif
endif
endfor
plist}}
{!fn get_dx(sproblem,pos){
local dxlist = ""
local dxarray = getfield(PROB_AFTER("delimited"),"|","")
local dxsize = size(dxarray)
for countp = 1, countp <= dxsize, countp = countp + 1 do
local onedx = getfield(dxarray[countp],"^","")
if match(sproblem,onedx[2]) > 0 then
dxlist = dxlist + "|" + onedx[pos]
else ""
endif
endfor
if dxlist <> "" then local fdxlist = remove(dxlist,1,1) else "" endif
fdxlist}}
/*1 month*/
{fn add_1_month_order(clist,sorder,sprob,comment,sdate){
local ordera = getfield(ORDER_CUST_LIST(clist),"|","")
local ordersz = size(ordera)
for counta = 1, counta <= ordersz, counta = counta + 1 do
local oneorder = getfield(ordera[counta],"^","")
if match(sorder,oneorder[2]) > 0 then
/*MEL_ADD_ORDER(oneorder[1],oneorder[4],oneorder[2],"",get_dx(sprob,3),get_dx(sprob,2),comment,"","","",ADDDATES(str(._TODAYSDATE), "0", "0", "0"))*/
MEL_ADD_ORDER(oneorder[1],oneorder[4],oneorder[2],"",get_dx(sprob,3),get_dx(sprob,2),comment,"","","",ADDDATES(str(._TODAYSDATE), "0", "1", "0"))
else ""
endif
endfor
return blank}}
Your original function:
{!fn LoadProblemListBox(prob_after)
{
local plist = ""
local parray = getfield(prob_after,"|","")
local psize = size(parray)
for countl = 1, countl <= psize, countl = countl + 1 do
local onep = getfield(parray[countl],"^","")
local tempp = ReplaceStr(onep[2],",","\,")
if plist = "" AND onep[1] == "Dx of" then
plist = tempp
else
if plist <> "" and onep[1] == "Dx of" then
plist = plist + "," + tempp
else ""
endif
endif
endfor
plist
}
}
Modified version:
{!fn LoadProblemListBox(prob_after)
{
local plist = ""
local parray = getfield(prob_after,"|","")
local psize = size(parray)
local countl
local onep = ""
local tempp = ""
for countl = 1, countl <= psize, countl = countl + 1 do
onep = getfield(parray[countl],"^","")
tempp = ReplaceStr(onep[2],",",numtoascii(130))
cond
case plist = "" AND onep[1] == "Dx of" plist = tempp
case plist <> "" and onep[1] == "Dx of" plist = plist + "," + tempp
else ""
endcond
endfor
return plist
}
}
A few notes:
- Be careful when declaring local variables inside a loop - it can be unpredictable.
- When using a variable that has not been declared as local, it will become global to the update. Note that you are not localizing the countl variable.
- Use caution when mixing MEL with MEL shorthand, it can get you into trouble. i.e. ending the function with just 'plist' instead of 'return plist'.
Wow thank you! I'm not a programmer by nature so styles and standards have never been my thing, but I'll be sure to use these as rules going forward. They seemed to of fixed an issue I was having with that form, where the initial click of a button tied to the function wouldn't fire now it's firing regularly.