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

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

initial load of WorldVistAEHR

File size: 4.6 KB
Line 
1DIE2 ;SFISC/GFT,XAK-DELETE AND ENTRY ;12:45 PM 17 Sep 2002
2 ;;22.0;VA FileMan;**4,11,95**;Mar 30, 1999
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 D F,DL Q:$D(DTOUT) G B^DIED:Y=2,A^DIED:Y,UP^DIE1:DL>1,Q^DIE1
5 ;
6F S D=$P(DQ(DQ),U,4) S:DP+1 D=DIFLD Q
7 ;
8Z S DIEZFLAG=1 D DL K DIEZFLAG S DU="" I Y=2 G @(DQ_U_DNM)
9 I Y D:$G(DE(DW,"INDEX")) SAVEVALS^@DNM G @("A^"_DNM)
10 G R^DIE9:DL>1,E^DIE9
11DL ;
12 S %=DP,X=D,Y=$P(DQ(DQ),U,4)="0;1"
13 G X:$D(DE(DQ))[0,X:DV["R"&'Y,X:$D(^DD("KEY","F",DP,D))&'Y,S:DP<0,DD:DUZ(0)="@" I DV S %=+$P(DC,U,2),X=.01
14 G DD:DP<2 I $D(DIDEL),DIDEL\1=(DP\1) G DD
15 I Y,$S($D(^VA(200,"AFOF")):1,1:$D(^DIC(3,"AFOF"))) G DD:$D(^DD(DP,0,"UP"))!DV,DAR:'$S($D(^VA(200,DUZ,"FOF",DP)):1,1:$D(^DIC(3,DUZ,"FOF",DP))),DAR:'$P(^(DP,0),U,3),DD
16 I Y,$D(^DIC(%,0,"DEL")) S X=^("DEL")
17 E G DD:'$D(^DD(%,X,8.5)) S X=^(8.5)
18 G DD:X="" F %=1:1:$L(X) G DD:DUZ(0)[$E(X,%)
19DAR W !,"'DELETE ACCESS' REQUIRED!!"
20X I $D(DB(DQ)) D N G A
21 W:'$D(DIER) $C(7),"??" W:DV["R"&'$D(DIER) " Required" W:$D(^DD("KEY","F",DP,D))&'$D(DIER) $S(DV'["R":" Required",1:"")_" Key field" G R
22DD G MD:DV S DH=0,DU=0 F S DH=$O(^DD(DP,D,"DEL",DH)) Q:DH="" I $D(^(DH,0)) X ^(0) Q:$D(DTOUT) G X:$T
23 S DH=-1,X=DQ(DQ) I Y,$E(@(DIE_"0)"))'=U S X=^(0)
24 D D G R:X I Y D FIREREC(DP) S X=DE(DQ) D DEL:$D(DIU(0)) K DE,DG,DQ,DB S DIK=DIE D ^DIK S Y=0 K:DL<2 DA Q
25S S X="",DG($P(DQ(DQ),U,4))="" D:'$G(DIEZFLAG) LOADXR^DIED
26A S Y=1 Q
27 ;
28D I $D(DB(DQ)) S X=0 Q
29 W $C(7),!?3,"SURE YOU WANT TO DELETE"
30 I Y W " THE ENTIRE " W:DV'["D"&(DV'["P")&(DV'["V") "'"_DE(DQ)_"' " W $P(X,U,1)
31 S %=0,X=0 D YN^DICN Q:%=1 S X=1 W:$X>55 !?9
32N I $D(DE(DQ))#2,'$D(DDS) W:'$D(ZTQUEUED) $C(7)," <NOTHING DELETED>"
33 Q
34 ;
35MD G X:DV["R"&($P(DC,U,5)=1) S DH=0,DU=0 F S DH=$O(^DD(+$P(DC,U,2),.01,"DEL",DH)) Q:DH="" I $D(^(DH,0)) D DDA X ^(0) D UDA G X:$T
36 S DH=-1,Y=DC>1,X=$E(DQ(DQ),8,99) D D
37 I 'X D DDA D FIREREC(+$P(DC,U,2)) S DIK=DIC D ^DIK,UDA K DE(DQ) S X=$P(@(DIK_"0)"),U,3,4),DC=$P(DC,U,1,3)_U_X,DIC=DIE S:$D(^(+X,0)) DE(DQ)=$P(^(0),U,1)
38R S Y=2 Q
39 ;
40DDA N T,X
41 S T=$T
42 F X=+$O(DA(" "),-1):-1:1 K DA(X+1) S:$D(DA(X))#2 DA(X+1)=DA(X)
43 S:$D(DA)#2 DA(1)=DA
44 S DIC=DIE_DA_","""_$P(DC,U,3)_""",",DA=$P(DC,U,4)
45 S:$D(DIETMP)#2 DIIENS=DA_","_DIIENS
46 I T
47 Q
48 ;
49UDA N T,X
50 S T=$T
51 S DA=$G(DA(1)) ;K DA(1)
52 F X=2:1:+$O(DA(" "),-1) I $D(DA(X))#2 S DA(X-1)=DA(X) K DA(X)
53 S:$D(DIETMP)#2 DIIENS=$P(DIIENS,",",2,999)
54 I T
55 Q
56QS ;
57 G ^DIEQ
58QQ ;
59 G QQ^DIEQ
60 Q
61DEL I '$S($D(^VA(200,"AFOF",DA)):1,1:$D(^DIC(3,"AFOF",DA))) Q
62 S DA(1)="",DIFOF=DA
63 F P=0:0 S DA(1)=$S($D(^VA(200,"AFOF")):$O(^VA(200,"AFOF",DA,DA(1))),1:$O(^DIC(3,"AFOF",DA,DA(1)))) Q:'DA(1) I $S($D(^VA(200,DA(1),"FOF",DA)):1,1:$D(^DIC(3,DA(1),"FOF",DA))) S DIK=$S($D(^VA(200)):"^VA(200,",1:"^DIC(3,")_DA(1)_",""FOF""," D ^DIK
64 K DA S DA=DIFOF K DIFOF
65 Q
66V ;
67 G ^DIE3
68 ;
69FIREREC(DIFILE) ;Fire record-level xrefs accumulated in ^TMP for file
70 ;or subfile DIFILE and all its subfiles
71 G:$G(DIEZFLAG) FIRERECZ
72 Q:$D(DIETMP)[0
73 Q:$D(@DIETMP@("R"))<2
74 ;
75 ;If we're at top level, fire all accumulated record-level xrefs
76 N X,Y
77 I '$G(^DD(DIFILE,0,"UP")) D FIREREC^DIE1 Q
78 ;
79 ;Save the DA array and DIIENS
80 N DASV,DIIENSSV
81 M DASV=DA S DIIENSSV=DIIENS
82 ;
83 ;Get list of subfiles under DIFILE
84 N DA,DIE,DIFLIST,DIIENS,DIPAT,DP
85 D SUBFILES^DIKCU(DIFILE,.DIFLIST)
86 S DIFLIST(DIFILE)=""
87 S DIPAT=".E1"""_DIIENSSV_""""
88 ;
89 ;Fire record-level cross references DIFILE and its subfiles
90 S DP=0 F S DP=$O(DIFLIST(DP)) Q:'DP D
91 . Q:'$D(@DIETMP@("R",DP))
92 . S DIIENS=" " F S DIIENS=$O(@DIETMP@("R",DP,DIIENS)) Q:DIIENS="" D
93 .. Q:DIIENS'?@DIPAT
94 .. S DIE=@DIETMP@("R",DP,DIIENS)
95 .. D DA^DILF(DIIENS,.DA)
96 .. D FIRE^DIKC(DP,.DA,"KS",$NA(@DIETMP@("R")),"F")
97 .. K @DIETMP@("R",DP,DIIENS),@DIETMP@("V",DP,DIIENS)
98 . K:'$D(@DIETMP@("V",DP)) @DIETMP@("R",DP)
99 Q
100 ;
101FIRERECZ ;Come here from FIREREC above, for compiled templates
102 Q:'$D(DIEZRXR)
103 ;
104 ;If we're at top level, fire all accumulated record-level xrefs
105 N X,Y
106 I '$G(^DD(DIFILE,0,"UP")) D FIREREC^DIE17 Q
107 ;
108 ;Save the DA array and DIIENS
109 N DASV,DIIENSSV
110 M DASV=DA S DIIENSSV=DIIENS
111 ;
112 ;Get list of subfiles under DIFILE
113 N DA,DIE,DIEZXR,DIFLIST,DIIENS,DIPAT,DP
114 D SUBFILES^DIKCU(DIFILE,.DIFLIST)
115 S DIFLIST(DIFILE)=""
116 S DIPAT=".E1"""_DIIENSSV_""""
117 ;
118 ;Fire record-level cross references DIFILE and its subfiles
119 S DP=0 F S DP=$O(DIFLIST(DP)) Q:'DP D
120 . Q:'$D(DIEZRXR(DP))
121 . S DIIENS=" " F S DIIENS=$O(DIEZRXR(DP,DIIENS)) Q:DIIENS="" D
122 .. Q:DIIENS'?@DIPAT
123 .. S DIE=DIEZRXR(DP,DIIENS)
124 .. D DA^DILF(DIIENS,.DA)
125 .. S DIEZXR=0 F S DIEZXR=$O(DIEZRXR(DP,DIEZXR)) Q:DIEZXR'=+DIEZXR D
126 ... D:$D(DIEZAR(DP,DIEZXR))#2 @DIEZAR(DP,DIEZXR)
127 .. K DIEZRXR(DP,DIIENS),@DIETMP@("V",DP,DIIENS)
128 . K:'$D(@DIETMP@("V",DP)) DIEZRXR(DP)
129 Q
Note: See TracBrowser for help on using the repository browser.