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

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

initial load of FOIAVistA 6/30/08 version

File size: 4.0 KB
Line 
1DIEVK1 ;SFISC/MKO-KEY VALIDATION ;10:42 AM 30 Sep 1998
2 ;;22.0;VA FileMan;;Mar 30, 1999
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5BUILD(DIVKFDA,DIVKFLAG) ;Loop thru FDA and load key info
6 N DIVKEYOK,DIVKFIL,DIVKFLD,DIVKIENS,DIVKQUIT
7 ;
8 S DIVKEYOK=1,DIVKFIL=0
9 F S DIVKFIL=$O(@DIVKFDA@(DIVKFIL)) Q:'DIVKFIL D Q:$G(DIVKQUIT)
10 . Q:'$D(^DD("KEY","F",DIVKFIL))
11 . D:$G(DIVKFLAG)["K" GETPKEY(DIVKFIL)
12 . S DIVKIENS=""
13 . F S DIVKIENS=$O(@DIVKFDA@(DIVKFIL,DIVKIENS)) Q:DIVKIENS="" D Q:$G(DIVKQUIT)
14 .. I $G(DIVKFLAG)["K",$E(DIVKIENS)="?",$E(DIVKIENS,2)'="+",'$$KFLD(DIVKFIL,DIVKIENS,DIVKFDA) S DIVKEYOK=0 I $G(DIVKFLAG)["Q" S DIVKQUIT=1 Q
15 .. S DIVKFLD=0
16 .. F S DIVKFLD=$O(@DIVKFDA@(DIVKFIL,DIVKIENS,DIVKFLD)) Q:'DIVKFLD D BLDFLD(DIVKFIL,DIVKIENS,DIVKFLD)
17 Q DIVKEYOK
18 ;
19BLDFLD(DIVKFIL,DIVKIENS,DIVKFLD) ;Build key/index info on a given field
20 ; ^TMP("DIKK",$J,"L",key) = rfile^ui^priority
21 ; ... ,file,iens) = ""
22 ; ... ,"UIR") = uir
23 ; ... ,"SS",n) = file^field^maxlen
24 N DIVKEY,DIVKPRI,DIVKRFIL,DIVKSS,DIVKUI,DIVKUIR
25 ;
26 S DIVKEY=0
27 F S DIVKEY=$O(^DD("KEY","F",DIVKFIL,DIVKFLD,DIVKEY)) Q:'DIVKEY D
28 . Q:$D(^TMP("DIKK",$J,"L",DIVKEY,DIVKFIL,DIVKIENS))#2 S ^(DIVKIENS)=""
29 . Q:$D(^TMP("DIKK",$J,"L",DIVKEY))#2
30 . ;
31 . D LOADKEY^DIKK1(DIVKEY)
32 . S DIVKRFIL=$P($G(^DD("KEY",DIVKEY,0)),U),DIVKUI=$P($G(^(0)),U,4),DIVKPRI=$P($G(^(0)),U,3)
33 . S ^TMP("DIKK",$J,"L",DIVKEY)=DIVKRFIL_U_DIVKUI_U_DIVKPRI
34 . Q:'DIVKRFIL!'DIVKUI
35 . D XRINFO^DIKCU2(DIVKUI,.DIVKUIR,"","","","",.DIVKSS)
36 . S ^TMP("DIKK",$J,"L",DIVKEY,"UIR")=DIVKUIR
37 . M ^TMP("DIKK",$J,"L",DIVKEY,"SS")=DIVKSS
38 Q
39 ;
40GETPKEY(KFIL) ;Get fields in primary key for file KFIL
41 ; ^TMP("DIKK",$J,"P",kfile) = key^ui#^uifile^uiname
42 ; ... ,file,field) = seq#
43 ;
44 N FIL,FLD,I,KEY,SEQ,UI
45 S KEY=$O(^DD("KEY","AP",KFIL,"P",0)) Q:'KEY
46 S I=0 F S I=$O(^DD("KEY",KEY,2,I)) Q:'I D
47 . Q:$D(^DD("KEY",KEY,2,I,0))[0 S FLD=$P(^(0),U),FIL=$P(^(0),U,2),SEQ=$P(^(0),U,3)
48 . Q:'FLD!'FIL!'SEQ
49 . S ^TMP("DIKK",$J,"P",KFIL,FIL,FLD)=SEQ
50 I $D(^TMP("DIKK",$J,"P",KFIL)) D
51 . S UI=$P(^DD("KEY",KEY,0),U,4)
52 . S ^TMP("DIKK",$J,"P",KFIL)=KEY_U_UI_U_$P($G(^DD("IX",+UI,0)),U,1,2)
53 Q
54 ;
55KFLD(KFIL,IENS,FDA) ;Check that at least one primary key field is in FDA
56 N FIL,FLD,KEY,OK,SEQ
57 S KEY=+$G(^TMP("DIKK",$J,"P",KFIL)) Q:'KEY 1
58 S OK=0
59 S FIL=0 F S FIL=$O(^TMP("DIKK",$J,"P",KFIL,FIL)) Q:'FIL D Q:OK
60 . S FLD=0 F S FLD=$O(^TMP("DIKK",$J,"P",KFIL,FIL,FLD)) Q:'FLD D Q:OK
61 .. S:"@"'[$G(@FDA@(FIL,IENS,FLD)) OK=1
62 D:'OK ERR746(KFIL,KEY,IENS)
63 Q OK
64 ;
65FINDCONV(DIVKIENS,DIVKFIEN) ;Replace ?n in DIVKIENS with actual ien's
66 N I,N,P
67 F I=1:1:$L(DIVKIENS,",")-1 D
68 . S P=$P(DIVKIENS,",",I) Q:P'["?"
69 . S N=$G(@DIVKFIEN@($TR(P,"?+"))) Q:'N
70 . S $P(DIVKIENS,",",I)=+$G(@DIVKFIEN@($TR(P,"?+")))
71 Q DIVKIENS
72 ;
73ERR740(FILE,KEY,IENS) ;New values are invalid because they create a duplicate
74 ;Key '|1|' for the |2| file.
75 N P,PEXT
76 S P(1)=$P(^DD("KEY",KEY,0),U,2)
77 S P(2)=$O(^DD(FILE,0,"NM","")) S:P(2)?." " P(2)="#"_FILE
78 S PEXT("FILE")=FILE,PEXT("KEY")=KEY,PEXT("IENS")=IENS
79 D BLD^DIALOG(740,.P,.PEXT)
80 Q
81 ;
82ERR742(FILE,FIELD,KEY,IENS) ; The value of field |1| in the |2| file
83 ;cannot be deleted because that field is part of the '|3|' key.
84 N P,PEXT
85 S P(1)=$$FLDNM^DIEFU(FILE,FIELD)
86 S P(2)=$O(^DD(FILE,0,"NM","")) S:P(2)?." " P(2)="#"_FILE
87 S P(3)=$P(^DD("KEY",KEY,0),U,2)
88 S PEXT("FILE")=FILE,PEXT("FIELD")=FIELD,PEXT("IENS")=IENS
89 D BLD^DIALOG(742,.P,.PEXT)
90 Q
91 ;
92ERR744(FILE,FIELD,KEY,IENS) ;Field |1| is part of Key '|2|', but the
93 ;field has not been assigned a value.
94 N P,PEXT
95 S P(1)=$$FLDNM^DIEFU(FILE,FIELD)
96 S P(2)=$P(^DD("KEY",KEY,0),U,2)
97 S PEXT("FILE")=FILE,PEXT("FIELD")=FIELD,PEXT("IENS")=IENS
98 D BLD^DIALOG(744,.P,.PEXT)
99 Q
100 ;
101ERR746(FILE,KEY,IENS) ;At least one field in Primary Key '|1|' must be
102 ;provided in the FDA to look up '|IENS|' in the |2| file.
103 N P,PEXT
104 S P(1)=$P(^DD("KEY",KEY,0),U,2)
105 S P(2)=$O(^DD(FILE,0,"NM","")) S:P(2)?." " P(2)="#"_FILE
106 S P("IENS")=IENS
107 S PEXT("FILE")=FILE,PEXT("KEY")=KEY,PEXT("IENS")=IENS
108 D BLD^DIALOG(746,.P,.PEXT)
109 Q
Note: See TracBrowser for help on using the repository browser.