maintenance: title: SCH_FUNC_DISCONTINUE_ORDER;; mlmname: SCH_FUNC_DISCONTINUE_ORDER;; arden: version 2.5;; version: 16.30;; institution: ;; author: Juliet M. Law;; specialist: St. Clair Hospital;; date: 2017-09-25;; validation: testing;; library: purpose: Discontinue an Order using the information passed from the calling MLM. ;; explanation: Called MLM that discontinues orders for a patient. Copied from SCH_FUNC_CREATE_ORDER MLM. Change history 09.25.2017 JML CSR# 26413 Created ;; keywords: Called MLM, Generic, Discontinue Order ;; knowledge: type: data-driven;; data: (visitGUID, userGUID, orderGUID, orderDCReason) := ARGUMENT; // Specify which .NET assemblies need to be loaded for ObjectsPlus standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; using "mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; using "System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; using "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; using "ObjectsPlusXA.SCM"; using "System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; using "SCMLib"; using namespace "System"; using namespace "System.Exception"; using namespace "System.Windows.Forms"; using namespace "ObjectsPlusXA.SunriseClinicalManager"; using namespace "SCMLib.PObj"; using namespace "SCMLib.PObj.OrderPObj"; include standard_libs; error_occurred := false; error_msg := ""; //Error Destination Object 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 := 1004, Rule_subgroup := "", Send_with_order := "", Alert_dialog_settings := "", Display_alert := true ]; user_IDType := "Edstan Number (physician)"; user_IDCode := read last {"SELECT IDCode FROM CV3CAREPROVIDERID " || " where ProviderGUID = " || SQL(userGUID) || " and ProviderIDTypeCode = " || SQL(user_IDType) }; ;; priority: 50 ;; evoke: ;; logic: if called_by_editor then conclude false; endif; try ClientVisit_OBJ := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with (( visitGUID as number ) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}} ); RequestedBy_OBJ := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindById with ( user_IDType, (user_IDCode as STRING) ); endtry; catch exception ex error_occurred := true; error_msg := "{{+R}}Common Data:{{-R}}\n" || ex.Message || "\n\n"; if ( ClientVisit_OBJ IS NOT NULL ) then void := call ClientVisit_OBJ.Dispose; ClientVisit_OBJ := null; endif; if ( RequestedBy_OBJ IS NOT NULL ) then void := call RequestedBy_OBJ.Dispose; RequestedBy_OBJ := null; endif; endcatch; try RequestedBySource := "Per Hospital Policy"; OrderDiscontinueReason := orderDCReason; Order_OBJ := new net_object {{{SINGLE-QUOTE}}}SCMLib.PObj.OrderPObj{{{SINGLE-QUOTE}}} with orderGUID; Order_OBJ.SuppressSignOnSubmit := true; Order_OBJ.ToBeSigned := false; now_dtm := now + 1 minute; date_str := ( ( extract year now_dtm ) as string ) || "-" || (extract month now_dtm ) formatted with "%0.2d" || "-" || (extract day now_dtm ) formatted with "%0.2d"; time_str := ( extract hour now_dtm ) formatted with "%0.2d" || ":" || ( extract minute now_dtm ) formatted with "%0.2d" || ":" || ( extract second now_dtm ) formatted with "%0.2d"; careProviderGUID := ( RequestedBy_OBJ.PrimaryKey as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}} ) as string; dcOrder_OBJ := call Order_OBJ.Discontinue with OrderDiscontinueReason, date_str, time_str, RequestedBySource, careProviderGUID; endtry; catch exception ex error_occurred := true; error_msg := "{{+R}}Common Data:{{-R}}\n" || ex.Message || "\n\n"; endcatch; //Dispose if ( ClientVisit_OBJ IS NOT NULL ) then void := call ClientVisit_OBJ.Dispose; ClientVisit_OBJ := null; endif; if ( RequestedBy_OBJ IS NOT NULL ) then void := call RequestedBy_OBJ.Dispose; RequestedBy_OBJ := null; endif; Conclude true; ;; action: if error_occurred then write "An error has occured in the MLM {{+B}}SCH_FUNC_DISCONTINUE_ORDER{{-B}} " || "Please notify your System Administrators that an error message has occurred " || "message: \n" at error_destination; write error_msg at error_destination; endif; return error_occurred; ;; Urgency: 50;; end: