Anyone seeing a BAD INDEX error in the Lab result section of their CVS?
this is what is formatted in this section this was from the original CVS
Labs and Tests received in the past 3 days:
{fn fnCVS_LabTestResults()
{local list = ""
local sz, i, dt, tody, lab, dtbegin, dur
local lablist
local labs = GET_FLOWSHEET_VALUES('Enterprise\Interfaces\CCD\Diagnostic Results')
if labs <> "" then
lablist = getfield(labs, "\n", "")
sz = 0+size(lablist)
for i = 1, i <= sz, i = i + 1 do
dt = ""
tody = str(._todaysdate)
lab = lablist[i]
if size(lab) > 0 then
dtbegin = match( lab,"/") -2
dt = sub(lab, dtbegin, 10)
dur = durationdays(dt, tody)
if dur < 4 then
list = list + lab +"\r\n"
else
list = list
endif
else
list = list
endif
endfor
if list == "" then list ="No lab results." endif
else
list="No lab results."
endif
return list
}}{fnCVS_LabTestResults()}
Try this:
{fn fnCVS_LabTestResults()
{
local list = ""
local sz, i, dt, tody, lab, dtbegin, dur
local lablist
local labs = GET_FLOWSHEET_VALUES('Enterprise\Interfaces\CCD\Diagnostic Results')
if labs <> "" then
lablist = GETFIELD(labs, "\n", "")
sz = 0 + SIZE(lablist)
for i = 1, i <= sz, i = i + 1 do
dt = ""
tody = STR(._TODAYSDATE)
lab = lablist[i]
if SIZE(lab) > 0 then
dtbegin = MATCH(lab, "/") - 2
if dtbegin > 0 then // skip if '/' in obs value
dt = SUB(lab, dtbegin, 10)
dur = DURATIONDAYS(dt, tody)
if dur < 4 then
list = list + lab + "\r\n"
endif
endif
endif
endfor
if list == "" then
list = "No lab results."
endif
else
list = "No lab results."
endif
return list
}
}{fnCVS_LabTestResults()}
This will skip an obs value if there is a '/' in it. You could do a second match at the point where I've commented to skip around the first '/' to get to the date.