maintenance: title: DOC_FUNC_SUICIDAL_OR_VIOLENT;; mlmname: DOC_FUNC_SUICIDAL_OR_VIOLENT;; arden: version 5.0;; version: 2.00;; institution: St.Clair Hospital;; author: GMS;; specialist: Don Warnick ;; date: 2018-05-23;; validation: testing;; library: purpose: ;; explanation: Upon open of the ED Triage Note, this MLM will retrieve suicide & violence risk information from past visits and update an observation textbox. Upon save of the ED Triage Note, it will update the Suicide Violence status board column with the latest information. Change history 05.23.2018 DW CSR# 36510 Harm to Self or Others - Created 07.03.2018 DW CSR# 36510 added this response which is configured in the Paient Profile "NA under 12 years of age". There is no comma after the "NA" as there is in the ED Triage Note. 07.06.2018 DW CSR# 36510 added code to support the "discrepancy between past history and patient responses" checkbox 07.25.2018 DW CSR# 36510 Harm to Self or Others - Changes required for inpatient processes 10.30.2018 DW CSR# 36510 Harm to Self or Others - Changes required for inpatient processes - requested changes ("notify md" order verbiage change) 08.06.2019 DW CSR# 38551 Redesign based upon JACHO observations 09.03.2019 DW CSR# 38604 Columbia Severity Note for Outpatients and Adult Patient Profile Behavioral Health Outpatients ;; keywords: ;; 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"; local_session := cds_session.local; // Recieve arguments from the structured note (thisDocumentCommunication) := argument; // Extract interesting parts of the object model (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; (thisParameters) := thisStructuredNoteDoc.ParametersList; (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; FreeTextValueType := OBJECT [Value]; DateValueType := OBJECT [Value]; ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; // Get the client and visit GUIDs ClientGUID := thisDocumentCommunication.ClientGUID; ChartGUID := thisDocumentCommunication.ChartGUID; VisitGUID := thisDocumentCommunication.ClientVisitGUID; userGuid := thisDocumentCommunication.UserGUID; document_event_enter := event {ClientDocumentEnter User ClientDocument: where documentname = "ED Triage Note" or documentname matches pattern "%Patient Profile" }; document_event_modify := event {ClientDocumentModify User ClientDocument: where documentname = "ED Triage Note" or documentname matches pattern "%Patient Profile" }; // If evoked by document enter or document modify, attain the guids If EvokingEventType = document_event_modify.type or EvokingEventType = document_event_enter.type then (VisitGUID, ChartGUID, ClientGUID) := read last {ClientDocument: ClientVisitGUID, ChartGUID, ClientGUID REFERENCING EvokingObject}; endif; // Determine the type of Structured Note if thisDocumentCommunication.DocumentName = "Adult Patient Profile - Behavioral Health Outpatient" then current_document_type := "behv_outpatient_patient_profile"; has_orders := "no"; elseif thisDocumentCommunication.DocumentName matches pattern "%Profile%" then current_document_type := "patient_profile"; orders_observation_name:= "SCH_PSY_Risk OrdersInp"; // List of order checkboxes has_orders := "yes"; elseif thisDocumentCommunication.DocumentName = "ED Triage Note" then current_document_type := "triage_note"; orders_observation_name:= "SCH_PSY_Risk Orders"; // List of order checkboxes has_orders := "yes"; else current_document_type := "columbia_outpatient"; has_orders := "no"; endif; If thisdocumentCommunication.EventType = "DocumentOpening" or thisdocumentCommunication.EventType is null then // Gather past history (...only for "DocumentOpening" & "Document modify/enter"...unneeded for other events) SignificantEvent := read {" select case when (c.OnsetYearNum is null and c.OnsetMonthNum is null) or (c.OnsetYearNum = 0 and c.OnsetMonthNum = 0) then cast (convert(char(10), c.CreatedWhen,20)as varchar) when c.OnsetYearNum is not null and c.OnsetYearNum <> 0 and c.OnsetMonthNum is not null and c.OnsetMonthNum <> 0 and c.OnsetDayNum is not null and c.OnsetDayNum <> 0 then cast (c.OnsetYearNum as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + cast (c.OnsetMonthNum as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + cast (c.OnsetDayNum as varchar) else case when c.OnsetYearNum is not null and c.OnsetMonthNum = 0 then cast (c.OnsetYearNum as varchar) when c.OnsetYearNum is not null and c.OnsetMonthNum > 0 then cast (c.OnsetYearNum as varchar) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + cast (c.OnsetMonthNum as varchar) end end + case when c.TypeCode = {{{SINGLE-QUOTE}}}Violence-Clinical Support Team{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}} - Flagged for Violence Caution by the Clinical Support Team (see significant event){{{SINGLE-QUOTE}}} when c.TypeCode = {{{SINGLE-QUOTE}}}Behavioral Health{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}} - Flagged by Mental Health for {{{SINGLE-QUOTE}}} + c.Description + {{{SINGLE-QUOTE}}} (see significant event){{{SINGLE-QUOTE}}} end + {{{SINGLE-QUOTE}}}\n{{{SINGLE-QUOTE}}} from CV3ClientEventDeclaration c with (nolock) where c.TypeCode in ({{{SINGLE-QUOTE}}}Violence-Clinical Support Team{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Behavioral Health{{{SINGLE-QUOTE}}}) and c.status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}} and c.ClientGUID = " || ClientGuid || " order by c.CreatedWhen "}; SuidcideObservation := read {" SET CONCAT_NULL_YIELDS_NULL off select cast (convert(char(10), obsparam.RecordedDtm,20)as varchar) + {{{SINGLE-QUOTE}}} - {{{SINGLE-QUOTE}}} + case when ocmi.name = {{{SINGLE-QUOTE}}}SCH_PSY_Wish to be Dead{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}Have you wished you were dead or wished you could sleep and not wake up?{{{SINGLE-QUOTE}}} when ocmi.name = {{{SINGLE-QUOTE}}}SCH_PSY_Suicidal Thoughts{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}Have you actually had any thoughts of killing yourself?{{{SINGLE-QUOTE}}} when ocmi.name = {{{SINGLE-QUOTE}}}SCH_PSY_Suicide Behavior Question{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}Have you ever done, started, prepared to end your life?{{{SINGLE-QUOTE}}} else ocmi.LeftJustifiedLabel + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + ocmi.RightJustifiedLabel end + {{{SINGLE-QUOTE}}} - {{{SINGLE-QUOTE}}} + {{{SINGLE-QUOTE}}} ({{{SINGLE-QUOTE}}} + fs.Value + obsparam.ValueText +{{{SINGLE-QUOTE}}}){{{SINGLE-QUOTE}}} + {{{SINGLE-QUOTE}}}\n{{{SINGLE-QUOTE}}} from CV3ObsCatalogMasterItem ocmi with (nolock) inner join SXACDObservationParameter obsparam with (nolock) on " || ClientGuid || " = obsparam.ClientGUID and obsparam.ObsMasterItemGUID = ocmi.GUID and obsparam.IsCanceled = 0 left outer join SCMObsFSListValues fs with (nolock) on fs.ClientGUID = " || ClientGuid || " and ObsParam.ObservationDocumentGUID = fs.ParentGUID where ( ( ocmi.name like ({{{SINGLE-QUOTE}}}%hurt%{{{SINGLE-QUOTE}}}) or ocmi.name in ({{{SINGLE-QUOTE}}}SCH_PSY_Wish to be Dead{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_Suicidal Thoughts{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_Suicide Behavior Question{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}CAS psych suicide homicide ideation{{{SINGLE-QUOTE}}}) ) and fs.value not in ({{{SINGLE-QUOTE}}}no{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Not at all{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Unable to answer due to clinical condition{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}NA, under 12 years of age{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}NA under 12 years of age{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Unable to respond or under 12 years of age{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}neither{{{SINGLE-QUOTE}}}) ) or ocmi.name = {{{SINGLE-QUOTE}}}SCH_PSY_Columbia Risk Score{{{SINGLE-QUOTE}}} and obsparam.ValueText <> {{{SINGLE-QUOTE}}}No Risk{{{SINGLE-QUOTE}}} order by obsparam.RecordedDtm desc "}; endif; // DOCUMENT OPEN SECTION IF thisdocumentCommunication.EventType = "DocumentOpening" then HarmText := ""; // Concatenate the individual significant event items into a text variable (removes the commas) If exists SignificantEvent then SignificantEventText:= ""; for i in 1 seqto count SignificantEvent do SignificantEventText := SignificantEventText || SignificantEvent[i]; enddo; HarmText:= SignificantEventText; endif; // Concatenate the individual suicide list items into a text variable (removes the commas) If exists SuidcideObservation then SuidcideObservationText:= ""; for i in 1 seqto count SuidcideObservation do SuidcideObservationText := SuidcideObservationText || SuidcideObservation[i]; enddo; if HarmText = "" then HarmText := SuidcideObservationText; else HarmText := HarmText || SuidcideObservationText; endif; endif; If HarmText = "" then HarmText := "No history of harming self or others has been found in the chart." ; endif; // Populate past history free text box this_parametername := first of (thisParameters where thisParameters.Name = "sch_edtriage_Hurt History"); this_currentObj := NEW ObservationType; this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; this_currentObj.ParameterGUID := this_parametername.ParameterGUID; this_currentObj.DataType := "FreeTextValue"; this_currentObj.ValueObj := New FreeTextValueType; this_currentObj.ValueObj.Value := HarmText; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); // Determine which Orders were selected at Document Open (needed to prevent new orders from being created when the SN is updated for other reasons) if has_orders = "yes" then PriorOrders:= " "; theParameter := first of (thisparameters where thisparameters.Name = orders_observation_name); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "MHRN Consult") then PriorOrders:= PriorOrders || "M"; endif; If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "SCO 1:1") then PriorOrders:= PriorOrders || "S"; endif; If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Notify MD (day/evening) PPM (nights)") then PriorOrders:= PriorOrders || "N"; endif; If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Self Harm Precautions/Observation Monitoring") then PriorOrders:= PriorOrders || "P"; endif; If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Constant Observation (CO)") then PriorOrders:= PriorOrders || "C"; endif; If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Implement Environmental Assessment for High Suicidal Risk") then PriorOrders:= PriorOrders || "E"; endif; // Populate prior order selections free text box this_parametername := first of (thisParameters where thisParameters.Name = "SCH_PSY_Risk Orders Prior"); this_currentObj := NEW ObservationType; this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; this_currentObj.ParameterGUID := this_parametername.ParameterGUID; this_currentObj.DataType := "FreeTextValue"; this_currentObj.ValueObj := New FreeTextValueType; this_currentObj.ValueObj.Value := PriorOrders; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); endif; // Patient Profile only Section - if this is a new profile, populate Columbia question responses with the ED Triage responses from this visit If current_document_type= "patient_profile" and thisStructuredNoteDoc.ClientDocumentGUID is null then // Gather the responses SuidcideObservationThisVisit := read {" SET CONCAT_NULL_YIELDS_NULL off select ocmi.name + {{{SINGLE-QUOTE}}}|{{{SINGLE-QUOTE}}} + isnull ((obsparam.valuetext + fs.Value), {{{SINGLE-QUOTE}}}X{{{SINGLE-QUOTE}}}) from CV3ObsCatalogMasterItem ocmi with (nolock) inner join SXACDObservationParameter obsparam with (nolock) on " || ClientGuid || " = obsparam.ClientGUID and obsparam.ChartGUID = " || ChartGuid || " and obsparam.ClientVisitGUID = " || VisitGuid || " and obsparam.ObsMasterItemGUID = ocmi.GUID and obsparam.IsCanceled = 0 left outer join SCMObsFSListValues fs with (nolock) on fs.ClientGUID = " || ClientGuid || " and ObsParam.ObservationDocumentGUID = fs.ParentGUID join CV3ClientDocument cd with (nolock) on cd.guid = obsparam.OwnerGUID where ocmi.name in ({{{SINGLE-QUOTE}}}SCH_PSY_Columbia Risk Score{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_Wish Dead Wake Up{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_Done Start Any to End Life{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_Think of How Might do{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_Work out Detail of How to and Carry Out{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_PSY_THought and Intention of Acting{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_Actual Thought of Killing Self{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_Think of How Might do{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_PSY_How Long ago{{{SINGLE-QUOTE}}}) and cd.DocumentName = {{{SINGLE-QUOTE}}}ed triage note{{{SINGLE-QUOTE}}} and obsparam.ClientGUID = " || ClientGuid || " and obsparam.ChartGUID = " || ChartGuid || " and obsparam.ClientVisitGUID = " || VisitGuid || " "}; // Loop through the responses looking for the risk score for i in 1 seqto count SuidcideObservationThisVisit DO observation := SuidcideObservationThisVisit[i]; if observation matches pattern "SCH_PSY_Columbia Risk Score%" then RiskScore:= substring ((length of observation) - (FIND "|" STRING observation)) CHARACTERS STARTING AT ((FIND "|" STRING observation) +1) FROM observation; endif; enddo; // Pre-populate the responses unless it is No Risk if RiskScore <> "No Risk" then // Loop through the responses and update the corresponding observation in this note for i in 1 seqto count SuidcideObservationThisVisit DO observation := SuidcideObservationThisVisit[i]; ColumbiaQuestion := substring (FIND "|" STRING observation)-1 CHARACTERS STARTING AT 1 FROM observation; ColumbiaResponse := substring ((length of observation) - (FIND "|" STRING observation)) CHARACTERS STARTING AT ((FIND "|" STRING observation) +1) FROM observation; if observation matches pattern "SCH_PSY_Columbia Risk Score%" then // Populate risk score value text box this_parametername := first of (thisParameters where thisParameters.Name = ColumbiaQuestion); this_currentObj := NEW ObservationType; this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; this_currentObj.ParameterGUID := this_parametername.ParameterGUID; this_currentObj.DataType := "FreeTextValue"; this_currentObj.ValueObj := New FreeTextValueType; this_currentObj.ValueObj.Value := ColumbiaResponse; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); else // Populate the other observations this_parametername := first of (thisParameters where thisParameters.Name = ColumbiaQuestion ); this_currentObj := NEW ObservationType; this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; this_currentObj.ParameterGUID := this_parametername.ParameterGUID; this_currentObj.DataType := "ListValue"; this_currentObj.ValueObj := New ListValueType; this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; listItems := (); FOR item IN this_parametername.ConfigurationObj.ListItemsList DO selectedItem := NEW ListValueListItemType; selectedItem.ListItemGUID := item.ListItemGUID; selectedItem.Value := item.Value; if selectedItem.Value = ColumbiaResponse then selectedItem.IsSelected := true; endif; listItems := (listItems, selectedItem); ENDDO; this_currentobj.ValueObj.ListItemsList := listItems; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); endif; enddo; // Populate risk score instructions text box if RiskScore = "Low Risk" then protocol_instructions:= "Immediate notification of MD is required. Consider Special Constant Observation (SCO 1:1); Constant Observation and Safety Precautions/Observation Monitoring. Select the orders from below. If diet is being ordered: Add a Seclusion Tray with No Hot Beverages."; elseif RiskScore = "Moderate Risk" then protocol_instructions:= "Immediate notification of MD is required. Constant Observation; Safety Precautions/Observation Monitoring orders will be automatically entered. If diet is being ordered:Add a Seclusion Tray with No Hot Beverages."; elseif RiskScore = "High Risk" then protocol_instructions:= "Immediate notification of MD is required. Special Constant Observation (SCO 1:1); Environmental Assessment; Safety Precautions/Observation Monitoring orders will be automatically entered. If diet is being ordered: Add a Seclusion Tray with No Hot Beverages."; endif; this_parametername := first of (thisParameters where thisParameters.Name = "SCH_PSY_Risk Order Choices"); this_currentObj := NEW ObservationType; this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; this_currentObj.ParameterGUID := this_parametername.ParameterGUID; this_currentObj.DataType := "FreeTextValue"; this_currentObj.ValueObj := New FreeTextValueType; this_currentObj.ValueObj.Value := protocol_instructions; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); // Select the appropriate Orders for the risk this_parametername := first of (thisParameters where thisParameters.Name = orders_observation_name); this_currentObj := NEW ObservationType; this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; this_currentObj.ParameterGUID := this_parametername.ParameterGUID; this_currentObj.DataType := "ListValue"; this_currentObj.ValueObj := New ListValueType; this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; listItems := (); FOR item IN this_parametername.ConfigurationObj.ListItemsList DO selectedItem := NEW ListValueListItemType; selectedItem.ListItemGUID := item.ListItemGUID; selectedItem.Value := item.Value; if RiskScore = "High Risk" or RiskScore = "Moderate Risk" then if selectedItem.Value = "SCO 1:1" then selectedItem.IsSelected := true; endif; if selectedItem.Value = "Notify MD (day/evening) PPM (nights)" then selectedItem.IsSelected := true; endif; if selectedItem.Value = "Safety Precautions/Observation Monitoring" then selectedItem.IsSelected := true; endif; if selectedItem.Value = "Environmental Assessment" then selectedItem.IsSelected := true; endif; endif; listItems := (listItems, selectedItem); ENDDO; this_currentobj.ValueObj.ListItemsList := listItems; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); endif; // Moderate or High Risk Section endif; // Patient Profile Section // CHART OBSERVATION SECTION elseif thisdocumentCommunication.EventType = "ChartObservation" then theParameter := first of (thisparameters where thisparameters.Name = "SCH_PSY_Discrepancy"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = ".") then nurseoverride := "yes"; endif; // Determine which observation was selected if it is a Patient Profile or ED Triage Note (risk question vs order selection) if has_orders = "yes" then theParameter := first of (thisparameters where thisparameters.Name = orders_observation_name); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); endif; if (has_orders = "yes" and thisDocumentCommunication.CurrentObservationObj.parameterguid <> theParameter.ParameterGUID) or has_orders = "no" then // Risk Button or Descrepancy Checbox Selection Section // Determine which of the risk score buttons is selected riskscore := 0 as number; theParameter := first of (thisparameters where thisparameters.Name matches pattern "SCH_PSY_Wish Dead Wake Up%" or thisparameters.Name matches pattern "SCH_PSY_Wish Dead WakeUp%"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") then riskscore := riskscore + 1 as number; endif; theParameter := first of (thisparameters where thisparameters.Name matches pattern "SCH_PSY_Actual Thought of Killing%"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes...") then riskscore := riskscore + 1 as number; endif; theParameter := first of (thisparameters where thisparameters.Name matches pattern "SCH_PSY_Think of How Might%"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") then riskscore := riskscore + 10 as number; endif; theParameter := first of (thisparameters where thisparameters.Name matches pattern "SCH_PSY_Thought and Intention%"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") then riskscore := riskscore + 20 as number; endif; theParameter := first of (thisparameters where thisparameters.Name matches pattern "SCH_PSY_Work out Detail of How to and Carry%"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") then riskscore := riskscore + 20 as number; endif; theParameter := first of (thisparameters where thisparameters.Name matches pattern "SCH_PSY_How Long%"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Over a year ago") then riskscore := riskscore + 1 as number; elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Between 3 months and a year") then riskscore := riskscore + 10 as number; elseif true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Within the last 3 months") then riskscore := riskscore + 20 as number; endif; // Only found in the Columbia Severity Score for Outpatients Note theParameter := first of (thisparameters where thisparameters.Name = "SCH_PSY_Risk Protect Factors"); // This one will elevate from Low to Moderate theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") and riskscore >= 0 and riskscore < 10 then riskscore := riskscore + 10 as number; endif; // Only found in the Behavioral Health Outpatient Note theParameter := first of (thisparameters where thisparameters.Name = "SCH_PSY_Recent hosp step down"); // This one will elevate from Low to Moderate theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "yes") and riskscore >= 0 and riskscore < 10 then riskscore := riskscore + 10 as number; endif; // Calculate the risk score value If riskscore = 0 then riskscorevalue := "No Risk"; triage_instructions := "No Mental Health orders are necessary."; profile_instructions := "No Mental Health orders are necessary."; columbop_instructions:= "No Mental Health orders are necessary."; elseif riskscore >= 0 and riskscore < 10 then riskscorevalue := "Low Risk"; triage_instructions := "Consider ordering MHRN Consult and/or Special Constant Observation (SCO 1:1); or Constant Observation with Safety Precautions/Observation Monitoring if other risk factors are present. Select from below. If diet is being ordered: Add a Seclusion Tray with No Hot Beverages."; profile_instructions := "Immediate notification of MD is required. Consider Special Constant Observation (SCO 1:1); Constant Observation and Safety Precautions/Observation Monitoring. Select the orders from below. If diet is being ordered: Add a Seclusion Tray with No Hot Beverages"; columbop_instructions:= "Low:\n\n-Develop and or reinforce Crisis Safety Plan"; elseif riskscore >= 10 and riskscore < 20 then riskscorevalue := "Moderate Risk"; triage_instructions := "MHRN Consult; Constant Observation; Safety Precautions/Observation Monitoring; orders will be automatically entered. If diet is being ordered: Add a Seclusion Tray with No Hot Beverages"; profile_instructions := "Immediate notification of MD is required. Constant Observation; Safety Precautions/Observation Monitoring orders will be automatically entered. If diet is being ordered:Add a Seclusion Tray with No Hot Beverages."; columbop_instructions:= "Moderate: \n\n-Develop and or reinforce Crisis Safety Plan \n\n-Patient to complete Self Report form at each visit \n\n-Staff to review patient{{{SINGLE-QUOTE}}}s Self Report form at each visit and discuss with patient if this is a change from last contact"; elseif riskscore >= 20 then riskscorevalue := "High Risk"; triage_instructions := "Immediate notification of MD is required. MHRN Consult, Special Constant Observation (SCO 1:1)), Implement the Safety Precautions/ Observation Monitoring Form, the Environmental Assessment for High Suicidal Risk will be automatically entered. If diet is being ordered: Add a Seclusion Tray with No Hot Beverages."; profile_instructions := "Immediate notification of MD is required. Special Constant Observation (SCO 1:1); Environmental Assessment; Safety Precautions/Observation Monitoring orders will be automatically entered. If diet is being ordered:Add a Seclusion Tray with No Hot Beverages."; columbop_instructions:= "High:\n\n-SCO 1:1 \n\n-Escort patient to the Emergency Department for a mental health evaluation \n\n-Contact attending psychiatrist \n\n-Encourage patient to notify family/significant other or staff to call if patient requests"; endif; // Populate risk score value text box this_parametername := first of (thisParameters where thisParameters.Name = "SCH_PSY_Columbia Risk Score"); this_currentObj := NEW ObservationType; this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; this_currentObj.ParameterGUID := this_parametername.ParameterGUID; this_currentObj.DataType := "FreeTextValue"; this_currentObj.ValueObj := New FreeTextValueType; this_currentObj.ValueObj.Value := riskscorevalue; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); // Populate risk score instructions text box If current_document_type= "patient_profile" then protocol_instructions := profile_instructions; else protocol_instructions := triage_instructions; endif; // ED Triage Note vs Patient Profile ? this_parametername := first of (thisParameters where thisParameters.Name = "SCH_PSY_Risk Order Choices"); this_currentObj := NEW ObservationType; this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; this_currentObj.ParameterGUID := this_parametername.ParameterGUID; this_currentObj.DataType := "FreeTextValue"; this_currentObj.ValueObj := New FreeTextValueType; this_currentObj.ValueObj.Value := protocol_instructions; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); // Populate Interventions text box (Columbia Severity Score Note only) this_parametername := first of (thisParameters where thisParameters.Name = "SCH_PSY_Interventions"); // Columbia Severity Note for Outpatients only this_currentObj := NEW ObservationType; this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; this_currentObj.ParameterGUID := this_parametername.ParameterGUID; this_currentObj.DataType := "FreeTextValue"; this_currentObj.ValueObj := New FreeTextValueType; this_currentObj.ValueObj.Value := columbop_instructions; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); if has_orders = "yes" then // Select the appropriate Orders for the risk this_parametername := first of (thisParameters where thisParameters.Name = orders_observation_name); this_currentObj := NEW ObservationType; this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; this_currentObj.ParameterGUID := this_parametername.ParameterGUID; this_currentObj.DataType := "ListValue"; this_currentObj.ValueObj := New ListValueType; this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; listItems := (); FOR item IN this_parametername.ConfigurationObj.ListItemsList DO selectedItem := NEW ListValueListItemType; selectedItem.ListItemGUID := item.ListItemGUID; selectedItem.Value := item.Value; if riskscorevalue = "High Risk" then if selectedItem.Value = "SCO 1:1" then selectedItem.IsSelected := true; endif; if selectedItem.Value = "MHRN Consult" then selectedItem.IsSelected := true; endif; // ED Triage Note Only if selectedItem.Value = "Notify MD (day/evening) PPM (nights)" then selectedItem.IsSelected := true; endif; // Patient Profile Only if selectedItem.Value = "Environmental Assessment" then selectedItem.IsSelected := true; endif; if selectedItem.Value = "Safety Precautions/Observation Monitoring" then selectedItem.IsSelected := true; endif; endif; if riskscorevalue = "Moderate Risk" then if selectedItem.Value = "CO" then selectedItem.IsSelected := true; endif; if selectedItem.Value = "MHRN Consult" then selectedItem.IsSelected := true; endif; // ED Triage Note Only if selectedItem.Value = "Notify MD (day/evening) PPM (nights)" then selectedItem.IsSelected := true; endif; // Patient Profile Only if selectedItem.Value = "Safety Precautions/Observation Monitoring" then selectedItem.IsSelected := true; endif; endif; if nurseoverride = "yes" then if selectedItem.Value = "SCO 1:1" then selectedItem.IsSelected := true; endif; endif; listItems := (listItems, selectedItem); ENDDO; this_currentobj.ValueObj.ListItemsList := listItems; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); endif; else // Order Button Checkbox Selection Section if has_orders = "yes" then // Determine the value Risk Score text box theParameter := first of (thisParameters where thisParameters.Name = "SCH_PSY_Columbia Risk Score"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); riskscorevalue := theObservation.ValueObj.Value; if (riskscorevalue = "Moderate Risk" or riskscorevalue = "High Risk") then // Select the appropriate Orders for the risk this_parametername := first of (thisParameters where thisParameters.Name = orders_observation_name); this_currentObj := NEW ObservationType; this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; this_currentObj.ParameterGUID := this_parametername.ParameterGUID; this_currentObj.DataType := "ListValue"; this_currentObj.ValueObj := New ListValueType; this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; listItems := (); FOR item IN this_parametername.ConfigurationObj.ListItemsList DO selectedItem := NEW ListValueListItemType; selectedItem.ListItemGUID := item.ListItemGUID; selectedItem.Value := item.Value; if riskscorevalue = "High Risk" then if selectedItem.Value = "SCO 1:1" then selectedItem.IsSelected := true; endif; if selectedItem.Value = "MHRN Consult" then selectedItem.IsSelected := true; endif; // ED Triage Note Only if selectedItem.Value = "Notify MD (day/evening) PPM (nights)" then selectedItem.IsSelected := true; endif; // Patient Profile Only if selectedItem.Value = "Environmental Assessment" then selectedItem.IsSelected := true; endif; if selectedItem.Value = "Safety Precautions/Observation Monitoring" then selectedItem.IsSelected := true; endif; endif; if riskscorevalue = "Moderate Risk" then if selectedItem.Value = "CO" then selectedItem.IsSelected := true; endif; if selectedItem.Value = "MHRN Consult" then selectedItem.IsSelected := true; endif; // ED Triage Note Only if selectedItem.Value = "Notify MD (day/evening) PPM (nights)" then selectedItem.IsSelected := true; endif; // Patient Profile Only if selectedItem.Value = "Safety Precautions/Observation Monitoring" then selectedItem.IsSelected := true; endif; endif; listItems := (listItems, selectedItem); ENDDO; this_currentobj.ValueObj.ListItemsList := listItems; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); endif; // Manually select orders when the patient is low risk if riskscorevalue = "Low Risk" then SelectedBefore:= local_session.SessionSuicideOrdersSelected; theParameter := first of (thisparameters where thisparameters.Name = orders_observation_name); theObservation:= first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); SelectedNow := (theObservation.ValueObj.ListItemsList.Value where theObservation.ValueObj.ListItemsList.IsSelected = true); // SCO is selected if "SCO 1:1" in SelectedNow then this_parametername := first of (thisParameters where thisParameters.Name = orders_observation_name); this_currentObj := NEW ObservationType; this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; this_currentObj.ParameterGUID := this_parametername.ParameterGUID; this_currentObj.DataType := "ListValue"; this_currentObj.ValueObj := New ListValueType; this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; listItems := (); FOR item IN this_parametername.ConfigurationObj.ListItemsList DO selectedItem := NEW ListValueListItemType; selectedItem.ListItemGUID := item.ListItemGUID; selectedItem.Value := item.Value; if selectedItem.Value = "SCO 1:1" then selectedItem.IsSelected := true; endif; if selectedItem.Value = "MHRN Consult" then selectedItem.IsSelected := true; endif; // ED Triage Note Only if selectedItem.Value = "Notify MD (day/evening) PPM (nights)" then selectedItem.IsSelected := true; endif; // Patient Profile Only if selectedItem.Value = "Environmental Assessment" then selectedItem.IsSelected := true; endif; if selectedItem.Value = "Safety Precautions/Observation Monitoring" then selectedItem.IsSelected := true; endif; if selectedItem.Value = "CO" then selectedItem.IsSelected := false; endif; listItems := (listItems, selectedItem); ENDDO; this_currentobj.ValueObj.ListItemsList := listItems; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); elseif "SCO 1:1" not in SelectedNow and "SCO 1:1" in SelectedBefore then this_parametername := first of (thisParameters where thisParameters.Name = orders_observation_name); this_currentObj := NEW ObservationType; this_currentObj.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; this_currentObj.ParameterGUID := this_parametername.ParameterGUID; this_currentObj.DataType := "ListValue"; this_currentObj.ValueObj := New ListValueType; this_currentObj.ValueObj.ListGUID:= this_parametername.ConfigurationObj.ListGUID; listItems := (); FOR item IN this_parametername.ConfigurationObj.ListItemsList DO selectedItem := NEW ListValueListItemType; selectedItem.ListItemGUID := item.ListItemGUID; selectedItem.Value := item.Value; if selectedItem.Value = "SCO 1:1" then selectedItem.IsSelected := false; endif; if selectedItem.Value = "MHRN Consult" then selectedItem.IsSelected := false; endif; // ED Triage Note Only if selectedItem.Value = "Notify MD (day/evening) PPM (nights)" then selectedItem.IsSelected := false; endif; // Patient Profile Only if selectedItem.Value = "Environmental Assessment" then selectedItem.IsSelected := false; endif; if selectedItem.Value = "Safety Precautions/Observation Monitoring" then selectedItem.IsSelected := false; endif; if selectedItem.Value = "CO" then selectedItem.IsSelected := false; endif; listItems := (listItems, selectedItem); ENDDO; this_currentobj.ValueObj.ListItemsList := listItems; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); endif; // SCO selected local_session.SessionSuicideOrdersSelected:= SelectedNow; // Set session object = orders that were selected endif; // Low Risk endif; // The note has orders endif; // Risk Button or Order Button was selected // DOCUMENT CLOSE SECTION elseif thisdocumentCommunication.EventType = "DocumentClosing" then // Determine the value of the risk score field theParameter := first of (thisParameters where thisParameters.Name = "SCH_PSY_Columbia Risk Score"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); riskscorevalue := theObservation.ValueObj.Value; // Search for {{{SINGLE-QUOTE}}}Call Physician{{{SINGLE-QUOTE}}} order on file (CallPhysicianOnFile) := read {" select distinct ocmi.name from cv3ordercatalogmasteritem ocmi with (nolock) join cv3order o with (nolock) on o.ordercatalogmasteritemguid = ocmi.guid where o.clientguid = " || clientGuid || " and o.chartguid = " || chartGuid || " and o.clientvisitguid = " || visitGuid || " and ocmi.name = {{{SINGLE-QUOTE}}}Call Physician{{{SINGLE-QUOTE}}} "}; // Display the "contact the doctor" message if "High Risk" (suppress on SN modify "Call Physician" order already on file) If current_document_type = "triage_note" then notifymessage := "\n The patient score suggests a high risk of suicide.\n\n\n Please contact the doctor immediately.\n"; else notifymessage := "\n The patient score suggests a high risk of suicide.\n\n\n Please contact the doctor(day/evening) PPM (nights) immediately.\n"; endif; If riskscorevalue = "High Risk" and not exists CallPhysicianOnFile then dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with notifymessage, "Suicide Caution","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; endif; // Determine which order boxes were selected ordercount:= 0; if has_orders = "yes" then theParameter := first of (thisparameters where thisparameters.Name = orders_observation_name); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "SCO 1:1") then ordercount := ordercount + 1; SCOorder := true; ordername:= "SCO 1:1"; endif; If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "CO") then ordercount := ordercount + 1; COorder := true; ordername:= "CO"; endif; If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "MHRN Consult") then ordercount := ordercount + 1; MHRNorder := true; ordername:= "Mental Health Nurse Consult"; endif; If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Notify MD (day/evening) PPM (nights)") then ordercount := ordercount + 1; NotifyMDorder := true; ordername:= "Notify MD"; endif; If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Safety Precautions/Observation Monitoring") then ordercount := ordercount + 1; HarmPrecautorder:= true; ordername:= "Implement Safety Precautions/Observation Monitoring"; endif; If true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = "Environmental Assessment") then ordercount := ordercount + 1; EnvirAssessorder:= true; ordername:= "Implement Safety Precautions/Observation Monitoring"; endif; endif; // Create orders if something was selected if ordercount > 0 then // Search for orders already on file (MHorderOnFile) := read {" select distinct ocmi.name from cv3ordercatalogmasteritem ocmi with (nolock) join cv3order o with (nolock) on o.ordercatalogmasteritemguid = ocmi.guid where o.clientguid = " || clientGuid || " and o.chartguid = " || chartGuid || " and o.clientvisitguid = " || visitGuid || " and ocmi.name in ({{{SINGLE-QUOTE}}}Constant Observation (CO){{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Special Constant Observation (SCO 1:1){{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Mental Health Nurse Consult{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Implement Environmental Assessment for High Suicidal Risk{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Implement Safety Precautions/ Observation Monitoring{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Call Physician{{{SINGLE-QUOTE}}}) "}; // Attain the Attending MD attendingguid := read last {"Select providerguid from cv3careprovidervisitrole cpr with (nolock) join cv3user u with (nolock) on u.guid = cpr.providerguid where cpr.rolecode = {{{SINGLE-QUOTE}}}attending{{{SINGLE-QUOTE}}} and cpr.active = 1 and cpr.ToDtm is null and u.lastname not like {{{SINGLE-QUOTE}}}non staff%{{{SINGLE-QUOTE}}} and cpr.clientguid = " || clientguid || " and cpr.chartguid = " || chartguid || " and cpr.clientvisitguid = " || visitguid || " "}; SCOOnFile := false; MHRNOnFile := false; NotifyMDOnFile := false; HarmPrecautOnFile:= false; EnvirAssessOnFile:= false; COOnFile := false; If exists MHorderOnFile then for i in 1 seqto count MHorderOnFile do if MHorderOnFile[i] = "Special Constant Observation (SCO 1:1)" then SCOOnFile := true; endif; if MHorderOnFile[i] = "Mental Health Nurse Consult" then MHRNOnFile := true; endif; if MHorderOnFile[i] = "Call Physician" then NotifyMDOnFile := true; endif; if MHorderOnFile[i] = "Implement Safety Precautions/ Observation Monitoring" then HarmPrecautOnFile:= true; endif; if MHorderOnFile[i] = "Implement Environmental Assessment for High Suicidal Risk" then EnvirAssessOnFile:= true; endif; if MHorderOnFile[i] = "Constant Observation (CO)" then COOnFile := true; endif; enddo; endif; // Determine is the order is newly selected by comparing it to the list of orders selected upon document open PriorOrderSCO := 0; PriorOrderMHRN := 0; PriorOrderHarmPrecaut:= 0; PriorOrderNotifyMD := 0; PriorOrderEnvirAssess:= 0; PriorOrderCO := 0; theParameter := first of (thisParameters where thisParameters.Name = "SCH_PSY_Risk Orders Prior"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); if exists theObservation then PriorOrderList:= theObservation.ValueObj.Value; PriorOrderSCO := FIND "S" IN STRING PriorOrderList; PriorOrderMHRN := FIND "M" IN STRING PriorOrderList; PriorOrderHarmPrecaut := FIND "P" IN STRING PriorOrderList; PriorOrderNotifyMD := FIND "N" IN STRING PriorOrderList; PriorOrderEnvirAssess := FIND "E" IN STRING PriorOrderList; PriorOrderCO := FIND "C" IN STRING PriorOrderList; endif; // Create Objects and value variables to be used by either order try locationGuid := read last {"SELECT CurrentLocationGUID, touchedWhen" || " FROM CV3ClientVisit with (nolock)" || " WHERE GUID = " || Sql(visitGuid) || " AND ClientGUID = " || Sql(clientGuid) , primaryTime = touchedWhen}; client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((locationGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); Order_Creation_Reason := "Suicide Risk Assessment"; RequestingSource := "Standing Order"; SessionType := "Standard"; SessionReason := ""; endtry; catch Exception ex error_occurred := true; error_message := "{{+R}}CommonData: {{-R}}\n" || ex.Message || "\n\n"; if location_obj IS NOT Null then void := call location_obj.Dispose; location_obj := null; endif; if client_visit_obj IS NOT Null then void := call client_visit_obj.Dispose; client_visit_obj := null; endif; endcatch; if client_visit_obj IS NOT Null then // Create SSO Order if SCOorder = true and SCOOnFile = false and PriorOrderSCO = 0 then try if not exist attendingguid then if current_document_type = "triage_note" then attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}biggs{{{SINGLE-QUOTE}}} and firstname = {{{SINGLE-QUOTE}}}jason{{{SINGLE-QUOTE}}} and active = 1"}; else attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}non staff{{{SINGLE-QUOTE}}} and active = 1"}; endif; endif; care_provider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((attendingGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); order_catalog_obj:= call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with ("Special Constant Observation (SCO 1:1)"); order_obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder with client_visit_obj, order_catalog_obj,Order_Creation_Reason,care_provider_obj,RequestingSource,SessionType,SessionReason,location_obj,"Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; void := call order_obj.Save; if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; endtry; catch Exception ex error_occurred := true; error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; endcatch; endif; // Create CO Order if COorder = true and COOnFile = false and PriorOrderCO = 0 then try if not exist attendingguid then if current_document_type = "triage_note" then attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}biggs{{{SINGLE-QUOTE}}} and firstname = {{{SINGLE-QUOTE}}}jason{{{SINGLE-QUOTE}}} and active = 1"}; else attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}non staff{{{SINGLE-QUOTE}}} and active = 1"}; endif; endif; care_provider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((attendingGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); order_catalog_obj:= call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with ("Constant Observation (CO)"); order_obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder with client_visit_obj, order_catalog_obj,Order_Creation_Reason,care_provider_obj,RequestingSource,SessionType,SessionReason,location_obj,"Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; void := call order_obj.Save; if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; endtry; catch Exception ex error_occurred := true; error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; endcatch; endif; // Create MNRN Consult Order if MHRNorder = true and MHRNOnFile = false and PriorOrderMHRN = 0 then try if not exist attendingguid then if current_document_type = "triage_note" then attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}biggs{{{SINGLE-QUOTE}}} and firstname = {{{SINGLE-QUOTE}}}jason{{{SINGLE-QUOTE}}} and active = 1"}; else attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}non staff{{{SINGLE-QUOTE}}} and active = 1"}; endif; endif; care_provider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((attendingGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); order_catalog_obj:= call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with ("Mental Health Nurse Consult"); order_obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder with client_visit_obj, order_catalog_obj,Order_Creation_Reason,care_provider_obj,RequestingSource,SessionType,SessionReason,location_obj,"Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; void := call order_obj.Save; if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; endtry; catch Exception ex error_occurred := true; error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; endcatch; endif; // Create Notify MD Order if NotifyMDorder = true and NotifyMDOnFile = false and PriorOrderNotifyMD = 0 then try if not exist attendingguid then if current_document_type = "triage_note" then attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}biggs{{{SINGLE-QUOTE}}} and firstname = {{{SINGLE-QUOTE}}}jason{{{SINGLE-QUOTE}}} and active = 1"}; else attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}non staff{{{SINGLE-QUOTE}}} and active = 1"}; endif; endif; care_provider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((attendingGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); order_catalog_obj:= call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with ("Call Physician"); order_obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder with client_visit_obj, order_catalog_obj,Order_Creation_Reason,care_provider_obj,RequestingSource,SessionType,SessionReason,location_obj,"Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; order_obj.SpecialInstructions := "Notify MD (day/evening) PPM (nights). Further direction regarding mental health consult"; retval := call order_obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue{{{SINGLE-QUOTE}}} with "NUR_NotifyType", "Physician" ; void := call order_obj.Save; if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; endtry; catch Exception ex error_occurred := true; error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; endcatch; endif; // Create Environmental Assessment Order if EnvirAssessorder = true and EnvirAssessOnFile = false and PriorOrderEnvirAssess = 0 then try if not exist attendingguid then if current_document_type = "triage_note" then attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}biggs{{{SINGLE-QUOTE}}} and firstname = {{{SINGLE-QUOTE}}}jason{{{SINGLE-QUOTE}}} and active = 1"}; else attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}non staff{{{SINGLE-QUOTE}}} and active = 1"}; endif; endif; care_provider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((attendingGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); order_catalog_obj:= call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with ("Implement Environmental Assessment for High Suicidal Risk"); order_obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder with client_visit_obj, order_catalog_obj,Order_Creation_Reason,care_provider_obj,RequestingSource,SessionType,SessionReason,location_obj,"Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; void := call order_obj.Save; if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; endtry; catch Exception ex error_occurred := true; error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; endcatch; endif; // Create Self Harm Precautions Order if HarmPrecautorder = true and HarmPrecautOnFile = false and PriorOrderHarmPrecaut = 0 then try if not exist attendingguid then if current_document_type = "triage_note" then attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}biggs{{{SINGLE-QUOTE}}} and firstname = {{{SINGLE-QUOTE}}}jason{{{SINGLE-QUOTE}}} and active = 1"}; else attendingGuid := read last {"Select guid from cv3user with (nolock) where lastname = {{{SINGLE-QUOTE}}}non staff{{{SINGLE-QUOTE}}} and active = 1"}; endif; endif; care_provider_obj:= call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((attendingGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); order_catalog_obj := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with ("Implement Safety Precautions/ Observation Monitoring"); order_obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder with client_visit_obj, order_catalog_obj,Order_Creation_Reason,care_provider_obj,RequestingSource,SessionType,SessionReason,location_obj,"Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; void := call order_obj.Save; if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; endtry; catch Exception ex error_occurred := true; error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n"; if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif; if order_obj is not null then void := call order_obj.Dispose; order_obj := null; endif; if order_catalog_obj is not null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif; endcatch; endif; // Dispose of common objects if location_obj is not null then void := call location_obj.Dispose; location_obj := null; endif; if client_visit_obj is not null then void := call client_visit_obj.Dispose; client_visit_obj := null; endif; endif; // Common Objects were succesfully created ? endif; // Order count > 0 // DOCUMENT ENTER/MODIFY EVOKE SECTION else // Update the Enterprise Defined Column after the filing of the document. A new risk may have been revealed by the Columnbia resposnes If called_by_editor then columnvalue := "."; endif; if exists SuidcideObservation or exists SignificantEvent then columnvalue := "Yes"; else columnvalue := "."; endif; create_ED_column := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_CREATE_ENTERPRISE_DEFINED_COLUMN{{{SINGLE-QUOTE}}}; // MLM that creates the Enterprise Defined Column EDCObj := OBJECT [column_name,column_value,client_guid,chart_guid,client_visit_guid]; // Create Enterprise Defined Column Obj SuicideViolence_Column := NEW EDCObj WITH [ column_name := "Suicide Violence Risk", column_value := columnvalue, client_guid := ClientGUID, chart_guid := ChartGUID, client_visit_guid := visitGuid ]; return_value := call create_ED_column with ( SuicideViolence_Column ); endif; // Document Open / Chart Observation / Document Enter/ Document Modify Evoking Event ;; evoke: 15 seconds after time of document_event_enter; 15 seconds after time of document_event_modify; ;; logic: conclude true; ;; action: return thisDocumentCommunication; ;; Urgency: 50;; end: