DGSATX ; GENERATED FROM 'DGSCHADMIT' INPUT TEMPLATE(#433), FILE 41.1;12/08/20
D DE G BEGIN
DE S DIE="^DGS(41.1,",DIC=DIE,DP=41.1,DL=1,DIEL=0,DU="" K DG,DE,DB Q:$O(^DGS(41.1,DA,""))=""
I $D(^(0)) S %Z=^(0) S %=$P(%Z,U,2) S:%]"" DE(4)=% S %=$P(%Z,U,3) S:%]"" DE(16)=% S %=$P(%Z,U,4) S:%]"" DE(17)=% S %=$P(%Z,U,5) S:%]"" DE(18)=% S %=$P(%Z,U,6) S:%]"" DE(19)=% S %=$P(%Z,U,7) S:%]"" DE(20)=% S %=$P(%Z,U,8) S:%]"" DE(7)=%
I S %=$P(%Z,U,9) S:%]"" DE(14)=% S %=$P(%Z,U,10) S:%]"" DE(5)=% S %=$P(%Z,U,11) S:%]"" DE(3)=% S %=$P(%Z,U,12) S:%]"" DE(15)=%
K %Z Q
;
W W !?DL+DL-2,DLB_": "
Q
O D W W Y W:$X>45 !?9
I $L(Y)>19,'DV,DV'["I",(DV["F"!(DV["K")) G RW^DIR2
W:Y]"" "// " I 'DV,DV["I",$D(DE(DQ))#2 K X S X("FIELD")=DIFLD,X("FILE")=DP W " ("_$$EZBLD^DIALOG(710,.X)_")" K X S X="" Q ;**
TR Q:DV["K"&(DUZ(0)'="@") R X:DTIME E S (DTOUT,X)=U W $C(7)
Q
A K DQ(DQ) S DQ=DQ+1
B G @DQ
RE G A:DV["K"&(DUZ(0)'["@"),PR:$D(DE(DQ)) D W,TR
N I X="" G NKEY:$D(^DD("KEY","F",DP,DIFLD)),A:DV'["R",X:'DV,X:D'>0,A
RD G QS:X?."?" I X["^" D D G ^DIE17
I X="@" D D G Z^DIE2
I X=" ",DV["d",DV'["P",$D(^DISV(DUZ,"DIE",DLB)) S X=^(DLB) I DV'["D",DV'["S" W " "_X
T G M^DIE17:DV,^DIE3:DV["V",P:DV'["S" I X?.ANP D SET^DIED I 'DDER G V
K DDER G X
P I DV["P" S DIC=U_DU,DIC(0)=$E("EN",$D(DB(DQ))+1)_"M"_$E("L",DV'["'") S:DIC(0)["L" DLAYGO=+$P(DV,"P",2) G:DV["*" AST^DIED D NOSCR^DIED S X=+Y,DIC=DIE G X:X<0
G V:DV'["N" D D I $L($P(X,"."))>24 K X G Z
I $P(DQ(DQ),U,5)'["$",X?.1"-".N.1".".N,$P(DQ(DQ),U,5,99)["+X'=X" S X=+X
V D @("X"_DQ) K YS
UNIQ I DV["U",$D(X),DIFLD=.01 K % M %=@(DIE_"""B"",X)") K %(DA) K:$O(%(0)) X
Z K DIC("S"),DLAYGO I $D(X),X'=U D:$G(DE(DW,"INDEX")) SAVEVALS G:'$$KEYCHK UNIQFERR^DIE17 S DG(DW)=X S:DV["d" ^DISV(DUZ,"DIE",DLB)=X G A
X W:'$D(ZTQUEUED) $C(7),"??" I $D(DB(DQ)) G Z^DIE17
S X="?BAD"
QS S DZ=X D D,QQ^DIEQ G B
D S D=DIFLD,DQ(DQ)=DLB_U_DV_U_DU_U_DW_U_$P($T(@("X"_DQ))," ",2,99) Q
Y I '$D(DE(DQ)) D O G RD:"@"'[X,A:DV'["R"&(X="@"),X:X="@" S X=Y G N
PR S DG=DV,Y=DE(DQ),X=DU I $D(DQ(DQ,2)) X DQ(DQ,2) G RP
R I DG["P",@("$D(^"_X_"0))") S X=+$P(^(0),U,2) G RP:'$D(^(Y,0)) S Y=$P(^(0),U),X=$P(^DD(X,.01,0),U,3),DG=$P(^(0),U,2) G R
I DG["V",+Y,$P(Y,";",2)["(",$D(@(U_$P(Y,";",2)_"0)")) S X=+$P(^(0),U,2) G RP:'$D(^(+Y,0)) S Y=$P(^(0),U) I $D(^DD(+X,.01,0)) S DG=$P(^(0),U,2),X=$P(^(0),U,3) G R
X:DG["D" ^DD("DD") I DG["S" S %=$P($P(";"_X,";"_Y_":",2),";") I %]"" S Y=$S($G(DUZ("LANG"))'>1:%,'DIFLD:%,1:$$SET^DIQ(DP,DIFLD,Y))
RP D O I X="" S X=DE(DQ) G A:'DV,A:DC<2,N^DIE17
I I DV'["I",DV'["#" G RD
D E^DIE0 G RD:$D(X),PR
Q
SAVEVALS S @DIEZTMP@("V",DP,DIIENS,DIFLD,"O")=$G(DE(DQ)) S:$D(^("F"))[0 ^("F")=$G(DE(DQ))
I $D(DE(DW,"4/")) S @DIEZTMP@("V",DP,DIIENS,DIFLD,"4/")=""
E K @DIEZTMP@("V",DP,DIIENS,DIFLD,"4/")
Q
NKEY W:'$D(ZTQUEUED) "?? Required key field" S X="?BAD" G QS
KEYCHK() Q:$G(DE(DW,"KEY"))="" 1 Q @DE(DW,"KEY")
BEGIN S DNM="DGSATX",DQ=1
N DIEZTMP,DIEZAR,DIEZRXR,DIIENS,DIXR K DIEFIRE,DIEBADK S DIEZTMP=$$GETTMP^DIKC1("DIEZ")
M DIEZAR=^DIE(433,"AR") S DICRREC="TRIG^DIE17"
S:$D(DTIME)[0 DTIME=300 S D0=DA,DIIENS=DA_",",DIEZ=433,U="^"
1 D:$D(DG)>9 F^DIE17,DE S Y=U,DQ=1 D X1 D:$D(DIEFIRE)#2 FIREREC^DIE17 G A:$D(Y)[0,A:Y=U S X=Y,DIC(0)="F",DW=DQ G OUT^DIE17
X1 I '$D(DGDIV)!('$D(DUZ)#2) W !!,*7,"NECESSARY VARIABLES NOT DEFINED!!" S Y=0
Q
2 D:$D(DG)>9 F^DIE17,DE S Y=U,DQ=2 D X2 D:$D(DIEFIRE)#2 FIREREC^DIE17 G A:$D(Y)[0,A:Y=U S X=Y,DIC(0)="F",DW=DQ G OUT^DIE17
X2 S DGSDIV=$P(DGDIV,"^",2)
Q
3 S DW="0;11",DV="P200'",DU="",DIFLD=11,DLB=$$LABEL^DIALOGZ(DP,DIFLD)
S DE(DW)="C3^DGSATX",DE(DW,"INDEX")=1
S DU="VA(200,"
S X=DUZ
S Y=X
S X=Y,DB(DQ)=1,DE(DW,"4/")="" G:X="" N^DIE17:DV,A I $D(DE(DQ)),DV["I"!(DV["#") D E^DIE0 G A:'$D(X)
G RD:X="@",Z
C3 G C3S:$D(DE(3))[0 K DB
C3S S X="" G:DG(DQ)=X C3F1 K DB
C3F1 S DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NA(@$$CREF^DILF(DIE)))
F DIXR=837 S DIEZRXR(41.1,DIXR)=""
Q
X3 Q
4 D:$D(DG)>9 F^DIE17,DE S DQ=4,DW="0;2",DV="RDX",DU="",DIFLD=2,DLB=$$LABEL^DIALOGZ(DP,DIFLD)
S DE(DW)="C4^DGSATX",DE(DW,"INDEX")=1
G RE
C4 G C4S:$D(DE(4))[0 K DB
S X=DE(4),DIC=DIE
K ^DGS(41.1,"C",$E(X,1,30),DA)
C4S S X="" G:DG(DQ)=X C4F1 K DB
S X=DG(DQ),DIC=DIE
S ^DGS(41.1,"C",$E(X,1,30),DA)=""
C4F1 S DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NA(@$$CREF^DILF(DIE)))
F DIXR=837 S DIEZRXR(41.1,DIXR)=""
Q
X4 S %DT="ERTX" D ^%DT S X=Y K:Y<1 X
Q
;
5 D:$D(DG)>9 F^DIE17,DE S DQ=5,DW="0;10",DV="RS",DU="",DIFLD=10,DLB=$$LABEL^DIALOGZ(DP,DIFLD)
S DE(DW)="C5^DGSATX",DE(DW,"INDEX")=1
S DU="W:WARD;T:TREATING SPECIALTY;"
G RE
C5 G C5S:$D(DE(5))[0 K DB
S X=DE(5),DIC=DIE
;
S X=DE(5),DIC=DIE
;
C5S S X="" G:DG(DQ)=X C5F1 K DB
S X=DG(DQ),DIC=DIE
X ^DD(41.1,10,1,1,1.3) I X S X=DIV S Y(1)=$S($D(^DGS(41.1,D0,0)):^(0),1:"") S X=$P(Y(1),U,8),X=X S DIU=X K Y S X="" X ^DD(41.1,10,1,1,1.4)
S X=DG(DQ),DIC=DIE
X ^DD(41.1,10,1,2,1.3) I X S X=DIV S Y(1)=$S($D(^DGS(41.1,D0,0)):^(0),1:"") S X=$P(Y(1),U,9),X=X S DIU=X K Y S X="" X ^DD(41.1,10,1,2,1.4)
C5F1 S DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NA(@$$CREF^DILF(DIE)))
F DIXR=837 S DIEZRXR(41.1,DIXR)=""
Q
X5 Q
6 D:$D(DG)>9 F^DIE17,DE S Y=U,DQ=6 D X6 D:$D(DIEFIRE)#2 FIREREC^DIE17 G A:$D(Y)[0,A:Y=U S X=Y,DIC(0)="F",DW=DQ G OUT^DIE17
X6 S:X="T" Y=9
Q
7 D:$D(DG)>9 F^DIE17,DE S DQ=7,DW="0;8",DV="R*P42'",DU="",DIFLD=8,DLB=$$LABEL^DIALOGZ(DP,DIFLD)
S DE(DW)="C7^DGSATX",DE(DW,"INDEX")=1
S DU="DIC(42,"
G RE
C7 G C7S:$D(DE(7))[0 K DB
S X=DE(7),DIC=DIE
K ^DGS(41.1,"ARSV",$E(X,1,30),DA)
S X=DE(7),DIC=DIE
K DIV S DIV=X,D0=DA,DIV(0)=D0 S Y(1)=$S($D(^DGS(41.1,D0,0)):^(0),1:"") S X=$P(Y(1),U,12),X=X S DIU=X K Y S X="" X ^DD(41.1,8,1,2,2.4)
C7S S X="" G:DG(DQ)=X C7F1 K DB
S X=DG(DQ),DIC=DIE
S ^DGS(41.1,"ARSV",$E(X,1,30),DA)=""
S X=DG(DQ),DIC=DIE
K DIV S DIV=X,D0=DA,DIV(0)=D0 S Y(1)=$S($D(^DGS(41.1,D0,0)):^(0),1:"") S X=$P(Y(1),U,12),X=X S DIU=X K Y X ^DD(41.1,8,1,2,1.1) X ^DD(41.1,8,1,2,1.4)
C7F1 S DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NA(@$$CREF^DILF(DIE)))
F DIXR=837 S DIEZRXR(41.1,DIXR)=""
Q
X7 S DIC("S")="I $S($D(^(""I"")):^(""I"")="""",1:1)" D ^DIC K DIC S DIC=DIE,X=+Y K:Y<0 X
Q
;
8 D:$D(DG)>9 F^DIE17,DE S Y=U,DQ=8 D X8 D:$D(DIEFIRE)#2 FIREREC^DIE17 G A:$D(Y)[0,A:Y=U S X=Y,DIC(0)="F",DW=DQ G OUT^DIE17
X8 S DGJJ=$$WACT^DGSCHAD(X,$P(^DGS(41.1,DA,0),U,2))
Q
9 D:$D(DG)>9 F^DIE17,DE S Y=U,DQ=9 D X9 D:$D(DIEFIRE)#2 FIREREC^DIE17 G A:$D(Y)[0,A:Y=U S X=Y,DIC(0)="F",DW=DQ G OUT^DIE17
X9 I DGJJ=0 W !!,*7,"Ward OUT-OF-SERVICE on selected date... Try again!",! S Y=2,$P(^DGS(41.1,DA,0),U,8)=""
Q
10 D:$D(DG)>9 F^DIE17,DE S Y=U,DQ=10 D X10 D:$D(DIEFIRE)#2 FIREREC^DIE17 G A:$D(Y)[0,A:Y=U S X=Y,DIC(0)="F",DW=DQ G OUT^DIE17
X10 I DGJJ=-1 W !!,*7,"???... Try again.",! S Y=2,$P(^DGS(41.1,DA,0),U,8)=""
Q
11 D:$D(DG)>9 F^DIE17,DE S Y=U,DQ=11 D X11 D:$D(DIEFIRE)#2 FIREREC^DIE17 G A:$D(Y)[0,A:Y=U S X=Y,DIC(0)="F",DW=DQ G OUT^DIE17
X11 I DGJJ=1 W !,"Ward will be in-service on selected date.",!
Q
12 D:$D(DG)>9 F^DIE17,DE S Y=U,DQ=12 D X12 D:$D(DIEFIRE)#2 FIREREC^DIE17 G A:$D(Y)[0,A:Y=U S X=Y,DIC(0)="F",DW=DQ G OUT^DIE17
X12 I X,'DGDIV S DGSDIV=$S($D(^DIC(42,+X,0)):+$P(^(0),"^",11),1:"") I DGSDIV S DGSDIV=$S($D(^DG(40.8,+DGSDIV,0)):$P(^(0),"^",1),1:"")
Q
13 D:$D(DG)>9 F^DIE17,DE S Y=U,DQ=13 D X13 D:$D(DIEFIRE)#2 FIREREC^DIE17 G A:$D(Y)[0,A:Y=U S X=Y,DIC(0)="F",DW=DQ G OUT^DIE17
X13 S Y=12
Q
14 D:$D(DG)>9 F^DIE17,DE S DQ=14,DW="0;9",DV="R*P45.7'",DU="",DIFLD=9,DLB=$$LABEL^DIALOGZ(DP,DIFLD)
S DE(DW)="C14^DGSATX",DE(DW,"INDEX")=1
S DU="DIC(45.7,"
G RE
C14 G C14S:$D(DE(14))[0 K DB
C14S S X="" G:DG(DQ)=X C14F1 K DB
C14F1 S DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NA(@$$CREF^DILF(DIE)))
F DIXR=837 S DIEZRXR(41.1,DIXR)=""
Q
X14 S DIC("S")="I $$ACTIVE^DGACT(45.7,Y,$P($G(^DGS(41.1,DA,0)),U,2))" D ^DIC K DIC S DIC=DIE,X=+Y K:Y<0 X
Q
;
15 D:$D(DG)>9 F^DIE17,DE S DQ=15,DW="0;12",DV="*P40.8'",DU="",DIFLD=12,DLB=$$LABEL^DIALOGZ(DP,DIFLD)
S DE(DW)="C15^DGSATX",DE(DW,"INDEX")=1
S DU="DG(40.8,"
S X=DGSDIV
S Y=X
G Y
C15 G C15S:$D(DE(15))[0 K DB
C15S S X="" G:DG(DQ)=X C15F1 K DB
C15F1 S DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NA(@$$CREF^DILF(DIE)))
F DIXR=837 S DIEZRXR(41.1,DIXR)=""
Q
X15 S DIC("S")="I '$P(^(0),U,3)" D ^DIC K DIC S DIC=DIE,X=+Y K:Y<0 X
Q
;
16 D:$D(DG)>9 F^DIE17,DE S DQ=16,DW="0;3",DV="NJ3,0",DU="",DIFLD=3,DLB=$$LABEL^DIALOGZ(DP,DIFLD)
S DE(DW)="C16^DGSATX",DE(DW,"INDEX")=1
G RE
C16 G C16S:$D(DE(16))[0 K DB
C16S S X="" G:DG(DQ)=X C16F1 K DB
C16F1 S DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NA(@$$CREF^DILF(DIE)))
F DIXR=837 S DIEZRXR(41.1,DIXR)=""
Q
X16 K:+X'=X!(X>999)!(X<0)!(X?.E1"."1N.N) X
Q
;
17 D:$D(DG)>9 F^DIE17,DE S DQ=17,DW="0;4",DV="RF",DU="",DIFLD=4,DLB=$$LABEL^DIALOGZ(DP,DIFLD)
S DE(DW)="C17^DGSATX",DE(DW,"INDEX")=1
G RE
C17 G C17S:$D(DE(17))[0 K DB
C17S S X="" G:DG(DQ)=X C17F1 K DB
C17F1 S DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NA(@$$CREF^DILF(DIE)))
F DIXR=837 S DIEZRXR(41.1,DIXR)=""
Q
X17 K:$L(X)>30!($L(X)<2) X
I $D(X),X'?.ANP K X
Q
;
18 D:$D(DG)>9 F^DIE17,DE S DQ=18,DW="0;5",DV="R*P200'",DU="",DIFLD=5,DLB=$$LABEL^DIALOGZ(DP,DIFLD)
S DE(DW)="C18^DGSATX",DE(DW,"INDEX")=1
S DU="VA(200,"
G RE
C18 G C18S:$D(DE(18))[0 K DB
C18S S X="" G:DG(DQ)=X C18F1 K DB
C18F1 S DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NA(@$$CREF^DILF(DIE)))
F DIXR=837 S DIEZRXR(41.1,DIXR)=""
Q
X18 S DIC("S")="I $$SCREEN^DGPMDD(Y,DA,DT)" D ^DIC K DIC S DIC=DIE,X=+Y K:Y<0 X
Q
;
19 D:$D(DG)>9 F^DIE17,DE S DQ=19,DW="0;6",DV="S",DU="",DIFLD=6,DLB=$$LABEL^DIALOGZ(DP,DIFLD)
S DE(DW)="C19^DGSATX",DE(DW,"INDEX")=1
S DU="Y:YES;N:NO;"
G RE
C19 G C19S:$D(DE(19))[0 K DB
C19S S X="" G:DG(DQ)=X C19F1 K DB
C19F1 S DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NA(@$$CREF^DILF(DIE)))
F DIXR=837 S DIEZRXR(41.1,DIXR)=""
Q
X19 Q
20 D:$D(DG)>9 F^DIE17,DE S DQ=20,DW="0;7",DV="S",DU="",DIFLD=7,DLB=$$LABEL^DIALOGZ(DP,DIFLD)
S DE(DW)="C20^DGSATX",DE(DW,"INDEX")=1
S DU="1:YES;0:NO;"
G RE
C20 G C20S:$D(DE(20))[0 K DB
C20S S X="" G:DG(DQ)=X C20F1 K DB
C20F1 S DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NA(@$$CREF^DILF(DIE)))
F DIXR=837 S DIEZRXR(41.1,DIXR)=""
Q
X20 Q
21 G 0^DIE17
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDGSATX 10112 printed Nov 22, 2024@18:08:43 Page 2
DGSATX ; GENERATED FROM 'DGSCHADMIT' INPUT TEMPLATE(#433), FILE 41.1;12/08/20
+1 DO DE
GOTO BEGIN
DE SET DIE="^DGS(41.1,"
SET DIC=DIE
SET DP=41.1
SET DL=1
SET DIEL=0
SET DU=""
KILL DG,DE,DB
if $ORDER(^DGS(41.1,DA,""))=""
QUIT
+1 IF $DATA(^(0))
SET %Z=^(0)
SET %=$PIECE(%Z,U,2)
if %]""
SET DE(4)=%
SET %=$PIECE(%Z,U,3)
if %]""
SET DE(16)=%
SET %=$PIECE(%Z,U,4)
if %]""
SET DE(17)=%
SET %=$PIECE(%Z,U,5)
if %]""
SET DE(18)=%
SET %=$PIECE(%Z,U,6)
if %]""
SET DE(19)=%
SET %=$PIECE(%Z,U,7)
if %]""
SET DE(20)=%
SET %=$PIECE(%Z,U,8)
if %]""
SET DE(7)=%
+2 IF $TEST
SET %=$PIECE(%Z,U,9)
if %]""
SET DE(14)=%
SET %=$PIECE(%Z,U,10)
if %]""
SET DE(5)=%
SET %=$PIECE(%Z,U,11)
if %]""
SET DE(3)=%
SET %=$PIECE(%Z,U,12)
if %]""
SET DE(15)=%
+3 KILL %Z
QUIT
+4 ;
W WRITE !?DL+DL-2,DLB_": "
+1 QUIT
O DO W
WRITE Y
if $X>45
WRITE !?9
+1 IF $LENGTH(Y)>19
IF 'DV
IF DV'["I"
IF (DV["F"!(DV["K"))
GOTO RW^DIR2
+2 ;**
if Y]""
WRITE "// "
IF 'DV
IF DV["I"
IF $DATA(DE(DQ))#2
KILL X
SET X("FIELD")=DIFLD
SET X("FILE")=DP
WRITE " ("_$$EZBLD^DIALOG(710,.X)_")"
KILL X
SET X=""
QUIT
TR if DV["K"&(DUZ(0)'="@")
QUIT
READ X:DTIME
IF '$TEST
SET (DTOUT,X)=U
WRITE $CHAR(7)
+1 QUIT
A KILL DQ(DQ)
SET DQ=DQ+1
B GOTO @DQ
RE if DV["K"&(DUZ(0)'["@")
GOTO A
if $DATA(DE(DQ))
GOTO PR
DO W
DO TR
N IF X=""
if $DATA(^DD("KEY","F",DP,DIFLD))
GOTO NKEY
if DV'["R"
GOTO A
if 'DV
GOTO X
if D'>0
GOTO X
GOTO A
RD if X?."?"
GOTO QS
IF X["^"
DO D
GOTO ^DIE17
+1 IF X="@"
DO D
GOTO Z^DIE2
+2 IF X=" "
IF DV["d"
IF DV'["P"
IF $DATA(^DISV(DUZ,"DIE",DLB))
SET X=^(DLB)
IF DV'["D"
IF DV'["S"
WRITE " "_X
T if DV
GOTO M^DIE17
if DV["V"
GOTO ^DIE3
if DV'["S"
GOTO P
IF X?.ANP
DO SET^DIED
IF 'DDER
GOTO V
+1 KILL DDER
GOTO X
P IF DV["P"
SET DIC=U_DU
SET DIC(0)=$EXTRACT("EN",$DATA(DB(DQ))+1)_"M"_$EXTRACT("L",DV'["'")
if DIC(0)["L"
SET DLAYGO=+$PIECE(DV,"P",2)
if DV["*"
GOTO AST^DIED
DO NOSCR^DIED
SET X=+Y
SET DIC=DIE
if X<0
GOTO X
+1 if DV'["N"
GOTO V
DO D
IF $LENGTH($PIECE(X,"."))>24
KILL X
GOTO Z
+2 IF $PIECE(DQ(DQ),U,5)'["$"
IF X?.1"-".N.1".".N
IF $PIECE(DQ(DQ),U,5,99)["+X'=X"
SET X=+X
V DO @("X"_DQ)
KILL YS
UNIQ IF DV["U"
IF $DATA(X)
IF DIFLD=.01
KILL %
MERGE %=@(DIE_"""B"",X)")
KILL %(DA)
if $ORDER(%(0))
KILL X
Z KILL DIC("S"),DLAYGO
IF $DATA(X)
IF X'=U
if $GET(DE(DW,"INDEX"))
DO SAVEVALS
if '$$KEYCHK
GOTO UNIQFERR^DIE17
SET DG(DW)=X
if DV["d"
SET ^DISV(DUZ,"DIE",DLB)=X
GOTO A
X if '$DATA(ZTQUEUED)
WRITE $CHAR(7),"??"
IF $DATA(DB(DQ))
GOTO Z^DIE17
+1 SET X="?BAD"
QS SET DZ=X
DO D
DO QQ^DIEQ
GOTO B
D SET D=DIFLD
SET DQ(DQ)=DLB_U_DV_U_DU_U_DW_U_$PIECE($TEXT(@("X"_DQ))," ",2,99)
QUIT
Y IF '$DATA(DE(DQ))
DO O
if "@"'[X
GOTO RD
if DV'["R"&(X="@")
GOTO A
if X="@"
GOTO X
SET X=Y
GOTO N
PR SET DG=DV
SET Y=DE(DQ)
SET X=DU
IF $DATA(DQ(DQ,2))
XECUTE DQ(DQ,2)
GOTO RP
R IF DG["P"
IF @("$D(^"_X_"0))")
SET X=+$PIECE(^(0),U,2)
if '$DATA(^(Y,0))
GOTO RP
SET Y=$PIECE(^(0),U)
SET X=$PIECE(^DD(X,.01,0),U,3)
SET DG=$PIECE(^(0),U,2)
GOTO R
+1 IF DG["V"
IF +Y
IF $PIECE(Y,";",2)["("
IF $DATA(@(U_$PIECE(Y,";",2)_"0)"))
SET X=+$PIECE(^(0),U,2)
if '$DATA(^(+Y,0))
GOTO RP
SET Y=$PIECE(^(0),U)
IF $DATA(^DD(+X,.01,0))
SET DG=$PIECE(^(0),U,2)
SET X=$PIECE(^(0),U,3)
GOTO R
+2 if DG["D"
XECUTE ^DD("DD")
IF DG["S"
SET %=$PIECE($PIECE(";"_X,";"_Y_":",2),";")
IF %]""
SET Y=$SELECT($GET(DUZ("LANG"))'>1:%,'DIFLD:%,1:$$SET^DIQ(DP,DIFLD,Y))
RP DO O
IF X=""
SET X=DE(DQ)
if 'DV
GOTO A
if DC<2
GOTO A
GOTO N^DIE17
I IF DV'["I"
IF DV'["#"
GOTO RD
+1 DO E^DIE0
if $DATA(X)
GOTO RD
GOTO PR
+2 QUIT
SAVEVALS SET @DIEZTMP@("V",DP,DIIENS,DIFLD,"O")=$GET(DE(DQ))
if $DATA(^("F"))[0
SET ^("F")=$GET(DE(DQ))
+1 IF $DATA(DE(DW,"4/"))
SET @DIEZTMP@("V",DP,DIIENS,DIFLD,"4/")=""
+2 IF '$TEST
KILL @DIEZTMP@("V",DP,DIIENS,DIFLD,"4/")
+3 QUIT
NKEY if '$DATA(ZTQUEUED)
WRITE "?? Required key field"
SET X="?BAD"
GOTO QS
KEYCHK() if $GET(DE(DW,"KEY"))=""
QUIT 1
QUIT @DE(DW,"KEY")
BEGIN SET DNM="DGSATX"
SET DQ=1
+1 NEW DIEZTMP,DIEZAR,DIEZRXR,DIIENS,DIXR
KILL DIEFIRE,DIEBADK
SET DIEZTMP=$$GETTMP^DIKC1("DIEZ")
+2 MERGE DIEZAR=^DIE(433,"AR")
SET DICRREC="TRIG^DIE17"
+3 if $DATA(DTIME)[0
SET DTIME=300
SET D0=DA
SET DIIENS=DA_","
SET DIEZ=433
SET U="^"
1 if $DATA(DG)>9
DO F^DIE17
DO DE
SET Y=U
SET DQ=1
DO X1
if $DATA(DIEFIRE)#2
DO FIREREC^DIE17
if $DATA(Y)[0
GOTO A
if Y=U
GOTO A
SET X=Y
SET DIC(0)="F"
SET DW=DQ
GOTO OUT^DIE17
X1 IF '$DATA(DGDIV)!('$DATA(DUZ)#2)
WRITE !!,*7,"NECESSARY VARIABLES NOT DEFINED!!"
SET Y=0
+1 QUIT
2 if $DATA(DG)>9
DO F^DIE17
DO DE
SET Y=U
SET DQ=2
DO X2
if $DATA(DIEFIRE)#2
DO FIREREC^DIE17
if $DATA(Y)[0
GOTO A
if Y=U
GOTO A
SET X=Y
SET DIC(0)="F"
SET DW=DQ
GOTO OUT^DIE17
X2 SET DGSDIV=$PIECE(DGDIV,"^",2)
+1 QUIT
3 SET DW="0;11"
SET DV="P200'"
SET DU=""
SET DIFLD=11
SET DLB=$$LABEL^DIALOGZ(DP,DIFLD)
+1 SET DE(DW)="C3^DGSATX"
SET DE(DW,"INDEX")=1
+2 SET DU="VA(200,"
+3 SET X=DUZ
+4 SET Y=X
+5 SET X=Y
SET DB(DQ)=1
SET DE(DW,"4/")=""
if X=""
if DV
GOTO N^DIE17
GOTO A
IF $DATA(DE(DQ))
IF DV["I"!(DV["#")
DO E^DIE0
if '$DATA(X)
GOTO A
+6 if X="@"
GOTO RD
GOTO Z
C3 if $DATA(DE(3))[0
GOTO C3S
KILL DB
C3S SET X=""
if DG(DQ)=X
GOTO C3F1
KILL DB
C3F1 SET DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NAME(@$$CREF^DILF(DIE)))
+1 FOR DIXR=837
SET DIEZRXR(41.1,DIXR)=""
+2 QUIT
X3 QUIT
4 if $DATA(DG)>9
DO F^DIE17
DO DE
SET DQ=4
SET DW="0;2"
SET DV="RDX"
SET DU=""
SET DIFLD=2
SET DLB=$$LABEL^DIALOGZ(DP,DIFLD)
+1 SET DE(DW)="C4^DGSATX"
SET DE(DW,"INDEX")=1
+2 GOTO RE
C4 if $DATA(DE(4))[0
GOTO C4S
KILL DB
+1 SET X=DE(4)
SET DIC=DIE
+2 KILL ^DGS(41.1,"C",$EXTRACT(X,1,30),DA)
C4S SET X=""
if DG(DQ)=X
GOTO C4F1
KILL DB
+1 SET X=DG(DQ)
SET DIC=DIE
+2 SET ^DGS(41.1,"C",$EXTRACT(X,1,30),DA)=""
C4F1 SET DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NAME(@$$CREF^DILF(DIE)))
+1 FOR DIXR=837
SET DIEZRXR(41.1,DIXR)=""
+2 QUIT
X4 SET %DT="ERTX"
DO ^%DT
SET X=Y
if Y<1
KILL X
+1 QUIT
+2 ;
5 if $DATA(DG)>9
DO F^DIE17
DO DE
SET DQ=5
SET DW="0;10"
SET DV="RS"
SET DU=""
SET DIFLD=10
SET DLB=$$LABEL^DIALOGZ(DP,DIFLD)
+1 SET DE(DW)="C5^DGSATX"
SET DE(DW,"INDEX")=1
+2 SET DU="W:WARD;T:TREATING SPECIALTY;"
+3 GOTO RE
C5 if $DATA(DE(5))[0
GOTO C5S
KILL DB
+1 SET X=DE(5)
SET DIC=DIE
+2 ;
+3 SET X=DE(5)
SET DIC=DIE
+4 ;
C5S SET X=""
if DG(DQ)=X
GOTO C5F1
KILL DB
+1 SET X=DG(DQ)
SET DIC=DIE
+2 XECUTE ^DD(41.1,10,1,1,1.3)
IF X
SET X=DIV
SET Y(1)=$SELECT($DATA(^DGS(41.1,D0,0)):^(0),1:"")
SET X=$PIECE(Y(1),U,8)
SET X=X
SET DIU=X
KILL Y
SET X=""
XECUTE ^DD(41.1,10,1,1,1.4)
+3 SET X=DG(DQ)
SET DIC=DIE
+4 XECUTE ^DD(41.1,10,1,2,1.3)
IF X
SET X=DIV
SET Y(1)=$SELECT($DATA(^DGS(41.1,D0,0)):^(0),1:"")
SET X=$PIECE(Y(1),U,9)
SET X=X
SET DIU=X
KILL Y
SET X=""
XECUTE ^DD(41.1,10,1,2,1.4)
C5F1 SET DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NAME(@$$CREF^DILF(DIE)))
+1 FOR DIXR=837
SET DIEZRXR(41.1,DIXR)=""
+2 QUIT
X5 QUIT
6 if $DATA(DG)>9
DO F^DIE17
DO DE
SET Y=U
SET DQ=6
DO X6
if $DATA(DIEFIRE)#2
DO FIREREC^DIE17
if $DATA(Y)[0
GOTO A
if Y=U
GOTO A
SET X=Y
SET DIC(0)="F"
SET DW=DQ
GOTO OUT^DIE17
X6 if X="T"
SET Y=9
+1 QUIT
7 if $DATA(DG)>9
DO F^DIE17
DO DE
SET DQ=7
SET DW="0;8"
SET DV="R*P42'"
SET DU=""
SET DIFLD=8
SET DLB=$$LABEL^DIALOGZ(DP,DIFLD)
+1 SET DE(DW)="C7^DGSATX"
SET DE(DW,"INDEX")=1
+2 SET DU="DIC(42,"
+3 GOTO RE
C7 if $DATA(DE(7))[0
GOTO C7S
KILL DB
+1 SET X=DE(7)
SET DIC=DIE
+2 KILL ^DGS(41.1,"ARSV",$EXTRACT(X,1,30),DA)
+3 SET X=DE(7)
SET DIC=DIE
+4 KILL DIV
SET DIV=X
SET D0=DA
SET DIV(0)=D0
SET Y(1)=$SELECT($DATA(^DGS(41.1,D0,0)):^(0),1:"")
SET X=$PIECE(Y(1),U,12)
SET X=X
SET DIU=X
KILL Y
SET X=""
XECUTE ^DD(41.1,8,1,2,2.4)
C7S SET X=""
if DG(DQ)=X
GOTO C7F1
KILL DB
+1 SET X=DG(DQ)
SET DIC=DIE
+2 SET ^DGS(41.1,"ARSV",$EXTRACT(X,1,30),DA)=""
+3 SET X=DG(DQ)
SET DIC=DIE
+4 KILL DIV
SET DIV=X
SET D0=DA
SET DIV(0)=D0
SET Y(1)=$SELECT($DATA(^DGS(41.1,D0,0)):^(0),1:"")
SET X=$PIECE(Y(1),U,12)
SET X=X
SET DIU=X
KILL Y
XECUTE ^DD(41.1,8,1,2,1.1)
XECUTE ^DD(41.1,8,1,2,1.4)
C7F1 SET DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NAME(@$$CREF^DILF(DIE)))
+1 FOR DIXR=837
SET DIEZRXR(41.1,DIXR)=""
+2 QUIT
X7 SET DIC("S")="I $S($D(^(""I"")):^(""I"")="""",1:1)"
DO ^DIC
KILL DIC
SET DIC=DIE
SET X=+Y
if Y<0
KILL X
+1 QUIT
+2 ;
8 if $DATA(DG)>9
DO F^DIE17
DO DE
SET Y=U
SET DQ=8
DO X8
if $DATA(DIEFIRE)#2
DO FIREREC^DIE17
if $DATA(Y)[0
GOTO A
if Y=U
GOTO A
SET X=Y
SET DIC(0)="F"
SET DW=DQ
GOTO OUT^DIE17
X8 SET DGJJ=$$WACT^DGSCHAD(X,$PIECE(^DGS(41.1,DA,0),U,2))
+1 QUIT
9 if $DATA(DG)>9
DO F^DIE17
DO DE
SET Y=U
SET DQ=9
DO X9
if $DATA(DIEFIRE)#2
DO FIREREC^DIE17
if $DATA(Y)[0
GOTO A
if Y=U
GOTO A
SET X=Y
SET DIC(0)="F"
SET DW=DQ
GOTO OUT^DIE17
X9 IF DGJJ=0
WRITE !!,*7,"Ward OUT-OF-SERVICE on selected date... Try again!",!
SET Y=2
SET $PIECE(^DGS(41.1,DA,0),U,8)=""
+1 QUIT
10 if $DATA(DG)>9
DO F^DIE17
DO DE
SET Y=U
SET DQ=10
DO X10
if $DATA(DIEFIRE)#2
DO FIREREC^DIE17
if $DATA(Y)[0
GOTO A
if Y=U
GOTO A
SET X=Y
SET DIC(0)="F"
SET DW=DQ
GOTO OUT^DIE17
X10 IF DGJJ=-1
WRITE !!,*7,"???... Try again.",!
SET Y=2
SET $PIECE(^DGS(41.1,DA,0),U,8)=""
+1 QUIT
11 if $DATA(DG)>9
DO F^DIE17
DO DE
SET Y=U
SET DQ=11
DO X11
if $DATA(DIEFIRE)#2
DO FIREREC^DIE17
if $DATA(Y)[0
GOTO A
if Y=U
GOTO A
SET X=Y
SET DIC(0)="F"
SET DW=DQ
GOTO OUT^DIE17
X11 IF DGJJ=1
WRITE !,"Ward will be in-service on selected date.",!
+1 QUIT
12 if $DATA(DG)>9
DO F^DIE17
DO DE
SET Y=U
SET DQ=12
DO X12
if $DATA(DIEFIRE)#2
DO FIREREC^DIE17
if $DATA(Y)[0
GOTO A
if Y=U
GOTO A
SET X=Y
SET DIC(0)="F"
SET DW=DQ
GOTO OUT^DIE17
X12 IF X
IF 'DGDIV
SET DGSDIV=$SELECT($DATA(^DIC(42,+X,0)):+$PIECE(^(0),"^",11),1:"")
IF DGSDIV
SET DGSDIV=$SELECT($DATA(^DG(40.8,+DGSDIV,0)):$PIECE(^(0),"^",1),1:"")
+1 QUIT
13 if $DATA(DG)>9
DO F^DIE17
DO DE
SET Y=U
SET DQ=13
DO X13
if $DATA(DIEFIRE)#2
DO FIREREC^DIE17
if $DATA(Y)[0
GOTO A
if Y=U
GOTO A
SET X=Y
SET DIC(0)="F"
SET DW=DQ
GOTO OUT^DIE17
X13 SET Y=12
+1 QUIT
14 if $DATA(DG)>9
DO F^DIE17
DO DE
SET DQ=14
SET DW="0;9"
SET DV="R*P45.7'"
SET DU=""
SET DIFLD=9
SET DLB=$$LABEL^DIALOGZ(DP,DIFLD)
+1 SET DE(DW)="C14^DGSATX"
SET DE(DW,"INDEX")=1
+2 SET DU="DIC(45.7,"
+3 GOTO RE
C14 if $DATA(DE(14))[0
GOTO C14S
KILL DB
C14S SET X=""
if DG(DQ)=X
GOTO C14F1
KILL DB
C14F1 SET DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NAME(@$$CREF^DILF(DIE)))
+1 FOR DIXR=837
SET DIEZRXR(41.1,DIXR)=""
+2 QUIT
X14 SET DIC("S")="I $$ACTIVE^DGACT(45.7,Y,$P($G(^DGS(41.1,DA,0)),U,2))"
DO ^DIC
KILL DIC
SET DIC=DIE
SET X=+Y
if Y<0
KILL X
+1 QUIT
+2 ;
15 if $DATA(DG)>9
DO F^DIE17
DO DE
SET DQ=15
SET DW="0;12"
SET DV="*P40.8'"
SET DU=""
SET DIFLD=12
SET DLB=$$LABEL^DIALOGZ(DP,DIFLD)
+1 SET DE(DW)="C15^DGSATX"
SET DE(DW,"INDEX")=1
+2 SET DU="DG(40.8,"
+3 SET X=DGSDIV
+4 SET Y=X
+5 GOTO Y
C15 if $DATA(DE(15))[0
GOTO C15S
KILL DB
C15S SET X=""
if DG(DQ)=X
GOTO C15F1
KILL DB
C15F1 SET DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NAME(@$$CREF^DILF(DIE)))
+1 FOR DIXR=837
SET DIEZRXR(41.1,DIXR)=""
+2 QUIT
X15 SET DIC("S")="I '$P(^(0),U,3)"
DO ^DIC
KILL DIC
SET DIC=DIE
SET X=+Y
if Y<0
KILL X
+1 QUIT
+2 ;
16 if $DATA(DG)>9
DO F^DIE17
DO DE
SET DQ=16
SET DW="0;3"
SET DV="NJ3,0"
SET DU=""
SET DIFLD=3
SET DLB=$$LABEL^DIALOGZ(DP,DIFLD)
+1 SET DE(DW)="C16^DGSATX"
SET DE(DW,"INDEX")=1
+2 GOTO RE
C16 if $DATA(DE(16))[0
GOTO C16S
KILL DB
C16S SET X=""
if DG(DQ)=X
GOTO C16F1
KILL DB
C16F1 SET DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NAME(@$$CREF^DILF(DIE)))
+1 FOR DIXR=837
SET DIEZRXR(41.1,DIXR)=""
+2 QUIT
X16 if +X'=X!(X>999)!(X<0)!(X?.E1"."1N.N)
KILL X
+1 QUIT
+2 ;
17 if $DATA(DG)>9
DO F^DIE17
DO DE
SET DQ=17
SET DW="0;4"
SET DV="RF"
SET DU=""
SET DIFLD=4
SET DLB=$$LABEL^DIALOGZ(DP,DIFLD)
+1 SET DE(DW)="C17^DGSATX"
SET DE(DW,"INDEX")=1
+2 GOTO RE
C17 if $DATA(DE(17))[0
GOTO C17S
KILL DB
C17S SET X=""
if DG(DQ)=X
GOTO C17F1
KILL DB
C17F1 SET DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NAME(@$$CREF^DILF(DIE)))
+1 FOR DIXR=837
SET DIEZRXR(41.1,DIXR)=""
+2 QUIT
X17 if $LENGTH(X)>30!($LENGTH(X)<2)
KILL X
+1 IF $DATA(X)
IF X'?.ANP
KILL X
+2 QUIT
+3 ;
18 if $DATA(DG)>9
DO F^DIE17
DO DE
SET DQ=18
SET DW="0;5"
SET DV="R*P200'"
SET DU=""
SET DIFLD=5
SET DLB=$$LABEL^DIALOGZ(DP,DIFLD)
+1 SET DE(DW)="C18^DGSATX"
SET DE(DW,"INDEX")=1
+2 SET DU="VA(200,"
+3 GOTO RE
C18 if $DATA(DE(18))[0
GOTO C18S
KILL DB
C18S SET X=""
if DG(DQ)=X
GOTO C18F1
KILL DB
C18F1 SET DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NAME(@$$CREF^DILF(DIE)))
+1 FOR DIXR=837
SET DIEZRXR(41.1,DIXR)=""
+2 QUIT
X18 SET DIC("S")="I $$SCREEN^DGPMDD(Y,DA,DT)"
DO ^DIC
KILL DIC
SET DIC=DIE
SET X=+Y
if Y<0
KILL X
+1 QUIT
+2 ;
19 if $DATA(DG)>9
DO F^DIE17
DO DE
SET DQ=19
SET DW="0;6"
SET DV="S"
SET DU=""
SET DIFLD=6
SET DLB=$$LABEL^DIALOGZ(DP,DIFLD)
+1 SET DE(DW)="C19^DGSATX"
SET DE(DW,"INDEX")=1
+2 SET DU="Y:YES;N:NO;"
+3 GOTO RE
C19 if $DATA(DE(19))[0
GOTO C19S
KILL DB
C19S SET X=""
if DG(DQ)=X
GOTO C19F1
KILL DB
C19F1 SET DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NAME(@$$CREF^DILF(DIE)))
+1 FOR DIXR=837
SET DIEZRXR(41.1,DIXR)=""
+2 QUIT
X19 QUIT
20 if $DATA(DG)>9
DO F^DIE17
DO DE
SET DQ=20
SET DW="0;7"
SET DV="S"
SET DU=""
SET DIFLD=7
SET DLB=$$LABEL^DIALOGZ(DP,DIFLD)
+1 SET DE(DW)="C20^DGSATX"
SET DE(DW,"INDEX")=1
+2 SET DU="1:YES;0:NO;"
+3 GOTO RE
C20 if $DATA(DE(20))[0
GOTO C20S
KILL DB
C20S SET X=""
if DG(DQ)=X
GOTO C20F1
KILL DB
C20F1 SET DIEZRXR(41.1,DIIENS)=$$OREF^DILF($NAME(@$$CREF^DILF(DIE)))
+1 FOR DIXR=837
SET DIEZRXR(41.1,DIXR)=""
+2 QUIT
X20 QUIT
21 GOTO 0^DIE17