SDPCE ;MJK/ALB - Process PCE Event Data ;31 MAY 2005
;;5.3;Scheduling;**27,91,132,150,244,325,441**;Aug 13, 1993;Build 14
;
; **** See SDPCE0 for variable definitions ****
;
EN ; -- main entry pt for PCE event processing
;
; -- start rt monitor
D:$D(XRTL) T0^%ZOSV
;
N SDVSIT,SDVSIT0,SDEVENT,SDERR,SDCLST,SDCS,SDPCNT,SDVDT,SDELAP
S SDVSIT0=0,SDEVENT="SDEVENT"
; -- process each visit (initially will only be 1)
F S SDVSIT0=$O(^TMP("PXKCO",$J,SDVSIT0)) Q:'SDVSIT0 D
. I $$HISTORIC^VSIT(SDVSIT0) Q
. S SDVSIT("AFTER")=$G(^TMP("PXKCO",$J,SDVSIT0,"VST",SDVSIT0,0,"AFTER")),SDVSIT("BEFORE")=$G(^("BEFORE"))
.;
.; -- new or old visit
. IF SDVSIT("AFTER")]"",SDVSIT("BEFORE")]""!(SDVSIT("BEFORE")="") D ADD(.SDVSIT0,.SDEVENT,.SDERR) Q
.;
.; -- deleted visit
. IF SDVSIT("AFTER")="",SDVSIT("BEFORE")]"" D DEL(.SDVSIT0,.SDEVENT,.SDERR) Q
;
; -- stop rt monitor
IF $D(XRT0) S XRTN=$T(+0) D T1^%ZOSV
;
Q
;
ADD(SDVSIT0,SDEVENT,SDERR) ; -- add/update encounter data
N DFN,SDT,SDCL,SDRESULT,SDTYPE,SDOE,SDDIS,SDPVSIT,SDELAP
; -- get patient/encounter data
D PAT(SDVSIT("AFTER"),.DFN,.SDT,.SDCL)
S SDVSIT=$S($P(SDVSIT("AFTER"),U,12):$P(SDVSIT("AFTER"),U,12),1:SDVSIT0)
; -- get encounter data
S SDOE=$O(^SCE("AVSIT",+SDVSIT,0)),SDDIS=$P($G(^SCE(+SDOE,0)),U,8)
I 'SDDIS,$G(SDOEP) S SDDIS=$P($G(^SCE(+SDOEP,0)),U,8)
;
; -- get elig for visit
S @SDEVENT@("ELIGIBILITY")=$S($P(SDVSIT("AFTER"),U,21):$P(SDVSIT("AFTER"),U,21),1:"")
;
; -- get appt type
S SDELAP=$G(^TMP("PXKCO",$J,SDVSIT0,"VST",SDVSIT0,"ELAP","AFTER"))
S @SDEVENT@("APPT TYPE")=$S($P(SDELAP,U,3):$P(SDELAP,U,3),1:"")
;
; -- get co d/t
S @SDEVENT@("DATE/TIME")=$S($P(SDVSIT("AFTER"),U,18):$P(SDVSIT("AFTER"),U,18),1:"")
;
; -- determine the type of event
IF SDCL,SDCL=+$G(^DPT(DFN,"S",SDT,0)) D
. S @SDEVENT@("EVENT")="CHECK-OUT"
;
ELSE I SDDIS,SDDIS=3 D
. S @SDEVENT@("EVENT")="DISPOSITION"
;
ELSE D Q:$$DELAE()
. S @SDEVENT@("EVENT")="ADD/EDIT CHECK-OUT"
. I SDVSIT S SDPVSIT=SDVSIT D ENCEVENT^PXKENC(SDPVSIT)
;
; -- get user
S @SDEVENT@("USER")=$S($D(^VA(200,+$G(DUZ),0)):+DUZ,1:.5)
D CLASS(.SDVSIT,.SDEVENT)
S @SDEVENT@("VISIT CHANGE FLAGS")=$$CHANGE(.SDVSIT0)
I $G(SDPVSIT),'$D(@SDEVENT@("CLASSIFICATION")) D CLASSAE(SDPVSIT,.SDEVENT)
; -- call api
D API(DFN,SDT,SDCL,.SDEVENT,.SDERR,SDVSIT,"ADDITION")
K ^TMP("PXKENC",$J)
Q
;
DEL(SDVSIT0,SDEVENT,SDERR) ; -- delete co info when visit delete
N DFN,SDT,SDCL
S SDVSIT=$S($P(SDVSIT("AFTER"),U,12):$P(SDVSIT("AFTER"),U,12),1:SDVSIT0)
D PAT(SDVSIT("BEFORE"),.DFN,.SDT,.SDCL)
S @SDEVENT@("USER")=$S($P(SDVSIT("BEFORE"),U,23):$P(SDVSIT("BEFORE"),U,23),1:.5)
S @SDEVENT@("EVENT")="CHECK-OUT DELETE"
D API(DFN,SDT,SDCL,.SDEVENT,.SDERR,SDVSIT,"DELETION")
Q
;
DELAE() ; -- delete standalone encounter if no cpt, dx and providers
N SDDEL
S SDDEL=0
IF '$D(^TMP("PXKENC",$J,SDVSIT,"CPT")),'$D(^("POV")),'$D(^("PRV")) D
. S @SDEVENT@("USER")=$S($P(SDVSIT("BEFORE"),U,23):$P(SDVSIT("BEFORE"),U,23),1:.5)
. S @SDEVENT@("EVENT")="CHECK-OUT DELETE"
. D API(DFN,SDT,SDCL,.SDEVENT,.SDERR,SDVSIT,"DELETION")
. K ^TMP("PXKENC",$J)
. S SDDEL=1
Q SDDEL
;
API(DFN,SDT,SDCL,SDEVENT,SDERR,SDVSIT,SDACT) ;
N SDRET,SDSOR
S SDRET=$$EN^SDAPI(DFN,SDT,SDCL,.SDEVENT,.SDERR,SDVSIT)
;
; -- is it ok to send bulletin if needed
S SDSOR=+$O(^TMP("PXKCO",$J,SDVSIT,"SOR",0))
IF SDSOR,'$P($G(^TMP("PXKCO",$J,SDVSIT,"SOR",SDSOR,0,"AFTER")),U,9) D
. Q
ELSE D
. D BULL^SDPCE2(DFN,SDT,SDCL,.SDEVENT,.SDERR,SDVSIT,SDACT)
Q
;
PAT(SDVSIT0,DFN,SDT,SDCL) ; -- return patient/encounter data for visit
S DFN=+$P(SDVSIT0,U,5),SDT=+SDVSIT0,SDCL=+$P(SDVSIT0,U,22)
Q
;
CLASS(SDVSIT,SDEVENT) ; -- set-up classification data from visit data
N SD800A,SD800B,SDI,CLASS,SDA,SDB
S SD800A=$G(^TMP("PXKCO",$J,SDVSIT,"VST",SDVSIT,800,"AFTER")),SD800B=$G(^("BEFORE"))
; -- process each piece
F SDI=1:1:8 D
. S CLASS=$P("SC^AO^IR^EC^MST^HNC^CV^SHAD",U,SDI),SDA=$P(SD800A,U,SDI),SDB=$P(SD800B,U,SDI)
.; -- changed or same class data
. IF SDA]"",SDB]"" S @SDEVENT@("CLASSIFICATION",$S(SDA'=SDB:"CHANGE",1:"ADD"),CLASS)=$$CLASSVAL(SDA) Q
.; -- new class data
. IF SDA]"",SDB="" S @SDEVENT@("CLASSIFICATION","ADD",CLASS)=$$CLASSVAL(SDA) Q
.; -- deleted class data
. IF SDA="",SDB]"" S @SDEVENT@("CLASSIFICATION","DELETE",CLASS)="" Q
Q
CLASSVAL(Y) ; -- yes/no processing
Q $S(Y=1:"Y",Y=0:"N",1:"??")
;
CLASSAE(SDVSIT,SDEVENT) ; -- set-up classification data from visit data
N SD800A,SD800B,SDI,CLASS,SDA,SDB
S SD800A=$G(^TMP("PXKENC",$J,SDVSIT,"VST",SDVSIT,800,"AFTER")),SD800B=$G(^("BEFORE"))
; -- process each piece
F SDI=1:1:8 D
. S CLASS=$P("SC^AO^IR^EC^MST^HNC^CV^SHAD",U,SDI),SDA=$P(SD800A,U,SDI),SDB=$P(SD800B,U,SDI)
.; -- changed or same class data
. IF SDA]"",SDB]"" S @SDEVENT@("CLASSIFICATION",$S(SDA'=SDB:"CHANGE",1:"ADD"),CLASS)=$$CLASSVAL(SDA) Q
.; -- new class data
. IF SDA]"",SDB="" S @SDEVENT@("CLASSIFICATION","ADD",CLASS)=$$CLASSVAL(SDA) Q
.; -- deleted class data
. IF SDA="",SDB]"" S @SDEVENT@("CLASSIFICATION","DELETE",CLASS)="" Q
Q
;
ELAP(DFN,SC) ; -- This function will return Elig and Appt Type data
; INPUT: DFN - Patient, SC - Clinic IEN
; OUTPUT: Elig ptr^ Elig text^ Appt Ptr^ Appt Text
;
N VAEL,VADM,X,Y,SDAPTYP,SDATD,SDEMP,SDDECOD,SDEC,SDAMBAE
S SDAMBAE=1
;-- get appt type
D TYPE^SDM4
S SDEMP=""
;-- get elig if more than 1
I $O(VAEL(1,0))>0 S SDEMP="" D ELIG^SDM4:"369"[SDAPTYP S SDEMP=$S(SDDECOD:SDDECOD,1:SDEMP)
I 'SDEMP S SDEMP=VAEL(1)
;
Q +SDEMP_U_$P($G(^DIC(8,+SDEMP,0)),U)_U_+SDAPTYP_U_$P($G(^SD(409.1,+SDAPTYP,0)),U)
;
NEW(DATE) ;-- This function will return 1 if SD is turned on for
; Visit Tracking and optionally check if the date is past
; the cut over date for the new PCE interface.
; INPUT : DATE (Optional) Date to check for cut over.
; OUTPUT: 1 Yes, 0 No
N SDRES,SDX,SDY
I '$G(DATE) S DATE=DT
;-- is Scheduling on ?
S SDRES=0,SDY=$$PKGON^VSIT("SD")
;-- if date is it pass cut over?
S SDX=1 I $G(DATE) S SDX=$$SWITCHCK^PXAPI(DATE)
;-- And together
I SDX,SDY S SDRES=1
Q SDRES
;
STATUS(SDVSIT) ; Return status of an encounter
; Input: SDOE = Visit File IEN
; Output: Status of the encounter Internal IEN^External Value
;
N SDINT,SDEXT,SDOE
S SDOE=$O(^SCE("AVSIT",+SDVSIT,0))
S SDINT=$P($G(^SCE(+SDOE,0)),U,12)
S SDEXT=$P($G(^SD(409.63,+SDINT,0)),U)
STATQ Q SDINT_"^"_SDEXT
;
CHANGE(SDVST) ; -- set flags for overall visit change
N SDI,SDFLAGS
;
; -- initalize chnage flags
; -- cpt changed ^ provider data changed ^ dx changed
S SDFLAGS="0^0^0"
;
; -- set cpt change flag
S SDI=0
F S SDI=$O(^TMP("PXKCO",$J,SDVST,"CPT",SDI)) Q:'SDI IF $G(^TMP("PXKCO",$J,SDVST,"CPT",SDI,0,"BEFORE"))'=$G(^("AFTER")) S $P(SDFLAGS,U,1)=1
;
; -- set provider change flag
S SDI=0
F S SDI=$O(^TMP("PXKCO",$J,SDVST,"PRV",SDI)) Q:'SDI IF $G(^TMP("PXKCO",$J,SDVST,"PRV",SDI,0,"BEFORE"))'=$G(^("AFTER")) S $P(SDFLAGS,U,2)=1
;
; -- set dx change flag
S SDI=0
F S SDI=$O(^TMP("PXKCO",$J,SDVST,"POV",SDI)) Q:'SDI IF $G(^TMP("PXKCO",$J,SDVST,"POV",SDI,0,"BEFORE"))'=$G(^("AFTER")) S $P(SDFLAGS,U,3)=1
;
Q SDFLAGS
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDPCE 7264 printed Dec 13, 2024@02:59:28 Page 2
SDPCE ;MJK/ALB - Process PCE Event Data ;31 MAY 2005
+1 ;;5.3;Scheduling;**27,91,132,150,244,325,441**;Aug 13, 1993;Build 14
+2 ;
+3 ; **** See SDPCE0 for variable definitions ****
+4 ;
EN ; -- main entry pt for PCE event processing
+1 ;
+2 ; -- start rt monitor
+3 if $DATA(XRTL)
DO T0^%ZOSV
+4 ;
+5 NEW SDVSIT,SDVSIT0,SDEVENT,SDERR,SDCLST,SDCS,SDPCNT,SDVDT,SDELAP
+6 SET SDVSIT0=0
SET SDEVENT="SDEVENT"
+7 ; -- process each visit (initially will only be 1)
+8 FOR
SET SDVSIT0=$ORDER(^TMP("PXKCO",$JOB,SDVSIT0))
if 'SDVSIT0
QUIT
Begin DoDot:1
+9 IF $$HISTORIC^VSIT(SDVSIT0)
QUIT
+10 SET SDVSIT("AFTER")=$GET(^TMP("PXKCO",$JOB,SDVSIT0,"VST",SDVSIT0,0,"AFTER"))
SET SDVSIT("BEFORE")=$GET(^("BEFORE"))
+11 ;
+12 ; -- new or old visit
+13 IF SDVSIT("AFTER")]""
IF SDVSIT("BEFORE")]""!(SDVSIT("BEFORE")="")
DO ADD(.SDVSIT0,.SDEVENT,.SDERR)
QUIT
+14 ;
+15 ; -- deleted visit
+16 IF SDVSIT("AFTER")=""
IF SDVSIT("BEFORE")]""
DO DEL(.SDVSIT0,.SDEVENT,.SDERR)
QUIT
End DoDot:1
+17 ;
+18 ; -- stop rt monitor
+19 IF $DATA(XRT0)
SET XRTN=$TEXT(+0)
DO T1^%ZOSV
+20 ;
+21 QUIT
+22 ;
ADD(SDVSIT0,SDEVENT,SDERR) ; -- add/update encounter data
+1 NEW DFN,SDT,SDCL,SDRESULT,SDTYPE,SDOE,SDDIS,SDPVSIT,SDELAP
+2 ; -- get patient/encounter data
+3 DO PAT(SDVSIT("AFTER"),.DFN,.SDT,.SDCL)
+4 SET SDVSIT=$SELECT($PIECE(SDVSIT("AFTER"),U,12):$PIECE(SDVSIT("AFTER"),U,12),1:SDVSIT0)
+5 ; -- get encounter data
+6 SET SDOE=$ORDER(^SCE("AVSIT",+SDVSIT,0))
SET SDDIS=$PIECE($GET(^SCE(+SDOE,0)),U,8)
+7 IF 'SDDIS
IF $GET(SDOEP)
SET SDDIS=$PIECE($GET(^SCE(+SDOEP,0)),U,8)
+8 ;
+9 ; -- get elig for visit
+10 SET @SDEVENT@("ELIGIBILITY")=$SELECT($PIECE(SDVSIT("AFTER"),U,21):$PIECE(SDVSIT("AFTER"),U,21),1:"")
+11 ;
+12 ; -- get appt type
+13 SET SDELAP=$GET(^TMP("PXKCO",$JOB,SDVSIT0,"VST",SDVSIT0,"ELAP","AFTER"))
+14 SET @SDEVENT@("APPT TYPE")=$SELECT($PIECE(SDELAP,U,3):$PIECE(SDELAP,U,3),1:"")
+15 ;
+16 ; -- get co d/t
+17 SET @SDEVENT@("DATE/TIME")=$SELECT($PIECE(SDVSIT("AFTER"),U,18):$PIECE(SDVSIT("AFTER"),U,18),1:"")
+18 ;
+19 ; -- determine the type of event
+20 IF SDCL
IF SDCL=+$GET(^DPT(DFN,"S",SDT,0))
Begin DoDot:1
+21 SET @SDEVENT@("EVENT")="CHECK-OUT"
End DoDot:1
+22 ;
+23 IF '$TEST
IF SDDIS
IF SDDIS=3
Begin DoDot:1
+24 SET @SDEVENT@("EVENT")="DISPOSITION"
End DoDot:1
+25 ;
+26 IF '$TEST
Begin DoDot:1
+27 SET @SDEVENT@("EVENT")="ADD/EDIT CHECK-OUT"
+28 IF SDVSIT
SET SDPVSIT=SDVSIT
DO ENCEVENT^PXKENC(SDPVSIT)
End DoDot:1
if $$DELAE()
QUIT
+29 ;
+30 ; -- get user
+31 SET @SDEVENT@("USER")=$SELECT($DATA(^VA(200,+$GET(DUZ),0)):+DUZ,1:.5)
+32 DO CLASS(.SDVSIT,.SDEVENT)
+33 SET @SDEVENT@("VISIT CHANGE FLAGS")=$$CHANGE(.SDVSIT0)
+34 IF $GET(SDPVSIT)
IF '$DATA(@SDEVENT@("CLASSIFICATION"))
DO CLASSAE(SDPVSIT,.SDEVENT)
+35 ; -- call api
+36 DO API(DFN,SDT,SDCL,.SDEVENT,.SDERR,SDVSIT,"ADDITION")
+37 KILL ^TMP("PXKENC",$JOB)
+38 QUIT
+39 ;
DEL(SDVSIT0,SDEVENT,SDERR) ; -- delete co info when visit delete
+1 NEW DFN,SDT,SDCL
+2 SET SDVSIT=$SELECT($PIECE(SDVSIT("AFTER"),U,12):$PIECE(SDVSIT("AFTER"),U,12),1:SDVSIT0)
+3 DO PAT(SDVSIT("BEFORE"),.DFN,.SDT,.SDCL)
+4 SET @SDEVENT@("USER")=$SELECT($PIECE(SDVSIT("BEFORE"),U,23):$PIECE(SDVSIT("BEFORE"),U,23),1:.5)
+5 SET @SDEVENT@("EVENT")="CHECK-OUT DELETE"
+6 DO API(DFN,SDT,SDCL,.SDEVENT,.SDERR,SDVSIT,"DELETION")
+7 QUIT
+8 ;
DELAE() ; -- delete standalone encounter if no cpt, dx and providers
+1 NEW SDDEL
+2 SET SDDEL=0
+3 IF '$DATA(^TMP("PXKENC",$JOB,SDVSIT,"CPT"))
IF '$DATA(^("POV"))
IF '$DATA(^("PRV"))
Begin DoDot:1
+4 SET @SDEVENT@("USER")=$SELECT($PIECE(SDVSIT("BEFORE"),U,23):$PIECE(SDVSIT("BEFORE"),U,23),1:.5)
+5 SET @SDEVENT@("EVENT")="CHECK-OUT DELETE"
+6 DO API(DFN,SDT,SDCL,.SDEVENT,.SDERR,SDVSIT,"DELETION")
+7 KILL ^TMP("PXKENC",$JOB)
+8 SET SDDEL=1
End DoDot:1
+9 QUIT SDDEL
+10 ;
API(DFN,SDT,SDCL,SDEVENT,SDERR,SDVSIT,SDACT) ;
+1 NEW SDRET,SDSOR
+2 SET SDRET=$$EN^SDAPI(DFN,SDT,SDCL,.SDEVENT,.SDERR,SDVSIT)
+3 ;
+4 ; -- is it ok to send bulletin if needed
+5 SET SDSOR=+$ORDER(^TMP("PXKCO",$JOB,SDVSIT,"SOR",0))
+6 IF SDSOR
IF '$PIECE($GET(^TMP("PXKCO",$JOB,SDVSIT,"SOR",SDSOR,0,"AFTER")),U,9)
Begin DoDot:1
+7 QUIT
End DoDot:1
+8 IF '$TEST
Begin DoDot:1
+9 DO BULL^SDPCE2(DFN,SDT,SDCL,.SDEVENT,.SDERR,SDVSIT,SDACT)
End DoDot:1
+10 QUIT
+11 ;
PAT(SDVSIT0,DFN,SDT,SDCL) ; -- return patient/encounter data for visit
+1 SET DFN=+$PIECE(SDVSIT0,U,5)
SET SDT=+SDVSIT0
SET SDCL=+$PIECE(SDVSIT0,U,22)
+2 QUIT
+3 ;
CLASS(SDVSIT,SDEVENT) ; -- set-up classification data from visit data
+1 NEW SD800A,SD800B,SDI,CLASS,SDA,SDB
+2 SET SD800A=$GET(^TMP("PXKCO",$JOB,SDVSIT,"VST",SDVSIT,800,"AFTER"))
SET SD800B=$GET(^("BEFORE"))
+3 ; -- process each piece
+4 FOR SDI=1:1:8
Begin DoDot:1
+5 SET CLASS=$PIECE("SC^AO^IR^EC^MST^HNC^CV^SHAD",U,SDI)
SET SDA=$PIECE(SD800A,U,SDI)
SET SDB=$PIECE(SD800B,U,SDI)
+6 ; -- changed or same class data
+7 IF SDA]""
IF SDB]""
SET @SDEVENT@("CLASSIFICATION",$SELECT(SDA'=SDB:"CHANGE",1:"ADD"),CLASS)=$$CLASSVAL(SDA)
QUIT
+8 ; -- new class data
+9 IF SDA]""
IF SDB=""
SET @SDEVENT@("CLASSIFICATION","ADD",CLASS)=$$CLASSVAL(SDA)
QUIT
+10 ; -- deleted class data
+11 IF SDA=""
IF SDB]""
SET @SDEVENT@("CLASSIFICATION","DELETE",CLASS)=""
QUIT
End DoDot:1
+12 QUIT
CLASSVAL(Y) ; -- yes/no processing
+1 QUIT $SELECT(Y=1:"Y",Y=0:"N",1:"??")
+2 ;
CLASSAE(SDVSIT,SDEVENT) ; -- set-up classification data from visit data
+1 NEW SD800A,SD800B,SDI,CLASS,SDA,SDB
+2 SET SD800A=$GET(^TMP("PXKENC",$JOB,SDVSIT,"VST",SDVSIT,800,"AFTER"))
SET SD800B=$GET(^("BEFORE"))
+3 ; -- process each piece
+4 FOR SDI=1:1:8
Begin DoDot:1
+5 SET CLASS=$PIECE("SC^AO^IR^EC^MST^HNC^CV^SHAD",U,SDI)
SET SDA=$PIECE(SD800A,U,SDI)
SET SDB=$PIECE(SD800B,U,SDI)
+6 ; -- changed or same class data
+7 IF SDA]""
IF SDB]""
SET @SDEVENT@("CLASSIFICATION",$SELECT(SDA'=SDB:"CHANGE",1:"ADD"),CLASS)=$$CLASSVAL(SDA)
QUIT
+8 ; -- new class data
+9 IF SDA]""
IF SDB=""
SET @SDEVENT@("CLASSIFICATION","ADD",CLASS)=$$CLASSVAL(SDA)
QUIT
+10 ; -- deleted class data
+11 IF SDA=""
IF SDB]""
SET @SDEVENT@("CLASSIFICATION","DELETE",CLASS)=""
QUIT
End DoDot:1
+12 QUIT
+13 ;
ELAP(DFN,SC) ; -- This function will return Elig and Appt Type data
+1 ; INPUT: DFN - Patient, SC - Clinic IEN
+2 ; OUTPUT: Elig ptr^ Elig text^ Appt Ptr^ Appt Text
+3 ;
+4 NEW VAEL,VADM,X,Y,SDAPTYP,SDATD,SDEMP,SDDECOD,SDEC,SDAMBAE
+5 SET SDAMBAE=1
+6 ;-- get appt type
+7 DO TYPE^SDM4
+8 SET SDEMP=""
+9 ;-- get elig if more than 1
+10 IF $ORDER(VAEL(1,0))>0
SET SDEMP=""
if "369"[SDAPTYP
DO ELIG^SDM4
SET SDEMP=$SELECT(SDDECOD:SDDECOD,1:SDEMP)
+11 IF 'SDEMP
SET SDEMP=VAEL(1)
+12 ;
+13 QUIT +SDEMP_U_$PIECE($GET(^DIC(8,+SDEMP,0)),U)_U_+SDAPTYP_U_$PIECE($GET(^SD(409.1,+SDAPTYP,0)),U)
+14 ;
NEW(DATE) ;-- This function will return 1 if SD is turned on for
+1 ; Visit Tracking and optionally check if the date is past
+2 ; the cut over date for the new PCE interface.
+3 ; INPUT : DATE (Optional) Date to check for cut over.
+4 ; OUTPUT: 1 Yes, 0 No
+5 NEW SDRES,SDX,SDY
+6 IF '$GET(DATE)
SET DATE=DT
+7 ;-- is Scheduling on ?
+8 SET SDRES=0
SET SDY=$$PKGON^VSIT("SD")
+9 ;-- if date is it pass cut over?
+10 SET SDX=1
IF $GET(DATE)
SET SDX=$$SWITCHCK^PXAPI(DATE)
+11 ;-- And together
+12 IF SDX
IF SDY
SET SDRES=1
+13 QUIT SDRES
+14 ;
STATUS(SDVSIT) ; Return status of an encounter
+1 ; Input: SDOE = Visit File IEN
+2 ; Output: Status of the encounter Internal IEN^External Value
+3 ;
+4 NEW SDINT,SDEXT,SDOE
+5 SET SDOE=$ORDER(^SCE("AVSIT",+SDVSIT,0))
+6 SET SDINT=$PIECE($GET(^SCE(+SDOE,0)),U,12)
+7 SET SDEXT=$PIECE($GET(^SD(409.63,+SDINT,0)),U)
STATQ QUIT SDINT_"^"_SDEXT
+1 ;
CHANGE(SDVST) ; -- set flags for overall visit change
+1 NEW SDI,SDFLAGS
+2 ;
+3 ; -- initalize chnage flags
+4 ; -- cpt changed ^ provider data changed ^ dx changed
+5 SET SDFLAGS="0^0^0"
+6 ;
+7 ; -- set cpt change flag
+8 SET SDI=0
+9 FOR
SET SDI=$ORDER(^TMP("PXKCO",$JOB,SDVST,"CPT",SDI))
if 'SDI
QUIT
IF $GET(^TMP("PXKCO",$JOB,SDVST,"CPT",SDI,0,"BEFORE"))'=$GET(^("AFTER"))
SET $PIECE(SDFLAGS,U,1)=1
+10 ;
+11 ; -- set provider change flag
+12 SET SDI=0
+13 FOR
SET SDI=$ORDER(^TMP("PXKCO",$JOB,SDVST,"PRV",SDI))
if 'SDI
QUIT
IF $GET(^TMP("PXKCO",$JOB,SDVST,"PRV",SDI,0,"BEFORE"))'=$GET(^("AFTER"))
SET $PIECE(SDFLAGS,U,2)=1
+14 ;
+15 ; -- set dx change flag
+16 SET SDI=0
+17 FOR
SET SDI=$ORDER(^TMP("PXKCO",$JOB,SDVST,"POV",SDI))
if 'SDI
QUIT
IF $GET(^TMP("PXKCO",$JOB,SDVST,"POV",SDI,0,"BEFORE"))'=$GET(^("AFTER"))
SET $PIECE(SDFLAGS,U,3)=1
+18 ;
+19 QUIT SDFLAGS
+20 ;