MAGDLB1 ;WOIFO/LB/JSL/SAF/NST/DAC/MLH - Routine to fix failed DICOM entries ; 11 Apr 2012 1:09 PM
;;3.0;IMAGING;**11,30,54,123,118**;Mar 19, 2002;Build 4525;May 01, 2013
;; Per VHA Directive 2004-038, this routine should not be modified.
;; +---------------------------------------------------------------+
;; | 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
;
DISPLAY ;
S OUT=0
W !,"**************Processing entry**********"
W !!?2,"PATIENT: ",PAT,?50,$$PIDLABEL^MAGSPID(),": ",PID,!,"RADIOLOGY CASE #: ",CASENO ;;P123
W !?2,"Equipment: ",MOD,?50,"Model: ",MODEL
W !?2,"Date Processed: ",DATE,?50,"Problem with: ",REASON
W !?2,"Comment: ",COMNT1
W !?2,"Correcting file on Image gateway server ID: ",MACHID,!?5,FILE
S MSG="Do you want to Correct this entry? "
Q
;
NEWCASE ;
S NEWDFN=$P(MAGDY,"^"),NEWNME=$P(MAGDY,"^",2),NEWPID=$P(MAGDY,"^",3)
S NEWCAS=$P(MAGDY,"^",4),NEWPROC=$P(MAGDY,"^",5),NEWDTI=$P(MAGDY,"^",6)
S NEWMUL=$P(MAGDY,"^",7),NEWPIEN=$P(MAGDY,"^",8),PP=$P(MAGDY,"^",9)
Q
;
ASK() ;
N ANS,ASK
;
ASK1 S ASK="Y/N/D/Q"
I $G(PREV)'=$G(MAGIEN),MAGTYPE="RAD" S ASK=ASK_"/P"
W !,$G(MSG),"("_ASK_")// " R ANS:600
I '$T!(ANS["^") Q "^"
I ANS="" Q "N"
I "YNDPQyndpq"'[$E(ANS) D G ASK1
. W !,"Please respond with one of the following codes."
. W !,"Legend: Y=yes, N=no, D=delete, P=Previous entry, and Q=quit",!
S ANS=$TR(ANS,"yndpq","YNDPQ")
Q $E(ANS)
;
CHK ;remove any punctuation before doing comparison on SSN
;stop on 1st check.
N OLD,I
S OLD="" F I=1:1:$L(PID) I $E(PID,I)?1AN S OLD=OLD_$E(PID,I)
I NEWPID'=OLD D Q
. I $$ISIHS^MAGSPID() S MSG="Patient ID numbers do not match. Update? " Q ;P123
. S MSG="Social Security numbers do not match. Update? "
I NEWNME'=PAT D Q
. S MSG="Patient names do not match. Update? "
;Finally the problem is with the case number...either no longer in "C"
;xref or invalid number provided
S MSG="Radiology case number different. Update? "
Q
;
NEWDIS ;
W !?2,"****Please review the following: *****"
W !?2,"Previous name: ",PAT,!?2," New name: ",NEWNME
W !?2,"Previous ",$$PIDLABEL^MAGSPID(),": ",PID,!?2," New ",$$PIDLABEL^MAGSPID(),": ",NEWPID ;P123
W !?2,"Previous case #: ",CASENO,!?2," New case #: ",NEWCAS
I $L($G(PP)) W !?15,"Case number selected: ",PP
; Variable PP already has text message about being part of printset.
Q
;
UPDT ;
N GWLOC ; -- gateway location
N % ; ------ utility variable for FM calls
W !,"Will change the following: " D NEWDIS
W !,"Are you sure you want to correct this entry? " S %=2 D YN^DICN
I %=-1!(%=2) S OUT=1 Q
W !,"Updating the file."
S NEWDTIM=$TR(NEWDTI,"0123456789","9876543210")
S ^MAGD(2006.575,MAGIEN,"FIXD")="1^"_NEWDFN_"^"_NEWNME_"^"_NEWPID_"^"_NEWCAS_"^"_NEWDTI_"^"_NEWMUL_"^"_NEWDTIM W "."
S ^MAGD(2006.575,MAGIEN,"FIXPR")=NEWPIEN_"^"_NEWPROC W "."
;Same as ^radpt(newdfn,"DT",newdti,"P",newmul,0) & ^RAMIS(71,newpien,0)
S MACHID=$S(MACHID="":"A",1:MACHID) ; server ID
S GWLOC=$P($G(^MAGD(2006.575,MAGIEN,1)),"^",5)
I GWLOC S ^MAGD(2006.575,"AFX",GWLOC,MACHID,MAGIEN)="" W "."
E W !,"Gateway place not defined on image entry "_MAGIEN_", continuing.."
;Xref to loop & process entries; processing will be minimal.
S MAGFIX(MAGIEN)="F"
Q
;
SETDEL ;Entry to be deleted
N GWLOC ; -- gateway location
D LOGERR I ANS="^" S OUT=1 Q
S GWLOC=$P($G(^MAGD(2006.575,MAGIEN,1)),"^",5)
I GWLOC S ^MAGD(2006.575,"AFX",GWLOC,MACHID,MAGIEN)="D" W "."
E W !,"Gateway place not defined on this image entry "_MAGIEN_", continuing.."
S $P(^MAGD(2006.575,MAGIEN,0),"^",6)="1"
S ^MAGD(2006.575,MAGIEN,"FIXD")=1
S MAGFIX(MAGIEN)="D"
Q
;
LOGERR ;Need to record error
N DIR,DIRUT,DTOUT,ENTRY,I,MAGERR,MAGOUT,NOW,WHY,WHO,X,Y
W !! F I=1:1:80 W "*"
W !,"*** Will log in error log (file 2006.599). ****"
S NOW=$$NOW^XLFDT()
S DIR(0)="F^3:30"
S DIR("A")="Reason for deletion"
S DIR("A",1)="Please enter a reason for deleting."
S DIR("A",2)="For example: TEST PATIENT"
D ^DIR
I $D(DIRUT)!($D(DTOUT))!(Y="") D S ANS="^" Q
. W !,"Cannot delete if a reason is not provided."
. Q
S WHY=Y,WHO=$G(DUZ)
I WHO D
. D GETS^DIQ(200,DUZ,".01","E","MAGOUT","MAGERR")
. Q:$D(MAGERR("DIERR"))
. S WHO=$G(MAGOUT(200,DUZ_",",.01,"E"))
I WHO="" S WHO="UNKNOWN"
I '$D(^MAGD(2006.599,0)) D
. S ^MAGD(2006.599,0)="Dicom Error Log^2006.599^^"
. Q
S ENTRY=$P(^MAGD(2006.599,0),"^",3)+1
S $P(^MAGD(2006.599,0),"^",3)=ENTRY
S $P(^MAGD(2006.599,0),"^",4)=$P(^MAGD(2006.599,0),"^",4)+1
S ^MAGD(2006.599,ENTRY,0)=NOW_"^"_WHY_"^"_FILE_"^"_MODEL
S ^MAGD(2006.599,ENTRY,1)=WHO_"^"_PAT_"^"_PID_"^"_CASENO_"^"_MACHID
S ^MAGD(2006.599,"B",NOW,ENTRY)=""
Q
;
SET ;
S MAGTYPE=$P(^MAGD(2006.575,MAGIEN,"TYPE"),"^")
Q:$P($G(^MAGD(2006.575,MAGIEN,"FIXD")),"^") ; Already fixed.
; Only process Radiology images...medicine images done by other rtns.
I MAGTYPE'["RAD" Q
S DATA=^MAGD(2006.575,MAGIEN,0)
S FILE=$P(^MAGD(2006.575,MAGIEN,0),"^")
S DATA1=^MAGD(2006.575,MAGIEN,1) ; Case no. info
S DATA2=$G(^MAGD(2006.575,MAGIEN,"AMFG")) ; Modality info
S PAT=$P(DATA,"^",4),PID=$P(DATA,"^",3),REASON=$P(DATA,"^",2)
S MOD=$P(DATA2,"^"),MODEL=$P(DATA2,"^",6)
S CASENO=$P(DATA1,"^",2),MACHID=$P(DATA1,"^",4)
S Y=$P(DATA1,"^",3) X ^DD("DD") S DATE=Y
S COMNT1=$G(^MAGD(2006.575,MAGIEN,"ACSTXT")) ; 1st line comment.
S MACHID=$P(DATA1,"^",4),GWLOC=$P(DATA2,"^",9)
S ANS="" D DISPLAY S ANS=$$ASK
I ANS="Q"!(ANS["^") S (OOUT,OUT)=1 D SETPREV Q
I ANS="N" S OUT=1 D SETPREV Q
I ANS="P" D CHKPREV Q
I ANS="D" D SETDEL,SETPREV Q
Q:OUT
K MAGDY W !," Lookup by case number or patient name"
;
; Fall Through intended
LOOK ;
;D ^MAGDLB2 Q:'$D(MAGDY) Q:MAGDY'[""
D EN^MAGDRA2 Q:'$D(MAGDY) Q:MAGDY'[""
D NEWCASE,CHK,NEWDIS S ANS=$$ASK
I ANS="Q"!(ANS["^") S (OOUT,OUT)=1 D SETPREV Q
I ANS="D" D SETDEL,SETPREV Q
I ANS="P" D CHKPREV Q
I ANS="N" S OUT=1 D SETPREV Q
Q:OUT
D UPDT
I ANS="P" D CHKPREV Q
D SETMAG
Q
;
DATELOOP(START,STOP) ;Loop thru the "AD" cross reference
N MAGIEN,SUID,THEDT,FIRST,OOUT,MAGFIX,MDV
S KFIXALL=$$SECKEY^MAGDLB12
S THEDT=START-.1,(OOUT,FIRST)=0
F S THEDT=$O(^MAGD(2006.575,"AD",THEDT)) Q:'THEDT!(THEDT>STOP)!(OOUT) D
. S MAGIEN=0
. F S MAGIEN=$O(^MAGD(2006.575,"AD",THEDT,MAGIEN)) Q:'MAGIEN D
. . I '$D(^MAGD(2006.575,MAGIEN,0)) D Q
. . . K ^MAGD(2006.575,"AD",THEDT,MAGIEN)
. . . Q
. . I $P($G(^MAGD(2006.575,MAGIEN,"TYPE")),U,1)'["RAD" Q
. . ; No security key, or gateway site other than this site
. . I 'KFIXALL,$P($G(^MAGD(2006.575,MAGIEN,1)),U,5)'=$G(DUZ(2)) Q
. . I 'FIRST S PREV=MAGIEN,FIRST=1
. . D SET
. . Q
. Q
Q
;
SETPREV ;
S PREV=MAGIEN,PREVS=$G(SUID)
Q
;
SETMAG ;
S FIRST=MAGIEN,FIRSTS=$G(SUID),MAGIEN=PREV,SUID=$G(PREVS)
S PREV=FIRST,PREVS=FIRSTS
Q
;
CHKPREV ;
S OUT=1 N STATUS
I '$D(MAGFIX(PREV)) D SETMAG G SET
S STATUS=$S($G(MAGFIX(PREV))="D":"deleted",1:"corrected")
W !,"Previous entry has been "_STATUS_".",$C(7)
G SET
Q
;
NAME(ENTRY) ;SITE NAME
N NAME,MAGOUT,MAGERR
I '$G(ENTRY) Q ""
D GETS^DIQ(4,ENTRY,".01","E","MAGOUT","MAGERR")
I $D(MAGERR("DIERR")) Q ""
S NAME=$G(MAGOUT(4,ENTRY_",",.01,"E"))
Q NAME
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGDLB1 8064 printed Oct 16, 2024@18:01:19 Page 2
MAGDLB1 ;WOIFO/LB/JSL/SAF/NST/DAC/MLH - Routine to fix failed DICOM entries ; 11 Apr 2012 1:09 PM
+1 ;;3.0;IMAGING;**11,30,54,123,118**;Mar 19, 2002;Build 4525;May 01, 2013
+2 ;; Per VHA Directive 2004-038, this routine should not be modified.
+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 ;; | 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
+18 ;
DISPLAY ;
+1 SET OUT=0
+2 WRITE !,"**************Processing entry**********"
+3 ;;P123
WRITE !!?2,"PATIENT: ",PAT,?50,$$PIDLABEL^MAGSPID(),": ",PID,!,"RADIOLOGY CASE #: ",CASENO
+4 WRITE !?2,"Equipment: ",MOD,?50,"Model: ",MODEL
+5 WRITE !?2,"Date Processed: ",DATE,?50,"Problem with: ",REASON
+6 WRITE !?2,"Comment: ",COMNT1
+7 WRITE !?2,"Correcting file on Image gateway server ID: ",MACHID,!?5,FILE
+8 SET MSG="Do you want to Correct this entry? "
+9 QUIT
+10 ;
NEWCASE ;
+1 SET NEWDFN=$PIECE(MAGDY,"^")
SET NEWNME=$PIECE(MAGDY,"^",2)
SET NEWPID=$PIECE(MAGDY,"^",3)
+2 SET NEWCAS=$PIECE(MAGDY,"^",4)
SET NEWPROC=$PIECE(MAGDY,"^",5)
SET NEWDTI=$PIECE(MAGDY,"^",6)
+3 SET NEWMUL=$PIECE(MAGDY,"^",7)
SET NEWPIEN=$PIECE(MAGDY,"^",8)
SET PP=$PIECE(MAGDY,"^",9)
+4 QUIT
+5 ;
ASK() ;
+1 NEW ANS,ASK
+2 ;
ASK1 SET ASK="Y/N/D/Q"
+1 IF $GET(PREV)'=$GET(MAGIEN)
IF MAGTYPE="RAD"
SET ASK=ASK_"/P"
+2 WRITE !,$GET(MSG),"("_ASK_")// "
READ ANS:600
+3 IF '$TEST!(ANS["^")
QUIT "^"
+4 IF ANS=""
QUIT "N"
+5 IF "YNDPQyndpq"'[$EXTRACT(ANS)
Begin DoDot:1
+6 WRITE !,"Please respond with one of the following codes."
+7 WRITE !,"Legend: Y=yes, N=no, D=delete, P=Previous entry, and Q=quit",!
End DoDot:1
GOTO ASK1
+8 SET ANS=$TRANSLATE(ANS,"yndpq","YNDPQ")
+9 QUIT $EXTRACT(ANS)
+10 ;
CHK ;remove any punctuation before doing comparison on SSN
+1 ;stop on 1st check.
+2 NEW OLD,I
+3 SET OLD=""
FOR I=1:1:$LENGTH(PID)
IF $EXTRACT(PID,I)?1AN
SET OLD=OLD_$EXTRACT(PID,I)
+4 IF NEWPID'=OLD
Begin DoDot:1
+5 ;P123
IF $$ISIHS^MAGSPID()
SET MSG="Patient ID numbers do not match. Update? "
QUIT
+6 SET MSG="Social Security numbers do not match. Update? "
End DoDot:1
QUIT
+7 IF NEWNME'=PAT
Begin DoDot:1
+8 SET MSG="Patient names do not match. Update? "
End DoDot:1
QUIT
+9 ;Finally the problem is with the case number...either no longer in "C"
+10 ;xref or invalid number provided
+11 SET MSG="Radiology case number different. Update? "
+12 QUIT
+13 ;
NEWDIS ;
+1 WRITE !?2,"****Please review the following: *****"
+2 WRITE !?2,"Previous name: ",PAT,!?2," New name: ",NEWNME
+3 ;P123
WRITE !?2,"Previous ",$$PIDLABEL^MAGSPID(),": ",PID,!?2," New ",$$PIDLABEL^MAGSPID(),": ",NEWPID
+4 WRITE !?2,"Previous case #: ",CASENO,!?2," New case #: ",NEWCAS
+5 IF $LENGTH($GET(PP))
WRITE !?15,"Case number selected: ",PP
+6 ; Variable PP already has text message about being part of printset.
+7 QUIT
+8 ;
UPDT ;
+1 ; -- gateway location
NEW GWLOC
+2 ; ------ utility variable for FM calls
NEW %
+3 WRITE !,"Will change the following: "
DO NEWDIS
+4 WRITE !,"Are you sure you want to correct this entry? "
SET %=2
DO YN^DICN
+5 IF %=-1!(%=2)
SET OUT=1
QUIT
+6 WRITE !,"Updating the file."
+7 SET NEWDTIM=$TRANSLATE(NEWDTI,"0123456789","9876543210")
+8 SET ^MAGD(2006.575,MAGIEN,"FIXD")="1^"_NEWDFN_"^"_NEWNME_"^"_NEWPID_"^"_NEWCAS_"^"_NEWDTI_"^"_NEWMUL_"^"_NEWDTIM
WRITE "."
+9 SET ^MAGD(2006.575,MAGIEN,"FIXPR")=NEWPIEN_"^"_NEWPROC
WRITE "."
+10 ;Same as ^radpt(newdfn,"DT",newdti,"P",newmul,0) & ^RAMIS(71,newpien,0)
+11 ; server ID
SET MACHID=$SELECT(MACHID="":"A",1:MACHID)
+12 SET GWLOC=$PIECE($GET(^MAGD(2006.575,MAGIEN,1)),"^",5)
+13 IF GWLOC
SET ^MAGD(2006.575,"AFX",GWLOC,MACHID,MAGIEN)=""
WRITE "."
+14 IF '$TEST
WRITE !,"Gateway place not defined on image entry "_MAGIEN_", continuing.."
+15 ;Xref to loop & process entries; processing will be minimal.
+16 SET MAGFIX(MAGIEN)="F"
+17 QUIT
+18 ;
SETDEL ;Entry to be deleted
+1 ; -- gateway location
NEW GWLOC
+2 DO LOGERR
IF ANS="^"
SET OUT=1
QUIT
+3 SET GWLOC=$PIECE($GET(^MAGD(2006.575,MAGIEN,1)),"^",5)
+4 IF GWLOC
SET ^MAGD(2006.575,"AFX",GWLOC,MACHID,MAGIEN)="D"
WRITE "."
+5 IF '$TEST
WRITE !,"Gateway place not defined on this image entry "_MAGIEN_", continuing.."
+6 SET $PIECE(^MAGD(2006.575,MAGIEN,0),"^",6)="1"
+7 SET ^MAGD(2006.575,MAGIEN,"FIXD")=1
+8 SET MAGFIX(MAGIEN)="D"
+9 QUIT
+10 ;
LOGERR ;Need to record error
+1 NEW DIR,DIRUT,DTOUT,ENTRY,I,MAGERR,MAGOUT,NOW,WHY,WHO,X,Y
+2 WRITE !!
FOR I=1:1:80
WRITE "*"
+3 WRITE !,"*** Will log in error log (file 2006.599). ****"
+4 SET NOW=$$NOW^XLFDT()
+5 SET DIR(0)="F^3:30"
+6 SET DIR("A")="Reason for deletion"
+7 SET DIR("A",1)="Please enter a reason for deleting."
+8 SET DIR("A",2)="For example: TEST PATIENT"
+9 DO ^DIR
+10 IF $DATA(DIRUT)!($DATA(DTOUT))!(Y="")
Begin DoDot:1
+11 WRITE !,"Cannot delete if a reason is not provided."
+12 QUIT
End DoDot:1
SET ANS="^"
QUIT
+13 SET WHY=Y
SET WHO=$GET(DUZ)
+14 IF WHO
Begin DoDot:1
+15 DO GETS^DIQ(200,DUZ,".01","E","MAGOUT","MAGERR")
+16 if $DATA(MAGERR("DIERR"))
QUIT
+17 SET WHO=$GET(MAGOUT(200,DUZ_",",.01,"E"))
End DoDot:1
+18 IF WHO=""
SET WHO="UNKNOWN"
+19 IF '$DATA(^MAGD(2006.599,0))
Begin DoDot:1
+20 SET ^MAGD(2006.599,0)="Dicom Error Log^2006.599^^"
+21 QUIT
End DoDot:1
+22 SET ENTRY=$PIECE(^MAGD(2006.599,0),"^",3)+1
+23 SET $PIECE(^MAGD(2006.599,0),"^",3)=ENTRY
+24 SET $PIECE(^MAGD(2006.599,0),"^",4)=$PIECE(^MAGD(2006.599,0),"^",4)+1
+25 SET ^MAGD(2006.599,ENTRY,0)=NOW_"^"_WHY_"^"_FILE_"^"_MODEL
+26 SET ^MAGD(2006.599,ENTRY,1)=WHO_"^"_PAT_"^"_PID_"^"_CASENO_"^"_MACHID
+27 SET ^MAGD(2006.599,"B",NOW,ENTRY)=""
+28 QUIT
+29 ;
SET ;
+1 SET MAGTYPE=$PIECE(^MAGD(2006.575,MAGIEN,"TYPE"),"^")
+2 ; Already fixed.
if $PIECE($GET(^MAGD(2006.575,MAGIEN,"FIXD")),"^")
QUIT
+3 ; Only process Radiology images...medicine images done by other rtns.
+4 IF MAGTYPE'["RAD"
QUIT
+5 SET DATA=^MAGD(2006.575,MAGIEN,0)
+6 SET FILE=$PIECE(^MAGD(2006.575,MAGIEN,0),"^")
+7 ; Case no. info
SET DATA1=^MAGD(2006.575,MAGIEN,1)
+8 ; Modality info
SET DATA2=$GET(^MAGD(2006.575,MAGIEN,"AMFG"))
+9 SET PAT=$PIECE(DATA,"^",4)
SET PID=$PIECE(DATA,"^",3)
SET REASON=$PIECE(DATA,"^",2)
+10 SET MOD=$PIECE(DATA2,"^")
SET MODEL=$PIECE(DATA2,"^",6)
+11 SET CASENO=$PIECE(DATA1,"^",2)
SET MACHID=$PIECE(DATA1,"^",4)
+12 SET Y=$PIECE(DATA1,"^",3)
XECUTE ^DD("DD")
SET DATE=Y
+13 ; 1st line comment.
SET COMNT1=$GET(^MAGD(2006.575,MAGIEN,"ACSTXT"))
+14 SET MACHID=$PIECE(DATA1,"^",4)
SET GWLOC=$PIECE(DATA2,"^",9)
+15 SET ANS=""
DO DISPLAY
SET ANS=$$ASK
+16 IF ANS="Q"!(ANS["^")
SET (OOUT,OUT)=1
DO SETPREV
QUIT
+17 IF ANS="N"
SET OUT=1
DO SETPREV
QUIT
+18 IF ANS="P"
DO CHKPREV
QUIT
+19 IF ANS="D"
DO SETDEL
DO SETPREV
QUIT
+20 if OUT
QUIT
+21 KILL MAGDY
WRITE !," Lookup by case number or patient name"
+22 ;
+23 ; Fall Through intended
LOOK ;
+1 ;D ^MAGDLB2 Q:'$D(MAGDY) Q:MAGDY'[""
+2 DO EN^MAGDRA2
if '$DATA(MAGDY)
QUIT
if MAGDY'[""
QUIT
+3 DO NEWCASE
DO CHK
DO NEWDIS
SET ANS=$$ASK
+4 IF ANS="Q"!(ANS["^")
SET (OOUT,OUT)=1
DO SETPREV
QUIT
+5 IF ANS="D"
DO SETDEL
DO SETPREV
QUIT
+6 IF ANS="P"
DO CHKPREV
QUIT
+7 IF ANS="N"
SET OUT=1
DO SETPREV
QUIT
+8 if OUT
QUIT
+9 DO UPDT
+10 IF ANS="P"
DO CHKPREV
QUIT
+11 DO SETMAG
+12 QUIT
+13 ;
DATELOOP(START,STOP) ;Loop thru the "AD" cross reference
+1 NEW MAGIEN,SUID,THEDT,FIRST,OOUT,MAGFIX,MDV
+2 SET KFIXALL=$$SECKEY^MAGDLB12
+3 SET THEDT=START-.1
SET (OOUT,FIRST)=0
+4 FOR
SET THEDT=$ORDER(^MAGD(2006.575,"AD",THEDT))
if 'THEDT!(THEDT>STOP)!(OOUT)
QUIT
Begin DoDot:1
+5 SET MAGIEN=0
+6 FOR
SET MAGIEN=$ORDER(^MAGD(2006.575,"AD",THEDT,MAGIEN))
if 'MAGIEN
QUIT
Begin DoDot:2
+7 IF '$DATA(^MAGD(2006.575,MAGIEN,0))
Begin DoDot:3
+8 KILL ^MAGD(2006.575,"AD",THEDT,MAGIEN)
+9 QUIT
End DoDot:3
QUIT
+10 IF $PIECE($GET(^MAGD(2006.575,MAGIEN,"TYPE")),U,1)'["RAD"
QUIT
+11 ; No security key, or gateway site other than this site
+12 IF 'KFIXALL
IF $PIECE($GET(^MAGD(2006.575,MAGIEN,1)),U,5)'=$GET(DUZ(2))
QUIT
+13 IF 'FIRST
SET PREV=MAGIEN
SET FIRST=1
+14 DO SET
+15 QUIT
End DoDot:2
+16 QUIT
End DoDot:1
+17 QUIT
+18 ;
SETPREV ;
+1 SET PREV=MAGIEN
SET PREVS=$GET(SUID)
+2 QUIT
+3 ;
SETMAG ;
+1 SET FIRST=MAGIEN
SET FIRSTS=$GET(SUID)
SET MAGIEN=PREV
SET SUID=$GET(PREVS)
+2 SET PREV=FIRST
SET PREVS=FIRSTS
+3 QUIT
+4 ;
CHKPREV ;
+1 SET OUT=1
NEW STATUS
+2 IF '$DATA(MAGFIX(PREV))
DO SETMAG
GOTO SET
+3 SET STATUS=$SELECT($GET(MAGFIX(PREV))="D":"deleted",1:"corrected")
+4 WRITE !,"Previous entry has been "_STATUS_".",$CHAR(7)
+5 GOTO SET
+6 QUIT
+7 ;
NAME(ENTRY) ;SITE NAME
+1 NEW NAME,MAGOUT,MAGERR
+2 IF '$GET(ENTRY)
QUIT ""
+3 DO GETS^DIQ(4,ENTRY,".01","E","MAGOUT","MAGERR")
+4 IF $DATA(MAGERR("DIERR"))
QUIT ""
+5 SET NAME=$GET(MAGOUT(4,ENTRY_",",.01,"E"))
+6 QUIT NAME
+7 ;