MAGDLB7 ;WOIFO/LB - Utilities for file 2006.575 ; [ 06/20/2001 08:56 ]
;;3.0;IMAGING;;Mar 01, 2002
;; +---------------------------------------------------------------+
;; | Property of the US Government. |
;; | No permission to copy or redistribute this software is given. |
;; | Use of unreleased versions of this software requires the user |
;; | to execute a written test agreement with the VistA Imaging |
;; | Development Office of the Department of Veterans Affairs, |
;; | telephone (301) 734-0100. |
;; | |
;; | The Food and Drug Administration classifies this software as |
;; | a medical device. As such, it may not be changed in any way. |
;; | Modifications to this software may result in an adulterated |
;; | medical device under 21CFR820, the use of which is considered |
;; | to be a violation of US Federal Statutes. |
;; +---------------------------------------------------------------+
;;
Q
REINDXF ;Reindex field 9 - Unique Study Identifications
N DIK
S DIK="^MAGD(2006.575,",DIK(1)="9"
D ENALL^DIK
Q
EN ;
N DIR,DDAY,X,Y,DOUT,DROUT,NOWDAY
W !,"Will re-index field 9, Unique Study Id."
D REINDXF
I '$D(^MAGD(2006.575,"F")) W !,"Nothing to process" Q
D NOW^%DTC S NOWDAY=X
W !,"Entries will be delete up to the date you specify."
EN1 ;restart point
S DIR(0)="DA",DIR("A")="Last date to keep."
S DIR("?")="Enter a date."
D ^DIR I 'Y!(Y="^") W !,"No date entered. Quitting." Q
S DDAY=Y I NOWDAY=DDAY W !,"Can not be today." G EN1
D PURGE
Q
PURGE ;
N DATEPROC,IEN,NIEN,ITEM,SUID
S IEN=0,SUID="" F S SUID=$O(^MAGD(2006.575,"F",SUID)) W !,SUID Q:SUID="" D
. F S IEN=$O(^MAGD(2006.575,"F",SUID,IEN)) W !,IEN Q:'IEN D
. . I '$D(^MAGD(2006.575,IEN,0)) D Q
. . . K ^MAGD(2006.575,"F",SUID,IEN) ;Tidy up.
. . S DATEPROC=$P(^MAGD(2006.575,IEN,1),"^",3)
. . I DATEPROC>DDAY Q
. . I $D(^MAGD(2006.575,IEN,"RLATE")) D
. . . ;start purging the related entries 1st before the parent entry
. . . S NIEN=0 F S NIEN=$O(^MAGD(2006.575,IEN,"RLATE",NIEN)) Q:'NIEN D
. . . . Q:'$D(^MAGD(2006.575,IEN,"RLATE",NIEN,0))
. . . . S ITEM=$P(^MAGD(2006.575,IEN,"RLATE",NIEN,0),"^") Q:'ITEM
. . . . D REMOVE^MAGDLB5(ITEM) W "."
. . D REMOVE^MAGDLB5(IEN) W "."
W !,"Finished."
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGDLB7 2438 printed Apr 09, 2024@21:06:01 Page 2
MAGDLB7 ;WOIFO/LB - Utilities for file 2006.575 ; [ 06/20/2001 08:56 ]
+1 ;;3.0;IMAGING;;Mar 01, 2002
+2 ;; +---------------------------------------------------------------+
+3 ;; | Property of the US Government. |
+4 ;; | No permission to copy or redistribute this software is given. |
+5 ;; | Use of unreleased versions of this software requires the user |
+6 ;; | to execute a written test agreement with the VistA Imaging |
+7 ;; | Development Office of the Department of Veterans Affairs, |
+8 ;; | telephone (301) 734-0100. |
+9 ;; | |
+10 ;; | The Food and Drug Administration classifies this software as |
+11 ;; | a medical device. As such, it may not be changed in any way. |
+12 ;; | Modifications to this software may result in an adulterated |
+13 ;; | medical device under 21CFR820, the use of which is considered |
+14 ;; | to be a violation of US Federal Statutes. |
+15 ;; +---------------------------------------------------------------+
+16 ;;
+17 QUIT
REINDXF ;Reindex field 9 - Unique Study Identifications
+1 NEW DIK
+2 SET DIK="^MAGD(2006.575,"
SET DIK(1)="9"
+3 DO ENALL^DIK
+4 QUIT
EN ;
+1 NEW DIR,DDAY,X,Y,DOUT,DROUT,NOWDAY
+2 WRITE !,"Will re-index field 9, Unique Study Id."
+3 DO REINDXF
+4 IF '$DATA(^MAGD(2006.575,"F"))
WRITE !,"Nothing to process"
QUIT
+5 DO NOW^%DTC
SET NOWDAY=X
+6 WRITE !,"Entries will be delete up to the date you specify."
EN1 ;restart point
+1 SET DIR(0)="DA"
SET DIR("A")="Last date to keep."
+2 SET DIR("?")="Enter a date."
+3 DO ^DIR
IF 'Y!(Y="^")
WRITE !,"No date entered. Quitting."
QUIT
+4 SET DDAY=Y
IF NOWDAY=DDAY
WRITE !,"Can not be today."
GOTO EN1
+5 DO PURGE
+6 QUIT
PURGE ;
+1 NEW DATEPROC,IEN,NIEN,ITEM,SUID
+2 SET IEN=0
SET SUID=""
FOR
SET SUID=$ORDER(^MAGD(2006.575,"F",SUID))
WRITE !,SUID
if SUID=""
QUIT
Begin DoDot:1
+3 FOR
SET IEN=$ORDER(^MAGD(2006.575,"F",SUID,IEN))
WRITE !,IEN
if 'IEN
QUIT
Begin DoDot:2
+4 IF '$DATA(^MAGD(2006.575,IEN,0))
Begin DoDot:3
+5 ;Tidy up.
KILL ^MAGD(2006.575,"F",SUID,IEN)
End DoDot:3
QUIT
+6 SET DATEPROC=$PIECE(^MAGD(2006.575,IEN,1),"^",3)
+7 IF DATEPROC>DDAY
QUIT
+8 IF $DATA(^MAGD(2006.575,IEN,"RLATE"))
Begin DoDot:3
+9 ;start purging the related entries 1st before the parent entry
+10 SET NIEN=0
FOR
SET NIEN=$ORDER(^MAGD(2006.575,IEN,"RLATE",NIEN))
if 'NIEN
QUIT
Begin DoDot:4
+11 if '$DATA(^MAGD(2006.575,IEN,"RLATE",NIEN,0))
QUIT
+12 SET ITEM=$PIECE(^MAGD(2006.575,IEN,"RLATE",NIEN,0),"^")
if 'ITEM
QUIT
+13 DO REMOVE^MAGDLB5(ITEM)
WRITE "."
End DoDot:4
End DoDot:3
+14 DO REMOVE^MAGDLB5(IEN)
WRITE "."
End DoDot:2
End DoDot:1
+15 WRITE !,"Finished."
+16 QUIT