maintenance: title: Doc_Launch_PDMP_Search;; filename: Doc_Launch_PDMP_Search;; arden: version 2;; version: 1.00;; institution: St. Clair Hospital;; author: Peggy Karish;; specialist: Don Warnick;; date: 2015-03-04;; validation: testing;; library: purpose: This mlm launches the PDMP Search Objects+ custom application from a document ;; explanation: The PDMP Search Objects+ custom application was designed to make searching the Pennsylvania Department of Health Drug Monitoring Program website easier. This MLM will also document in the Structured Note that the doctor has searched the site. Change history 04.27.2017 DW CSR# 35436 - PDMP Improvements - Created 09.28.2018 DW CSR# 36715 Created - PDMP in order session ;; keywords: ;; knowledge: type: data-driven;; data: (this_documentCommunication) := argument; log_execution_info := FALSE; str_parse := mlm {{{SINGLE-QUOTE}}}UTIL_STRING_PARSE{{{SINGLE-QUOTE}}}; standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; include standard_libs; using "ObjectsPlusXA.SCM.Forms"; using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; problemlist := " "; launchtheapp:= "yes"; (thisStructuredNoteDoc) := this_documentCommunication.DocumentConfigurationObj; (thisParameters) := thisStructuredNoteDoc.ParametersList; (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; FreeTextValueType := OBJECT [Value]; DateValueType := OBJECT [Value]; ListValueType := OBJECT [ListGuid,ListItemsList, SuggestedTextValue]; ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected]; launchtheapp:= "no"; client_visit_guid := this_documentCommunication.clientvisitguid; client_guid := this_documentCommunication.clientguid; chart_guid := this_documentCommunication.chartguid; user_guid := this_documentCommunication.UserGUID; user_name := read last {"SELECT case when middlename is not null then firstname + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + middlename + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + lastname else firstname + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + lastname end FROM CV3User with (nolock) WHERE GUID = " || Sql(user_guid)} ; SignificantEvent_dest:= destination { ObjectsPlus } with [ alert_type := "Warning", short_message := "Object created by MLM", priority := "low", scope := "General",rule_group := "Significant Event Object", rule_number := 2010 ]; error_destination := destination { Alert } with [ alert_type := "Warning", short_message := "ObjectsPlus Error from MLM", priority := "low", scope := "chart", Rule_group := "ObjectsPlus Error from MLM", Rule_number := 1001, Rule_subgroup := "", Send_with_order := "", Alert_dialog_settings := "", Display_alert := true ]; selectedobservationname:= first of (thisparameters.Name where thisparameters.ParameterGUID = this_documentCommunication.CurrentObservationObj.parameterguid); // Document Open IF this_documentCommunication.EventType = "DocumentOpening" then // Gather, format, and write the PDMP Search significant events for this visit to a text field pastsearches := read {" select text from CV3ClientEventDeclaration with (nolock) " || " where Description = {{{SINGLE-QUOTE}}}Checked{{{SINGLE-QUOTE}}} and clientvisitguid = " || client_visit_guid || " and chartguid = " || chart_guid || " and clientguid = " || client_guid || " and status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}} order by createdwhen desc " }; pastsearches_count := count(pastsearches) As Number; pastsearch_information:=""; if pastsearches_count > 0 then for k in (1 seqto (pastsearches_count )) do if pastsearches[k] is not null then pastsearch_information := pastsearch_information || pastsearches[k] || "\n" ; if k <> pastsearches_count then // not the last in the list pastsearch_information := pastsearch_information; endif; endif; enddo; endif; writefield := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Drug MonitorSig Event FT"); newObservation := NEW ObservationType; newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; newObservation.ParameterGUID := writefield.ParameterGUID; newObservation.DataType := "FreeTextValue"; newObservation.ValueObj := NEW FreeTextValueType; newObservation.ValueObj.Value := pastsearch_information; thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); endif; // Document Open // Chart Observation /* // A Comment was selected from the list IF this_documentCommunication.EventType = "ChartObservation" and selectedobservationname = "SCH_MDPN_No Flag List" then launchtheapp:= "no"; // Concatenate the search date stamp and comments to a text field which will be made into a significant event theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Drug Monitor Checked FT"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); search_datestamp := theObservation.ValueObj.Value; if search_datestamp is null then search_datestamp := "Comment entered without search by " || user_name || " " || extract month now || "/" || extract day now || "/" || extract year now || " "; endif; datestamp_and_comments:= search_datestamp; theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_No Flag List"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); listItems := (); FOR item IN theParameter.ConfigurationObj.ListItemsList DO selectedItem := NEW ListValueListItemType; selectedItem.ListItemGUID := item.ListItemGUID; selectedItem.Value := item.Value; if true in (theObservation.ValueObj.ListItemsList.IsSelected where theObservation.ValueObj.ListItemsList.Value = selectedItem.Value) then datestamp_and_comments := datestamp_and_comments || " " || selectedItem.Value; endif; listItems := (listItems, selectedItem); ENDDO; writefield := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Drug Monitoring Comment FT"); newObservation := NEW ObservationType; newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; newObservation.ParameterGUID := writefield.ParameterGUID; newObservation.DataType := "FreeTextValue"; newObservation.ValueObj := NEW FreeTextValueType; newObservation.ValueObj.Value := datestamp_and_comments; thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); */ // ElseIf this_documentCommunication.EventType = "ChartObservation" and selectedobservationname = "SCH_MDPN_Launch PA Drug App" // The Launch button was selected If this_documentCommunication.EventType = "ChartObservation" and selectedobservationname = "SCH_MDPN_Launch PA Drug App" then launchtheapp:= "yes"; // Launch the PDMP Search using "LaunchPDMP"; test:= new net_object {{{SINGLE-QUOTE}}}LaunchPDMP.LaunchPDMPForm{{{SINGLE-QUOTE}}}; // Reset the launch button theParameterx := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Launch PA Drug App"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameterx.ParameterGUID); if this_documentCommunication.CurrentObservationObj.parameterguid = theParameterx.ParameterGUID then this_parametername := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Launch PA Drug App"); 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; selectedItem.IsSelected := false; listItems := (listItems, selectedItem); ENDDO; this_currentobj.ValueObj.ListItemsList := listItems; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); endif; // Some other button was selected (shouldn{{{SINGLE-QUOTE}}}t happen) else launchtheapp:= "no"; endif; // ChartObservation ;; evoke: // No evoke statement ;; logic: // Gather Data from the text field that contains search date stamp and comments theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_Drug Monitoring Comment FT"); theObservation := first of (thisobservations where thisobservations.ParameterGUID = theParameter.ParameterGUID); pdmp_search_information := theObservation.ValueObj.Value; // Document Closing with search information If this_documentCommunication.EventType = "DocumentClosing" and launchtheapp = "no" and pdmp_search_information is not null then try client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((client_visit_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; endtry; catch Exception ex error_occurred := true; error_message := "{{+R}}Retrieve client:{{-R}}\n" || ex.Message || "\n\n"; if ex.InnerException is not null net_object then error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; endif; endcatch; TimeOfEntry := now ; yr := extract year TimeOfEntry; mn := extract month TimeOfEntry; dd := extract day TimeOfEntry; PartialDate_obj := new net_object {{{SINGLE-QUOTE}}}PartialDate{{{SINGLE-QUOTE}}} with ( yr as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, // Year mn as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}}, // Month dd as {{{SINGLE-QUOTE}}}Int32{{{SINGLE-QUOTE}}} ); // Day BBEventTypeCode := "PDMP"; BBEventText := pdmp_search_information; LeukRedEventText := "Checked"; // Create Significant Event try SignificantEvent_obj := call {{{SINGLE-QUOTE}}}SignificantEvent{{{SINGLE-QUOTE}}}.CreateSignificantEvent with (client_visit_obj, //ClientVisit BBEventTypeCode, //TypeCode LeukRedEventText); //Event SignificantEvent_obj.Text := BBEventText; SignificantEvent_obj.OnsetDate := PartialDate_obj; SignificantEvent_dest.ObjectsPlus := SignificantEvent_obj; void := call SignificantEvent_obj.save; endtry; catch exception ex error_occurred := true; error_message := error_message || "{{+R}}New Significant Event{{-R}}\n" || ex.Message || "\n\n"; if ex.InnerException is not null net_object then error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; endif; if ( SignificantEvent_obj is NOT NULL ) then void:= call SignificantEvent_obj.Dispose; SignificantEvent_obj:= null; endif; SignificantEvent_dest := null; endcatch; if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; endif; // Launch the application if launchtheapp = "yes" then oeUnsigned:=CALL test.ShowDialog; return_string:= test.text; endif; // Application has closed after a search // if return_string = "search completed" if return_string matches pattern "search completed%" then SearchAssessment := substring 80 characters starting at 17 from return_string ; // SearchInformation:= "PDMP Searched by " || user_name || " " || Now; SearchInformation:= "PDMP Searched by " || user_name || " " || extract month now || "/" || extract day now || "/" || extract year now || " " || extract hour now || ":" || extract minute now || SearchAssessment; // Populate Information Boxes With The Scearh Stamp // Search Stamp Box this_parametername := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Drug Monitor Checked FT"); 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 := SearchInformation; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); // Comment Box (search stamp plus physician comments) this_parametername := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Drug Monitoring Comment FT"); 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 := SearchInformation; thisStructuredNoteDoc.ChartedObservationsList := (thisstructuredNoteDoc.ChartedObservationsList, this_currentObj); endif; conclude true; // always concludes TRUE ;; action: if Error_occurred then write "An error has occured in the MLM {{+B}}Doc_Launch_PDMP_Search {{-B}} " || "Please notify your System Administrators that an error message has occurred for this patient. They will review the following error message: \n" at error_destination; write error_message at error_destination; endif; if EXISTS SignificantEvent_dest then write true at SignificantEvent_dest; endif; return this_documentCommunication; ;; end: