Hello!
I have code which returns all orders that contain a wildcard so that the end-user can view a specific type of order (e.g. Assistive Devices). The code below returns ONLY the last documented order. Does anyone know or see where in the code this is occurring? Also, any idea of what is going on in the commented out segment?
CODE
/*To get the Active Order list*/
!fn fnOrderListADA(strList)
{
local i
local OrderList
local nStart
local strBuf
local strFormattedList = ""
OrderList = getfield(strList, "|", "")
for i = 1, i <= size(OrderList), i = i + 1 do
OrderList[i] = getfield(OrderList[i], "^", "")
/* Need to remove commas from order name */
strBuf = OrderList[i][1] + " - " + OrderList[i][8]
strBuf = ReplaceStr(strBuf, ",", ";")
if (match(OrderList[i][1], 1, "Assistive Device ") > 0) then
/*for j = 1, j <= 26, j = j + 1 do
strBuf = j + OrderList[i][j] + " - " + OrderList[i][j]
strBuf = ReplaceStr(strBuf, ",", ";")
strFormattedList = strFormattedList + strBuf + ","
endfor*/
strFormattedList = strBuf
endif
endfor
if (i > 100) then
strFormattedList = remove(strFormattedList, size(strFormattedList))
endif
return (strFormattedList)
}
REFERENCE IN DATA DISPLAY
{fnOrderListADA(ORDERS_PRIOR("delimited"))}
If I had to guess, it is overwriting your strFormattedList variable every time that it finds and order.
Try to replace this: strFormattedList = strBuf
with this:
strFormattedList = strFormattedList +", " + strBuf
I haven't tested it on my end, but this should put you on the right track hopefully.
-James Caswell
That worked. THANKS!
Do you know how to show every instance that 99387 and 99397 was ordered in the last year? Its only showing most recent, but I figure it has to be a simple tweak. Below is the function and this is what I have in the data display:
getOrder("99387") + " " + getOrder("99397")+
{fn getOrder(cptcode){
results = ""
orderArray = getfield(ORDERS_ALL("delimited"),"|","")
for c = 1, c 0 and durationdays(orderArray[c][4], str(._todaysdate)) < 731
then results = " " + orderArray[c][1] + ", " + orderArray[c][4] + ", " + orderArray[c][21]
endif endif
endfor
return results
}}
thanks!