SDB ;FLA/RF,BSN/GRR - SET UP A CLINIC ;9/30/10 15:59
;;5.3;PIMS;**20,63,167,455,1015,1016**;JUN 30, 2012;Build 20
;IHS/ANMC/LJF 6/23/2000 changed edit from input template to call to
; ^BSDB which calls ScreenMan form
; 8/18/2000 added DIC("W") to warn if clinic inactivated
; 9/21/2000 added check so only owners can access clinics
;
S SDTOP=1,SDZQ=1 K SDREACT
C Q:$D(SDREACT)!('$D(SDTOP)) W !! D DT^DICRW S (DLAYGO,DIC)=44,DIC(0)="MAQEZL",DIC("A")="Select CLINIC NAME: ",DIC("DR")="2////C",DIC("S")="I $P(^(0),""^"",3)=""C"",'$G(^(""OOS""))" K SDREACT
D TURNON^DIAUTL(44,".01;8;2502;2503;2505;2506")
S DIC("W")=$$INACTMSG^BSDU ;IHS/ANMC/LJF 8/18/2000
D ^DIC K DIC("A"),DIC("S") G:Y<0 END S DIE=44,DA=+Y S:$P(Y,U,3)=1 DIE("NO^")=""
I '$$OWNER^BSDU(+Y,+$G(DUZ)) D MSG^BDGF("You are NOT an owner of this clinic. Please select again.",2,1) G C ;IHS/ANMC/LJF 9/21/2000
K SDIN,SDINH,SDRE,SDRE1 I $D(^SC(DA,"I")),+^("I")>0 S SDIN=+^("I"),SDINH=SDIN,SDRE=+$P(^("I"),"^",2)
;S DR="[SDB]" S:'$D(^SC(DA,"ST",0)) ^SC(DA,"ST",0)="^44.005" D ^DIE K DIE("NO^") ;IHS/ANMC/LJF 6/23/2000
S DR="[SDB]" S:'$D(^SC(DA,"ST",0)) ^SC(DA,"ST",0)="^44.005" D SETUP^BSDB(DA) K DIE("NO^") ;IHS/ANMC/LJF 6/23/2000
EN ;Q:$D(SDONE)&('$D(SDTOP)) SD*5.3*455 added 2nd Go on next line
G C:'$D(^SC(DA,"SL")) G C:'+$G(^SC(DA,"SL")) S SL=^("SL"),STARTDAY=8,X=$P(SL,U,3),D=$P(SL,U,6),SI=$S(D:D,1:4),DIC(0)="MAQEZL",(DIC,DIE)="^SC("_DA_",""T"",",DIC("W")=$P($T(DOW),";",3) S:'$D(^("T",0)) ^(0)="^44.002D" S:$L(X) STARTDAY=X
;K SDREACT
G1 D:$D(SDREACT)&('$D(SDTOP)) E1 S SI=$P(SL,"^",6) K Y,HY S SDFSW="" S:$D(SDINH) SDIN=SDINH D PRINT
S (SDREB,SDEL)=0,(SDSAV,SDPAT)="" R !!,"AVAILABILITY DATE: ",X:DTIME Q:U[X&$D(SDREACT) G C:U[X S %DT="EFX" K Y D ^%DT G HLPD^SDB1:X["?" S POP=0 I $D(SDIN),$S(SDIN>Y!(SDIN=0):0,(SDRE'>Y&(SDRE'=0))!(SDRE=0&(SDIN=0)):0,1:1) D INACT G:POP G1
G EN:$D(SDONE)&(Y<0)&('$D(SDTOP)),EN:$D(SDREACT)&(Y<0),C:Y<0&('$D(SDREACT)) S SD=Y,X=Y D DOW^SDM0 S DOW=Y
D EN1^SDB0 Q:$D(SDREACT)
END K %,%DT,%H,C,CCXN,CNT,COLLAT,CTR,D0,DA,DFN,DG,DGO,DH,DI,DIC,DIE,DIFLD,DIK,DK,DL,DLAYGO,DM,DOW,DR,ENDATE,H1,H2,HSI,I,J,LT,M1,M2,MAX,NSL,POP,S,SB,SC,SD,SDAV,SDCL,SDDIF,SDEL,SDFSW,SDHX,SDIN,SDINA,SDINH,SDREACT,SDSDL,SDL,SDLA,SDMAX,SDMM,SDPAT
K SDRE,SDREB,SDRVE,SDSAV,SDSOH,SDT,SDTOP,SDW,SDZQ,SDA1,SI,SL,SLT,SM,SS,SDSTRTDT,STARTDAY,STIME,STR,T1,T2,WY,X,Y,Y1,ZDX
Q
INACT Q:Y<0 S POP=1,Y=SDIN D DTS^SDUTL S Y1=Y,Y=SDRE D:Y DTS^SDUTL W !,*7,"Clinic is inactive",$S('SDRE:" as of ",1:" from "),Y1,$S('SDRE:"",1:" to "_Y) Q
;
E1 S:'$D(^SC(DA,"T"_DOW,9999999,1))&($O(^SC(DA,"T"_DOW,0))>0) ^SC(DA,"T"_DOW,9999999,1)="",^(0)=9999999 D TX^SDB1 S:'$D(SDRE) SDRE=D0 Q
DOW ;;S %=$E(^(0),1,3),I=$E(^(0),4,5),I=I>2&'(%#4)+$E("144025036146",I) X "F %=%:-1:281 S I=%#4=1+1+I" W " ",$P("SUN^MON^TUES^WEDNES^THURS^FRI^SATUR",U,$E(^(0),6,7)+I#7+1),"DAY"
Q
PRINT ;Print cancelled days
N Y I '$D(^TMP("SDAVAIL",$J)) G PRINTQ
W !,"Availability has been cancelled previously. The day(s) has been overwritten",!,"with the new availability. Would you like to see the day(s) that has been affected"
S %=1 D YN^DICN G:%=-1!(%=2) PRINTQ I %=0 D HELP G PRINT
S %ZIS="PMQ" D ^%ZIS I POP G PRINTQ
I '$D(IO("Q")) G PRINT1
S Y=$$QUE(0) G PRINTQ
;
PRINT1 N SDAVAIL,SDLINE S SDAVAIL=0,$P(SDLINE,"=",80)=""
U IO W !,"Dates of Availability Previously Cancelled for "_$E($P($G(^SC(DA,0)),U),1,25),?70,$$FDATE^VALM1(DT),!,SDLINE
F S SDAVAIL=$O(^TMP("SDAVAIL",$J,SDAVAIL)) Q:'SDAVAIL D
.W !,$$FDATE^VALM1(SDAVAIL)_" "_$G(^TMP("SDAVAIL",$J,SDAVAIL))
;
PRINTQ K ^TMP("SDAVAIL",$J)
D:'$D(ZTQUEUED) ^%ZISC
Q
HELP ;
W !,"Answer 'Y'es or 'N'o."
Q
QUE(X) ; -- que job
; return: did job que [ 1|yes 0|no ]
;
K ZTSK,IO("Q")
S ZTDESC="Previously Cancelled Availability Dates",ZTRTN="PRINT1^SDB"
F S X=$O(^TMP("SDAVAIL",$J,X)) Q:'X D
.S ZTSAVE("^TMP(""SDAVAIL"",$J,")=^TMP("SDAVAIL",$J,X)
S ZTSAVE("DA")=DA
D ^%ZTLOAD W:$D(ZTSK) " (Task: ",ZTSK,")"
Q $D(ZTSK)
SDB ;FLA/RF,BSN/GRR - SET UP A CLINIC ;9/30/10 15:59
+1 ;;5.3;PIMS;**20,63,167,455,1015,1016**;JUN 30, 2012;Build 20
+2 ;IHS/ANMC/LJF 6/23/2000 changed edit from input template to call to
+3 ; ^BSDB which calls ScreenMan form
+4 ; 8/18/2000 added DIC("W") to warn if clinic inactivated
+5 ; 9/21/2000 added check so only owners can access clinics
+6 ;
+7 SET SDTOP=1
SET SDZQ=1
KILL SDREACT
C IF $DATA(SDREACT)!('$DATA(SDTOP))
QUIT
WRITE !!
DO DT^DICRW
SET (DLAYGO,DIC)=44
SET DIC(0)="MAQEZL"
SET DIC("A")="Select CLINIC NAME: "
SET DIC("DR")="2////C"
SET DIC("S")="I $P(^(0),""^"",3)=""C"",'$G(^(""OOS""))"
KILL SDREACT
+1 DO TURNON^DIAUTL(44,".01;8;2502;2503;2505;2506")
+2 ;IHS/ANMC/LJF 8/18/2000
SET DIC("W")=$$INACTMSG^BSDU
+3 DO ^DIC
KILL DIC("A"),DIC("S")
IF Y<0
GOTO END
SET DIE=44
SET DA=+Y
IF $PIECE(Y,U,3)=1
SET DIE("NO^")=""
+4 ;IHS/ANMC/LJF 9/21/2000
IF '$$OWNER^BSDU(+Y,+$GET(DUZ))
DO MSG^BDGF("You are NOT an owner of this clinic. Please select again.",2,1)
GOTO C
+5 KILL SDIN,SDINH,SDRE,SDRE1
IF $DATA(^SC(DA,"I"))
IF +^("I")>0
SET SDIN=+^("I")
SET SDINH=SDIN
SET SDRE=+$PIECE(^("I"),"^",2)
+6 ;S DR="[SDB]" S:'$D(^SC(DA,"ST",0)) ^SC(DA,"ST",0)="^44.005" D ^DIE K DIE("NO^") ;IHS/ANMC/LJF 6/23/2000
+7 ;IHS/ANMC/LJF 6/23/2000
SET DR="[SDB]"
IF '$DATA(^SC(DA,"ST",0))
SET ^SC(DA,"ST",0)="^44.005"
DO SETUP^BSDB(DA)
KILL DIE("NO^")
EN ;Q:$D(SDONE)&('$D(SDTOP)) SD*5.3*455 added 2nd Go on next line
+1 IF '$DATA(^SC(DA,"SL"))
GOTO C
IF '+$GET(^SC(DA,"SL"))
GOTO C
SET SL=^("SL")
SET STARTDAY=8
SET X=$PIECE(SL,U,3)
SET D=$PIECE(SL,U,6)
SET SI=$SELECT(D:D,1:4)
SET DIC(0)="MAQEZL"
SET (DIC,DIE)="^SC("_DA_",""T"","
SET DIC("W")=$PIECE($TEXT(DOW),";",3)
IF '$DATA(^("T",0))
SET ^(0)="^44.002D"
IF $LENGTH(X)
SET STARTDAY=X
+2 ;K SDREACT
G1 IF $DATA(SDREACT)&('$DATA(SDTOP))
DO E1
SET SI=$PIECE(SL,"^",6)
KILL Y,HY
SET SDFSW=""
IF $DATA(SDINH)
SET SDIN=SDINH
DO PRINT
+1 SET (SDREB,SDEL)=0
SET (SDSAV,SDPAT)=""
READ !!,"AVAILABILITY DATE: ",X:DTIME
IF U[X&$DATA(SDREACT)
QUIT
IF U[X
GOTO C
SET %DT="EFX"
KILL Y
DO ^%DT
IF X["?"
GOTO HLPD^SDB1
SET POP=0
IF $DATA(SDIN)
IF $SELECT(SDIN>Y!(SDIN=0):0,(SDRE'>Y&(SDRE'=0))!(SDRE=0&(SDIN=0)):0,1:1)
DO INACT
IF POP
GOTO G1
+2 IF $DATA(SDONE)&(Y<0)&('$DATA(SDTOP))
GOTO EN
IF $DATA(SDREACT)&(Y<0)
GOTO EN
IF Y<0&('$DATA(SDREACT))
GOTO C
SET SD=Y
SET X=Y
DO DOW^SDM0
SET DOW=Y
+3 DO EN1^SDB0
IF $DATA(SDREACT)
QUIT
END KILL %,%DT,%H,C,CCXN,CNT,COLLAT,CTR,D0,DA,DFN,DG,DGO,DH,DI,DIC,DIE,DIFLD,DIK,DK,DL,DLAYGO,DM,DOW,DR,ENDATE,H1,H2,HSI,I,J,LT,M1,M2,MAX,NSL,POP,S,SB,SC,SD,SDAV,SDCL,SDDIF,SDEL,SDFSW,SDHX,SDIN,SDINA,SDINH,SDREACT,SDSDL,SDL,SDLA,SDMAX,SDMM,SDPAT
+1 KILL SDRE,SDREB,SDRVE,SDSAV,SDSOH,SDT,SDTOP,SDW,SDZQ,SDA1,SI,SL,SLT,SM,SS,SDSTRTDT,STARTDAY,STIME,STR,T1,T2,WY,X,Y,Y1,ZDX
+2 QUIT
INACT IF Y<0
QUIT
SET POP=1
SET Y=SDIN
DO DTS^SDUTL
SET Y1=Y
SET Y=SDRE
IF Y
DO DTS^SDUTL
WRITE !,*7,"Clinic is inactive",$SELECT('SDRE:" as of ",1:" from "),Y1,$SELECT('SDRE:"",1:" to "_Y)
QUIT
+1 ;
E1 IF '$DATA(^SC(DA,"T"_DOW,9999999,1))&($ORDER(^SC(DA,"T"_DOW,0))>0)
SET ^SC(DA,"T"_DOW,9999999,1)=""
SET ^(0)=9999999
DO TX^SDB1
IF '$DATA(SDRE)
SET SDRE=D0
QUIT
DOW ;;S %=$E(^(0),1,3),I=$E(^(0),4,5),I=I>2&'(%#4)+$E("144025036146",I) X "F %=%:-1:281 S I=%#4=1+1+I" W " ",$P("SUN^MON^TUES^WEDNES^THURS^FRI^SATUR",U,$E(^(0),6,7)+I#7+1),"DAY"
+1 QUIT
PRINT ;Print cancelled days
+1 NEW Y
IF '$DATA(^TMP("SDAVAIL",$JOB))
GOTO PRINTQ
+2 WRITE !,"Availability has been cancelled previously. The day(s) has been overwritten",!,"with the new availability. Would you like to see the day(s) that has been affected"
+3 SET %=1
DO YN^DICN
IF %=-1!(%=2)
GOTO PRINTQ
IF %=0
DO HELP
GOTO PRINT
+4 SET %ZIS="PMQ"
DO ^%ZIS
IF POP
GOTO PRINTQ
+5 IF '$DATA(IO("Q"))
GOTO PRINT1
+6 SET Y=$$QUE(0)
GOTO PRINTQ
+7 ;
PRINT1 NEW SDAVAIL,SDLINE
SET SDAVAIL=0
SET $PIECE(SDLINE,"=",80)=""
+1 USE IO
WRITE !,"Dates of Availability Previously Cancelled for "_$EXTRACT($PIECE($GET(^SC(DA,0)),U),1,25),?70,$$FDATE^VALM1(DT),!,SDLINE
+2 FOR
SET SDAVAIL=$ORDER(^TMP("SDAVAIL",$JOB,SDAVAIL))
IF 'SDAVAIL
QUIT
Begin DoDot:1
+3 WRITE !,$$FDATE^VALM1(SDAVAIL)_" "_$GET(^TMP("SDAVAIL",$JOB,SDAVAIL))
End DoDot:1
+4 ;
PRINTQ KILL ^TMP("SDAVAIL",$JOB)
+1 IF '$DATA(ZTQUEUED)
DO ^%ZISC
+2 QUIT
HELP ;
+1 WRITE !,"Answer 'Y'es or 'N'o."
+2 QUIT
QUE(X) ; -- que job
+1 ; return: did job que [ 1|yes 0|no ]
+2 ;
+3 KILL ZTSK,IO("Q")
+4 SET ZTDESC="Previously Cancelled Availability Dates"
SET ZTRTN="PRINT1^SDB"
+5 FOR
SET X=$ORDER(^TMP("SDAVAIL",$JOB,X))
IF 'X
QUIT
Begin DoDot:1
+6 SET ZTSAVE("^TMP(""SDAVAIL"",$J,")=^TMP("SDAVAIL",$JOB,X)
End DoDot:1
+7 SET ZTSAVE("DA")=DA
+8 DO ^%ZTLOAD
IF $DATA(ZTSK)
WRITE " (Task: ",ZTSK,")"
+9 QUIT $DATA(ZTSK)