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

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

initial load of WorldVistAEHR

File size: 4.8 KB
Line 
1DICA1 ;SEA/TOAD-VA FileMan: Updater, Pre-Processor ;11:46 AM 11 May 1999
2 ;;22.0;VA FileMan;**1**;Mar 30, 1999
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5CHECK(DIFLAGS,DIFDA,DINUMS,DIRULE,DIOK) ;
6 ; ENTRY POINT--check out the FDA
7 ; subroutine, DIFLAGS passed by value
8 N DIC,DIEN,DIFILE,DIFLD,DIN,DINODE,DINT,DINUM,DIOP
9 N DIOUT1,DIOUT2,DIOUT3,DIRID,DIRIGHT,DISEQ,DITYPE,DIVAL
10 N DIKEYEX
11FILES ;
12 S DIFILE=0,DIOUT1=0 F D Q:DIOUT1!$G(DIERR)
13 . S DIFILE=$O(@DIFDA@(DIFILE))
14 . I 'DIFILE S DIOUT1=1 Q
15 . S DINODE=$G(^DD(DIFILE,.01,0))
16 . I DINODE="" D Q
17 . . D ERR^DICA3($S('$D(^DD(DIFILE)):401,1:406),DIFILE)
18 . I $P(DINODE,U,2)["W" D Q
19 . . D ERR^DICA3(407,DIFILE)
20 . S DIRID=$$RID^DICU(DIFILE)
21 . ;
22 . ;If we're using primary keys for lookup, get key info
23 . S DIKEYEX=$D(^DD("KEY","F",DIFILE))
24 . I $G(DIFLAGS)["K",DIKEYEX D GETPKEY^DIEVK1(DIFILE)
25 . ;
26IENS . ;
27 . S DIEN="",DIOUT2=0 F D Q:DIOUT2!$G(DIERR)
28 . . S DIEN=$O(@DIFDA@(DIFILE,DIEN))
29 . . I DIEN="" S DIOUT2=1 Q
30 . . N DIDA D IEN^DICA2(.DIFILE,DIEN,.DIDA,DIRULE,.DIOK) Q:$G(DIERR)
31 . . I 'DIOK S DIOUT1=1,DIOUT2=1 D Q
32 . . . I $E(DIEN,$L(DIEN))'="," D ERR^DICA3(304,"",DIEN) Q
33 . . . D ERR^DICA3(202,"","","","IENS")
34 . . Q:'$$RID(DIFILE,DIEN,DIFDA,DIRID,DIFLAGS,DIKEYEX)
35 . . I $D(@DIFDA@(DIFILE,DIEN,.001))#2 D
36 . . . N DIENS S DIENS=@DIFDA@(DIFILE,DIEN,.001)
37 . . . I $D(@DINUMS@(@DIRULE@("NUM")))[0 D
38 . . . . S @DINUMS@(@DIRULE@("NUM"))=DIENS
39 . . . S @DIRULE@("SAVE",$J,DIFILE,DIEN,.001)=DIENS
40 . . . K @DIFDA@(DIFILE,DIEN,.001)
41VALUES . . ;
42 . . I DIFLAGS'["E",$G(DIFLAGS)["U"!'DIKEYEX Q
43 . . S DIFLD="",DIOUT3=0 F D Q:DIOUT3!$G(DIERR)
44 . . . S DIFLD=$O(@DIFDA@(DIFILE,DIEN,DIFLD))
45 . . . I DIFLD="" S DIOUT3=1 Q
46 . . . I $G(DIFLAGS)'["U",DIKEYEX D BLDFLD^DIEVK1(DIFILE,DIEN,DIFLD) Q:DIFLAGS'["E"
47 . . . I $E(DIEN)="?",$E(DIEN,2)'="+" Q:DIFLD=.01&(DIFLAGS'["K") I DIFLAGS["K",$D(^TMP("DIKK",$J,"P",DIFILE,DIFILE,DIFLD))#2 Q
48 . . . S DIVAL=$G(@DIFDA@(DIFILE,DIEN,DIFLD))
49 . . . D DTYP^DIOU(DIFILE,DIFLD,.DITYPE)
50 . . . I DITYPE=5 S DINT=DIVAL
51CONVERT . . . ;
52 . . . I DITYPE'=5 D Q:$G(DIERR)
53 . . . . I DIEN["?"!(DIEN["+") D Q:$G(DIERR)
54 . . . . . I "@"[DIVAL D Q
55 . . . . . . I DIEN["?",$P($G(^DD(DIFILE,DIFLD,0)),U,2)["R" D Q
56 . . . . . . . D ERR712(DIFILE,DIFLD)
57 . . . . . . S DINT=DIVAL
58 . . . . . I DIFLAGS["K",$E(DIEN)'="+",$P($G(^DD(DIFILE,DIFLD,0)),U,5,999)["DINUM",$D(^TMP("DIKK",$J,"P",DIFILE)),$D(^(DIFILE,DIFLD))[0 D Q
59 . . . . . . D ERR^DICA3(520,DIFILE,"",DIFLD,"DINUMed")
60 . . . . . N DA M DA=DIDA
61 . . . . . N DIARG S DIARG="D0"
62 . . . . . N DIMAX S DIMAX=$O(DA(""),-1)
63 . . . . . N DIVAR F DIVAR=1:1:DIMAX S DIARG=DIARG_",D"_DIVAR
64 . . . . . N @DIARG F DIVAR=0:1:DIMAX-1 S @("D"_DIVAR)=DA(DIMAX-DIVAR)
65 . . . . . S:DIMAX @("D"_DIMAX)=DA
66 . . . . . N DIDA D CHK^DIE(DIFILE,DIFLD,"N",DIVAL,.DINT)
67 . . . . E D Q:$G(DIERR)
68 . . . . . N DIVALFLG S DIVALFLG="RU"_$E("Y",DIFLAGS["Y")
69 . . . . . D VAL^DIE(DIFILE,DIEN,DIFLD,DIVALFLG,DIVAL,.DINT)
70 . . . . Q:$D(DINUM)[0
71 . . . . S @DINUMS@(@DIRULE@("NUM"))=DINUM K DINUM
72 . . . S @DIRULE@("FDA",DIFILE,DIEN,DIFLD)=DINT
73CLEANUP ;
74 I $G(DIERR)!'DIOK K @DIRULE Q
75 K @DIRULE@("L"),@DIRULE@("NUM"),@DIRULE@("OP"),@DIRULE@("ROOT")
76 K @DIRULE@("SEQ"),@DIRULE@("TEMP"),@DIRULE@("UP")
77 S DIN=$NA(@DIRULE@("ORDER")),DIC=0,@DIRULE@("THE END")=""
78 F S DIN=$Q(@DIN) Q:DIN=""!($P(DIN,",",3)'="""ORDER""") D
79 . S DIC=DIC+1,@DIRULE@("NEXT",DIC)=@DIN
80 K @DIRULE@("ORDER"),@DIRULE@("THE END")
81 I DIFLAGS["E" S DIFDA=$NA(@DIRULE@("FDA"))
82 Q
83 ;
84RID(DIFILE,DIEN,DIFDA,DIRID,DIFLAGS,DIKEYEX) ;
85 N DIC,DIK,DIOK,DIP,DIR
86 ;
87 ;Check required ids
88 S DIP=$P(DIEN,","),DIOK=1
89 F DIC=1:1 S DIR=$P(DIRID,U,DIC) Q:DIR="" D
90 . I DIR=.01 D
91 . . I DIP'?1P.E
92 . . E I DIP["+" D:"@"[$G(@DIFDA@(DIFILE,DIEN,.01))
93 . . . S DIOK=0 D ERR^DICA3(352,DIFILE,DIEN)
94 . . E I DIFLAGS'["K" D:"@"[$G(@DIFDA@(DIFILE,DIEN,.01))
95 . . . S DIOK=0 D ERR^DICA3(351,DIFILE,DIEN)
96 . E I DIP["+" D:"@"[$G(@DIFDA@(DIFILE,DIEN,DIR))
97 . . S DIOK=0 D ERR^DICA3(311,DIFILE,DIEN,DIR)
98 . E D:"@"[$G(@DIFDA@(DIFILE,DIEN,DIR),0)
99 . . S DIOK=0 D ERR712(DIFILE,DIR)
100 ;
101 ;Check that the FDA contains the appropriate key fields
102 Q:'$G(DIKEYEX,1) DIOK
103 ;
104 ;If appropriate, ensure all primary and secondary keys are provided
105 I DIFLAGS'["U",DIP["+" D
106 . S DIR=0 F S DIR=$O(^DD("KEY","F",DIFILE,DIR)) Q:'DIR D
107 . . D:"@"[$G(@DIFDA@(DIFILE,DIEN,DIR))
108 . . . S DIK=0 F S DIK=$O(^DD("KEY","F",DIFILE,DIR,DIK)) Q:'DIK D
109 . . . . S DIOK=0 D ERR744^DIEVK1(DIFILE,DIR,DIK,DIEN)
110 ;
111 ;If appropriate, ensure at least one key field is provided
112 E I $G(DIFLAGS)["K",$E(DIEN)="?",$E(DIEN,2)'="+"!($G(DIFLAGS)["U") D
113 . S:'$$KFLD^DIEVK1(DIFILE,DIEN,DIFDA) DIOK=0
114 Q DIOK
115 ;
116ERR712(DIFILE,DIFIELD) ;
117 N DIFILNAM S DIFILNAM=$O(^DD(DIFILE,0,"NM","")) S:DIFILNAM?." " DIFILNAM="#"_DIFILE
118 N DIFLDNAM S DIFLDNAM=$$FLDNM^DIEFU(DIFILE,DIFIELD)
119 D ERR^DICA3(712,DIFILE,"",DIFIELD,DIFLDNAM,DIFILNAM)
120 Q
Note: See TracBrowser for help on using the repository browser.