maintenance: title: FORM_SET_ROBOTIC_PROSTATECTOMY;; mlmname: FORM_SET_ROBOTIC_PROSTATECTOMY;; arden: version 2.5;; version: 5.50;; institution: St. Clair Hospital;; author: Juliet M. Law, ext. 7461;; specialist: Maria Pest, ext. 7443;; date: 2012-03-05;; validation: testing;; library: purpose: Used for the Robotic Prostatectomy Order Set. ;; explanation: Used for the Robotic Prostatectomy Order Set. Change history 03.05.2012 JMLaw Created. ;; keywords: Robotic, Prostatectomy, 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"; error_message := ""; field_list := this_form.fields; client_guid := this_communication.ClientGUID; visit_guid := this_communication.ClientVisitGUID; chart_guid := this_communication.ChartGUID; CallingEvent := this_communication.CallingEvent; CallingField := this_communication.CallingFieldName; Pharmacy_Meds := last of (field_list WHERE field_list.DataItemName = "MultiOrderGrid" AND field_list.Control_MultiFieldOccNum = 30); Pharmacy_Meds_List := Pharmacy_Meds.Value; //Determine if patient is allergic to sulfa drugs (allergen) := read {"SELECT a.Code, a.TouchedWhen" || " FROM CV3AllergyDeclaration ad with (nolock) JOIN CV3Allergen a with (nolock) " || " ON a.GUID = ad.AllergenGUID" || " WHERE a.Code = {{{SINGLE-QUOTE}}}sulfa drugs{{{SINGLE-QUOTE}}}" || " AND ad.Status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}} " || " AND ad.ClientGUID = " || Sql(client_guid) , primaryTime = touchedWhen}; //Set boolean variable based on number of sulfa allergies returned from above query sulfaAllergyExists := ((count allergen) > 0); //If Form Open event AND patient has a sulfa allergy, set the Celecoxib medication to Read Only if (CallingEvent = "FormOpen") then if (sulfaAllergyExists = true) then celecoxibFld := first of (Pharmacy_Meds_List WHERE Pharmacy_Meds_List.Name = "Celecoxib 200mg Cap"); celecoxibFld.IsReadOnly := true; endif; endif; //On Field Change event, control ability to select certain medications in the Pharmacy / Medications grid if (CallingEvent = "FieldChange") then if (CallingField = "MultiOrderGrid|30") then //List of medications in the Narcotic section in the Pharmacy / Medications grid //List contains OxyCODONE 5 mg/Acetaminophen 325 mg (percocet) 1 tab PO every 4 hours as needed for moderate pain //and oxyCODONE 5 mg / Acetaminophen 325 mg (Percocet) 2 tabs PO every 4 hours as needed for severe pain Narcotic_Meds := (Pharmacy_Meds_List.IsSelected[8], Pharmacy_Meds_List.IsSelected[9]); NarcoticMedsTrueCount := count (Narcotic_Meds WHERE Narcotic_Meds = true); //Initialize variables used to set the IsReadOnly and IsSelected property on medications in grid NewReadOnly := (); NewSelected := (); //Begin to loop through all the medications contained in the Pharmacy / Medications grid for i in 1 seqto (count Pharmacy_Meds_List.IsSelected) do //If one or both Narcotic medications defined in the list above are selected, //disable the OxyCODONE 5 mg 1 to 2 tablets PO, every 4 hours as needed for moderate to severe pain //medication - all other grid fields are left alone if ((NarcoticMedsTrueCount = 1 AND Pharmacy_Meds_List.IsReadOnly[10] = false) OR (NarcoticMedsTrueCount = 2)) then if (i >= 8 AND i < 10) then NewReadOnly := NewReadOnly, false; NewSelected := NewSelected, true; elseif (i = 10) then NewReadOnly := NewReadOnly, true; NewSelected := NewSelected, false; else NewReadOnly := NewReadOnly, Pharmacy_Meds_List.IsReadOnly[i]; NewSelected := NewSelected, Pharmacy_Meds_List.IsSelected[i]; endif; elseif (NarcoticMedsTrueCount = 1 AND Pharmacy_Meds_List.IsReadOnly[10] = true) then if (i >= 8 AND i < 10) then NewReadOnly := NewReadOnly, false; NewSelected := NewSelected, false; elseif (i = 10) then NewReadOnly := NewReadOnly, false; NewSelected := NewSelected, false; else NewReadOnly := NewReadOnly, Pharmacy_Meds_List.IsReadOnly[i]; NewSelected := NewSelected, Pharmacy_Meds_List.IsSelected[i]; endif; //If the third oxycodone med is selected // (OxyCODONE 5 mg 1 to 2 tablets PO, every 4 hours as needed for moderate to severe pain), //disable the medications contained in the narcotic meds list - all other grid fields are left alone elseif (Pharmacy_Meds_List.IsSelected[10] = true) then if (i >= 8 AND i < 10) then NewReadOnly := NewReadOnly, true; NewSelected := NewSelected, false; else NewReadOnly := NewReadOnly, Pharmacy_Meds_List.IsReadOnly[i]; NewSelected := NewSelected, Pharmacy_Meds_List.IsSelected[i]; endif; //Nothing is selected; reset all 3 oxycodone medications to NOT Read Only and NOT selected //all other grid fields are left alone else if (i >= 8 AND i <= 10) then NewReadOnly := NewReadOnly, false; NewSelected := NewSelected, false; else NewReadOnly := NewReadOnly, Pharmacy_Meds_List.IsReadOnly[i]; NewSelected := NewSelected, Pharmacy_Meds_List.IsSelected[i]; endif; endif; enddo; //Update Pharmacy / Medication grid fields with appropriate IsReadOnly and IsSelected properties Pharmacy_Meds_List.IsReadOnly := NewReadOnly; Pharmacy_Meds_List.IsSelected := NewSelected; //If patient does NOT have a sulfa allergy, then control the ability to select only 1 medication field under //the NSAIDs section in the Pharmacy / Medication grid //NOTE: only need to perform this logic IF patient does not have sulfa allergy since //celecoxib med is disabled on form open for patients with sulfa allergy if (sulfaAllergyExists = false) then //List of NSAIDs meds selected Nsaid_Meds := (Pharmacy_Meds_List.IsSelected[2], Pharmacy_Meds_List.IsSelected[3]); //Initialize variabled used to set IsReadOnly and IsSelected properties NewReadOnly := (); NewSelected := (); //Loop through all medications in grid for k in 1 seqto (count Pharmacy_Meds_List.IsSelected) do //If one medication in the NSAID meds list is selected, disable the other NSAID med //all other meds in grid are left alone if (true IN Nsaid_Meds) then if (k >= 2 AND k < 4) then if (Pharmacy_Meds_List.IsSelected[k] = true) then NewReadOnly := NewReadOnly, false; NewSelected := NewSelected, true; else NewReadOnly := NewReadOnly, true; NewSelected := NewSelected, false; endif; else NewReadOnly := NewReadOnly, Pharmacy_Meds_List.IsReadOnly[k]; NewSelected := NewSelected, Pharmacy_Meds_List.IsSelected[k]; endif; //No NSAID med is selected, reset both medications in list to NOT read only and NOT selected //all other meds in grid are left alone else if (k >= 2 AND k < 4) then NewReadOnly := NewReadOnly, false; NewSelected := NewSelected, false; else NewReadOnly := NewReadOnly, Pharmacy_Meds_List.IsReadOnly[k]; NewSelected := NewSelected, Pharmacy_Meds_List.IsSelected[k]; endif; endif; enddo; //Update Pharmacy / Medication grid fields with appropriate IsReadOnly and IsSelected properties Pharmacy_Meds_List.IsReadOnly := NewReadOnly; Pharmacy_Meds_List.IsSelected := NewSelected; endif; endif; endif; ;; priority: 50 ;; evoke: ;; logic: conclude true; ;; action: return this_communication, this_form; ;; Urgency: 50;; end: