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

1096 lines
56 KiB
Plaintext

maintenance:
title: FORM_SET_Diabetic_Mgt;;
mlmname: FORM_SET_Diabetic_Mgt;;
arden: version 2.5;;
version: 16.3;;
institution: St Clair Hospital;;
author: Teresa Spicuzza, Allscripts ;;
specialist: St Clair Hospital;;
date: 2017-10-31;;
validation: testing;;
library:
purpose: Support best practice for diabetic management including standardized weight based calculation long and short acting insulin.
;;
explanation:
Change history
10.31.2017 TMS CSR 35723: Created to calculate interim insulin orders and/or enter other orders to manage patients with Diabetes
until a full review of home medications and hospital treatment is reviewed by the physician managing the patient.
11.13.2017 TMS CSR 35723: Updated to check blood glucose and present user with an alert box allowing them to enter
a dose to be given now based upon the sliding scale ordered from the algorithm.
07.24.2018 TMS CSR 36815: Updated to to increase the Insulin Total Daily Dose (TDD) for patients on IV corticosteroids to
0.5 units/kg (previously was 0.4) as well as increase the Total Daily Dose (TDD) for patients without steroids
and without GFR issues to 0.4 units/kg (previously was 0.3).
;;
keywords: Insulin, weight based, diabetic
;;
knowledge:
type: data-driven;;
data:
standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
include standard_libs;
local_session := CDS_SESSION.local;
using "ObjectsPlusXA.SCM.Forms";
using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms";
// 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;
comm_obj := this_communication.primaryobj;
/*******************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:="";
CR := 13 formatted with "%c";
LF := 10 formatted with "%c";
CRLF:= CR||LF;
TAB := 9 FORMATTED WITH "%C" ;
TAB2 := TAB || TAB ;
TAB3 := TAB || TAB || TAB;
// Assigns fields passed in the Form object to the Field object
field_list:= this_form.fields;
CallingEvent := this_communication.CallingEvent;
CallingField := this_communication.CallingFieldName;
ClientGuid := this_communication.ClientGUID;
ClientVisitGuid := this_communication.ClientVisitGUID;
ChartGuid := this_communication.ChartGUID;
UserGuid := this_communication.UserGuid;
//Form fields
Endo_Consult:= last of ( field_list WHERE field_list.DataItemName = "MultiOrderGrid"
AND field_list.Control_MultiFieldOccNum = 5 );
Physician_Consult:= last of ( field_list WHERE field_list.DataItemName = "MultiOrderGrid"
AND field_list.Control_MultiFieldOccNum = 6 );
InsulinLowDose := last of (field_list WHERE field_list.DataItemName = "MultiOrderInline"
AND field_list.Control_MultiFieldOccNum = 1);
InsulinModDose := last of (field_list WHERE field_list.DataItemName = "MultiOrderInline"
AND field_list.Control_MultiFieldOccNum = 2);
InsulinHighDose := last of (field_list WHERE field_list.DataItemName = "MultiOrderInline"
AND field_list.Control_MultiFieldOccNum = 3);
BasalInsulin:= last of ( field_list WHERE field_list.DataItemName = "MultiOrderGrid"
AND field_list.Control_MultiFieldOccNum = 2 );
CurrWeight := last of ( field_list WHERE field_list.DataItemName = "CombinedMeasurements"
AND field_list.Control_MultiFieldOccNum = 1 );
OrderInfo := last of ( field_list WHERE field_list.DataItemName = "PRX_NOTECOMMENT0"
AND field_list.Control_MultiFieldOccNum = 1 );
BGMFrequencyCode := last of ( field_list WHERE field_list.DataItemName = "FrequencyCode"
AND field_list.Control_MultiFieldOccNum = 1 );
BGMFrequency := BGMFrequencyCode.value;
SingleOral_CB := last of ( field_list WHERE field_list.DataItemName = "PRX_DM_SingleOralHomeMed"
AND field_list.Control_MultiFieldOccNum = 1 );
MultipleOralOrInsulin_CB := last of ( field_list WHERE field_list.DataItemName = "PRX_DM_MultipleOralOrInsulin"
AND field_list.Control_MultiFieldOccNum = 1 );
Diabetic_CB := last of ( field_list WHERE field_list.DataItemName = "PRX_DM_PatientIsDiabetic"
AND field_list.Control_MultiFieldOccNum = 1 );
InsulinPump_CB := last of ( field_list WHERE field_list.DataItemName = "PRX_DM_PatientOnInsulinPump"
AND field_list.Control_MultiFieldOccNum = 1 );
DietControlled_CB:= last of ( field_list WHERE field_list.DataItemName = "PRX_DM_PatientDietControlled"
AND field_list.Control_MultiFieldOccNum = 1 );
GFR_CB:= last of ( field_list WHERE field_list.DataItemName = "PRX_DM_GFR_LT_30"
AND field_list.Control_MultiFieldOccNum = 1 );
IvSteroid_CB := last of ( field_list WHERE field_list.DataItemName = "PRX_DM_PtOnIvSteroids"
AND field_list.Control_MultiFieldOccNum = 1 );
Override_CB := last of ( field_list WHERE field_list.DataItemName = "PRX_Generic_CB"
AND field_list.Control_MultiFieldOccNum = 1 );
CurrentLoc := read last
{" select currentlocation from cv3clientvisit "
|| " where ClientGUID = " || SQL(clientguid)
|| " and GUID = " || SQL(clientvisitguid)};
InsulinLowDoseList := InsulinLowDose.value;
InsulinModDoseList := InsulinModDose.value;
InsulinHighDoseList := InsulinHighDose.value;
BasalInsulinList := BasalInsulin.value;
Physician_ConsultList := Physician_Consult.value;
Endo_ConsultList := Endo_Consult.value;
CalcDose := last of (field_list WHERE field_list.DataItemName = "DosageLow"
AND field_list.Control_MultiFieldOccNum = 1);
if exists CurrWeight then
CurrWeight_val := CurrWeight.Value;
wt := CurrWeight_val.weight;
fmtwt := wt formatted with "%.1f";
else
wtgm := read last
{ " Select Text from CV3PhysicalNoteDeclaration "
|| " where ClientGUID = " || SQL(clientguid)
|| " and ClientVisitGUID = " || SQL(clientvisitguid)
|| " and TypeCode = {{{SINGLE-QUOTE}}}weight{{{SINGLE-QUOTE}}} "
|| " order by Entered asc " };
wt := (wtgm as number) / 1000;
fmtwt := wt formatted with "%.1f";
endif;
If CallingEvent = "FormOpen" or (CallingEvent = "FieldChange" and CallingField = "CombinedMeasurements|1" and Override_CB.Value = False)
or (CallingEvent = "FieldChange" and CallingField = "PRX_Generic_CB|1" and Override_CB.Value = False) then
/*********************************BEGIN HEALTH ISSUE SECTION**********************************************/
HealthIssue := read last {" select distinct hi.ShortName
from cv3healthissuedeclaration hi with (nolock)
inner join cv3codedhealthissue chi with (nolock) on hi.CodedHealthIssueGUID = chi.guid and chi.TypeCode IN({{{SINGLE-QUOTE}}}I9{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}})
where Clientguid = " || SQL (clientguid)
|| " and hi.active = 1
and Status in ({{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Chronic{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Retired Code{{{SINGLE-QUOTE}}})
and (((ICD10Code like {{{SINGLE-QUOTE}}}E10%{{{SINGLE-QUOTE}}}) or (ICD10Code like {{{SINGLE-QUOTE}}}E11%{{{SINGLE-QUOTE}}}) or (ICD10Code like {{{SINGLE-QUOTE}}}E09%{{{SINGLE-QUOTE}}}))
or ((ICD9Code like {{{SINGLE-QUOTE}}}250.%{{{SINGLE-QUOTE}}} and ICD10Code is null))
or ((ICD9Code like {{{SINGLE-QUOTE}}}249.%{{{SINGLE-QUOTE}}} and ICD10Code is null))
or ((chi.TypeCode IN({{{SINGLE-QUOTE}}}I9{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}})) and ((chi.Code like {{{SINGLE-QUOTE}}}250.%{{{SINGLE-QUOTE}}}) or chi.Code like {{{SINGLE-QUOTE}}}249.%{{{SINGLE-QUOTE}}}))
or ((chi.TypeCode = {{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}}) and ((chi.Code like {{{SINGLE-QUOTE}}}E11%{{{SINGLE-QUOTE}}}) or chi.Code like {{{SINGLE-QUOTE}}}E09%{{{SINGLE-QUOTE}}})))"};
if exist HealthIssue then Patient_is_Diabetic := "Yes"; else Patient_is_Diabetic := "No"; endif;
If Patient_is_Diabetic = "Yes" then
Diabetic_CB.value := True;
Diabetic_CB.Control_Read_Only := True;
else
If Diabetic_CB.value = False then
dialogResult1 := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n Unable to retrieve health issues for Diabetes. \n Does this patient have Diabetes? ","Alert","YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}};
if((dialogResult1 as string) = "Yes") then
Diabetic_CB.value := True;
Diabetic_CB.Control_Read_Only := True;
else
Diabetic_CB.Control_Read_Only := False;
endif;
endif;
endif;
/***********************BEGIN INSULIN PUMP DOCUMENTATION SEARCH ********************************/
(InsulinPump) := read last {"select fsl.value "
|| " from CV3ClientDocument cd with (nolock) "
|| " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = " || SQL(clientguid) || " and cdd.active = 1) "
|| " left join CV3ObservationDocument od with (nolock) ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 "
|| " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID and ocmi.name in ({{{SINGLE-QUOTE}}}SCHCK type of insulin{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCHCK insulin pump type{{{SINGLE-QUOTE}}}) "
|| " left join SCMObsFSListValues fsl(nolock) ON (fsl.ParentGUID = od.ObservationDocumentGUID AND fsl.ClientGUID = " || SQL(clientguid) || ") "
|| " where cd.clientguid = " || SQL(clientguid) || " and cd.clientvisitguid = " || SQL(clientvisitguid)
|| " and cd.documentname in ({{{SINGLE-QUOTE}}}ED Triage Note{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}adult patient profile{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}OB Patient Profile{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Pediatric Patient Profile{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Newborn Patient Profile{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Test{{{SINGLE-QUOTE}}}) " };
if exist insulinPump then
Patient_on_Insulin_Pump := "Yes";
else
PumpHealthIssue := read last {" select distinct hi.ShortName
from cv3healthissuedeclaration hi with (nolock)
inner join cv3codedhealthissue chi with (nolock) on hi.CodedHealthIssueGUID = chi.guid and chi.TypeCode IN({{{SINGLE-QUOTE}}}I9{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}ICD9{{{SINGLE-QUOTE}}})
where Clientguid = " || SQL (clientguid)
|| " and hi.active = 1
and Status in ({{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Chronic{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Retired Code{{{SINGLE-QUOTE}}})
and ((ICD10Code = {{{SINGLE-QUOTE}}}Z96.41{{{SINGLE-QUOTE}}})
or (ICD9Code = {{{SINGLE-QUOTE}}}V45.85{{{SINGLE-QUOTE}}} and ICD10Code is null)
or ((chi.TypeCode = {{{SINGLE-QUOTE}}}ICD10{{{SINGLE-QUOTE}}}) and (chi.Code = {{{SINGLE-QUOTE}}}Z96.41{{{SINGLE-QUOTE}}})))"};
if exist pumpHealthIssue then Patient_on_Insulin_Pump := "Yes"; else Patient_on_Insulin_Pump := "No"; endif;
endif;
/***********************BEGIN HOME MEDICATION ORAL DIABETIC AGENT SEARCH********************************/
(OralHomeMed,rxid) := read { "select distinct cp.DrugName, cp.prescriptionid
from SXAAMBClientPrescription cp
inner join SXAMTDrugNameMapVW dnm on dnm.drug_synonym_id = cp.FormularyBrandKey
join SXAMTCategoryDrugXREFVW cdx on cdx.drug_id = dnm.drug_id
join SXAMTDrugCategoriesVW cat on cat.multum_category_id = cdx.multum_category_id
where cp.ClientGUID = " || SQL(ClientGuid) || " and cp.statustype = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}}
and cat.category_name in ({{{SINGLE-QUOTE}}}dipeptidyl peptidase 4 inhibitors{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}antidiabetic combinations{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}sulfonylureas{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}biguanides{{{SINGLE-QUOTE}}})"};
if exist OralHomeMed then Patient_on_Oral_Home_Agent := "Yes"; else Patient_on_Oral_Home_Agent := "No"; endif;
HomeMedCount := count (OralHomeMed);
If Patient_on_Oral_Home_Agent = "Yes" then
If HomeMedCount = 1 then
SingleOralAgent := "Yes";
MultiOralAgent := "No";
else
SingleOralAgent := "No";
MultiOralAgent := "Yes";
endif;
endif;
/*********************************BEGIN HOME INSULIN SEARCH********************************************/
InsulinHomeMed := read last { "select distinct cp.DrugName
from SXAAMBClientPrescription cp
inner join SXAMTDrugNameMapVW dnm on dnm.drug_synonym_id = cp.FormularyBrandKey
join SXAMTCategoryDrugXREFVW cdx on cdx.drug_id = dnm.drug_id
join SXAMTDrugCategoriesVW cat on cat.multum_category_id = cdx.multum_category_id
where cp.ClientGUID = " || SQL(ClientGuid) || " and cp.statustype = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}}
and cat.category_name = {{{SINGLE-QUOTE}}}insulin{{{SINGLE-QUOTE}}}
and cp.EndDate is null "};
if exist InsulinHomeMed then Patient_on_Home_Insulin := "Yes"; else Patient_on_Home_Insulin := "No"; endif;
/********************************* BEGIN DIET ORDER SEARCH********************************************/
NPO := read last { "select o.guid from cv3order o
join CV3OrderCatalogMasterItem ocmi on ocmi.guid = o.OrderCatalogMasterItemGUID
where clientvisitguid = " || SQL (clientvisitguid) || " and o.clientguid = " || SQL (clientguid) ||"
and o.typecode = {{{SINGLE-QUOTE}}}Other{{{SINGLE-QUOTE}}}
and ocmi.Name = {{{SINGLE-QUOTE}}}NPO{{{SINGLE-QUOTE}}}"};
Diet := read last { "select o.guid from cv3order o
join CV3OrderCatalogMasterItem ocmi on ocmi.guid = o.OrderCatalogMasterItemGUID
where clientvisitguid = " || SQL (clientvisitguid) || " and o.clientguid = " || SQL (clientguid) ||"
and o.typecode = {{{SINGLE-QUOTE}}}Other{{{SINGLE-QUOTE}}}
and ocmi.Name = {{{SINGLE-QUOTE}}}Diet{{{SINGLE-QUOTE}}}"};
//Unsubmitted Active NPO order determined by local session variable
if (local_session.SessionUnsubNPOOrder = true) then
UnsubNPOOrderExists := true;
endif;
//Unsubmitted Active Diet order determined by local session variable
if (local_session.SessionUnsubDietOrder = true) then
UnsubDietOrderExists := true;
endif;
/***********************BEGIN IV STEROID SEARCH ********************************/
IvAddSteroid := read last { "select o.guid from cv3order o
join CV3OrderCatalogMasterItem ocmi on ocmi.guid = o.OrderCatalogMasterItemGUID
join CV3MedicationExtension me on me.guid = o.guid
left join CV3OrderComponent oc on oc.OrderGUID = o.guid
where clientvisitguid = " || SQL (clientvisitguid) || " and o.clientguid = " || SQL (clientguid) ||"
and o.typecode = {{{SINGLE-QUOTE}}}Medication{{{SINGLE-QUOTE}}}
and ocmi.TherapeuticCategory = {{{SINGLE-QUOTE}}}hormones/hormone modifiers | adrenal cortical steroids{{{SINGLE-QUOTE}}}
and me.OrderRouteCode in ({{{SINGLE-QUOTE}}}IV{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}IV Push{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}IVPB{{{SINGLE-QUOTE}}})"};
IvSteroid := read last { " select o.guid from cv3order o
join CV3MedicationExtension me on me.guid = o.guid
left join CV3OrderComponent oc on oc.OrderGUID = o.guid
join CV3OrderCatalogMasterItem ocmi on ocmi.guid = oc.OrderCatalogMasterItemGUID
where clientvisitguid = " || SQL (clientvisitguid) || " and o.clientguid = " || SQL (clientguid) ||"
and o.typecode = {{{SINGLE-QUOTE}}}Medication{{{SINGLE-QUOTE}}}
and ocmi.TherapeuticCategory = {{{SINGLE-QUOTE}}}hormones/hormone modifiers | adrenal cortical steroids{{{SINGLE-QUOTE}}}
and me.OrderRouteCode in ({{{SINGLE-QUOTE}}}IV{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}IV Push{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}IVPB{{{SINGLE-QUOTE}}})"};
IvSteroidTask := read {" select TaskStatusCode from CV3OrderTaskOccurrence oto
join cv3order o on o.guid = oto.OrderGUID
join CV3OrderCatalogMasterItem ocmi on ocmi.GUID = o.OrderCatalogMasterItemGUID
join CV3MedicationExtension me on me.guid = o.guid
where clientvisitguid = " || SQL (clientvisitguid) || " and oto.clientguid = " || SQL (clientguid) ||"
and o.typecode = {{{SINGLE-QUOTE}}}Medication{{{SINGLE-QUOTE}}}
and oto.TaskStatusCode <> ({{{SINGLE-QUOTE}}}Canceled{{{SINGLE-QUOTE}}})
and ocmi.TherapeuticCategory = {{{SINGLE-QUOTE}}}hormones/hormone modifiers | adrenal cortical steroids{{{SINGLE-QUOTE}}}
and me.OrderRouteCode in ({{{SINGLE-QUOTE}}}IV{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}IV Push{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}IVPB{{{SINGLE-QUOTE}}})"};
IvAddSteroidTask := read {" select TaskStatusCode from CV3OrderTaskOccurrence oto
join cv3order o on o.guid = oto.OrderGUID
join CV3MedicationExtension me on me.guid = o.guid
left join CV3OrderComponent oc on oc.OrderGUID = o.guid
join CV3OrderCatalogMasterItem ocmi on ocmi.guid = oc.OrderCatalogMasterItemGUID
where clientvisitguid = " || SQL (clientvisitguid) || " and oto.clientguid = " || SQL (clientguid) ||"
and o.typecode = {{{SINGLE-QUOTE}}}Medication{{{SINGLE-QUOTE}}}
and oto.TaskStatusCode <> ({{{SINGLE-QUOTE}}}Canceled{{{SINGLE-QUOTE}}})
and ocmi.TherapeuticCategory = {{{SINGLE-QUOTE}}}hormones/hormone modifiers | adrenal cortical steroids{{{SINGLE-QUOTE}}}
and me.OrderRouteCode in ({{{SINGLE-QUOTE}}}IV{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}IV Push{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}IVPB{{{SINGLE-QUOTE}}})"};
if (local_session.SessionUnsubIVSteroidOrder = true) then
UnsubSteroidOrderExists := true;
endif;
if exist IvSteroid then
Patient_on_IV_Steroid := "Yes";
IvSteroid_CB.value := True;
IvSteroid_CB.Control_Read_only := True;
elseif exist IvSteroidTask then
Patient_on_IV_Steroid := "Yes";
IvSteroid_CB.value := True;
IvSteroid_CB.Control_Read_only := True;
elseif exist IvAddSteroid then
Patient_on_IV_Steroid := "Yes";
IvSteroid_CB.value := True;
IvSteroid_CB.Control_Read_only := True;
elseif exist IvAddSteroidTask then
Patient_on_IV_Steroid := "Yes";
IvSteroid_CB.value := True;
IvSteroid_CB.Control_Read_only := True;
elseif
UnsubSteroidOrderExists = True then
Patient_on_IV_Steroid := "Yes";
IvSteroid_CB.value := True;
IvSteroid_CB.Control_Read_only := True;
else
Patient_on_IV_Steroid := "No";
IvSteroid_CB.value := False;
IvSteroid_CB.Control_Read_only := True;
endif;
/**************************GFR LAB VALUE SEARCH ***********************************/
Race := read last
{" Select RaceCode from cv3client where RaceCode like {{{SINGLE-QUOTE}}}%African%{{{SINGLE-QUOTE}}} and Guid = " ||SQL (clientguid)};
If Race is not null then
GFR, GFRName, GFRUom, AbnCode := read last
{"Select top 1 bo.value, bo.itemname, bo.UnitofMeasure, bo.AbnormalityCode "
|| " 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(clientguid)
|| " and o.performeddtm >= (DATEADD(hour, -240, getdate())) "
|| " and bo.itemname = {{{SINGLE-QUOTE}}}GFR (African American){{{SINGLE-QUOTE}}} "
|| " order by o.performeddtm desc "
};
else
GFR, GFRName, GFRUom, AbnCode := read last
{"Select top 1 bo.value, bo.itemname, bo.UnitofMeasure, bo.AbnormalityCode "
|| " 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(clientguid)
|| " and o.performeddtm >= (DATEADD(hour, -240, getdate())) "
|| " and bo.itemname = {{{SINGLE-QUOTE}}}GFR (Caucasian/Other){{{SINGLE-QUOTE}}} "
|| " order by o.performeddtm desc "
};
endif;
If ABNCode = "L" and (GFR as number ) < 30 then
Low_GFR := "Yes";
GFR_CB.value := True;
GFR_CB.Control_Read_Only := True;
elseif GFR is Null then
No_GFR := "Yes";
GFR_CB.value := False;
GFR_CB.Control_Read_Only := True;
else
Low_GFR := "No";
GFR_CB.value := False;
GFR_CB.Control_Read_Only := True;
endif;
If Patient_is_Diabetic = "Yes" and Patient_on_Insulin_Pump = "Yes" then
Endo_ConsultList.IsSelected := (True, True);
Physician_ConsultList.IsSelected := (True);
ThisMsg := "Patient on an Insulin Pump." || CRLF
|| "Place a STAT Endocrinology Consult.";
OrderInfo.value := ThisMsg;
InsulinPump_CB.value := True;
Diabetic_CB.value := True;
DietControlled_CB.value:= False;
MultipleOralOrInsulin_CB.value := False;
SingleOral_CB.value := False;
DietControlled_CB.control_read_only := True;
MultipleOralOrInsulin_CB.control_read_only := True;
SingleOral_CB.control_read_only := True;
ElseIf Patient_on_Insulin_Pump = "No" and Patient_on_Oral_Home_Agent = "No" and Patient_on_Home_Insulin = "No" then
dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n Unable to retrieve any home insulin or home oral diabetic agents. \n\n Please select {{{SINGLE-QUOTE}}}YES{{{SINGLE-QUOTE}}} to confirm that this patient does not take oral diabetic agents or insulin. ","Alert","YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}};
if((dialogResult as string) = "Yes") then
Patient_is_Diet_Controlled := "Yes";
DietControlled_CB.value := True;
MultipleOralOrInsulin_CB.value := False;
MultipleOralOrInsulin_CB.Control_Read_Only := True;
SingleOral_CB.value := False;
SingleOral_CB.Control_Read_Only := True;
InsulinPump_CB.value := False;
InsulinPump_CB.Control_Read_Only := True;
if Diet is not null or UnsubDietOrderExists then
BGMFrequency.FrequencySummary := "QID (AC and HS)";
elseif NPO is not null or UnsubNPOOrderExists then
BGMFrequency.FrequencySummary := "Q6H";
else
dialogResult3 := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n Unable to retrieve any diet orders. \n Is this patient NPO? ","Alert","YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}};
if((dialogResult3 as string) = "Yes") then
BGMFrequency.FrequencySummary := "Q6H";
else
BGMFrequency.FrequencySummary := "QID (AC and HS)";
endif;
endif;
else
If this_communication.CatalogParentOrderSetGUID is not null then
dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n You will need to re-open the Diabetic Management Protocol Order Set from the Review Screen before submitting orders to make any Parameter Selections." ,"Alert","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}};
endif;
Patient_is_Diet_Controlled := "No";
DietControlled_CB.value := False;
Override_CB.value := True;
GFR_CB.Control_Read_Only := False;
IvSteroid_CB.Control_Read_only := False;
MultipleOralOrInsulin_CB.control_read_only := False;
SingleOral_CB.control_read_only := False;
InsulinPump_CB.control_read_only := False;
DietControlled_CB.control_read_only := False;
endif;
endif;
if Patient_is_Diabetic = "Yes" and Patient_on_Insulin_Pump = "No" and (Patient_is_Diet_Controlled = "No" or Patient_is_Diet_Controlled is Null) then
If Patient_on_IV_Steroid = "No" and this_communication.CatalogParentOrderSetGUID is not null and (MultiOralAgent = "Yes" or Patient_on_Home_Insulin = "Yes") then
dialogResult6 := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n Will you be placing this patient on IV Steroids?" ,"Alert","YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}};
if((dialogResult6 as string) = "Yes") then
Patient_on_IV_Steroid := "Yes";
IvSteroid_CB.value := True;
IvSteroid_CB.Control_Read_only := True;
else
Patient_on_IV_Steroid := "No";
endif;
endif;
// Get patient weight
if exists CurrWeight then
CurrWeight_val := CurrWeight.Value;
wt := CurrWeight_val.weight;
fmtwt := wt formatted with "%.1f";
else
wtgm := read last
{ " Select Text from CV3PhysicalNoteDeclaration "
|| " where ClientGUID = " || SQL(clientguid)
|| " and ClientVisitGUID = " || SQL(clientvisitguid)
|| " and TypeCode = {{{SINGLE-QUOTE}}}weight{{{SINGLE-QUOTE}}} "
|| " order by Entered asc " };
wt := (wtgm as number) / 1000;
fmtwt := wt formatted with "%.1f";
endif;
If wt = 0 or wt is null then
dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n Please enter a patient weight to continue. ","Alert","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}};
CurrWeight.Control_Mandatory := True;
endif;
If Patient_on_Oral_Home_Agent = "Yes" and SingleOralAgent = "Yes" and MultiOralAgent = "No" and Patient_on_Home_Insulin = "No" then
TDD_calc := (wt as number) * 0.2;
fmt_TDD := TDD_calc formatted with "%.0f";
TDD_half := (TDD_calc as number) * 0.5;
TDD_halfrnd := int (((TDD_half as number) + 0.5)/1)*1;
fmt_TDD_halfrnd := TDD_halfrnd formatted with "%.0f";
CalcDose.Value := TDD_halfrnd;
BasalInsulinList.IsSelected := (True);
Endo_ConsultList.IsSelected := (False, True);
Physician_ConsultList.IsSelected := (False);
BGMFrequency.FrequencySummary := "QID (AC and HS)";
InsulinPump_CB.value:= False;
DietControlled_CB.value:= False;
SingleOral_CB.value := True;
MultipleOralOrInsulin_CB.value := False;
InsulinPump_CB.control_read_only := True;
SingleOral_CB.control_read_only := True;
DietControlled_CB.control_read_only := True;
SingleOral_CB.control_read_only := True;
MultipleOralOrInsulin_CB.control_read_only := True;
If (TDD_calc as number) > 80 then
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (True);
Slidescale := "Total Daily Dose > 80 units - Use High Dose Correctional Sliding Scale";
elseif (TDD_calc as number) >= 40 and (TDD_calc as number) <= 80 then
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (True);
InsulinHighDoseList.IsSelected := (False);
Slidescale := "Total Daily Dose 40 - 80 units - Use Moderate Dose Correctional Sliding Scale";
elseif (TDD_calc as number) < 40 then
InsulinLowDoseList.IsSelected := (True);
InsulinModDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (False);
Slidescale := "Total Daily Dose < 40 units - Use Low Dose Correctional Sliding Scale";
endif;
ThisMsg := "Patient on single oral agent at home." || CRLF
|| "Total Daily Dose = 0.2 units/kg || (" || fmtwt || " kg * 0.2 = " || fmt_TDD|| " units)" || CRLF
|| "Basal Insulin = 50% of Total Daily Dose || (" || fmt_TDD ||" units * 0.5 = " || fmt_TDD_halfrnd || " units)" ||CRLF || Slidescale;
OrderInfo.value := ThisMsg;
elseif ((Patient_on_Oral_Home_Agent = "Yes" and SingleOralAgent = "No" and MultiOralAgent = "Yes") or Patient_on_Home_Insulin = "Yes") and Patient_on_IV_Steroid = "Yes" then
TDD_calc := (wt as number) * 0.5;
fmt_TDD := TDD_calc formatted with "%.0f";
TDD_half := (TDD_calc as number) * 0.5;
TDD_halfrnd := int (((TDD_half as number) + 0.5)/1)*1;
fmt_TDD_halfrnd := TDD_halfrnd formatted with "%.0f";
CalcDose.Value := TDD_halfrnd;
InsulinModDoseList.IsSelected := (True);
InsulinLowDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (False);
BasalInsulinList.IsSelected := (True);
Endo_ConsultList.IsSelected := (False, True);
Physician_ConsultList.IsSelected := (False);
BGMFrequency.FrequencySummary := "QID (AC and HS)";
InsulinPump_CB.value:= False;
DietControlled_CB.value:= False;
SingleOral_CB.value := False;
MultipleOralOrInsulin_CB.value := True;
InsulinPump_CB.control_read_only := True;
DietControlled_CB.control_read_only := True;
SingleOral_CB.control_read_only := True;
MultipleOralOrInsulin_CB.control_read_only := True;
Slidescale := "Use Moderate Dose Correctional Sliding Scale";
ThisMsg := "Patient on IV Steroids." || CRLF
|| "Total Daily Dose = 0.5 units/kg || (" || fmtwt || " kg * 0.5 = " || fmt_TDD || " units)" || CRLF
|| "Basal Insulin = 50% of Total Daily Dose || (" || fmt_TDD ||" units * 0.5 = " || fmt_TDD_halfrnd || " units)" ||CRLF || Slidescale;
OrderInfo.value := ThisMsg;
elseif ((Patient_on_Oral_Home_Agent = "Yes" and SingleOralAgent = "No" and MultiOralAgent = "Yes") or Patient_on_Home_Insulin = "Yes") and Patient_on_IV_Steroid = "No" and Low_GFR = "Yes" then
TDD_calc := (wt as number) * 0.2;
fmt_TDD := TDD_calc formatted with "%.0f";
TDD_half := (TDD_calc as number) * 0.5;
TDD_halfrnd := int (((TDD_half as number) + 0.5)/1)*1;
fmt_TDD_halfrnd := TDD_halfrnd formatted with "%.0f";
CalcDose.Value := TDD_halfrnd;
BasalInsulinList.IsSelected := (True);
Endo_ConsultList.IsSelected := (False, True);
Physician_ConsultList.IsSelected := (False);
BGMFrequency.FrequencySummary := "QID (AC and HS)";
GFR_CB.value := True;
GFR_CB.Control_Read_Only := True;
InsulinPump_CB.value:= False;
DietControlled_CB.value:= False;
SingleOral_CB.value := False;
MultipleOralOrInsulin_CB.value := True;
InsulinPump_CB.control_read_only := True;
DietControlled_CB.control_read_only := True;
SingleOral_CB.control_read_only := True;
MultipleOralOrInsulin_CB.control_read_only := True;
If (TDD_calc as number) > 80 then
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (True);
Slidescale := "Total Daily Dose > 80 units - Use High Dose Correctional Sliding Scale";
elseif (TDD_calc as number) >= 40 and (TDD_calc as number) <= 80 then
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (True);
InsulinHighDoseList.IsSelected := (False);
Slidescale := "Total Daily Dose 40 - 80 units - Use Moderate Dose Correctional Sliding Scale";
elseif (TDD_calc as number) < 40 then
InsulinLowDoseList.IsSelected := (True);
InsulinModDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (False);
Slidescale := "Total Daily Dose < 40 units - Use Low Dose Correctional Sliding Scale";
endif;
ThisMsg := GFRName ||" " || GFR || " " || GFRUom || CRLF
|| "Total Daily Dose = 0.2 units/kg || (" || fmtwt || " kg * 0.2 = " || fmt_TDD|| " units)" || CRLF
|| "Basal Insulin = 50% of Total Daily Dose || (" || fmt_TDD ||" units * 0.5 = " || fmt_TDD_halfrnd || " units)" ||CRLF || Slidescale;
OrderInfo.value := ThisMsg;
elseif ((Patient_on_Oral_Home_Agent = "Yes" and SingleOralAgent = "No" and MultiOralAgent = "Yes") or Patient_on_Home_Insulin = "Yes") and Patient_on_IV_Steroid = "No" and Low_GFR = "No" then
TDD_calc := (wt as number) * 0.4;
fmt_TDD := TDD_calc formatted with "%.0f";
TDD_half := (TDD_calc as number) * 0.5;
TDD_halfrnd := int (((TDD_half as number) + 0.5)/1)*1;
fmt_TDD_halfrnd := TDD_halfrnd formatted with "%.0f";
CalcDose.Value := TDD_halfrnd;
BasalInsulinList.IsSelected := (True);
Endo_ConsultList.IsSelected := (False, True);
Physician_ConsultList.IsSelected := (False);
BGMFrequency.FrequencySummary := "QID (AC and HS)";
GFR_CB.value := False ;
SingleOral_CB.value := False;
SingleOral_CB.control_read_only := True;
MultipleOralOrInsulin_CB.value := True;
MultipleOralOrInsulin_CB.control_read_only := True;
DietControlled_CB.value := False;
DietControlled_CB.control_read_only := True;
If Patient_on_Home_Insulin = "No" then
InsulinPump_CB.Control_Read_Only := True;
else
InsulinPump_CB.Control_Read_Only := False;
endif;
If (TDD_calc as number) > 80 then
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (True);
Slidescale := "Total Daily Dose > 80 units - Use High Dose Correctional Sliding Scale";
elseif (TDD_calc as number) >= 40 and (TDD_calc as number) <= 80 then
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (True);
InsulinHighDoseList.IsSelected := (False);
Slidescale := "Total Daily Dose 40 - 80 units - Use Moderate Dose Correctional Sliding Scale";
elseif (TDD_calc as number) < 40 then
InsulinLowDoseList.IsSelected := (True);
InsulinModDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (False);
Slidescale := "Total Daily Dose < 40 units - Use Low Dose Correctional Sliding Scale";
endif;
ThisMsg := GFRName ||" " || GFR || " " || GFRUom || CRLF
|| "Total Daily Dose = 0.4 units/kg || (" || fmtwt || " kg * 0.4 = " || fmt_TDD || " units)" || CRLF
|| "Basal Insulin = 50% of Total Daily Dose || (" || fmt_TDD ||" units * 0.5 = " || fmt_TDD_halfrnd || " units)" ||CRLF || Slidescale;
OrderInfo.value := ThisMsg;
elseif ((Patient_on_Oral_Home_Agent = "Yes" and SingleOralAgent = "No" and MultiOralAgent = "Yes") or Patient_on_Home_Insulin = "Yes") and Patient_on_IV_Steroid = "No" and No_GFR = "Yes" then
TDD_calc := (wt as number) * 0.2;
fmt_TDD := TDD_calc formatted with "%.0f";
TDD_half := (TDD_calc as number) * 0.5;
TDD_halfrnd := int (((TDD_half as number) + 0.5)/1)*1;
fmt_TDD_halfrnd := TDD_halfrnd formatted with "%.0f";
CalcDose.Value := TDD_halfrnd;
BasalInsulinList.IsSelected := (True);
Endo_ConsultList.IsSelected := (False, True);
Physician_ConsultList.IsSelected := (False);
BGMFrequency.FrequencySummary := "QID (AC and HS)";
GFR_CB.value := False ;
SingleOral_CB.value := False;
SingleOral_CB.control_read_only := True;
MultipleOralOrInsulin_CB.value := True;
MultipleOralOrInsulin_CB.control_read_only := True;
DietControlled_CB.value := False;
DietControlled_CB.control_read_only := True;
If Patient_on_Home_Insulin = "No" then
InsulinPump_CB.Control_Read_Only := True;
else
InsulinPump_CB.Control_Read_Only := False;
endif;
If (TDD_calc as number) > 80 then
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (True);
Slidescale := "Total Daily Dose > 80 units - Use High Dose Correctional Sliding Scale";
elseif (TDD_calc as number) >= 40 and (TDD_calc as number) <= 80 then
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (True);
InsulinHighDoseList.IsSelected := (False);
Slidescale := "Total Daily Dose 40 - 80 units - Use Moderate Dose Correctional Sliding Scale";
elseif (TDD_calc as number) < 40 then
InsulinLowDoseList.IsSelected := (True);
InsulinModDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (False);
Slidescale := "Total Daily Dose < 40 units - Use Low Dose Correctional Sliding Scale";
endif;
ThisMsg := " No GFR Value Found" || CRLF
|| "Total Daily Dose = 0.2 units/kg || (" || fmtwt || " kg * 0.2 = " || fmt_TDD || " units)" || CRLF
|| "Basal Insulin = 50% of Total Daily Dose || (" || fmt_TDD ||" units * 0.5 = " || fmt_TDD_halfrnd || " units)" ||CRLF || Slidescale;
OrderInfo.value := ThisMsg;
else
ThisMsg := " " ;
OrderInfo.value := ThisMsg;
endif;
endif;
endif;
If callingEvent = "FieldChange" or callingEvent = "FormClose" then
If callingEvent = "FormClose" and (MultipleOralOrInsulin_CB.value = True or SingleOral_CB.value = True) and (wt = 0 or wt is null) then
this_communication.DisplayForm := "yes";
this_communication.Message := "\n You must enter a patient weight to continue. ";
this_communication.MessageType := "Error";
endif;
If CallingField = "PRX_Generic_CB|1" and Override_CB.Value = True then
InsulinPump_CB.Control_Read_Only := False;
MultipleOralOrInsulin_CB.control_read_only := False;
SingleOral_CB.control_read_only := False;
DietControlled_CB.control_read_only := False;
GFR_CB.Control_Read_Only := False;
IvSteroid_CB.Control_Read_only := False;
Endo_ConsultList.IsSelected := (False, True);
Physician_ConsultList.IsSelected := (False);
BasalInsulinList.IsSelected := (False);
BGMFrequency.FrequencySummary := "QID (AC and HS)";
endif;
If CallingField = "PRX_DM_PatientOnInsulinPump|1" then
If InsulinPump_CB.value = False then
MultipleOralOrInsulin_CB.control_read_only := False;
SingleOral_CB.control_read_only := False;
DietControlled_CB.control_read_only := False;
Elseif InsulinPump_CB.value = True then
Endo_ConsultList.IsSelected := (True, True);
Physician_ConsultList.IsSelected := (True);
BasalInsulinList.IsSelected := (False);
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (False);
BGMFrequency.FrequencySummary := "QID (AC and HS)";
ThisMsg := "Patient on an Insulin Pump." || CRLF
|| "Place a STAT Endocrinology Consult.";
OrderInfo.value := ThisMsg;
Diabetic_CB.value := True;
DietControlled_CB.value:= False;
MultipleOralOrInsulin_CB.value := False;
SingleOral_CB.value := False;
DietControlled_CB.control_read_only := True;
MultipleOralOrInsulin_CB.control_read_only := True;
SingleOral_CB.control_read_only := True;
endif;
endif;
If (CallingField = "PRX_DM_SingleOralHomeMed|1" and (SingleOral_CB.value = True or SingleOral_CB.value = False))or (CallingField = "CombinedMeasurements|1" and SingleOral_CB.value = true) then
If SingleOral_CB.value = False then
MultipleOralOrInsulin_CB.control_read_only := False;
SingleOral_CB.control_read_only := False;
DietControlled_CB.control_read_only := False;
InsulinPump_CB.control_read_only := False;
Elseif SingleOral_CB.value = True then
TDD_calc := (wt as number) * 0.2;
fmt_TDD := TDD_calc formatted with "%.0f";
TDD_half := (TDD_calc as number) * 0.5;
TDD_halfrnd := int (((TDD_half as number) + 0.5)/1)*1;
fmt_TDD_halfrnd := TDD_halfrnd formatted with "%.0f";
CalcDose.Value := TDD_halfrnd;
BasalInsulinList.IsSelected := (True);
Endo_ConsultList.IsSelected := (False, True);
Physician_ConsultList.IsSelected := (False);
BGMFrequency.FrequencySummary := "QID (AC and HS)";
InsulinPump_CB.value:= False;
DietControlled_CB.value:= False;
MultipleOralOrInsulin_CB.value := False;
InsulinPump_CB.control_read_only := True;
DietControlled_CB.control_read_only := True;
MultipleOralOrInsulin_CB.control_read_only := True;
If (TDD_calc as number) > 80 then
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (True);
Slidescale := "Total Daily Dose > 80 units - Use High Dose Correctional Sliding Scale";
elseif (TDD_calc as number) >= 40 and (TDD_calc as number) <= 80 then
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (True);
InsulinHighDoseList.IsSelected := (False);
Slidescale := "Total Daily Dose 40 - 80 units - Use Moderate Dose Correctional Sliding Scale";
elseif (TDD_calc as number) < 40 then
InsulinLowDoseList.IsSelected := (True);
InsulinModDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (False);
Slidescale := "Total Daily Dose < 40 units - Use Low Dose Correctional Sliding Scale";
endif;
ThisMsg := "Patient on single oral agent at home." || CRLF
|| "Total Daily Dose = 0.2 units/kg || (" || fmtwt || " kg * 0.2 = " || fmt_TDD|| " units)" || CRLF
|| "Basal Insulin = 50% of Total Daily Dose || (" || fmt_TDD ||" units * 0.5 = " || fmt_TDD_halfrnd || " units)" ||CRLF || Slidescale;
OrderInfo.value := ThisMsg;
endif;
endif;
If (CallingField = "PRX_DM_MultipleOralOrInsulin|1" or CallingField = "PRX_DM_PtOnIvSteroids|1" or CallingField = "PRX_DM_GFR_LT_30|1")
or (CallingField = "CombinedMeasurements|1" and MultipleOralOrInsulin_CB.value = true) then
If MultipleOralOrInsulin_CB.value = False then
MultipleOralOrInsulin_CB.control_read_only := False;
SingleOral_CB.control_read_only := False;
DietControlled_CB.control_read_only := False;
InsulinPump_CB.control_read_only := False;
ElseIf MultipleOralOrInsulin_CB.value = True then
If IvSteroid_CB.value = True then
TDD_calc := (wt as number) * 0.5;
fmt_TDD := TDD_calc formatted with "%.0f";
TDD_half := (TDD_calc as number) * 0.5;
TDD_halfrnd := int (((TDD_half as number) + 0.5)/1)*1;
fmt_TDD_halfrnd := TDD_halfrnd formatted with "%.0f";
CalcDose.Value := TDD_halfrnd;
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (True);
InsulinHighDoseList.IsSelected := (False);
BasalInsulinList.IsSelected := (True);
Endo_ConsultList.IsSelected := (False, True);
Physician_ConsultList.IsSelected := (False);
BGMFrequency.FrequencySummary := "QID (AC and HS)";
InsulinPump_CB.value:= False;
DietControlled_CB.value:= False;
SingleOral_CB.value := False;
InsulinPump_CB.control_read_only := True;
DietControlled_CB.control_read_only := True;
SingleOral_CB.control_read_only := True;
Slidescale := "Use Moderate Dose Correctional Sliding Scale";
ThisMsg := "Patient on IV Steroids." || CRLF
|| "Total Daily Dose = 0.5 units/kg || (" || fmtwt || " kg * 0.5 = " || fmt_TDD || " units)" || CRLF
|| "Basal Insulin = 50% of Total Daily Dose || (" || fmt_TDD ||" units * 0.5 = " || fmt_TDD_halfrnd || " units)" ||CRLF || Slidescale;
OrderInfo.value := ThisMsg;
ElseIf GFR_CB.value = True and IvSteroid_CB.value = False then
TDD_calc := (wt as number) * 0.2;
fmt_TDD := TDD_calc formatted with "%.0f";
TDD_half := (TDD_calc as number) * 0.5;
TDD_halfrnd := int (((TDD_half as number) + 0.5)/1)*1;
fmt_TDD_halfrnd := TDD_halfrnd formatted with "%.0f";
CalcDose.Value := TDD_halfrnd;
BasalInsulinList.IsSelected := (True);
Endo_ConsultList.IsSelected := (False, True);
Physician_ConsultList.IsSelected := (False);
BGMFrequency.FrequencySummary := "QID (AC and HS)";
InsulinPump_CB.value:= False;
DietControlled_CB.value:= False;
SingleOral_CB.value := False;
InsulinPump_CB.control_read_only := True;
DietControlled_CB.control_read_only := True;
SingleOral_CB.control_read_only := True;
If (TDD_calc as number) > 80 then
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (True);
Slidescale := "Total Daily Dose > 80 units - Use High Dose Correctional Sliding Scale";
elseif (TDD_calc as number) >= 40 and (TDD_calc as number) <= 80 then
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (True);
InsulinHighDoseList.IsSelected := (False);
Slidescale := "Total Daily Dose 40 - 80 units - Use Moderate Dose Correctional Sliding Scale";
elseif (TDD_calc as number) < 40 then
InsulinLowDoseList.IsSelected := (True);
InsulinModDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (False);
Slidescale := "Total Daily Dose < 40 units - Use Low Dose Correctional Sliding Scale";
endif;
ThisMsg := "This patient has a GFR < 30ml/min" || CRLF
|| "Total Daily Dose = 0.2 units/kg || (" || fmtwt || " kg * 0.2 = " || fmt_TDD|| " units)" || CRLF
|| "Basal Insulin = 50% of Total Daily Dose || (" || fmt_TDD ||" units * 0.5 = " || fmt_TDD_halfrnd || " units)" ||CRLF || Slidescale;
OrderInfo.value := ThisMsg;
ElseIf GFR_CB.value = False and IvSteroid_CB.value = False then
TDD_calc := (wt as number) * 0.4;
fmt_TDD := TDD_calc formatted with "%.0f";
TDD_half := (TDD_calc as number) * 0.5;
TDD_halfrnd := int (((TDD_half as number) + 0.5)/1)*1;
fmt_TDD_halfrnd := TDD_halfrnd formatted with "%.0f";
CalcDose.Value := TDD_halfrnd;
BasalInsulinList.IsSelected := (True);
Endo_ConsultList.IsSelected := (False, True);
Physician_ConsultList.IsSelected := (False);
BGMFrequency.FrequencySummary := "QID (AC and HS)";
SingleOral_CB.value := False;
SingleOral_CB.control_read_only := True;
DietControlled_CB.value := False;
DietControlled_CB.control_read_only := True;
If (TDD_calc as number) > 80 then
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (True);
Slidescale := "Total Daily Dose > 80 units - Use High Dose Correctional Sliding Scale";
elseif (TDD_calc as number) >= 40 and (TDD_calc as number) <= 80 then
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (True);
InsulinHighDoseList.IsSelected := (False);
Slidescale := "Total Daily Dose 40 - 80 units - Use Moderate Dose Correctional Sliding Scale";
elseif (TDD_calc as number) < 40 then
InsulinLowDoseList.IsSelected := (True);
InsulinModDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (False);
Slidescale := "Total Daily Dose < 40 units - Use Low Dose Correctional Sliding Scale";
endif;
If GFRName is not null then
ThisMsg := GFRName ||" " || GFR || " " || GFRUom || CRLF
|| "Total Daily Dose = 0.4 units/kg || (" || fmtwt || " kg * 0.4 = " || fmt_TDD || " units)" || CRLF
|| "Basal Insulin = 50% of Total Daily Dose || (" || fmt_TDD ||" units * 0.5 = " || fmt_TDD_halfrnd || " units)" ||CRLF || Slidescale;
Else
ThisMsg := " " || CRLF
|| "Total Daily Dose = 0.4 units/kg || (" || fmtwt || " kg * 0.4 = " || fmt_TDD || " units)" || CRLF
|| "Basal Insulin = 50% of Total Daily Dose || (" || fmt_TDD ||" units * 0.5 = " || fmt_TDD_halfrnd || " units)" ||CRLF || Slidescale;
Endif;
OrderInfo.value := ThisMsg;
endif;
endif;
endif;
If CallingField = "PRX_DM_PatientDietControlled|1" then
If DietControlled_CB.value = False then
MultipleOralOrInsulin_CB.control_read_only := False;
SingleOral_CB.control_read_only := False;
DietControlled_CB.control_read_only := False;
InsulinPump_CB.control_read_only := False;
ElseIf DietControlled_CB.value = True then
BasalInsulinList.IsSelected := (False);
Endo_ConsultList.IsSelected := (False, True);
Physician_ConsultList.IsSelected := (False);
InsulinLowDoseList.IsSelected := (False);
InsulinModDoseList.IsSelected := (False);
InsulinHighDoseList.IsSelected := (False);
MultipleOralOrInsulin_CB.value := False;
MultipleOralOrInsulin_CB.Control_Read_Only := True;
SingleOral_CB.value := False;
SingleOral_CB.Control_Read_Only := True;
InsulinPump_CB.value := False;
InsulinPump_CB.Control_Read_Only := True;
ThisMsg := " " || CRLF;
OrderInfo.value := ThisMsg;
if Diet is not null or UnsubDietOrderExists then
BGMFrequency.FrequencySummary := "QID (AC and HS)";
elseif NPO is not null or UnsubNPOOrderExists then
BGMFrequency.FrequencySummary := "Q6H";
else
dialogResult3 := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n Unable to retrieve any diet orders. \n Is this patient NPO? ","Alert","YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}};
if((dialogResult3 as string) = "Yes") then
BGMFrequency.FrequencySummary := "Q6H";
else
BGMFrequency.FrequencySummary := "QID (AC and HS)";
endif;
endif;
endif;
endif;
endif;
If callingEvent = "FormClose" and (CurrentLoc = "ER Major" or CurrentLoc matches pattern "ER-%" )then
GlucoseName, GlucoseValue, GlucoseUom, GlucoseDone, GlucoseAbn := read last
{"Select top 1 bo.ItemName, bo.value , bo.UnitOfMeasure, o.performeddtm, bo.AbnormalityCode
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(clientguid) || "
and o.performeddtm >= (DATEADD(hour, -12, getdate()))
and bo.itemname in ({{{SINGLE-QUOTE}}}Glucose Non-Fasting{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Glucose Bedside{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Glucose Bedside.{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Glucose Fasting{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Glucose Fasting from Blood Gas{{{SINGLE-QUOTE}}}
,{{{SINGLE-QUOTE}}}Glucose from Blood Gas{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Glucose, ABG, POC{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Glucose, VBG, POC{{{SINGLE-QUOTE}}})
and bo.AbnormalityCode in ({{{SINGLE-QUOTE}}}H{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}HH{{{SINGLE-QUOTE}}})
and bo.value > {{{SINGLE-QUOTE}}}300{{{SINGLE-QUOTE}}}
order by o.performeddtm desc "
};
If GlucoseValue is not null then
DiabeticMedTask, DiabeticMedName, MedGiven, DoseGiven, UomGiven, OrderDate := read last
{" select oto.TaskStatusCode, ocmi.Name, oto.PerformedFromDtm, oto.TaskDose, oto.TaskUom, o.RequestedDtm from CV3OrderTaskOccurrence oto
join cv3order o on o.guid = oto.OrderGUID
join CV3MedicationExtension me on me.guid = o.guid
join CV3OrderCatalogMasterItem ocmi on ocmi.guid = o.OrderCatalogMasterItemGUID
where clientvisitguid = " || SQL(ClientVisitGuid) || " and oto.clientguid = " || SQL(ClientGuid) || "
and o.typecode = {{{SINGLE-QUOTE}}}Medication{{{SINGLE-QUOTE}}}
and oto.TaskStatusCode not in ({{{SINGLE-QUOTE}}}Canceled{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Not Performed{{{SINGLE-QUOTE}}})
and ocmi.TherapeuticCategory = {{{SINGLE-QUOTE}}}metabolic agents | antidiabetic agents{{{SINGLE-QUOTE}}}
and oto.ScheduledDtm > DATEadd (HH, -12, getdate())
order by oto.TaskStatusCode "
};
If DiabeticMedTask is not null then
If DiabeticMedTask = "Performed" then
InfoMsg := "Patient received " || DiabeticMedName || " " || DoseGiven || " " || UOMGiven || " at " || MedGiven;
else
InfoMsg := "Patient has been ordered " || DiabeticMedName || " at " || OrderDate;
endif;
else
InfoMsg := " ";
endif;
Create_STAT_Order := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_CREATE_MED_ORDER{{{SINGLE-QUOTE}}};
SessionType := "Standard";
OrderSource := "Protocol Order";
OrderFrequency := "STAT";
numgrids := 3;
k := 1;
grid_count := 1 seqto numgrids;
for k in grid_count do
Currentgrid := last of (field_list where field_list.DataItemName = "MultiOrderInline"
and field_List.Control_MultiFieldOccNum = k);
gridval := currentgrid.value;
index_list := 1 seqto (count gridval) ;
if exist currentgrid then
for M in index_list do
selorders := gridval.IsSelected [M];
if selorders = true then
main_order_name := Gridval.Name [M] ;
If main_order_name = "Insulin Aspart Inj" then
OrderName := main_order_name;
If k = 1 then ItemModifier := "Low Dose - ED Coverage";
elseif k = 2 then ItemModifier := "Moderate Dose - ED Coverage";
elseif k = 3 then ItemModifier := "High Dose - ED Coverage";
endif;
dialogResult4 := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n Patient has a " ||GlucoseName || " of " || GlucoseValue || " " || GlucoseUom || " on " ||GlucoseDone ||
"\n\n " || infomsg ||
"\n Do you wish to order a dose to be administered now? ","Alert","YesNo" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}};
if((dialogResult4 as string) = "Yes") then
Coverage := Call Create_STAT_Order with (ClientVisitGuid,UserGuid,ClientGUID,SessionType,OrderSource,OrderName,ItemModifier,"Medication",this_communication.CareProviderGUID) ;
endif;
endif;
endif;
enddo;
endif;
enddo;
endif;
endif;
// 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;
;;
end: