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

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

initial load of FOIAVistA 6/30/08 version

File size: 4.4 KB
Line 
1DIKKUTL3 ;SFISC/MKO-VERIFY KEY INTEGRITY ;3:10 PM 27 Oct 1998
2 ;;22.0;VA FileMan;;Mar 30, 1999
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5VERIFY(DIKKEY,DIKKTOP,DIKKFILE) ;Verify key integrity
6 N DIKKTEMP,POP,%ZIS
7 ;
8 ;Ask whether to save records in a template
9 S DIKKTEMP=$$ASKTEMP(DIKKTOP)
10 ;
11 ;Select Device
12 S %ZIS=$S($D(^%ZTSK):"Q",1:"")
13 W ! D ^%ZIS Q:$G(POP)
14 K %ZIS,POP
15 ;
16 ;Queue report
17 I $D(IO("Q")) D Q
18 . N I,ZTSK
19 . S ZTRTN="MAIN^DIKKUTL3"
20 . S ZTDESC="KEY INTEGRITY CHECK"
21 . F I="DIKKEY","DIKKTOP","DIKKFILE","DIKKTEMP" S ZTSAVE(I)=""
22 . D ^%ZTLOAD
23 . I $D(ZTSK)#2 W !,"Report queued!",!,"Task number: "_$G(ZTSK),!
24 . E W !,"Report canceled!",!
25 . S IOP="HOME" D ^%ZIS
26 ;
27 U IO
28 ;
29MAIN ;Queued tasks enter here
30 N DIKKHLIN,DIKKFIL,DIKKNAME,DIKKPAGE,DIKKTAB,DIKKUI,DIKKUIFL,DIKKUINM
31 N DIKKIENS,DIKKFLD,DIKKFNAM,DIKKROOT,DIKKSUPP
32 K ^TMP("DIKKUTL",$J)
33 ;
34 ;Check key integrity
35 D INTEG^DIKK(DIKKTOP,"","",DIKKEY,"",1)
36 I $D(DIERR) D MSG^DIALOG() Q
37 ;
38 ;Initialize "global" variables for report
39 S DIKKPAGE=0
40 S %H=$H D YX^%DTC
41 S DIKKHLIN=$P(Y,"@")_" "_$P($P(Y,"@",2),":",1,2)_" PAGE "
42 S DIKKTAB(1)=9,DIKKTAB(2)=41
43 S DIKKNAME=$P($G(^DD("KEY",DIKKEY,0)),U,2)
44 S DIKKUI=$P($G(^DD("KEY",DIKKEY,0)),U,4)
45 S DIKKUINM=$P($G(^DD("IX",+DIKKUI,0)),U,2),DIKKUIFL=$P($G(^(0)),U)
46 ;
47 ;Print first header
48 W:$E(IOST,1,2)="C-" @IOF
49 D HDR
50 I '$D(^TMP("DIKKTAR",$J)) W !!," ** NO PROBLEMS **" G END
51 ;
52 ;Loop through target error and list problems
53 S DIKKFIL=0
54 F S DIKKFIL=$O(^TMP("DIKKTAR",$J,DIKKFIL)) Q:'DIKKFIL!$D(DIRUT) D
55 . D COLHDR
56 . S DIKKROOT=$$FROOTDA^DIKCU(DIKKFIL)
57 . S DIKKIENS=" "
58 . F S DIKKIENS=$O(^TMP("DIKKTAR",$J,DIKKFIL,DIKKIENS)) Q:DIKKIENS=""!$D(DIRUT) D
59 .. D:$D(^TMP("DIKKTAR",$J,DIKKFIL,DIKKIENS,"K",DIKKEY)) KEYERR(DIKKFIL,DIKKIENS,DIKKEY,DIKKROOT)
60 .. S (DIKKSUPP,DIKKFLD)=0
61 .. F S DIKKFLD=$O(^TMP("DIKKTAR",$J,DIKKFIL,DIKKIENS,DIKKFLD)) Q:'DIKKFLD!$D(DIRUT) D FLDERR(DIKKFIL,DIKKIENS,DIKKFLD,DIKKROOT,.DIKKSUPP)
62 .. Q:$D(DIRUT)
63 .. D W()
64 ;
65END D:'$D(DIRUT) EOPREAD
66 ;
67 ;Save in template, cleanup, and quit
68 D:$G(DIKKTEMP) SAVETEMP(DIKKTEMP)
69 K ^TMP("DIKKTAR",$J)
70 I $D(ZTQUEUED) S ZTREQ="@"
71 E X $G(^%ZIS("C"))
72 Q
73 ;
74KEYERR(RFIL,IENS,KEY,ROOT) ;
75 D WRREC(RFIL,IENS,DIKKTAB(1),.ROOT) Q:$D(DIRUT)
76 W ?DIKKTAB(2),"Duplicate Key "_$P($G(^DD("KEY",KEY,0)),U,2)_" (#"_KEY_")"
77 Q
78 ;
79FLDERR(FIL,IENS,FLD,ROOT,SUPP) ;
80 I '$G(SUPP) D Q:$D(DIRUT)
81 . D WRREC(FIL,IENS,DIKKTAB(1),.ROOT) Q:$D(DIRUT)
82 . W ?DIKKTAB(2),"Missing Key Field(s):"
83 D W($P($G(^DD(FIL,FLD,0)),U)_" ["_FIL_","_FLD_"]",DIKKTAB(2)+1)
84 S SUPP=1
85 Q
86 ;
87WRREC(FILE,IENS,TAB,ROOT) ;Write the record info
88 N DA,DIERR,ENAM,MSG
89 S:$G(ROOT)="" ROOT=$$FROOTDA^DIKCU(FILE)
90 D DA(IENS,.DA) Q:$D(DIRUT)
91 S ENAM=$P($G(@ROOT@(DA,0)),U)
92 S:ENAM]"" ENAM=$$EXTERNAL^DILFD(FILE,.01,"",ENAM,"MSG")
93 W ?TAB,$S(ENAM]"":ENAM,1:"Unknown record name")
94 Q
95 ;
96W(STR,TAB,KWN) ;Write STR
97 I $Y+3+$G(KWN)'<IOSL D Q:$D(DIRUT)
98 . D EOP Q:$D(DIRUT)
99 . D HDR,COLHDR
100 W !?+$G(TAB),$G(STR)
101 Q
102 ;
103EOP ;Check whether task should be stopped
104 I $D(ZTQUEUED),$$S^%ZTLOAD S (ZTSTOP,DIRUT)=1 Q
105 D EOPREAD Q:$D(DIRUT)
106 W @IOF
107 Q
108 ;
109EOPREAD ;
110 Q:$E(IOST,1,2)'="C-"!$D(ZTQUEUED)
111 N DIR,DIROUT,DTOUT,DUOUT,X,Y
112 S DIR(0)="E" W ! D ^DIR
113 Q
114 ;
115HDR ;Write page header
116 S DIKKPAGE=$G(DIKKPAGE)+1
117 S $X=0 W "KEY INTEGRITY CHECK"
118 W ?(IOM-$L(DIKKHLIN)-$L(DIKKPAGE)-1),DIKKHLIN_DIKKPAGE
119 W !,$TR($J("",IOM-1)," ","-")
120 W !," Key: "_DIKKNAME_" (#"_DIKKEY_"), File #"_DIKKFILE
121 W !,"Uniqueness Index: "_DIKKUINM_" (#"_DIKKUI_")"
122 W:DIKKFILE'=DIKKUIFL ", Whole File #"_DIKKUIFL
123 Q
124 ;
125COLHDR ;Write column headers
126 N FNAM
127 S FNAM=$P($G(^DD(DIKKFIL,.01,0)),U)
128 D W() Q:$D(DIRUT)
129 D W("ENTRY #","",2) Q:$D(DIRUT) W ?DIKKTAB(1),FNAM,?DIKKTAB(2),"ERROR"
130 W !,"-------",?DIKKTAB(1),$TR($J("",$L(FNAM))," ","-"),?DIKKTAB(2),"-----"
131 Q
132 ;
133ASKTEMP(DIKKTOP) ;Ask for a template name
134 N DDA,DIC,DICKL,DIR,DIROUT,DIRUT,DIU0,DK,DQ,DTOUT,DUOUT
135 N C,D,D1,D1,D2,D3,D4,I,J,L,O,X,Y
136 ;
137 S DK=DIKKTOP
138 D S2^DIBT1 Q:Y<0!$D(DIRUT) ""
139 Q +Y
140 ;
141SAVETEMP(Y) ;Save records in template Y
142 N CNT,DK,FILE,FLD,IENS,REC
143 S (CNT,FILE)=0 F S FILE=$O(^TMP("DIKKTAR",$J,FILE)) Q:'FILE D
144 . S IENS="" F S IENS=$O(^TMP("DIKKTAR",$J,FILE,IENS)) Q:IENS="" D
145 .. S REC=$P(IENS,",",$L(IENS,",")-1)
146 .. S:$D(^DIBT(+Y,1,REC))[0 CNT=CNT+1,^DIBT(+Y,1,REC)=""
147 S:CNT>0 ^DIBT(+Y,"QR")=DT_U_CNT
148 Q
149 ;
150DA(IENS,DA) ;Given IENS, write ien's and setup DA array
151 N I
152 D W("","",$L(IENS,",")-2) Q:$D(DIRUT)
153 K DA
154 F I=$L(IENS,",")-1:-1:2 S DA(I-1)=$P(IENS,",",I) W DA(I-1),!
155 S DA=$P(IENS,",") W DA
156 Q
157 ;
Note: See TracBrowser for help on using the repository browser.