Okay all. I need to pull the last assessment recorded on a problem being picked from a dropdown list.
I have the following and it pulls what I want except that it pulls all assessments. I need to have it only pull the last assessment. Anyone have an idea?
!fn fnImpPlanGetAssessments2(strProblemName)
{
local lCounter
local lIndex
local lSize
local lRowID
local lAssessmentList = ""
local lProblemType = ""
local lBuffer
if (strProblemName == "") then
return ("")
endif
/* Generate problem list array */
local lProblemArray = getfield(PROB_AFTER("delimited"), "|", "")
lSize = size(lProblemArray)
for lIndex = 1, lIndex <= lSize, lIndex = lIndex + 1 do
lProblemArray[lIndex] = getfield(lProblemArray[lIndex], "^", "")
/* Verify that problem name is same as list box */
lBuffer = lProblemArray[lIndex][2]
/* Convert problem type to appropriate format */
lProblemType = fnConvertProblemTypeToString2(lProblemArray[lIndex][1], FALSE)
/* Add prefix */
lBuffer = lProblemType + lBuffer
/* If they do not match go to next entry */
if (match(strProblemName, lBuffer) == 0) then
continue
endif
/* Problem is found. Get assessments */
lRowID = fnGetProblemRowID2(lProblemArray[lIndex][5], lProblemArray[lIndex][1], lProblemArray[lIndex][2])
lAssessmentList = fnGetProblemAssessments3(lRowID)
return (lAssessmentList)
endfor
return ("")
}
Ernie, here is a function I have for getting the last assessment:
{fn get_last_assessments()
{
local aPD,cPD,ePD
ePD = 0
local iPD = getRowCount('Assessments')
while iPD > 0 do
iPD = iPD-1
aPD = getRow('Assessments',iPD,'SDID')
cPD=aPD
if cPD > ePD then
ePD =cPD
else
""
endif
endwhile
local aP,cP
cP = fmt("Problems discussed at your last visit:","B") + HRET
local iP = getRowCount('Assessments')
while iP > 0 do
iP = iP-1
aP = getRow('Assessments',iP,'SDID','ANNOTATE','SPRID')
if aP[1] = ePD then
cP=cP + get_prob_from_sprid(aP[3]) + HRET + "Assessment: " + aP[2] + HRET
else
""
endif
endwhile
if cP=="" then return "None entered" else "" endif
return str(cP)
}}
{get_last_assessments()}{fn get_prob_from_sprid(passedsprid)
{
passedsprid = replacestr(passedsprid,".00","")
local aSP, cSP
local iSP = getRowCount('_MasterProb')
while iSP > 0 do
iSP = iSP-1
aSP = getRow('_MasterProb',iSP,'SPRID','DESCRIPTION')
if aSP[1] = passedsprid then
cSP=aSP[2]
else
""
endif
endwhile
return cSP
}}
I have that one also david and it works great to pull all of the last assessments, but I am looking for it to pull the assessment based off a drop down list to be able to populate a edit box.
I have tried to adept this function to work but either it pulls all of them or nothing. Thanks for the function anyway.
This combo does get the last visit assessment - you should be able to modify it to narrow it down to a passed
{fn get_last_assessments()
{
local aPD,cPD,ePD
ePD = 0
local iPD = getRowCount('Assessments')
while iPD > 0 do
iPD = iPD-1
aPD = getRow('Assessments',iPD,'SDID')
cPD=aPD
if cPD > ePD then
ePD =cPD
else
""
endif
endwhile
local aP,cP
cP = "Assessed Problems from last visit:" + HRET
local iP = getRowCount('Assessments')
while iP > 0 do
iP = iP-1
aP = getRow('Assessments',iP,'SDID','ANNOTATE','SPRID')
if aP[1] = ePD then
cP=cP + get_prob_from_sprid(aP[3]) + HRET + "Assessment: " + aP[2] + HRET
else
""
endif
endwhile
if cP=="" then return "None entered" else "" endif
return str(cP)
}}
{get_last_assessments()}
{fn get_prob_from_sprid(passedsprid)
{
passedsprid = replacestr(passedsprid,".00","")
local aSP, cSP
local iSP = getRowCount('_MasterProb')
while iSP > 0 do
iSP = iSP-1
aSP = getRow('_MasterProb',iSP,'SPRID','DESCRIPTION')
if aSP[1] = passedsprid then
cSP=aSP[2]
else
""
endif
endwhile
return cSP
}}
Hi David,
I copied that exact text into my MEL worksheet and left a data display with the MEL expression { get_last_assessments } inside of the data display. Somehow, it still isn't working. Do you know what I am doing wrong?
Thanks much!
I whipped up this little form. At the top is a drop down that lists PROB_AFTER(). I rewrote get_last_assessments to take a parameter. The top data display is the get_last_assessments() function with no parameters. The bottom data display will use the problem selected in the drop down and show the assessment for that problem from the last visit (if it exists). Hope this helps.