maintenance: title: SCH_Create_Request_Bed_Order ;; mlmname: SCH_Create_Request_Bed_Order ;; arden: version 2.5;; version: 5.50;; // FP1 institution: SCH ;; author: Shivprasad Jadhav ;; specialist: ;; date: 2014-03-13;; validation: testing;; library: purpose: Creates and saves prefilled and standard orders using ObjectsPlus. Each order will be saved directly to the database once the order on the worksheet is saved. ;; explanation: This orders created by this MLM will by-pass the order entry worksheet and will write directly to the database once the evoking object is saved. ;; keywords: ObjectsPlus, Orders ;; knowledge: type: data-driven;; data: // Specify which .NET assemblies need to be loaded for ObjectsPlus standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; include standard_libs; error_occurred := false; error_message := ""; //------------------------------------------------------------------------------- // References the LOCAL SESSION object local_session := cds_session.local; // for local_session.SessionRequestBed //------------------------------------------------------------------------------- log_execution_info := false; Order_Submit := event {OrderWorksheetSubmit User } ; //Order : WHERE Name Matches pattern "Place in Observation%" } ;//Order: where Name in ("Place in Observation")}; onames := read { UNSUBMITTED ORDER: Name}; //Document_Modify := event {ClientDocumentModify User ClientDocument: where documentname in ("Pediatric Patient Profile")}; ( careProvider_obj ) := read last{ UserInfo: careProvider }; ( careProvider_Actaul ) := read last{ UserInfo: This }; /*user_IDType := "Primary"; CareProviderIDs_obj := read last { CareProvider: CareProviderID REFERENCING careProvider_obj }; user_IDCode := read last { CareProviderID: IDCode REFERENCING CareProviderIDs_obj where ProviderIDTypeCode = user_IDType }; */ (location_guid, Active_ClientVisitGUID, client_guid) := read last { ClientVisit: CurrentLocationGUID, GUID, clientguid }; Care_Provider := local_session.SessionRequestedGUID; // careprovider_obj.GUID ; //EVOKINGOBJECT.AuthoredProviderGUID; visitGuid := EVOKINGOBJECT.GUID ; (LocationLevelCode) := read last { "select Top 1 case when cc.typecode = {{{SINGLE-QUOTE}}}unit{{{SINGLE-QUOTE}}} then cc.levelcode when b.typecode={{{SINGLE-QUOTE}}}unit{{{SINGLE-QUOTE}}} then b.levelcode when a.typecode={{{SINGLE-QUOTE}}}unit{{{SINGLE-QUOTE}}} then a.levelcode " || " when cv3l.typecode={{{SINGLE-QUOTE}}}unit{{{SINGLE-QUOTE}}} then cv3l.levelcode else null end as Unit From CV3ClientVisit CV With (nolock) " || " Inner Join Cv3Location L With (nolock) On L.Guid=CV.CurrentLocationGUID AND CV.Active=1 AND CV.VisitStatus={{{SINGLE-QUOTE}}}ADM{{{SINGLE-QUOTE}}} " || " Left Join Cv3ClientVisitLocation CVL With (nolock) ON CVL.ClientVisitGUID=CV.GUID Left Join CV3Location CV3L On CV3L.GUID=CVL.LocationGUID " || " Left Join CV3Location a With (nolock) on CV3L.parentguid= a.guid Left Join CV3Location b With (nolock) on a.parentguid = b.guid " || " left join cv3location cc With (nolock) on b.parentguid = cc.guid " || " WHERE CVL.Status={{{SINGLE-QUOTE}}}CUR{{{SINGLE-QUOTE}}} and CV.GUID = " || visitGuid || " " }; //If (EVOKINGOBJECT.TypeCode = "EMERGENCY" or EVOKINGOBJECT.TypeCode = "Observation" ) Then If LocationLevelCode In ("5","6","ER") Then If ( "Place in Observation" In onames ) or ( "Admit to Inpatient" In onames ) Then (Typecode, Username ) := Read first {" Select Typecode, DisplayName from CV3CareProvider With (nolock) Where GUID = " || Care_Provider || " "} ; location_guid := Read First {" Select CurrentLocationGUID from CV3ClientVisit With (nolock) Where GUID = " || visitGuid || " "} ; If Typecode is Not in ("PA","CRNP") Then CareProvider_GUID := Care_Provider ; Else CareProvider_GUID := Read First {" Select GUID from CV3CareProvider With (nolock) Where DisplayName = {{{SINGLE-QUOTE}}}Biggs, Jason {{{SINGLE-QUOTE}}} "} ; Endif; DiagnosticOrder_dest := destination { ObjectsPlus } with [ alert_type := "Warning", short_message := "Object created by MLM", priority := "low", scope := "chart", rule_group := "Order Object", rule_number := 2010 ]; order_Creation_Reason := "Created by MLM"; 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_alert_with_order := "", Alert_dialog_settings := "", Display_alert := true ]; IF(visitGuid IS NOT NULL) THEN try client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; WSSessionType := "Standard";//"Inpatient Orders";//Standard";//" WSSessionReason := ""; WSRequestedBySource := "";//"1 Standard"; WSRequestedBy_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ( ( CareProvider_GUID as number ) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}} ); WSlocation_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((location_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}); endtry; catch Exception ex error_occurred := true; error_message := "{{+R}}Common Data:{{-R}}\n" || ex.Message || "\n\n"; if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif; if ( WSRequestedBy_obj is NOT NULL ) then void:= call WSRequestedBy_obj.Dispose; WSRequestedBy_obj:= null; endif; if ( WSlocation_obj is NOT NULL ) then void:= call WSlocation_obj.Dispose; WSlocation_obj:= null; endif; endcatch; ENDIF; if (client_visit_obj is not null) then try Catalog_Item_Name := "Request Bed"; order_Creation_Reason := "Order Created From MLM"; // get OrderCatalogMasterItem ObjectsPlus object diagnostic_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name; DiagnosticOrder_obj := call {{{SINGLE-QUOTE}}}DiagnosticOrder{{{SINGLE-QUOTE}}}.CreateDiagnosticOrder with client_visit_obj, // ClientVisit ObjectsPlus object diagnostic_catalog_item, // OrderCatalogMasterItem ObjectsPlus object order_Creation_Reason, // CreateReason wsRequestedBy_obj, // RequestedBy ObjectsPlus object wsRequestedBySource, // string RequestedBySource (must be in dictionary) wsSessionType, // string SessionType wsSessionReason, // string SessionReason wslocation_obj, // Location ReleaseLocGrpID "Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; // AvailabilityOverride DiagnosticOrder_obj.SpecialInstructions := local_session.SessionRequestBed ; //"ABCD" ; //StrFinal ; //"Instruction text from MLM"; local_session.SessionRequestBed := Null ; //void := DiagnosticOrder_obj.save; DiagnosticOrder_dest.ObjectsPlus := DiagnosticOrder_obj; void := call DiagnosticOrder_obj.save; ///To Save The Order To SCM endtry; catch Exception ex error_occurred := true; error_message := error_message || "{{+R}}New general order:{{-R}}\n" || ex.Message || "\n\n"; if ( Catalog_Item_Name is NOT NULL ) then void:= call Catalog_Item_Name.Dispose; Catalog_Item_Name:= null; endif; if ( DiagnosticOrder_obj is NOT NULL ) then void:= call DiagnosticOrder_obj.Dispose; DiagnosticOrder_obj:= null; endif; endcatch; ENDIF; Endif; //Else //dialogResult := call {{{SINGLE-QUOTE}}}MessageBox{{{SINGLE-QUOTE}}}.Show with " We Cannot Place the {{{SINGLE-QUOTE}}}Request Bed{{{SINGLE-QUOTE}}} order in "|| EVOKINGOBJECT.TypeCode || " Visit type ", "Important Alert","OK" as {{{SINGLE-QUOTE}}}MessageBoxButtons{{{SINGLE-QUOTE}}}; Endif; ;; priority: 50 ;; evoke: Order_Submit; //Document_Modify; ;; logic: if EvokingObject is null then conclude false; endif; conclude true; ;; action: ;; Urgency: 50;; end: