207 lines
7.5 KiB
Plaintext
207 lines
7.5 KiB
Plaintext
maintenance:
|
|
|
|
title: SCH_RISK_CATEGORY;;
|
|
mlmname: SCH_RISK_CATEGORY;;
|
|
arden: version 4.5;;
|
|
version: 2.00;;
|
|
institution: St.Clair Hospital;;
|
|
author: Janet Nordin;;
|
|
specialist: Don Warnick;;
|
|
date: 2017-10-17;;
|
|
validation: testing;;
|
|
|
|
library:
|
|
purpose:
|
|
;;
|
|
explanation:
|
|
Change history
|
|
|
|
10.17.2017 DW CSR# 36030 Elder Risk (renamed Risk Category then renamed Readmission Risk)
|
|
08.27.2018 DW CSR# 36721 Risk Score Enhancement - increase the score via the EPN
|
|
|
|
|
|
;;
|
|
keywords:
|
|
;;
|
|
knowledge:
|
|
type: data-driven;;
|
|
data:
|
|
|
|
standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
|
|
include standard_libs;
|
|
using "ObjectsPlusXA.SCM.Forms";
|
|
using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms";
|
|
|
|
|
|
// (clientVisitGUID, ChartGUID, clientGUID) := ARGUMENT;
|
|
|
|
|
|
Document_Enter := event {ClientDocumentEnter User ClientDocument: where documentname in ("Adult Patient Profile", "Adult Patient Profile - Observation" , "Discharge Instructions (Post Hospital Care Orders)" , "Readmission Risk Planning")
|
|
or documentname matches pattern "Physician Progress Note%"};
|
|
Document_Modify := event {ClientDocumentModify User ClientDocument: where documentname in ("Adult Patient Profile", "Adult Patient Profile - Observation" , "Discharge Instructions (Post Hospital Care Orders)" , "Readmission Risk Planning")
|
|
or documentname matches pattern "Physician Progress Note%"};
|
|
|
|
|
|
(clientVisitGUID, ChartGUID, clientGUID) := read last {ClientVisit: GUID, ChartGUID, ClientGUID};
|
|
|
|
|
|
discontinue_comment_guid := read last
|
|
{ " select GUID from CV3CommentDeclaration with (nolock)
|
|
where TypeCode = {{{SINGLE-QUOTE}}}Readmission Risk{{{SINGLE-QUOTE}}} and Status = {{{SINGLE-QUOTE}}}Active{{{SINGLE-QUOTE}}}
|
|
and ClientGUID = " || clientGUID || " and ChartGUID = " || ChartGUID || " and ClientVisitGUID = " || clientVisitGUID || " "
|
|
} ;
|
|
|
|
|
|
latest_risk_data := read last
|
|
{ " select top 1
|
|
o.valuetext
|
|
from CV3ClientDocumentCUR cd with (nolock)
|
|
join CV3ClientDocDetailCUR cdd with (nolock) on cdd.ClientDocumentGUID = cd.GUID and cdd.ClientGUID = cd.clientguid and cdd.Active = 1 and cdd.ArcType = cd.ArcType
|
|
join CV3ObservationDocumentCUR od with (nolock) on od.OwnerGUID = cdd.ClientDocumentGUID and od.ArcType = cdd.ArcType
|
|
join CV3ObservationCUR o with (nolock) on o.GUID = od.ObservationGUID and o.ArcType = od.ArcType
|
|
join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID
|
|
left join SCMObsFSListValues fsl with (nolock) on fsl.ParentGUID = od.ObservationDocumentGUID AND fsl.ClientGUID = " || clientGUID || "
|
|
where cd.ClientGUID = " || clientGUID || " and cd.ChartGUID = " || ChartGUID || " and cd.ClientVisitGUID = " || clientVisitGUID || "
|
|
and cd.IsCanceled = 0 and od.Active = 1 and o.ValueText is not null and ocmi.Name = {{{SINGLE-QUOTE}}}SCH_READMISSION RISK{{{SINGLE-QUOTE}}}
|
|
and (cd.DocumentName in ({{{SINGLE-QUOTE}}}Adult Patient Profile{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Adult Patient Profile - Observation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Discharge Instructions (Post Hospital Care Orders){{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Readmission Risk Planning{{{SINGLE-QUOTE}}}) or cd.DocumentName like {{{SINGLE-QUOTE}}}Physician Progress Note%{{{SINGLE-QUOTE}}})
|
|
order by cdd.Createdwhen desc "
|
|
} ;
|
|
|
|
// substring (o.valuetext, 0,charindex ({{{SINGLE-QUOTE}}}){{{SINGLE-QUOTE}}},o.valuetext)+1) (parsed out the score when evidence was being filed during validation)
|
|
|
|
// DESTINATIONS
|
|
|
|
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 ];
|
|
|
|
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 := 1003,
|
|
Rule_subgroup := "",
|
|
Send_with_order := "",
|
|
Alert_dialog_settings := "",
|
|
Display_alert := true ];
|
|
|
|
|
|
|
|
If exists latest_risk_data
|
|
|
|
then
|
|
|
|
If exists discontinue_comment_guid
|
|
|
|
then // Delete the Comment (CSR# 32675 first delete any prior comment as one is now created at time of admission)
|
|
|
|
try
|
|
Discontinue_Comment_obj := call {{{SINGLE-QUOTE}}}PatientComment{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ( (discontinue_Comment_GUID 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;
|
|
|
|
|
|
// Create the Comment
|
|
|
|
try
|
|
client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((ClientVisitGUID as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ;
|
|
New_Comment_obj := call {{{SINGLE-QUOTE}}}PatientComment{{{SINGLE-QUOTE}}}.CreatePatientComment with client_visit_obj,"Readmission Risk";
|
|
|
|
New_Comment_obj.Text := latest_risk_data;
|
|
NewComment_dest.ObjectsPlus := New_Comment_obj;
|
|
|
|
if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif;
|
|
|
|
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;
|
|
|
|
if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif;
|
|
|
|
|
|
endcatch;
|
|
|
|
|
|
endif;
|
|
|
|
|
|
;;
|
|
evoke:
|
|
|
|
0 seconds after time of Document_Enter;
|
|
0 seconds after time of Document_Modify;
|
|
|
|
;;
|
|
|
|
logic: conclude true;
|
|
|
|
;;
|
|
action:
|
|
|
|
|
|
if Error_occurred
|
|
then
|
|
|
|
write "An error has occured in the MLM {{+B}}SCH_ORDER_REC_SAVED_INCOMPLETE_CREATE_COMMENT{{-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 NewComment_dest then
|
|
write true at NewComment_dest;
|
|
endif;
|
|
|
|
if EXISTS DiscontinueComment_dest then
|
|
write true at DiscontinueComment_dest ;
|
|
endif;
|
|
|
|
|
|
|
|
|
|
;;
|
|
Urgency: 50;;
|
|
end:
|