Initial Checking with all 820 MLMs

This commit is contained in:
2020-02-02 00:54:01 -05:00
parent c59dc6de2e
commit 840d0432f4
828 changed files with 239162 additions and 0 deletions

View File

@@ -0,0 +1,352 @@
maintenance:
title: DOC_FUNC_EPN_ALERTS;;
mlmname: DOC_FUNC_EPN_ALERTS;;
arden: version 4.5;;
version: 2.00;;
institution: St.Clair Hospital;;
author: Don Warnick;;
specialist: Don Warnick ;;
date: 2010-02-02;;
validation: testing;;
library:
purpose:
;;
explanation:
Change history
10.20.2014 DW CSR# 32746 - (Alert for missing VTE order) & 32675 (Altert for incomplete or missing Admission ORM)
10.23.2015 DW CSR# 32874 - Alert the Pulumonary Specialists when an ICU patient has an active Ventilator order, but does not have and active Chest Medical Imaging order.
12.16.2015 DW CSR# 33655 - Previnar
02.09.2016 DW CSR# 33949 - Add Code Status and CPR order review
10.05.2017 JML CSR# 26413 - Modified for Code Status changes based on DOH
11.03.2017 JML CSR# 26413 - Eliminating Outpatients and Discharged patients from receiving code status alert
09.28.2018 DW CSR# 36715 - Created - PDMP in order session
;;
keywords:
;;
knowledge:
type: data-driven;;
data:
// Recieve arguments from the structured note
(thisDocumentCommunication) := argument;
// Extract interesting parts of the object model
(thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj;
(thisParameters) := thisStructuredNoteDoc.ParametersList;
(thisObservations) := thisStructuredNoteDoc.ChartedObservationsList;
// Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate
ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj];
FreeTextValueType := OBJECT [Value];
// Get the client and visit GUIDs
clientGuid := thisDocumentCommunication.ClientGUID;
visitGuid := thisDocumentCommunication.ClientVisitGUID;
chartGuid := thisDocumentCommunication.ChartGUID;
userGuid := thisDocumentCommunication.UserGUID;
standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
include standard_libs;
using "ObjectsPlusXA.SCM.Forms";
using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms";
using "CustomCodeStatusAlert";
using namespace "CustomCodeStatusAlert";
(OccCode, RoleType) := read last {" select OccupationCode, OrderRoleType from CV3USER with (nolock) where guid = " || sql(userGuid) };
//Get Visit Status
( visitStatus,
visitType) := read last { "SELECT cv.VisitStatus, cv.TypeCode FROM CV3ClientVisit cv WHERE cv.GUID = " || SQL(visitGuid) };
// Code Status Order Section
(CodeStatusOrder,
CodeStatusType) := read {"SELECT ocmi.Name, CASE WHEN ocmi.Name IN ({{{SINGLE-QUOTE}}}Code Status: Comfort Measures Only{{{SINGLE-QUOTE}}},"
|| " {{{SINGLE-QUOTE}}}Code Status: Limited Interventions{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Code Status: Full Treatment{{{SINGLE-QUOTE}}}) THEN {{{SINGLE-QUOTE}}}CODE STATUS{{{SINGLE-QUOTE}}}"
|| " WHEN ocmi.Name = {{{SINGLE-QUOTE}}}Code Status: Ethically unable to determine{{{SINGLE-QUOTE}}} THEN {{{SINGLE-QUOTE}}}CODE STATUS ND{{{SINGLE-QUOTE}}}"
|| " WHEN ocmi.Name IN ({{{SINGLE-QUOTE}}}CPR/Attempt Resuscitation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}DNR/Do Not Attempt Resuscitation{{{SINGLE-QUOTE}}}) THEN {{{SINGLE-QUOTE}}}CPR{{{SINGLE-QUOTE}}}"
|| " ELSE {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}"
|| " END"
|| " FROM CV3OrderCatalogMasterItem ocmi with (nolock) JOIN CV3Order o with (nolock)"
|| " ON o.OrderCatalogMasterItemGUID = ocmi.GUID"
|| " AND o.ClientGUID = " || SQL(ClientGuid)
|| " AND o.ClientVisitGUID = " || SQL(VisitGuid)
|| " AND o.ChartGUID = " || SQL(ChartGuid)
|| " WHERE ( ocmi.Name IN ({{{SINGLE-QUOTE}}}CPR/Attempt Resuscitation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}DNR/Do Not Attempt Resuscitation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Code Status: Comfort Measures Only{{{SINGLE-QUOTE}}},"
|| " {{{SINGLE-QUOTE}}}Code Status: Limited Interventions{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Code Status: Full Treatment{{{SINGLE-QUOTE}}})"
|| " OR ocmi.Name = {{{SINGLE-QUOTE}}}Code Status: Ethically unable to determine{{{SINGLE-QUOTE}}} )"
|| " AND o.OrderStatusLevelNum >= 15 "
|| " AND o.OrderStatusLevelNum not in (69, 70) "};
// DOCUMENT OPEN
if thisdocumentCommunication.EventType = "DocumentOpening" then
// Admission ORM Section
(AdmORMStatus) := read last
{
" select "
|| " (SELECT enumrefvalue FROM SCH_EnumRef_LookUp_FN({{{SINGLE-QUOTE}}}CV3ORDERRECONCILE{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}reconcilestatustype{{{SINGLE-QUOTE}}},reconcilestatustype)) as {{{SINGLE-QUOTE}}}reconcile_status{{{SINGLE-QUOTE}}} "
|| " from CV3ORDERRECONCILE with (nolock) "
|| " where chartguid = " || ChartGuid || " and clientguid = " || ClientGuid || " and clientvisitguid = " || VisitGuid || " and ReconcileTypeCode = {{{SINGLE-QUOTE}}}admission{{{SINGLE-QUOTE}}}"
};
/*
(CPROrder) := read last
{
" select ocmi.Name "
|| " from cv3ordercatalogmasteritem as ocmi with (nolock) "
|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid "
|| " and o.chartguid = " || ChartGuid || " and o.clientguid = " || ClientGuid || " and o.clientvisitguid = " || VisitGuid || " "
|| " and o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) "
|| " where (ocmi.name like {{{SINGLE-QUOTE}}}CPR%{{{SINGLE-QUOTE}}} or ocmi.name like {{{SINGLE-QUOTE}}}DNR%{{{SINGLE-QUOTE}}} ) "
};
*/
// Ventilator Order Section
(VentilatorOrder) := read last
{
" select ocmi.Name "
|| " from cv3ordercatalogmasteritem as ocmi with (nolock) "
|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid "
|| " and o.chartguid = " || ChartGuid || " and o.clientguid = " || ClientGuid || " and o.clientvisitguid = " || VisitGuid || " "
|| " and o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) "
|| " where ocmi.name = {{{SINGLE-QUOTE}}}ventilator{{{SINGLE-QUOTE}}} "
};
(ChestOrder) := read last
{
" select ocmi.Name "
|| " from cv3ordercatalogmasteritem as ocmi with (nolock) "
|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid "
|| " and o.chartguid = " || ChartGuid || " and o.clientguid = " || ClientGuid || " and o.clientvisitguid = " || VisitGuid || " "
|| " and o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) "
|| " and o.RepeatOrder <> 1 "
|| " where ocmi.name = {{{SINGLE-QUOTE}}}Chest Portable{{{SINGLE-QUOTE}}}"
};
CurrentLocation := read last {"Select CurrentLocation FROM CV3ClientVisit with (nolock) where currentlocation like {{{SINGLE-QUOTE}}}icu%{{{SINGLE-QUOTE}}} and ClientGUID = " || thisdocumentCommunication.ClientGUID};
Specialty := read last {"Select Discipline from CV3CareProvider with (nolock) where TypeCode = {{{SINGLE-QUOTE}}}physician{{{SINGLE-QUOTE}}} and discipline like {{{SINGLE-QUOTE}}}%pulmonary%{{{SINGLE-QUOTE}}} and guid = " || thisDocumentCommunication.UserGUID};
// PDMP Search Section
PatientAge := read last
{"
select case when
right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (datepart (MM,getdate()) as varchar),2) + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (datepart (DD,getdate()) as varchar),2) <
right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (birthmonthnum as varchar),2) + right({{{SINGLE-QUOTE}}}00{{{SINGLE-QUOTE}}} + cast (birthdaynum as varchar),2)
then datediff (yy, cast (birthyearnum as varchar) ,getdate()) -1
else datediff (yy, cast (birthyearnum as varchar) ,getdate())
end
from cv3client with (nolock) where guid = " || clientGuid || "
"};
If patientage > 0
then
Opiods_BenzosFound := " ";
SignificantEvent := read last
{"
select c.text
from CV3ClientEventDeclaration c with (nolock)
where c.TypeCode = {{{SINGLE-QUOTE}}}PDMP{{{SINGLE-QUOTE}}} and c.status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}} and c.text like {{{SINGLE-QUOTE}}}%:%{{{SINGLE-QUOTE}}}
and c.ClientGUID = " || ClientGuid || " and c.clientvisitguid = " || VisitGuid || " and c.chartguid = " || ChartGuid || "
order by c.CreatedWhen
"};
if not exist SignificantEvent
then
(Opiods_Benzos) := read
{ "
select distinct gn.DrugCatalogKey
from SXAAMBDrugName bn with (nolock)
join SXAAMBGenericNameDrugNameXRef dnx with (nolock) on dnx.DrugNameID = bn.DrugNameID
join SXARxGenericName gn with (nolock) on gn.GenericNameID = dnx.GenericNameID
join SXAAMBDrugCategoryXRef xr with (nolock) on gn.GenericNameID = xr.GenericNameID
join SXAAMBDrugCategory dc with (nolock) on xr.DrugCategoryID = dc.DrugCategoryID
where dc.CategoryName in ({{{SINGLE-QUOTE}}}Benzodiazepines{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}narcotic analgesics{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}narcotic analgesic combinations{{{SINGLE-QUOTE}}})
"};
(PatientMedDrugID, PatientMedName, PatientMedOrderInfo ) := read
{ "
SET CONCAT_NULL_YIELDS_NULL off
select dm.DrugKey, ocmi.Name, convert(char(11),o.Entered,101) + convert(char(5),o.Entered,108) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + substring (u.FirstName,1,1) + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + u.lastname + {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}} + u.OccupationCode
from cv3ordercatalogmasteritem ocmi with (nolock)
join cv3order o with (nolock) on o.OrderCatalogMasterItemGUID = ocmi.guid
JOIN CV3DrugMapping dm with (nolock) on dm.CatalogItemGUID = ocmi.GUID
join CV3OrganizationalUnit ou with (nolock) on ou.GUID = ocmi.OrgUnitGUID
left join cv3user u with (nolock) on u.guid = o.userguid
join CV3OrganizationalUnit uou with (nolock) on uou.guid = u.OrgUnitGUID
where
ou.name ={{{SINGLE-QUOTE}}}Pharmacy Department{{{SINGLE-QUOTE}}} and o.OrderStatusLevelNum > 15 and o.OrderStatusLevelNum not in ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}}) and
u.OrderRoleType <> {{{SINGLE-QUOTE}}}anesthesia physician{{{SINGLE-QUOTE}}} and uou.Description <> {{{SINGLE-QUOTE}}}Emergency Department{{{SINGLE-QUOTE}}} and
o.clientguid = " || ClientGuid || " and o.ChartGUID = " || ChartGuid || " and o.ClientVisitGUID = " || visitGuid || "
"};
// Check for Opiod/Benzo Medications
Opiods_BenzosFound:= "";
for x in 1 seqto count (PatientMedDrugID) do
if (PatientMedDrugID[x] is in Opiods_Benzos)
then Opiods_BenzosFound := Opiods_BenzosFound || "\n - PDMP Search Required for - " || PatientMedName [x] || " " || PatientMedOrderInfo [x] ;
endif;
enddo;
endif; // significant event found ?
endif; // patient age > 0 ?
// VTE Order Section
(VTERelatedOrders) := read
{
" select ocmi.Name "
|| " from cv3ordercatalogmasteritem as ocmi with (nolock) "
|| " join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid "
|| " and o.chartguid = " || ChartGuid || " and o.clientguid = " || ClientGuid || " and o.clientvisitguid = " || VisitGuid || " "
|| " and o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) "
|| " where ( "
|| " ocmi.name = {{{SINGLE-QUOTE}}}VTE Drug Therapy Evaluation{{{SINGLE-QUOTE}}} or "
|| " (ocmi.name like {{{SINGLE-QUOTE}}}%Heparin%{{{SINGLE-QUOTE}}} and o.typecode = {{{SINGLE-QUOTE}}}medication{{{SINGLE-QUOTE}}} and ocmi.name not like {{{SINGLE-QUOTE}}}%flush%{{{SINGLE-QUOTE}}} and ocmi.name not like {{{SINGLE-QUOTE}}}%lock%{{{SINGLE-QUOTE}}}) "
|| " or ocmi.name like {{{SINGLE-QUOTE}}}%Enoxaparin%{{{SINGLE-QUOTE}}} or ocmi.name like {{{SINGLE-QUOTE}}}%Fondaparinux%{{{SINGLE-QUOTE}}} or ocmi.name like {{{SINGLE-QUOTE}}}%Argatroban%{{{SINGLE-QUOTE}}} or ocmi.name like {{{SINGLE-QUOTE}}}%Dabigatran%{{{SINGLE-QUOTE}}} "
|| " or ocmi.name like {{{SINGLE-QUOTE}}}%Apixaban%{{{SINGLE-QUOTE}}} or ocmi.name like {{{SINGLE-QUOTE}}}%Rivaroxaban%{{{SINGLE-QUOTE}}} or ocmi.name like {{{SINGLE-QUOTE}}}%Warfarin%{{{SINGLE-QUOTE}}} "
|| " or (ocmi.name like {{{SINGLE-QUOTE}}}Aspirin%{{{SINGLE-QUOTE}}} and ocmi.name not like {{{SINGLE-QUOTE}}}%dipyridamole%{{{SINGLE-QUOTE}}}) "
|| " ) "
|| " and ocmi.name not like {{{SINGLE-QUOTE}}}zz%{{{SINGLE-QUOTE}}} "
|| " and ocmi.name <> {{{SINGLE-QUOTE}}}No Warfarin{{{SINGLE-QUOTE}}} "
};
VTEEvaluationOrder := "No";
VTEPreventativeOrder := "No";
indexList := 1 seqto count (VTERelatedOrders);
for i in indexList do
obsName := last (first i from VTERelatedOrders);
if obsName = "VTE Drug Therapy Evaluation" then VTEEvaluationOrder := "Yes"; endif; // VTE order was found
if obsName <> "VTE Drug Therapy Evaluation" then
// If it is an Asprin order, a Knee or Hip OS order needs to be on file to qualify
if obsName matches pattern "%Aspirin%" then
(KneeOrHipOrders) := read
{
" select top 1 o.OrderSetName "
|| " from cv3order as o with (nolock) "
|| " where o.chartguid = " || ChartGuid || " and o.clientguid = " || ClientGuid || " and o.clientvisitguid = " || VisitGuid || " "
|| " and o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) "
|| " and (o.OrderSetName like {{{SINGLE-QUOTE}}}%knee%{{{SINGLE-QUOTE}}} or o.OrderSetName like {{{SINGLE-QUOTE}}}%hip%{{{SINGLE-QUOTE}}}) "
};
If exists KneeOrHipOrders then
VTEPreventativeOrder := "Yes";
endif;
else
VTEPreventativeOrder := "Yes"; // A Non-Aspirin Medication order
endif;
endif;
enddo;
// Message Assesment Section
//formattedTextAll:= " ** Important Reminders (VIEW ONLY) ** ";
//formattedTextAll:= " ";
If AdmORMStatus = "incomplete" then AdmORMStatusMessage := " - Admission ORM Incomplete";
elseif not exists AdmORMStatus then AdmORMStatusMessage := " - Admission ORM NOT Initiated";
else AdmORMStatusMessage := "";
endif;
// If not exists CodeStatusOrder then CodeStatusMessage := "\n\n - Code Status - CPR Review Required"; else CodeStatusMessage := ""; endif;
// If not exists CPROrder then CPRMessage := " CPR Review Required"; else CPRMessage := ""; endif;
If VTEEvaluationOrder = "No" and VTEPreventativeOrder = "No" then VTEStatusMessage := "\n - VTE Review Required";
else VTEStatusMessage := ""; endif;
If exists Specialty and exist VentilatorOrder and not exists ChestOrder and exists CurrentLocation then
VentilatorMessage := "\n - The order for a Chest Portable-Daily has expired.";
else
VentilatorMessage := "";
endif;
// No Messages found message
If AdmORMStatusMessage = "" and VTEStatusMessage = "" and VentilatorMessage = "" then
NoErrorMessage := "\n - There are no messages for the patient.";
// then NoErrorMessage := "\n\n ";
else
NoErrorMessage := "";
endif;
//formattedTextAll:= AdmORMStatusMessage || CodeStatusMessage || VTEStatusMessage || VentilatorMessage || NoErrorMessage;
formattedTextAll:= AdmORMStatusMessage || VTEStatusMessage || VentilatorMessage || NoErrorMessage || Opiods_BenzosFound;
endif; // Document Open
// Write to the Structured Note Text Box
If formattedTextAll is not null then
vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Reminder");
newObservation := NEW ObservationType;
newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID;
newObservation.ParameterGUID := vitalSignsHL.ParameterGUID;
newObservation.DataType := "FreeTextValue";
newObservation.ValueObj := NEW FreeTextValueType;
newObservation.ValueObj.Value := formattedTextAll;
thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation);
endif;
;;
evoke:
;;
logic:
if ( NOT ( RoleType matches pattern "%student%" ) ) AND ( NOT ( OccCode matches pattern "%student%" ) ) then
if ( visitStatus = "ADM" AND ( visitType = "Inpatient" OR visitType = "Observation" ) ) then
if thisDocumentCommunication.EventType = "DocumentOpening" OR thisDocumentCommunication.EventType = "DocumentClosing" then
if ( NOT ( exists CodeStatusOrder ) ) then
CodeStatusAlert_OBJ := new net_object {{{SINGLE-QUOTE}}}CustomCodeStatusAlert.CustomCodeStatusAlertForm{{{SINGLE-QUOTE}}} WITH thisDocumentCommunication.EventType;
rtnValue := CALL CodeStatusAlert_OBJ.ShowDialog;
elseif ( "CODE STATUS ND" IN CodeStatusType ) then
CodeStatusAlert_OBJ := new net_object {{{SINGLE-QUOTE}}}CustomCodeStatusAlert.CustomCodeStatusAlertForm{{{SINGLE-QUOTE}}} WITH "CODE STATUS ND", "Code Status: Ethically unable to determine", thisDocumentCommunication.EventType;
rtnValue := CALL CodeStatusAlert_OBJ.ShowDialog;
endif;
endif;
endif;
endif;
conclude true;
;;
action: return thisDocumentCommunication;
;;
Urgency: 50;;
end: