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

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

initial load of FOIAVistA 6/30/08 version

File size: 5.3 KB
Line 
1DIAXD ;SFISC/DCM-GET SOURCE DATA ;9/6/96 15:17
2 ;;22.0;VA FileMan;;Mar 30, 1999
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4EN ;
5 N DILL,FRFILE,TOFILE,DIAXIEN,DIAXI,DIAXFR,DIAXTO,DATAFR,DATALST,Z
6 S (DILL,DIAXI)=$G(DILL)+1,FRFILE=@DIAXTFR@(DILL,"FR"),TOFILE=@DIAXTFR@(FRFILE,"TO"),Z=","
7 S DIAXFR="^TMP($J,""DIAXFR"")",DIAXTO="^TMP($J,""DIAXTO"")",DATAFR="^TMP($J,""DATAFR"")",DATALST="^TMP($J,""DATALST"")"
8 D Q,TOP I $G(DIERR) D Q Q
9 D NEXTLVL
10Q K @DIAXFR,@DIAXTO,@DATAFR
11 K:$G(DIERR) ^TMP("DIAX",$J)
12 Q
13TOP ;
14 N FRIENS,TOIENS
15 S (FRIENS,@DIAXFR@(FRFILE,"IENS"))=DIAXFE_Z
16 S (TOIENS,@DIAXTO@(TOFILE,"IENS"),@DIAXTO@(FRFILE,"IENS",FRIENS))=$$DIAXIEN()
17 D GETFDA(FRIENS,TOIENS)
18 Q
19GETFDA(FRIENS,TOIENS) ;
20 D GETS Q:$G(DIERR)
21 D FDA
22 Q
23GETS ;
24 N DR,FLAGS,FIELDS
25 F S DR=$G(DR)+1 Q:'$G(@DIAXTFR@(FRFILE,"DR",DR)) D Q:$G(DIERR)
26 . S FLAGS="EIN"
27 . S FIELDS=@DIAXTFR@(FRFILE,"DR",DR)
28 . D GETS^DIQ(FRFILE,FRIENS,FIELDS,FLAGS,DATAFR,DIAXERR) D:$G(DIERR) ERR
29 Q
30FDA ;
31 N A,B,C S A=0
32 F S A=$O(@DATAFR@(FRFILE,FRIENS,A)) Q:A'>0 F C=0,1 S B=$G(@DIAXTTO@(FRFILE,A,C)) D:B]"" Q:$G(DIERR)
33 . I $O(@DATAFR@(FRFILE,FRIENS,A,0)) S ^TMP("DIAX",$J,TOFILE,TOIENS,+$P(B,U,2))=U_$P($$GET1^DIQ(FRFILE,FRIENS,A,"B"),U,2) Q
34 . S ^TMP("DIAX",$J,TOFILE,TOIENS,+$P(B,U,2))=$S(+$P(B,U,3):@DATAFR@(FRFILE,FRIENS,A,"E"),1:@DATAFR@(FRFILE,FRIENS,A,"I"))
35 I '$D(^TMP("DIAX",$J,TOFILE,TOIENS,.01)) S ^TMP("DIAX",$J,TOFILE,TOIENS,.01)=$$GET1^DIQ(FRFILE,FRIENS,.01,"I","",DIAXERR) D:$G(DIERR) ERR
36 K @DATAFR
37 Q
38GETLIST ;
39 N SCR,A,B S SCR=$G(DIAXSCR(FRFILE))
40 S FRIENS=$G(FRIENS),PART=$G(PART),INDEX=$G(INDEX) K @DATALST
41 D LIST^DIC(FRFILE,FRIENS,"","","","",PART,INDEX,.SCR,"",DATALST,DIAXERR)
42 I $G(DIERR) D ERR,Q1 Q
43 I '$P(@DATALST@("DILIST",0),U) D Q1 Q
44 I $G(PART)]"" S FRIENS=Z_@DIAXFR@(PARENT,"IENS")
45 S A=0 F S A=$O(@DATALST@("DILIST",2,A)) Q:A'>0 S B=@DATALST@("DILIST",2,A),@DIAXFR@(FRFILE,"IENS",$E(FRIENS,2,99),B_FRIENS)=""
46Q1 K @DATALST,PART,INDEX
47 Q
48TOIENS ;
49 N A,B S A=""
50 F S A=$O(@DIAXFR@(FRFILE,"IENS",FRIENS,A)) Q:A="" S B=$$DIAXIEN(),@DIAXTO@(FRFILE,"IENS",A)=B_@DIAXTO@(PARENT,"IENS",FRIENS)
51 Q
52GETDATA ;
53 Q:'$D(@DIAXTFR@(FRFILE,"DR"))
54 N A,ZFRIENS S A="",ZFRIENS=FRIENS N FRIENS
55 F S A=$O(@DIAXFR@(FRFILE,"IENS",ZFRIENS,A)) Q:A="" S FRIENS=A D Q:$G(DIERR)
56 . N TOIENS
57 . S TOIENS=@DIAXTO@(FRFILE,"IENS",FRIENS)
58 . D GETFDA(FRIENS,TOIENS) Q:$G(DIERR)
59 . I $D(DIAXFILE(FRFILE)) D Q
60 . . N Y,DIERZ
61 . . D RECURSE
62 . . I $G(DIERZ) N DIERR,Y S Y("IEN")=DIAXFE D BLD^DIALOG(1300,"",.Y) D STE^DIAXU()
63 Q
64MULT(FRIENS) ;
65 S FRIENS=Z_FRIENS
66 D GETLIST Q:$G(DIERR)
67 S FRIENS=$E(FRIENS,2,99)
68 D TOIENS
69 D GETDATA
70 Q
71ERR ;
72 Q:'$D(FRFILE)!('$D(FRIENS))
73 Q:'$D(DIAXFILE(FRFILE))
74 D STE^DIAXU(FRFILE,FRIENS)
75 Q
76NEXTLVL ;
77 F DIAXI=$G(DIAXI):0 S DIAXI=$O(@DIAXTFR@(DIAXI)) Q:'$D(@DIAXTFR@(+DIAXI,"FR")) D NEXTLVL2 Q:$G(DIERR)!(DIAXI="")
78 Q
79NEXTLVL2 ;
80 N FRFILE,TOFILE,PARENT,DILL,FRIENS,TOIENS,TAG
81 S FRFILE=@DIAXTFR@(DIAXI,"FR"),TOFILE=@DIAXTFR@(FRFILE,"TO"),PARENT=^("PRT"),DILL=^("P2"),TAG=^("P4")
82 D @TAG
83 Q
843 ;
85 I $D(DIAXFILE(FRFILE)) D FILE Q:$G(DIERR)
86 I DILL=2 S FRIENS=@DIAXFR@(PARENT,"IENS") D MULT(FRIENS) Q
87 N A,B S (A,B)="" F S B=$O(@DIAXFR@(PARENT,"IENS",B)) Q:B="" D
88 . F S A=$O(@DIAXFR@(PARENT,"IENS",B,A)) Q:A="" D Q:$D(DIAXFILE(PARENT))
89 . . S FRIENS=A D MULT(FRIENS) Q:$G(DIERR)
90 Q
912 ;
92 N PTRFLD,FRIENS,PTRIEN,A,B
93 S PTRFLD=$P(@DIAXTFR@(FRFILE,"P5"),":")
94 I DILL=2 S FRIENS=@DIAXFR@(PARENT,"IENS") D 21 Q
95 S (A,B)="" F S B=$O(@DIAXFR@(PARENT,"IENS",B)) Q:B="" D Q:$G(DIERR)!('PTRIEN)
96 . F S A=$O(@DIAXFR@(PARENT,"IENS",B,A)) Q:A="" D Q:$G(DIERR)!'(PTRIEN)!($D(DIAXFILE(PARENT)))
97 . . S FRIENS=A D 21
98 Q
9921 N TOIENS
100 S PTRIEN=$$GET1^DIQ(PARENT,FRIENS,PTRFLD,"I","",DIAXERR) D:$G(DIERR) Q:$G(DIERR)!('PTRIEN)
101 . N FRFILE
102 . S FRFILE=PARENT
103 . D ERR
104 S FRIENS=PTRIEN_Z
105 S TOIENS=@DIAXTO@(PARENT,"IENS",A)
106 D GETFDA(FRIENS,TOIENS)
107 Q
1084 ;
109 N PART,INDEX,FRIENS
110 S PART=$$GET1^DIQ(PARENT,@DIAXFR@(PARENT,"IENS"),.01,"I","",DIAXERR) D:$G(DIERR) Q:PART']""!$G(DIERR)
111 . N FRFILE,FRIENS
112 . S FRFILE=PARENT
113 . S FRIENS=@DIAXFR@(PARENT,"IENS")
114 . D ERR
115 S INDEX=@DIAXTFR@(FRFILE,"P7")
116 I $D(DIAXFILE(FRFILE)) D FILE Q:$G(DIERR)
117 S FRIENS="" D GETLIST Q:$G(DIERR)
118 S FRIENS=@DIAXFR@(PARENT,"IENS")
119 D TOIENS,GETDATA
120 Q
121DIAXIEN() ;
122 S DIAXIEN=$G(DIAXIEN)+1
123 Q "+"_DIAXIEN_Z
124FILE ;
125 Q:'$D(^TMP("DIAX",$J))
126 N IEN S IEN="^TMP($J,""IEN"")"
127 D Q2,UPDATE^DIE("E","^TMP(""DIAX"",$J)",IEN,DIAXERR)
128 I $G(DIERR) D Q
129 . K ^TMP("DIAX",$J)
130 . D ERR
131 N %,NODE,A,B,FI,VAL,DA S %=0,NODE=DIAXTO
132 I $G(@IEN@(1)) S DIAXDA=^(1),FI=0,FI=$O(@NODE@(FI))
133 E S FI=FRFILE
134 F S %=$O(@IEN@(%)) Q:'% S DA=@IEN@(%) D VAL
135Q2 K @IEN Q
136VAL S NODE=DIAXTO,NODE=$NA(@NODE@(FI)) F S NODE=$Q(@NODE) Q:NODE'["DIAXTO" Q:$QS(NODE,5)'[$G(FRIENS) S VAL=@NODE I VAL[("+"_%_Z) S VAL=$P(VAL,"+"_%_Z,1)_DA_Z_$P(VAL,"+"_%_Z,2) S @NODE=VAL D
137 . S A=$QS(NODE,3),B=$QS(NODE,5)
138 . Q:(A'=DIAXF)&('$D(DIAXFILE(A)))
139 . Q:A=""!(B="")
140 . I A=DIAXF S B=+B,VAL=+VAL
141 . S @DIAXRSLT@("RESULT",A,B)=VAL
142 Q
143RECURSE ;
144 N DIAXIZ,DILLZ,DIERR
145 S DIAXIZ=DIAXI,DILLZ=DILL
146 D NEXTLVL,FILE
147 N NODE,SUB,FILE S FILE=FRFILE
148 F S FILE=$O(@DIAXFR@(FILE)) Q:'FILE F NODE=$NA(@DIAXFR@(FILE)),$NA(@DIAXTO@(FILE)) F S NODE=$Q(@NODE) Q:NODE'["IENS" S SUB=$QS(NODE,5) I SUB[FRIENS K @NODE
149 K @DIAXFR@(FRFILE,"IENS",ZFRIENS,FRIENS),@DIAXTO@(FRFILE,"IENS",FRIENS)
150 S DIAXI=DIAXIZ,DILL=DILLZ,A=""
151 I $G(DIERR) K DIAXDA S DIERZ=1
152 Q
Note: See TracBrowser for help on using the repository browser.