SDAMEVT4 ;ALB/MJK - Appt Event Driver Utilities ;12/1/91
;;5.3;Scheduling;**28,132,1015**;Aug 13, 1993;Build 21
;
COMP(SDHDL,SDAMEVT) ; -- main entry point for compare
N SDORG,SDCHG
S (SDORG,SDCHG)=0
F S SDORG=$O(^TMP("SDEVT",$J,SDHDL,SDORG)) Q:'SDORG D Q:SDCHG
.;
.; -- if overall visit flag is 1
.; then set to 1
.IF $G(^TMP("SDEVT",$J,SDHDL,SDORG,"VISIT CHANGE FLAGS"))[1 S SDCHG=1 Q
.;
.; -- if not a credit stop
.; and visit flags not set then assume data changed
.; then set to 1
.IF SDORG'=4,$G(^TMP("SDEVT",$J,SDHDL,SDORG,"VISIT CHANGE FLAGS"))="" S SDCHG=1 Q
.;
.; -- process orginating types
.I SDORG=1 S SDCHG=$$APPT(SDHDL) Q
.I SDORG=2 S SDCHG=$$AE(SDHDL) Q
.I SDORG=3 S SDCHG=$$DIS(SDHDL) Q
.I SDORG=4 S SDCHG=$$CRSC(SDHDL) Q
COMPQ Q SDCHG
;
APPT(SDHDL) ; -- appt check
N SDCHG,NODE
S SDCHG=$S(SDATA("BEFORE","STATUS")'=SDATA("AFTER","STATUS"):1,1:0)
I 'SDCHG S SDCHG=$$OE(SDHDL,1)
I 'SDCHG F NODE="DPT","SC" I $G(^TMP("SDEVT",$J,SDHDL,1,NODE,0,"BEFORE"))'=$G(^("AFTER")) S SDCHG=1 Q
Q SDCHG
;
AE(SDHDL) ; -- add/edit check
N SDCHG,SDDA,NODE
S SDCHG=$$OE(SDHDL,2)
I 'SDCHG,$G(^TMP("SDEVT",$J,SDHDL,2,"STANDALONE",0,"BEFORE"))'=$G(^("AFTER")) S SDCHG=1
Q SDCHG
;
DIS(SDHDL) ; - disposition check
N SDCHG
S SDCHG=$$OE(SDHDL,3)
I 'SDCHG,$G(^TMP("SDEVT",$J,SDHDL,3,"DIS",0,"BEFORE"))'=$G(^("AFTER")) S SDCHG=1
Q SDCHG
;
CRSC(SDHDL) ; -- credit stop code check
N SDCHG
S SDCHG=$$OE(SDHDL,4)
Q SDCHG
;
OE(SDHDL,SDORG) ; -- compare encounter data
N SDCHG,SDI,NODE,SDOE
S (SDOE,SDCHG)=0
F S SDOE=$O(^TMP("SDEVT",$J,SDHDL,SDORG,"SDOE",SDOE)) Q:'SDOE D Q:SDCHG
.I $G(^TMP("SDEVT",$J,SDHDL,SDORG,"SDOE",SDOE,0,"BEFORE"))'=$G(^("AFTER")) S SDCHG=1 Q
.F NODE="CL" S SDI=0 D Q:SDCHG
..F S SDI=$O(^TMP("SDEVT",$J,SDHDL,SDORG,"SDOE",SDOE,NODE,SDI)) Q:'SDI D Q:SDCHG
...I $G(^TMP("SDEVT",$J,SDHDL,SDORG,"SDOE",SDOE,NODE,SDI,0,"BEFORE"))'=$G(^("AFTER")) S SDCHG=1
OEQ Q SDCHG
;
; -- SEE SDAMEVT0 FOR DOC ON VARIABLES
;
MODE(SDHDL) ; -- can event talk
N Y S Y=""
I $D(ZTQUEUED) S Y=2 ; -- queued job
I Y="",IO'=IO(0) S Y=2 ; -- not home device
S:Y="" Y=$G(SDMODE)
Q $S(Y=0:"DIALOGUE",Y=1:"MONOLOGUE",Y=2:"QUIET",1:"QUIET")
;
MESSAGE(MESSAGE,SDHDL) ; -- show message to user if ok
N SDSENT
I $$MODE()["LOGUE" W !!,MESSAGE S SDSENT=1
Q $G(SDSENT)
;
CHANGE(SDHDL,SDORG,SDFLAGS) ; -- set visit change flags value
S ^TMP("SDEVT",$J,+$G(SDHDL),+$G(SDORG),"VISIT CHANGE FLAGS")=$G(SDFLAGS)
Q
;
SDAMEVT4 ;ALB/MJK - Appt Event Driver Utilities ;12/1/91
+1 ;;5.3;Scheduling;**28,132,1015**;Aug 13, 1993;Build 21
+2 ;
COMP(SDHDL,SDAMEVT) ; -- main entry point for compare
+1 NEW SDORG,SDCHG
+2 SET (SDORG,SDCHG)=0
+3 FOR
SET SDORG=$ORDER(^TMP("SDEVT",$JOB,SDHDL,SDORG))
IF 'SDORG
QUIT
Begin DoDot:1
+4 ;
+5 ; -- if overall visit flag is 1
+6 ; then set to 1
+7 IF $GET(^TMP("SDEVT",$JOB,SDHDL,SDORG,"VISIT CHANGE FLAGS"))[1
SET SDCHG=1
QUIT
+8 ;
+9 ; -- if not a credit stop
+10 ; and visit flags not set then assume data changed
+11 ; then set to 1
+12 IF SDORG'=4
IF $GET(^TMP("SDEVT",$JOB,SDHDL,SDORG,"VISIT CHANGE FLAGS"))=""
SET SDCHG=1
QUIT
+13 ;
+14 ; -- process orginating types
+15 IF SDORG=1
SET SDCHG=$$APPT(SDHDL)
QUIT
+16 IF SDORG=2
SET SDCHG=$$AE(SDHDL)
QUIT
+17 IF SDORG=3
SET SDCHG=$$DIS(SDHDL)
QUIT
+18 IF SDORG=4
SET SDCHG=$$CRSC(SDHDL)
QUIT
End DoDot:1
IF SDCHG
QUIT
COMPQ QUIT SDCHG
+1 ;
APPT(SDHDL) ; -- appt check
+1 NEW SDCHG,NODE
+2 SET SDCHG=$SELECT(SDATA("BEFORE","STATUS")'=SDATA("AFTER","STATUS"):1,1:0)
+3 IF 'SDCHG
SET SDCHG=$$OE(SDHDL,1)
+4 IF 'SDCHG
FOR NODE="DPT","SC"
IF $GET(^TMP("SDEVT",$JOB,SDHDL,1,NODE,0,"BEFORE"))'=$GET(^("AFTER"))
SET SDCHG=1
QUIT
+5 QUIT SDCHG
+6 ;
AE(SDHDL) ; -- add/edit check
+1 NEW SDCHG,SDDA,NODE
+2 SET SDCHG=$$OE(SDHDL,2)
+3 IF 'SDCHG
IF $GET(^TMP("SDEVT",$JOB,SDHDL,2,"STANDALONE",0,"BEFORE"))'=$GET(^("AFTER"))
SET SDCHG=1
+4 QUIT SDCHG
+5 ;
DIS(SDHDL) ; - disposition check
+1 NEW SDCHG
+2 SET SDCHG=$$OE(SDHDL,3)
+3 IF 'SDCHG
IF $GET(^TMP("SDEVT",$JOB,SDHDL,3,"DIS",0,"BEFORE"))'=$GET(^("AFTER"))
SET SDCHG=1
+4 QUIT SDCHG
+5 ;
CRSC(SDHDL) ; -- credit stop code check
+1 NEW SDCHG
+2 SET SDCHG=$$OE(SDHDL,4)
+3 QUIT SDCHG
+4 ;
OE(SDHDL,SDORG) ; -- compare encounter data
+1 NEW SDCHG,SDI,NODE,SDOE
+2 SET (SDOE,SDCHG)=0
+3 FOR
SET SDOE=$ORDER(^TMP("SDEVT",$JOB,SDHDL,SDORG,"SDOE",SDOE))
IF 'SDOE
QUIT
Begin DoDot:1
+4 IF $GET(^TMP("SDEVT",$JOB,SDHDL,SDORG,"SDOE",SDOE,0,"BEFORE"))'=$GET(^("AFTER"))
SET SDCHG=1
QUIT
+5 FOR NODE="CL"
SET SDI=0
Begin DoDot:2
+6 FOR
SET SDI=$ORDER(^TMP("SDEVT",$JOB,SDHDL,SDORG,"SDOE",SDOE,NODE,SDI))
IF 'SDI
QUIT
Begin DoDot:3
+7 IF $GET(^TMP("SDEVT",$JOB,SDHDL,SDORG,"SDOE",SDOE,NODE,SDI,0,"BEFORE"))'=$GET(^("AFTER"))
SET SDCHG=1
End DoDot:3
IF SDCHG
QUIT
End DoDot:2
IF SDCHG
QUIT
End DoDot:1
IF SDCHG
QUIT
OEQ QUIT SDCHG
+1 ;
+2 ; -- SEE SDAMEVT0 FOR DOC ON VARIABLES
+3 ;
MODE(SDHDL) ; -- can event talk
+1 NEW Y
SET Y=""
+2 ; -- queued job
IF $DATA(ZTQUEUED)
SET Y=2
+3 ; -- not home device
IF Y=""
IF IO'=IO(0)
SET Y=2
+4 IF Y=""
SET Y=$GET(SDMODE)
+5 QUIT $SELECT(Y=0:"DIALOGUE",Y=1:"MONOLOGUE",Y=2:"QUIET",1:"QUIET")
+6 ;
MESSAGE(MESSAGE,SDHDL) ; -- show message to user if ok
+1 NEW SDSENT
+2 IF $$MODE()["LOGUE"
WRITE !!,MESSAGE
SET SDSENT=1
+3 QUIT $GET(SDSENT)
+4 ;
CHANGE(SDHDL,SDORG,SDFLAGS) ; -- set visit change flags value
+1 SET ^TMP("SDEVT",$JOB,+$GET(SDHDL),+$GET(SDORG),"VISIT CHANGE FLAGS")=$GET(SDFLAGS)
+2 QUIT
+3 ;