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,135 @@
maintenance:
title: SCH Order Sets Correct Session;;
filename: SC_Ordersets_Correct_Session;;
arden: version 2;;
version: 5.00;;
institution: St Clair;;
author: Robert Spence;;
specialist: Robert Spence;;
date: 2010-05-07;;
validation: testing;;
library:
purpose: Check to see if ordersets in list are in the correct session, if not alert with appropriate information
;;
explanation: Same as purpose.
Change History
Robert 05.07.2010 - Original Coding.
DW 08.29.2014 - CSR# 32551 - Added ED location override code for the "Acute Ischemic Stroke/TIA Admission" OS
JML 03.21.2016 - CSR# 34077 - Added Transition Orders to Hold session.
DW 05.25.2017 - CSR# 35320 - Added Discharge Order Set - Outpatient{{{SINGLE-QUOTE}}} to Discharge session.
;;
keywords: Order set, admission, discharge, session type, worksheetinfo
;;
knowledge:
type: data-driven;;
data:
log_execution_info:= false;
standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
include standard_libs;
send_alert := "DoNotSend";
location := read last {ClientVisit : CurrentLocation};
worksheetInfo := call {{{SINGLE-QUOTE}}}OrderEntryBatch{{{SINGLE-QUOTE}}}.GetCurrent;
order_sess_alert:= destination { Alert: warning, "Order Session Type", high, chart, "Order Session Type", 15042, send_alert, "No Override Allowed" };
event_var:= Event {OrderSetInit User OrderSet: WHERE OrderSetName Matches pattern "Admission Orders%"
or OrderSetName Matches pattern "Discharge Orders%"
or OrderSetName Matches pattern "Pediatric -%Admission"
or OrderSetName Matches pattern "Transition Orders%"
or OrderSetName = "Discharge Order Set - Outpatient"
};
MessageOut := "";
(order_name,order_status) := read last {OrderSet: OrderSetName, OrderSetStatusCode REFERENCING EvokingObject };
stoporder:= false;
// Discharge OS handling
if (order_name matches pattern "Discharge Orders%" or order_name = "Discharge Order Set - Outpatient") and worksheetinfo.sessiontype <> "Discharge"
then
if worksheetInfo.UnsubmittedOrdersCount = 0
then
void := call worksheetInfo.SetSessionType with ("Discharge", "Discharge Orders");
else
stoporder := true;
MessageOut := "ALERT: Discharge Order Session Type is Required for Discharge Orders." || "\n\n"
|| "Please Select ""Go Back"" and Re-Select a Session Type of ""Discharge""\n\n"
|| " on the Order Entry Worksheet";
endif;
// Admission OS handling
elseif (
(order_name matches pattern "Admission Orders%" or order_name matches pattern "Pediatric -%Admission")
and worksheetinfo.sessiontype <> "Hold" and (location matches pattern "ER%" or location = "Pre-Admit" )
)
then
if worksheetInfo.UnsubmittedOrdersCount = 0
then
void := call worksheetInfo.SetSessionType with ("Hold", "Hold Orders");
else
stoporder := true;
MessageOut := "ALERT: Hold Order Session Type is Required for Admission Orders. " || "\n\n"
|| "Please Select ""Go Back"" and Re-Select a Session Type of ""Hold"" "
|| "on the Order Entry Worksheet";
endif;
//JML CSR 34077 Change
elseif ( order_name matches pattern "Transition Orders%" AND worksheetInfo.sessiontype <> "Hold"
AND ( location matches pattern "ER%" OR location = "Pre-Admit" ) ) then
if ( worksheetInfo.UnsubmittedOrdersCount = 0 ) then
void := call worksheetInfo.SetSessionType WITH ("Hold", "Hold Orders" );
else
stoporder := true;
MessageOut := "ALERT: Hold Order Session Type is required for Transition Orders." || "\n\n"
|| "Please select ""Go Back"" and re-select a session type of ""Hold"" "
|| "on the Order Entry Worksheet.";
endif;
endif;
;;
evoke: event_var;
;;
logic:
conclude stoporder;
if( worksheetInfo is NOT NULL ) then
void := call worksheetInfo.Dispose;
worksheetInfo:= null;
endif;
;;
action:
write MessageOut at order_sess_alert;
;;
end:

View File

