I received this function code to pull in meds by GPI Classification some time back and now the provider is asking if there is a way to suppress the category if there is not a med for that currently on the patients med list. Currently will list as None under the med class header. We want to not have it list if there is no med. Please see below and let me know if this is possible.
{fn GetMedsByClass(med_class, num, update) { local rets = "" local meds_array = getfield(MEDS_AFTER("delimited"), "|", "") for i = 1, i <= size(meds_array), i = i + 1 do local med_array = getfield(meds_array[i], "^", "") if (ok(med_array[4])) then if (med_array[4] <> "") then if (sub(med_array[4], 1, num) == med_class) then rets = rets + med_array[1] + HRET else continue endif else continue endif else continue endif endfor if (rets == "") then rets = "None" endif return rets }}{FMT("Antihypertensive Medications", "B,U,2") + HRET +FMT(GetMedsByClass("36", 2), "")}
Thank you!
Change "None" to "" and use CFMT instead of FMT to suppress the item when blank
{fn GetMedsByClass(med_class, num, update) { local rets = "" local meds_array = getfield(MEDS_AFTER("delimited"), "|", "") for i = 1, i <= size(meds_array), i = i + 1 do local med_array = getfield(meds_array[i], "^", "") if (ok(med_array[4])) then if (med_array[4] <> "") then if (sub(med_array[4], 1, num) == med_class) then rets = rets + med_array[1] + HRET else continue endif else continue endif else continue endif endfor if (rets == "") then rets = "" endif return rets }}{CFMT(GetMedsByClass("36", 2), "","Antihypertensive Medications" + hret, "B,U,2" , hret,"")}
I created this. You just need to change the way you are calling the GetMedsByClass() function.
Try replacing
{FMT("Antihypertensive Medications", "B,U,2") + HRET +FMT(GetMedsByClass("36", 2), "")}
with
{ local anti anti = GetMedsByClass("36", 2) if (anti <> "None" AND anti <> "") then FMT("Antihypertensive Medications", "B,U,2") + HRET +FMT(anti, "") else "" endif }
EDIT: gibsonmi's post works as well.
Thank you mikeseale! I could not remember who gave this to me and I sure couldn't find the original thread! Thank you!!! I will try this now!
This worked perfectly! Thank you again.