maintenance: title: FORM_Clostridium_Difficile_Toxin_Order ;; mlmname: FORM_Clostridium_Difficile_Toxin_Order ;; arden: version 2.5;; version: 6.10;; institution: St. Clair Hospital;; author: Shivprasad Jadhav;; specialist: Shivprasad jadhav, Allscripts Corporation;; date: 2015-10-23;; validation: testing;; library: purpose: Preselect the "Clostridium Difficile Toxin by PCR" Order IF: 1st Senario:- Order is not placed at all. 2nd Senario:- MLM will look back for past 4days lab result across the visit for "Clostridium Difficile Toxin by PCR" order with the order status as "Specimen Recieved by performing Department" if order is not placed then it has to be preselect. 3rd Senario:-MLM will lool back for past 4days lab result across the visit for "Clostridium Difficile Toxin by PCR" with the order status "1 or more final results received" if this order staus is not present then lab order has to be preselect. ;; explanation: Change History ----------------- 23.10.2015 JML CSR# 33678: Created 06.29.2016 DJW CSR# 34852 Updated for new message #1 12/08/2017 SHAMI CSR#36182 #2 12/15/2017 SHAMI 07/10/2019 JML CSR# 38386: Modified logic to auto-check lab test based on ED vs. Inpatient location. ;; keywords: Called MLMs ;; 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; 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:=""; // Assigns fields passed in the Form object to the Field object 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; pObj := this_communication.PrimaryObj; CallingEvent := this_communication.CallingEvent; CallingField := this_communication.CallingFieldName; item_event := this_communication.itemevent; form_type := this_communication.formtype; //Get patient{{{SINGLE-QUOTE}}}s current location curr_loc := read last { "SELECT CurrentLocation FROM CV3ClientVisit cv WITH (NOLOCK) WHERE cv.GUID = " || visit_guid }; if ( curr_loc = "ER Major" ) then lab_test_name := "Clostridium Difficile Toxin Gene Testing by PCR"; index_val := 2; C_Diff_O := last of ( field_list WHERE field_list.DataItemName = "MultiOrderCheckBox" AND field_list.Control_MultiFieldOccNum = 4); else lab_test_name := "Clostridium Difficile Screening"; index_val := 4; C_Diff_O := last of ( field_list WHERE field_list.DataItemName = "MultiOrderCheckBox" AND field_list.Control_MultiFieldOccNum = 2); endif; //Retrieve relevant form fields C_Diff := last of ( field_list WHERE field_list.DataItemName = "MultiOrderCheckBox" AND field_list.Control_MultiFieldOccNum = index_val); C_Speci := last of ( field_list WHERE field_list.DataItemName = "MultiOrderGrid" and field_list.Control_MultiFieldOccNum = 3); C_Comment := last of ( field_list WHERE field_list.DataItemName = "NUR_ Comment 1 line" ); NurseInstructionsGrid := first of (field_list where field_list.DataItemName = "MultiOrderInline" and field_List.Control_MultiFieldOccNum = 1); read_only_instr := false; C_Iso := last of ( field_list WHERE field_list.DataItemName = "MultiOrderCheckBox" AND field_list.Control_MultiFieldOccNum = 3 ); C_NotifyID := last of ( field_list WHERE field_list.DataItemName = "MultiOrderGrid" AND field_list.Control_MultiFieldOccNum = 2 ); C_Diff_Val := C_Diff.Value; C_Speci_Val:= C_Speci.Value ; C_Iso_Val := C_Iso.Value; C_NotifyID_Val := C_NotifyID.Value; C_NotifyID_Order := C_NotifyID_Val[1]; C_Diff_O_Val := C_Diff_O.Value; Special_Instr := C_Speci_Val[1]; if ( CallingEvent = "FormOpen" ) then //Check to see if patient is on Clostridium Difficile Toxin Gene Testing by PCR //Ordered OR resulted C_Diff_Order := read {"SELECT o.Name" || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3Order o WITH (NOLOCK)" || " 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 o.NAME IN ( {{{SINGLE-QUOTE}}}Clostridium Difficile Toxin Gene Testing by PCR{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Clostridium Difficile Screening{{{SINGLE-QUOTE}}} ) " || " AND DATEDIFF(HH, o.SignificantDtm, GetDate()) <= 96 " //96 || " AND o.OrderStatusCode IN ({{{SINGLE-QUOTE}}}SPRV{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}RESF{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}RESI{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}RESC{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PCOL{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}COLL{{{SINGLE-QUOTE}}})"}; //Ordered ONLY C_Diff_Ord_Pending := read {"SELECT o.Name" || " FROM CV3ClientVisit cv WITH (NOLOCK) JOIN CV3Order o WITH (NOLOCK)" || " 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 o.NAME IN ( {{{SINGLE-QUOTE}}}Clostridium Difficile Toxin Gene Testing by PCR{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Clostridium Difficile Screening{{{SINGLE-QUOTE}}} ) " || " AND DATEDIFF(HH, o.SignificantDtm, GetDate()) <= 96 " || " AND o.OrderStatusCode IN ({{{SINGLE-QUOTE}}}SPRV{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}PCOL{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}COLL{{{SINGLE-QUOTE}}})"}; //If lab test Ordered, display Comment line informing user C Diff order has already been placed If exist C_Diff_Ord_Pending Then C_Comment.Control_Visible := True ; Else C_Comment.Control_Visible := False ; EndIf; //If C Diff order doesn{{{SINGLE-QUOTE}}}t exist, auto check C Diff lab if ( Not exists C_Diff_Order ) then for lab in 1 seqto ( count C_Diff_Val ) do if ( C_Diff_Val[lab].Name = lab_test_name ) then C_Diff_Val[lab].IsSelected := true ; C_Diff_Val[lab].IsReadonly := False ; C_Diff_O_Val.IsSelected := false; C_Diff_O_Val.IsReadOnly := true; Special_Instr.IsSelected := True ; C_Comment.Control_Visible := False ; C_Iso_Val.IsSelected := true; C_NotifyID_Order.IsSelected := true; endif; enddo; else C_Diff_Val.IsSelected := ( false); C_Diff_Val.IsReadonly := (true ); C_Diff_O_Val.IsSelected := false; C_Diff_O_Val.IsReadonly := true; read_only_instr := true; C_Iso_Val.IsSelected := false; C_Iso_Val.IsReadOnly := true; C_NotifyID_Order.IsSelected := false; C_NotifyID_Order.IsReadonly := true; Special_Instr.IsSelected := false; Special_Instr.IsReadonly := true; endif; index_list := 1 seqto (count NurseInstructionsGrid.Value); for I in index_list do NurseInstructionsGrid.Value[I].IsReadonly := read_only_instr; enddo; //#1 : Start IF(this_form.name="NUR_Cdiff StandOrder") Then Result := read last { " SELECT TOP 1 O.Name " ||" FROM Cv3Order (NOLOCK) O " ||" INNER JOIN CV3OrderTaskOccurrence ot on ot.ClientGUID=O.ClientGUID and ot.OrderGUID=O.GUID and ot.TaskStatusCode={{{SINGLE-QUOTE}}}Performed{{{SINGLE-QUOTE}}} " ||" WHERE ot.PerformedFromDtm >= DATEADD(HOUR, -48, GETDATE())" ||" AND O.Status= {{{SINGLE-QUOTE}}}ACTIVE{{{SINGLE-QUOTE}}} AND O.ActivateStatus={{{SINGLE-QUOTE}}}AUA1{{{SINGLE-QUOTE}}} " ||" AND Name IN ({{{SINGLE-QUOTE}}}Bisacodyl 5mg EC Tab{{{SINGLE-QUOTE}}} , " ||" {{{SINGLE-QUOTE}}}Bisacodyl 10mg Rectal Supp{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Chondrus/Mineral Oil{{{SINGLE-QUOTE}}} , " ||" {{{SINGLE-QUOTE}}}Docusate Calcium 240mg Cap{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Docusate Sodium 50mg Cap{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Docusate Sodium 100mg Cap{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Docusate Sodium Syrup{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Docusate Sodium Syrup/Mineral Oil{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Glycerin Adult Supp{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Glycerin Pediatric Supp{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Lo-So Prep - Magnesium Citrate Powder{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Magnesium Citrate 300ml Soln{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Magnesium Hydroxide Susp{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Mineral Oil{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Mineral Oil Enema{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Polycarbophil 500mg Tab{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Senna Tab{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Senna Syrup{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Senna/Docusate Sodium Tab{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Sodium Phosphate Enema{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Sodium Phosphate Pediatric Enema{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Polyethylene Glycol - Electrolytes Prep{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Polyethylene Glycol - Electrolytes Prep{{{SINGLE-QUOTE}}}, " ||" {{{SINGLE-QUOTE}}}Polyethylene Glycol 17gm Powder{{{SINGLE-QUOTE}}}) " ||" AND O.ClientGUID = " || SQL(client_guid) ||" AND O.ChartGUID = " || SQL(Chart_guid) ||" AND O.ClientVisitGUID = " || SQL(Visit_guid) }; IF(EXISTS Result ) THEN Flag := True; //#2 Start C_Infprev := last of ( field_list WHERE field_list.DataItemName = "MultiOrderGrid" and field_list.Control_MultiFieldOccNum = 2); C_Notify := C_Infprev.Value[1]; C_Spe := C_Speci.Value[1]; C_Notify.IsSelected := False ; C_Notify.IsReadonly := True ; C_Spe.IsSelected := False ; C_Spe.IsReadonly := True ; //#2 END Indicator_1 := NurseInstructionsGrid.Value[1] ; Indicator_2 := NurseInstructionsGrid.Value[2]; Indicator_3 := NurseInstructionsGrid.Value[3]; C_Diff_Val[lab].IsSelected := False ; C_Diff_Val[lab].IsReadonly := True ; C_Diff_O_Val.IsSelected := false; C_Diff_O_Val.IsReadOnly := true; Indicator_1.IsReadonly := True ; Indicator_2.IsReadonly := True ; Indicator_3.IsReadonly := true; C_Iso_Val.IsSelected := false; C_Iso_Val.IsReadOnly := true; if Flag = True then dlg_result := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n This patient has received laxatives in the last 48 hours. C.diff testing is not recommended in this setting. "|| " " ,"C Diff Ordering Information ", "OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Information" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; else dlg_result := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n If patient has had laxitives, lactulose, bowel prep or new tube feed, sending C.diff specimen is not recommended. "|| " " ,"C Diff Ordering Information ", "OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Information" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; Endif;// Flag else dlg_result := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with "\n If patient has had laxitives, lactulose, bowel prep or new tube feed, sending C.diff specimen is not recommended. "|| " " ,"C Diff Ordering Information ", "OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}},"Information" as {{{SINGLE-QUOTE}}}MessageBoxIcon{{{SINGLE-QUOTE}}}; ENDIF;//Result exist ENDIF;//form exist ENDIF;// Calling EVNET //#1 : END ;; 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: