fn fnGetProblemCodes()
{
local lCounter
local lSize
local lResult = str("")
local lProblemList = getfield(DOCUMENT.PROBLEMS, ",", "") /* Get selected problems and separate into array by commas */
lSize = size(lProblemList) /* Determine size of array */
for lCounter = 1, lCounter <= lSize, lCounter = lCounter + 1 do /* Loop through all rows of the array */
lProblemList[lCounter] = getfield(lProblemList[lCounter], "^", "") /* Separate problem description and code */
lResult = lResult + lProblemList[lCounter][2] + "|"/* Join codes into a string separated by pipes */
endfor
if (lResult <> "") then
lResult = remove(lResult, size(lResult)) /* Remove trailing pipe (|) */
endif
}
fn fnGetProblemDescriptions()
{
local lCounter
local lSize
local lResult = str("")
local lProblemList = getfield(DOCUMENT.PROBLEMS, ",", "") /* Get selected problems and separate into array by commas */
lSize = size(lProblemList) /* Determine size of array */
for lCounter = 1, lCounter <= lSize, lCounter = lCounter + 1 do /* Loop through all rows of the array */
lProblemList[lCounter] = getfield(lProblemList[lCounter], "^", "") /* Separate problem description and code */
lResult = lResult + lProblemList[lCounter][1] + "|"/* Join descriptions into a string separated by pipes */
endfor
if (lResult <> "") then
lResult = remove(lResult, size(lResult)) /* Remove trailing pipe (|) */
endif
}
!fn fnProblemList2(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] + "; " + lProbArray[lCounter][8] + "), " endfor
/* Remove trailing comma */
if (lCounter > 1) then
lFormattedList = remove(lFormattedList, size(lFormattedList))
endif
/* Return comma separated list */
return (lFormattedList)
}
show an example of your MEL_ADD_ORDER statement. That would help put this in context.
Here it is:
{IF (DOCUMENT.CCM)<>"" then
MEL_ADD_ORDER("S", "CCM", "Chronic Care Management", "", fnGetProblemCodes(), fnGetProblemDescriptions(), "", "", "", fnSrvPhys(DOCUMENT.AUTH_PROV), "")
else ""
endif
}
Shouldn't you be returning 'lResult' in both the fnGetProblemCodes and fnGetProblemDescriptions?
Assuming that the 'guts' of the function is working and you can see it work. Then it might not be actually returning anything.
local pCodeList=""
local pDescList = ""
local thisProv=""
local sRet=""
IF (DOCUMENT.CCM)<>"" then
pCodeList=fnGetProblemCodes()
pDescList = fnGetProblemDescriptions()
thisProv=fnSrvPhys(DOCUMENT.AUTH_PROV)
sRet = MEL_ADD_ORDER("S", "CCM", "Chronic Care Management", "", pCodeList, pDescList, "", "", "",thisProv, "")
else ""
endif
Do pCodeList, pDescList, thisProv have values?
Do pCodeList and pDescList have the same number of items ?
What error code is sRet returning ?
0=success; otherwise Should be one of:
-1 : Invalid Order Type
-2 : Invalid order category
-3 : Invalid Description
-4 : Order obsolete
-5 : Invalid Diagnosis Code
-6 : Comments field too long
-7 : Invalid Priority
-8 : Invalid or obsolete authorizing provider
-9 : Invalid order date
-10: Invalid Modifier
-11: Additional information is required for this order
-12: Unequal number of diagnosis codes and diagnosis code descriptions
-13: Invalid quantity or units