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

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

initial load of FOIAVistA 6/30/08 version

File size: 4.6 KB
Line 
1DIFROMS3 ;SFISC/DCL,TKW- DATA TO DISTRIBUTION ARRAY ;5/14/98 12:30
2 ;;22.0;VA FileMan;;Mar 30, 1999
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5 Q
6EN ;
7 I '$D(@DIFRFIA) D ERR(2) Q
8 G:$G(DIFRFILE) FILE
9 S DIFRFILE=0 F S DIFRFILE=$O(@DIFRFIA@(DIFRFILE)) Q:DIFRFILE'>0 D FILE
10 Q
11FCHK I '$D(@DIFRFIA@(DIFRFILE)) D ERR(5) Q ; * * * * PHASING OUT * * * *
12FILE N DIFRS,DIFRSCR,DIFRDA,DIFROOT,DIFRRLR,DIFR01,DIFRPR,DIFRDNSC,DIFRFRV,DIFRFRVX
13 N DIFRQ,DIFRTART,DIFRK,R,R1,R2,R3,C,F,G,I,DIFR2DD,DIFRNODE,DIFRFELD,DIFRPCE,DIFRIENS,DIFRDD0
14 S DIFR01=$G(@DIFRFIA@(DIFRFILE,0,1)),DIFRPR=$TR($P(DIFR01,"^",5),"Y","y")="y"
15 I $TR($P(DIFR01,"^",7),"Y","y")'="y" Q
16 I DIFRPR D PGL^DIFROMSP(DIFRFILE,"",DIFRTA)
17 S DIFRS=$G(@DIFRFIA@(DIFRFILE,0,11))]"",DIFRSCR=$G(^(11))
18 S DIFROOT=$NA(@($$ROOT^DILFD(DIFRFILE,"",1))),DIFRDA=0 ;$NA/trans gbl $Q
19 S DIFRRLR=$G(@DIFRFIA@(DIFRFILE,0,"RLRO"))
20 S:DIFRRLR="" DIFRRLR=DIFROOT
21 I $D(@DIFRRLR)'>9 D ERR(4) Q
22 N Y
23 F S DIFRDA=$O(@DIFRRLR@(DIFRDA)) Q:DIFRDA'>0 D
24 .I '$D(@DIFROOT@(DIFRDA,0)) D Q
25 ..N DIFRERR S DIFRERR(1)=DIFRDA,DIFRERR(2)=DIFRFILE
26 ..D BLD^DIALOG(9513,.DIFRERR)
27 ..Q
28 .I DIFRS,$D(@DIFRRLR@(DIFRDA,0)) S Y=DIFRDA X DIFRSCR Q:'$T ;set *NAKED* and *Y*
29 .M @DIFRTA@("DATA",DIFRFILE,DIFRDA)=@DIFROOT@(DIFRDA)
30 .Q
31 S DIFRQ=$NA(@DIFRTA@("DATA",DIFRFILE)) ;$NA/trans gbl/$Q
32 S DIFRTART=$$OREF^DILF(DIFRQ)
33 F S DIFRQ=$Q(@DIFRQ) Q:$P(DIFRQ,DIFRTART)]""!(DIFRQ="") D:$P(DIFRQ,DIFRTART,2,99)[""""!(DIFRPR)
34 .K R1
35 .S DIFRK=1
36 .S R2=$P(DIFRQ,DIFRTART,2,99),$E(R2,$L(R2))="",C=$L(R2,","),F=1,R1=0
37 .F I=1:1 Q:I>C S G=$P(R2,",",F,I) Q:G="" I G'[""""!($L(G,"""")#2&($E(G)="""")&($E(G,$L(G))="""")) S F=F+$L(G,","),I=F-1,R1(R1)=G,R1=R1+1,C=C+($L(G,",")-1) I 'G,G'?1"0".E,R1#2 S DIFRK=DIFRTART_$P(R2,",",1,I)_")" Q
38 .I DIFRPR,DIFRK,'(R1#2) D Q ;RESOLVE POINTERS
39 ..D Q:DIFR2DD'>0
40 ...I R1'>3 S DIFR2DD=DIFRFILE Q
41 ...S R3=""
42 ...F I=0:1:R1-3 S R3=R3_R1(I)_","
43 ...S DIFR2DD=+$P($G(@(DIFRTART_R3_"0)")),"^",2)
44 ...Q
45 ..S DIFRNODE=R1($O(R1(""),-1)),DIFRDNSC=R2
46 ..Q:'$D(@DIFRTA@("PGL",DIFR2DD,DIFRNODE))
47 ..S DIFRPCE=0
48 ..F S DIFRPCE=$O(@DIFRTA@("PGL",DIFR2DD,DIFRNODE,DIFRPCE)) Q:DIFRPCE="" D:DIFRPCE>0
49 ...Q:$P(@DIFRQ,"^",DIFRPCE)=""
50 ...S DIFRFELD=$O(@DIFRTA@("PGL",DIFR2DD,DIFRNODE,DIFRPCE,"")),(I,DIFRIENS)=""
51 ...;CREATE IENS * * * * * * * * * * * * * * * * *
52 ...F S I=$O(R1(I),-1) Q:I="" S:'(I#2) DIFRIENS=DIFRIENS_R1(I)_","
53 ...S DIFRDD0=^DD(DIFR2DD,DIFRFELD,0)
54 ...D DIERR
55 ...S DIFRFRV=$$GET1^DIQ(DIFR2DD,DIFRIENS,DIFRFELD)
56 ...D DIERR
57 ...I DIFRFRV']"" D Q
58 ....N DIFRERR
59 ....S DIFRERR(1)=DIFR2DD,DIFRERR(2)=DIFRIENS,DIFRERR(3)=DIFRFELD
60 ....D BLD^DIALOG(9514,.DIFRERR)
61 ....D DIERR
62 ....Q
63 ...S DIFRFRVX="FRV1"
64 ...; If .01 field on file level is a pointer use "FRV0" subscript
65 ...;I R1'>3,DIFRPCE=1,DIFRNODE=0 S DIFRFRVX="FRV0"
66 ...S @DIFRTA@(DIFRFRVX,DIFRFILE,DIFRDNSC,DIFRPCE)=DIFRFRV
67 ...S @DIFRTA@(DIFRFRVX,DIFRFILE,DIFRDNSC,DIFRPCE,"F")=$S($P(DIFRDD0,"^",2)["P":";"_$P(DIFRDD0,"^",3),$P(DIFRDD0,"^",2)["V":"1;"_$P($P(@DIFRQ,"^",DIFRPCE),";",2),1:"")
68 ...D KEYVAL
69 ...Q
70 ..Q
71 ..;Q:IF HEADER NODE OR IF NOT DATA NODE THEN FIND DD AND CHECK
72 ..; IF DD#,"PGL",DATA NODE EXIST IF SO GET PIECE AND FIELD
73 ..; AND SET IT UP INTO A STRUCTURE ; ALL RESOLVED; .01,IDs AND PTR.
74 ..;IT WAS DECIDED NOT TO RESOLVE .01 AND ID POINTERS
75 ..Q
76 .Q:DIFRK
77 .K @DIFRK
78 .Q
79 Q
80 ;
81KEYVAL ; Send KEY values if pointed-to file has a primary KEY
82 N DIFL S DIFL=$P(DIFRDD0,"^",2)
83 I DIFL["P" S DIFL=+$P(DIFL,"P",2)
84 E D
85 . S DIFL=$P($P(@DIFRQ,"^",DIFRPCE),";",2)
86 . S DIFL=+$P($G(@("^"_DIFL_"0)")),"^",2) Q
87 Q:'DIFL
88 N DIKEY S DIKEY=$O(^DD("KEY","AP",DIFL,"P",0)) Q:'DIKEY
89 N X,DIOUT S DIOUT=0 D Q:DIOUT
90 . S X=$P(^DD("KEY",DIKEY,0),U,4) I 'X S DIOUT=1 Q
91 . S X=$P($G(^DD("IX",X,0)),U,2) I X="" S DIOUT=1 Q
92 . S @DIFRTA@("FRV1K",DIFRFILE,DIFRDNSC,DIFRPCE)=X Q
93 N DIFLD,DIVAL,DIPTR,DIER,DIERR,DIFLDDA,DISEQ
94 S DIPTR=+$P(@DIFRQ,"^",DIFRPCE),DIFLDDA=0,DIOUT=0
95 F S DIFLDDA=$O(^DD("KEY",DIKEY,2,DIFLDDA)) Q:'DIFLDDA S X=$G(^(DIFLDDA,0)) D Q:DIOUT
96 . S DIFLD=$P(X,U),DISEQ=$P(X,U,3) I 'DISEQ S DIOUT=1 Q
97 . I $P(X,U,2)'=DIFL S DIOUT=1 Q
98 . I DIFLD=.01 S DIVAL=DIFRFRV
99 . E S DIVAL=$$GET1^DIQ(DIFL,DIPTR_",",DIFLD,"","","DIER")
100 . I $D(DIER) K DIER S DIOUT=1 Q
101 . S @DIFRTA@("FRV1K",DIFRFILE,DIFRDNSC,DIFRPCE,DISEQ)=DIVAL
102 . Q
103 I DIOUT K @DIFRTA@("FRV1K",DIFRFILE,DIFRDNSC,DIFRPCE)
104 Q
105 ;
106DIERR I $G(DIERR) S DIFRERRC=$$ERRC($G(DIFRERRC),DIERR) K DIERR
107 Q
108 ;
109ERRC(X,Y) ;
110 S X=$G(X),Y=$G(Y)
111 S $P(X,"^")=+X+Y,$P(X,"^",2)=$P(X,"^",2)+$P(Y,"^",2)
112 Q X
113 ;
114ERR(X) N Y S Y=$P($T(ERR+X),";",5) Q:'Y D BLD^DIALOG(Y) Q
115 ;;FIA Node Is Set To "No Data";1;9509
116 ;;FIA Array Does Not Exist;2;9501
117 ;;;3;
118 ;;Records Do Not Exist;4;9510
119 ;;FIA File Number Invalid;5;9502
Note: See TracBrowser for help on using the repository browser.