Initial Checking with all 820 MLMs

This commit is contained in:
2020-02-02 00:54:01 -05:00
parent c59dc6de2e
commit 840d0432f4
828 changed files with 239162 additions and 0 deletions

View File

@@ -0,0 +1,530 @@
maintenance:
title: FORM_Set_Code_Status;;
mlmname: FORM_Set_Code_Status;;
arden: version 2.5;;
version: 5.50;;
institution: St Clair Hospital;;
author: Dean Miklavic;;
specialist: Don Warnick;;
date: 2016-02-11;;
validation: testing;;
library:
purpose: Prevent the user from leaving the Code Status order set w/o selecting a code status order and a cpr order
;;
explanation: This MLM is called from the Code Status Order Set
Change history
02.09.2016 - DJW CSR# 33949 - Change to wording of Code Status and CPR orders
09.14.2017 - JML CSR# 26413 - Modify order set to allow physician to enter a "temporary" code status, "Ethically unable to determine....".
02.16.2018 JML CSR# 26413 - Changed historical code status SQL to only pull from most recent previous visit; fix reorder historical
selection to ensure the last historical code status is always selected.
05.23.2018 JML CSR# 36342 - Modified MLM to allow for historical Code Status values to be reorder since verbiage change.
;;
keywords: Called MLMs,
;;
knowledge:
type: data-driven;;
data:
(this_communication, this_form, client_info_obj) := argument;
standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
include standard_libs;
using "ObjectsPlusXA.SCM.Forms";
using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms";
log_execution_info := FALSE;
error_message:="";
dc_order := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_DISCONTINUE_ORDER{{{SINGLE-QUOTE}}};
field_list:= this_form.fields;
client_guid := this_communication.ClientGUID;
visit_guid := this_communication.ClientVisitGUID;
chart_guid := this_communication.ChartGuid;
user_guid := this_communication.UserGUID;
CallingEvent := this_communication.CallingEvent;
CallingField := this_communication.CallingFieldName;
falseCPRList := ();
falseCSList := ();
CodeStatusLabel := "";
// VISIBLE FIELDS
PriorOrders := first of (field_list where field_list.DataItemName = "NUR_Code Status" and field_List.Control_MultiFieldOccNum = 1);
CPRGrid := first of (field_list where field_list.DataItemName = "MultiOrderGrid" and field_List.Control_MultiFieldOccNum = 1);
CodeStatusGrid := first of (field_list where field_list.DataItemName = "MultiOrderGrid" and field_List.Control_MultiFieldOccNum = 2);
ReorderInstruct:= last of ( field_list where field_list.DataItemName = "NUR_CodeStatus_Instructions" and field_list.Control_MultiFieldOccNum = 4);
Reorder := last of ( field_list where field_list.DataItemName = "NUR_Code Status CB1" and field_list.Control_MultiFieldOccNum = 1);
EthicalOrders := last of ( field_list WHERE field_list.DataItemname = "MultiOrderGrid" AND field_list.Control_MultiFieldOccNum = 4 );
ConsultOrders := last of ( field_list WHERE field_list.DataItemName = "MultiOrderGrid" AND field_list.Control_MultiFieldOccNum = 5 );
DC_CodeStatuses_CK := last of ( field_list WHERE field_list.DataItemName = "NUR_Code Status CB2 DC" AND field_list.Control_MultiFieldOccNum = 1 );
// DC_EthicalOrder_CK := last of ( field_list WHERE field_list.DataItemName = "NUR_Code Status CB3 DC1" AND field_list.Control_MultiFieldOccNum = 1 );
// HIDDEN FIELDS
// Current Summary Line information for compare to prior order summary line. If then name & summary match the prior order, the grid row number will be saved
CodeStatus_CMO_Summary:= first of (field_list where field_list.DataItemName = "NUR_NewCMO_Summary" and field_List.Control_MultiFieldOccNum = 1);
CodeStatus_LI_Summary := first of (field_list where field_list.DataItemName = "NUR_NewLI_Summary" and field_List.Control_MultiFieldOccNum = 1);
CodeStatus_FT_Summary := first of (field_list where field_list.DataItemName = "NUR_NewFT_Summary" and field_List.Control_MultiFieldOccNum = 1);
CPR_Summary := first of (field_list where field_list.DataItemName = "NUR_NewCPR_Summary" and field_List.Control_MultiFieldOccNum = 1);
DNR_Summary := first of (field_list where field_list.DataItemName = "NUR_NewDNR_Summary" and field_List.Control_MultiFieldOccNum = 1);
// These hidden fields store grid row number of the order that matches the prior order (if no match, 999 is stored in the field)
Code_Status_Grid_Value_Match:= first of (field_list where field_list.DataItemName = "NUR_CodeSt Order Match" and field_List.Control_MultiFieldOccNum = 1);
CPR_Grid_Value_Match := first of (field_list where field_list.DataItemName = "NUR_CodeSt CPR Order Match" and field_List.Control_MultiFieldOccNum = 1);
MissingOrderBox:= first of (field_list where field_list.DataItemName = "Nur_CPR_MI_Orders" and field_List.Control_MultiFieldOccNum = 1);
CPRGridValue := CPRGrid.value;
CodeStatusGridValue := CodeStatusGrid.value;
EthicalOrdersValue := EthicalOrders.Value;
ConsultOrdersValue := ConsultOrders.Value;
CPR := CPRGrid.Value[1];
DNR := CPRGrid.Value[2];
CMO := CodeStatusGrid.Value[3];
LI := CodeStatusGrid.Value[2];
FT := CodeStatusGrid.Value[1];
EUD := EthicalOrders.Value[1];
for i IN 1 seqto ( count CPRGridValue.IsSelected ) do
falseCPRList := falseCPRList, false;
enddo;
for j IN 1 seqto ( count CodeStatusGridValue.IsSelected ) do
falseCSList := falseCSList, false;
enddo;
// Form Open
If CallingEvent = "FormOpen" then
(clientVisitStatus, codestatusorder, cprorder, discussionorder, codestatusordername,
codestatussummary, cprordername, cprsummary,
ethicalorder, ethicalorderonly, ethicalsummaryonly) := read last
{"CREATE TABLE #tmp_aaa (ID int IDENTITY(1, 1), ordername varchar(300), clientvisitguid varchar (16), clientVisitStatus varchar(6), summaryline varchar(500), enteredtime datetime, ordertype varchar(1), "
|| " CPRorder varchar(300), EthicalOrder varchar(300), Discussionorder varchar(300), CPRorderOnly varchar(300), CPRSummaryOnly varchar(300), EthicalOrderOnly varchar(300), EthicalSummaryOnly varchar(300))"
|| " SET CONCAT_NULL_YIELDS_NULL off"
|| " INSERT INTO #tmp_aaa (ordername,clientvisitguid, clientVisitStatus, summaryline , enteredtime, ordertype) "
|| " select o.Name,o.ClientVisitGUID as varchar, cv.VisitStatus, isnull (substring( o.SummaryLine, 3, 498), {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}}) , o.createdwhen,"
|| " case when ocmi.name like {{{SINGLE-QUOTE}}}code status:%{{{SINGLE-QUOTE}}} and ocmi.name not like {{{SINGLE-QUOTE}}}code status: ethical%{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} "
|| " when ocmi.name like {{{SINGLE-QUOTE}}}cpr%{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} "
|| " when ocmi.name like {{{SINGLE-QUOTE}}}dnr%{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} "
|| " when ocmi.name like {{{SINGLE-QUOTE}}}code status discussion%{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}3{{{SINGLE-QUOTE}}} "
|| " when ocmi.name like {{{SINGLE-QUOTE}}}code status: Ethical%{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}4{{{SINGLE-QUOTE}}}"
|| " else {{{SINGLE-QUOTE}}}5{{{SINGLE-QUOTE}}}"
|| " end {{{SINGLE-QUOTE}}}ordertype{{{SINGLE-QUOTE}}}"
|| " from CV3OrderCatalogMasterItem ocmi with (nolock) join CV3Order o with (nolock) on o.OrderCatalogMasterItemGUID = ocmi.GUID"
|| " JOIN CV3ClientVisit cv WITH (NOLOCK) on o.ClientVisitGUID = cv.GUID"
|| " AND o.ClientGuid = cv.ClientGuid and o.ChartGuid = cv.ChartGuid"
|| " where o.clientguid = " || SQL(client_guid)
|| " and ( ocmi.name like {{{SINGLE-QUOTE}}}Code Status%{{{SINGLE-QUOTE}}}"
|| " or ocmi.name like {{{SINGLE-QUOTE}}}cpr%{{{SINGLE-QUOTE}}} "
|| " or ocmi.name like {{{SINGLE-QUOTE}}}dnr%{{{SINGLE-QUOTE}}}) "
|| " and o.OrderStatusLevelNum >= 15 "
|| " and o.OrderStatusCode not in ({{{SINGLE-QUOTE}}}DISC{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}CANC{{{SINGLE-QUOTE}}})"
|| " and cv.VisitStatus = {{{SINGLE-QUOTE}}}DSC{{{SINGLE-QUOTE}}}"
|| " and o.InitialSessionTypeCode = {{{SINGLE-QUOTE}}}Standard{{{SINGLE-QUOTE}}}"
|| " order by o.clientvisitguid, ordertype, cast( convert(char(16), o.CreatedWhen,120) as varchar)"
|| " update t1 "
|| " set t1.CPRorder = cast( convert(char(10), t2.enteredtime,110) as varchar) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + cast( convert(char(5), t2.enteredtime,114) as varchar) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + t2.ordername + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + t2.summaryline ,"
|| " t1.discussionorder =cast( convert(char(10), t3.enteredtime,110) as varchar) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + cast( convert(char(5), t3.enteredtime,114) as varchar) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + t3.ordername + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + t3.summaryline, "
|| " t1.CPRorderOnly = t2.ordername, t1.CPRSummaryOnly = t2.summaryline"
|| " from #tmp_aaa t1 inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.clientvisitguid = t2.clientvisitguid and t1.ordertype = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} and t2.ordertype = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}}"
|| " inner join #tmp_aaa t3 on t3.id = t1.id +2 and t1.clientvisitguid = t3.clientvisitguid and t1.ordertype = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} and t3.ordertype = {{{SINGLE-QUOTE}}}3{{{SINGLE-QUOTE}}}"
|| " UPDATE T1"
|| " SET t1.EthicalOrder = cast( convert(char(10), t4.enteredtime,110) as varchar) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + cast( convert(char(5), t4.enteredtime,114) as varchar) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + t4.ordername + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + t4.summaryline,"
|| " t1.EthicalOrderOnly = t4.ordername, t1.EthicalSummaryOnly = t4.summaryline"
|| " FROM #tmp_aaa t1 INNER JOIN #tmp_aaa t4 ON t4.ID = t1.ID + 3 AND t1.clientvisitguid = t4.clientvisitguid AND t1.ordertype = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} AND t4.ordertype = {{{SINGLE-QUOTE}}}4{{{SINGLE-QUOTE}}}"
|| " delete from #tmp_aaa where ordertype <> {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}}"
|| " delete from #tmp_aaa where enteredtime < GETDATE () -730"
|| " select clientVisitStatus, cast( convert(char(10), enteredtime,110) as varchar) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + cast( convert(char(5), enteredtime,114) as varchar) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + ordername + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + summaryline ,"
|| " CPRorder, Discussionorder, ordername, summaryline, CPRorderOnly , CPRSummaryOnly, EthicalOrder, EthicalOrderOnly, EthicalSummaryOnly"
|| " from #tmp_aaa "
|| " order by enteredtime"
|| " drop table #tmp_aaa"
} ;
//Retrieve Current Code Status order
( curr_order,
curr_orderSequence ) := read { "SELECT CONVERT(varchar(26), o.CreatedWhen, 120 ) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + o.Name + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + ISNULL ( SUBSTRING( o.SummaryLine, 3, 498), {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}}) , "
|| " CASE WHEN ocmi.Name LIKE {{{SINGLE-QUOTE}}}code status:%{{{SINGLE-QUOTE}}} AND ocmi.Name NOT LIKE {{{SINGLE-QUOTE}}}code status: ethical%{{{SINGLE-QUOTE}}} THEN {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} "
|| " WHEN ocmi.Name LIKE {{{SINGLE-QUOTE}}}cpr%{{{SINGLE-QUOTE}}} THEN {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} "
|| " WHEN ocmi.Name LIKE {{{SINGLE-QUOTE}}}dnr%{{{SINGLE-QUOTE}}} THEN {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} "
|| " WHEN ocmi.Name LIKE {{{SINGLE-QUOTE}}}code status discussion%{{{SINGLE-QUOTE}}} THEN {{{SINGLE-QUOTE}}}4{{{SINGLE-QUOTE}}} "
|| " WHEN ocmi.Name LIKE {{{SINGLE-QUOTE}}}code status: Ethical%{{{SINGLE-QUOTE}}} THEN {{{SINGLE-QUOTE}}}3{{{SINGLE-QUOTE}}}"
|| " ELSE {{{SINGLE-QUOTE}}}5{{{SINGLE-QUOTE}}}"
|| " END {{{SINGLE-QUOTE}}}OrderType{{{SINGLE-QUOTE}}}"
|| " FROM CV3OrderCatalogMasterItem ocmi WITH (NOLOCK) JOIN CV3Order o WITH (NOLOCK)"
|| " ON o.OrderCatalogMasterItemGUID = ocmi.GUID"
|| " JOIN CV3ClientVisit cv WITH (NOLOCK) "
|| " ON o.ClientVisitGUID = cv.GUID"
|| " AND o.ClientGuid = cv.ClientGuid AND o.ChartGuid = cv.ChartGuid"
|| " WHERE o.ClientGUID = " || SQL(client_guid)
|| " AND ( ocmi.Name LIKE {{{SINGLE-QUOTE}}}Code Status%{{{SINGLE-QUOTE}}}"
|| " OR ocmi.Name LIKE {{{SINGLE-QUOTE}}}cpr%{{{SINGLE-QUOTE}}} "
|| " OR ocmi.Name LIKE {{{SINGLE-QUOTE}}}dnr%{{{SINGLE-QUOTE}}}) "
|| " AND o.OrderStatusLevelNum >= 15 "
|| " AND o.OrderStatusCode NOT IN ({{{SINGLE-QUOTE}}}DISC{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}CANC{{{SINGLE-QUOTE}}})"
|| " AND cv.VisitStatus = {{{SINGLE-QUOTE}}}ADM{{{SINGLE-QUOTE}}}"
|| " AND o.InitialSessionTypeCode = {{{SINGLE-QUOTE}}}Standard{{{SINGLE-QUOTE}}}"
|| " ORDER BY o.ClientVisitGUID, OrderType, CAST( CONVERT( char(16), o.CreatedWhen, 120 ) AS VARCHAR )" };
CR := 13 formatted with "%c";
LF := 10 formatted with "%c";
CRLF:= CR||LF;
PriorOrders.Value := "";
//If current orders exist, add them to display box at top of order set
if exists ( curr_order ) then
CodeStatusLabel := "Current" || CRLF || "-----------" || CRLF;
PriorOrders.Value := PriorOrders.Value || CodeStatusLabel;
for i IN ( 1 seqto count curr_order ) DO
PriorOrders.Value := PriorOrders.Value || curr_order[i] || CRLF;
enddo;
PriorOrders.Value := PriorOrders.Value || CRLF || CRLF;
else
DC_CodeStatuses_CK.Control_Read_Only := true;
endif;
// If there is no order, change the null value to a blank (required for formatting in the prior order text box)
if not exist codestatusorder then codestatusorder := " "; endif;
if not exist cprorder then cprorder := " "; endif;
if not exist discussionorder then discussionorder := " "; endif;
if not exist ethicalorder then ethicalorder := " "; endif;
// If past orders are found display them in the visible "Prior Orders" box and write the components to hidden fields for later compare
If codestatusorder || cprorder || discussionorder || ethicalorder = " " then
PriorOrders.value := PriorOrders.Value || "No historical orders to display";
Reorder.Control_Read_Only := True;
ReorderInstruct.Value := "There were NO Code Status orders found within the last 2 years. Please select new Code Status orders";
else
CodeStatusLabel := "Historical (previous visit)" || CRLF || "--------------------------------------" || CRLF;
PriorOrders.Value := PriorOrders.Value || CodeStatusLabel || cprorder || CRLF || codestatusorder || CRLF;
if ( ethicalorder <> " " ) then
PriorOrders.Value := PriorOrders.Value || ethicalorder || CRLF;
endif;
PriorOrders.Value := PriorOrders.Value || discussionorder;
endif;
// Set the "SummaryLine Compare Value" for the CPR & CS order to the matching value stored in the Summary value at the bottom of the form (these are the "current" summary line values)
If codestatusordername = "Code Status: Comfort Measures Only" then SummaryCompare_CS := CodeStatus_CMO_Summary.Value; endif;
if codestatusordername = "Code Status: Limited Interventions" then SummaryCompare_CS := CodeStatus_LI_Summary.Value; endif;
if codestatusordername = "Code Status: Full Treatment" then SummaryCompare_CS := CodeStatus_FT_Summary.Value; endif;
if cprordername = "CPR/Attempt Resuscitation" then
SummaryCompare_CPR := CPR_Summary.Value;
SummaryCompare_OldCPR := "If patient is PULSELESS AND APNEIC"; //JML CSR 36342: old verbiage
endif;
if cprordername = "DNR/Do Not Attempt Resuscitation" then
SummaryCompare_CPR := DNR_Summary.Value;
SummaryCompare_OldCPR := "Allow natural death if patient is PULSELESS AND APNEIC"; //JML CSR 36342: old verbiage
endif;
// Compare the Prior Code Status Name to each name in the Grid. If a match is found, compare the Prior Summary line to the "current" summary line
Code_Status_Grid_Value_Match.Value := 999;
index_list := 1 seqto (count CodeStatusGrid.Value);
for I in index_list do
// Name match
if codestatusordername = CodeStatusGrid.Value[I].Name then
// SummaryLine match
if codestatussummary = SummaryCompare_CS then
Code_Status_Grid_Value_Match.Value := I;
endif;
endif;
enddo;
// Compare the Prior CPR Name to each name in the Grid. If a match is found, compare the Prior Summary line to the "current" summary line
CPR_Grid_Value_Match.value := 999;
index_list := 1 seqto (count CPRGrid.Value);
for J in index_list do
// Name match
if cprordername = CPRGrid.Value[J].Name then
// SummaryLine match
if cprsummary = SummaryCompare_CPR OR cprsummary = SummaryCompare_OldCPR then //JML CSR 36342: test for old verbiage as well as new
CPR_Grid_Value_Match.value := J;
endif;
endif;
enddo;
// If a partial or full match is found, then enable the "re-order button"
if Code_Status_Grid_Value_Match.Value <> 999 or CPR_Grid_Value_Match.value <> 999 and PriorOrders.value <> "No orders to display" then
Reorder.Control_Read_Only := False;
ReorderInstruct.Value := "Click on the checkbox below to acknowledge the previous Code Status Order(s) and to reorder for this visit. Must be an exact match.";
endif;
// If neither the Code Status nor the CPR orders on file match the new format, then disable the "re-order button"
if Code_Status_Grid_Value_Match.Value = 999 and CPR_Grid_Value_Match.value = 999 and PriorOrders.value <> "No orders to display" then
Reorder.Control_Read_Only := True;
ReorderInstruct.Value := "Previous Code Status orders found that do not match current format. Please select new Code Status orders.";
endif;
endif; // Form Open
// Field Change
If this_communication.CallingEvent ="FieldChange" Then
// CPR Order was selected
If this_communication.CallingFieldName = "MultiOrderGrid|1" Then
Reorder.Value := False;
CPRGridValue.IsReadonly := falseCPRList;
if NOT ( true IN CodeStatusGridValue.IsSelected ) then
EthicalOrdersValue.IsReadonly := false;
endif;
if EUD.IsSelected = true then
EthicalOrdersValue.IsSelected := false;
endif;
if CPR.IsSelected = True then
CPRGridValue.IsReadonly := (false,true);
EthicalOrdersValue.IsReadonly := true;
endif;
if DNR.IsSelected = True then
CPRGridValue.IsReadonly := (true,false);
EthicalOrdersValue.IsReadonly := true;
endif;
endif;
// Code Status Order was selected
If this_communication.CallingFieldName = "MultiOrderGrid|2" Then
Reorder.Value := False;
CodeStatusGridValue.IsReadonly := falseCSList;
if ( NOT ( true IN CPRGridValue.IsSelected ) ) then
EthicalOrdersValue.IsReadonly := false;
endif;
if EUD.IsSelected = True then
EthicalOrdersValue.IsSelected := false;
endif;
if CMO.IsSelected = True then
CodeStatusGridValue.IsReadonly := (true,true,false);
EthicalOrdersValue.IsReadonly := true;
endif;
if LI.IsSelected = True then
CodeStatusGridValue.IsReadonly := (true,false,true);
EthicalOrdersValue.IsReadonly := true;
endif;
if FT.IsSelected = True then
CodeStatusGridValue.IsReadonly := (false,true,true);
EthicalOrdersValue.IsReadonly := true;
endif;
endif;
// Reorder Checkbox was selected
if this_communication.CallingFieldName ="NUR_Code Status CB1|1" then
// "Reorder" checkbox is deselected - enable the order buttons
If Reorder.Value = False Then
CPR.IsSelected := false; CPR.IsReadOnly := False;
DNR.IsSelected := false; DNR.IsReadOnly := False;
CMO.IsSelected := false; CMO.IsReadOnly := False;
LI.IsSelected := false; LI.IsReadOnly := False;
FT.IsSelected := false; FT.IsReadOnly := False;
DC_CodeStatuses_CK.Value := false;
Else // "Reorder" checkbox is selected
// If a Code Status or CPR match was found, disable the order buttons and select the order grid item stored in the hidden fields
if Code_Status_Grid_Value_Match.Value <> "999" then
CMO.IsSelected := false; CMO.IsReadOnly := True;
LI.IsSelected := false; LI.IsReadOnly := True;
FT.IsSelected := false; FT.IsReadOnly := True;
CodeStatusGrid.Value[Code_Status_Grid_Value_Match.Value as number].IsSelected := True;
CodeStatusGrid.Value[Code_Status_Grid_Value_Match.Value as number].IsReadOnly := False;
endif;
if CPR_Grid_Value_Match.Value <> "999" then
CPR.IsSelected := false; CPR.IsReadOnly := True;
DNR.IsSelected := false; DNR.IsReadOnly := True;
CPRGrid.Value[CPR_Grid_Value_Match.Value as number].IsSelected := True;
CPRGrid.Value[CPR_Grid_Value_Match.Value as number].IsReadOnly := False;
endif;
//Auto-check "DC: Ethically unable to determine"
DC_CodeStatuses_CK.Value := true;
endif; // Reorder checkbox slected or deselected
endif; // Reorder checkbox changed
// Ethical Order
if this_communication.CallingFieldName = "MultiOrderGrid|4" then
if ( EUD.IsSelected = true ) then
if ( true IN CPRGridValue.IsSelected ) then
CPRGridValue.IsSelected := falseCPRList;
endif;
CPR.IsSelected := true;
CPRGridValue.IsReadOnly := ( false, true );
if ( true IN CodeStatusGridValue.IsSelected ) then
CodeStatusGridValue.IsSelected := falseCSList;
endif;
FT.IsSelected := true;
CodeStatusGridValue.IsReadOnly := ( false, true, true );
else
CodeStatusGridValue.IsSelected := falseCSList;
CodeStatusGridValue.IsReadOnly := falseCSList;
CPRGridValue.IsSelected := falseCPRList;
CPRGridValue.IsReadOnly := falseCPRList;
endif;
endif;
//Consult Orders
if this_communication.CallingFieldName = "MultiOrderGrid|5" then
if ( true IN ConsultOrdersValue.IsSelected ) then
if ( ( NOT ( true IN CPRGridValue.IsSelected ) ) AND ( NOT ( true IN CodeStatusGridValue.IsSelected ) ) ) then
EUD.IsSelected := true;
CPR.IsSelected := true;
CPRGridValue.IsReadOnly := ( false, true );
FT.IsSelected := true;
CodeStatusGridValue.IsReadOnly := ( false, true, true );
endif;
else
if ( EUD.IsSelected = true ) then
EUD.IsSelected := false;
CPRGridValue.IsSelected := falseCPRList;
CPRGridValue.IsReadOnly := falseCPRList;
CodeStatusGridValue.IsSelected := falseCSList;
CodeStatusGridValue.IsReadOnly := falseCSList;
endif;
endif;
endif;
//DC_CodeStatuses_CK & DC_EthicalOrder_CK
if ( this_communication.CallingFieldName = "NUR_Code Status CB2 DC|1" ) then
if DC_CodeStatuses_CK.Value = true then
DC_EthicalOrder_CK.Value := false;
endif;
endif;
if ( this_communication.CallingFieldName = "NUR_Code Status CB3 DC1|1" ) then
if ( DC_EthicalOrder_CK.Value = true ) then
DC_CodeStatuses_CK.Value := false;
endif;
endif;
endif; // Field Change
// Form Close
If CallingEvent = "FormClose" then
if true in CPRGridValue.IsSelected then
cpr_was_selected := "true";
else
cpr_was_selected := "false";
endif;
If true in CodeStatusGridValue.IsSelected then
codestatus_was_selected := "true";
else
codestatus_was_selected := "false";
endif;
If codestatus_was_selected = "true" and cpr_was_selected = "true" then
MissingOrderBox.Value := "CPR and Code Status Order were entered";
endif;
// Handle DC_CodeStatuses_CK and DC_EthicalOrder_CK discontinue logic
if ( DC_CodeStatuses_CK.Value = true OR DC_EthicalOrder_CK.Value = true ) then
if ( DC_CodeStatuses_CK.value = true ) then
order_names_to_filter := "{{{SINGLE-QUOTE}}}Code Status Discussion{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Code Status: Comfort Measures Only{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Code Status: Limited Interventions{{{SINGLE-QUOTE}}},"
|| "{{{SINGLE-QUOTE}}}Code Status: Full Treatment{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}CPR/Attempt Resuscitation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}DNR/Do Not Attempt Resuscitation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Code Status: Ethically unable to determine{{{SINGLE-QUOTE}}}";
endif;
if ( DC_EthicalOrder_CK.Value = true ) then
order_names_to_filter := "{{{SINGLE-QUOTE}}}Code Status Discussion{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Code Status: Ethically unable to determine{{{SINGLE-QUOTE}}}";
endif;
//Need to grab Order GUIDs of previous orders
( orderGUID, orderName ) := read {"SELECT o.GUID, o.Name"
|| " FROM CV3ClientVisit cv JOIN CV3ORDER o"
|| " ON cv.GUID = o.ClientVisitGUID"
|| " AND cv.ClientGUID = o.ClientGUID"
|| " AND cv.ChartGUID = o.ChartGUID"
|| " WHERE cv.ClientGUID = " || SQL(client_guid)
|| " AND cv.GUID = " || SQL(visit_guid)
|| " AND cv.ChartGUID = " || SQL(chart_guid)
|| " AND o.Name IN (" || order_names_to_filter || ")"
|| " AND o.OrderStatusLevelNum >= 15"
|| " AND o.OrderStatusCode not in ({{{SINGLE-QUOTE}}}DISC{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}CANC{{{SINGLE-QUOTE}}})"};
if ( exists orderGUID ) then
MissingOrderBox.Value := "CPR and CodeStatus Order were entered.";
for i IN 1 seqto ( count orderGUID ) do
a := orderName[i];
rtnValue := call dc_order WITH visit_guid, user_guid, orderGUID[i], "Code Status Order Discontinue";
enddo;
endif;
endif;
endif; // Form Close
;;
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: