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

196 lines
6.5 KiB
Plaintext

maintenance:
title: FORM_DISCHARGE_ORDER_RESTRICT_ACTIVITY;;
mlmname: FORM_DISCHARGE_ORDER_RESTRICT_ACTIVITY;;
arden: version 2.5;;
version: 5.50;;
institution: St Clair Charger MLM;;
author: Juliet Johns, Allscripts, Inc;;
specialist: Amanda Kirsopp, Allscripts, Inc;;
date: 2013-04-04;;
validation: testing;;
library:
purpose: This MLM restricts the selection of mutually exclusive activities in the Activity on Discharge order.
;;
explanation: This MLM will not allow contradicting activities to be selected within the Activity on Discharge order.
For example, if the user selects "Drive with caution" under the Activity section, this MLM will
disable the "No driving" checkbox under the Activity Restricted section.
;;
keywords: Called MLMs, Form fields, Discharge Orders, Activity on Discharge
;;
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;
// RS ADD Message box
standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
include standard_libs;
//String Parsing Lib
str_parse := mlm {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}};
/*******************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;
CallingField :=this_communication.CallingFieldName;
CallingEvent := this_communication.CallingEvent;
FormType := this_communication.FormType;
//Define activities List
discharge_activity_list := ("Drive with caution",
"May shower",
"May return to work",
"May resume sexual activity",
"Short walks are encouraged",
"May use steps");
discharge_restrict_list := ("No driving",
"May not shower",
"May not return to work",
"May not resume sexual activity",
"Limit walking",
"May not use steps");
//Retrieve relevant fields
Disch_Activity := last of (field_list WHERE field_list.DataItemName = "SCH_DI Activity Approved");
Disch_Restricted := last of (field_list WHERE field_list.DataItemName = "DISC_Activity Restricted");
Disch_Diet := last of (field_list WHERE field_list.DataItemName = "DISC_DIET");
if (CallingEvent = "FieldChange") then
if (CallingField = "SCH_DI Activity Approved" OR CallingField = "DISC_Activity Restricted") then
//Activities selected by user
activity_list := CALL str_parse WITH Disch_Activity.Value, ";";
//Restrictions selected by user
restrict_list := CALL str_parse WITH Disch_Restricted.Value, ";";
aa := "";
//Loop through restricted activities selected by the user
for i in 1 seqto (count restrict_list) do
//Check to see if a potential conflicting restriction was selected by the user
// based on the predefined list (above)
if (Trim(restrict_list[i]) NOT IN discharge_restrict_list) then
//Potential conflict was not selected
//Begin building Restricted Activity List
if (aa = "") then
aa := restrict_list[i];
else
aa := aa || ";" || restrict_list[i];
endif;
else
//Potential conflicting restriction was selected by user
//Retrieve index in discharge_restrict_list where potential conflict occurs
bool := true;
k := 1;
while bool = true do
if (discharge_restrict_list[k] = Trim(restrict_list[i])) then
bool := false;
contra_restrict_index := k;
else
k := k + 1;
endif;
enddo;
//Check for a match in the predefined conflicting activity list (above)
// and the activity list selected by user
// Needed to add a check for one item in activity list selected or multiple due to the need
// to trim extra spaces before and after conflicting activity to make a match
if (count activity_list = 1) then
if (Trim(discharge_activity_list[contra_restrict_index]) IN activity_list) then
displayMsg := true;
else
displayMsg := false;
endif;
else
if (Trim(discharge_activity_list[contra_restrict_index]) IN Trim(activity_list)) then
displayMsg := true;
else
displayMsg := false;
endif;
endif;
if (displayMsg) then
msg := "You selected contradicting activities, " || discharge_activity_list[contra_restrict_index]
|| ", and " || discharge_restrict_list[contra_restrict_index]
|| ". The restricted activity has been unselected."
|| " If you want the restriction, please unselect the activity.";
dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with msg, "Info", "Ok" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}};
else
//Conflict does not exist
//Build into restrictions value
if (aa = "") then
aa := restrict_list[i];
else
aa := aa || ";" || restrict_list[i];
endif;
endif;
endif;
enddo;
if (aa IS NULL OR aa = "") then
Disch_Restricted.Value := "";
else
Disch_Restricted.Value := aa;
endif;
elseif (CallingField = "DISC_DIET") then
diet_list := CALL str_parse WITH Disch_Diet.Value, ";";
bb := "";
for i in 1 seqto (count diet_list) do
if (count diet_list > 1) then
if (Trim(diet_list[i]) = "NPO") then
msg := "You selected contradicting diets with an NPO."
|| " The NPO diet has been unselected."
|| " If you want the NPO diet, please unselect all other diets.";
dialogRes := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with msg, "Info", "Ok" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}};
else
if (bb = "") then
bb := diet_list[i];
else
bb := bb || ";" || diet_list[i];
endif;
endif;
else
bb := diet_list[i];
endif;
enddo;
Disch_Diet.Value := bb;
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: