[613] | 1 | DICFIX ;SEA/TOAD,SF/TKW-FileMan: Finder, Search Compound Indexes ;5/26/99 14:40
|
---|
| 2 | ;;22.0;VA FileMan;**4**;Mar 30, 1999;
|
---|
| 3 | ;Per VHA Directive 10-93-142, this routine should not be modified.
|
---|
| 4 | ;
|
---|
| 5 | WALK(DIFLAGS,DINDEX,DIDENT,DIFILE,DIEN,DIFIEN,DISCREEN,DILIST,DIC,DIY,DIYX) ;
|
---|
| 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 | ;
|
---|
| 10 | PREP ; 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 | N DITRXNO S DITRXNO=DIDENT(-4)
|
---|
| 16 | I $G(DINDEX(DISUB,"USE")),DIVAL'="" D
|
---|
| 17 | . S DIVAL=$O(@DINDEX(DISUB,"ROOT")@(DIVAL),-DINDEX(DISUB,"WAY"))
|
---|
| 18 | ;
|
---|
| 19 | LOOP ; loop through subscripts
|
---|
| 20 | ;
|
---|
| 21 | N DIDONE,DISKIP S DIDONE=0 F D Q:DIDONE!$G(DIERR)
|
---|
| 22 | . S DIVAL=$O(@DINDEX(DISUB,"ROOT")@(DIVAL),DINDEX(DISUB,"WAY"))
|
---|
| 23 | .
|
---|
| 24 | DATA . ; if we're in the data subscripts, we need to walk further
|
---|
| 25 | .
|
---|
| 26 | . I DISUB'>DINDEX("#") D Q
|
---|
| 27 | . . S DISKIP=0
|
---|
| 28 | . . I DIVAL'="",'$D(DINDEX(DISUB,"IXROOT")) D CHK Q:DISKIP
|
---|
| 29 | . . S:DIVAL="" DIDONE=1
|
---|
| 30 | . . I DIDONE Q:'DITRXNO D Q:DIDONE!(DISKIP)
|
---|
| 31 | . . . S DITRXNO=$O(DINDEX(DISUB,DITRXNO)) Q:'DITRXNO
|
---|
| 32 | . . . S (DIVAL,DIPART)=DINDEX(DISUB,DITRXNO)
|
---|
| 33 | . . . I DITRXNO=3!(DITRXNO=4),DIDENT(-1)>DINDEX("TOTAL") S DISKIP=1
|
---|
| 34 | . . . S DIDONE=0
|
---|
| 35 | . . . Q
|
---|
| 36 | . . S DINDEX(DISUB)=DIVAL,DINDEX("AT")=DISUB+1
|
---|
| 37 | . . S DINDEX(DISUB,"FOUND")=DITRXNO,DIDENT(-4)=1
|
---|
| 38 | . . I DISUB=1,$D(DINDEX(1,"IXROOT")) S DINDEX(1)=$P(DIVAL,U,2)
|
---|
| 39 | . . D WALK(.DIFLAGS,.DINDEX,.DIDENT,.DIFILE,.DIEN,DIFIEN,.DISCREEN,.DILIST,.DIC,.DIY,.DIYX)
|
---|
| 40 | . . S DINDEX("AT")=DISUB
|
---|
| 41 | . . S DIDENT(-4)=DITRXNO
|
---|
| 42 | . . I DISUB=1,$D(DINDEX(1,"IXROOT")) S DINDEX(1)=DIVAL
|
---|
| 43 | . . I $G(DINDEX("DONE"))!$G(DIERR) S DIDONE=1
|
---|
| 44 | .
|
---|
| 45 | IEN . ; otherwise, we're in the IEN subscripts & need to process
|
---|
| 46 | .
|
---|
| 47 | . I DIVAL="" S DIDONE=1 Q
|
---|
| 48 | . I DINDEX="B" N DIMNEM D
|
---|
| 49 | . . I $D(@DINDEX(DISUB,"ROOT")@(DIVAL))#2 Q:'^(DIVAL)
|
---|
| 50 | . . E Q:'$O(@DINDEX(DISUB,"ROOT")@(DIVAL,""))
|
---|
| 51 | . . S DIMNEM="" Q
|
---|
| 52 | . D TRY
|
---|
| 53 | . Q
|
---|
| 54 | CLEAN ; clean up after loop, exit
|
---|
| 55 | S DINDEX(DISUB)=$S(DISUB<(DINDEX("#")+1):$G(DINDEX(DISUB,"FROM")),1:"")
|
---|
| 56 | S DIDENT(-4)=1
|
---|
| 57 | Q
|
---|
| 58 | ;
|
---|
| 59 | CHK ; See whether we have a match or are at the end of the subscripts.
|
---|
| 60 | I DISUB>1,"VP"[DINDEX(DISUB,"TYPE"),DIFLAGS'["Q" D Q
|
---|
| 61 | . N DIFL,DIFLD,DIV
|
---|
| 62 | . S DIFL=DINDEX(DISUB,"FILE"),DIFLD=DINDEX(DISUB,"FIELD"),DIV=DIVAL
|
---|
| 63 | . I DINDEX(DISUB,"TYPE")="V",$G(DISCREEN("V",DISUB))]"" D Q:DISKIP
|
---|
| 64 | . . N G S G="^"_$P(DIV,";",2) Q:G="^"
|
---|
| 65 | . . S:'$D(DINDEX(DISUB,"VP",G)) DISKIP=1 Q
|
---|
| 66 | . N DIVAL S DIVAL=$$EXTERNAL^DIDU(DIFL,DIFLD,"i",DIV)
|
---|
| 67 | . I $G(DIERR),DIFLAGS["l" K DIERR,^TMP("DIERR",$J) S DIVAL=DIV
|
---|
| 68 | . I DIVAL="" S DIDONE=1 Q
|
---|
| 69 | . F DITRXNO=0:0 S DITRXNO=$O(DINDEX(DISUB,DITRXNO)) Q:'DITRXNO D Q:'DIDONE
|
---|
| 70 | . . S DIPART=DINDEX(DISUB,DITRXNO),DIDONE=0
|
---|
| 71 | . . D MATCH I DIDONE,'$G(DINDEX("DONE")),DIMORE,DIFLAGS'["X" D
|
---|
| 72 | . . . S DIDONE=0 D FINDMORE^DICLIX0(DISUB,.DIVAL,DIPART,.DINDEX,.DIMORE) I DIVAL="" S DIDONE=1 Q
|
---|
| 73 | . . . D MATCH Q
|
---|
| 74 | . . Q:DIDONE
|
---|
| 75 | . . S DINDEX(DISUB,"EXT")=$$EXTERNAL^DIDU(DIFL,DIFLD,"",DIV)
|
---|
| 76 | . . I $G(DIERR),DIFLAGS["l" K DIERR,^TMP("DIERR",$J) S DINDEX(DISUB,"EXT")=DIV
|
---|
| 77 | . . Q
|
---|
| 78 | . I DIDONE S DIDONE=0,DISKIP=1
|
---|
| 79 | . Q
|
---|
| 80 | D MATCH I DIDONE,'$G(DINDEX("DONE")),DIMORE,DIFLAGS'["X" D
|
---|
| 81 | . S DIDONE=0 D FINDMORE^DICLIX0(DISUB,.DIVAL,DIPART,.DINDEX,.DIMORE) I DIVAL="" S DIDONE=1 Q
|
---|
| 82 | . D MATCH Q
|
---|
| 83 | Q
|
---|
| 84 | ;
|
---|
| 85 | MATCH ; No more subscripts or partial matches, or past our TO value?
|
---|
| 86 | Q:DIVAL="" I DIFLAGS["l",DINDEX(DISUB,DITRXNO)="" Q
|
---|
| 87 | I DIFLAGS["X",DIVAL'=DINDEX(DISUB,DITRXNO) S DIDONE=1 Q
|
---|
| 88 | I $P(DIVAL,$G(DIPART))'="" S DIDONE=1 Q
|
---|
| 89 | I $G(DINDEX(DISUB,+DITRXNO,"c"))]"" D Q:DIDONE!(DISKIP)
|
---|
| 90 | . D NXTNAM^DICFIX1(.DIVAL,DIPART,.DINDEX,.DISKIP,.DIDONE) Q
|
---|
| 91 | Q
|
---|
| 92 | ;
|
---|
| 93 | TRY ; Apply screens to entry. If passed, add entry to output.
|
---|
| 94 | S (DIEN,DINDEX(DISUB))=DIVAL
|
---|
| 95 | N DI0NODE S DI0NODE=$G(@DIFILE(DIFILE)@(DIEN,0))
|
---|
| 96 | Q:$$SCREEN^DICL2(.DIFILE,.DIEN,DIFLAGS,DIFIEN,.DISCREEN,.DINDEX,DI0NODE)
|
---|
| 97 | ; If called from ^DIC, special processing.
|
---|
| 98 | I DIFLAGS["l" D DICLIST Q
|
---|
| 99 | ; Else, add entry to output list.
|
---|
| 100 | D ACCEPT^DICL2(.DIFILE,.DIEN,.DIFLAGS,DIFIEN,.DINDEX,.DIDENT,.DILIST,DI0NODE)
|
---|
| 101 | Q:$G(DIERR)
|
---|
| 102 | I DIDENT(-1)=DIDENT(-1,"MAX"),'DIDENT(-1,"JUST LOOKING") S DIDONE=1,DINDEX("DONE")=1
|
---|
| 103 | Q
|
---|
| 104 | ;
|
---|
| 105 | DICLIST ; Build output list when Finder is called from ^DIC.
|
---|
| 106 | ; Display entries and allow selection if screen is filled.
|
---|
| 107 | K DTOUT,DUOUT N D,DIX,DIFINDR,DIFILE,X,Y I DIC(0)["E" N DIQUIET
|
---|
| 108 | S Y=DIEN,D=DINDEX,DIX=DINDEX(1),DIFINDR=1
|
---|
| 109 | S X=$S("VP"[DINDEX(1,"TYPE"):DIX,1:DINDEX(1,DINDEX(1,"FOUND")))
|
---|
| 110 | I "VP"[DINDEX(1,"TYPE") S DS(0,"DICRS")=1
|
---|
| 111 | I "D"[DINDEX(1,"TYPE") S DS(0,"DIDA")=1
|
---|
| 112 | D MN^DIC3 Q:'$T
|
---|
| 113 | D K^DIC3
|
---|
| 114 | I DS(0) S (DIDONE,DINDEX("DONE"))=1
|
---|
| 115 | Q
|
---|
| 116 | ;
|
---|
| 117 | ;
|
---|