can use as a text component, trigger w QT or whatever.
{fn dn_calc_GFR_MDRD() {
//estimate GFR based on creat, sex, race & age
//first part sets up all the local vars
local creat=lastobsvalue('creatinine')
local creatdate=lastobsdate('creatinine')
local gender if PATIENT.SEX=="F" then gender=0.742 else gender=1 endif
local age=(PATIENT._AGEINMONTHS)/12
local race if PATIENT.RACE=="B" then race=1.21 else race=1 endif
//make strings for the labels
local racestr if race==1.21 then racestr="Black" else racestr="Non-Black" endif
local genderstr if gender==1 then genderstr="Male" else genderstr="Female" endif
//error traps return nothing except the userok()
if creat="" then userOK("You can't calculate this without a creatinine. " + hret + hret + "Please order one & try again. " + hret + hret + "Thanks for your interest. ") return "" else "" endif
if PATIENT.SEX=="U" then userok("Please correct the patient's gender in registration & try again. ") return "" endif
if patient.race=="" then userok("Patient race must be entered in registration for this to work. ") return "" endif
//actual GFR calculation
local gfr=186*(val(creat)^(-1.154))*(age^(-0.203))*gender*race
//build the interpretation string
local interp
cond
case gfr>100 interp="Normal"
case gfr<=100 and gfr>=56 interp="Mild Renal Failure"
case gfr<56 and gfr >=25 interp="Moderate Renal Failure"
case gfr<25 interp="Severe Renal Failure"
endcond
//build the result string including the interpretation & ranges
//this could as easily be returned to a data display
if useryesno("Based on these parameters:" + hret + hret + " Patient age: " + age + " years" + hret + " Patient Gender: " + genderstr + hret + " Patient Race: " + racestr + hret + " Most Recent Creatinine: " + creat + " (" + creatdate + ")" + hret + hret + "Patient's estimated GFR based on Modification" + hret + " of Diet in Renal Disease study is: " + hret + hret + gfr + " mL/min/1.73 m^2" + hret + hret + "Interpretation: " + interp + hret + hret + "56-100 Mild RF" + hret + "25-55 Moderate RF" + hret + "<24 Severe RF" + hret + hret + "Do you want me to enter this in to the chart" + hret + " as the patient's current GFR?" )=="Yes" then obsnow("GFR",str(gfr),str(._TODAYSDATE)) else "" endif
//return just the result to wherever
return "Estimated GFR (MDRD) is " + gfr + " mL/min/1.73 m^2 (" + interp + ")"}}{dn_calc_GFR_MDRD()}
Posted : November 20, 2012 8:12 am