So this is the function I have in Patient Instructions to pull lab visits from the "last 3 days" but it is ACTUALLY pulliing in RANDOM dates
{labs = GET_FLOWSHEET_VALUES('Enterprise\Printing\Chart_Summary\Current-Labs')
if labs <> "" then
lablist = getfield(labs, "\n", "")
sz = size(lablist)
list = ""
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 + "\n\r"
else
list = list
endif
else
list = list
endif
endfor
if list <> "" then list else "No lab results." endif
else
"No lab results."
endif}
I am pretty sure I changed nothing as most of this is like alien language anyways ... PLEASE HELP!!!!
Try this, replace the flow sheet with your info:
{fn fnCVS_LabTestResults()
{local list = ""
local sz, i, dt, tody, lab, dtbegin, dur
local lablist
local labs = GET_FLOWSHEET_VALUES('EnterpriseInterfacesCCDDiagnostic 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 +"rn"
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()}
I copied and then got this:
{fn fnCVS_LabTestResults()
<-COMPILER ERROR NEARBY: Expect LEFT CURLY BRACKET. Instead had IDENTIFIER after RIGHT PAREN
{fnCVS_LabTestResults() <-FUNCTION DEFINITION IS NOT EXECUTABLE
The only thing I changed was the path of the flowsheet name
ahall716 said:
I copied and then got this:
{fn fnCVS_LabTestResults()
<-COMPILER ERROR NEARBY: Expect LEFT CURLY BRACKET. Instead had IDENTIFIER after RIGHT PAREN
{fnCVS_LabTestResults() <-FUNCTION DEFINITION IS NOT EXECUTABLE
The only thing I changed was the path of the flowsheet name
Copy it and paste it in notepad first, then copy / paste it in the handout.
I've done something ... luckily to a test one but now it says
{fnCVS_LabTestResults() <- Bad index
ahall716 said:
I've done something ... luckily to a test one but now it says
{fnCVS_LabTestResults() <- Bad index
That comes up if the flowsheet doesn't exist or isn't linked properly. I got the same error when I had your flowsheet listed, switched it back to mine and got "No lab results."
Okay I will try that ... is the "LabTestResults" something specific to your stuff or is that a general function name
ahall716 said:
Okay I will try that ... is the "LabTestResults" something specific to your stuff or is that a general function name
It's just a function name, you could change it to "MeangingfulUseSucks" and it would still work 🙂 (Just make sure if you change it to change it at the bottom as well)
Still getting "bad index" statement on the following this morning:
{fn fnCVS_LabTestResults()
{local list = ""
local sz, i, dt, tody, lab, dtbegin, dur
local lablist
local labs = GET_FLOWSHEET_VALUES('Enterprise\Printing\Chart_Summary\Current-Labs')
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 +"rn"
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()}
Are you 100% positive that this is the correct path to the flowsheet: Enterprise\Printing\Chart_Summary\Current-Labs ? I just replicated it on my side and it worked properly. My guess is you don't have a flowsheet or that isn't the right path...
Am i missing something w/below
ahall716 said:
Am i missing something w/below
Not that I can tell. Have you tried changing the function name? I was doing this in 9.5 but did it in 10 and it worked as well (didn't realize I had the same flowsheet in 10).
Okay so I've made some adjustments and no longer are getting any errors BUT NOW I'm getting NOTHING
{fn LabTestResults( )
{local list = ""
local sz, i, dt, tody, lab, dtbegin, dur
local lablist
local labs = GET_FLOWSHEET_VALUES('Enterprise\Printing\Chart_Summary\Current-Labs')
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 +"rn"
else
list = list
endif
else
list = list
endif
endfor
if list == "" then list ="No lab results." endif
else
list="No lab results."
endif
}}
ahall716 said:
Okay so I've made some adjustments and no longer are getting any errors BUT NOW I'm getting NOTHING
{fn LabTestResults( )
{local list = ""
local sz, i, dt, tody, lab, dtbegin, dur
local lablist
local labs = GET_FLOWSHEET_VALUES('Enterprise\Printing\Chart_Summary\Current-Labs')
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 +"rn"
else
list = list
endif
else
list = list
endif
endfor
if list == "" then list ="No lab results." endif
else
list="No lab results."
endif
}}
What you posted is what happens behind the scenes of the function, but you haven't called the function, so ya nothing will happen 🙂 after the }} put {LabTestResults()} and try again.
I honestly am not sure what is happeneing but I added that exact line and this is what i got
{LabTestResults( ) <-Bad index