maintenance: title: SCH_Readmission_Risk_Comment;; mlmname: SCH_Readmission_Risk_Comment;; arden: version 2.5;; version: 5.50;; institution: SCH ;; author: Chintan Tilwa;; specialist: ;; date: 2012-10-26;; validation: testing;; library: purpose: ;; explanation: ;; keywords: ObjectsPlus, Orders ;; knowledge: type: data-driven;; data: standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; include standard_libs; local_session := CDS_SESSION.local; log_execution_info := false; error_occurred := false; error_message := ""; //Order_Enter := event { OrderEnter User Order: where Name = "Readmission Risk" }; Order_Discontinue := event { OrderDiscontinue User Order: where Name = "Readmission Risk" }; Document_Enter := event {ClientDocumentEnter User ClientDocument: where documentname in ("Readmission Risk Assessment","Adult Patient Profile","Adult Patient Profile - Observation")}; Document_Modify := event {ClientDocumentModify User ClientDocument: where documentname in ("Readmission Risk Assessment","Adult Patient Profile","Adult Patient Profile - Observation") AND IsCanceled = FALSE }; Client_GUID := EvokingObject.ClientGUID; Visit_GUID := EvokingObject.ClientVisitGUID; cmntDeclGUID := Read Last { "SELECT GUID from CV3CommentDeclaration (NoLock) WHERE ClientGUID = " || sql(Client_GUID) || " AND ClientVisitGUID = " || sql(Visit_GUID) || " AND Active = 1 AND Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}} AND TypeCode = {{{SINGLE-QUOTE}}}Readmit Score{{{SINGLE-QUOTE}}} " }; NewComment_dest := destination { ObjectsPlus } with [ alert_type := "Warning", short_message := "Object created by MLM", priority := "low", scope := "chart", rule_group := "Comment Object", rule_number := 2010 ]; DiscontinueComment_dest := destination { ObjectsPlus } with [ alert_type := "Warning", short_message := "Object discontinued by MLM", priority := "low", scope := "chart", rule_group := "Comment Object", rule_number := 2030 ]; ///destination_variable := Destination {XAObject: CommentDeclaration}; //Comment_Declaration := destination_variable.comment; //Comment_Declaration.typecode := "Readmit Score"; //Comment_Declaration.text := local_session.SessionReadmissionScore ; try //get the .NET version of the Client Visit object. Needed to create new //ObjectsPlus objects client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((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; // If the client object cannot be retrieved, do not attempt // to create any ObjectsPlus objects. //conclude true; endcatch; if ( EvokingEventType in ("ClientDocumentEnter","ClientDocumentModify") ) then if ( local_session.SessionReadmissionScore >= 5 ) then if exists cmntDeclGUID then //Comment_Declaration.updatetype := "Modify"; //Comment_Declaration.guid := cmntDeclGUID; try Discontinue_Comment_obj := call {{{SINGLE-QUOTE}}}PatientComment{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ( (cmntDeclGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}} ); empty := call Discontinue_Comment_obj.Discontinue; DiscontinueComment_dest.ObjectsPlus := Discontinue_Comment_obj; endtry; catch exception ex error_occurred := true; error_message := error_message || "{{+R}}Discontinue Comment:{{-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 ( Discontinue_Comment_obj is NOT NULL ) then void:= call Discontinue_Comment_obj.Dispose; Discontinue_Comment_obj:= null; endif; DiscontinueComment_dest := null; endcatch; try // The comment type that will be created newCommentTypeCode := "Readmit Score"; // Create an instance of Patient Comment New_Comment_obj := call {{{SINGLE-QUOTE}}}PatientComment{{{SINGLE-QUOTE}}}.CreatePatientComment with (client_visit_obj, //ClientVisit newCommentTypeCode); //TypeCode // Populate the text New_Comment_obj.Text := local_session.SessionReadmissionScore ; // Set the destination ObjectsPlus NewComment_dest.ObjectsPlus := New_Comment_obj; endtry; catch exception ex error_occurred := true; error_message := "{{+R}}New Comment:{{-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 ( New_Comment_obj is NOT NULL ) then void:= call New_Comment_obj.Dispose; New_Comment_obj:= null; endif; NewComment_dest := null; endcatch; else try // The comment type that will be created newCommentTypeCode := "Readmit Score"; // Create an instance of Patient Comment New_Comment_obj := call {{{SINGLE-QUOTE}}}PatientComment{{{SINGLE-QUOTE}}}.CreatePatientComment with (client_visit_obj, //ClientVisit newCommentTypeCode); //TypeCode // Populate the text New_Comment_obj.Text := local_session.SessionReadmissionScore ; // Set the destination ObjectsPlus NewComment_dest.ObjectsPlus := New_Comment_obj; endtry; catch exception ex error_occurred := true; error_message := "{{+R}}New Comment:{{-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 ( New_Comment_obj is NOT NULL ) then void:= call New_Comment_obj.Dispose; New_Comment_obj:= null; endif; NewComment_dest := null; endcatch; endif; else /*if ( Comment_Declaration.updatetype = "NewIgnore" and Comment_Declaration.text < 5 ) then Comment_Declaration.updatetype := "Delete"; Comment_Declaration.guid := cmntDeclGUID; else*/ //Comment_Declaration.updatetype := "Delete"; //Comment_Declaration.guid := cmntDeclGUID; //endif; try Discontinue_Comment_obj := call {{{SINGLE-QUOTE}}}PatientComment{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ( (cmntDeclGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}} ); empty := call Discontinue_Comment_obj.Discontinue; DiscontinueComment_dest.ObjectsPlus := Discontinue_Comment_obj; endtry; catch exception ex error_occurred := true; error_message := error_message || "{{+R}}Discontinue Comment:{{-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 ( Discontinue_Comment_obj is NOT NULL ) then void:= call Discontinue_Comment_obj.Dispose; Discontinue_Comment_obj:= null; endif; DiscontinueComment_dest := null; endcatch; endif; else //Comment_Declaration.updatetype := "Delete"; //Comment_Declaration.guid := cmntDeclGUID; try Discontinue_Comment_obj := call {{{SINGLE-QUOTE}}}PatientComment{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ( (cmntDeclGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}} ); empty := call Discontinue_Comment_obj.Discontinue; DiscontinueComment_dest.ObjectsPlus := Discontinue_Comment_obj; endtry; catch exception ex error_occurred := true; error_message := error_message || "{{+R}}Discontinue Comment:{{-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 ( Discontinue_Comment_obj is NOT NULL ) then void:= call Discontinue_Comment_obj.Dispose; Discontinue_Comment_obj:= null; endif; DiscontinueComment_dest := null; endcatch; local_session.SessionReadmissionScore := "" ; endif; ;; priority: 90 ;; evoke: //Order_Enter ; Order_Discontinue ; Document_Enter ; Document_Modify ; ;; logic: conclude true; ;; action: //write true at destination_variable; if EXISTS NewComment_dest then write true at NewComment_dest; endif; if EXISTS DiscontinueComment_dest then write true at DiscontinueComment_dest; endif; ;; Urgency: 50;; end: