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

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

initial load of WorldVistAEHR

File size: 4.4 KB
RevLine 
[613]1DIC0 ;SFISC/TKW-Lookup routine utilities called by DIC ;12/10/99 12:10
2 ;;22.0;VA FileMan;**4,20**;Mar 30, 1999
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5D ; Reset back to starting index for lookup.
6 S D=DINDEX("START") K DINDEX S (DINDEX,DINDEX("START"))=D,DINDEX("WAY")=1
7 S:$D(DID(1)) DID(1)=2
8 N DIFLAGS S DIFLAGS="4l"_$P("M^",U,DIC(0)["M")
9 D INDEX^DICUIX(.DIFILEI,DIFLAGS,.DINDEX,"",.DIVAL)
10 Q
11 ;
12SETVAL ; If custom lookup routine (like MTLU) comes in to entry point after ASK, we need to set up the lookup values.
13 K DIVAL,DIALLVAL D CHKVAL
14 I DIVAL(0) D CHKVAL1(DINDEX("#"),.DIVAL,DIC(0),DIC(0),.DIALLVAL)
15 Q
16 ;
17INIT ; Initialize variables at all entry points in ^DIC.
18 I '$D(DIFILEI)#2 D GETFILE(.DIC,.DIFILEI,.DIENS) Q:DIFILEI=""
19 I '$D(@(DIC_"0)")),'$D(DIC("P")),$E(DIC,1,6)'="^DOPT(" S DIC("P")=$$GETP^DIC0(DIFILEI) I DIC("P")="" S Y=-1 D Q^DIC2 Q
20 I $G(DO)="" K DO D GETFA^DIC1(.DIC,.DO)
21 S (DINDEX,DINDEX("START"))=D,DINDEX("WAY")=1
22 D INDEX^DICUIX(.DIFILEI,"4l",.DINDEX,"",.DIVAL)
23 I DIC(0)["V" S DIASKOK=1
24 S Y=-1 I DIC(0)["Z" K Y(0)
25 Q
26 ;
27CHKVAL ; Check lookup values input by user.
28 N I I $G(X)="" S X=$G(X(1))
29 S DIVAL(0)=0,DIVAL(1)=X F I=2:1:DINDEX("#") S DIVAL(I)=$G(X(I))
30 N J,DIOUT S DIOUT=0
31 F I=1:1:DINDEX("#") S J=$G(DIVAL(I)) I J]"" D Q:DIOUT
32 . I DINDEX("#")>1 S X(I)=J
33 . I J["^" S (DUOUT,DIOUT)=1,DIVAL(0)=0 Q
34 . I J?1."?" K DIVAL S DIVAL(0)=0,X=$E(J,1,2),DIOUT=1 Q
35 . S DIVAL(0)=DIVAL(0)+1 Q
36 Q
37 ;
38CHKVAL1(DIXNO,DIVAL,DIFLAGS,DIC0,DIALLVAL) ; Check for errors with values, flags,index.
39 N DIERROR,I S DIALLVAL=1 D
40 . I '$D(DIC0),DIFLAGS'["l" D Q:$G(DIERROR)
41 . . S I=$O(DIVAL(99999),-1) I I>DIXNO S DIERROR=8093 Q
42 . . S:DIXNO>1&(DIFLAGS["M") DIERROR=8095 Q
43 . F I=1:1:DIXNO S DIVAL(I)=$G(DIVAL(I)) D:DIVAL(I)=""
44 . . I DIFLAGS["X",DIFLAGS'["l" S DIERROR=8094 Q
45 . . S DIALLVAL=0 Q
46 . Q
47 I $D(DIERROR) D
48 . I '$D(DIC0) D ERR^DICF4(DIERROR) Q
49 . K DIVAL S DIVAL(0)=0 Q:DIC0'["E" W $C(7),!,$$EZBLD^DIALOG(DIERROR) Q
50 Q
51 ;
52CHKVAL2(DIXNO,DIVAL,DIC0,DDS) ; Check lookup values for control characters or too long.
53 N I,J,DIER S DIER=""
54 F I=1:1:DIXNO S J=$G(DIVAL(I)) D:J]"" Q:DIER
55 . I J'?.ANP S DIER=204 Q
56 . I J?1.N.1".".N,($L($P(J,"."))>25!($L($P(J,".",2))>25)) S DIER=208 Q
57 . I ($L(J)-255)>0 S DIER=209
58 . Q
59 Q:'DIER
60 D:DIC0["Q"
61 . W $C(7) Q:DIC(0)'["E"
62 . I '$D(DDS) W !,$$EZBLD^DIALOG(DIER) Q
63 . N DDH S DDH=1,DDH(1,"T")=" ** "_$$EZBLD^DIALOG(DIER)
64 . S DDC=7,DDD=1 D LIST^DDSU
65 . Q
66 K DIVAL S DIVAL(0)=0
67 Q
68 ;
69KILL2 K DIVAL,DIALLVAL
70KILL1 K DIFILEI,DINDEX,DIMAXLEN,DIENS Q
71 ;
72GETFILE(DIC,DIFILE,DIENS) ; Return file number, global references, IEN string and KEY fields data.
73 S DIFILE="" I $G(DIC)="" Q
74 I +$P(DIC,"E")'=DIC N DIDIC M DIDIC=DIC N DIC S DIDIC=$$CREF^DILF(DIDIC),DIDIC=$NA(@DIDIC),DIDIC=$$OREF^DILF(DIDIC) M DIC=DIDIC K DIDIC
75 N DA
76 I +$P(DIC,"E")=DIC D
77 . S DIFILE=DIC,DIC=$G(^DIC(DIC,0,"GL")) Q:DIC]""
78 . S DIC=DIFILE,DIFILE="" Q
79 E D
80 . S DIFILE=$G(@(DIC_"0)")) I DIFILE]"" S DIFILE=+$P(DIFILE,U,2) Q
81 . S DIFILE=+$G(DIC("P")) Q:DIFILE
82 . S DIFILE=$$FILENUM^DILIBF(DIC) Q
83 Q:DIFILE=""
84 S DIENS=","
85 I DIC(0)'["p" D SETIEN(DIC,DIFILE,.DIENS) Q:DIFILE=""
86 S DIFILE(DIFILE,"O")=DIC
87 S DIFILE(DIFILE)=$$CREF^DILF(DIC)
88 N I S I=$O(^DD("KEY","AP",DIFILE,"P",0)) Q:'I
89 S DIFILE(DIFILE,"KEY","IEN")=DIENS
90 N F,X F F=0:0 S F=$O(^DD("KEY",I,2,F)) Q:'F S X=$G(^(F,0)) D
91 . S DIFILE(DIFILE,"KEY",+$P(X,U,2),+$P(X,U,3),+X)="" Q
92 Q
93 ;
94SETIEN(DIC,DIFILE,DIENS) ; Set DIENS from global root
95 N F,G,I,J,K,DIDA
96 S F=$$FNO^DILIBF(DIFILE) I F="" S DIFILE="" Q
97 S G=$G(^DIC(F,0,"GL")) I G="" S DIFILE="" Q
98 S F=$P(DIC,G,2)
99 S K=0 F I=1:2 S J=$P(F,",",I) Q:J="" S K=K+1,J(K)=J
100 S DIDA="" F J=1:1:K S DIDA(K+1-J)=J(J)
101 S DIENS=$$IENS^DILF(.DIDA) Q
102 ;
103GETP(DISUB) ; Return DIC("P") for a subfile DIFILE.
104 N DIFILE S DIFILE=$G(^DD(DISUB,0,"UP")) Q:'DIFILE ""
105 N DIFIELD S DIFIELD=$O(^DD(DIFILE,"SB",DISUB,0)) Q:'DIFIELD ""
106 Q $P($G(^DD(DIFILE,DIFIELD,0)),U,2)
107 ;
108DSPH ; Display name of indexed fields when DIC(0)["T" (called from DICF2)
109 Q:$G(DS(0,"HDRDSP",DIFILEI)) S DS(0,"HDRDSP",DIFILEI)=1
110 W ! N I S I=($G(DICR))*2 W:I ?I
111 W " Lookup: "
112 I $G(DICR) S I=$G(@(DIC_"0)")) I I]"" W $P(I,U)_" "
113 F I=1:1:DINDEX("#") W DINDEX(I,"PROMPT")_$P(", ^",U,I<DINDEX("#"))
114 Q
115 ;
116 ; Error messages:
117 ; 204 The input value contains control character
118 ; 349 String too long by |1| character(s)!
119 ; 8093 Too many lookup values for this index.
120 ; 8094 Not enough lookup values provided for an e
121 ; 8095 Only one compound index allowed on a looku
122 ;
Note: See TracBrowser for help on using the repository browser.