Here are two functions I use to call Providers from patient contacts and pharmacy from patient contacts. I didn't update the comments for the provider one (it is modified from the pharmacy one) so if they don't make sense thats why, but they work for me on CPS 10.1.1.189
{fn fnProvLists(){
local lCounter
local lPharArray
local lStart
local lBuffer
local lFormattedList = ""
local l_FormattedList = ""
local StrList
local Resarray
StrList = str(PATIENT.CONTACTS)
/* Create array of Phar */
lPharArray = getfield(strList, "|", "")
for lCounter = 1, lCounter <= size(lPharArray), lCounter = lCounter + 1 do
/* Create array for each Phar */
lPharArray[lCounter] = getfield(lPharArray[lCounter],"^","")
/* Need to remove commas from Med name */
/*lBuffer = ReplaceStr(lPharArray[lCounter][2], ",", " ")*/
/* Append Med and ICD-9 code to formatted list */
if (match(lPharArray[lCounter],"Provider")>0) then
lFormattedList = lFormattedList + lPharArray[lCounter][1] + ","/* + hret + lPharArray[lCounter][5] + hret + lPharArray[lCounter][7] + ", " + lPharArray[lCounter][8] + " " + lPharArray[lCounter][9]*/
else "" endif
endfor
/* Remove trailing comma */
if (lCounter > 1) then
lFormattedList = remove(lFormattedList, size(lFormattedList))
endif
Resarray = getfield(lFormattedList,",","")
for j = 1, j <= size(Resarray), j = j+2 do
l_FormattedList = l_FormattedList + Resarray[j + 1] + " " + Resarray[j] + ","
endfor
/* Remove trailing comma */
if (lCounter > 1) then
l_FormattedList = remove(l_FormattedList, size(l_FormattedList))
endif
/* Return comma separated list */
return (l_FormattedList)
}}
{fn fnPharLists(){
local lCounter
local lPharArray
local lStart
local lBuffer
local lFormattedList = ""
local StrList
StrList = str(PATIENT.CONTACTS)
/* Create array of Phar */
lPharArray = getfield(strList, "|", "")
for lCounter = 1, lCounter <= size(lPharArray), lCounter = lCounter + 1 do
/* Create array for each Phar */
lPharArray[lCounter] = getfield(lPharArray[lCounter],"^","")
/* Need to remove commas from Med name */
/*lBuffer = ReplaceStr(lPharArray[lCounter][2], ",", " ")*/
/* Append Med and ICD-9 code to formatted list */
if (match(lPharArray[lCounter],"Pharmacy")>0) then
lFormattedList = lFormattedList + lPharArray[lCounter][1] + hret + lPharArray[lCounter][5] + hret + lPharArray[lCounter][7] + ", " + lPharArray[lCounter][8] + " " + lPharArray[lCounter][9]
else "" endif
endfor
/* Remove trailing comma */
if (lCounter > 1) then
lFormattedList = remove(lFormattedList, size(lFormattedList))
endif
/* Return comma separated list */
return (lFormattedList)
}}
Posted : October 2, 2012 5:28 am