SDC ;MAN/GRR,ALB/LDB,LAB - CANCEL A CLINIC'S AVAILABILITY ;JAN 15, 2016
;;5.3;Scheduling;**15,32,79,132,167,478,487,523,545,627,684,724,758,780,864**;Aug 13, 1993;Build 15
;;Per VHA Directive 6402, this routine should not be modified
N SDATA,SDCNHDL ; for evt dvr
SDC1 K SDLT,SDCP S NOAP="" D LO^DGUTL
S DIC=44,DIC(0)="MEQA",DIC("S")="I $P(^(0),""^"",3)=""C"",'$G(^(""OOS""))",DIC("A")="Select CLINIC NAME: " D ^DIC K DIC("S"),DIC("A") G:'$D(^SC(+Y,"SL")) END^SDC0
S SC=+Y,SL=^("SL"),%DT="AEXF",%DT("A")="CANCEL '"_$P(Y,U,2)_"' FOR WHAT DATE: " D ^%DT K %DT G:Y<0 END^SDC0 ;NAKED REFERNCE - ^SC(IFN,"SL")
S (SD,CDATE)=Y,%=$P(SL,U,6),SI=$S(%="":4,%<3:4,%:%,1:4),%=$P(SL,U,3),STARTDAY=$S($L(%):%,1:8) D NOW^%DTC S SDTIME=%
I '$D(^SC(SC,"ST",SD,1)) W !,*7,"CLINIC DOES NOT MEET ON THAT DAY" G SDC1
K SDRE,SDIN,SDRE1 I $D(^SC(SC,"I")) S SDIN=+^("I"),SDRE=+$P(^("I"),"^",2),Y=SDRE D:Y DTS^SDUTL S SDRE1=$S(SDRE:" to "_Y,1:"")
I $S('$D(SDIN):0,SDIN'>0!(SDIN>SD):0,SDRE'>SD&(SDRE):0,1:1) W !,*7,"Clinic is inactive ",$S('SDRE:"as of ",1:"from ") S Y=SDIN D DTS^SDUTL W Y,SDRE1 G SDC1
I '$D(^SC(SC,"ST",SD,1)) S DH="" D B S ^SC(SC,"ST",SD,1)=$P("SU^MO^TU^WE^TH^FR^SA",U,DOW+1)_" "_$E(SD,6,7)_$J("",SI+SI-6)_DH,^(0)=SD G N
I ^(1)["CANCELLED" W !,"APPOINTMENTS HAVE ALREADY BEEN CANCELLED",!,*7 S ANS="N",SDTIME="*",SDV1=$S($P(^SC(SC,0),"^",15):$P(^(0),"^",15),1:+$O(^DG(40.8,0))) K SDX G ASKL^SDC0 ;NAKED REFERENCE - ^SC(IFN,"ST",Date,1)
;N I '$F(^SC(SC,"ST",SD,1),"[") K:^(1)?2U.E ^SC(SC,"ST",SD) W !,*7,"CLINIC DOES NOT MEET ON THAT DAY" G SDC1 ; KILLs node if not holiday
N I '$F(^SC(SC,"ST",SD,1),"[") W !,*7,"CLINIC DOES NOT MEET ON THAT DAY" G SDC1 ; SD*5.3*684 - Remove KILL on "ST" (PATTERN) node
I $O(^SC(SC,"S",SD))\1-SD W *7,!?5,"NO APPOINTMENTS SCHEDULED" S NOAP=1 G W
W !,"FIRST, I'LL LIST THE EXISTING APPOINTMENTS",!
K DUOUT,DTOUT D ^SDC1 I $D(DUOUT)!$D(DTOUT) D END^SDC0 Q
I ^SC(SC,"ST",SD,1)["X" G ^SDC2
W S DH=0,%="" W !,"WANT TO CANCEL THE WHOLE DAY" D YN^DICN I '% W !,"REPLY YES (Y) OR NO (N)" G W
I %=1 G WP:$$COED^SDC4(SC,SD,SD+.2359,1),ALL
Q:%<1
WP S %="" W !,"WANT TO CANCEL PART OF THE DAY" D YN^DICN I '% W !,"REPLY YES (Y) OR NO (N)" G WP
Q:(%-1)
F R !,"STARTING TIME: ",X:DTIME Q:U[X D TC^SDC2 G F:Y<0 S FR=Y,ST=%
T R !,"ENDING TIME: ",X:DTIME Q:U[X D TC^SDC2 G T:Y<0 S SDHTO=X,TO=Y I TO'>FR W !,"Ending time must be greater than starting time",*7 G T
N SDDFR S SDDFR=TO-FR ;SD*5.3*758 - Set length of block
I $$COED^SDC4(SC,FR,TO,1) K FR,SDHTO,TO,ST W ! G F
ROPT R !,"Reason for cancellation: ",I:DTIME I I?1"?".E W !,"YOU MAY ENTER A MESSAGE CONCERNING THE CANCELLATION HERE" G ROPT
N CANREM S CANREM=I
Q:I["^" I '$D(^SC(SC,"SDCAN",0)) S ^SC(SC,"SDCAN",0)="^44.05D^"_FR_"^1" G SKIP
S A=^SC(SC,"SDCAN",0),SDCNT=$P(A,"^",4),^SC(SC,"SDCAN",0)=$P(A,"^",1,2)_"^"_FR_"^"_(SDCNT+1)
SKIP S ^SC(SC,"SDCAN",FR,0)=FR_"^"_SDHTO
S NOAP=$S($O(^SC(SC,"S",(FR-.0001)))'>0:1,$O(^SC(SC,"S",(FR-.0001)))>TO:1,1:0) I 'NOAP S NOAP=$S($O(^SC(SC,"S",+$O(^SC(SC,"S",(FR-.0001))),0))="MES":1,1:0)
S ^SC(SC,"S",FR,0)=FR,^("MES")="CANCELLED UNTIL "_X_$S(I?.P:"",1:" ("_I_")") D S S I=^(1),I=I_$J("",%-$L(I)),Y="" I $G(SDDFR)<100,$L(I)<77 S I=I_" " ;SD*5.3*758 - pad 4 empty spaces needed for blocks < 60 minutes
F X=0:2:% S DH=$E(I,X+SI+SI),P=$S(X<ST:DH_$E(I,X+1+SI+SI),X=%:$S(Y="[":Y,1:DH)_$E(I,X+1+SI+SI),1:$S(Y="["&(X=ST):"]",1:"X")_"X"),Y=$S(DH="]":"",DH="[":DH,1:Y),I=$E(I,1,X-1+SI+SI)_P_$E(I,X+2+SI+SI,999)
S:'$F(I,"[") I5=$F(I,"X"),I=$E(I,1,(I5-2))_"["_$E(I,I5,999) K I5
S DH=0,^(1)=I ;780
D EN^SDTMPHLC(SC,FR,TO,"P",CANREM) ;780
S FR=FR-.0001 ;780
G C ;NAKED REFERENCE - ^SC(IFN,"ST",Date,1)
S S ^("CAN")=^SC(SC,"ST",SD,1) Q
;
ALL N CANREM
W !,"Reason for cancellation: " R CANREM:DTIME I $L(CANREM)>160!($L(CANREM)<3) W !,*7,"Reason must be between 3 to 160 characters long",! G ALL
D S S ^(1)=" "_$E(SD,6,7)_" **CANCELLED**",FR=SD,TO=SD+.9 ;NAKED REFERENCE - ^SC(IFN,"ST",Date,1)
D EN^SDTMPHLC(SC,SD,,"C","**CANCELLED**") ;780
C S FR=$O(^SC(SC,"S",FR)) I FR<1!(FR'<TO) W !!,"CANCELLED! " K SDX G CHKEND^SDC0
N TDH,TMPD,DIE,DR,NODE,SDI
; SD*724 - Replace 'I' with 'SDI'
F SDI=0:0 S SDI=$O(^SC(SC,"S",FR,1,SDI)) Q:SDI'>0 D
.I '$D(^SC(SC,"S",FR,1,SDI,0)) I $D(^("C")) S J=FR,J2=SDI D DELETE^SDC1 K J,J2 Q ;SD*5.3*545 delete corrupt node
.I '+$G(^SC(SC,"S",FR,1,SDI,0)) S J=FR,J2=SDI D DELETE^SDC1 K J,J2 Q ;SD*5.3*545 if DFN is missing delete record
.Q:$P(^SC(SC,"S",FR,1,SDI,0),"^",9)="C" ;SD*5.3*758 - Quit processing if appointment already canceled.
.S DFN=+^SC(SC,"S",FR,1,SDI,0),SDCNHDL=$$HANDLE^SDAMEVT(1)
.D BEFORE^SDAMEVT(.SDATA,DFN,FR,SC,SDI,SDCNHDL)
.S $P(^SC(SC,"S",FR,1,SDI,0),"^",9)="C"
.S:$D(^DPT(DFN,"S",FR,0)) NODE=^(0) ;added SD/523
.Q:$P(NODE,U,1)'=SC ;added SD/523
.S ^DPT("ASDCN",SC,FR,DFN)=""
.S SDSC=SC,SDTTM=FR,SDPL=SDI,TDH=DH,TMPD=CANREM D CANCEL^SDCNSLT S DH=TDH ;SD/478
.I $D(^DPT(DFN,"S",FR,0)),$P(^(0),"^",2)'["C" S $P(^(0),"^",2)="C",$P(^(0),"^",12)=DUZ,$P(^(0),"^",14)=SDTIME,DH=DH+1,TDH=DH,DIE="^DPT(DFN,"_"""S"""_",",DR="17///^S X=CANREM",DA=FR D ^DIE S DH=TDH D MORE
.D SDEC^SDCNP0(DFN,FR,SC,"C","",$G(CANREM),SDTIME,DUZ) ;alb/sat 627
G C
;
B S X=SD D DOW^SDM0 S DOW=Y,SS=+$O(^SC(SC,"T"_Y,X)) I $D(^(SS,1)),^(1)]"" S DH=^(1),DO=X+1,DA(1)=SC
Q
MORE I $D(^SC("ARAD",SC,FR,DFN)) S ^(DFN)="N"
S SDIV=$S($P(^SC(SC,0),"^",15)]"":$P(^(0),"^",15),1:" 1"),SDV1=$S(SDIV:SDIV,1:+$O(^DG(40.8,0))) I $D(^DPT("ASDPSD","C",SDIV,SC,FR,DFN)) K ^(DFN)
; SD*724 - set SDPL with value from SDI
S SDH=DH,SDTTM=FR,SDSC=SC,SDPL=SDI,SDRT="D" D RT^SDUTL
S DH=SDH K SDH D CK1,EVT
K SD1,SDIV,SDPL,SDRT,SDSC,SDTTM,SDX Q
CK1 S SDX=0 F SD1=FR\1:0 S SD1=$O(^DPT(DFN,"S",SD1)) Q:'SD1!((SD1\1)'=(FR\1)) I $P(^(SD1,0),"^",2)'["C",$P(^(0),"^",2)'["N" S SDX=1 Q
Q:SDX F SD1=2,4 I $D(^SC("AAS",SD1,FR\1,DFN)) S SDX=1 Q
Q:SDX IF $D(^SCE(+$$EXAE^SDOE(DFN,FR\1,FR\1),0)) S SDX=1
Q:SDX K ^DPT("ASDPSD","B",SDIV,FR\1,DFN) Q
;
EVT ; -- separate tag if need to NEW vars
; -- cancel event
N FR,I,SDTIME,DH,SC
D CANCEL^SDAMEVT(.SDATA,DFN,SDTTM,SDSC,SDPL,0,SDCNHDL) K SDATA,SDCNHDL
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDC 6200 printed Oct 16, 2024@18:49:18 Page 2
SDC ;MAN/GRR,ALB/LDB,LAB - CANCEL A CLINIC'S AVAILABILITY ;JAN 15, 2016
+1 ;;5.3;Scheduling;**15,32,79,132,167,478,487,523,545,627,684,724,758,780,864**;Aug 13, 1993;Build 15
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ; for evt dvr
NEW SDATA,SDCNHDL
SDC1 KILL SDLT,SDCP
SET NOAP=""
DO LO^DGUTL
+1 SET DIC=44
SET DIC(0)="MEQA"
SET DIC("S")="I $P(^(0),""^"",3)=""C"",'$G(^(""OOS""))"
SET DIC("A")="Select CLINIC NAME: "
DO ^DIC
KILL DIC("S"),DIC("A")
if '$DATA(^SC(+Y,"SL"))
GOTO END^SDC0
+2 ;NAKED REFERNCE - ^SC(IFN,"SL")
SET SC=+Y
SET SL=^("SL")
SET %DT="AEXF"
SET %DT("A")="CANCEL '"_$PIECE(Y,U,2)_"' FOR WHAT DATE: "
DO ^%DT
KILL %DT
if Y<0
GOTO END^SDC0
+3 SET (SD,CDATE)=Y
SET %=$PIECE(SL,U,6)
SET SI=$SELECT(%="":4,%<3:4,%:%,1:4)
SET %=$PIECE(SL,U,3)
SET STARTDAY=$SELECT($LENGTH(%):%,1:8)
DO NOW^%DTC
SET SDTIME=%
+4 IF '$DATA(^SC(SC,"ST",SD,1))
WRITE !,*7,"CLINIC DOES NOT MEET ON THAT DAY"
GOTO SDC1
+5 KILL SDRE,SDIN,SDRE1
IF $DATA(^SC(SC,"I"))
SET SDIN=+^("I")
SET SDRE=+$PIECE(^("I"),"^",2)
SET Y=SDRE
if Y
DO DTS^SDUTL
SET SDRE1=$SELECT(SDRE:" to "_Y,1:"")
+6 IF $SELECT('$DATA(SDIN):0,SDIN'>0!(SDIN>SD):0,SDRE'>SD&(SDRE):0,1:1)
WRITE !,*7,"Clinic is inactive ",$SELECT('SDRE:"as of ",1:"from ")
SET Y=SDIN
DO DTS^SDUTL
WRITE Y,SDRE1
GOTO SDC1
+7 IF '$DATA(^SC(SC,"ST",SD,1))
SET DH=""
DO B
SET ^SC(SC,"ST",SD,1)=$PIECE("SU^MO^TU^WE^TH^FR^SA",U,DOW+1)_" "_$EXTRACT(SD,6,7)_$JUSTIFY("",SI+SI-6)_DH
SET ^(0)=SD
GOTO N
+8 ;NAKED REFERENCE - ^SC(IFN,"ST",Date,1)
IF ^(1)["CANCELLED"
WRITE !,"APPOINTMENTS HAVE ALREADY BEEN CANCELLED",!,*7
SET ANS="N"
SET SDTIME="*"
SET SDV1=$SELECT($PIECE(^SC(SC,0),"^",15):$PIECE(^(0),"^",15),1:+$ORDER(^DG(40.8,0)))
KILL SDX
GOTO ASKL^SDC0
+9 ;N I '$F(^SC(SC,"ST",SD,1),"[") K:^(1)?2U.E ^SC(SC,"ST",SD) W !,*7,"CLINIC DOES NOT MEET ON THAT DAY" G SDC1 ; KILLs node if not holiday
N ; SD*5.3*684 - Remove KILL on "ST" (PATTERN) node
IF '$FIND(^SC(SC,"ST",SD,1),"[")
WRITE !,*7,"CLINIC DOES NOT MEET ON THAT DAY"
GOTO SDC1
+1 IF $ORDER(^SC(SC,"S",SD))\1-SD
WRITE *7,!?5,"NO APPOINTMENTS SCHEDULED"
SET NOAP=1
GOTO W
+2 WRITE !,"FIRST, I'LL LIST THE EXISTING APPOINTMENTS",!
+3 KILL DUOUT,DTOUT
DO ^SDC1
IF $DATA(DUOUT)!$DATA(DTOUT)
DO END^SDC0
QUIT
+4 IF ^SC(SC,"ST",SD,1)["X"
GOTO ^SDC2
W SET DH=0
SET %=""
WRITE !,"WANT TO CANCEL THE WHOLE DAY"
DO YN^DICN
IF '%
WRITE !,"REPLY YES (Y) OR NO (N)"
GOTO W
+1 IF %=1
if $$COED^SDC4(SC,SD,SD+.2359,1)
GOTO WP
GOTO ALL
+2 if %<1
QUIT
WP SET %=""
WRITE !,"WANT TO CANCEL PART OF THE DAY"
DO YN^DICN
IF '%
WRITE !,"REPLY YES (Y) OR NO (N)"
GOTO WP
+1 if (%-1)
QUIT
F READ !,"STARTING TIME: ",X:DTIME
if U[X
QUIT
DO TC^SDC2
if Y<0
GOTO F
SET FR=Y
SET ST=%
T READ !,"ENDING TIME: ",X:DTIME
if U[X
QUIT
DO TC^SDC2
if Y<0
GOTO T
SET SDHTO=X
SET TO=Y
IF TO'>FR
WRITE !,"Ending time must be greater than starting time",*7
GOTO T
+1 ;SD*5.3*758 - Set length of block
NEW SDDFR
SET SDDFR=TO-FR
+2 IF $$COED^SDC4(SC,FR,TO,1)
KILL FR,SDHTO,TO,ST
WRITE !
GOTO F
ROPT READ !,"Reason for cancellation: ",I:DTIME
IF I?1"?".E
WRITE !,"YOU MAY ENTER A MESSAGE CONCERNING THE CANCELLATION HERE"
GOTO ROPT
+1 NEW CANREM
SET CANREM=I
+2 if I["^"
QUIT
IF '$DATA(^SC(SC,"SDCAN",0))
SET ^SC(SC,"SDCAN",0)="^44.05D^"_FR_"^1"
GOTO SKIP
+3 SET A=^SC(SC,"SDCAN",0)
SET SDCNT=$PIECE(A,"^",4)
SET ^SC(SC,"SDCAN",0)=$PIECE(A,"^",1,2)_"^"_FR_"^"_(SDCNT+1)
SKIP SET ^SC(SC,"SDCAN",FR,0)=FR_"^"_SDHTO
+1 SET NOAP=$SELECT($ORDER(^SC(SC,"S",(FR-.0001)))'>0:1,$ORDER(^SC(SC,"S",(FR-.0001)))>TO:1,1:0)
IF 'NOAP
SET NOAP=$SELECT($ORDER(^SC(SC,"S",+$ORDER(^SC(SC,"S",(FR-.0001))),0))="MES":1,1:0)
+2 ;SD*5.3*758 - pad 4 empty spaces needed for blocks < 60 minutes
SET ^SC(SC,"S",FR,0)=FR
SET ^("MES")="CANCELLED UNTIL "_X_$SELECT(I?.P:"",1:" ("_I_")")
DO S
SET I=^(1)
SET I=I_$JUSTIFY("",%-$LENGTH(I))
SET Y=""
IF $GET(SDDFR)<100
IF $LENGTH(I)<77
SET I=I_" "
+3 FOR X=0:2:%
SET DH=$EXTRACT(I,X+SI+SI)
SET P=$SELECT(X<ST:DH_$EXTRACT(I,X+1+SI+SI),X=%:$SELECT(Y="[":Y,1:DH)_$EXTRACT(I,X+1+SI+SI),1:$SELECT(Y="["&(X=ST):"]",1:"X")_"X")
SET Y=$SELECT(DH="]":"",DH="[":DH,1:Y)
SET I=$EXTRACT(I,1,X-1+SI+SI)_P_$EXTRACT(I,X+2+SI+SI,999)
+4 if '$FIND(I,"[")
SET I5=$FIND(I,"X")
SET I=$EXTRACT(I,1,(I5-2))_"["_$EXTRACT(I,I5,999)
KILL I5
+5 ;780
SET DH=0
SET ^(1)=I
+6 ;780
DO EN^SDTMPHLC(SC,FR,TO,"P",CANREM)
+7 ;780
SET FR=FR-.0001
+8 ;NAKED REFERENCE - ^SC(IFN,"ST",Date,1)
GOTO C
S SET ^("CAN")=^SC(SC,"ST",SD,1)
QUIT
+1 ;
ALL NEW CANREM
+1 WRITE !,"Reason for cancellation: "
READ CANREM:DTIME
IF $LENGTH(CANREM)>160!($LENGTH(CANREM)<3)
WRITE !,*7,"Reason must be between 3 to 160 characters long",!
GOTO ALL
+2 ;NAKED REFERENCE - ^SC(IFN,"ST",Date,1)
DO S
SET ^(1)=" "_$EXTRACT(SD,6,7)_" **CANCELLED**"
SET FR=SD
SET TO=SD+.9
+3 ;780
DO EN^SDTMPHLC(SC,SD,,"C","**CANCELLED**")
C SET FR=$ORDER(^SC(SC,"S",FR))
IF FR<1!(FR'<TO)
WRITE !!,"CANCELLED! "
KILL SDX
GOTO CHKEND^SDC0
+1 NEW TDH,TMPD,DIE,DR,NODE,SDI
+2 ; SD*724 - Replace 'I' with 'SDI'
+3 FOR SDI=0:0
SET SDI=$ORDER(^SC(SC,"S",FR,1,SDI))
if SDI'>0
QUIT
Begin DoDot:1
+4 ;SD*5.3*545 delete corrupt node
IF '$DATA(^SC(SC,"S",FR,1,SDI,0))
IF $DATA(^("C"))
SET J=FR
SET J2=SDI
DO DELETE^SDC1
KILL J,J2
QUIT
+5 ;SD*5.3*545 if DFN is missing delete record
IF '+$GET(^SC(SC,"S",FR,1,SDI,0))
SET J=FR
SET J2=SDI
DO DELETE^SDC1
KILL J,J2
QUIT
+6 ;SD*5.3*758 - Quit processing if appointment already canceled.
if $PIECE(^SC(SC,"S",FR,1,SDI,0),"^",9)="C"
QUIT
+7 SET DFN=+^SC(SC,"S",FR,1,SDI,0)
SET SDCNHDL=$$HANDLE^SDAMEVT(1)
+8 DO BEFORE^SDAMEVT(.SDATA,DFN,FR,SC,SDI,SDCNHDL)
+9 SET $PIECE(^SC(SC,"S",FR,1,SDI,0),"^",9)="C"
+10 ;added SD/523
if $DATA(^DPT(DFN,"S",FR,0))
SET NODE=^(0)
+11 ;added SD/523
if $PIECE(NODE,U,1)'=SC
QUIT
+12 SET ^DPT("ASDCN",SC,FR,DFN)=""
+13 ;SD/478
SET SDSC=SC
SET SDTTM=FR
SET SDPL=SDI
SET TDH=DH
SET TMPD=CANREM
DO CANCEL^SDCNSLT
SET DH=TDH
+14 IF $DATA(^DPT(DFN,"S",FR,0))
IF $PIECE(^(0),"^",2)'["C"
SET $PIECE(^(0),"^",2)="C"
SET $PIECE(^(0),"^",12)=DUZ
SET $PIECE(^(0),"^",14)=SDTIME
SET DH=DH+1
SET TDH=DH
SET DIE="^DPT(DFN,"_"""S"""_","
SET DR="17///^S X=CANREM"
SET DA=FR
DO ^DIE
SET DH=TDH
DO MORE
+15 ;alb/sat 627
DO SDEC^SDCNP0(DFN,FR,SC,"C","",$GET(CANREM),SDTIME,DUZ)
End DoDot:1
+16 GOTO C
+17 ;
B SET X=SD
DO DOW^SDM0
SET DOW=Y
SET SS=+$ORDER(^SC(SC,"T"_Y,X))
IF $DATA(^(SS,1))
IF ^(1)]""
SET DH=^(1)
SET DO=X+1
SET DA(1)=SC
+1 QUIT
MORE IF $DATA(^SC("ARAD",SC,FR,DFN))
SET ^(DFN)="N"
+1 SET SDIV=$SELECT($PIECE(^SC(SC,0),"^",15)]"":$PIECE(^(0),"^",15),1:" 1")
SET SDV1=$SELECT(SDIV:SDIV,1:+$ORDER(^DG(40.8,0)))
IF $DATA(^DPT("ASDPSD","C",SDIV,SC,FR,DFN))
KILL ^(DFN)
+2 ; SD*724 - set SDPL with value from SDI
+3 SET SDH=DH
SET SDTTM=FR
SET SDSC=SC
SET SDPL=SDI
SET SDRT="D"
DO RT^SDUTL
+4 SET DH=SDH
KILL SDH
DO CK1
DO EVT
+5 KILL SD1,SDIV,SDPL,SDRT,SDSC,SDTTM,SDX
QUIT
CK1 SET SDX=0
FOR SD1=FR\1:0
SET SD1=$ORDER(^DPT(DFN,"S",SD1))
if 'SD1!((SD1\1)'=(FR\1))
QUIT
IF $PIECE(^(SD1,0),"^",2)'["C"
IF $PIECE(^(0),"^",2)'["N"
SET SDX=1
QUIT
+1 if SDX
QUIT
FOR SD1=2,4
IF $DATA(^SC("AAS",SD1,FR\1,DFN))
SET SDX=1
QUIT
+2 if SDX
QUIT
IF $DATA(^SCE(+$$EXAE^SDOE(DFN,FR\1,FR\1),0))
SET SDX=1
+3 if SDX
QUIT
KILL ^DPT("ASDPSD","B",SDIV,FR\1,DFN)
QUIT
+4 ;
EVT ; -- separate tag if need to NEW vars
+1 ; -- cancel event
+2 NEW FR,I,SDTIME,DH,SC
+3 DO CANCEL^SDAMEVT(.SDATA,DFN,SDTTM,SDSC,SDPL,0,SDCNHDL)
KILL SDATA,SDCNHDL
+4 QUIT
+5 ;