source: FOIAVistA/trunk/r/VA_FILEMAN-ARJT-DI-DD-DM-DT-%DT-%RCR/DIE17.m@ 677

Last change on this file since 677 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 6.1 KB
Line 
1DIE17 ;SFISC/GFT-COMPILED TMPLT UTIL ;9:08 AM 22 Oct 1999
2 ;;22.0;VA FileMan;**4,11**;Mar 30, 1999
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 I $D(DTOUT) S X="" G OUT
5 G:$A(X)-94 X:'$P(DW,";E",2),@("T^"_DNM)
6 I $D(DIE("NO^")),X=U,DIE("NO^")'["OUTOK" W !?3,"EXIT NOT ALLOWED " S D="" G X
7 I $D(DIE("NO^")),X?1"^"1.E,DIE("NO^")'["BACK" W !?3,"JUMPING NOT ALLOWED " S D="" G X
8 I $L(X,"^")-1>1 S X=$E(X,2,99) G DIE17
9 S X=$P(X,U,2),DIC(0)="E" G OUT
10Z ;
11 S DL=1,X=0
12OUT ;
13 I 0[X S DM=DW D FILE G ABORT:DL=1,R
14 S DIC="^DD("_DP_"," G OJ:'$D(^DIE(DIEZ,"AB")) S DIEZAB=$S(DL=1:U,1:DNM(DL,0)_U_DNM(DL)) I X?1"@".N,$D(^("AB",DIEZAB,X)) S DNM=^(X) G JMP
15 S DDBK=0 I $D(DIE("NO^")),DIE("NO^")["BACK" D DR S DDBK=1,DIC("S")="I $D(^DIE(DIEZ,""AB"",DIEZAB,Y)) D S^DIE0"
16 E S DIC("S")="I $D(^DIE(DIEZ,""AB"",DIEZAB,Y)),DIC(0)[""F""!'$D(^(Y,""///""))"
17 S DIC="^DD("_DP_"," D ^DIC S DIC=DIE I Y<0 S D="" W:DDBK !?3,"JUMPING FORWARD NOT ALLOWED "
18 I DDBK K DR S DR(1,DP)=^DIE(DIEZ,"ROU"),DR=DI
19 K A0,A1,DDBK,DIC,DTOUT G X:Y<0 S DNM=^DIE(DIEZ,"AB",DIEZAB,+Y)
20JMP K DIEZAB D FILE S Y=DNM,DNM=$P(Y,U,2),DQ=+Y,D=0 D @("DE^"_DNM) G @Y
21 ;
22OJ I X?1"@".N,$D(^DIE("AF",X,DIEZ)) S DNM=^(DIEZ)
23 E S DIC("S")="I $D(^DIE(""AF"","_DP_",Y,DIEZ)),DIC(0)[""F""!'$D(^(DIEZ,""///""))" D ^DIC K DIC S DIC=DIE G X:Y<0 S DNM=^DIE("AF",DP,+Y,DIEZ)
24 G JMP
25F ;
26 S DC=$S($D(X)#2:X,1:0) D FILE S X=DC Q
27FILE ;
28 K DQ Q:$D(DG)<9 S DQ="",DU=-2,DG="$D("_DIE_DA_",DU))"
29Y S DQ=$O(DG(DQ)),DW=$P(DQ,";",2) G DE:$P(DQ,";",1)=DU
30 I DU'<0 S ^(DU)=DV,DU=-2
31 G E1:DQ="" S DU=$P(DQ,";",1),DV="" I @DG S DV=^(DU)
32DE I 'DW S DW=$E(DW,2,99),DE=DW-$L(DV)-1,%=$P(DW,",",2)+1,X=$E(DV,%,999),DV=$E(DV,0,DW-1)_$J("",$S(DE>0:DE,1:0))_DG(DQ) S:X'?." " DV=DV_$J("",%-DW-$L(DG(DQ)))_X G Y
33PC S $P(DV,U,DW)=DG(DQ) G Y
34 ;
35IX D:$D(DE(DQ))#2 @DE(DQ)
36K K DE(DQ)
37E1 S DQ=$O(DE(" ")) I DQ'="" G IX:$D(DG(DQ)),K
38 K DG,DE,DIFLD S DQ=0 Q
391 ;
40 D FILE
41R D UP G @("R"_DQ_U_DNM)
42 ;
43UP S DNM=DNM(DL),DQ=DNM(DL,0) K DTOUT,DNM(DL) I $D(DIEC(DL)) D DIEC^DIE1 G U
44 S DIEL=DIEL-1,%=2,DA=DA(1) K DA(1)
45DA I $D(DA(%)) S DA(%-1)=DA(%) K DA(%) S %=%+1 G DA
46 S DIIENS=$P(DIIENS,",",2,999)
47U S DL=DL-1 Q
48 ;
49X W:X'["?"&'$D(ZTQUEUED) $C(7),"??" G Z:$D(DB(DQ))
50B G @(DQ_U_DNM)
51N ;
52 D DOWN S DA=$P(DC,U,4),$P(DIIENS,",")=DA,D=0 S ^DISV(DUZ,$E(DIC,1,28))=$E(DIC,29,999)_DA
53D1 S @("D"_DIEL)=DA G @(DGO)
54M ;
55 S DD=X D DOWN S DO(2)=$P(DC,"^",2),DO=DOW_"^"_DO(2)_"^"_$P(DC,"^",4,5),DIC(0)="LM"_$S($D(DB(DNM(DL,0))):"X",1:"QE") I @("'$D("_DIC_"0))") S ^(0)="^"_DO(2)
56 E I DO(2)["I" S %=0,DIC("W")="" D W^DIC1
57 K DIC("PTRIX") M DIC("PTRIX")=DIE("PTRIX")
58 K DICR S D="B",DLAYGO=DP\1,X=DD D X^DIC K DIC("PTRIX")
59 I Y>0 S DA=+Y,$P(DIIENS,",")=DA,X=$P(Y,U,2),D=$P(Y,U,3) G D1
60 D UP G @(DQ_U_DNM)
61 ;
62DOWN S DL=DL+1,DNM(DL)=DNM,DNM(DL,0)=DQ D FILE
63 F %=DL+1:-1:1 I $D(DA(%)) S DA(%+1)=DA(%)
64 S DA(1)=DA,DIC=DIE_DA_","""_$P(DC,U,3)_""",",DIEL=DIEL+1,DIIENS=","_DIIENS Q
65ABORT D E S Y(DM)="" Q
660 ;
67 D FILE
68E D FIREREC K:$D(DIEZTMP)#2 @DIEZTMP
69 K DIP,Y,DE,DOW,DB,DP,DW,DU,DC,DV,DH,DIL,DNM,DIEZ,DLB,DIEL,DGO,DICRREC Q
70DR ;
71 N F,DA I $E(DR)="[" S %X="^DIE(DIEZ,""DR"",",%Y="DR(" D %XY^%RCR S DR=DR(DL,DP) Q
72 S F=0 D DICS^DIA F DDW=1:1 S DDW1=$P(DR,";",DDW) Q:DDW1="" I $D(^DD(DI,+DDW1,0)),+$P(^(0),U,2)!(DDW1[":") S X=+DDW1,D(F)=+$P(DDW1,":",2) S:'D(F) D(F)=X D RANGE^DIA1
73 K DDW,DDW1 Q
74 ;
75FIREREC ;Fire the record level xrefs
76 Q:'$D(DIEZRXR)&$S($D(DIEZTMP)#2:'$D(@DIEZTMP@("R")),1:1)
77 N DA,DIE,DIEZXR,DIIENS,DIKEY,DP
78 ;
79 S DP=0 F S DP=$O(DIEZRXR(DP)) Q:'DP D
80 . S DIIENS=" " F S DIIENS=$O(DIEZRXR(DP,DIIENS)) Q:DIIENS="" D
81 .. S DIE=DIEZRXR(DP,DIIENS)
82 .. D DA^DILF(DIIENS,.DA)
83 .. S DIEZXR=0 F S DIEZXR=$O(DIEZRXR(DP,DIEZXR)) Q:DIEZXR'=+DIEZXR D
84 ... I $D(DIEZAR(DP,DIEZXR))#2 N DIEXEC S DIEXEC="K" D @DIEZAR(DP,DIEZXR)
85 ;
86 ;Fire record level indexes for triggered fields not in the template
87 S DP=0 F S DP=$O(@DIEZTMP@("R",DP)) Q:'DP D
88 . S DIIENS=" " F S DIIENS=$O(@DIEZTMP@("R",DP,DIIENS)) Q:DIIENS="" D
89 .. D DA^DILF(DIIENS,.DA)
90 .. D FIRE^DIKC(DP,.DA,"KS",$NA(@DIEZTMP@("R")),"F^^K",.DIKEY,$E("C",$G(DIOPER)="A"))
91 ;
92 ;If any keys are invalid, restore values
93 D:$D(DIKEY)>9 RESTORE^DIE1(.DIKEY,DIEZTMP)
94 ;
95 K DIEFIRE,DIEZRXR,@DIEZTMP@("V")
96 Q
97 ;
98 ;===========
99 ; $$UNIQUE
100 ;===========
101 ;Called from compiled routine.
102 ;Look at actual (untruncated) values in the matching indexes.
103 ;Return 1 if unique.
104 ;In:
105 ; DIUIR = Root of matching uniqueness index
106 ; DISETX = Entry point to set X array
107 ; DIMAXL(order#) = max length of subscript with order #
108 ;
109UNIQUE(X,DA,DIUIR,DISETX,DIMAXL) ;
110 N DIDASV,DIIENS,DIIENSC,DINDX,DINS,DIUNIQ,DIXSV,I,O
111 ;
112 M DIDASV=DA,DIXSV=X
113 S DIIENSC=$$IENS(.DA)
114 ;
115 S DIUNIQ=1,DINS=$QL(DIUIR),DINDX=DIUIR
116 F S DINDX=$Q(@DINDX) Q:$NA(@DINDX,DINS)'=DIUIR D Q:'DIUNIQ
117 . ;Set DA array, quit if this is index for current record
118 . S DIIENS=$E(DINDX,$L(DIUIR)+1,$L(DINDX)-1),L=$L(DIIENS,",")
119 . S DA=$P(DIIENS,",",L) F I=1:1:L-1 S DA(I)=$P(DIIENS,",",L-I)
120 . S DIIENS=$$IENS(.DA) Q:DIIENS=DIIENSC
121 . I '$D(DIMAXL) S DIUNIQ=0 Q
122 . ;
123 . ;Set the X array for the indexed record and compare
124 . D @(DISETX_"(""ONFILE"")")
125 . S O=0 F S O=$O(DIMAXL(O)) Q:'O Q:X(O)'=DIXSV(O)
126 . S:'O DIUNIQ=0
127 ;
128 K DA,X M DA=DIDASV,X=DIXSV
129 Q DIUNIQ
130 ;
131UNIQFERR ;The field is part of a key and is not unique
132 I '$D(ZTQUEUED),'$D(DDS) D
133 . W $C(7)_"??"
134 . W:'$D(DB(DQ)) !," Another entry already exists with this key value."
135 K DIEFXREF S ^("N")=@DIEZTMP@("V",DP,DIIENS,DIFLD,"O")
136 G:$D(DB(DQ)) Z
137 S X="?BAD"
138 G @("QS^"_DNM)
139 ;
140IENS(DA) ;Return IENS from DA array
141 N I,IENS
142 S IENS=$G(DA)_"," F I=1:1:$O(DA(" "),-1) S IENS=IENS_DA(I)_","
143 Q IENS
144 ;
145TRIG ;Save info for record level indexes on a triggered field.
146 ;Called by DICR (via @DICRREC)
147 N DIE,DIE17RXR,OLD,XR
148 S OLD=DIU
149 ;
150 ;Get record level indexes on triggered field
151 D LOADFLD^DIKC1(DIH,DIG,"KS","",$NA(@DIEZTMP@("V")),"","DIE17RXR","",.RLIST,"f")
152 Q:RLIST=""
153 ;
154 S DIE=$$OREF^DILF($NA(@$$FROOTDA^DIKCU(DIH)))
155 I $D(^DIE("AF",DIH,DIG,DIEZ)) D
156 . N N,PC,RL,XR
157 . S RL=RLIST
158 . F D Q:RL=""
159 .. F PC=1:1:$L(RL,U) S XR=$P(RL,U,PC) S:XR DIEZRXR(DIH,XR)=""
160 .. S N=$G(N)+1,RL=$G(RLIST(N))
161 . S DIEZRXR(DIH,DICRIENS)=DIE
162 E M @DIEZTMP@("R")=DIE17RXR S @DIEZTMP@("R",DIH,DICRIENS)=DIE
163 ;
164 ;Save the old value of the field
165 S @DIEZTMP@("V",DIH,DICRIENS,DIG,"O")=OLD S:$D(^("F"))[0 ^("F")=OLD
166 Q
Note: See TracBrowser for help on using the repository browser.