@@ -0,0 +1,617 @@
maintenance:
title: SC Visit Discharge ;;
filename: SC_Visit_Discharge;;
arden: version 2;;
version: 4.50;;
institution: St Clair;;
author: Kathy Kennedy, Eclipsys;;
specialist: Robert Spence;;
date: 2006-11-06;;
validation: testing;;
library:
purpose: Do not allow a patient to be discharged via the SCM application
if there is no {{{SINGLE-QUOTE}}}Discharge{{{SINGLE-QUOTE}}} order active on the patient.
;;
explanation: When a user selects {{{SINGLE-QUOTE}}}Discharge Visit{{{SINGLE-QUOTE}}} in the SCM application
and contiues to discharge the patient when they click the {{{SINGLE-QUOTE}}}Discharge{{{SINGLE-QUOTE}}} button
a hard stop alert will display if the patient does not have an active
(i.e. not cancelled or discontinued) {{{SINGLE-QUOTE}}}Discharge{{{SINGLE-QUOTE}}} order on that particular visit.
change history
02.22.2008 DJW added logic for additional "registration is incomplete" warning messeage
05.22.2008 RS added logic for 93952 to insure disposition = order type
12.02.2008 DJW altered logic for additional "registration is incomplete" logic (look for clerk initials instead of print location)
07.28.2010 DJW altered logic for presence of date and time stamp requirement on observation orders
12.19.2012 DJW CSR# 25244 Call the Discharge Report which is interfaced back in as a document.
06.12.2014 DJW CSR# 31688 - MU2 Transport CCDA to Manor Care SNFs
07.08.2014 DW CSR# 31688 - MU2 Suppress print for behavioral health patients
08.25.2014 DW CSR# 31688 - Added Concordia as a recipient
09.24.2014 DW CSR# 31688 - Added Family Home Health as a recipient
05.15.2015 DW CSR# 32359 - Physician CPT codes - (build alternate charge when a patient is discharged)
06.22.2015 DW CSR# 32359 - Address the PA / CRNP who enters on behalf of a physician
06.19.2015 SH CSR# 32070 - Discharge Summary requirements - need to make sure Discharge Order Rec is completed if patient here greater than 48 hours AND not deceased.
Also patient type changes require the ability to discharge for a date that equals > 48 hours because the system will not allow you discharge with a prior date.
08.18.2015 DW CSR# 26006 - Transport CCDA to CCHIE via XDS protocol
12.01.2016 DW CSR# 35130 - Upgrade SCM to version 16.3
08.22.2017 DW CSR# 36214 - SCM AM Registration - Changed criteria for determining incomplete registration to "iscompleteregistration" flag
04.09.2018 DW CSR# 36624 - Exclude Recurring patients from discharge order requirement
04.19.2018 DW CSR# 36577 - Concordia Visiting Nurses office in South Hills - request for change in direct messaging destination (temporary changed MLM to also send to prior address)
05.24.2018 DW CSR# 36577 - Concordia Visiting Nurses office in South Hills - request for change in direct messaging destination (removed temporary change to also send to prior address)
04.25.2019 DW CSR# 36767 - 18.4 - Discharges in Dev were taking 1 minute. Believe that it was associated with the Environment line. ClientOID "4" = "Test" changed to ClientOID "4" = "Development"
09.20.2019 DW CSR# 35638 - MU3 - Transmit to physician direct address (redisign....pass direct address to create and transport MLM instead of discharge location)
10.07.2019 DW CSR# 38769 - Discharge Opsu, Endo, MLSC (Temporarily override the requirmement to enter a discharge order for SCD patients
11.13.2019 DW CSR# 35638 - MU3 - File Patient Discharge CCDA on ED patients and transmit to Baptist/Providence Point
;;
keywords: discharge
;;
knowledge:
type: data-driven;;
data:
/*******************Make Changes To Spelling And Flags In This Section*******************/
/* Set to true if logging is needed.*/
log_execution_info:= false;
standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
include standard_libs;
DCSummmary_Print_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_DCSUMMARY_PRINT{{{SINGLE-QUOTE}}};
using "ObjectsPlusXA.SCM.Forms";
using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms";
// Set the text for this variable to indicate whether to send the message or not.
send_alert := "DoNotSend";
discharge_order := "Discharge";
discharge_observation_order := "Discharge-Observation";
expired_order := "Expired";
// 12/2/08 DW changed criteria for identifying incomplete registration
// print_location := "print location";
reg_initials := "reg initials";
order_entered := " ";
complete_registration := " ";
obs_disch_message := " ";
msg_Missing_DCRec := " ";
Report_Print_MLM := mlm {{{SINGLE-QUOTE}}}SCH_FUNC_PRINT{{{SINGLE-QUOTE}}};
/* Change the message within the quotes if a different short-message is needed.*/
visit_alert:= destination { Alert: warning, "Visit Discharge", high, chart,
"Visit Discharge", 4005, send_alert, "No Override Allowed" };
visit_discharge := EVENT{ClientVisitDischarge User ClientVisit };
/***************************************************************************************/
/* This block executes only when this MLM is called by the editor */
if called_by_editor then
visit_obj := read last
{ ClientVisit: THIS };
EvokingObject := visit_obj;
EvokingObject.dischargedtm := "12-26-2012 14:07:00" as time;
Bk_Loc_Name := "ER-2401";
Bk_Loc_GUid := "4000001081061001";
Bk_VisitStatus := "ADM";
Bk_TypeCode := "Inpatient";
else
/* Get the backup Object */
(backup_obj) := read last {ClientVisit: Backup REFERENCING EvokingObject};
(Bk_VisitStatus) :=
read last {ClientVisit: VisitStatus REFERENCING backup_obj};
endif;
/* Get the Client GUID */
/* Get the ended with data */
//(visit_guid, chart_guid, client_guid,disch_disp,visit_status,current_location,visit_type) :=
// read last {ClientVisit: GUID, ChartGUID, ClientGUID, DischargeDisposition,VisitStatus,CurrentLocation,TypeCode REFERENCING EvokingObject};
(visit_guid, chart_guid, client_guid,disch_disp,visit_status,current_location,visit_type,DischargeDtm, AdmitDtm) :=
read last {ClientVisit: GUID, ChartGUID, ClientGUID, DischargeDisposition,VisitStatus,CurrentLocation,TypeCode,DischargeDtm,AdmitDtm REFERENCING EvokingObject};
LOShours := (((DischargeDtm - AdmitDtm) / 60 seconds) / 60) formatted with "%.2f";
patient_type_change_post_discharge_guid := read last {"select o.guid from cv3clientvisit cv with (nolock) "
|| " inner join cv3order o with (nolock) on cv.clientguid = o.clientguid "
|| " and cv.chartguid = o.chartguid and cv.guid = o.clientvisitguid and o.name = {{{SINGLE-QUOTE}}}Patient Type Change Post Discharge{{{SINGLE-QUOTE}}} "
|| " where cv.ClientGUID = " || sql(client_guid)
|| " and cv.ChartGUID = " || sql(chart_guid)
|| " and cv.GUID = " || sql(visit_guid)
|| " and o.OrderStatusCode = {{{SINGLE-QUOTE}}}AUA1{{{SINGLE-QUOTE}}} "};
exist_order := read last {"select name from Cv3Order where (name = " || SQL(discharge_order)
|| " or name = " || SQL(expired_order) || "or name = " || SQL(discharge_observation_order) || ")"
|| " and ClientGUID = " || SQL(client_guid)
|| " and ChartGUID = " || SQL(chart_guid)
|| " and ClientVisitGUID= " || SQL(visit_guid)
|| " and active = 1 "
|| " and OrderStatusLevelNum > 15 "
|| " and OrderStatusLevelNum not in (69, 70) "
};
order_bad := false;
dc_orderrec_GUID := read last {"select guid from CV3OrderReconcile with (nolock) "
|| " where clientguid = " || sql(client_guid)
|| " and chartguid = " || sql(chart_guid)
|| " and ClientVisitGUID = " || sql(visit_guid)
|| " and reconciletypecode = {{{SINGLE-QUOTE}}}discharge{{{SINGLE-QUOTE}}} "
|| " and ReconcileStatusType = 2 "};
// 2008-07-10 RS Added to override order checking if patient is already discharged. Note we use the backup object in this scenario
// 2018-04-09 DW Also exclude recurring patients from this "discarge order" logic
If Bk_VisitStatus = "DSC" or visit_type = "recurring" then
order_bad := false;
else
if exist exist_order then
Is_Exp := read last {" Select isexpired from CV3DischargeDisposition "
|| " where code = " || SQL(disch_disp)
|| " and active = 1 "
};
If (exist_order = discharge_order) and (Is_Exp = true) then
order_entered := "\n" || "\n" || " You are discharging this patient as: {{{SINGLE-QUOTE}}}" || disch_disp || "{{{SINGLE-QUOTE}}}"
|| "\n No {{{SINGLE-QUOTE}}}Expired{{{SINGLE-QUOTE}}} order has been placed for this visit. "
|| "\n\n There is, however, an active {{{SINGLE-QUOTE}}}Discharge{{{SINGLE-QUOTE}}} order for this visit "
;
order_bad := true;
elseif (exist_order = expired_order) and (Is_Exp = False) then
order_entered := "\n" || "\n" ||" You are discharging this patient to: {{{SINGLE-QUOTE}}}" || disch_disp || "{{{SINGLE-QUOTE}}}"
|| "\n No {{{SINGLE-QUOTE}}}Discharge{{{SINGLE-QUOTE}}} order has been placed for this visit."
|| "\n\n There is, however, an active {{{SINGLE-QUOTE}}}Expired{{{SINGLE-QUOTE}}} order for this visit ";
order_bad := true;
else
order_entered := " ";
order_bad := false;
endif;
else
order_entered := "\n" || "\n" || " No {{{SINGLE-QUOTE}}}Discharge{{{SINGLE-QUOTE}}} or {{{SINGLE-QUOTE}}}Expired{{{SINGLE-QUOTE}}} order has been placed for the visit. ";
order_bad := true;
endif;
endif;
// 12/2/08 DW changed criteria for identifying incomplete registration from print location to reg clerk initials
// 08/22/17 DW changed criterai to utilize the "iscompleteregistration" flag
/*
reg_complete := read last {"select typecode from cv3commentdeclaration where typecode = " || SQL(reg_initials)
|| " and ClientGUID = " || SQL(client_guid)
|| " and ChartGUID = " || SQL(chart_guid)
|| " and ClientVisitGUID= " || SQL(visit_guid)
|| " and active = 1 "
};
*/
reg_complete := read last {"
select vr.IsCompleteRegistration
from SXAAMVisitRegistration vr with (nolock)
where vr.IsCompleteRegistration = 1 and vr.ClientVisitGUID = " || visit_guid || " "
};
if exist reg_complete then complete_registration := " ";
else complete_registration := "\n" || "\n" || " The registration was not completed by the registrar. ";
endif;
// 07/28/2010 DW added criteria to look for missing discharge time
obs_disch_incomplete_flag :=false;
obs_disch_miss_date,obs_disch_miss_time := read last {"select top 1 isnull (requesteddate,{{{SINGLE-QUOTE}}}date missing{{{SINGLE-QUOTE}}}), isnull (requestedtime,{{{SINGLE-QUOTE}}}time missing{{{SINGLE-QUOTE}}}) "
|| " from cv3order with (nolock)"
|| " where name = {{{SINGLE-QUOTE}}}Discharge{{{SINGLE-QUOTE}}} "
|| " and ClientGUID = " || SQL(client_guid)
|| " and ChartGUID = " || SQL(chart_guid)
|| " and ClientVisitGUID= " || SQL(visit_guid)
|| " and active = 1 and orderstatuscode <> {{{SINGLE-QUOTE}}}DISC{{{SINGLE-QUOTE}}} and orderstatuscode <> {{{SINGLE-QUOTE}}}COMP{{{SINGLE-QUOTE}}} and orderstatuscode <> {{{SINGLE-QUOTE}}}CANC{{{SINGLE-QUOTE}}} "
|| " order by requesteddtm desc "
};
if (obs_disch_miss_date = "date missing" or obs_disch_miss_time = "time missing")
and visit_type = "Observation" and current_location matches pattern "4B-%"
then obs_disch_incomplete_flag :=true;
obs_disch_message := "\n" || "\n" || " The {{{SINGLE-QUOTE}}}Discharge{{{SINGLE-QUOTE}}} order does not have an effective date / time. "
|| "\n Please modify this order with the appropriate date and time. ";
else obs_disch_message := " ";
endif;
/*
if (order_bad = false) and exist reg_complete and (obs_disch_incomplete_flag = false) then
reportname := "PatDischargeInst_MLM"; logicalprinter := ""; physicalprinter:= "PDF_RAS";
void := call Report_Print_MLM with(reportname, logicalprinter, physicalprinter);
else
break;
endif;
*/
// 10.07.2019 DW CSR# 38769 - Discharge Opsu, Endo, MLSC (Temporarily override the requirmement to enter a discharge order for SCD patients
sdc_patient := read {"
select typecode
from CV3ActiveVisitList with (nolock)
where typecode = {{{SINGLE-QUOTE}}}sdc{{{SINGLE-QUOTE}}} and CurrentLocation in ({{{SINGLE-QUOTE}}}MTLSC{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}ENDO{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}St. Clair Hospital Anc{{{SINGLE-QUOTE}}})
and ClientGUID = " || client_guid || " and ChartGUID = " || chart_guid || " and GUID= " || visit_guid || "
"};
if exist sdc_patient then order_bad := false; endif;
// CCDA TRANSMISSION SECTION
// Gather some information for all CCDA document processing
SCMEnvironment := read last
{ " SELECT "
||" case when substring (value, 28,1) = {{{SINGLE-QUOTE}}}1{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}Production{{{SINGLE-QUOTE}}} "
||" when substring (value, 28,1) = {{{SINGLE-QUOTE}}}2{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}Test{{{SINGLE-QUOTE}}} "
||" when substring (value, 28,1) = {{{SINGLE-QUOTE}}}3{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}Training{{{SINGLE-QUOTE}}} "
||" when substring (value, 28,1) = {{{SINGLE-QUOTE}}}4{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}Development{{{SINGLE-QUOTE}}} "
||" else {{{SINGLE-QUOTE}}}Other{{{SINGLE-QUOTE}}} "
||" end "
||" FROM HVCEnvProfile with (nolock) "
||" WHERE Code = {{{SINGLE-QUOTE}}}ClientOID{{{SINGLE-QUOTE}}} "
||" AND HierarchyCode = {{{SINGLE-QUOTE}}}Documents|Continuity of Care{{{SINGLE-QUOTE}}}"};
// 04.25.2019 DW CSR# 36767 - 18.4
// This code was introduced on 04/19/2018 when Train and Dev were swapped (originally Train was 4 and Dev was 3). Was it a mistake?
// ||" when substring (value, 28,1) = {{{SINGLE-QUOTE}}}4{{{SINGLE-QUOTE}}} then {{{SINGLE-QUOTE}}}Test{{{SINGLE-QUOTE}}} "
PsychPatient := read
{
" Select currentlocation from cv3clientvisit with (nolock) "
|| " Where ClientGUID = " || sql(client_guid) || " AND ChartGUID = " || SQL(chart_guid)
|| " AND GUID = " || SQL(visit_guid) || " and currentlocation like {{{SINGLE-QUOTE}}}Psy%{{{SINGLE-QUOTE}}} "
};
DischargeLocation := EVOKINGOBJECT.DischargeLocation;
// CCDA tranmission to nursing homes
// If (visit_type = "Inpatient" or visit_type = "Observation") and (SCMEnvironment = "Production" or SCMEnvironment = "Test") and order_bad = false // updated 11/13/2019
If (visit_type = "Inpatient" or visit_type = "Observation" or visit_type = "Emergency" )and order_bad = false
then
If DischargeLocation matches pattern "Manor Care%" or
DischargeLocation = "Concordia" or
DischargeLocation = "Home with Family Home Health" or
DischargeLocation = "Baptist Home" or
DischargeLocation = "Baptist Home PCH" or
DischargeLocation = "Providence Point"
then
If DischargeLocation = "Manor Care Bethel Park" then DirectAddress := "BethelPark@hcr-manorcaredirect.com";
ElseIf DischargeLocation = "Manor Care Greentree" then DirectAddress := "Greentree@hcr-manorcaredirect.com";
ElseIf DischargeLocation = "Manor Care Peters Township" then DirectAddress := "PetersTownship@hcr-manorcaredirect.com";
ElseIf DischargeLocation = "Manor Care Whitehall Borough" then DirectAddress := "WhitehallBorough@hcr-manorcaredirect.com";
ElseIf DischargeLocation = "Concordia" then DirectAddress := "CCSNClinical@cabot.netsmartdirect.net";
ElseIf DischargeLocation = "Home with Family Home Health" then DirectAddress := "familyhomehealthservices@direct.medalliesmail.com";
ElseIf DischargeLocation = "Baptist Home" then DirectAddress := "baptisthomessociety@sch.allscriptsdirect.net";
ElseIf DischargeLocation = "Baptist Home PCH" then DirectAddress := "baptisthomessociety@sch.allscriptsdirect.net";
ElseIf DischargeLocation = "Providence Point" then DirectAddress := "providencepoint@sch.allscriptsdirect.net";
endif;
Transport := TRUE;
TransportType := "DIRECT";
CCDAReport := "CCDA Summary of Care";
CCD_MLM := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_CCDA_CREATE_AND_TRANSPORT{{{SINGLE-QUOTE}}};
void := call CCD_MLM with client_guid,chart_guid,visit_guid,CCDAReport,Transport,SCMEnvironment,DirectAddress,TransportType;
endif;
endif;
// CCDA tranmission to individual physician
If (SCMEnvironment = "Production" or SCMEnvironment = "Test") and order_bad = false
then
direct_address := read {"
select oud.value
from cv3ordercatalogmasteritem ocmi with (nolock)
join cv3order o with (nolock) on o.ordercatalogmasteritemguid = ocmi.guid and o.ClientGUID = " || client_guid || " and o.ChartGUID = " || chart_guid || " and o.ClientVisitGUID = " || visit_guid || "
join CV3OrderUserData oud with (nolock) on o.ClientGUID = oud.ClientGUID and o.GUID = oud.OrderGUID and oud.UserDataCode like {{{SINGLE-QUOTE}}}SCH_DI_DirectAddress%{{{SINGLE-QUOTE}}}
where ocmi.name = {{{SINGLE-QUOTE}}}Discharge Follow-Up Visits{{{SINGLE-QUOTE}}} and o.OrderStatusLevelNum > 15 and o.OrderStatusLevelNum not in ({{{SINGLE-QUOTE}}}69{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}70{{{SINGLE-QUOTE}}})
order by o.CreatedWhen desc
"};
If exist direct_address
then
Transport := TRUE;
TransportType := "DIRECT";
CCDAReport := "CCDA Summary of Care";
for i in 1 seqto count (direct_address) do
DirectAddress := direct_address[i];
CCD_MLM := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_CCDA_CREATE_AND_TRANSPORT{{{SINGLE-QUOTE}}};
void := call CCD_MLM with client_guid,chart_guid,visit_guid,CCDAReport,Transport,SCMEnvironment,DirectAddress,TransportType;
enddo;
endif;
endif;
// Vistit Discharge Document generation
If (visit_type = "Inpatient" or visit_type = "Observation" or visit_type = "Emergency" ) and not exist PsychPatient and order_bad = false
then
Transport := FALSE;
TransportType := "NA";
CCDAReport := "CCDA Patient Discharge";
CCD_MLM := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_CCDA_CREATE_AND_TRANSPORT{{{SINGLE-QUOTE}}};
void := call CCD_MLM with client_guid,chart_guid,visit_guid,CCDAReport,Transport,SCMEnvironment,DirectAddress,TransportType;
endif;
// CCHIE transmission
If (SCMEnvironment = "Production" or SCMEnvironment = "Development") and not exist PsychPatient and order_bad = false
then
Transport := TRUE;
TransportType := "XDS";
CCDAReport := "CCDA Post Discharge for CCHIE";
CCD_MLM := MLM {{{SINGLE-QUOTE}}}SCH_FUNC_CCDA_CREATE_AND_TRANSPORT{{{SINGLE-QUOTE}}};
void := call CCD_MLM with client_guid,chart_guid,visit_guid,CCDAReport,Transport,SCMEnvironment,DirectAddress,TransportType;
endif;
// Look for Physician "Conditional Discharge" charges
if (order_bad = false) and exist reg_complete and (obs_disch_incomplete_flag = false)
then
// Find conditional orders entered today
(ordername1, orderguid1, charge1, charge_date, user_guid,ordername2, diagnosislist, cosigner ) := read last {"select "
|| " o.name, o.guid, an.Name, substring (convert(char(10), o.entered,110),7,4) + {{{SINGLE-QUOTE}}}-{{{SINGLE-QUOTE}}} + substring (convert(char(10), o.entered,110),0,6), "
|| " o.UserGUID, substring (oud.value, 6, len(oud.value)-5) , "
|| " (select top 1 oud2.value from CV3OrderUserData oud2 with (nolock) where oud2.orderguid = o.guid and oud2.UserDataCode = {{{SINGLE-QUOTE}}}CHG_MDBill_Dx{{{SINGLE-QUOTE}}}),"
|| " isnull ((select top 1 oud3.value from CV3OrderUserData oud3 with (nolock) where oud3.orderguid = o.guid and oud3.UserDataCode = {{{SINGLE-QUOTE}}}CHG_Cosigner{{{SINGLE-QUOTE}}}), {{{SINGLE-QUOTE}}} {{{SINGLE-QUOTE}}}) "
|| " from cv3ordercatalogmasteritem ocmi with (nolock) "
|| " join cv3order o with (nolock) on o.ordercatalogmasteritemguid = ocmi.guid "
|| " join cv3organizationalunit ou with (nolock) on ou.guid = ocmi.orgunitguid "
|| " join CV3AncillaryName an with (nolock) on an.MainCatItemGUID = ocmi.GUID "
|| " join CV3OrderUserData oud with (nolock) ON oud.orderguid = o.guid "
|| " where o.ClientGUID = " || SQL(client_guid) || " and o.ChartGUID= " || SQL(chart_guid) || " and o.ClientVisitGUID = " || SQL(visit_guid) || " and "
|| " o.OrderStatusLevelNum >= 15 and o.OrderStatusLevelNum not in (69, 70) "
|| " and o.typecode = {{{SINGLE-QUOTE}}}other{{{SINGLE-QUOTE}}} and ou.Description = {{{SINGLE-QUOTE}}}physician{{{SINGLE-QUOTE}}} and CodingStd = {{{SINGLE-QUOTE}}}CHGMD{{{SINGLE-QUOTE}}} "
|| " and oud.UserDataCode = {{{SINGLE-QUOTE}}}CHG_MDBill_Comment{{{SINGLE-QUOTE}}} "
|| " and convert(char(10), getdate(),20) = convert(char(10), o.entered,20) "
|| " order by o.entered desc "
};
locationGuid := read last {"SELECT CurrentLocationGUID, touchedWhen"
|| " FROM CV3ClientVisit with (nolock) "
|| " WHERE GUID = " || Sql(visit_guid) || " AND ClientGUID = " || Sql(client_guid)
, primaryTime = touchedWhen};
// if exists ordername2 and not exists ordername2onfile
if exists ordername2
then
orderplaced := "false";
try
client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visit_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}});
care_provider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((user_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}});
location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((locationGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}});
order_catalog_obj := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with (ordername2);
endtry;
catch Exception ex
error_occurred := true;
error_message := "{{+R}}CommonData: {{-R}}\n" || ex.Message || "\n\n";
if order_catalog_obj is NOT Null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif;
if location_obj IS NOT Null then void := call location_obj.Dispose; location_obj := null; endif;
if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif;
if client_visit_obj IS NOT Null then void := call client_visit_obj.Dispose; client_visit_obj := null; endif;
endcatch;
try
Order_Creation_Reason := "Physician Charge";
RequestingSource := "";
SessionType := "Standard";
SessionReason := "";
Order_Obj := call {{{SINGLE-QUOTE}}}GeneralOrder{{{SINGLE-QUOTE}}}.CreateGeneralOrder
with client_visit_obj,
order_catalog_obj,
Order_Creation_Reason,
care_provider_obj,
RequestingSource,
SessionType,
SessionReason,
location_obj,
"Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}};
orderplaced := "true";
endtry;
catch Exception ex
error_occurred := true;
error_message := "{{+R}}New Other Order: {{-R}}\n" || ex.Message || "\n\n";
if Order_Obj IS NOT Null then void := call Order_Obj.Dispose; Order_Obj := null; endif;
endcatch;
diagnosis_val := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue<String>{{{SINGLE-QUOTE}}} with "CHG_MDBill_Dx","ICD09 " || diagnosislist;
// 35130 Upgrade SCM to version 16.3
// dateofsvc_val := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue<Nullable<DateTime>>{{{SINGLE-QUOTE}}} with "CHG_SVC_DATE",charge_date as time;
dateofsvc_val := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue<Nullable<DateTime>>{{{SINGLE-QUOTE}}} with "CHG_SVC_DATE",(charge_date as time)as{{{SINGLE-QUOTE}}}System.DateTime{{{SINGLE-QUOTE}}};
cosigner_val := call Order_Obj.{{{SINGLE-QUOTE}}}SetEnterpriseDefinedDataItemValue<String>{{{SINGLE-QUOTE}}} with "CHG_Cosigner",cosigner;
void := call Order_Obj.Save;
if order_catalog_obj IS NOT Null then void := call order_catalog_obj.Dispose; order_catalog_obj := null; endif;
if location_obj IS NOT Null then void := call location_obj.Dispose; location_obj := null; endif;
if care_provider_obj IS NOT Null then void := call care_provider_obj.Dispose; care_provider_obj := null; endif;
if client_visit_obj IS NOT Null then void := call client_visit_obj.Dispose; client_visit_obj := null; endif;
// If the order was successfully placed, launch the Charge Builder App which will delete the conditional order
if orderplaced = "true"
then
problemlist := "SCM-Discharge01-01-2015#" || orderguid1 || "#" || user_guid ; // Upon discarge, we send GUIDS
using "PhysicianChargeBuilder";
test:= new net_object {{{SINGLE-QUOTE}}}PhysicianChargeBuilder.PhysicianChargeBuilderForm{{{SINGLE-QUOTE}}} with (problemlist);
endif;
endif;
endif; // Physician "Conditional Discharge" charges section
;;
evoke: visit_discharge ;
;;
logic:
// Launch the Charge Builder App which will delete the conditional order (it will be reported as a credit to the physician billing system)
if orderplaced = "true"
then
oeUnsigned:=CALL test.ShowDialog;
return_string:= test.text;
endif;
// Determine whether to generate a Discharge Instructions PDF
if (order_bad = false) and exist reg_complete and (obs_disch_incomplete_flag = false)
and Bk_VisitStatus = "ADM" and disch_disp <> "DECEASED"
and (visit_type = "Inpatient" or visit_type = "Observation")
and EvokingObject.dischargedtm IS WITHIN past 24 hours then
reportname := "PatDischargeInst_MLM"; logicalprinter := "PDFHL7"; physicalprinter:= "";
void := call Report_Print_MLM with(reportname, logicalprinter, physicalprinter);
endif;
missingDCRec := false;
// Determine if Order Rec needs completed and also print DC Summary if exists
if (patient_type_change_post_discharge_guid is null
and ((LOShours as number) >= 48) and (visit_type = "Inpatient" or visit_type = "Observation")
and ((current_location matches pattern "infus%") = false))
then
if disch_disp = "DECEASED" or disch_disp = "Against Medical Advice" then
void := CALL DCSummmary_Print_MLM with (client_guid,chart_guid,visit_guid,"Day of Discharge%",null);
else
if dc_orderrec_GUID is null or dc_orderrec_GUID = "" then
missingDCRec := true;
msg_Missing_DCRec := "\n" || "\n" || " {{{SINGLE-QUOTE}}}Discharge{{{SINGLE-QUOTE}}} Order Reconiliation is incomplete. ";
else
missingDCRec := false;
msg_Missing_DCRec := " ";
void := CALL DCSummmary_Print_MLM with (client_guid,chart_guid,visit_guid,"Day of Discharge%",null);
endif;
endif;
endif;
// Determine whether to generate an alert
if (order_bad = false) and exist reg_complete and (obs_disch_incomplete_flag = false) /*and missingDCRec = false*/ then
conclude false;
else
conclude true;
endif;
conclude true;
;;
action:
write "This visit cannot be discharged for the following reason(s)" || order_entered || complete_registration || obs_disch_message || msg_Missing_DCRec at visit_alert;
;;
end:

