SDAMC ;ALB/MJK - Cancel Appt Action ; 8/31/05 3:02pm ; 12/26/08 12:26pm ; 5/25/12 12:40pm
;;5.3;Scheduling;**20,28,32,46,263,414,444,478,538,554,597,592**;Aug 13, 1993;Build 4
;
; Reference/ICR
; ^VALM1 - 10116
; ^VALM2 - 10119
;
EN ; -- protocol SDAM APPT CANCEL entry pt
; input: VALMY := array entries
;
N SDI,SDAT,VALMY,SDAMCIDT,CNT,L,SDWH,SDCP,SDREM,SDSCR,SDMSG,SCLHOLD
K ^UTILITY($J)
;
;
I '$D(DFN),$G(SDFN),($G(SDAMTYP)="P") S DFN=SDFN
;
S VALMBCK=""
D SEL^VALM2,CHK G ENQ:'$O(VALMY(0))
D FULL^VALM1 S VALMBCK="R"
S SDWH=$$WHO,SDCP=$S(SDWH="C":0,1:1) G ENQ:SDWH=-1
S SDSCR=$$RSN(SDWH) G ENQ:SDSCR=-1
S (TMPD,SDREM)=$$REM G ENQ:SDREM=-1 ;SD/478
S (SDI,CNT,L)=0
;set L=SDI SD*5.3*592
F S SDI=$O(VALMY(SDI)) Q:'SDI I $D(^TMP("SDAMIDX",$J,SDI)) K SDAT S SDAT=^(SDI),L=SDI W !,^TMP("SDAM",$J,+SDAT,0) D CAN($P(SDAT,U,2),$P(SDAT,U,3),.CNT,.L,SDWH,SDCP,SDSCR,SDREM)
I SDAMTYP="P" D BLD^SDAM1
I SDAMTYP="C" D BLD^SDAM3
ENQ Q
;
CAN(DFN,SDT,CNT,L,SDWH,SDCP,SDSCR,SDREM) ;
N A1,NDT S NDT=SDT
I $P($G(^DPT(DFN,"S",NDT,0)),U,2)["C" W !!,"Appointment already cancelled" H 2 Q
;removed L=L\1+1 which incorrectly incremented the variable L SD*5.3*592
I $D(^DPT(DFN,"S",NDT,0)) S SD0=^(0) I $P(SD0,"^",2)'["C" S SC=+SD0,APL="" D FLEN^SDCNP1A S ^UTILITY($J,"SDCNP",L)=NDT_"^"_SC_"^"_COV_"^"_APL_"^^"_APL_"^^^^^^"_SDSP D CHKSO^SDCNP0 ;SD/478
;SD*5.3*414 next line added to set hold variable SCLHOLD for clinic ptr
S APP=1,A1=L\1 S SCLHOLD=$P(^UTILITY($J,"SDCNP",A1),U,2) D BEGD^SDCNP0
D MES,NOPE W ! S (CNT,L)=0 K ^UTILITY($J,"SDCNP")
Q
CANQ(SDFN,SDCLN) ; SD*5.3*554 - Passes in SDFN, SDCLN
;Wait List Message
;
I SDFN=""!(SDCLN="") Q ;Checks to make sure that SDFN and SDCLN are set to a non null value - PATCH SD*5.3*597
N SDOMES S SDOMES="" I $D(^SDWL(409.3,"SC",SDCLN)) D
.N SDWL S SDWL="" F S SDWL=$O(^SDWL(409.3,"SC",SDCLN,SDWL)) Q:SDWL="" D Q:SDOMES
..I $P(^SDWL(409.3,SDWL,0),U,17)="O" I $P(^SDWL(409.3,SDWL,0),U)=$G(SDFN) D S SDOMES=1
...W !,?1,"There are Wait List entries waiting for an Appointment for this patient in ",!?1,$P(^SC(SDCLN,0),U,1)," Clinic.",!
W ! S DIR(0)="E" D ^DIR W !
K SCLHOLD,SC,COV,APP,SDCLN
Q
MES ; -- set error message
S SDMSG="W !,""Enter appt. numbers separated by commas and/or a range separated"",!,""by dashes (ie 2,4,6-9)"" H 2"
Q
;
WHO() ;
W ! S DIR(0)="SOA^PC:PATIENT;C:CLINIC",DIR("A")="Appointments cancelled by (P)atient or (C)linic: ",DIR("B")="Patient"
D ^DIR K DIR
Q $S(Y=""!(Y="^"):-1,1:Y)
;
RSN(SDWH) ;
RSN1 W ! S DIC="^SD(409.2,",DIC(0)="AEMQ",DIC("S")="I '$P(^(0),U,4),"""_$E(SDWH)_"B""[$P(^(0),U,2)" D ^DIC K DIC
I X["^" G RSNQ
I Y<0 W *7 G RSN1
RSNQ Q +Y
;
REM() ;
W ! S DIR(0)="2.98,17" D ^DIR K DIR
I $E(X)="^" S Y=-1
Q Y
;
NOPE ;
N SDEND,SDPAUSE
S:'CNT SDPAUSE=1
D NOPE^SDCNP1
D:$G(SDPAUSE) PAUSE^VALM1
Q
;
CHK ; -- check if status of appt permits cancelling
N SDI S SDI=0
F S SDI=$O(VALMY(SDI)) Q:'SDI I $D(^TMP("SDAMIDX",$J,SDI)) K SDAT S SDAT=^(SDI) I '$D(^SD(409.63,"ACAN",1,+$$STATUS^SDAM1($P(SDAT,U,2),$P(SDAT,U,3),+$G(^DPT(+$P(SDAT,U,2),"S",+$P(SDAT,U,3),0)),$G(^(0))))) D
.W !,^TMP("SDAM",$J,+SDAT,0),!!,*7,"You cannot cancel this appointment."
.K VALMY(SDI) D PAUSE^VALM1
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDAMC 3293 printed Oct 16, 2024@18:48:06 Page 2
SDAMC ;ALB/MJK - Cancel Appt Action ; 8/31/05 3:02pm ; 12/26/08 12:26pm ; 5/25/12 12:40pm
+1 ;;5.3;Scheduling;**20,28,32,46,263,414,444,478,538,554,597,592**;Aug 13, 1993;Build 4
+2 ;
+3 ; Reference/ICR
+4 ; ^VALM1 - 10116
+5 ; ^VALM2 - 10119
+6 ;
EN ; -- protocol SDAM APPT CANCEL entry pt
+1 ; input: VALMY := array entries
+2 ;
+3 NEW SDI,SDAT,VALMY,SDAMCIDT,CNT,L,SDWH,SDCP,SDREM,SDSCR,SDMSG,SCLHOLD
+4 KILL ^UTILITY($JOB)
+5 ;
+6 ;
+7 IF '$DATA(DFN)
IF $GET(SDFN)
IF ($GET(SDAMTYP)="P")
SET DFN=SDFN
+8 ;
+9 SET VALMBCK=""
+10 DO SEL^VALM2
DO CHK
if '$ORDER(VALMY(0))
GOTO ENQ
+11 DO FULL^VALM1
SET VALMBCK="R"
+12 SET SDWH=$$WHO
SET SDCP=$SELECT(SDWH="C":0,1:1)
if SDWH=-1
GOTO ENQ
+13 SET SDSCR=$$RSN(SDWH)
if SDSCR=-1
GOTO ENQ
+14 ;SD/478
SET (TMPD,SDREM)=$$REM
if SDREM=-1
GOTO ENQ
+15 SET (SDI,CNT,L)=0
+16 ;set L=SDI SD*5.3*592
+17 FOR
SET SDI=$ORDER(VALMY(SDI))
if 'SDI
QUIT
IF $DATA(^TMP("SDAMIDX",$JOB,SDI))
KILL SDAT
SET SDAT=^(SDI)
SET L=SDI
WRITE !,^TMP("SDAM",$JOB,+SDAT,0)
DO CAN($PIECE(SDAT,U,2),$PIECE(SDAT,U,3),.CNT,.L,SDWH,SDCP,SDSCR,SDREM)
+18 IF SDAMTYP="P"
DO BLD^SDAM1
+19 IF SDAMTYP="C"
DO BLD^SDAM3
ENQ QUIT
+1 ;
CAN(DFN,SDT,CNT,L,SDWH,SDCP,SDSCR,SDREM) ;
+1 NEW A1,NDT
SET NDT=SDT
+2 IF $PIECE($GET(^DPT(DFN,"S",NDT,0)),U,2)["C"
WRITE !!,"Appointment already cancelled"
HANG 2
QUIT
+3 ;removed L=L\1+1 which incorrectly incremented the variable L SD*5.3*592
+4 ;SD/478
IF $DATA(^DPT(DFN,"S",NDT,0))
SET SD0=^(0)
IF $PIECE(SD0,"^",2)'["C"
SET SC=+SD0
SET APL=""
DO FLEN^SDCNP1A
SET ^UTILITY($JOB,"SDCNP",L)=NDT_"^"_SC_"^"_COV_"^"_APL_"^^"_APL_"^^^^^^"_SDSP
DO CHKSO^SDCNP0
+5 ;SD*5.3*414 next line added to set hold variable SCLHOLD for clinic ptr
+6 SET APP=1
SET A1=L\1
SET SCLHOLD=$PIECE(^UTILITY($JOB,"SDCNP",A1),U,2)
DO BEGD^SDCNP0
+7 DO MES
DO NOPE
WRITE !
SET (CNT,L)=0
KILL ^UTILITY($JOB,"SDCNP")
+8 QUIT
CANQ(SDFN,SDCLN) ; SD*5.3*554 - Passes in SDFN, SDCLN
+1 ;Wait List Message
+2 ;
+3 ;Checks to make sure that SDFN and SDCLN are set to a non null value - PATCH SD*5.3*597
IF SDFN=""!(SDCLN="")
QUIT
+4 NEW SDOMES
SET SDOMES=""
IF $DATA(^SDWL(409.3,"SC",SDCLN))
Begin DoDot:1
+5 NEW SDWL
SET SDWL=""
FOR
SET SDWL=$ORDER(^SDWL(409.3,"SC",SDCLN,SDWL))
if SDWL=""
QUIT
Begin DoDot:2
+6 IF $PIECE(^SDWL(409.3,SDWL,0),U,17)="O"
IF $PIECE(^SDWL(409.3,SDWL,0),U)=$GET(SDFN)
Begin DoDot:3
+7 WRITE !,?1,"There are Wait List entries waiting for an Appointment for this patient in ",!?1,$PIECE(^SC(SDCLN,0),U,1)," Clinic.",!
End DoDot:3
SET SDOMES=1
End DoDot:2
if SDOMES
QUIT
End DoDot:1
+8 WRITE !
SET DIR(0)="E"
DO ^DIR
WRITE !
+9 KILL SCLHOLD,SC,COV,APP,SDCLN
+10 QUIT
MES ; -- set error message
+1 SET SDMSG="W !,""Enter appt. numbers separated by commas and/or a range separated"",!,""by dashes (ie 2,4,6-9)"" H 2"
+2 QUIT
+3 ;
WHO() ;
+1 WRITE !
SET DIR(0)="SOA^PC:PATIENT;C:CLINIC"
SET DIR("A")="Appointments cancelled by (P)atient or (C)linic: "
SET DIR("B")="Patient"
+2 DO ^DIR
KILL DIR
+3 QUIT $SELECT(Y=""!(Y="^"):-1,1:Y)
+4 ;
RSN(SDWH) ;
RSN1 WRITE !
SET DIC="^SD(409.2,"
SET DIC(0)="AEMQ"
SET DIC("S")="I '$P(^(0),U,4),"""_$EXTRACT(SDWH)_"B""[$P(^(0),U,2)"
DO ^DIC
KILL DIC
+1 IF X["^"
GOTO RSNQ
+2 IF Y<0
WRITE *7
GOTO RSN1
RSNQ QUIT +Y
+1 ;
REM() ;
+1 WRITE !
SET DIR(0)="2.98,17"
DO ^DIR
KILL DIR
+2 IF $EXTRACT(X)="^"
SET Y=-1
+3 QUIT Y
+4 ;
NOPE ;
+1 NEW SDEND,SDPAUSE
+2 if 'CNT
SET SDPAUSE=1
+3 DO NOPE^SDCNP1
+4 if $GET(SDPAUSE)
DO PAUSE^VALM1
+5 QUIT
+6 ;
CHK ; -- check if status of appt permits cancelling
+1 NEW SDI
SET SDI=0
+2 FOR
SET SDI=$ORDER(VALMY(SDI))
if 'SDI
QUIT
IF $DATA(^TMP("SDAMIDX",$JOB,SDI))
KILL SDAT
SET SDAT=^(SDI)
IF '$DATA(^SD(409.63,"ACAN",1,+$$STATUS^SDAM1($PIECE(SDAT,U,2),$PIECE(SDAT,U,3),+$GET(^DPT(+$PIECE(SDAT,U,2),"S",+$PIECE(SDAT,U,3),0)),$GET(^(0)))))
Begin DoDot:1
+3 WRITE !,^TMP("SDAM",$JOB,+SDAT,0),!!,*7,"You cannot cancel this appointment."
+4 KILL VALMY(SDI)
DO PAUSE^VALM1
End DoDot:1
+5 QUIT