I'm using VFE to pull a list of procedures for booking surgeries. I'm using a listbox field to display all the different procedures with the CPT code in front of the description and attaching that to a document variable (DOCUMENT.TRIGEMINAL_NEURALGIA) and in the function view attaching it to an obs term as well. The choice list looks like this:
61458 - MVD,61781 - Stealth,62140 - Cranioplasty up to 5mm,61798 - Radiosurgery
If the provider chooses both the MVD and Radiosurgery procedures, then both of these will also go to the obs term PROCEDUREDONE like this: 61458 - MVD, 61798 - Radiosurgery (a comma separated list)
I now have a request to pull those same procedures onto a consent form without the CPT codes. So I'm thinking I will need to attach them to a different obs term with the codes extracted out somehow. I have tried {remove(DOCUMENT.TRIGEMINAL_NEURALGIA,1,8)} but that only removes the first CPT code in the list resulting in MVD, 61798 - Radiosurgery. You can see the procedure after the comma still has the CPT code.
Any help with removing all CPT codes from the selection is greatly appreciated.
Thanks,
Crystal Price
You are almost there.
Loop through the list and use your remove statement on each loop iteration. You might want to check for the presence of " - " before doing so, however. You will also want to account for the extra space after the comma in your remove statement.
I am not good with loops, but I tried to do a while loop to accomplish this, but I'm obviously off because when trying it in a data display CPS crashes. Any way you can look at my loop to see what I'm doing wrong?
I'm thinking the below code says while document.trigeminal_neuralgia has a dash in it, keep removing. Obviously the positions will not be the same for each procedure, but I'm stuck here. Please help?
{
while match(DOCUMENT.TRIGEMINAL_NEURALGIA,"-")>0
do
remove(DOCUMENT.TRIGEMINAL_NEURALGIA,1,8)
endwhile
}
Try the following. Note: The function assumes that the character count to be removed will always be 8 characters. You should add more code if this is not the case.
Call the function with the following (you can use it as is to return a value or assign it to a variable or obsterm):
{fnRemoveCPT(DOCUMENT.TRIGEMINAL_NEURALGIA)}
The function:
{! fn fnRemoveCPT(strList)
{
local retStr = ""
local strTemp = ""
local strBuf = ""
local i
strTemp = getfield(strList,",","")
for i = 1, i <= size(strTemp), i = i + 1 do
if match(strTemp[i]," ") == 1 then
strTemp[i] = sub(strTemp[i],2)
endif
if match(strTemp[i]," - ") > 0 then
strBuf = remove(strTemp[i],1,8)
else
strBuf = strTemp[i]
endif
if retStr <> "" then
retStr = retStr + ", " + strBuf
else
retStr = strBuf
endif
endfor
return retStr
}
}
This should get you to where you want to be, if I understand you correctly.
Lee,
You are awesome! It works perfectly sir.
Thanks,
Crystal