618 lines
28 KiB
Plaintext
618 lines
28 KiB
Plaintext
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:
|