Initial Checking with all 820 MLMs
This commit is contained in:
@@ -0,0 +1,334 @@
|
||||
maintenance:
|
||||
|
||||
title: SCH_PARKINSONS_CREATE_CONSULT_ORDER ;;
|
||||
mlmname: SCH_PARKINSONS_CREATE_CONSULT_ORDER ;;
|
||||
arden: version 2;;
|
||||
version: 4.50;;
|
||||
institution: St Clair;;
|
||||
author: Maria Pest;;
|
||||
specialist: Don Warnick;;
|
||||
date: 2016-08-24;;
|
||||
validation: testing;;
|
||||
|
||||
library:
|
||||
purpose: Notify pharmacy when a Parkinson{{{SINGLE-QUOTE}}}s patient is in house.
|
||||
;;
|
||||
|
||||
explanation: This is one of several MLMs that creates a Parkinson{{{SINGLE-QUOTE}}}s consult order in the pharmacy. It creates the order when a Parkinson{{{SINGLE-QUOTE}}}s Health Issue is created.
|
||||
|
||||
Change History
|
||||
|
||||
08.24.2016 DW CSR# 34277 - Created MLM.
|
||||
05/26/2017 DW CSR# 34277 - Adjusted the MLM several days after activation to evoke on Order Worksheet Submit rather than Order Enter
|
||||
12/08/2017 TMS CSR# 36024 - Updated to remove alert firing on amantadine and pramipexole they are most commonly ordered for reasons other
|
||||
than parkinson{{{SINGLE-QUOTE}}}s. Request also for and rivastigmine but it currently does not fire since the therapeutic
|
||||
category is not {{{SINGLE-QUOTE}}}dopaminergic antiparkinsonism agents{{{SINGLE-QUOTE}}}.
|
||||
12/8/2017 TMS HD# 2907243 - Updated to remove health issues listing Poisoning by anti-Parkinsonism drugs per the pharmacy.
|
||||
|
||||
;;
|
||||
|
||||
keywords: Health Issue, Pharmacy Consult Order, Parkinson
|
||||
;;
|
||||
|
||||
knowledge:
|
||||
type: data-driven;;
|
||||
data:
|
||||
|
||||
standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
|
||||
include standard_libs;
|
||||
|
||||
Health_Issue_Enter := event {HealthIssueEnter Any HealthIssue: Where (ShortName matches pattern "%Parkinson%") and not(ShortName matches pattern "%Wolf%")
|
||||
and not(CHICODE matches pattern "T42.%")};
|
||||
Medication_Enter := event {OrderWorksheetSubmit User } ;
|
||||
Client_Visit_Enter := event {ClientVisitEnter ANY ClientVisit: where TypeCode = "Inpatient" or typecode = "Observation"};
|
||||
Client_Visit_Modify:= event {ClientVisitModify ANY ClientVisit: where typecode = "Inpatient" or typecode = "Observation"};
|
||||
|
||||
If EvokingEventType = Health_Issue_Enter.type then (visitGuid, ChartGuid, ClientGuid) := read last {HealthIssue: ClientVisitGUID, ChartGUID, ClientGUID REFERENCING EvokingObject }; endif;
|
||||
If EvokingEventType = Client_Visit_Enter.type then (visitGuid, ChartGuid, ClientGuid) := read last {ClientVisit: GUID, ChartGUID, ClientGUID REFERENCING EvokingObject}; endif;
|
||||
If EvokingEventType = Client_Visit_Modify.type then (VisitGUID, ChartGUID, ClientGUID, TypeCode):= read last {ClientVisit: GUID, ChartGUID, ClientGUID, TypeCode REFERENCING EvokingObject}; endif;
|
||||
|
||||
VisitType := read last {ClientVisit: TypeCode};
|
||||
|
||||
|
||||
// Proceed only for Inptatients and Observation patients
|
||||
|
||||
|
||||
If (VisitType = "inpatient" or VisitType = "observation")
|
||||
|
||||
then
|
||||
|
||||
if EvokingEventType = "OrderWorksheetSubmit"
|
||||
|
||||
|
||||
// Medication Order Evoke
|
||||
|
||||
|
||||
then
|
||||
|
||||
// Gather all Parkinson Medication GUIDs
|
||||
|
||||
ParkinsonDrugIDs := read {" select distinct ocmi.guid
|
||||
from SXAMTCategoryDrugXREFVW cdx
|
||||
join SXAMTDrugCategoriesVW cat on cat.multum_category_id = cdx.multum_category_id
|
||||
inner join CV3DrugMapping dm on cdx.drug_id = dm.drugkey
|
||||
inner join cv3ordercatalogmasteritem ocmi on dm.catalogitemguid = ocmi.guid
|
||||
where cat.category_name = {{{SINGLE-QUOTE}}}dopaminergic antiparkinsonism agents{{{SINGLE-QUOTE}}}
|
||||
and dm.drugkey not in ({{{SINGLE-QUOTE}}}d04145{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}d00086{{{SINGLE-QUOTE}}})
|
||||
"};
|
||||
|
||||
// Gather all Parkinson Medication GUIDs
|
||||
|
||||
ParkinsonOrderName := read last { UNSUBMITTED Order: Name where TypeCode = "Medication" and OrderCatalogMasterItemGUID is in ParkinsonDrugIDs };
|
||||
|
||||
If exists ParkinsonOrderName
|
||||
|
||||
then
|
||||
(clientGUID, chartGUID, visitGuid) := read last { ClientVisit: ClientGUID, ChartGUID, GUID };
|
||||
proceed := "yes";
|
||||
OrderReason:= "Reason - order entered for " || ParkinsonOrderName;
|
||||
|
||||
else
|
||||
|
||||
proceed := "no";
|
||||
|
||||
endif; //anti-parkinson drug class ?
|
||||
|
||||
|
||||
elseif (EvokingEventType = "ClientVisitEnter") or (EvokingEventType = "ClientVisitModify")
|
||||
|
||||
then
|
||||
|
||||
|
||||
|
||||
// Admission Evoke
|
||||
|
||||
|
||||
Parkinson_Home_Meds_OnFile := read {" select distinct cp.DrugName
|
||||
from SXAAMBClientPrescription cp with (nolock)
|
||||
inner join SXAMTDrugNameMapVW dnm with (nolock) on dnm.drug_synonym_id = cp.FormularyBrandKey
|
||||
join SXAMTCategoryDrugXREFVW cdx on cdx.drug_id = dnm.drug_id
|
||||
join SXAMTDrugCategoriesVW cat on cat.multum_category_id = cdx.multum_category_id
|
||||
where cp.ClientGuid = " || ClientGUID || " and cp.statustype = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}}
|
||||
and cat.category_name = {{{SINGLE-QUOTE}}}dopaminergic antiparkinsonism agents{{{SINGLE-QUOTE}}}
|
||||
and dnm.drug_id not in ({{{SINGLE-QUOTE}}}d04145{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}d00086{{{SINGLE-QUOTE}}}) "};
|
||||
|
||||
Parkinson_Problem_OnFile := read {" select hi.shortname
|
||||
from CV3HealthIssueDeclaration hi with (nolock)
|
||||
join CV3CodedHealthIssue h with (nolock) on h.GUID = hi.CodedHealthIssueGUID
|
||||
where (hi.Active = 1 and status = {{{SINGLE-QUOTE}}}active{{{SINGLE-QUOTE}}} and hi.shortname like {{{SINGLE-QUOTE}}}%parkinson%{{{SINGLE-QUOTE}}} and hi.shortname not like {{{SINGLE-QUOTE}}}%wolf%{{{SINGLE-QUOTE}}}
|
||||
and h.code not like ({{{SINGLE-QUOTE}}}T42.%{{{SINGLE-QUOTE}}}))
|
||||
and ClientGuid = " || ClientGUID || " "};
|
||||
|
||||
|
||||
if (exists Parkinson_Home_Meds_OnFile or exists Parkinson_Problem_OnFile)
|
||||
|
||||
then
|
||||
|
||||
proceed := "yes"; // patient has anti-parkinson home med or parkinson problem on file
|
||||
OrderReason := "Reason - admission with ";
|
||||
HomeMedAlsoFound:= " ";
|
||||
|
||||
// Remove leading comma if only one item is found in the list
|
||||
if count Parkinson_Problem_OnFile = 1 then Parkinson_Problem_OnFile:= Parkinson_Problem_OnFile[1]; endif;
|
||||
if count Parkinson_Home_Meds_OnFile = 1 then Parkinson_Home_Meds_OnFile:= Parkinson_Home_Meds_OnFile[1]; endif;
|
||||
|
||||
if exists Parkinson_Home_Meds_OnFile
|
||||
then
|
||||
OrderReason := OrderReason || "home medication " || Parkinson_Home_Meds_OnFile || " on file";
|
||||
HomeMedAlsoFound := " and ";
|
||||
endif;
|
||||
|
||||
if exists Parkinson_Problem_OnFile
|
||||
then
|
||||
OrderReason := OrderReason || HomeMedAlsoFound || "health issue for " || Parkinson_Problem_OnFile || " on file";
|
||||
endif;
|
||||
|
||||
else
|
||||
proceed := "no"; // patient has no anti-parkinson home med or parkinson problem on file
|
||||
endif; // level 1 class ?
|
||||
|
||||
|
||||
elseif EvokingEventType = "HealthIssueEnter"
|
||||
|
||||
|
||||
then
|
||||
|
||||
|
||||
// Health Issue Evoke
|
||||
|
||||
|
||||
proceed := "yes"; // only appropriate HI are evoked, so we automatically proceed for all HI entry
|
||||
OrderReason:= "Reason - health issue for " ||EVOKINGOBJECT.ShortName || " entered";
|
||||
|
||||
else
|
||||
|
||||
proceed := "no"; // not a qualifying evoke type
|
||||
|
||||
endif; // qualifying evoke event?
|
||||
|
||||
|
||||
else
|
||||
|
||||
proceed := "no"; // not a qualifying visit type
|
||||
|
||||
|
||||
endif; // visit type ?
|
||||
|
||||
|
||||
|
||||
// Proceed if appropriate
|
||||
|
||||
|
||||
if proceed = "yes"
|
||||
|
||||
then
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Parkinson_Alert_OnFile := read last {"select o.name
|
||||
from cv3ordercatalogmasteritem as ocmi with (nolock)
|
||||
join cv3order as o with (nolock)on o.ordercatalogmasteritemguid = ocmi.guid
|
||||
and o.ClientGUID = " || ClientGUID || " and o.ChartGUID = " || ChartGuid || " and o.ClientVisitGUID = " || visitguid || "
|
||||
and o.name = {{{SINGLE-QUOTE}}}Potential Parkinson Patient{{{SINGLE-QUOTE}}}
|
||||
"};
|
||||
// and o.OrderStatusLevelNum > 15 and o.OrderStatusLevelNum not in ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}100{{{SINGLE-QUOTE}}}) "};
|
||||
|
||||
|
||||
if not exists Parkinson_Alert_OnFile
|
||||
|
||||
then
|
||||
|
||||
// Create the objects
|
||||
|
||||
|
||||
careProvider_obj := read last{ UserInfo: careProvider };
|
||||
careProvider_Actaul := read last{ UserInfo: This };
|
||||
|
||||
Care_Provider := careprovider_obj.GUID ;
|
||||
|
||||
(Typecode, Username ) := Read first {" Select Typecode, DisplayName from CV3CareProvider Where GUID = " || Care_Provider || " "} ;
|
||||
location_guid := Read First {" Select CurrentLocationGUID from CV3ClientVisit Where GUID = " || visitGuid || " "} ;
|
||||
|
||||
log_execution_info := false;
|
||||
order_Creation_Reason := "Created by MLM";
|
||||
|
||||
try
|
||||
client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ;
|
||||
WSSessionType := "Standard";
|
||||
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;
|
||||
|
||||
|
||||
|
||||
// Create the order
|
||||
|
||||
|
||||
if client_visit_obj is not null
|
||||
|
||||
then
|
||||
|
||||
|
||||
try
|
||||
|
||||
|
||||
// Create a new MEDICATION order from a Pre-Filled item
|
||||
|
||||
|
||||
user_IDType := "Edstan Number (physician)";
|
||||
order_Creation_Reason := "Potential Parkinson Patient";
|
||||
|
||||
client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ;
|
||||
user_IDCode := read last {"SELECT IDCode FROM CV3User " || " where GUID = " || Care_Provider};
|
||||
RequestingCareProvider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindById with ( user_IDType, (user_IDCode as STRING) );
|
||||
location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((location_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}});
|
||||
|
||||
SessionType := "Standard";
|
||||
SessionReason := "";
|
||||
RequestingSource := "Standing Order";
|
||||
Catalog_Item_Name := "Potential Parkinson Patient";
|
||||
Catalog_Item_Modifier := "-";
|
||||
Catalog_Item_Version := "";
|
||||
Medication_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name;
|
||||
PreFilled_MedicationOrder_obj := call {{{SINGLE-QUOTE}}}MedicationOrder{{{SINGLE-QUOTE}}}.CreateMedicationOrder
|
||||
with
|
||||
client_visit_obj, // ClientVisit ObjectsPlus object
|
||||
Medication_catalog_item, // OrderCatalogMasterItem ObjectsPlus object
|
||||
Catalog_Item_Modifier, // string ItemNameModifier
|
||||
Catalog_Item_Version, // string ItemNameModifierVersion
|
||||
order_Creation_Reason, // string CreateReason
|
||||
RequestingCareProvider_obj , // RequestedBy ObjectsPlus object
|
||||
RequestingSource, // string RequestedBySource (must be in dictionary)
|
||||
SessionType, // string SessionType
|
||||
SessionReason, // string SessionReason
|
||||
location_obj, // Location ReleaseLocGrpID
|
||||
"Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; // AvailabilityOverride eAvailabilityOverride
|
||||
|
||||
PreFilled_MedicationOrder_obj.AdministrationInstructions:= OrderReason;
|
||||
|
||||
|
||||
if ( Medication_catalog_item is NOT NULL ) then
|
||||
void := call PreFilled_MedicationOrder_obj.Save;
|
||||
void := call PreFilled_MedicationOrder_obj.Dispose;
|
||||
void:= call Medication_catalog_item.Dispose;
|
||||
Medication_catalog_item:= null;
|
||||
endif;
|
||||
|
||||
|
||||
endtry;
|
||||
|
||||
catch Exception ex error_occurred := true; error_message := "{{+R}}New prefilled medication order:{{-R}}\n" || ex.Message || "\n\n";
|
||||
|
||||
if ( Medication_catalog_item is NOT NULL ) then void:= call Medication_catalog_item.Dispose; Medication_catalog_item:= null; endif;
|
||||
if ( PreFilled_MedicationOrder_obj is NOT NULL ) then void:= call PreFilled_MedicationOrder_obj.Dispose; PreFilled_MedicationOrder_obj:= null; endif;
|
||||
|
||||
endcatch;
|
||||
|
||||
if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif;
|
||||
if ( RequestingCareProvider_obj is NOT NULL ) then void:= call RequestingCareProvider_obj.Dispose; RequestingCareProvider_obj:= null; endif;
|
||||
if ( location_obj is NOT NULL ) then void:= call location_obj.Dispose; location_obj:= null; endif;
|
||||
|
||||
|
||||
endif; // Create the order ?
|
||||
|
||||
|
||||
endif; // Parkinson order already on file ?
|
||||
|
||||
|
||||
endif; // procced ?
|
||||
|
||||
|
||||
|
||||
;;
|
||||
evoke:
|
||||
|
||||
Health_Issue_Enter;
|
||||
Medication_Enter;
|
||||
|
||||
10 seconds after time of Client_Visit_Modify;
|
||||
10 seconds after time of Client_Visit_Enter;
|
||||
|
||||
|
||||
;;
|
||||
logic:
|
||||
|
||||
|
||||
conclude True;
|
||||
|
||||
;;
|
||||
action:
|
||||
|
||||
;;
|
||||
end:
|
||||
Reference in New Issue
Block a user