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

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

initial load of FOIAVistA 6/30/08 version

File size: 3.5 KB
Line 
1DICF0 ;SEA/TOAD,SF/TKW-VA FileMan: Finder, get alternate index ;2/8/00 11:11
2 ;;22.0;VA FileMan;**28**;Mar 30, 1999
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4ALTIDX(DINDEX,DIFILE,DIVALUE,DISCREEN,DINUMBER) ; Find alternate index when lookup value for first subscript is null.
5 N DIX S DIX=DINDEX,DIX("WAY")=DINDEX("WAY"),DIX("OLDSUB")=DINDEX("#")
6 D IDXOK(.DINDEX,DIFILE,.DIX) Q:DIX'=DINDEX
7A1 ; Find next lookup value
8 N DIFIELD,DISUB,DITYPE,I,J,K,X,Y,Z
9 F DISUB=1:0 S DISUB=$O(DIVALUE(DISUB)) Q:'DISUB I DIVALUE(DISUB)]"" D
10 . S X=$G(DINDEX(DISUB,"TYPE"))
11 . S DITYPE=$S(X="V":3,X="P":2,1:1),DITYPE(DITYPE,DISUB)=""
12 . Q
13 S DIX=""
14 F DITYPE=1,2,3 Q:DIX]"" I $D(DITYPE(DITYPE)) F DISUB=0:0 D Q:'DISUB Q:DIX]""
15 . S DISUB=$O(DITYPE(DITYPE,DISUB)) Q:'DISUB
16 . S DIFIELD=DINDEX(DISUB,"FIELD")
17A2 . ; find alternate index on that field.
18 . F I=0:0 S I=$O(^DD(DIFILE,DIFIELD,1,I)) Q:'I S X=$G(^(I,0)) D Q:DIX]""
19 . . I $P(X,U,3)="",$P(X,U,2)]"A[" S DIX=$P(X,U,2) Q:DIX'=DINDEX
20 . . S DIX="" Q
21 . I DIX]"" S DIX("#")=1,DIX(1)=DISUB Q
22 . F I=0:0 S I=$O(^DD("IX","F",DIFILE,DIFIELD,I)) Q:'I D Q:DIX]""
23 . . S DIX=$P($G(^DD("IX",I,0)),U,2) Q:DIX=""
24 . . I DIX=DINDEX S DIX="" Q
25 . . D IDXOK(.DINDEX,DIFILE,.DIX,I,.DIVALUE)
26 . . Q
27 . Q
28 Q:DIX=""
29A3 ; Rearrange lookup values and for new index
30 N DIV,DIS
31 M DIS("S")=DISCREEN("S"),DIS("F")=DISCREEN("F")
32 F I=1:1:DIX("#") S J=DIX(I) D
33 . Q:DIVALUE(J)=""
34 . M DIV(I)=DIVALUE(J),DIS(I)=DISCREEN(J)
35 . K DIVALUE(J),DISCREEN(J) Q
36A4 ; Build screening logic for fields whose lookup values are not on new index.
37 F J=0:0 S J=$O(DIVALUE(J)) Q:'J D
38 . M DIS("VAL",J)=DIVALUE(J)
39 . I $D(DISCREEN(J)) D
40 . . S X="DINDEX(",Z="DISCREEN(""VAL"","
41 . . F K=0:0 S K=$O(DISCREEN(J,K)) Q:'K S Y=DISCREEN(J,K) I Y[X S DISCREEN(J,K)="" F Q:Y'[X D
42 . . . N L,S S S=$P(Y,X),L=$L(S_X),S=S_Z,Y=$E(Y,L+1,$L(Y))
43 . . . S DISCREEN(J,K)=DISCREEN(J,K)_S
44 . . . I Y'[X S DISCREEN(J,K)=DISCREEN(J,K)_Y
45 . . . Q
46 . . M DIS("X",J)=DISCREEN(J) Q
47 . N DICODE,DINODE
48 . D GET^DICUIX1(DIFILE,DIFILE,DINDEX(J,"FIELD"),.DINODE,.DICODE)
49 . I "PVSD"'[DINDEX(J,"TYPE") S DIS("X",J,"GET")="S DIVAL="_DICODE Q
50 . S DIS("X",J,"GET")="S DIVAL=$$EXTERNAL^DIDU("_DIFILE_","_DINDEX(J,"FIELD")_","""","_DICODE_")"
51 . D
52 . . N DISAVJ S DISAVJ=J N J
53 . . S X=$$EXTERNAL^DIDU(DINDEX(DISAVJ,"FILE"),DINDEX(DISAVJ,"FIELD"),"",DIS("VAL",DISAVJ),"DIERR")
54 . . S J=$O(DIS("VAL",DISAVJ,99999),-1)+1
55 . . S DIS("VAL",DISAVJ,J)=X Q
56 . Q
57 K DINDEX S DINDEX=DIX,DINDEX("WAY")=DIX("WAY")
58 I DIFLAGS["l" S DINDEX("START")=DIX,DINDEX("OLDSUB")=DIX("OLDSUB")
59 K DISCREEN,DIVALUE M DISCREEN=DIS,DIVALUE=DIV K DIS,DIV
60 D INDEX^DICUIX(.DIFILE,DIFLAGS,.DINDEX,"",.DIVALUE,DINUMBER,.DISCREEN)
61 D XFORM^DICF1(DIFLAGS,.DIVALUE,.DISCREEN,.DINDEX)
62 Q
63 ;
64IDXOK(DINDEX,DIFILE,DIX,DIXIEN,DIVALUE) ; Return alternate index name DIX if it has no set/kill conditions and all subscripts are fields from original index DINDEX.
65 I '$G(DIXIEN) S DIXIEN=$O(^DD("IX","BB",DIFILE,DIX,0)) I 'DIXIEN S DIX="" Q
66 I $G(^DD("IX",DIXIEN,1.4))]""!($G(^(2.4))]"") S DIX="" Q
67 N I,J,X,DIFIELD,DISKIP S DISKIP=1 I $O(DIVALUE(0)) S DIX("#")=0
68 F I=0:0 S I=$O(^DD("IX",DIXIEN,11.1,"AC",I)) Q:'I S DISKIP=1 D Q:DISKIP
69 . S X=$G(^DD("IX",DIXIEN,11.1,I,0))
70 . Q:$P(X,U,3)'=DIFILE Q:$P(X,U,6)'=I S DIFIELD=$P(X,U,4) Q:'DIFIELD
71 . Q:$G(^DD("IX",DIXIEN,11.1,I,2))]""
72 . I '$O(DIVALUE(0)) S DISKIP=0 Q
73 . F J=1:1:DINDEX("#") D Q:'DISKIP
74 . . Q:DINDEX(J,"FIELD")'=DIFIELD
75 . . I I=1,DIVALUE(J)="" Q
76 . . S DIX(I)=J,DISKIP=0 Q
77 . I 'DISKIP S DIX("#")=DIX("#")+1
78 . Q
79 I DISKIP S DIX="" Q
80 Q
81 ;
Note: See TracBrowser for help on using the repository browser.