Does anyone out there know of a function that will pull an alphabetized list of the patient's meds into a dropdown list or listbox?
Refer to the "sort" function in the Help file, this should get you started. The bigger question is "Why". The user can easily sort the array into most relevant, or alphabetical within the UI.
Please contact me if you would like to see the code for the above.
Thanks John. 🙂 Very helpful. Actually in the version of Centricity that we currently have (9.8 C-EMR), we don't have sort capabilities on the problems and meds lists.
This will pull the med list:
!fn fnFormatFormList(strList)
{
strList = getfield(strList, ",", "")
strList = str(strList, "\,")
strList = getfield(strList, "^", "")
strList = str(strList, "")
strList = getfield(strList, "|", "")
strList = str(strList, ",")
}
/*To get the Active Med list*/
!fn fnMedList(strList)
{
local i
local MedArray
local nStart
local strBuf
local strFormattedList = ""
MedArray = getfield(strList, "|", "")
for i = 1, i <= size(MedArray), i = i + 1 do
MedArray[i] = getfield(MedArray[i], "^", "")
/* Need to remove commas from medication name */
strBuf = tolower(MedArray[i][1])
strBuf = set(strBuf, 1, toupper(get(strBuf, 1))) + " " + MedArray[i][7]
strBuf = ReplaceStr(strBuf, ",", ";")
strFormattedList = strFormattedList + strBuf + ","
endfor
if (i > 1) then
strFormattedList = remove(strFormattedList, size(strFormattedList))
endif
return (strFormattedList)
}
This goes in your dropdown or listbox:
{fnMedList(MEDS_AFTER("delimited"))}
I've never tried sorting with this function, but I'd imagine it's possible. Hope this helps.
Thought I would add this piece here just case your still working on a sort.
{!fn xGrabMeds() {
local temp = getfield(MEDS_AFTER("delimited"), "|", "")
local hold
local rslt =""
for i=1, i<=size(temp),i=i+1 do
hold = getfield(temp[i],"^","")
if hold[1] <> "" then
if rslt <> "" then
rslt = rslt + hret
endif
rslt = rslt + hold[1] + hold[7] + ","
endif
endfor
return rslt
}}
This is also one of my most used pieces. Just swap out the MEDS_AFTER with any symbol and enjoy. The hold[1] and hold[7] grab the area between the ^ if you where to use a given symbol in a chart as a quicktext.
I tried Adam's fnMedList(strList) in a drop down with a dynamic choice list on a test form and it worked great. And to get the data to sort alphabetically all I had to add was the line
sort(MedArray)
after the line
MedArray = getfield(strList, "|", "")
This worked on the EMR Evaluation version which is the equivalent of EMR 9.8 service pack 9.
Here's the little quick and dirty test form