SDAMC ;ALB/MJK - Cancel Appt Action ; 8/31/05 3:02pm ; 12/26/08 12:26pm ; Compiled January 8, 2009 15:41:48
;;5.3;PIMS;**20,28,32,46,263,414,444,478,1015,1016**;JUN 30, 2012;Build 20
;IHS/ANMC/LJF 12/06/2000 prevent cancel if appt already checked in
;IHS/OIT/LJF 01/26/2006 PATCH 1005 added OTHER INFO to Cancel Remarks
;cmi/anch/maw 09/04/2008 PATCH 1010 added hard cancel if node in DPT but not SC
;cmi/flag/maw 06/02/2010 PATCH 1012 RQMT149 added for appt check in list view
;
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
F S SDI=$O(VALMY(SDI)) Q:'SDI I $D(^TMP("SDAMIDX",$J,SDI)) K SDAT S SDAT=^(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 G CANQ
;IHS/ANMC/LJF 12/06/2000 new code to screen for checked in patients
NEW IEN,C S C=+$G(^DPT(DFN,"S",NDT,0)),IEN=$$SCIEN^BSDU2(DFN,C,NDT)
;cmi/anch/maw 9/4/2008 PIMS Patch 1010 for hanging cancellations from GUI Scheduling
I '$G(IEN) D G CANQ
. S $P(^DPT(DFN,"S",NDT,0),U,2)="C" ;mark the appointment as cancelled
. W !!,"Appointment cancelled" H 2
I $$CI^BSDU2(DFN,C,NDT,IEN) D MSG^BDGF("Patient already checked-in. Cannot cancel unless check-in date deleted.",2,1),PAUSE^BDGF Q
;IHS/ANMC/LJF 12/06/2000 end of new code
;
;IHS/OIT/LJF 01/26/2006 PATCH 1005 add OTHER INFO to end of Cancel Remarks
; (using C and IEN set above) this way OTHER INFO is stored after cancellation
NEW X S X=$P($G(^SC(C,"S",SDT,1,IEN,0)),U,4) I X]"" S SDREM=SDREM_"["_X_"]",SDREM=$E(SDREM,1,160) ;ihs/cmi/maw 07/25/2012 concatenate OI on cancellation remarks
I $D(^DPT(DFN,"S",NDT,0)) S SD0=^(0) I $P(SD0,"^",2)'["C" S SC=+SD0,L=L\1+1,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")
CANQ ;
;Wait List Message
;
I $G(SCLHOLD)'="" S:'$D(SDCLN) SDCLN=SCLHOLD ; SD*5.3*414
N SDOMES S SDOMES="" I $G(SDCLN)'="",$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.",!
S DIR(0)="E" D ^DIR W !
K:SDAMTYP="P" SDCLN
K SCLHOLD,SC,COV,APP
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
SDAMC ;ALB/MJK - Cancel Appt Action ; 8/31/05 3:02pm ; 12/26/08 12:26pm ; Compiled January 8, 2009 15:41:48
+1 ;;5.3;PIMS;**20,28,32,46,263,414,444,478,1015,1016**;JUN 30, 2012;Build 20
+2 ;IHS/ANMC/LJF 12/06/2000 prevent cancel if appt already checked in
+3 ;IHS/OIT/LJF 01/26/2006 PATCH 1005 added OTHER INFO to Cancel Remarks
+4 ;cmi/anch/maw 09/04/2008 PATCH 1010 added hard cancel if node in DPT but not SC
+5 ;cmi/flag/maw 06/02/2010 PATCH 1012 RQMT149 added for appt check in list view
+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 FOR
SET SDI=$ORDER(VALMY(SDI))
IF 'SDI
QUIT
IF $DATA(^TMP("SDAMIDX",$JOB,SDI))
KILL SDAT
SET SDAT=^(SDI)
WRITE !,^TMP("SDAM",$JOB,+SDAT,0)
DO CAN($PIECE(SDAT,U,2),$PIECE(SDAT,U,3),.CNT,.L,SDWH,SDCP,SDSCR,SDREM)
+17 IF SDAMTYP="P"
DO BLD^SDAM1
+18 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
GOTO CANQ
+3 ;IHS/ANMC/LJF 12/06/2000 new code to screen for checked in patients
+4 NEW IEN,C
SET C=+$GET(^DPT(DFN,"S",NDT,0))
SET IEN=$$SCIEN^BSDU2(DFN,C,NDT)
+5 ;cmi/anch/maw 9/4/2008 PIMS Patch 1010 for hanging cancellations from GUI Scheduling
+6 IF '$GET(IEN)
Begin DoDot:1
+7 ;mark the appointment as cancelled
SET $PIECE(^DPT(DFN,"S",NDT,0),U,2)="C"
+8 WRITE !!,"Appointment cancelled"
HANG 2
End DoDot:1
GOTO CANQ
+9 IF $$CI^BSDU2(DFN,C,NDT,IEN)
DO MSG^BDGF("Patient already checked-in. Cannot cancel unless check-in date deleted.",2,1)
DO PAUSE^BDGF
QUIT
+10 ;IHS/ANMC/LJF 12/06/2000 end of new code
+11 ;
+12 ;IHS/OIT/LJF 01/26/2006 PATCH 1005 add OTHER INFO to end of Cancel Remarks
+13 ; (using C and IEN set above) this way OTHER INFO is stored after cancellation
+14 ;ihs/cmi/maw 07/25/2012 concatenate OI on cancellation remarks
NEW X
SET X=$PIECE($GET(^SC(C,"S",SDT,1,IEN,0)),U,4)
IF X]""
SET SDREM=SDREM_"["_X_"]"
SET SDREM=$EXTRACT(SDREM,1,160)
+15 ;SD/478
IF $DATA(^DPT(DFN,"S",NDT,0))
SET SD0=^(0)
IF $PIECE(SD0,"^",2)'["C"
SET SC=+SD0
SET L=L\1+1
SET APL=""
DO FLEN^SDCNP1A
SET ^UTILITY($JOB,"SDCNP",L)=NDT_"^"_SC_"^"_COV_"^"_APL_"^^"_APL_"^^^^^^"_SDSP
DO CHKSO^SDCNP0
+16 ;SD*5.3*414 next line added to set hold variable SCLHOLD for clinic ptr
+17 SET APP=1
SET A1=L\1
SET SCLHOLD=$PIECE(^UTILITY($JOB,"SDCNP",A1),U,2)
DO BEGD^SDCNP0
+18 DO MES
DO NOPE
WRITE !
SET (CNT,L)=0
KILL ^UTILITY($JOB,"SDCNP")
CANQ ;
+1 ;Wait List Message
+2 ;
+3 ; SD*5.3*414
IF $GET(SCLHOLD)'=""
IF '$DATA(SDCLN)
SET SDCLN=SCLHOLD
+4 NEW SDOMES
SET SDOMES=""
IF $GET(SDCLN)'=""
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 SET DIR(0)="E"
DO ^DIR
WRITE !
+9 IF SDAMTYP="P"
KILL SDCLN
+10 KILL SCLHOLD,SC,COV,APP
+11 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