source: WorldVistAEHR/trunk/r/VA_FILEMAN-ARJT-DI-DD-DM-DT-%DT-%RCR/DIEZ2.m@ 619

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

initial load of WorldVistAEHR

File size: 7.3 KB
Line 
1DIEZ2 ;SFISC/GFT-COMPILE INPUT TEMPLATE ;20SEP2004
2 ;;22.0;VA FileMan;**11,95,159**;Mar 30, 1999;Build 8
3 ;Per VHA Directive 2004-038, this routine should not be modified.
4 K DIEZAR D RECXR^DIEZ4(.DIEZAR)
5 K ^DIE(DIEZ,"AR") M:$D(DIEZAR) ^DIE(DIEZ,"AR")=DIEZAR
6 S %X="^UTILITY($J,""AF"",",%Y="^DIE(""AF""," D %XY^%RCR
7 K ^DIE(DIEZ,"AB") S %X="^UTILITY($J,""AB"",",%Y="^DIE(DIEZ,""AB""," D %XY^%RCR
8 S ^DIE(DIEZ,"ROUOLD")=DNM,^("ROU")=U_DNM
9K K ^DIBT(.402,1,DIEZ),^UTILITY($J)
10 K @DIEZTMP,DIEZTMP,DIEZAR,DIER,DIERN
11 K DIE,DINC,DK,DL,DMAX,DNR,DP,DQ,DQFF,DRD,DS,DSN,DV,DW,DI,DH,%,%X,%Y,%H,X,Y
12 K DIEZ,DIEZDUP,DIEZR,Q,DPP,DPR,DM,DR,DU,T,F,DRN,DOV,DIEZL,DIEZP,DIEZAB
13 Q
14 ;
15XREF ;
16 N DIEZR,DIEZX,DIEZLN
17 S X="C"_DQ_" G C"_DQ_"S:$D(DE("_DQ_"))[0 K DB" D L
18 S DIEZX=L,DIEZLN=0 ;remember cross-refs will start after 'L'
19 F %=0:0 S %=$O(^DD(DP,DI,1,%)) Q:%'>0 S DW=^(%,2),X=" S X=DE("_DQ_"),DIC=DIE" D SK ;first build the KILL XREFS
20 I DV["a" S X=" S X=DE("_DQ_"),DIIX=2_U_DIFLD D AUDIT^DIET" D X
21 ;I X]"" S X="C"_DQ_" ;" D L
22 D OVERFLO
23 S X="C"_DQ_"S S X="""" G:DG(DQ)=X C"_DQ_"F1 K DB" D L S X=""
24 S DIEZX=L,DIEZLN=L
25 F %=0:0 S %=$O(^DD(DP,DI,1,%)) Q:%'>0 S DW=^(%,1),X=X_" S X=DG(DQ),DIC=DIE" D SK ;then the SET XREFS
26 I DV["a" S X=X_" I $D(DE("_DQ_"))'[0!(^DD(DP,DIFLD,""AUDIT"")'=""e"") S X=DG(DQ),DIIX=3_U_DIFLD D AUDIT^DIET" D X
27 D OVERFLO
28 ;Build index code and code to check key
29 D INDEX
30 S X=X_" Q" D L
31 I $D(DIEZKEY) D GETKEY^DIEZ3(DP,DI,.DIEZKEY,DQ) K DIEZKEY
32 Q
33 ;
34SK D X I "Q"[DW S X=" ;" G X
35 I DW["Q",^DD(DP,DI,1,%,0)["MUMPS" S Q=DW,F=0 D QFF S X=" X "_Q G X
36 S X=" "_DW
37X D L S DIEZLN=DIEZLN+$L(X),X="" Q
38 ;
39OVERFLO I DIEZLN+T+100<DMAX!'DIEZLN Q
40 K ^UTILITY($J,"DIEZXR") M ^UTILITY($J,"DIEZXR")=^UTILITY($J,0)
41 S DIEZR=DRN,(DIEZR(1),DRN)=$O(DRN(""),-1)+1 D
42 .N T,DQ,L
43 .D NEWROU^DIEZ ;make a new routine holding just the X-REFS
44 .F T=2:1 S DIEZX=DIEZX+1 Q:'$D(^UTILITY($J,"DIEZXR",DIEZX)) S ^UTILITY($J,0,T)=^(DIEZX) K ^UTILITY($J,"DIEZXR",DIEZX)
45 .F K ^UTILITY($J,0,T) S T=$O(^(T)) Q:'T
46 .D SAVE^DIEZ1
47 K ^UTILITY($J,0) M ^UTILITY($J,0)=^UTILITY($J,"DIEZXR")
48 S DRN=DIEZR,T=T-DIEZLN,X=" D ^"_DNM_DIEZR(1) D L
49 Q
50 ;
51MUL ;
52 S DNR=%,DW=$P(DW,";",1),X=$P(^DD(+DV,0),U,4)_U_DV_U_DW_U,%=^(.01,0),DV=+DV_$P(%,U,2)
53 G 1:DV'["W" I DPR]"" S F=0,Q=DPR D QFF S X=" S DE(1,0)="_Q D L
54 S X=" S Y="""_$S(DIEZP]"":DIEZP_U_$P(%,U,2,9),1:%)_""",DG="""_DW_""",DC=""^"_+DV_""" D DIEN^DIWE K DE(1) G A" D L S X=" ;" D L,AF
55 S ^UTILITY($J,"AF",+DV,.01,DIEZ)="" D AB G NX^DIEZ0
56 ;
571 S X=" S DIFLD="_DI_",DGO=""^"_DNM_DNR_""",DC="""_X_""",DV="""_DV_""",DW=""0;1"",DOW="""_$S(DIEZP]"":DIEZP,1:$P(^(0),U))_""",DLB=$P($$EZBLD^DIALOG(8042,DOW),"": "") S:D DC=DC_D",DPP=DV["M",DU=$P(^(0),U,3) D L,DU:DU]""
58 S X=$P(" G RE:D",U,DPP)_" I $D(DSC("_+DV_"))#2,$P(DSC("_+DV_"),""I $D(^UTILITY("",1)="""" X DSC("_+DV_") S D=$O(^(0)) S:D="""" D=-1 G M"_DQ D L
59 S:+DW'=DW DW=""""_DW_"""" S X=" S D=$S($D("_DIE_"DA,"_DW_",0)):$P(^(0),U,3,4),$O(^(0))'="""":$O(^(0)),1:-1)" D L
60 S X="M"_DQ_" I D>0 S DC=DC_D I $D("_DIE_"DA,"_DW_",+D,0)) S DE("_DQ_")=$P(^(0),U,1)" D L
61 D PR^DIEZ0 S X="R"_DQ_" D DE" D L
62 S X=$S(DPP:" S D=$S($D("_DIE_"DA,"_DW_",0)):$P(^(0),U,3,4),1:1) G "_DQ_"+1",1:" G A") D L S X=" ;" D L,AF,DIERN
63 S DRN(DNR)=+DV_U_DIERN_DIE_"D"_DIEZL_","_DW_","_U_(DIEZL+1)_U_DQ_U_DRN G NX^DIEZ0
64 ;
65DIERN ;
66 N M S DIERN=DL+1,M=$P(DR,";",DK+1) S:M?1"^"1.NP DK=DK+1,DIERN=$P(M,U,2) Q
67 ;
68AF ;
69 S ^UTILITY($J,"AF",DP,DI,DIEZ)=""
70AB I '$D(^UTILITY($J,"AB",DIEZAB,DI)) S ^(DI)=DQ_U_DNM_DRN S:DPR?1"/".E ^(DI,"///")=""
71 Q
72 ;
73DU S F=0,Q=DU D QFF S X=" S DU="_Q,DU=""
74L S L=L+1,^UTILITY($J,0,L)=X,T=T+$L(X)+2 Q
75 ;
76O ;
77 S F=0,Q=^(2) D QFF S DIEZOT=" S DQ("_DQ_",2)="_Q Q
78 ;
79PR ;
80 F %=1,2,3 Q:$E(DPR,%)'="/"
81 S X=$E(DPR,%,999),Q=X,F=0 D QFF I $A(X)-94 S X=" S Y="_Q
82 E S X=" "_$E(X,2,999) D L S X=" S Y=X"
83 D L S X=" G Y" I %>1 S DPP=0,X=" S X=Y,DB(DQ)=1"_$S(%=3:",DE(DW,""4/"")=""""",1:"")_" G:X="""" N^DIE17:DV,A I $D(DE(DQ)),DV[""I""!(DV[""#"") D E^DIE0 G A:'$D(X)" D L S X=" G "_$S(%=3:"RD:X=""@"",Z",1:"RD")
84 Q
85QF ;
86 S F=0,Q=DIE
87QFF ;
88 S F=$F(Q,"""",F) I F S Q=$E(Q,1,F-1)_$E(Q,F-1,999),F=F+1 G QFF
89 S Q=""""_Q_""""
90 Q
91 ;
92INDEX ;Build code field and record level cross references.
93 ;In:
94 ; DP = file #
95 ; DI = field #
96 ; DIEZKEY(xref#) = "" : for each xref that is a Uniqueness Index
97 ; for a simple (single-field key)
98 N DIEZCNT,DIEZFLST,DIEZI,DIEZRLST,DIEZXR,DIEZXREF
99 S DIEZCNT=0
100 ;
101 ;Get field- and record-level xrefs
102 D LOADFLD^DIKC1(DP,DI,"KS","","@DIEZTMP@(""V"",","DIEZXREF",$NA(@DIEZTMP@("R")),.DIEZFLST,.DIEZRLST)
103 I DIEZFLST="",DIEZRLST="" S X="C"_DQ_"F1" Q
104 ;
105 ;Build code for each field-level xref
106 ;Save DIEZKEY(uniquenessIndex)=index tag # (DIEZCNT)
107 I DIEZFLST]"" S DIEZXR=0 F S DIEZXR=$O(DIEZXREF(DP,DIEZXR)) Q:'DIEZXR D
108 . D GETXR(DIEZXR,.DIEZCNT)
109 . S:$D(DIEZKEY(DIEZXR))#2 DIEZKEY(DIEZXR)=DIEZCNT
110 ;
111 ;Build code to set the DIEZRXR array for each record-level xref
112 S X="C"_DQ_"F"_(DIEZCNT+1)
113 Q:DIEZRLST=""
114 S X=X_" S DIEZRXR("_DP_",DIIENS)=$$OREF^DILF($NA(@$$CREF^DILF(DIE)))" D L
115 S X=" F DIXR="_$TR(DIEZRLST,U,",")_" S DIEZRXR("_DP_",DIXR)=""""" D L
116 S DIEZI=0 F S DIEZI=$O(DIEZRLST(DIEZI)) Q:'DIEZI D
117 . S X=" F DIXR="_$TR(DIEZRLST(DIEZI),U,",")_" S DIEZRXR("_DP_",DIEZIENS)=""""" D L
118 ;
119 S X=""
120 Q
121 ;
122GETXR(DIEZXR,DIEZCNT) ;Get code for one index DIEZXR
123 N DIEZCOD,DIEZF,DIEZKLOG,DIEZNSS,DIEZSLOG,DIEZO
124 S DIEZCNT=$G(DIEZCNT)+1
125 ;
126 ;Build code to call subroutine to set X array
127 S X="C"_DQ_"F"_DIEZCNT_$S(DIEZCNT=1:" N X,X1,X2",1:"")_" S DIXR="_DIEZXR_" D C"_DQ_"X"_DIEZCNT_"(U) K X2 M X2=X D C"_DQ_"X"_DIEZCNT_"(""O"") K X1 M X1=X"
128 D L
129 ;
130 ;Build code to check for null subscripts
131 S DIEZNSS="",DIEZO=0
132 F S DIEZO=$O(DIEZXREF(DP,DIEZXR,DIEZO)) Q:'DIEZO D
133 . Q:'$G(DIEZXREF(DP,DIEZXR,DIEZO,"SS"))
134 . I DIEZNSS="" S DIEZNSS="$G(X("_DIEZO_"))]"""""
135 . E S DIEZNSS=DIEZNSS_",$G(X("_DIEZO_"))]"""""
136 I DIEZNSS]"" S DIEZNSS=" I "_DIEZNSS_" D"
137 E S DIEZNSS=" D"
138 ;
139 ;Get kill logic and condition
140 S DIEZKLOG=$G(DIEZXREF(DP,DIEZXR,"K"))
141 I DIEZKLOG'?."^" D
142 . S X=DIEZNSS D L
143 . ;Get kill condition code
144 . S DIEZCOD=$G(DIEZXREF(DP,DIEZXR,"KC"))
145 . I DIEZCOD'?."^" D
146 .. S X=" . N DIEXARR M DIEXARR=X S DIEZCOND=1" D L
147 .. S X=" . "_DIEZCOD D L
148 .. S X=" . S DIEZCOND=$G(X) K X M X=DIEXARR Q:'DIEZCOND" D L
149 . ;Get kill logic
150 . S X=" . "_DIEZKLOG D L
151 ;
152 ;Get set logic and condition
153 S DIEZSLOG=$G(DIEZXREF(DP,DIEZXR,"S"))
154 I DIEZSLOG'?."^" D
155 . S X=" K X M X=X2"_DIEZNSS D L
156 . ;Get set condition code
157 . S DIEZCOD=$G(DIEZXREF(DP,DIEZXR,"SC"))
158 . I DIEZCOD'?."^" D
159 .. S X=" . N DIEXARR M DIEXARR=X S DIEZCOND=1" D L
160 .. S X=" . "_DIEZCOD D L
161 .. S X=" . S DIEZCOND=$G(X) K X M X=DIEXARR Q:'DIEZCOND" D L
162 . ;Get set logic
163 . S X=" . "_DIEZSLOG D L
164 ;
165 S X=" G C"_DQ_"F"_(DIEZCNT+1) D L
166 ;
167 ;Build code to set X array
168 S DIEZF=$O(DIEZXREF(DP,DIEZXR,0))
169 S X="C"_DQ_"X"_DIEZCNT_"(DION) K X" D L
170 S DIEZO=0
171 F S DIEZO=$O(DIEZXREF(DP,DIEZXR,DIEZO)) Q:'DIEZO D
172 . D BLDDEC(DP,DIEZXR,DIEZO)
173 S X=" S X=$G(X("_DIEZF_"))" D L
174 S X=" Q" D L
175 Q
176 ;
177BLDDEC(DP,DIEZXR,DIEZO) ;Build data extraction code
178 N CODE,NODE,TRANS
179 ;
180 S CODE=$G(DIEZXREF(DP,DIEZXR,DIEZO)) Q:CODE?."^"
181 S TRANS=$G(DIEZXREF(DP,DIEZXR,DIEZO,"T"))
182 I TRANS'?."^" D
183 . S X=" "_CODE D L
184 . D DOTLINE(" I $D(X)#2 "_TRANS)
185 . S X=" S:$D(X)#2 X("_DIEZO_")=X" D L
186 E I $D(DIEZXREF(DP,DIEZXR,DIEZO,"F"))#2,CODE?1"S X=".E D
187 . S X=" S X("_DIEZO_")"_$E(CODE,4,999) D L
188 E D
189 . S X=" "_CODE D L
190 . S X=" S:$D(X)#2 X("_DIEZO_")=X" D L
191 Q
192 ;
193DOTLINE(CODE) ;
194 I CODE[" Q"!(CODE[" Q:") D
195 . S X=" D" D L
196 . S X=" ."_CODE D L
197 E S X=CODE D L
198 Q
Note: See TracBrowser for help on using the repository browser.