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

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

initial load of FOIAVistA 6/30/08 version

File size: 4.2 KB
Line 
1DICLIX ;SEA/TOAD,SF/TKW-FileMan: Lister, Search Compound Indexes ;6/5/00 10:13
2 ;;22.0;VA FileMan;**4,3**;Mar 30, 1999;
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5WALK(DIFLAGS,DINDEX,DIDENT,DIFILE,DIEN,DIFIEN,DISCREEN,DILIST,DINDEX0,DIXV,DIC) ;
6 ;
7 ; a walker to traverse a compound index, taking actions
8 ; DINDEX is an array describing the index and how to walk it
9 ;
10PREP ; prepare to loop through subscript
11 ;
12 N DISUB S DISUB=DINDEX("AT")
13 N DIVAL S DIVAL=DINDEX(DISUB)
14 N DIPART,DIMORE S DIPART=$G(DINDEX(DISUB,"PART")),DIMORE=+$G(DINDEX(DISUB,"MORE?"))
15 I $G(DINDEX(DISUB,"USE")),DIVAL'="" D
16 . S DIVAL=$O(@DINDEX(DISUB,"ROOT")@(DIVAL),-DINDEX(DISUB,"WAY"))
17 ;
18LOOP ; loop through subscripts
19 ;
20 N DIDONE,DISKIP S DIDONE=0 F D Q:DIDONE!$G(DIERR)
21 . S DIVAL=$O(@DINDEX(DISUB,"ROOT")@(DIVAL),DINDEX(DISUB,"WAY"))
22 .
23DATA . ; if we're in the data subscripts, we need to walk further
24 .
25 . I DISUB'>DINDEX("#") D Q
26 . . I DISUB=1,$O(DIXV(0)) D LOWSUB
27 . . S DISKIP=0
28 . . I DIVAL'="",'$D(DINDEX(DISUB,"IXROOT")) D CHK Q:DISKIP
29 . . S:DIVAL="" DIDONE=1
30 . . Q:DIDONE
31 . . S DINDEX(DISUB)=DIVAL,DINDEX("AT")=DISUB+1
32 . . I $D(DINDEX("ROOTCNG",DISUB+1)) D BLDTMP^DICLIX1(.DINDEX,.DISCREEN,DIFLAGS,.DIDENT)
33 . . D WALK(.DIFLAGS,.DINDEX,.DIDENT,.DIFILE,.DIEN,DIFIEN,.DISCREEN,.DILIST,.DINDEX0,"",.DIC)
34 . . S DINDEX("AT")=DISUB
35 . . I $G(DINDEX("DONE"))!$G(DIERR) S DIDONE=1
36 . . Q
37 .
38IEN . ; otherwise, we're in the IEN subscripts & need to process
39 .
40 . I DIVAL="" S DIDONE=1 Q
41 . I DINDEX="B" N DISKIPMN,DIMNEM S DISKIPMN=0 D Q:DISKIPMN
42 . . I $D(@DINDEX(DISUB,"ROOT")@(DIVAL))#2 Q:'^(DIVAL)
43 . . E Q:'$O(@DINDEX(DISUB,"ROOT")@(DIVAL,""))
44 . . I DIFLAGS["M" S DISKIPMN=1 Q
45 . . S DIMNEM="" Q
46 . I $G(DINDEX(DISUB,"TO")) D Q:DIDONE
47 . . Q:$D(DINDEX(DISUB,"IXROOT"))
48 . . D BACKPAST^DICLIX1(DIFLAGS,.DINDEX,DISUB,DIVAL,.DIDONE) Q
49 . D TRY
50 . Q
51CLEAN ; clean up after loop, exit
52 S DINDEX(DISUB)=""
53 I DISUB>1,$G(DINDEX(DISUB,"PART"))]"" S DINDEX(DISUB)=DINDEX(DISUB,"FROM")
54 Q
55 ;
56CHK ; See whether we have a match or are at the end of the subscripts.
57 D MATCH I DIDONE,'$G(DINDEX("DONE")),DIMORE D
58 . S DIDONE=0 D FINDMORE^DICLIX0(DISUB,.DIVAL,DIPART,.DINDEX,.DIMORE) I DIVAL="" S DIDONE=1 Q
59 . D MATCH Q
60 Q
61 ;
62MATCH ; No more subscripts or partial matches, or past our TO value?
63 Q:DIVAL=""
64 I $P(DIVAL,$G(DIPART))'="" S DIDONE=1 Q
65 Q:$G(DINDEX(DISUB,"TO"))=""
66 I DIFLAGS["p" D BACKPAST^DICLIX1(DIFLAGS,.DINDEX0,DISUB,DIVAL,.DIDONE) Q
67 I $G(DINDEX(DISUB+1,"TO"))="" D BACKPAST^DICLIX1(DIFLAGS,.DINDEX,DISUB,DIVAL,.DIDONE)
68 Q
69 ;
70LOWSUB ; Find next subscript value from multiple pointed-to files
71 N I,DILOWNO,DILOWVAL S DILOWNO=+DIFILE("STACK"),DILOWVAL=DIVAL
72 I DILOWVAL="" D I 'DILOWNO K DIXV Q
73 . K DIXV(DILOWNO),DIFILE("STACKEND",DILOWNO)
74 . S DILOWNO=$O(DIXV(0)),DILOWVAL=$G(DIXV(+DILOWNO,1,"NXTVAL"))
75 . Q
76 N J S J=DILOWNO
77 I DILOWVAL'="" F I=0:0 S I=$O(DIFILE("STACKEND",I)) Q:'I I I'=J D
78 . I DINDEX(1,"WAY")=1,DILOWVAL']]DIXV(I,1,"NXTVAL") Q
79 . I DINDEX(1,"WAY")=-1,DIXV(I,1,"NXTVAL")']]DILOWVAL Q
80 . S DILOWNO=I,DILOWVAL=$G(DIXV(DILOWNO,1,"NXTVAL"))
81 . Q
82 I DILOWNO'=DIFILE("STACK") D
83 . I DIVAL'="" S DIXV(+DIFILE("STACK"),1,"NXTVAL")=DIVAL
84 . S DIFILE("STACK")=DILOWNO_U_DIFILE("STACKEND",DILOWNO)
85 . S DIVAL=DILOWVAL
86 . S DIFILE=+$P(DIFILE("STACK"),U,3)
87 . M DINDEX=DIXV(DILOWNO) Q
88 Q
89 ;
90TRY ; Apply screens to entry. If passed, add entry to output.
91 S (DIEN,DINDEX(DISUB))=DIVAL
92 I DIFLAGS["p" D
93 . S DINDEX0(1,"EXT")=DINDEX(1)
94 . D BACKTRAK^DICL3(.DIFLAGS,.DIFILE,DIFILE("STACK"),.DIEN,DIFIEN,.DINDEX0,.DINDEX,.DIDENT,.DISCREEN,.DILIST)
95 . S:$G(DINDEX0("DONE")) (DIDONE,DINDEX("DONE"))=1 Q
96 I DIFLAGS'["p" D
97 . N DI0NODE S DI0NODE=$G(@DIFILE(DIFILE)@(DIEN,0))
98 . Q:$$SCREEN^DICL2(.DIFILE,.DIEN,DIFLAGS,DIFIEN,.DISCREEN,.DINDEX,DI0NODE)
99 . D ACCEPT^DICL2(.DIFILE,.DIEN,.DIFLAGS,DIFIEN,.DINDEX,.DIDENT,.DILIST,DI0NODE)
100 . Q
101 Q:$G(DIERR)!($G(DINDEX("DONE")))
102 I DIDENT(-1)=DIDENT(-1,"MAX") D
103 . I 'DIDENT(-1,"JUST LOOKING") S DIDONE=1,DINDEX("DONE")=1 Q
104 . ; If called from online DIC help ^DICQ, display list.
105 . Q:DIFLAGS'["h"
106 . K DTOUT,DUOUT S DICQ(0,"MAP")=DIDENT(-3)
107 . D DSP^DICQ1(.DINDEX,.DICQ,.DIC,.DIFILE)
108 . I $G(DTOUT)!($G(DUOUT)) S (DINDEX("DONE"),DIDONE)=1 Q
109 . S DILIST("ORDER")=$S(DINDEX("WAY")=1:0,1:DIDENT(-1,"MAX")+1)
110 . S DIDENT(-1)=0,DIDENT(-1,"JUST LOOKING")=0 Q
111 Q
112 ;
113 ;
Note: See TracBrowser for help on using the repository browser.