View File

@@ -0,0 +1,412 @@
maintenance:
maintenance:
title: SC Visit Transfer ;;
filename: SC_Visit_Transfer;;
arden: version 2;;
version: 4.50;;
institution: St Clair;;
author: Robert Spence;;
specialist: Robert Spence;;
date: 2007-03-22;;
validation: testing;;
library:
purpose: Do not allow a patient to be transfered via the SCM application
if the starting location is not valid
;;
explanation: When a user selects {{{SINGLE-QUOTE}}}OK{{{SINGLE-QUOTE}}} in change location (Confirm Transfer) in the SCM application
and the patient is not already in house,
a hard stop alert will display
Change History
Robert 03.29.2007 - Added logic to allow ER to Psych or ER to IRU
03.29.2007 - Also logic for Psych to ER and IRU to ER
03.02.2010 - Addded logic to trap for release of temp and change to new bed
DW 12.16.2010 - Added logic for MRSA ordering
JML 05.24.2013 - WO #158012 - Restrict transfer from Infusion, OR, and FBC.
STH 04.14.2016 - CSR#: 31256 - Update to allow SDC patients to be transfered to/from all units except IRU and PSYE (there is already logic to handle IRU and PSYE locations).
I just commented out the SDC visittype from checking the "bad patient" logic to prevent transfering to/from most locations. {Go-Live 4/25/2016}.
JML 02.01.2017 - WO #2545984 - Cancel Discharge events now evoke ClientVisitModify event. Added logic to not process this MLM
if previous VisitStatus = DSC.
DW 08.29.2017 - CSR# 36214 - SCM AM Registration
- Commented out IRU sections
- Changed the logic to only fire the "from / to bedded unit" logic on non (clinic or preclinic) patients.
- Cleaned up formatting for readability (Ultra edit compare will show many diffreneced even though the differences are harmless formatting changes)
- Some routines will not be processed for users other than in the Registration, HIS, and Laboratory departments
JML 01.29.2018 - CSR# 26413 - Modified code based on process changes for REG / SCHED activation:
- Allow nurses to Check In / Arrive Infusion patients based on a pre-admit location of {{{SINGLE-QUOTE}}}Infusion{{{SINGLE-QUOTE}}}.
- Move OR code logic to allow nurses to Check in / Arrive SSOP & Outpatient Surgical patients, using pre-admit location = "OR" and
"St. Clair Hospital Anc"
JML 02.19.2018 - CSR# 26413 - Modified code to accommodate SDC patient types now registered as OBS patients. Conditionally checking for service type = SSOP to allow nursing to arrive patients into
an OR bed.
;;
keywords: Transfer
;;
knowledge:
type: data-driven;;
data:
log_execution_info:= false;
send_alert := "DoNotSend";
stop_Message := "Test";
Hard_Stop:=False;
visit_alert := destination { Alert: warning, "Visit Transfer", high, chart,"Visit Transfer", 4005, send_alert, "No Override Allowed" };
visit_transfer:= event{ClientVisitModify User ClientVisit}; // where LocationStatusChange = "Confirm Transfer"};
standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
include standard_libs;
using "ObjectsPlusXA.SCM.Forms";
using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms";
/* This block executes only when this MLM is called by the editor */
if called_by_editor then
visit_obj := read last { ClientVisit: THIS };
EvokingObject := visit_obj;
Bk_Loc_Name := "ER-2401";
Bk_Loc_GUid := "4000001081061001";
Bk_VisitStatus := "ADM";
Bk_TypeCode := "Inpatient";
else
/* Get the backup Object */
(backup_obj) := read last {ClientVisit: Backup REFERENCING EvokingObject};
(Bk_Loc_Name, Bk_Loc_GUID, Bk_VisitStatus,Bk_TypeCode,Bk_TemporaryLocation, Bk_ServiceGuid) := read last {ClientVisit: CurrentLocation,CurrentLocationGUID,VisitStatus,TypeCode, TemporaryLocation, ServiceGUID REFERENCING backup_obj};
endif;
/* Get the ended with data */
(To_Loc_Name,To_Loc_GUID,To_VisitStatus,To_TypeCode,To_TemporaryLocation,VisitGuid) := read last {ClientVisit: CurrentLocation,CurrentLocationGUID,VisitStatus,TypeCode,TemporaryLocation,guid REFERENCING EvokingObject};
Temp_Loc_Prob:=False;
badPatient := False;
(UserGUID ) := read last { UserInfo: GUID };
// Determine if the user is from Registration, HIS, or Laboratory. These users will not recieve the hard stop related to some sections of the MLM.
(UserDepartment) := read last {"
select ou.name
from CV3User u with (nolock)
join cv3organizationalunit ou on ou.guid = u.orgunitguid
where " || UserGuid || " = u.guid
"
};
(PatientRegistration_Service) := read last { "SELECT s.Description FROM CV3Service s WITH (NOLOCK) where s.GUID = " || SQL(Bk_ServiceGuid) };
if (UserDepartment = "Registration Department" or UserDepartment = "Laboratory" or UserDepartment = "Eclipsys Corporation") then
UserDepartmentAlertOverride := true;
else
UserDepartmentAlertOverride := false;
endif;
//If ((Bk_Loc_Name = To_Loc_Name) OR (Bk_VisitStatus = "DSC"))// or (To_Loc_Name matches pattern "Room%"))
If ( ( Bk_Loc_Name = To_Loc_Name ) OR ( Bk_VisitStatus = "DSC" ) ) then
Hard_Stop := False; // This insures that the location is the only change here.
else
// Gather Room Lists
// IRU_Room_List := read {"select name from Cv3Location where name like {{{SINGLE-QUOTE}}}IRU%{{{SINGLE-QUOTE}}} and IsClientLocation = 1 and TypeCode = {{{SINGLE-QUOTE}}}Bed{{{SINGLE-QUOTE}}} order by name "};
Psych_Room_List := read {"select name from Cv3Location where name like {{{SINGLE-QUOTE}}}Psy%{{{SINGLE-QUOTE}}} and IsClientLocation = 1 and TypeCode = {{{SINGLE-QUOTE}}}Bed{{{SINGLE-QUOTE}}} order by name "};
ER_Room_List := read {"select name from Cv3Location where name like {{{SINGLE-QUOTE}}}ER-%{{{SINGLE-QUOTE}}} and IsClientLocation = 1 and TypeCode = {{{SINGLE-QUOTE}}}Bed{{{SINGLE-QUOTE}}} order by name "};
FBC_Room_List := read {"SELECT Name FROM CV3Location WHERE Name LIKE {{{SINGLE-QUOTE}}}FBC-%{{{SINGLE-QUOTE}}} AND IsClientLocation = 1 AND TypeCode = {{{SINGLE-QUOTE}}}Bed{{{SINGLE-QUOTE}}} ORDER BY Name"};
INFUSION_Room_List := read {"SELECT Name FROM CV3Location WHERE Name LIKE {{{SINGLE-QUOTE}}}INFUS-%{{{SINGLE-QUOTE}}}AND IsClientLocation = 1 AND TypeCode = {{{SINGLE-QUOTE}}}Bed{{{SINGLE-QUOTE}}} ORDER BY Name "};
OR_Room_List := read {"SELECT Name FROM CV3Location WHERE Name LIKE {{{SINGLE-QUOTE}}}OR-%{{{SINGLE-QUOTE}}} AND IsClientLocation = 1 AND TypeCode = {{{SINGLE-QUOTE}}}Bed{{{SINGLE-QUOTE}}} ORDER BY Name "};
// Determine backup (prior) visit status
If Bk_VisitStatus = "PRE" then
Bk_VisitStatus := "Pre-Admit";
elseif Bk_VisitStatus = "DSC" then
Bk_VisitStatus := "Discharged";
elseif Bk_VisitStatus = "CLS" then
Bk_VisitStatus := "Closed";
elseif Bk_VisitStatus = "ADM" then
Bk_VisitStatus := "Admitted";
endif;
/*
// Keep IRU In IRU (Except ED)
If (Bk_Loc_Name in IRU_Room_List) and (To_Loc_Name not in IRU_Room_List) and (To_Loc_Name Not in ER_Room_List) then
Hard_Stop := True;
Stop_Message := "directly from an IRU bed to another unit" || "\n" || "You must discharge and readmit the patient " || "\n\n" ||
"Current Patient Location is:- " || Bk_Loc_Name|| "\n" || "You are attempting to transfer to:- " || To_Loc_Name;
endif;
If (Bk_Loc_Name Not in IRU_Room_List) and (To_Loc_Name in IRU_Room_List) and (Bk_Loc_Name Not in ER_Room_List) then
Hard_Stop := True;
Stop_Message := "directly from this unit to an IRU bed" || "\n" || "You must discharge and readmit the patient " || "\n\n" ||
"Current Patient Location is:- " || Bk_Loc_Name|| "\n" || "You are attempting to transfer to:- " || To_Loc_Name;
endif;
*/
// Keep Psych In Psych (Except ED)
// From Psych
If (Bk_Loc_Name in Psych_Room_List) and (To_Loc_Name not in Psych_Room_List) and (To_Loc_Name Not in ER_Room_List) then
Hard_Stop := True;
Stop_Message := "directly from a Behavioral Health bed to another unit" || "\n" || "You must discharge and readmit the patient " || "\n\n" ||
"Current Patient Location is:- " || Bk_Loc_Name|| "\n" || "You are attempting to transfer to:- " || To_Loc_Name;
endif;
// To Psych
If (Bk_Loc_Name Not in Psych_Room_List) and (To_Loc_Name in Psych_Room_List) and (Bk_Loc_Name Not in ER_Room_List) then
Hard_Stop := True;
Stop_Message := "directly from this unit to a Behavioral Health bed" || "\n" || "You must discharge and readmit the patient " || "\n\n" ||
"Current Patient Location is:- " || Bk_Loc_Name|| "\n" || "You are attempting to transfer to:- " || To_Loc_Name;
endif;
If (Bk_TypeCode = "Clinic" OR To_Typecode = "Clinic") then
badPatient := True;
endif;
If (Bk_TypeCode = "Pre Clinic" or To_Typecode = "Pre Clinic") then
badPatient := True;
endif;
// Clinic or Pre Clinic patients
If (badPatient = True) then
// Keep FBC In FBC (Except ED)
// From FBC
If (Bk_Loc_Name IN FBC_Room_List) AND (To_Loc_Name NOT IN FBC_Room_List) and (To_Loc_Name NOT IN ER_Room_List) then
Hard_Stop := True;
Stop_Message := "as a " || Bk_Typecode || " patient directly from an FBC bed to another unit" || "\n" || "You must discharge and readmit the patient " || "\n\n" ||
"Current Patient Location is:- " || Bk_Loc_Name|| "\n" || "You are attempting to transfer to:- " || To_Loc_Name;
endif;
// To FBC
If (Bk_Loc_Name NOT IN FBC_Room_List) AND (To_Loc_Name IN FBC_Room_List) AND (Bk_Loc_Name NOT IN ER_Room_List) then
Hard_Stop := True;
Stop_Message := "as a " || To_Typecode || " patient directly from this unit to an FBC bed" || "\n" || "You must discharge and readmit the patient " || "\n\n" ||
"Current Patient Location is:- " || Bk_Loc_Name|| "\n" || "You are attempting to transfer to:- " || To_Loc_Name;
endif;
// Keep Infusion In Infusion (Except ED)
// From Infusion
If (Bk_Loc_Name IN INFUSION_Room_List) AND (To_Loc_Name NOT IN INFUSION_Room_List) AND (To_Loc_Name NOT IN ER_Room_List) then
Hard_Stop := True;
Stop_Message := "as a " || Bk_Typecode || " patient directly from an Infusion bed to another unit" || "\n" || "You must discharge and readmit the patient " || "\n\n" ||
"Current Patient Location is:- " || Bk_Loc_Name|| "\n" || "You are attempting to transfer to:- " || To_Loc_Name;
Endif;
// To Infusion
If (Bk_Loc_Name NOT IN INFUSION_Room_List) AND (Bk_Loc_Name <> "Infusion") AND (To_Loc_Name IN INFUSION_Room_List) AND (Bk_Loc_Name NOT IN ER_Room_List) then
Hard_Stop := True;
Stop_Message := "as a " || Bk_Typecode || " patient directly from this unit to an Infusion bed" || "\n" || "You must discharge and readmit the patient " || "\n\n" ||
"Current Patient Location is:- " || Bk_Loc_Name|| "\n" || "You are attempting to transfer to:- " || To_Loc_Name;
Endif;
// Do not allow Clinic or Pre Clinic patients transferred out of ED to any bed
If (Bk_Loc_Name IN ER_Room_List) AND (To_Loc_Name NOT IN ER_Room_List) then
Hard_Stop := True;
Stop_Message := "as a " || Bk_Typecode || " patient directly from an ER inpatient bed to another unit" || "\n" ||
"Please contact Registration." || "\n\n" || "Current Patient Location is:- " || Bk_Loc_Name|| "\nYou are attempting to transfer to:- " || To_Loc_Name;
Endif;
//Do not allow Clinic or Pre Clinic patients transferred in and out of OR
If (Bk_Loc_Name IN OR_Room_List) AND (To_Loc_Name NOT IN OR_Room_List) AND (To_Loc_Name NOT IN ER_Room_List) then
Hard_Stop := True;
Stop_Message := "as a " || Bk_Typecode || " patient directly from an OR bed to another unit" || "\n" || "You must discharge and readmit the patient " || "\n\n" ||
"Current Patient Location is:- " || Bk_Loc_Name|| "\n" || "You are attempting to transfer to:- " || To_Loc_Name;
Endif;
If (Bk_Loc_Name NOT IN OR_Room_List) AND ( Bk_Loc_Name <> "OR" AND Bk_Loc_Name <> "St. Clair Hospital Anc" ) AND (To_Loc_Name IN OR_Room_List) AND (Bk_Loc_Name NOT IN ER_Room_List) then
Hard_Stop := True;
Stop_Message := "as a " || Bk_Typecode || " patient directly from this unit to an OR bed" || "\n" || "You must discharge and readmit the patient " || "\n\n" ||
"Current Patient Location is:- " || Bk_Loc_Name|| "\n" || "You are attempting to transfer to:- " || To_Loc_Name;
Endif;
else // Not a clinic or pre clinic
//CSR 26413: Build in exception case for SDC and outpatient surgical
//TypeCode = SDC, VisitStatus = PRE, Bk_Loc_Name = OR
//TypeCode = SDC, VisitStatus = PRE, Bk_Loc_Name = St. Clair Hospital Anc
if ( Bk_TypeCode = "SDC" OR PatientRegistration_Service = "SSOP" OR ( Bk_TypeCode = "Inpatient" AND Bk_Loc_Name = "OR" ) ) then
// Keep OR In OR (Except ED)
// To OR
If (Bk_Loc_Name NOT IN OR_Room_List) AND ( Bk_Loc_Name <> "OR" AND Bk_Loc_Name <> "St. Clair Hospital Anc" ) AND (To_Loc_Name IN OR_Room_List) AND (Bk_Loc_Name NOT IN ER_Room_List) then
Hard_Stop := True;
Stop_Message := "as a " || Bk_Typecode || " patient directly from this unit to an OR bed" || "\n" || "You must discharge and readmit the patient " || "\n\n" ||
"Current Patient Location is:- " || Bk_Loc_Name|| "\n" || "You are attempting to transfer to:- " || To_Loc_Name;
Endif;
//All other cases where TypeCode <> Clinic or Pre-Clinic
else
// Is the FROM location a bed?
exist_bedded := read last {"select name from Cv3Location where LocnGrpGUID= " || SQL(Bk_Loc_GUID) || " and TypeCode = {{{SINGLE-QUOTE}}}Bed{{{SINGLE-QUOTE}}} and IsClientLocation = 1 and Name= " || SQL(Bk_Loc_Name) };
If exist exist_bedded then
test:=True;
else
Hard_Stop := True;
Stop_Message := "because this patient is not currently assigned to a bed" || "\n" || "Please verify you have selected the correct visit" || "\n\n" ||
"Current Patient Location is:- " || Bk_Loc_Name || "\n" || "Current patient type is:- " || Bk_TypeCode;
endif;
// Is the TO location a bed?
To_exist_bedded := read last {"select name from Cv3Location where LocnGrpGUID= " || SQL(To_Loc_GUID) || " and TypeCode = {{{SINGLE-QUOTE}}}Bed{{{SINGLE-QUOTE}}} and IsClientLocation = 1 and Name= " || SQL(To_Loc_Name) };
If exist To_exist_bedded then
test:=True;
else
Hard_Stop := True;
Stop_Message := "to an invalid location" || "\n\n" || "You are attempting to transfer to:- " || To_Loc_Name ;
endif;
endif; //Exception case for Surgical Patients (OPSU)
Endif; // Is this a clinic or preclinic ?
// Is the Patient Admitted?
/*
If BK_VisitStatus <> "Admitted" then
Hard_Stop :=True;
Stop_Message := "because this patient is not currently admitted to the hospital" || "\n" || "Please verify you have selected the correct visit" || "\n\n" ||
"Current Patient Location is:- " || Bk_Loc_Name || "\n" || "Current Visit Status is:- " || Bk_VisitStatus ;
endif;
*/
// Now add the extra for temporary location issue with 5.0 SP3 03/02/2010
if Hard_Stop = false then
if Bk_TemporaryLocation is null then
Hard_Stop := false;
else
Hard_Stop := true;
Stop_Message := "{{+R}}You may not clear the Temporary Location {{+B}}" || "AND{{-B}} transfer to a New Location Bed Assignment in one step" ||
"\n\n" || "Please remove the New Location Bed Assignment and Click OK. Then " || "come back and transfer to the New Location Bed Assignment" ;
Temp_Loc_Prob:=True;
endif;
endif;
endif; // If ((Bk_Loc_Name = To_Loc_Name) OR (Bk_VisitStatus = "DSC"))
if Temp_Loc_Prob = False then
Stop_Message:= "You may not transfer this patient " || Stop_Message ;
endif;
// Added for MRSA Project
(ClientVisitGuid, ChartGuid, ClientGuid, CurrentLocation, VisitStatus) := read last {ClientVisit: GUID, ChartGUID, ClientGUID, CurrentLocation, VisitStatus };
(UserGUID ) := read last { UserInfo: GUID };
MRSA_Rules_MLM := mlm {{{SINGLE-QUOTE}}}SCH_Func_MRSA_Order{{{SINGLE-QUOTE}}};
(ScreeningUnit, OrderedToday, OrderedWithin3, Positivescreen, SignificantDTM, StatusCode, ResultValue, MRSAHistory, NursingHomeResidency, AntiInfectivewithin7)
:= call MRSA_Rules_MLM with (ClientVisitGuid, ChartGuid, ClientGuid, CurrentLocation);
If AntiInfectivewithin7 = "Yes" then
ModifierVariable := "Ordered Per Protocol";
else
ModifierVariable := "MRSA Screen Antibiotics";
endif;
FromUnit:= Substring (find "-" in string Bk_Loc_Name)-1 CHARACTERS From Bk_Loc_Name;
ToUnit := Substring (find "-" in string To_Loc_Name)-1 CHARACTERS From To_Loc_Name;
If FromUnit in ("ICU","CVSU","IRU","5A","5E","6E","5G") then
FromScreeningUnit := "Yes";
else
FromScreeningUnit := "No";
endif;
// Override the ScreeningUnit value attained from the called MLM which is not the "to unit" but is the "from unit"
If ToUnit in ("ICU","CVSU","IRU","5A","5E","6E","5G") then
ScreeningUnit := "Yes";
else
ScreeningUnit := "No";
endif;
If VisitStatus = "Adm" and (ScreeningUnit = "Yes" or FromScreeningUnit = "Yes") and FromUnit <> ToUnit and orderedtoday = "No" and Positivescreen = "No" and orderedwithin3 = "No" then
Proceed := "Yes";
else
Proceed := "No";
endif;
SessionType := "Standard";
SessionReason := "";
RequestingSource := "";
user_IDType := "Edstan Number (physician)";
order_Creation_Reason := "From Protocol";
client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((ClientVisitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ;
// user_IDCode := read last {"SELECT IDCode FROM CV3User " || " where GUID = " || UserGUID};
user_IDCode := "infectioncontrol";
RequestingCareProvider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindById with ( user_IDType, (user_IDCode as STRING) );
location_guid := read last {"SELECT CurrentLocationGUID FROM CV3ClientVisit where ClientGUID = " || ClientGUID};
location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((location_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}});
;;
evoke: visit_transfer ;
;;
logic:
// conclude Hard_Stop;
conclude true;
;;
action:
// MRSA Ordering Change
if Hard_Stop = true and UserDepartmentAlertOverride = false then
write Stop_Message at visit_alert;
else
if Proceed = "Yes" then
try
Catalog_Item_Name := "Nasal Screen for MRSA (Infection Control)";
Catalog_Item_Modifier := ModifierVariable;
Catalog_Item_Version := "";
Laboratory_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name;
Parent_DiagnosticOrder_obj := call {{{SINGLE-QUOTE}}}DiagnosticOrder{{{SINGLE-QUOTE}}}.CreateDiagnosticOrder
with client_visit_obj, // ClientVisit ObjectsPlus object
Laboratory_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
if ( Laboratory_catalog_item is NOT NULL ) then
void := call Parent_DiagnosticOrder_obj.Save;
void := call Parent_DiagnosticOrder_obj.Dispose;
void:= call Laboratory_catalog_item.Dispose;
Laboratory_catalog_item:= null;
endif;
endtry;
catch Exception ex
error_occurred := true; error_message := "{{+R}}New Parent Diagnostic order:{{-R}}\n" || ex.Message || "\n\n";
if ( Laboratory_catalog_item is NOT NULL ) then
void:= call Laboratory_catalog_item.Dispose;
Laboratory_catalog_item:= null;
endif;
if ( Parent_DiagnosticOrder_obj is NOT NULL ) then
void:= call Parent_DiagnosticOrder_obj.Dispose;
Parent_DiagnosticOrder_obj:= null;
endif;
Parent_DiagnosticOrder_dest := null;
endcatch;
endif;
endif;
;;
end: