source: WorldVistAEHR/trunk/r/IMAGING-MAG-ZMAG/MAGGTID.m@ 1096

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

revised back to 6/30/08 version

File size: 7.8 KB
Line 
1MAGGTID ;WOIFO/SRR/RED/SAF/GEK - Deletion of Images and Pointers ; [ 06/20/2001 08:56 ]
2 ;;3.0;IMAGING;**8**;Sep 15, 2004
3 ;; +---------------------------------------------------------------+
4 ;; | Property of the US Government. |
5 ;; | No permission to copy or redistribute this software is given. |
6 ;; | Use of unreleased versions of this software requires the user |
7 ;; | to execute a written test agreement with the VistA Imaging |
8 ;; | Development Office of the Department of Veterans Affairs, |
9 ;; | telephone (301) 734-0100. |
10 ;; | |
11 ;; | The Food and Drug Administration classifies this software as |
12 ;; | a medical device. As such, it may not be changed in any way. |
13 ;; | Modifications to this software may result in an adulterated |
14 ;; | medical device under 21CFR820, the use of which is considered |
15 ;; | to be a violation of US Federal Statutes. |
16 ;; +---------------------------------------------------------------+
17 ;;
18 Q
19 ;
20IMAGEDEL(MAGGRY,MAGIEN,MAGGRPDF,REASON) ;RPC [MAGG IMAGE DELETE]
21 ; Call to Delete Image entry
22 ; SEB 6/6/2002 - added MAGGRPDF - group delete flag = 1 if group delete allowed
23 ; from Image file ^MAG(2005
24 N Y,RY
25 ; 1 in 3rd piece means : DELETE the Image File Also.
26 S MAGGRPDF=+$G(MAGGRPDF),REASON=$G(REASON)
27 L +^MAG(2005,MAGIEN):4
28 E S MAGGRY(0)="Image ID# "_MAGIEN_" is Locked. Delete is Canceled" Q
29 D DELETE(.MAGGRY,MAGIEN,1,MAGGRPDF,REASON)
30 L -^MAG(2005,MAGIEN)
31 Q
32DELETE(RY,MAGIEN,DF,GRPDF,REASON) ;RPC [MAGQ DIK] Entry point for silent call
33 ;RY=Return Array RY(0)="1^SUCCESS"
34 ; RY(0)="0^reason for failure"
35 ; ;NOT RETURNING LIST AT THIS TIME
36 ; ( RY(1)..RY(n)= IEN's of deleted images.)
37 ;MAGIEN=Image entry number to be deleted
38 ; if MAGIEN has a 2nd piece = 1 then we force delete, don't test
39 ; for MAG DELETE KEY
40 ;DF=Delete file flag - 1=delete the Image file
41 ; - 0=don't delete the image file
42 ;
43 S REASON=$G(REASON) I REASON="" S REASON="Unknown reason"
44 S RY(0)="0^Image Delete Failed, reason unknown."
45 S:'$D(MAGSYS) MAGSYS=^%ZOSF("VOL")
46 N MAGERR,SYSDEL,Z
47 S SYSDEL=+$P(MAGIEN,U,2)
48 ; Check the business rules for deleting an image
49 D DELETE^MAGSIMBR(.RY,MAGIEN,SYSDEL) I +RY(0)=0 Q
50 S MAGIEN=+MAGIEN
51 ; a couple tests of privilage and valid IEN
52 I '$D(^MAG(2005,MAGIEN,0)) D Q
53 . S RY(0)="0^Image entry doesn't exist in image file"
54 I +$O(^MAG(2005,MAGIEN,1,0)),+$G(GRPDF)=0 D Q
55 . S RY(0)="0^Deleting a Group is not allowed."
56 I +$O(^MAG(2005,MAGIEN,1,0)),+$G(GRPDF)'=0 D Q
57 . N MAGGRP S MAGGRP=MAGIEN N MAGIEN,MAGX,MAGOK,MAGFAIL
58 . S MAGX=0,MAGOK=0,MAGFAIL=0
59 . F S MAGX=$O(^MAG(2005,MAGGRP,1,MAGX)) Q:'MAGX D
60 . . S MAGIEN=$P($G(^MAG(2005,MAGGRP,1,MAGX,0)),"^") D DEL1IMG
61 . . I +RY(0) S Z=+$O(RY(""),-1),RY(Z)=RY(Z)_"^"_RY(0),MAGOK=MAGOK+1
62 . . E S Z=+$O(RY(""),-1)+1,RY(Z)=MAGIEN_"^"_RY(0),MAGFAIL=MAGFAIL+1
63 . . Q
64 . I +MAGFAIL=0 S RY(0)="1^Deletion of Group #"_MAGGRP_" was successful.^"_MAGOK_"^0"
65 . E S RY(0)="0^Error deleting child image(s). Group Not Deleted.^"_MAGOK_"^"_MAGFAIL
66 . Q
67 ;
68 ; Ok lets start
69 ; lets delete the parent pointers first.
70DEL1IMG ;
71 N DELMSG,Z
72 D DELPAR^MAGSDEL2
73 I $G(MAGERR) S RY(0)="0^Error: Deleting Specialty Pointers. Image Not Deleted. "_DELMSG Q
74 ;
75 ; Now delete image record & xref's
76 ; if this Image is member of group DELGRP will delete those pointers
77 ; and delete the Group, if this is only image in it.
78 S MAGDFN=$P($G(^MAG(2005,MAGIEN,0)),"^",7) ; Moved here from below. DELGRP needs MAGDFN now.
79 D DELGRP
80 I $G(MAGERR) S RY(0)="0^Error deleting Group Pointers." Q
81 ;
82 ; write the deleted by, delete reason, and delete date to the file.
83 D SETDEL(MAGIEN,REASON)
84 ;
85 ; save the Image record to the archive before we delete it.
86 D ARCHIVE(MAGIEN)
87 ;
88 ; Now let's set the Queue to delete the Image File, if Flag is set
89 I $G(DF) D DELFILE
90 ;
91 ; we're having "APPXDT" crossref left around, lets delete it first.
92 S X=MAGDFN,DA=MAGIEN D KILPPXD^MAGUXRF
93 ;
94 ; now lets delete the image.
95 K DIK,DA,DA(1),DA(2),DIC,DR,DIE,DIR S DIK="^MAG(2005,",DA=MAGIEN
96 D ^DIK
97 S Z=+$O(RY(""),-1)+1,RY(Z)=MAGIEN
98 ; we were having problems with "AC" so lets check to make sure.
99 I $D(^MAG(2005,"AC",MAGDFN,MAGIEN)) K ^MAG(2005,"AC",MAGDFN,MAGIEN)
100 ; log it.
101 D ENTRY^MAGLOG("DELETE",$G(DUZ),$G(MAGIEN),"PARENT:"_$G(MAGSTORE),$G(MAGDFN),1)
102 S X="DEL^"_$G(MAGDFN)_"^"_$G(MAGIEN)
103 D ACTION^MAGGTAU(X,"1")
104 S RY(0)="1^Deletion of Image was Successful."
105 Q
106DELGRP ;del grp ptrs and check to see if this is the last image in the group
107 N MAGGRP,MAGX,MAGQUIT,MAGIFNS,Z
108 S MAGGRP=$P($G(^MAG(2005,MAGIEN,0)),"^",10)
109 Q:'$G(MAGGRP)
110 K DIK,DA,DA(1),DA(2),DIC,DR,DIE,DIR
111 S MAGX=0,MAGQUIT=0
112 F S MAGX=$O(^MAG(2005,MAGGRP,1,MAGX)) Q:'MAGX D Q:MAGQUIT
113 . I +^MAG(2005,MAGGRP,1,MAGX,0)=MAGIEN D
114 . . S DIK="^MAG(2005,MAGGRP,1,",DA(1)=MAGGRP,DA=MAGX D ^DIK S MAGQUIT=1
115 . . ;added DA(1) needed for xref deletion of dicom series
116 . I $O(^MAG(2005,MAGGRP,1,0))="" D
117 . . I $P($G(^MAG(2005,MAGGRP,2)),"^",6) D
118 . . . ;report is on group - need to delete it
119 . . . S MAGIFNS=MAGIEN,MAGIEN=MAGGRP
120 . . . D DELPAR^MAGSDEL2
121 . . . S MAGIEN=MAGIFNS
122 . . I '$D(MAGERR) D
123 . . . D SETDEL(MAGGRP,REASON),ARCHIVE(MAGGRP) S DIK="^MAG(2005,",DA=MAGGRP D ^DIK
124 . . . ; Log the Deletion of The Group Header to ^MAG(2006.95, and ^MAG(2006.82
125 . . . D ENTRY^MAGLOG("DELETE",$G(DUZ),$G(MAGGRP),"PARENT:"_$G(MAGSTORE),$G(MAGDFN),1,"Group Header deleted")
126 . . . S X="DEL^"_$G(MAGDFN)_"^"_$G(MAGGRP)
127 . . . D ACTION^MAGGTAU(X,"1")
128 . . . S Z=+$O(RY(""),-1)+1,RY(Z)=MAGGRP_"^1^Deletion of Group was Successful."
129 . . . Q
130 . . Q
131 . Q
132 Q
133SETDEL(MAGIEN,REASON) ; set deletion fields
134 N DA,DR,DIE,%H,X
135 S %H=$H D YMD^%DTC
136 ; gek - changed 3 slash to 4 slash. to stop FM question marks. ??
137 S DR="30////"_DUZ_";30.1////"_X_";30.2////"_REASON
138 S DIE="2005",DA=MAGIEN D ^DIE
139 Q
140 ;
141ARCHIVE(MAGARCIE) ;save image data before deletion
142 N MAGCNT,MAGLAST
143 S MAGCNT=$P(^MAG(2005.1,0),U,4)+1
144 S %X="^MAG(2005,"_MAGARCIE_",",%Y="^MAG(2005.1,"_MAGARCIE_","
145 D %XY^%RCR
146 ; GEK 9/29/00 Fix the 3rd piece to be last ien in file.
147 S MAGLAST=$O(^MAG(2005.1,"A"),-1)
148 S $P(^MAG(2005.1,0),U,4)=MAGCNT
149 I '($P(^MAG(2005.1,0),U,3)=MAGLAST) S $P(^MAG(2005.1,0),U,3)=MAGLAST
150 S DA=MAGARCIE
151 S DIK="^MAG(2005.1," D IX1^DIK
152 Q
153DELFILE ;Delete image file on server if exists
154 ;gek 3/21/2003 Changed to stop using FullRes Path for Abs,Big
155 ; and only Delete .TXT and Alternates if Full is being deleted.
156 N X0,X1,X2,ALTEXT,ALTPATH,MAGXX,XBIG
157 N MAGPLC ; DBI - SEB 9/20/2002
158 ; MAGIEN IS ASSUMED TO BE DEFINED.
159 ; MAGXX - This is IEN in ^MAG(2005, MAGFILEB Expects this to be defined.
160 ; MAGPLC - "Place" of Full Res Image.
161 ; ALTEXT - Extension of the Alternate image file.
162 ; ALTPATH - Full path of Alternate image file.
163 S X0=^MAG(2005,MAGIEN,0)
164 ;delete Full Res if one exists on Magnetic
165 I $P(X0,U,3) D
166 . S MAGXX=MAGIEN
167 . S MAGPLC=$$DA2PLC^MAGBAPIP(MAGIEN,"F")
168 . D VSTNOCP^MAGFILEB
169 . S X=$$DELETE^MAGBAPI(MAGFILE2,MAGPLC)
170 . ;Delete any other ALTernate files. ( TXT)
171 . ;gek 3/31/03 Since ALT files are (for now) always on same server as Full
172 . ; We only attempt to delete them here (If we have a path to FullRes on Magnetic)
173 . S X2=0
174 . F S X2=$O(^MAG(2006.1,MAGPLC,2,X2)) Q:'X2 D
175 . . S ALTEXT=^MAG(2006.1,MAGPLC,2,X2,0)
176 . . S ALTPATH=$P(MAGFILE2,".")_"."_ALTEXT
177 . . S X=$$DELETE^MAGBAPI(ALTPATH,MAGPLC)
178 . Q
179 ;
180 ;delete image abstract if one exists on Magnetic
181 I $P(X0,U,4) D
182 . S MAGXX=MAGIEN
183 . D ABSNOCP^MAGFILEB
184 . S X=$$DELETE^MAGBAPI(MAGFILE2,$$DA2PLC^MAGBAPIP(MAGIEN,"A")) ; DBI - SEB 9/20/2002
185 ;
186 ;delete the big file if one exists on Magnetic
187 S XBIG=$G(^MAG(2005,MAGIEN,"FBIG"))
188 I $P(XBIG,U) D
189 . S MAGXX=MAGIEN
190 . D BIGNOCP^MAGFILEB
191 . S X=$$DELETE^MAGBAPI(MAGFILE2,$$DA2PLC^MAGBAPIP(MAGIEN,"B")) ; DBI - SEB 9/20/2002
192 Q
Note: See TracBrowser for help on using the repository browser.