Does anyone know how to get this to pull in the removal comments and re order it to display most recent to last?
THANKS!!
{!fn fnLoopALLMeds(){
local returnMS = "Inactive Medications: " + HRET
local i =
getRowCount("_MasterMed")
for x = 0, x < i, x = x+1
do local MIDx =
getRow("_MasterMed",x,"MID")
local XIDx =
find("_MasterMed","XID","MID",MIDx)
local RSNx = find("_MasterMed","StopReason","MID",MIDx)
local Reason = "Due to " + cond
case RSNx == "A" "Adverse Reaction "
case RSNx == "C" "Changed Medication "
case RSNx == "D" "Removed Medication "
casecRSNx == "E" "Other Reason "
case RSNx == "N" "Not Effective "
case RSNx == "O" "Other Reason "
case RSNx == "P" "Patient Request "
case RSNx == "R" "Regimen Completed "
case RSNx == "S" "Side Effects "
case RSNx == "T" "Cost "
else "Other Reason "
endcond
returnMS = returnMS +
if XIDx = 1000000000000000000.00 then ""
else
Reason + ": " + find("_MasterMed","Description","MID",MIDx) + " " +
"Started: " + find("_MasterMed","StartDate","MID",MIDx) + " " +
if find("_MasterMed","StopDate","MID",MIDx) == "12/31/4700" then "" else
"Stopped: " + find("_MasterMed","StopDate","MID",MIDx) endif + " " +
if find("_MasterMed","Comments","MID",MIDx) == "" then "" else
"Comment: " + find("_MasterMed","Comments","MID",MIDx) endif + HRET
endif
endfor
returnMS}}
{fnLoopALLMeds()}