maintenance: title: SCH_Readmission_Pulmonary_Order;; mlmname: SCH_Readmission_Pulmonary_Order;; arden: version 2.5;; version: 5.50;; // FP1 institution: SCH ;; author: Chintan Tilwa;; specialist: ;; date: 2012-10-23;; 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; local_session := CDS_SESSION.local; error_occurred := false; error_message := ""; log_execution_info := false; Document_Enter := event {ClientDocumentEnter User ClientDocument: where documentname = "Adult Patient Profile"}; Document_Modify := event {ClientDocumentModify User ClientDocument: where documentname = "Adult Patient Profile"}; HI_mod_mlm := MLM {{{SINGLE-QUOTE}}}SCH_Create_General_Order{{{SINGLE-QUOTE}}}; ( careProvider_obj ) := read last{ UserInfo: careProvider }; 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 }; Active_ClientVisitGUID := EvokingObject.ClientVisitGUID; Care_Provider := EVOKINGOBJECT.AuthoredProviderGUID; try client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((Active_ClientVisitGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ; WSSessionType := "Standard"; WSSessionReason := ""; WSRequestedBySource := ""; WSRequestedBy_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((Care_Provider 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; order_Creation_Reason := "From Test MLM" ; WSRequestedBySource := ""; /* Get the ClientObservationDocument object pointer */ (Client_Observation_Document_Obj, GUID):= read last { ClientDocument: ClientObservationDocument, GUID REFERENCING EvokingObject }; (ObsFSListValues_Obj, oName) := read Last { ClientObservationDocument: ObsFSListValues, Name REFERENCING Client_Observation_Document_Obj where Name = "SCH_CK_Smoking Risk" }; (val1) := read { ObsFSListValues: Value Referencing ObsFSListValues_Obj }; for i in 1 seqto count of val1 do If ( val1[i] <> "No Smoking Risk" ) then local_session.SessionReadmissionOrder := val1[i] ; order_Name := "Pulmonary Health Education Consult" ; /*(dup_order_list) := read last { " select name " ||" from cv3order " ||" where ClientGUID = " || sql(client_guid) ||" and ClientVisitGUID = " || sql(Active_ClientVisitGUID) ||" and name = {{{SINGLE-QUOTE}}}" || order_Name || "{{{SINGLE-QUOTE}}}" ||" and orderstatuslevelnum < 55 " ||" and OrderStatusCode = {{{SINGLE-QUOTE}}}AUA1{{{SINGLE-QUOTE}}} " ||" and active = 1 " };*/ endif; enddo; //if not exists dup_order_list then try Catalog_Item_Name := order_Name ; order_type := "other"; order_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name; Obj_Error_occurred, Obj_error_message := call HI_mod_mlm with order_type, client_visit_obj, // ClientVisit ObjectsPlus object Order_catalog_item, // CatalogMasterItem ObjectsPlus object order_Creation_Reason, // string CreateReason WSRequestedBy_obj, // RequestingProvider ObjectsPlus object WSRequestedBySource, // string requestingSource(must be in dict) WSSessionType, // string SessionType WSSessionReason, // string SessionReason WSLocation_obj; endtry; catch Exception ex error_occurred := true; error_message := "{{+R}}New General order:{{-R}}\n" || ex.Message || "\n\n"; endcatch; if ( Order_catalog_item is NOT NULL ) then void:= call Order_catalog_item.Dispose; Order_catalog_item:= null; endif; //endif; //endif; //enddo; ;; priority: 50 ;; evoke: Document_Enter; Document_Modify; ;; logic: if EvokingObject is null then conclude false; endif; conclude true; ;; action: ;; Urgency: 50;; end: