I am trying to write a letter for missed labs. I want to be able to print it from reports but want it to mark if fasting is required based on the orders. Is this possible?
I was able to list the labs needed in the letter using this : {if ORDERS_AFTER("List","T") <> "" then ORDERS_AFTER('list','T') else "None" endif}. But I cannot get it to mark if it is fasting or not. Using the mel code below it just marks it as nonfasting no matter what labs are ordered.
{if ORDERS_AFTER("List","T")=="lipids"or"BMP"or"CMP"or"fasting glucose" then " Fasting required__X____ Nonfasting required_____" else " Fasting required______ Nonfasting required__X___ " endif}
Thank you.
I believe you will have to use an array for this and match to the first field. Otherwise I don't believe it breaks down the list by fields in order to match to order name.
The below code should work. Place the last line "{fnGetarray2()}" where you want the text to appear.
{!fn fnGetarray2()
{
local sList = ""
local sAry =""
local aRow
local i
local imax
local Text = ""
local OrdValue = "False"
sList = ORDERS_AFTER('DELIMITED','T')
sAry = getfield(sList,"|","")
imax = size(sAry)
for i=1, i<=imax, i=i+1 do
aRow = getfield(sAry[i],"^","")
if (str(aRow[1])= ”lipids”or”BMP”or”CMP”or”fasting glucose”) then OrdValue = "True"
else ""
endif
endfor
if (OrdValue = "True") then
Text = "Fasting required__X____ Nonfasting required_____"
else
Text = ”Fasting required______ Nonfasting required__X___”
endif
Return Text
}
}
{fnGetarray2()}
You might also want to review and change your comparison. You need to compare your OBS term to each potential value. Because ORDERS_AFTER can contain many items, you need to match your value to the list. The " > 0" is comparing it zero and not an O (oh).
{if match(ORDERS_AFTER(“List”,”T”), 1, ”lipids”) > 0 or
match(ORDERS_AFTER(“List”,”T”),1, ”BMP”) > 0 or
match(ORDERS_AFTER(“List”,”T”), 1, ”CMP”) > 0 or
match(ORDERS_AFTER(“List”,”T”), 1, ”fasting glucose”) > 0 then
” Fasting required__X____ Nonfasting required_____” else ” Fasting required______ Nonfasting required__X___ ” endif}