I'm using a function I found on CHUG to create a Problem list dropdown, and I'm not sure how to exclude uncoded problems from the dropdown, or problems where the ICD-9 is Null.
{!fn fnProbList(strList)
{
local lCounter
local lProbArray
local lStart
local lBuffer
local lFormattedList = ""
/* Create array of medications */
lProbArray = getfield(strList, "|", "")
for lCounter = 1, lCounter <= size(lProbArray), lCounter = lCounter + 1 do
/* Create array for each medication */
lProbArray[lCounter] = getfield(lProbArray[lCounter], "^", "")
/* Need to remove commas from problem name */
lBuffer = ReplaceStr(lProbArray[lCounter][2], ",", ";")
/* Append problem and ICD-9 code to formatted list */
lFormattedList = lFormattedList + lBuffer + "^" + lProbArray[lCounter][3] + ","
endfor
/* Remove trailing comma */
if (lCounter > 1) then
lFormattedList = remove(lFormattedList, size(lFormattedList))
endif
/* Return comma separated list */
return (lFormattedList)
}}
Thank you!
Using the delimited type of a data symbol (ie prob_after("delimited")), you'll need to confirm that the field specific to the ICD-9 contains a code. In this example it's the third field:
{!fn fnProbList(strList)
{
local lCounter
local lProbArray
local lStart
local lBuffer
local lFormattedList = ""
/* Create array of medications */
lProbArray = getfield(strList, "|", "")
for lCounter = 1, lCounter <= size(lProbArray), lCounter = lCounter + 1 do
/* Create array for each medication */
lProbArray[lCounter] = getfield(lProbArray[lCounter], "^", "")
/*Confirm coded problem */
if lProbArray[lCounter][3] <> "" then
/* Need to remove commas from problem name */
lBuffer = ReplaceStr(lProbArray[lCounter][2], ",", ";")
/* Append problem and ICD-9 code to formatted list */
lFormattedList = lFormattedList + lBuffer + "^" + lProbArray[lCounter][3] + ","
else ""
endif
endfor
/* Remove trailing comma */
if (lCounter > 1) then
lFormattedList = remove(lFormattedList, size(lFormattedList))
endif
/* Return comma separated list */
return (lFormattedList)
}}