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,715 @@
maintenance:
title: FORM_VANCOMYCIN_AUTOSCHEDULING_TROUGH_ORDER;;
mlmname: FORM_VANCOMYCIN_AUTOSCHEDULING_TROUGH_ORDERS;;
arden: version 2.5;;
version: 15.10;;
institution: St Clair Hospital;;
author: Juliet M. Law, Allscripts ;;
specialist: Peggy Leschak, Allscripts;;
date: 2016-05-05;;
validation: testing;;
library:
purpose:
;;
explanation: This MLM is called from Vancomycin Orders - Trough order set.
Change history
2016.05.05 JML CSR 34155: Created
;;
keywords: Called MLMs
;;
knowledge:
type: data-driven;;
data:
standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
include standard_libs;
//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;
//Called MLMs
display_field_mlm := MLM {{{SINGLE-QUOTE}}}FORM_FUNC_DISPLAY_FORM_FIELD{{{SINGLE-QUOTE}}};
//Local session object
local_session := cds_session.local;
/*******************Make Changes To Spelling And Flags In This Section*******************/
/* Set to true if a decision.log is needed.*/
log_execution_info := FALSE;
//Boolean to determine if first administration needs calculated
calc_first_admin := false;
//Boolean to determine if Trough order is selected
is_trough_selected := false;
admin_to_autoSched := 0;
is_disc_trough_next := false;
/***************************************************************************************/
// Initialize error message
error_message:="";
// 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;
FormName := this_form.Name;
PrimaryObjDetail := this_communication.PrimaryObj;
OrderSetName := PrimaryObjDetail.OrderSetName;
isHoldSession := PrimaryObjDetail.InitialSessionTypeCode;
//Define fields
Trough_Requested_Date := first of ( field_list WHERE field_list.DataItemName = "RequestedDate" );
Trough_Requested_Time := first of ( field_list WHERE field_list.DataItemName = "RequestedTime" );
Trough_ReqTime_Value := Trough_Requested_Time.Value;
Trough_ReqTime_Value.ReqTimeCode := "Scheduled Time";
First_Admin_Chk := first of ( field_list WHERE field_list.DataItemName = "Lab_Chem_Dose_1st_Admin_CB" );
First_Admin_Date := first of ( field_list WHERE field_list.DataItemName = "Lab_Chem_Dose_1st_Admin_Date_TDM" );
First_Admin_Time := first of ( field_list WHERE field_list.DataItemname = "Lab_Chem_Dose_1st_Admin_Time_TDM" );
Second_Admin_Chk := first of ( field_list WHERE field_list.DataItemName = "Lab_Chem_Dose_2nd_Admin_CB" );
Second_Admin_Date := first of ( field_list WHERE field_list.DataItemName = "Lab_Chem_Dose_2nd_Admin_Date_TDM" );
Second_Admin_Time := first of ( field_list WHERE field_list.DataItemName = "Lab_Chem_Dose_2nd_Admin_Time_TDM" );
Third_Admin_Chk := first of ( field_list WHERE field_list.DataItemName = "Lab_Chem_Dose_3rd_Admin_CB" );
Third_Admin_Date := first of ( field_list WHERE field_list.DataItemName = "Lab_Chem_Dose_3rd_Admin_Date_TDM" );
Third_Admin_Time := first of ( field_list WHERE field_list.DataItemName = "Lab_Chem_Dose_3rd_Admin_Time_TDM" );
Fourth_Admin_Chk := first of ( field_list WHERE field_list.DataItemName = "Lab_Chem_Dose_4th_Admin_CB" );
Fourth_Admin_Date := first of ( field_list WHERE field_list.DataItemName = "Lab_Chem_Dose_4th_Admin_Date_TDM" );
Fourth_Admin_Time := first of ( field_list WHERE field_list.DataItemName = "Lab_Chem_Dose_4th_Admin_Time_TDM" );
Fifth_Admin_Chk := first of ( field_list WHERE field_list.DataItemName = "Lab_Chem_Dose_5th_Admin_CB" );
Fifth_Admin_Date := first of ( field_list WHERE field_list.DataItemName = "Lab_Chem_Dose_5th_Admin_Date_TDM" );
Fifth_Admin_Time := first of ( field_list WHERE field_list.DataItemName = "Lab_Chem_Dose_5th_Admin_Time_TDM" );
fieldLst := ( First_Admin_Chk, First_Admin_Date, First_Admin_Time,
Second_Admin_Chk, Second_Admin_Date, Second_Admin_Time,
Third_Admin_Chk, Third_Admin_Date, Third_Admin_Time,
Fourth_Admin_Chk, Fourth_Admin_Date, Fourth_Admin_Time,
Fifth_Admin_Chk, Fifth_Admin_Date, Fifth_Admin_Time
);
rtnValue := call display_field_mlm WITH this_communication, this_form, client_info_obj, fieldLst, true;
if ( CallingEvent = "FormOpen" OR ( CallingEvent = "FieldChange" AND NOT ( CallingField matches pattern "Lab_Chem_Dose%" ) ) ) then
//Retrieve session variable values for requested date and time on vanco ordered
vanco_session_date := local_session.SessionVancoTroughScheduledDate;
vanco_session_time_var := local_session.SessionVancoTroughScheduledTime;
vanco_session_time_priority := vanco_session_time_var.ReqTimeCode;
vanco_session_time_value := vanco_session_time_var.ReqTimeValue;
vanco_session_frequency := local_session.SessionVancoTroughFrequency;
if ( vanco_session_time_value IS NOT NULL ) then
//Determine if a loading dose of Vanco has been administered less than 12 hours ago
( load_exists,
load_given,
load_oAdminDtm,
load_admin ) := READ LAST {"SELECT 1, ot.TaskStatusCode, CASE WHEN ot.TaskStatusCode = {{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} THEN ot.PerformedFromDtm"
|| " ELSE o.RequestedDtm END,"
|| " CASE WHEN ot.TaskStatusCode = {{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} THEN DateDiff(hour, ot.PerformedFromDtm, GETDATE())"
|| " ELSE DATEDIFF(HOUR, o.RequestedDtm, GETDATE()) END"
|| " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3Order o WITH (NOLOCK)"
|| " ON cv.ClientGUID = o.ClientGUID"
|| " AND cv.GUID = o.ClientVisitGUID"
|| " AND cv.ChartGUID = o.ChartGUID"
|| " JOIN CV3OrderTaskOccurrence ot WITH (NOLOCK)"
|| " ON ot.ClientGUID = o.ClientGUID"
|| " AND ot.OrderGUID = o.GUID"
|| " WHERE o.NAME LIKE {{{SINGLE-QUOTE}}}VANCOMYCIN%{{{SINGLE-QUOTE}}}"
|| " AND o.FrequencyCode IN ({{{SINGLE-QUOTE}}}Once{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}STAT{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Now{{{SINGLE-QUOTE}}})"
|| " AND cv.ClientGUID = " || SQL(ClientGUID)
|| " AND cv.GUID = " || SQL(ClientVisitGUID)
|| " AND cv.ChartGUID = " || SQL(ChartGUID)
|| " AND DateDiff(hh, o.Entered, GETDATE()) <= 48"
|| " AND (o.OrderStatusLevelNum > 15"
|| " AND o.OrderStatusLevelNum NOT IN ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}))"
|| " ORDER BY o.Entered ASC"};
if ( not exists load_exists ) then
//Ordering load with order set
//Make load the 1st administration
spanhourfromnow := ( ( now as Time ) + 30 minute );
newstarttime := ( spanhourfromnow as time );
newhr := extract hour newstarttime;
newhr := newhr formatted with "%2.2d";
newyr := extract year newstarttime;
newmn := extract month newstarttime;
newmn := newmn formatted with "%2.2d";
newdd := extract day newstarttime;
newdd := newdd formatted with "%2.2d";
filldate := ( newyr ||"-" || newmn || "-" || newdd || " 00:00" ) as time;
filltime := newhr || ":00";
vanco_session_date := filldate;
vanco_session_time_value := filltime;
elseif ( exists load_exists AND ( load_given <> "Performed" AND ( load_admin as number ) <= 8 ) OR ( load_given = "Performed" AND ( load_admin as number ) <= 12 ) ) then
spanhourfromnow := ( ( load_oAdminDtm as Time ) + 30 minute );
newstarttime := ( spanhourfromnow as time );
newhr := extract hour newstarttime;
newhr := newhr formatted with "%2.2d";
newyr := extract year newstarttime;
newmn := extract month newstarttime;
newmn := newmn formatted with "%2.2d";
newdd := extract day newstarttime;
newdd := newdd formatted with "%2.2d";
filldate := (newyr || "-" || newmn || "-" || newdd || " 00:00") as time;
filltime := newhr || ":00";
vanco_session_date := filldate;
vanco_session_time_value := filltime;
else
//No Load
//Determine if a Vanco has been DC{{{SINGLE-QUOTE}}}d in last 3 hours
( disc_oGUID,
disc_osGUID ) := READ LAST {"SELECT o.GUID, o.OrderSetGUID"
|| " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3Order o WITH (NOLOCK)"
|| " ON cv.ClientGUID = o.ClientGUID"
|| " AND cv.GUID = o.ClientVisitGUID"
|| " AND cv.ChartGUID = o.ChartGUID"
|| " JOIN CV3OrderCatalogMasterItem ocmi WITH (NOLOCK)"
|| " ON o.OrderCatalogMasterItemGUID = ocmi.GUID"
|| " WHERE o.NAME LIKE {{{SINGLE-QUOTE}}}VANCOMYCIN:%{{{SINGLE-QUOTE}}}"
|| " AND o.FrequencyCode NOT IN ({{{SINGLE-QUOTE}}}Once{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Now{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}STAT{{{SINGLE-QUOTE}}})"
|| " AND o.OrderStatusCode = {{{SINGLE-QUOTE}}}DISC{{{SINGLE-QUOTE}}}"
|| " AND cv.ClientGUID = " || SQL(ClientGUID)
|| " AND cv.GUID = " || SQL(ClientVisitGUID)
|| " AND cv.ChartGUID = " || SQL(ChartGUID)
|| " AND DateDiff(HOUR, o.StopDtm, GETDATE()) <= 3"
|| " ORDER BY o.StopDtm" };
if ( exists disc_oGUID ) then
//Retrieve old dose & frequency
( disc_freq,
disc_dose,
disc_dose_uom,
disc_req_date,
disc_req_time,
disc_next_sched_admin) := READ LAST {"SELECT o.FrequencyCode, ot.OrderDosageLow, ot.OrderUOM, o.RequestedDate, o.RequestedTime"
|| " , oto.ScheduledDtm"
|| " FROM CV3Order o WITH (NOLOCK) JOIN CV3OrderTaskOccurrence oto WITH (NOLOCK)"
|| " ON o.GUID = oto.OrderGUID"
|| " AND o.ClientGUID = oto.ClientGUID"
|| " JOIN CV3OrderTask ot WITH (NOLOCK)"
|| " ON oto.OrderTaskGUID = ot.GUID"
|| " AND oto.ClientGUID = ot.ClientGUID"
|| " WHERE o.GUID = " || SQL(disc_oGUID)
|| " and oto.TaskStatusCode = {{{SINGLE-QUOTE}}}canceled{{{SINGLE-QUOTE}}}"
||" order by oto.ScheduledDtm" };
curr_dose := local_session.SessionVancoTroughDose;
curr_dose_uom := local_session.SessionVancoTroughUOM;
curr_freq := local_session.SessionVancoTroughFrequency;
//Check for Dose & Freq match with old v new
if ( ( disc_dose as string ) = ( curr_dose as string )
AND ( disc_dose_uom as string ) = ( curr_dose_uom as string )
AND ( disc_freq as string ) =( vanco_session_frequency as string ) ) then
//Retrieve trough associated with this order
( disc_trough_oGUID,
disc_trough_req_date,
disc_trough_req_time,
disc_trough_req_dtm) := READ LAST {" SELECT o.GUID, o.RequestedDate, o.RequestedTime, o.RequestedDtm"
|| " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3Order o WITH (NOLOCK)"
|| " ON cv.ClientGUID = o.ClientGUID"
|| " AND cv.GUID = o.ClientVisitGUID"
|| " AND cv.ChartGUID = o.ChartGUID"
|| " JOIN CV3OrderCatalogMasterItem ocmi WITH (NOLOCK)"
|| " ON o.OrderCatalogMasterItemGUID = ocmi.GUID"
|| " WHERE o.NAME LIKE {{{SINGLE-QUOTE}}}Vancomycin Trough Plasma/Serum%{{{SINGLE-QUOTE}}}"
|| " AND o.OrderStatusCode = {{{SINGLE-QUOTE}}}CANC{{{SINGLE-QUOTE}}}"
|| " AND cv.ClientGUID = " || SQL(ClientGUID)
|| " AND cv.GUID = " || SQL(ClientVisitGUID)
|| " AND cv.ChartGUID = " || SQL(ChartGUID)
|| " AND o.OrderSetGUID = " || SQL(disc_osGUID) };
disc_trough_draw := ( disc_trough_req_dtm as Time ) + 30 minutes;
disc_vanco_next_admin := ( disc_next_sched_admin as Time );
if ( disc_trough_draw = disc_vanco_next_admin ) then
is_disc_trough_next := true;
//Subtract old dosing time
disc_time_hour := extract hour disc_next_sched_admin;
curr_time_hour := SUBSTRING 2 CHARACTERS FROM vanco_session_time_value;
admin_time_diff := ( ( curr_time_hour as number ) - ( disc_time_hour as number ) ) ;
if ( admin_time_diff < 0 ) then
admin_time_diff := admin_time_diff * (-1);
endif;
if ( admin_time_diff <= 2 ) then
admin_to_autosched := 1;
else
admin_to_autosched := 2;
endif;
else
is_disc_trough_next := false;
//Set to same admin as previous
(same_admin) := READ LAST { "SELECT oud.UserDataCode"
|| " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3Order o WITH (NOLOCK)"
|| " ON cv.ClientGUID = o.ClientGUID"
|| " AND cv.GUID = o.ClientVisitGUID"
|| " AND cv.ChartGUID = o.ChartGUID"
|| " JOIN CV3OrderCatalogMasterItem ocmi WITH (NOLOCK)"
|| " ON o.OrderCatalogMasterItemGUID = ocmi.GUID"
|| " JOIN CV3OrderUserData oud WITH (NOLOCK)"
|| " ON o.GUID = oud.OrderGUID"
|| " AND o.ClientGUID = oud.ClientGUID"
|| " WHERE o.GUID = " || SQL(disc_trough_oGUID)
|| " AND oud.UserDataCode in ({{{SINGLE-QUOTE}}}Lab_Chem_Dose_1st_Admin_CB{{{SINGLE-QUOTE}}}"
|| " , {{{SINGLE-QUOTE}}}Lab_Chem_Dose_2nd_Admin_CB{{{SINGLE-QUOTE}}}"
|| " , {{{SINGLE-QUOTE}}}Lab_Chem_Dose_3rd_Admin_CB{{{SINGLE-QUOTE}}}"
|| " , {{{SINGLE-QUOTE}}}Lab_Chem_Dose_4th_Admin_CB{{{SINGLE-QUOTE}}}"
|| " , {{{SINGLE-QUOTE}}}Lab_Chem_Dose_5th_Admin_CB{{{SINGLE-QUOTE}}})"
|| " AND oud.Value = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}}"};
if ( same_admin = "Lab_Chem_Dose_1st_Admin_CB" ) then
admin_to_autoSched := 1;
elseif ( same_admin = "Lab_Chem_Dose_2nd_Admin_CB" ) then
admin_to_autoSched := 2;
elseif ( same_admin = "Lab_Chem_Dose_3rd_Admin_CB" ) then
admin_to_autoSched := 3;
elseif ( same_admin = "Lab_Chem_Dose_4th_Admin_CB" ) then
admin_to_autoSched := 4;
elseif ( same_admin = "Lab_Chem_Dose_5th_Admin_CB" ) then
admin_to_autoSched := 5;
else
admin_to_autoSched := 0;
endif;
endif; //Determine admin to schedule
endif; //Dose & Freq match on disc. vanco
endif; //Disc. Vanco exists
endif; //Vanco load exists
//***** 1ST ADMIN DATE + TIME *****
First_Admin_Date.Value := ( vanco_session_date as Time );
First_Admin_Time.Value := vanco_session_time_value;
//***** 2ND ADMIN DATE + TIME *****
x_num := SUBSTRING 2 CHARACTERS STARTING AT 2 FROM ( vanco_session_frequency as String );
frequencyNum := ( x_num as number );
firstAdmin_Hour := (extract hour ( First_Admin_Time.Value as Time ) ) as number;
secondAdmin_Min := ( extract minute ( First_Admin_Time.Value as Time ) ) as number;
if ( secondAdmin_Min = 0 ) then
secondAdmin_Min := "00";
endif;
secondAdmin_Hour := firstAdmin_Hour + (frequencyNum as number);
firstDate_converted := ( First_Admin_Date.Value as Time );
sec_admin_month := SUBSTRING 2 CHARACTERS From ( firstDate_converted as string );
sec_admin_day := Substring 2 Characters starting at 4 from ( firstDate_converted as string );
sec_admin_year := substring 4 characters starting at 7 from ( firstDate_converted as string );
sec_admin_dtm := sec_admin_year || "-" || sec_admin_month || "-" || sec_admin_day || "T00:01:00";
sec_admin := sec_admin_dtm as Time;
if ( secondAdmin_Hour < 24 ) then
Second_Admin_Date.Value := sec_admin;
if ( secondAdmin_Hour >= 1 AND secondAdmin_Hour <= 9 ) then
Second_Admin_Time.Value := "0" || secondAdmin_Hour || ":" || secondAdmin_Min;
else
Second_Admin_Time.Value := secondAdmin_Hour || ":" || secondAdmin_Min;
endif;
elseif ( secondAdmin_Hour > 24 ) then
if ( frequencyNum > 24 ) then
secondAdmin_Hour := ( secondAdmin_Hour - ( frequencyNum as number ) ) as number;
Second_Admin_Date.Value := sec_admin + 2 days;
else
secondAdmin_Hour := ( secondAdmin_Hour - 24 ) as number;
Second_Admin_Date.Value := sec_admin + 1 day;
endif;
if ( secondAdmin_Hour >= 1 AND secondAdmin_Hour <= 9 ) then
Second_Admin_Time.Value := "0" || secondAdmin_Hour || ":" || secondAdmin_Min;
else
Second_Admin_Time.Value := secondAdmin_Hour || ":" || secondAdmin_Min;
endif;
elseif ( secondAdmin_Hour = 24 ) then
Second_Admin_Date.Value := sec_admin + 1 day;
Second_Admin_Time.Value := "00:" || secondAdmin_Min;
endif;
//***** 3RD ADMIN DATE + TIME *****
if ( secondAdmin_Hour = 24 ) then
hour_value := 0;
else
hour_value := secondAdmin_Hour;
endif;
thirdAdmin_Hour := hour_value + ( frequencyNum as number );
thirdAdmin_Min := secondAdmin_Min;
secondDate_converted := ( Second_Admin_Date.Value as Time );
third_admin_month := Substring 2 Characters From ( secondDate_converted as string );
third_admin_day := Substring 2 Characters Starting at 4 From ( secondDate_converted as string );
third_admin_year := Substring 4 Characters Starting at 7 From ( secondDate_converted as string );
third_admin_dtm := third_admin_year || "-" || third_admin_month || "-" || third_admin_day || "T00:01:00";
third_admin := third_admin_dtm as Time;
if ( thirdAdmin_Hour < 24 ) then
Third_Admin_Date.Value := Second_Admin_Date.Value;
if ( thirdAdmin_Hour >= 1 AND thirdAdmin_Hour <= 9 ) then
Third_Admin_Time.Value := "0" || thirdAdmin_Hour || ":" || thirdAdmin_Min;
else
Third_Admin_Time.Value := thirdAdmin_Hour || ":" || thirdAdmin_Min;
endif;
elseif ( thirdAdmin_Hour > 24 ) then
if ( frequencyNum > 24 ) then
thirdAdmin_Hour := ( thirdAdmin_Hour - ( frequencyNum as number ) ) as number;
Third_Admin_Date.Value := third_admin + 2 days;
else
thirdAdmin_Hour := ( thirdAdmin_Hour - 24 ) as number;
Third_Admin_Date.Value := third_admin + 1 day;
endif;
if ( thirdAdmin_Hour >= 1 AND thirdAdmin_Hour <= 9 ) then
Third_Admin_Time.Value := "0" || thirdAdmin_Hour || ":" || thirdAdmin_Min;
else
Third_Admin_Time.Value := thirdAdmin_Hour || ":" || thirdAdmin_Min;
endif;
elseif ( thirdAdmin_Hour = 24 ) then
Third_Admin_Date.Value := third_admin + 1 day;
Third_Admin_Time.Value := "00:" || thirdAdmin_Min;
endif;
//***** 4TH ADMIN DATE + TIME *****
if ( thirdAdmin_Hour = 24 ) then
hour_value := 0;
else
hour_value := thirdAdmin_Hour;
endif;
fourthAdmin_Hour := hour_value + ( frequencyNum as number );
fourthAdmin_Min := secondAdmin_Min;
thirdDate_converted := ( Third_Admin_Date.Value as Time );
fourth_admin_month := Substring 2 Characters From ( thirdDate_converted as string );
fourth_admin_day := Substring 2 Characters Starting at 4 From ( thirdDate_converted as string );
fourth_admin_year := Substring 4 Characters Starting at 7 From ( thirdDate_converted as string );
fourth_admin_dtm := fourth_admin_year || "-" || fourth_admin_month || "-" || fourth_admin_day || "T00:01:00";
fourth_admin := fourth_admin_dtm as Time;
if ( fourthAdmin_Hour < 24 ) then
Fourth_Admin_Date.Value := fourth_admin;
if ( fourthAdmin_Hour >= 1 AND fourthAdmin_Hour <= 9 ) then
Fourth_Admin_Time.Value := "0" || fourthAdmin_Hour || ":" || fourthAdmin_Min;
else
Fourth_Admin_Time.Value := fourthAdmin_Hour || ":" || fourthAdmin_Min;
endif;
elseif ( fourthAdmin_Hour > 24 ) then
if ( frequencyNum > 24 ) then
fourthAdmin_Hour := ( fourthAdmin_Hour - ( frequencyNum as number ) ) as number;
Fourth_Admin_Date.Value := fourth_admin + 2 days;
else
fourthAdmin_Hour := ( fourthAdmin_Hour - 24 ) as number;
Fourth_Admin_Date.Value := fourth_admin + 1 day;
endif;
if ( fourthAdmin_Hour >= 1 AND fourthAdmin_Hour <= 9 ) then
Fourth_Admin_Time.Value := "0" || fourthAdmin_Hour || ":" || fourthAdmin_Min;
else
Fourth_Admin_Time.Value := fourthAdmin_Hour || ":" || fourthAdmin_Min;
endif;
elseif ( fourthAdmin_Hour = 24 ) then
Fourth_Admin_Date.Value := fourth_admin + 1 day;
Fourth_Admin_Time.Value := "00:" || fourthAdmin_Min;
endif;
//Logic to handle autoscheduling 4th administration
if ( admin_to_autoSched = 0 ) then
if ( ( ( fourthAdmin_Hour as number ) >= 5 AND ( fourthAdmin_Hour as number ) <= 18 ) OR ( frequencyNum >= 24 ) ) then
admin_to_autoSched := 4;
else
admin_to_autoSched := 5;
endif;
endif;
//***** 5TH ADMIN DATE + TIME *****
if ( fourthAdmin_Hour = 24 ) then
hour_value := 0;
else
hour_value := fourthAdmin_Hour;
endif;
fifthAdmin_Hour := hour_value + ( frequencyNum as number );
fifthAdmin_Min := secondAdmin_Min;
fourthDate_converted := ( Fourth_Admin_Date.Value as Time );
fifth_admin_month := Substring 2 Characters From ( fourthDate_converted as string );
fifth_admin_day := Substring 2 Characters Starting at 4 From ( fourthDate_converted as string );
fifth_admin_year := Substring 4 Characters Starting at 7 From ( fourthDate_converted as string );
fifth_admin_dtm := fifth_admin_year || "-" || fifth_admin_month || "-" || fifth_admin_day || "T00:01:00";
fifth_admin := fifth_admin_dtm as Time;
if ( fifthAdmin_Hour < 24 ) then
Fifth_Admin_Date.Value := fifth_admin;
if ( fifthAdmin_Hour >= 1 AND fifthAdmin_Hour <= 9 ) then
Fifth_Admin_Time.Value := "0" || fifthAdmin_Hour || ":" || fifthAdmin_Min;
else
Fifth_Admin_Time.Value := fifthAdmin_Hour || ":" || fifthAdmin_Min;
endif;
elseif ( fifthAdmin_Hour > 24 ) then
if ( frequencyNum > 24 ) then
fifthAdmin_Hour := ( fifthAdmin_Hour - ( frequencyNum as number ) ) as number;
Fifth_Admin_Date.Value := fifth_admin + 2 days;
else
fifthAdmin_Hour := ( fifthAdmin_Hour - 24 ) as number;
Fifth_Admin_Date.Value := fifth_admin + 1 day;
endif;
if ( fifthAdmin_Hour >= 1 AND fifthAdmin_Hour <= 9 ) then
Fifth_Admin_Time.Value := "0" || fifthAdmin_Hour || ":" || fifthAdmin_Min;
else
Fifth_Admin_Time.Value := fifthAdmin_Hour || ":" || fifthAdmin_Min;
endif;
elseif ( fifthAdmin_Hour = 24 ) then
Fifth_Admin_Date.Value := fifth_admin + 1 day;
Fifth_Admin_Time.Value := "00:" || fifthAdmin_Min;
endif;
//Logic to autoselect trough time
if ( admin_to_autoSched = 1 ) then
First_Admin_Chk.Value := true;
Second_Admin_Chk.Value := false;
Third_Admin_Chk.Value := false;
Fourth_Admin_Chk.Value := false;
Fifth_Admin_Chk.Value := false;
dynamic_field_date := First_Admin_Date.Value;
dynamic_field_time := First_Admin_Time.Value;
elseif ( admin_to_autoSched = 2 ) then
Second_Admin_Chk.Value := true;
First_Admin_Chk.Value := false;
Third_Admin_Chk.Value := false;
Fourth_Admin_Chk.Value := false;
Fifth_Admin_Chk.Value := false;
dynamic_field_date := Second_Admin_Date.Value;
dynamic_field_time := Second_Admin_Time.Value;
elseif ( admin_to_autoSched = 3 ) then
Third_Admin_Chk.Value := true;
First_Admin_Chk.Value := false;
Second_Admin_Chk.Value := false;
Fourth_Admin_Chk.Value := false;
Fifth_Admin_Chk.Value := false;
dynamic_field_date := Third_Admin_Date.Value;
dynamic_field_time := Third_Admin_Time.Value;
elseif ( admin_to_autoSched = 4 ) then
Fourth_Admin_Chk.Value := true;
First_Admin_Chk.Value := false;
Second_Admin_Chk.Value := false;
Third_Admin_Chk.Value := false;
Fifth_Admin_Chk.Value := false;
dynamic_field_date := Fourth_Admin_Date.Value;
dynamic_field_time := Fourth_Admin_Time.Value;
elseif ( admin_to_autoSched = 5 ) then
Fifth_Admin_Chk.Value := true;
First_Admin_Chk.Value := false;
Second_Admin_Chk.Value := false;
Third_Admin_Chk.Value := false;
Fourth_Admin_Chk.Value := false;
dynamic_field_date := Fifth_Admin_Date.Value;
dynamic_field_time := Fifth_Admin_Time.Value;
endif;
Trough_Requested_Date.Value := dynamic_field_date;
if ( isHoldSession = "Hold" ) then
Trough_ReqTime_Value.ReqTimeValue := "";
else
a := ( dynamic_field_time as Time ) - 30 minutes;
b := extract hour a;
if ( b >= 1 AND b <= 9 ) then
b := "0" || b;
endif;
c := b || ":" || extract minute a;
Trough_ReqTime_Value.ReqTimeValue := c;
endif;
endif; //End Scheduled Time is null
endif; //End CallingEvent
//Handle user changing selected administration time
if ( CallingEvent = "FieldChange" ) then
uncheck_fields_lst := ( First_Admin_Chk, Second_Admin_Chk, Third_Admin_Chk,
Fourth_Admin_Chk, Fifth_Admin_Chk
);
if ( CallingField = "Lab_Chem_Dose_1st_Admin_CB" ) then
if ( First_Admin_Chk.Value = true ) then
for i IN 1 seqto count uncheck_fields_lst do
if ( uncheck_fields_lst[i].DataItemName <> CallingField ) then
uncheck_fields_lst[i].Value := false;
endif;
enddo;
Trough_Requested_Date.Value := First_Admin_Date.Value;
a := ( First_Admin_Time.Value as Time ) - 30 minutes;
b := extract hour a;
if ( b >= 1 and b <= 9 ) then
b := "0" || b;
endif;
c := b || ":" || extract minute a;
Trough_ReqTime_Value.ReqTimeValue := c;
endif;
endif;
if ( CallingField = "Lab_Chem_Dose_2nd_Admin_CB" ) then
if ( Second_Admin_Chk.Value = true ) then
for i IN 1 seqto count uncheck_fields_lst do
if ( uncheck_fields_lst[i].DataItemName <> CallingField ) then
uncheck_fields_lst[i].Value := false;
endif;
enddo;
Trough_Requested_Date.Value := Second_Admin_Date.Value;
a := ( Second_Admin_Time.Value as Time ) - 30 minutes;
b := extract hour a;
if ( b >= 1 and b <= 9 ) then
b := "0" || b;
endif;
c := b || ":" || extract minute a;
Trough_ReqTime_Value.ReqTimeValue := c;
endif;
endif;
if ( CallingField = "Lab_Chem_Dose_3rd_Admin_CB" ) then
if ( Third_Admin_Chk.Value = true ) then
for i IN 1 seqto count uncheck_fields_lst do
if ( uncheck_fields_lst[i].DataItemName <> CallingField ) then
uncheck_fields_lst[i].Value := false;
endif;
enddo;
Trough_Requested_Date.Value := Third_Admin_Date.Value;
a := ( Third_Admin_Time.Value as Time ) - 30 minutes;
b := extract hour a;
if ( b >= 1 and b <= 9 ) then
b := "0" || b;
endif;
c := b || ":" || extract minute a;
Trough_ReqTime_Value.ReqTimeValue := c;
endif;
endif;
if ( CallingField = "Lab_Chem_Dose_4th_Admin_CB" ) then
if ( Fourth_Admin_Chk.Value = true ) then
for i IN 1 seqto count uncheck_fields_lst do
if ( uncheck_fields_lst[i].DataItemName <> CallingField ) then
uncheck_fields_lst[i].Value := false;
endif;
enddo;
Trough_Requested_Date.Value := Fourth_Admin_Date.Value;
a := ( Fourth_Admin_Time.Value as Time ) - 30 minutes;
b := extract hour a;
if ( b >= 1 and b <= 9 ) then
b := "0" || b;
endif;
c := b || ":" || extract minute a;
Trough_ReqTime_Value.ReqTimeValue := c;
endif;
endif;
if ( CallingField = "Lab_Chem_Dose_5th_Admin_CB" ) then
if ( Fifth_Admin_Chk.Value = true ) then
for i IN 1 seqto count uncheck_fields_lst do
if ( uncheck_fields_lst[i].DataItemName <> CallingField ) then
uncheck_fields_lst[i].Value := false;
endif;
enddo;
Trough_Requested_Date.Value := Fifth_Admin_Date.Value;
a := ( Fifth_Admin_Time.Value as Time ) - 30 minutes;
b := extract hour a;
if ( b >= 1 and b <= 9 ) then
b := "0" || b;
endif;
c := b || ":" || extract minute a;
Trough_ReqTime_Value.ReqTimeValue := c;
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: