SDAMWI1 ;ALB/MJK - Walk-Ins (cont.) ;JUN 21, 2017
;;5.3;Scheduling;**94,167,206,168,544,627,651,665**;Aug 13, 1993;Build 14
;
MAKE(DFN,SDCL,SDT) ; -- set globals for appt
; input: DFN ; SDCL := clinic# ; SDT := appt d/t
; returned: success := 1
;
N SD,SDAP,SDINP,SC,DA,DIK
S SC=SDCL,X=SDT,SDINP=$$INP^SDAM2(DFN,SDT)
S SD=SDT D EN1^SDM3
S:'$D(^DPT(DFN,"S",0)) ^(0)="^2.98P^^"
S ^DPT(DFN,"S",SDT,0)=SC_"^"_$$STATUS^SDM1A(SC,SDINP,SDT)_"^^^^^4^^^^^^^^^"_SDAPTYP_"^^"_$G(DUZ)_"^"_DT_"^^^^^"_$G(SDXSCAT)_"^W^0"
;xref DATE APPT. MADE field
D
.N DIV
.S DA=SDT,DA(1)=DFN,DIK="^DPT(DA(1),""S"",",DIK(1)=20 D EN1^DIK
.Q
F I=1:1 I '$D(^SC(SC,"S",SDT,1,I)) S:'$D(^(0)) ^(0)="^44.003PA^^" S ^(I,0)=DFN_"^"_SDSL_"^^^^"_DUZ_"^"_DT,^SC(SC,"S",SDT,0)=SDT,SDDA=I D RT,EVT,DUAL,ROUT(DFN) Q
S SDAP=$$APPTGET^SDECUTL(DFN,SDT,SDCL) ;get SDEC APPOINTMENT ien alb/sat 627
I SDAP="" D SDEC ;alb/sat 627
;update availability grid
N HSI,SDDIF,SI,SL,STARTDAY,STR,SDNOT,X,SB,Y,S,I,ST,SS,SM
S SD=SDT,SC=SDCL
I '$D(^SC(SC,"ST",$P(SD,"."),1)) Q 1
S SL=^SC(+SC,"SL"),X=$P(SL,U,3),STARTDAY=$S($L(X):X,1:8),SB=STARTDAY-1/100,X=$P(SL,U,6),HSI=$S(X=1:X,X:X,1:4),SI=$S(X="":4,X<3:4,X:X,1:4),STR="#@!$* XXWVUTSRQPONMLKJIHGFEDCBA0123456789jklmnopqrstuvwxyz",SDDIF=$S(HSI<3:8/HSI,1:2) K Y
SC L +^SC(SC,"ST",$P(SD,"."),1):5 G:'$T SC S S=^SC(SC,"ST",$P(SD,"."),1) S I=SD#1-SB*100,ST=I#1*SI\.6+($P(I,".")*SI),SS=SL*HSI/60*SDDIF+ST+ST G C:(I<1!'$F(S,"["))&(S'["CAN")
S SM=0
I SM<7 S %=$F(S,"[",SS-1) S:'%!($P(SL,"^",6)<3) %=999 I $F(S,"]",SS)'<%!(SDDIF=2&$E(S,ST+ST+1,SS-1)["[") S SM=7
SP I ST+ST>$L(S) S S=S_" " G SP
S SDNOT=1 F I=ST+ST:SDDIF:SS-SDDIF S ST=$E(S,I+1) S:ST="" ST=" " S Y=$E(STR,$F(STR,ST)-2) G C:S["CAN"!(ST="X"&($D(^SC(+SC,"ST",$P(SD,"."),"CAN")))),C:Y="" S:Y'?1NL&(SM<6) SM=6 S ST=$E(S,I+2,999) S:ST="" ST=" " S S=$E(S,1,I)_Y_ST
S ^SC(+SC,"ST",$P(SD,"."),1)=S
C L -^SC(+SC,"ST",$P(SD,"."),1)
Q 1
;
SDEC ;update SDEC APPOINTMENT file 409.84 ;alb/sat 627
N SDAPPT,SDECSL,SDRES ;alb/sat 627 - add SDAPPT ;alb/sat 651 add SDECSL
S SDAPTYP=$G(SDAPTYP)
S:SDAPTYP="" SDAPTYP=$$GET1^DIQ(44,SDCL_",",2507,"I")
S SDECANS=$G(SDECANS) ;alb/sat 665
I $G(SDWL)="" N SDCLN S SDCLN=$$GET1^DIQ(44,SDCL_",",.01) S SDAPPT=$$SDWLA^SDM1A(DFN,SDT,SDCLN,$P(SDT,".",1),SDAPTYP,SDECANS) ;alb/sat 665 add SDECANS
K SDECANS ;alb/sat 665
S SDRES=$$GETRES^SDECUTL(SDCL)
S SDECSL=$G(SL) ;alb/sat 651
I '+SDECSL S SDECSL=$G(^SC(SDCL,"SL")) ;alb/sat 651
D SDECADD^SDEC07(SDT,$S(+SDECSL:$$FMADD^XLFDT(SDT,,,+SDECSL),1:""),DFN,SDRES,"WALKIN",$P(SDT,".",1),"",$S($G(SDWL)'="":"E|"_SDWL,1:"A|"_SDAPPT),,SDCL,,,,SDAPTYP) ;ADD SDEC APPOINTMENT ENTRY ;alb/sat 651 use SDECSL
Q
;end addition/modification ;alb/sat 627
;
RT ; -- request record
S SDRT="A",SDTTM=SDT,SDPL=I,SDSC=SC D RT^SDUTL
Q
;
ROUT(DFN) ; -- print routing slip
S DIR("A")="DO YOU WANT TO PRINT A ROUTING SLIP NOW",DIR(0)="Y"
W ! D ^DIR K DIR G ROUTQ:$D(DIRUT)!(Y=0)
K IOP S (SDX,SDSTART,ORDER,SDREP)="" D EN^SDROUT1
ROUTQ Q
;
DUAL ; -- ask elig if pt has more than one
I $O(VAEL(1,0))>0 S SDEMP="" D ELIG^SDM4:"369"[SDAPTYP S SDEMP=$S(SDDECOD:SDDECOD,1:SDEMP) I +SDEMP S $P(^SC(SC,"S",SDT,1,I,0),"^",10)=+SDEMP K SDEMP
Q
;
EVT ; -- separate if need to NEW vars
N I,DIV D MAKE^SDAMEVT(DFN,SDT,SDCL,SDDA,0)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDAMWI1 3351 printed Oct 16, 2024@18:48:54 Page 2
SDAMWI1 ;ALB/MJK - Walk-Ins (cont.) ;JUN 21, 2017
+1 ;;5.3;Scheduling;**94,167,206,168,544,627,651,665**;Aug 13, 1993;Build 14
+2 ;
MAKE(DFN,SDCL,SDT) ; -- set globals for appt
+1 ; input: DFN ; SDCL := clinic# ; SDT := appt d/t
+2 ; returned: success := 1
+3 ;
+4 NEW SD,SDAP,SDINP,SC,DA,DIK
+5 SET SC=SDCL
SET X=SDT
SET SDINP=$$INP^SDAM2(DFN,SDT)
+6 SET SD=SDT
DO EN1^SDM3
+7 if '$DATA(^DPT(DFN,"S",0))
SET ^(0)="^2.98P^^"
+8 SET ^DPT(DFN,"S",SDT,0)=SC_"^"_$$STATUS^SDM1A(SC,SDINP,SDT)_"^^^^^4^^^^^^^^^"_SDAPTYP_"^^"_$GET(DUZ)_"^"_DT_"^^^^^"_$GET(SDXSCAT)_"^W^0"
+9 ;xref DATE APPT. MADE field
+10 Begin DoDot:1
+11 NEW DIV
+12 SET DA=SDT
SET DA(1)=DFN
SET DIK="^DPT(DA(1),""S"","
SET DIK(1)=20
DO EN1^DIK
+13 QUIT
End DoDot:1
+14 FOR I=1:1
IF '$DATA(^SC(SC,"S",SDT,1,I))
if '$DATA(^(0))
SET ^(0)="^44.003PA^^"
SET ^(I,0)=DFN_"^"_SDSL_"^^^^"_DUZ_"^"_DT
SET ^SC(SC,"S",SDT,0)=SDT
SET SDDA=I
DO RT
DO EVT
DO DUAL
DO ROUT(DFN)
QUIT
+15 ;get SDEC APPOINTMENT ien alb/sat 627
SET SDAP=$$APPTGET^SDECUTL(DFN,SDT,SDCL)
+16 ;alb/sat 627
IF SDAP=""
DO SDEC
+17 ;update availability grid
+18 NEW HSI,SDDIF,SI,SL,STARTDAY,STR,SDNOT,X,SB,Y,S,I,ST,SS,SM
+19 SET SD=SDT
SET SC=SDCL
+20 IF '$DATA(^SC(SC,"ST",$PIECE(SD,"."),1))
QUIT 1
+21 SET SL=^SC(+SC,"SL")
SET X=$PIECE(SL,U,3)
SET STARTDAY=$SELECT($LENGTH(X):X,1:8)
SET SB=STARTDAY-1/100
SET X=$PIECE(SL,U,6)
SET HSI=$SELECT(X=1:X,X:X,1:4)
SET SI=$SELECT(X="":4,X<3:4,X:X,1:4)
SET STR="#@!$* XXWVUTSRQPONMLKJIHGFEDCBA0123456789jklmnopqrstuvwxyz"
SET SDDIF=$SELECT(HSI<3:8/HSI,1:2)
KILL Y
SC LOCK +^SC(SC,"ST",$PIECE(SD,"."),1):5
if '$TEST
GOTO SC
SET S=^SC(SC,"ST",$PIECE(SD,"."),1)
SET I=SD#1-SB*100
SET ST=I#1*SI\.6+($PIECE(I,".")*SI)
SET SS=SL*HSI/60*SDDIF+ST+ST
if (I<1!'$FIND(S,"["))&(S'["CAN")
GOTO C
+1 SET SM=0
+2 IF SM<7
SET %=$FIND(S,"[",SS-1)
if '%!($PIECE(SL,"^",6)<3)
SET %=999
IF $FIND(S,"]",SS)'<%!(SDDIF=2&$EXTRACT(S,ST+ST+1,SS-1)["[")
SET SM=7
SP IF ST+ST>$LENGTH(S)
SET S=S_" "
GOTO SP
+1 SET SDNOT=1
FOR I=ST+ST:SDDIF:SS-SDDIF
SET ST=$EXTRACT(S,I+1)
if ST=""
SET ST=" "
SET Y=$EXTRACT(STR,$FIND(STR,ST)-2)
if S["CAN"!(ST="X"&($DATA(^SC(+SC,"ST",$PIECE(SD,"."),"CAN"))))
GOTO C
if Y=""
GOTO C
if Y'?1NL&(SM<6)
SET SM=6
SET ST=$EXTRACT(S,I+2,999)
if ST=""
SET ST=" "
SET S=$EXTRACT(S,1,I)_Y_ST
+2 SET ^SC(+SC,"ST",$PIECE(SD,"."),1)=S
C LOCK -^SC(+SC,"ST",$PIECE(SD,"."),1)
+1 QUIT 1
+2 ;
SDEC ;update SDEC APPOINTMENT file 409.84 ;alb/sat 627
+1 ;alb/sat 627 - add SDAPPT ;alb/sat 651 add SDECSL
NEW SDAPPT,SDECSL,SDRES
+2 SET SDAPTYP=$GET(SDAPTYP)
+3 if SDAPTYP=""
SET SDAPTYP=$$GET1^DIQ(44,SDCL_",",2507,"I")
+4 ;alb/sat 665
SET SDECANS=$GET(SDECANS)
+5 ;alb/sat 665 add SDECANS
IF $GET(SDWL)=""
NEW SDCLN
SET SDCLN=$$GET1^DIQ(44,SDCL_",",.01)
SET SDAPPT=$$SDWLA^SDM1A(DFN,SDT,SDCLN,$PIECE(SDT,".",1),SDAPTYP,SDECANS)
+6 ;alb/sat 665
KILL SDECANS
+7 SET SDRES=$$GETRES^SDECUTL(SDCL)
+8 ;alb/sat 651
SET SDECSL=$GET(SL)
+9 ;alb/sat 651
IF '+SDECSL
SET SDECSL=$GET(^SC(SDCL,"SL"))
+10 ;ADD SDEC APPOINTMENT ENTRY ;alb/sat 651 use SDECSL
DO SDECADD^SDEC07(SDT,$SELECT(+SDECSL:$$FMADD^XLFDT(SDT,,,+SDECSL),1:""),DFN,SDRES,"WALKIN",$PIECE(SDT,".",1),"",$SELECT($GET(SDWL)'="":"E|"_SDWL,1:"A|"_SDAPPT),,SDCL,,,,SDAPTYP)
+11 QUIT
+12 ;end addition/modification ;alb/sat 627
+13 ;
RT ; -- request record
+1 SET SDRT="A"
SET SDTTM=SDT
SET SDPL=I
SET SDSC=SC
DO RT^SDUTL
+2 QUIT
+3 ;
ROUT(DFN) ; -- print routing slip
+1 SET DIR("A")="DO YOU WANT TO PRINT A ROUTING SLIP NOW"
SET DIR(0)="Y"
+2 WRITE !
DO ^DIR
KILL DIR
if $DATA(DIRUT)!(Y=0)
GOTO ROUTQ
+3 KILL IOP
SET (SDX,SDSTART,ORDER,SDREP)=""
DO EN^SDROUT1
ROUTQ QUIT
+1 ;
DUAL ; -- ask elig if pt has more than one
+1 IF $ORDER(VAEL(1,0))>0
SET SDEMP=""
if "369"[SDAPTYP
DO ELIG^SDM4
SET SDEMP=$SELECT(SDDECOD:SDDECOD,1:SDEMP)
IF +SDEMP
SET $PIECE(^SC(SC,"S",SDT,1,I,0),"^",10)=+SDEMP
KILL SDEMP
+2 QUIT
+3 ;
EVT ; -- separate if need to NEW vars
+1 NEW I,DIV
DO MAKE^SDAMEVT(DFN,SDT,SDCL,SDDA,0)
+2 QUIT