source: WorldVistAEHR/trunk/r/VA_FILEMAN-ARJT-DI-DD-DM-DT-%DT-%RCR/DICUIX1.m@ 1801

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

initial load of WorldVistAEHR

File size: 4.1 KB
RevLine 
[613]1DICUIX1 ;SF/TOAD/TKW-FileMan: Lookup Tools, Indexes (called by DICUIX) ;4/13/00 13:40
2 ;;22.0;VA FileMan;**4,28,3**;Mar 30, 1999;
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5GET(DITOP,DIFILE,DIFIELD,DIDEF,DICODE) ;
6 ; get the definition and fetch code for a field
7 ;
8G1 ; handle .001 fields, fetch field definition, & handle undefineds
9 ;
10 I DIFIELD=.001 S DICODE="DIEN",DIDEF="" Q
11 S DIDEF=$G(^DD(DIFILE,DIFIELD,0)),DICODE=""
12 I DIDEF="" D ERR^DICU1(501,DIFILE,"","",DIFIELD) Q
13 ;
14G2 ; piece out the fields data type, & handle multiples and WPs
15 ;
16 N DITYPE S DITYPE=$P(DIDEF,U,2)
17 I DITYPE D Q
18 . I $P($G(^DD(+DITYPE,.01,0)),U,2)["W" S DITYPE="Word-processing"
19 . E S DITYPE="Multiple"
20 . D ERR^DICU1(520,DIFILE,"",DIFIELD,DITYPE)
21 ;
22G3 ; handle computed fields
23 ;
24 I DITYPE["C" D Q
25 . S DICODE=$P(DIDEF,U,5,9999)
26 . S DIDEF=$P(DIDEF,U,1,4)
27 ;
28G30 ; Handle whole file x-refs
29 I DIFILE'=DITOP S DICODE="DINDEX(DISUB)" Q
30G4 ; get field's storage location, handle ?, build node fetch code
31 ;
32 N DISTORE S DISTORE=$P(DIDEF,U,4)
33 N DINODE S DINODE=$P(DISTORE,";")
34 N DIPIECE S DIPIECE=$P(DISTORE,";",2)
35 I DINODE="",$P(DIPIECE,"E")'="",'DIPIECE S (DICODE,DIDEF)="" Q
36 I DINODE=0,DIFILE=DITOP S DINODE="DI0NODE"
37 E S DINODE="$G(@DIFILE(DIFILE)@(+DIEN,"""_DINODE_"""))"
38 ;
39G5 ; build field fetch code (piece or extract) & quit
40 ;
41 I DIPIECE S DICODE="$P("_DINODE_",U,"_DIPIECE_")"
42 E D
43 . N DIEFROM S DIEFROM=$P($E(DIPIECE,2,9999),",")
44 . N DIETO S DIETO=$P(DIPIECE,",",2)
45 . S DICODE="$E("_DINODE_","_DIEFROM_","_DIETO_")"
46 Q
47 ;
48FIELD(DIFILE,DIFIELD,DINDEX) ;
49 ;
50 ; return code to fetch field value prior to screen execution
51 ;
52F1 ; handle .01 & computeds, build node expression
53 ;
54 I DIFIELD=.01 Q "DINDEX(1)"
55 N DISTORE S DISTORE=$P(DINDEX(1,"DEF"),U,4)
56 N DINODE S DINODE=$P(DISTORE,";")
57 N DIPIECE S DIPIECE=$P(DISTORE,";",2)
58 I 'DINODE,$P(DIPIECE,"E")'="",'DIPIECE Q "X"
59 I DINODE=0 S DINODE="DI0NODE"
60 E S DINODE="$G(@DIFILE(DIFILE)@(+DIEN,"""_DINODE_"""))"
61 ;
62F2 ; build fetch code from node expression
63 ;
64 N DICODE
65 I DIPIECE S DICODE="$P("_DINODE_",U,"_DIPIECE_")"
66 E D
67 . N DIEFROM S DIEFROM=$P($E(DIPIECE,2,9999),",")
68 . N DIETO S DIETO=$P(DIPIECE,",",2)
69 . S DICODE="$E("_DINODE_","_DIEFROM_","_DIETO_")"
70 Q DICODE
71 ;
72GETTMP(DITEMP,DISUB) ; Return name of unique entry in ^TMP global.
73 I $G(DISUB(1))']"" S DISUB(1)=$G(DISUB)
74 N I S DITEMP="^TMP("
75 F I=0:0 S I=$O(DISUB(I)) Q:'I I DISUB(I)]"" D
76 . N X S X=DISUB(I) I +$P(X,"E")'=X S X=""""_X_""""
77 . S DITEMP=DITEMP_X_","
78 N DIKJ,J
79 F DIKJ=$J:.01 S J=DITEMP_DIKJ_")" I '$D(@J) L +@J Q
80 S @J="",DITEMP=J L -@J Q
81 ;
82TMPB(DITEMP,DIFILE) ; Set place for temporary "B" index on file
83 N DISUB S DISUB(1)="DICLB",DISUB(2)=DIFILE
84 D GETTMP(.DITEMP,.DISUB)
85 S DITEMP=$E(DITEMP,1,($L(DITEMP)-1)) Q
86 ;
87BLDB(DIROOT,DITEMP) ; Build temporary "B" index on file
88 N DIENTRY,DIVALUE S DIENTRY=0,DITEMP=DITEMP_")"
89 F S DIENTRY=$O(@DIROOT@(DIENTRY)) Q:'DIENTRY D
90 . S DIVALUE=$P($G(@DIROOT@(DIENTRY,0)),U) Q:DIVALUE=""
91 . S @DITEMP@(DIVALUE,DIENTRY)=""
92 . Q
93 Q
94 ;
95TMPIDX(DISUB,DITEMP,DITEMP2,DINDEX) ; Set data to build temporary index on Lister call with Pointer/VP in index.
96 S DITEMP2=DITEMP
97 D GETTMP^DICUIX1(.DITEMP,"DICL")
98 S DITEMP=$E(DITEMP,1,($L(DITEMP)-1))
99 S DINDEX("ROOTCNG",DISUB)=""
100 Q
101 ;
102CHKP(DIFILE,DINDEX,DINUMBER,DIFRPRT,DISCREEN,DICQ1) ; Check whether to build temporary index on Lister call with Pointer/VP in first subscript of index.
103 N DIN1,DIN2,X,I,D S DIN2=0
104 S DIN1=+$P($G(@DIFILE(DIFILE)@(0)),U,4)
105 N DIF,DIVPTR M DIF=DIFILE S DIVPTR=$S(DINDEX(1,"TYPE")="V":1,1:0)
106 D FOLLOW^DICL3(.DIF,"",DINDEX(1,"NODE"),1,0,"",DINDEX(1,"FIELD"),DINDEX(1,"FILE"),DIVPTR,1,.DISCREEN)
107 F I=1:1 S X=+$P($G(DIF("STACKEND",I)),U,2) Q:'X D
108 . S X=$G(^DIC(X,0,"GL")) Q:X="" S X=$G(@(X_"0)"))
109 . S DIN2=DIN2+$P(X,U,4)
110 S D=1 D
111 . N F1,F2 S F1=DINDEX(1,"FILE"),F2=DINDEX(1,"FIELD")
112 . I 'DIVPTR S I=$P($G(^DD(F1,F2,0)),U,2) S:I["*" D=.5 Q
113 . F I=0:0 S I=$O(^DD(F1,F2,"V",I)) Q:'I I $G(^(I,1))]"" S D=.5 Q
114 . S D=D*.5 Q
115 S DIN2=$S(DINUMBER!(DIFRPRT]""):DIN2/(40*D),1:DIN2/(20*D))
116 I $G(DICQ1),DIFRPRT]"" S DIN2=DIN2/2
117 I DIN2>DIN1,DIN1>500,'$G(DICQ1) Q 0
118 Q DIN2>DIN1
119 ;
Note: See TracBrowser for help on using the repository browser.