Files
St.Clair/MLMStripper/bin/Debug/DOC/DOC_PEL_UPDATE.mlm

347 lines
19 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
maintenance:
title: DOC_PEL_UPDATE;;
mlmname: DOC_PEL_UPDATE;;
arden: version 2.5;;
version: 1.02;; //Release 5.5 SP1/FP1 and 6.0/6.1 SU2 and higher
institution: Speed to Value, Allscrtips;;
author: S2V, Philip Thomas (MODIFIED BY SHAWN HEAD);;
specialist: Allscripts Corporation (PLT) (MODIFIED BY SHAWN HEAD);;
date: 2014-06-06;;
validation: testing;;
library:
purpose:
This MLM will update the Patient Education Log based upon the Education Outcome Record being charted. For education to be charted you
must attach a Coding Standard of PEL_OBS to the observartion item you want to write to the education log. The education observartion needs to
be a fan out obeservation that will be suggested based on specific Plan of Care{{{SINGLE-QUOTE}}}s. Initially this was setup for COPD, Trauma/Injusry Risk,
Total Knee, Total Hip, and Pneumonia.
;;
explanation:
This MLM will add a row to the Patient Education Log based upon a observation being charted on the Education outcome Record by calling the stored procedure SXAAmbPatEdLogInsPr to update the Patient Education Log.
The MLM is triggered based upon the observation having a coding standard of PEL_OBS added to the configuration AND a value being selected that does not contain the word "refused".
The MLM is currently hardcoded to NOT allow duplicates. In the future if we need to change this we can use a class type or other SCM configuration
elements to identify if it should allow duplicates or not. This is hardcoded as NO_Duplicates = true.
Allscripts provided this use for the no_duplicates workflow; however at this point we have it hardcoded to true.
If the Class Type Value is "Update All Worklist Events" Then Duplicate entries will be created for this Order Task on the patient chart for each time the task is completed.
If the Class Type Value is "Update Once Per Document Name + Visit + Location" Then NO Duplicate entries if it is the same document name and patient location and visit combined.
-This is the recommended setting to avoid multiple entries for a task that is reset and then marked as done multiple times.
Any other class type values will create duplicate Education Log entry for each time the task is completed (default behavior).
The MLM will update the Education Log with the following parameters:
Education Document Name = Description from Coding Stadandard PEL_OBS added to observartion; // Passed Education Document Name (The Education Order Name)
Document Source = Coded Value from the coding standard PEL_OBS added to observartion; // Hard Coded in MLM as the passed Document Source
User_GUID = EvokingObject.PerformedProviderGUID; // The Task completion Given By user GUID
USER_ID = user_id; // task Entry User ID (not seen)
Education Given Date = charted column date/time // Sets the Education date and time to the task documented values
Comment = not used at this time. // The Education Log comment section from the configured task documentation summary line (accepts 4000 characters)
Note: The Outcomes cannot be updated with this MLM
SCM Configuration Tasks:
1. Add a coding standard to the observation that needs to write to the education log with the coding standard of PEL_OBS
2. Set the coded value to the source you want written in the patient education log.
NOTE: Initial install only has Education Outcome Record
3. Add a name of the edcucation provided to the Description. This should be the specific education that is being provided to the patient.
NOTE: Initial install only had COPD, Pneumonia, Total Knee, Total Hip, and Trauma/Injury Risk.
Modification history:
*** Allscripts Disclaimer:
Client is responsible for all decisions, acts, and omissions of any persons in connection with the delivery of medical care or other services to any patients.
Before any Licensed Materials are placed into a live production environment, it is Clients responsibility to review and test all Licensed Materials and associated
workflows and other content, as implemented, make independent decisions about system settings and configuration based upon Clients needs, practices, standards and
environment, and reach its own independent determination that they are appropriate for such live production use. Any such use by Client (or its Authorized Users)
will constitute Clients representation that it has complied with the foregoing. Client shall ensure that all Authorized Users are appropriately trained in use of
the then-deployed release of the Software prior to their use of the Software in a live production environment. Clinical Materials are tools to assist Authorized
Users in the delivery of medical care, but should not be viewed as prescriptive or authoritative. Clinical Materials are not a substitute for, and Client shall
ensure that each Authorized User applies in conjunction with the use thereof, independent professional medical judgment. Clinical Materials are not designed for use,
and Client shall not use them, in any system that provides medical care without the participation of properly trained personnel. Any live production use of Clinical
Materials by Client (or its Authorized Users) will constitute Clients acceptance of clinical responsibility for the use of such materials.
2014-06-10 STH CSR#: 31688 (MU2) - Modified S2V Sample MLM to use the flowsheet / Plan of Care observations to write to the Patient Education Log based on Kathy Baumgarten approval.
07.23.2019 TMS CSR#: 37676 - Change log_execution_info to false per upgrade analysis.
;;
keywords: Objects Plus, Education Log, Worklist, ARRA
;;
knowledge:
type: data-driven;;
data:
mlm_name := "DOC_PEL_UPDATE";
CR := 13 formatted with "%c";
LF := 10 formatted with "%c";
CRLF:= CR||LF;
//Set to true if a decision.log is needed for diagnostic purposes. Please refer to the CDS Authoring Guides for more information
log_execution_info:= false;
// Specify which .NET assemblies need to be loaded for ObjectsPlus
standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
include standard_libs;
using "ObjectsPlusXA.SCM.Forms";
using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms";
set_cds_vars := MLM {{{SINGLE-QUOTE}}}CALLED_DOC_FS_DEFINITION_MLM{{{SINGLE-QUOTE}}};
//---------------------------------------------------------------
// Error destination
//---------------------------------------------------------------
//"SYSTEM ALERT",
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_alert_with_order := "",
Alert_dialog_settings := "",
Display_alert := true ];
// Receive arguments from the structured note
(this_DocumentCommunication) := argument;
// Get the user, chart, client and visit GUIDs
if called_by_editor then
userguid := "";
clientGuid := "9000001860200200"; //Admission, Holly
clientvisitguid := "9000003613200270";//Admission, Holly
chartguid := "9000003613100170";//Admission, Holly
else
userGuid := this_DocumentCommunication.UserGUID;
clientGuid := this_DocumentCommunication.ClientGUID;
clientvisitGuid := this_DocumentCommunication.ClientVisitGUID;
chartGuid := this_DocumentCommunication.ChartGUID;
endif;
// Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate
ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj];
ListValueType := OBJECT [ListGuid, ListItemsList, SuggestedTextValue];
ListValueListItemType := OBJECT [ListItemGUID, Value, IsSelected];
Education_Observartions := OBJECT [SCM_Obs_Name,PEL_SCM_Source,PEL_SCM_DocumentName];
//Document Type
FLOWSHEET := "FlowSheet";
//Event Types
CHARTOBSERVATION := "ChartObservation";
DOCUMENTCLOSING := "DocumentClosing";
DOCUMENTOPENING := "DocumentOpening";
(this_documentCommunication, client_guid, client_visit_guid, chart_guid,
user_guid, document_type, document_name, event_type,
configuration_guid, this_currentObs, CancelEventFlag, this_fs_doc,
authored_by_guid, isIOFlowsheetFlag, client_document_guid, this_parameters,
this_columnList, this_currentColumn, this_chartedObservationsList,
this_parameters_displayName, current_parameter, current_parameter_name, current_parameter_guid,
current_parameter_datatype, selectedItems, selectedItems_Value, current_value,
diagnostic_message, displayMessageFlag) := CALL set_cds_vars WITH (this_documentCommunication);
Error_occurred := false;
SCM_Observartions := new Education_Observartions;
//get a list of observations that exist in the our observartion catalog that have the PEL_OBS coding standard added to them.
(PEL_OBS_Names, PEL_Source,PEL_Matieral ) := read {" select oci.Name, "
|| " oc.CodedValue, oc.CodeDescription from CV3ObsCatalogItem oci "
|| " inner join SCMObsCodedValue oc on oci.MasterObsGUID = oc.ParentGUID "
|| " where oc.CodingStandards = {{{SINGLE-QUOTE}}}PEL_OBS{{{SINGLE-QUOTE}}} "
|| " and oc.active = 1 "
|| " and oci.Active = 1 "};
//create a list of observation names, configured source, and configured education description based on the coding standard configuration added to the observations in SCM.
SCM_Observartions.SCM_Obs_Name := PEL_OBS_Names;
SCM_Observartions.PEL_SCM_Source := PEL_Source;
SCM_Observartions.PEL_SCM_DocumentName := PEL_Matieral;
//create a list of charted parameters that exist in the list of observartion names created above.
charted_parameters := (this_parameters where this_parameters.Name is in PEL_OBS_Names);
//loop through all the charted observrations that also have the proper coding standard added to them to determine in and education log entry needs written into
//the patient education log.
for x in (1 seqto(count(charted_parameters))) do
Education_obs := charted_parameters[x];
//If there are eudcation observations in the charted parameter list then we will continue otherwise the next charted_parameter will be checked until the end of the list.
if ( exists Education_obs ) then
//get the current column and current charted parameter value based on the education obs cound in the lists.
theCurrentColumn := first of ( this_columnList WHERE this_columnList.ClientDocumentGUID = this_currentObs.ClientDocumentGUID);
current_obs := first of ( theCurrentColumn.ChartedObservationsList WHERE theCurrentColumn.ChartedObservationsList.ParameterGUID = Education_obs.ParameterGUID);
//as long as the current observartion being charted is in the current column continue otherwise move on and check the next paramter item.
if (exists current_obs) then
//create a list of all the selected values in the lists
Education_ListItemsList := current_obs.ValueObj.ListValuesList.ListItemsList;
All_Education_values := ();
//this for loop combines all the lists. in the inital release verison there are 3 list sets and this will combine them into 1 list.
for y in (1 seqto(count(Education_ListItemsList))) do
All_Education_values := All_Education_values, Education_ListItemsList[y];
enddo;
//create a new education list items object to parse through and verify if and what to be added to the education log.
Education_lists_items_obj := new ListValueListItemType;
Education_lists_items_obj := (All_Education_values where All_Education_values.IsSelected = true);
//creates a variable for the stored procedure observartion name(s) in the list.
SP_Obs_Name := last of (SCM_Observartions.SCM_Obs_Name
where SCM_Observartions.SCM_Obs_Name = Education_obs.Name);
//creates a variable for the stored procedure observartion source(s) in the list.
SP_Obs_Source := last of (SCM_Observartions.PEL_SCM_Source
where SCM_Observartions.SCM_Obs_Name = Education_obs.Name);
//creates a variable for the stored procedure observartion Education Document Name(s) in the list.
SP_Obs_DocumentName := last of (SCM_Observartions.PEL_SCM_DocumentName
where SCM_Observartions.SCM_Obs_Name = Education_obs.Name);
//create a variable for the visit GUID
SP_Visit_GUID := clientvisitGuid;
//Get the Current Location information
SP_Location_GUID1 := read last {"select CurrentLocationguid "
|| " from CV3ClientVisit "
|| " where clientguid = " || sql(clientGuid)
|| " and ChartGUID = " || sql(chartguid)
|| " and guid = " || sql(clientvisitguid)
|| " "};
//create the other stored procedure values required.
SP_Location_GUID := SP_Location_GUID1 AS NUMBER;
SP_User_GUID := this_DocumentCommunication.UserGUID as number;//"9000002815101190";//user_GUID;
SP_USER_ID := read last { "select IDCode from cv3user where guid = " || sql(SP_User_GUID) };
SP_Comment := "";
NO_Duplicates := TRUE;
SP_Given_DTM := theCurrentColumn.DateTime;//"2014-03-20 01:00:00.000";
//check to see if "refused" was selected or if there are no items selected at all.
if "refused" in Education_lists_items_obj.Value or count(Education_lists_items_obj) = 0 then
(LOG_TouchedBy, LOG_PatEducationLogID, LOG_ReplTrans) := READ LAST
{" SELECT top 1 LOG.TouchedBy, LOG.PatEducationLogID, LOG.MSrepl_tran_version "
|| " FROM SXAAMBPatientEducationLog LOG LEFT JOIN CV3CareProvider ON CV3CareProvider.GUID = LOG.ProviderGUID"
|| " LEFT JOIN CV3Location ON CV3Location.GUID = LOG.LocationGUID INNER JOIN CV3ClientVisit ON CV3ClientVisit.GUID = LOG.ClientVisitGUID"
|| " INNER JOIN SXAAMBPatientEducationDoc DOC ON DOC.PatEducationDocID = LOG.PatEducationDocID"
|| " WHERE CV3ClientVisit.ClientGUID = " || sql(ClientGUID) || " AND CV3ClientVisit.GUID = " || SQL(ClientVisitGUID)
|| " AND DOC.DocName = " || SQL(SP_Obs_DocumentName) || " AND CV3Location.GUID = " || SQL(SP_Location_GUID) || " AND LOG.Active = 1"
|| " ORDER BY LOG.EducationDtm DESC"};
//Do not update the Stored Procedure if a duplicate is found for the same Document Name + Visit + Location
//check to see if the above SQL found an entry in the table for the current education entry. If so delete or deactivate it
If LOG_ReplTrans Is not NULL then
return_status := read {" SXAAmbPatEdLogDelPr "
|| " @UserName=" || SQL(LOG_TouchedBy) || ","
|| " @PatEducationLogID=" || SQL(LOG_PatEducationLogID) || ","
|| " @MSrepl_tran_version=" || SQL(LOG_ReplTrans) };
Endif;
else
//if refused is not selected AND there are at least 1 item selected in the lists associated with the observartion then we need to add
//the entry to the patient eduaction log.
call_procedure := true;
//If the setting to block duplicate entries based upon Document Name + Visit + Location is enabled then query the
// Education Log to see if an entry already exisits. Ignore update if a record is found.
If NO_Duplicates AND SP_Obs_DocumentName Is Not NULL then
(LOG_Visit_Number, LOG_Visit_GUID, LOG_DOC_Name, LOG_DOC_Source, LOG_ED_DTM, LOG_Provider_GUID, LOG_Location_GUID,
LOG_Provider_Name, LOG_Location, LOG_ID, LOG_Active, LOG_Comment) := READ LAST
{" SELECT CV3ClientVisit.VisitIDCode as VisitNumber, LOG.ClientVisitGUID as VisitGUID, DOC.DocName, DOC.DocSource,"
|| " LOG.EducationDtm AS EducationDTM, LOG.ProviderGUID, LOG.LocationGUID, CV3CareProvider.DisplayName,"
|| " CV3Location.Name AS LocationName, LOG.PatEducationLogID AS GUID, LOG.Active, LOG.Comment"
|| " FROM SXAAMBPatientEducationLog LOG LEFT JOIN CV3CareProvider ON CV3CareProvider.GUID = LOG.ProviderGUID"
|| " LEFT JOIN CV3Location ON CV3Location.GUID = LOG.LocationGUID INNER JOIN CV3ClientVisit ON CV3ClientVisit.GUID = LOG.ClientVisitGUID"
|| " INNER JOIN SXAAMBPatientEducationDoc DOC ON DOC.PatEducationDocID = LOG.PatEducationDocID"
|| " WHERE CV3ClientVisit.ClientGUID = " || sql(ClientGUID) || " AND CV3ClientVisit.GUID = " || SQL(ClientVisitGUID)
|| " AND DOC.DocName = " || SQL(SP_Obs_DocumentName) || " AND CV3Location.GUID = " || SQL(SP_Location_GUID) || " AND LOG.Active = 1"
|| " ORDER BY LOG.EducationDtm DESC"};
//Do not update the Stored Procedure if a duplicate is found for the same Document Name + Visit + Location
If LOG_ID Is not NULL then
Call_Procedure := FALSE;
Endif;
Endif;
if SP_Location_GUID is null or SP_Location_GUID = "" or SP_User_GUID is null or SP_User_GUID = ""
or SP_Given_DTM is null or SP_Given_DTM = "" or SP_Visit_GUID is null or SP_Visit_GUID = ""
or SP_Obs_DocumentName is null or SP_Obs_DocumentName = "" or SP_Obs_Source is null or SP_Obs_Source = ""
or SP_USER_ID is null or SP_USER_ID = "" then
Error_occurred := true;
error_message := "Missing required information: " || crlf;
error_message := error_message || "Location GUID =" || SP_Location_GUID || crlf;
error_message := error_message || "User GUID =" || SP_User_GUID || crlf;
error_message := error_message || "User User ID =" || SP_USER_ID || crlf;
error_message := error_message || "User Give DTTM =" || SP_Given_DTM || crlf;
error_message := error_message || "User Give Visit GUID =" || SP_Visit_GUID || crlf;
error_message := error_message || "User Give DocumentName=" || SP_Obs_DocumentName || crlf;
error_message := error_message || "User Give Source=" || SP_Obs_Source || crlf;
endif;
//-----//Add an Entry to the Education Log by calling the Stored Procedure to insert a row
If SP_Obs_DocumentName IS NOT NULL and Error_occurred = FALSE and Call_Procedure = true then
return_status := read {" SXAAmbPatEdLogInsPr "
|| " @LocationGUID=" || SQL(SP_Location_GUID) || ","
|| " @VisitGUID=" || SQL(SP_Visit_GUID) || ","
|| " @DocumentName=" || SQL(SP_Obs_DocumentName) || ","
|| " @DocumentSource=" || SQL(SP_Obs_Source) || ","
|| " @EducationDate=" || SQL(SP_Given_DTM) || ","
|| " @ProviderGUID=" || SQL(SP_User_GUID) || ","
|| " @UserID=" || SQL(SP_USER_ID) || ","
|| " @Comment=" || SQL(SP_Comment) || ",@PatEducationDocID=0"};
//If the SP Return Status is not the ED Doc ID then Trigger an Error Message
If return_status Is not number then
Error_occurred := true;
error_message := "Return Status: " || return_status;
Endif;
endif;
endif;
endif;
endif;
enddo;
;;
priority: 50
;;
evoke:
;;
logic:
//Conclude if results were found
// if Error_occurred then
// conclude false;
// else
conclude true;
// endif;
;;
action:
if Error_occurred then
write "An error has occured in the MLM {{+B}}" || mlm_name || "{{-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;
//error_message
Endif;
;;
Urgency: 50;;
end: