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

201 lines
8.2 KiB
Plaintext

maintenance:
title: DOC_CALL_SPECIMEN_PATHOLOGY ;;
mlmname: DOC_CALL_SPECIMEN_PATHOLOGY;;
arden: version 2.5;;
version: 0.00;;
institution: ;;
author: Brijesh Chauhan (Allscripts) ;;
specialist: ;;
date: 2017-08-16;;
validation: testing;;
library:
purpose: Print Speciment Pathology report after document will complete
;;
explanation:
**Change History**
1) 08/16/2017 New MLM created
2) 10/9/2018 STH CSR#: 37482 - Modified original and updated to work. {Go-Live 10/29/2018}
;;
keywords:
;;
citations:
;;
knowledge:
type: data-driven;;
data:
mlm_name := "DOC_CALL_SPECIMEN_PATHOLOGY";
standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
include standard_libs;
using "SCMLib";
using "SCM.Common.Interfaces";
using namespace "SCMLib";
using namespace "SCM.Common.Interfaces";
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 ];
error_dtl := "";
client_doc_enter := EVENT { ClientDocumentEnter USER ClientDocument : WHERE DocumentName IN ("Endo IntraOp Nursing Note","MLSC IntraOp Nursing Note","IntraOp Nursing Note")};
client_doc_modify := EVENT { ClientDocumentModify USER ClientDocument : WHERE DocumentName IN ("Endo IntraOp Nursing Note","MLSC IntraOp Nursing Note","IntraOp Nursing Note")};
ClientGUID := EVOKINGOBJECT.ClientGUID;
ChartGUID := EVOKINGOBJECT.ChartGUID;
VisitGUID := EVOKINGOBJECT.ClientVisitGUID;
CD_GUID := EVOKINGOBJECT.GUID;
errhndl := false;
tstinfo := EVOKINGOBJECT.ClientObservationDocument;
tstinfo2 := tstinfo.ClientObservation;
(CD_IsIncomplete, CD_Name) := read last {"SELECT
cd.isincomplete,cd.DocumentName
FROM CV3ClientVisit cv with (nolock)
INNER JOIN SXACDObservationParameter ObsParam with (nolock)
ON cv.ClientGUID = ObsParam.ClientGUID
AND cv.ChartGUID = ObsParam.ChartGUID
AND ObsParam.IsCanceled = 0
INNER JOIN CV3ClientDocument CD with (nolock)
on ObsParam.clientguid = cd.clientguid
and ObsParam.chartguid = cd.ChartGUID
and ObsParam.ClientVisitGUID = cd.ClientVisitGUID
and cd.GUID = ObsParam.OwnerGUID
LEFT OUTER JOIN SCMObsFSListValues with (nolock)
ON cv.ClientGUID = SCMObsFSListValues.ClientGUID
AND ObsParam.ObservationDocumentGUID = SCMObsFSListValues.ParentGUID
INNER JOIN CV3ObsCatalogMasterItem ocmi with (nolock)
on obsparam.ObsMasterItemGUID = ocmi.GUID
and ocmi.name like {{{SINGLE-QUOTE}}}SCH OR specimen description[0-9]%{{{SINGLE-QUOTE}}}
where cv.ClientGUID = " || sql(ClientGUID)
|| " and cv.ChartGUID =" || sql(ChartGUID)
|| " and cv.guid = " || sql(VisitGUID)
|| " and ObsParam.OwnerGUID = " || sql(CD_GUID) || " "};
//If there client document (structured note) does not contain at least 1 specimen AND/OR the client document is saved as incomplete the MLM will skip all the below logic and do nothing.
if((count(CD_Name)>0) and (CD_IsIncomplete = false)) then
//Get the CaseID from thew end of the clientdocumentname to pass into the HVCLine1 parameter of the report parameters
dash_CDName := find "-" in string CD_Name;
if(dash_CDName > 0) then
Len_CaseID := (length of CD_Name) - (dash_CDName);
CaseID := substring (Len_CaseID) characters starting at (dash_CDName + 1) from CD_Name;
endif;
//DEFAULT BROADCAST PRINTER TO PDFHIS
//If the structured note starts with ENDO print to ENDO printer, if the document starts with MLSC print to MLSC printer otherwise print to OR printer.
BroadcastPrinter := "PDFHIS";
Printcopies := 2;
if(CD_Name matches pattern "Endo%") then
BroadcastPrinter := "ENDO - GE LAB BACK";
Printcopies := 1;
elseif (CD_Name matches pattern "MLSC%") then
BroadcastPrinter := "MLSC Surgical";
else
BroadcastPrinter := "OR";
endif;
//Make sure we got a valid case ID from the end of the structured note. If the IntraOp note was entered in Acute Care (instead of surgical care) there will be no case identifier added to end of note.
if(caseID <> "" and caseID is not null) then
try
//Start building the report call object based on the report version name SCH_Specimen_Pathology_MLM
report_request_obj := call {{{SINGLE-QUOTE}}}ObjectsPlusXA.SunriseClinicalManager.ReportRequest{{{SINGLE-QUOTE}}}.CreateReportRequest with ("SCH_Specimen_Pathology_MLM" as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}});
//Make sure a valid report object was created, and if so create a list containg the report parameters availble.
if (report_request_obj.Parameters is not null and report_request_obj.Parameters.Count > 0)
then
report_parameter_list := ();
for parameterIndex in (1 seqto report_request_obj.Parameters.Count)
do
report_parameter_list := report_parameter_list, report_request_obj.Parameters[parameterIndex];
enddo;
endif;
//set variables equal to the report parameters from the list that we need to modify for the report to run against proper patient and note.
param_VisitGUID := first(report_parameter_list where report_parameter_list.Label = "ClientVisitGUID");
param_ClientDocGUID := first (report_parameter_list where report_parameter_list.Label = "DocumentGUID");
param_CaseID := first (report_parameter_list where report_parameter_list.Label = "Case Identifier:");
//make sure the parameters are set to allow modification, and if so set the parater values equal to the proper case ID, Visit guid and document guid
if param_CaseID.AllowModification then
void := call param_CaseID.{{{SINGLE-QUOTE}}}SetValue<System.String>{{{SINGLE-QUOTE}}} with STRING(CaseID) as {{{SINGLE-QUOTE}}}System.String{{{SINGLE-QUOTE}}};
endif;
if param_VisitGUID.AllowModification then
void := call param_VisitGUID.{{{SINGLE-QUOTE}}}SetValue<System.String>{{{SINGLE-QUOTE}}} with STRING(VisitGUID) as {{{SINGLE-QUOTE}}}System.String{{{SINGLE-QUOTE}}};
endif;
if param_ClientDocGUID.AllowModification then
void := call param_ClientDocGUID.{{{SINGLE-QUOTE}}}SetValue<System.String>{{{SINGLE-QUOTE}}} with STRING(CD_GUID) as {{{SINGLE-QUOTE}}}System.String{{{SINGLE-QUOTE}}};
endif;
//set the report object to use broadcast print and set the proper printer based on the structured note name defined above.
report_request_obj.PrintPolicy := 4;
report_request_obj.NumberOfCopies := Printcopies;
report_request_obj.PrintJobDestination := BroadcastPrinter;
// print the report
void := call report_request_obj.Save;
// Call Dispose on report_request_obj to clean it up
if report_request_obj is not null
then
void := call report_request_obj.Dispose;
report_request_obj := null;
endif;
endtry;
catch exception ex
error_dtl := ex;
errhndl := true;
if report_request_obj is not null
then
void := call report_request_obj.Dispose;
report_request_obj := null;
endif;
endcatch;
endif;
endif;
;;
priority: 50
;;
evoke:
3 seconds after time of client_doc_enter;
3 seconds after time of client_doc_modify;
;;
logic:
conclude true;
;;
action:
if errhndl 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\n" || "Case ID: " || CaseID
|| "\n VisitGUID: " || VisitGUID
|| "\n CD_GUID: " || CD_GUID
|| "\n\nERROR: " || error_dtl at error_destination;
endif;
;;
Urgency: 50;;
end: