Files
St.Clair/MLMStripper/bin/Debug/FORM/FORM_MLM_CREATININE_CLEARANCE.mlm

312 lines
9.9 KiB
Plaintext

maintenance:
title: FORM_MLM_Creatinine_Clearance;;
mlmname: FORM_MLM_Creatinine_Clearance;;
arden: version 2;;
version: 4.50;;
institution: St Clair Hospital;;
author: Robert Spence, Eclipsys Corp;;
specialist: ;;
date: 2008-03-07;;
validation: testing;;
library:
purpose: This MLM Calcualtes Creatinine Clearance based on SCH Guidelines
;;
explanation: Uses SCH guidelines to choose the correct weight, round serum where necessary and calculate creatinine
Uses SCH modified cockcrauft gault formula
Change History:
06.01.2016 TMS Added logic to existance of ht and wt to check for value of zero. Also added field to pass back to calling MLM for
Estimated CrCl value. CSR 34154, 34156
06.07.2016 TMS Added logic retrieve creatinine level for calculating clearance to any level this admission for Vancomycin and only the past 24 hours for all other medictions.
Lovenox is currently the only other medication using this calcuation. CSR 34154, 34156
06.5.2019 TMS CSR 38251 Modified to make retrieval of Creatinine for CrCl calculation to use the most recent this admission for all orders utilizing this MLM and
to remove retrieval of Creatinine 24 hours in the past for CrCl calcuation.
;;
keywords: Called MLMs, Form fields, Cockcrauft Gault, Creatinine
;;
knowledge:
type: data-driven;;
data:
// This MLM is passed three arguments, of types
// communication_type, form_type and client info object respectively.
(this_communication, // Communication object
this_form, // Form object
client_info_obj //Arden ClientInfo object
) := argument;
/*******************Make Changes To Spelling And Flags In This Section*******************/
/* Set to true if a decision.log is needed.*/
log_execution_info := FALSE;
/***************************************************************************************/
// Initialize error message
error_message:="";
// Assigns fields passed in the Form object to the Field object
field_list:= this_form.fields;
Visit_Guid := this_communication.ClientVisitGuid;
CallingField :=this_communication.CallingFieldName;
CallingEvent := this_communication.CallingEvent;
/* What is the HEIGHT limit for using the Ideal weight calculation? */
/* The calculation will be done if the height is GREATER THAN OR EQUAL TO this number listed below */
ideal_WT_height_limit:= 150; /* cm */
comb_ht_wt_field := first of
(field_list where field_list.DataItemName = "CombinedMeasurements");
if exists comb_ht_wt_field then
comb_ht_wt_val := comb_ht_wt_field.value;
wt := comb_ht_wt_val.weight;
ht := comb_ht_wt_val.height;
wt_type := comb_ht_wt_val.weighttype;
bsa := comb_ht_wt_val.bsa;
bmi := comb_ht_wt_val.bmi;
endif;
crclmgdl := first of (field_list where field_list.DataItemName = "PRX_CrCl_mg_dl");
crclumoll := first of (field_list where field_list.DataItemName = "PRX_CrCl_umol_L");
crclestd := first of (field_list where field_list.DataItemName = "PRX_CrCl_Estimated");
calcfield := first of (field_list where field_list.DataItemName = "PRX_Generic_CB");
commfield := first of (field_list where field_list.DataItemName = "PRX_NOTECOMMENT0");
client_guid := this_communication.ClientGUID;
visit_guid := this_communication.ClientVisitGUID;
chart_guid := this_communication.ChartGuid;
If (CallingEvent = "FormOpen") or (CallingEvent = "FieldChange") then
If CallingEvent = "FormOpen" then
// Get last creatinine level from this admission for antibiotics
// If this_form.Name = "PRX_Pb_Vanco" then
CPSVal := read last
{"Select top 1 bo.value "
|| " From cv3order as o with (nolock) "
|| " join cv3basicobservation as bo with (nolock) "
|| " on o.clientguid = bo.clientguid "
|| " and o.chartguid = bo.chartguid "
|| " and o.guid = bo.orderguid "
|| " and bo.status = {{{SINGLE-QUOTE}}}F{{{SINGLE-QUOTE}}} "
|| " and bo.Active = 1 "
|| " And bo.IsHistory = 0 "
|| " join cv3ordercatalogmasteritem as ocmi with (nolock) "
|| " on ocmi.guid = o.ordercatalogmasteritemguid "
|| " and ocmi.active = 1 "
|| " where o.clientguid = " || SQL(client_guid)
|| " and bo.itemname = {{{SINGLE-QUOTE}}}Creatinine Plasma/Serum{{{SINGLE-QUOTE}}} "
|| " order by o.performeddtm desc "
};
/* else
// Get lst creatinine level from previous 24 hour period
CPSVal := read last
{"Select top 1 bo.value "
|| " From cv3order as o with (nolock) "
|| " join cv3basicobservation as bo with (nolock) "
|| " on o.clientguid = bo.clientguid "
|| " and o.chartguid = bo.chartguid "
|| " and o.guid = bo.orderguid "
|| " and bo.status = {{{SINGLE-QUOTE}}}F{{{SINGLE-QUOTE}}} "
|| " and bo.Active = 1 "
|| " And bo.IsHistory = 0 "
|| " join cv3ordercatalogmasteritem as ocmi with (nolock) "
|| " on ocmi.guid = o.ordercatalogmasteritemguid "
|| " and ocmi.active = 1 "
|| " where o.clientguid = " || SQL(client_guid)
|| " and o.performeddtm >= (DATEADD(hour, -24, getdate())) "
|| " and bo.itemname = {{{SINGLE-QUOTE}}}Creatinine Plasma/Serum{{{SINGLE-QUOTE}}} "
|| " order by o.performeddtm desc "
};
endif;
*/
// endif;
CPSValNum := CPSVal As Number;
If exist CPSVal then
crclmgdl.value := (int ((CPSValNum + 0.05) * 10))/10;
crclumoll.value := (int (((crclmgdl.value * 88.4) + 0.05) * 10))/10;
endif;
endif; // Calling Field FormOpen
If (CallingField = "PRX_Generic_CB") or (CallingEvent = "FormOpen") or (CallingEvent = "FieldChange") then
fatalerror := false;
errormessage := "";
calcfield.value := false;
If not exist wt or wt = 0 then
errormessage := errormessage || "Weight is required to calculate Creatinine Clearance \n\n";
fatalerror := true;
endif;
if not exist ht or ht = 0 then
errormessage := errormessage || "Height is required to calculate Creatinine Clearance\n\n";
fatalerror := true;
endif;
if not exist crclmgdl.value then
errormessage := errormessage || "Creatinine is required to calculate Creatinine Clearance";
fatalerror := true;
endif;
if exist client_info_obj then
(birthdate, birth_year, patientgender ):= read last
{ClientInfo: birthdate, BirthYearNum, GenderTypeIntlCode REFERENCING client_info_obj};
endif;
if exist birthdate and birth_year > 0 and birthdate is time then
patientage:= (NOW - birthdate) / (1 year);
patientage:= (int (patientage));
endif;
if patientage < 18 then
fatalerror := true;
endif;
if fatalerror = true then
if patientage < 18 then
this_communication.Message := "This Calculation Is Not Approved For Patients < 18 Years Old";
this_communication.MessageType := "Error";
elseif callingfield = "PRX_Generic_CB" then
this_communication.Message := errormessage;
this_communication.MessageType := "Error";
endif;
else
Domore:=true;
actualwt:= wt;
// now ideal
if patientgender = "F"
then
WeightKg:= ((((ht /2.54)-60)* 2.3)+45.5);
else
WeightKg:= ((((ht /2.54)-60)* 2.3)+50);
endif; //if patientgender = "F"
idealwt := (int ((WeightKg+ 0.005) * 100))/100;
extraideal := "";
if ht < ideal_WT_height_limit
then
extraideal := "(Patient < 60 inches)";
if patientgender = "F"
then
idealwt := 45.5;
else
idealwt := 50;
endif;
endif;
// now adjusted
adjustedwt := ((actualwt - idealwt)* 0.4) + idealwt;
// now round all
actualwt := (int ((actualwt + 0.005) * 100))/100;
idealwt := (int ((idealwt + 0.005) * 100))/100;
adjustedwt := (int ((adjustedwt + 0.005) * 100))/100;
commfield.value:="Calculated with age of " || patientage || ", Actual Weight:" || actualwt ||
", Ideal Weight:" || idealwt || ", Adjusted Weight " || adjustedwt || " Gender:" || patientgender;
if actualwt < idealwt then
weightused:= actualwt;
else
weightused:= adjustedwt;
endif;
commfield.value := commfield.value || ", WEIGHT USED:" || weightused;
EstCrClval := ((140 - patientage) * weightused )
/ (72 * crclmgdl.value);
commfield.value := commfield.value || ", FORMULA USED:((140 - Age) x Wt / (72 x SerumCreat))";
if patientgender = "F"
then
EstCrClval := EstCrClval * 0.85;
commfield.value := commfield.value || " x 0.85";
endif; //gender = "F"
EstCrClval := (int ((EstCrClval + 0.05) * 10))/ 10;
crclestd.value := EstCrClval;
endif;
elseif CallingField = "PRX_CrCl_mg_dl"
then
if (exist crclmgdl.value) then
if crclmgdl.value > 0
then
//round to one decimal place
crclmgdl.value := (int ((crclmgdl.value + 0.05) * 10))/10;
crclumoll.value := (int (((crclmgdl.value * 88.4) + 0.05) * 10))/10;
else
crclmgdl.value := 0;
crclumoll.value := 0;
endif;
endif;
elseif CallingField = "PRX_CrCl_umol_L"
then
if (exist crclumoll.value) then
if crclumoll.value > 0
then
//round to one decimal place
crclumoll.value := (int ((crclumoll.value + 0.05) * 10))/10;
crclmgdl.value := (int (((crclumoll.value / 88.4) + 0.05) * 10))/10;
else
crclmgdl.value := 0;
crclumoll.value := 0;
endif;
endif;
endif;
endif;
If callingevent = "FormClose" then
EstCrClval := crclestd.value;
endif;
// If CallingField <> "PRX_Generic_CB" then
// crclestd.value := null;
// commfield.value := "Please click the calculate button for estimated Creatinine Clearance. Weight, Height and Creatinine are required";
// endif;
;;
evoke: // No evoke statement
;;
logic:
conclude true;
;;
action:
// This MLM returns two parameters, of types communication_type and form_type respectively.
return this_communication, this_form, EstCrClval;
;;
end: