MAGVUID ;WOIFO/RRB,NST,DAC,RRM - MAGV Duplicate UID Utilities and RPCs ; 24 Oct16 8:30 AM
;;3.0;IMAGING;**118,138,172,345**;Mar 19, 2002;Build 2
;; Per VA Directive 6402, 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
;
;
STUDY(RESULT,DFN,ACNUMB,SITE,INSTR,STUDYUID,DUPEFLAG) ; RPC - MAGV STUDY UID CHECK - P172/DAC - Duplicate flag added
;
N NEWUID,TYPE,UID
S TYPE="STUDY",DUPEFLAG=$G(DUPEFLAG)
;
; Check length of incoming UID and reject with fatal error message if >96 characters.
;
I $L(STUDYUID)>96 S RESULT="-1~Fatal UID > 96 Characters" Q
;
; Check IMAGING DUPLICATE UID LOG (#2005.66) to determine if the Study UID has been replaced.
; If it has return the replacement UID and quit. Otherwise, continue with UID checking.
;
S RESULT=$$UIDCHECK(STUDYUID,TYPE) ; Check for illegal UID format and characters
S UID=$$UIDLOOK^MAGVRS61(STUDYUID,DFN,ACNUMB,TYPE,STUDYUID)
I RESULT=1,+UID>0 S RESULT="3~Illegal UID Replacement~"_UID Q
I UID'=0 D Q
. I $$STUDYUIDSTAT^MAGGETUIDSTATUS(UID)="I" S RESULT=0 Q ;P345-check if the replaced UID is accessible
. S RESULT="1~LogUIDToUse~"_UID
;
I $$STUDYUIDSTAT^MAGGETUIDSTATUS(STUDYUID)="I" S RESULT=0 Q ;P345-check if the original UID is accessible
;
; Check and replace illegal Study UID
;
I $L(STUDYUID)>64 D Q RESULT ; Replace UID having Illegal Length
. S RESULT="3~Illegal UID Replacement~"
. S NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,STUDYUID,TYPE)
. S RESULT=$S(+NEWUID=-1:NEWUID,1:RESULT_NEWUID)
. Q
;
; S RESULT=$$UIDCHECK(STUDYUID,TYPE) ; Check for illegal UID format and characters
;
I RESULT=1 D Q RESULT ; Replace UID having Illegal format or characters
. S RESULT="3~Illegal UID Replacement~"
. S NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,STUDYUID,TYPE)
. S RESULT=$S(+NEWUID=-1:NEWUID,1:RESULT_NEWUID)
;
I RESULT'=0 Q
;
; Proceed with checking Study UID
;
S RESULT=$$STUDY^MAGVGUID(DFN,ACNUMB,STUDYUID) ; Check Study UID in ^MAG(2005)
;
I (RESULT=1) D Q ; FIX 10/21/206
. S NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,STUDYUID,TYPE)
. S RESULT=$S(+NEWUID=-1:NEWUID,1:RESULT_"~NewUIDToUse~"_NEWUID)
. Q
;
S RESULT=$$DUPSTUD^MAGVRS61(DFN,ACNUMB,STUDYUID) ; Check Study UID in ^MAGV(2005.62)
;
I (RESULT=1) D ; Create New Study UID if duplicate is found in #2005.62 - P172/DAC - If flag not set store duplicate
. S NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,STUDYUID,TYPE)
. S RESULT=$S(+NEWUID=-1:NEWUID,1:RESULT_"~NewUIDToUse~"_NEWUID)
. Q
;
Q
;
SERIES(RESULT,DFN,ACNUMB,SITE,INSTR,STUDYUID,SERIESUID,DUPEFLAG) ; RPC - MAGV SERIES UID CHECK
;
N NEWUID,TYPE,UID
S TYPE="SERIES",DUPEFLAG=$G(DUPEFLAG)
;
; Check length of incoming UID and reject with fatal error message if >96 characters.
;
I $L(SERIESUID)>96 S RESULT="-1~Fatal UID > 96 Characters" Q
;
; Check IMAGING DUPLICATE UID LOG (#2005.66) to determine if the Series UID has been replaced.
; If it has return the replacement UID and quit. Otherwise, continue with UID checking.
;
; S UID=$$UIDLOOK^MAGVRS61(SERIESUID,DFN,ACNUMB,TYPE,STUDYUID)
; I UID'=0 S RESULT="1~LogUIDToUse~"_UID Q
;
S RESULT=$$UIDCHECK(SERIESUID,TYPE) ; Check for illegal UID format and characters
S UID=$$UIDLOOK^MAGVRS61(SERIESUID,DFN,ACNUMB,TYPE,STUDYUID)
I RESULT=1,+UID>0 S RESULT="3~Illegal UID Replacement~"_UID Q
I UID'=0 D Q
. I $$GETSERIESUIDSTAT^MAGGETUIDSTATUS(UID)="I" S RESULT=0 Q ;P345-check if the replaced UID is accessible
. S RESULT="1~LogUIDToUse~"_UID
;
I $$GETSERIESUIDSTAT^MAGGETUIDSTATUS(SERIESUID)="I" S RESULT=0 Q ;P345-check if the original UID is accessible
; Check and replace illegal Series UID
;
I $L(SERIESUID)>64 D Q RESULT ; Replace UID having Illegal Length
. S RESULT="3~Illegal UID Replacement~"
. S NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,SERIESUID,TYPE,STUDYUID)
. S RESULT=$S(+NEWUID=-1:NEWUID,1:RESULT_NEWUID)
. Q
;
; S RESULT=$$UIDCHECK(SERIESUID,TYPE) ; Check for illegal UID format and characters
;
I RESULT=1 D Q RESULT ; Replace UID having Illegal format or characters
. S RESULT="3~Illegal UID Replacement~"
. S NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,SERIESUID,TYPE,STUDYUID)
. S RESULT=$S(+NEWUID=-1:NEWUID,1:RESULT_NEWUID)
;
I RESULT'=0 Q
;
; Proceed with checking Series UID
;
S RESULT=$$SERIES^MAGVGUID(DFN,ACNUMB,STUDYUID,SERIESUID) ; Check Series UID in ^MAG(2005) - P172/DAC - If flag not set store duplicate
;
I (RESULT=1)&('DUPEFLAG) D Q ; Create New Series UID and Quit if duplicate is found in #2005
. S NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,SERIESUID,TYPE,STUDYUID)
. S RESULT=$S(+NEWUID=-1:NEWUID,1:RESULT_"~NewUIDToUse~"_NEWUID)
. Q
;
S RESULT=$$DUPSER^MAGVRS61(DFN,ACNUMB,STUDYUID,SERIESUID) ; Check Series UID in ^MAGV(2005.63) - P172/DAC - If flag not set store duplicate
;
I (RESULT=1)&('DUPEFLAG) D ; Create New Series UID if duplicate is found in #2005.63
. S NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,SERIESUID,TYPE,STUDYUID)
. S RESULT=$S(+NEWUID=-1:NEWUID,1:RESULT_"~NewUIDToUse~"_NEWUID)
. Q
;
I (RESULT=1)&(DUPEFLAG) S RESULT=RESULT_"~NewUIDToUse~0" ; P172/DAC - If flag set do not store duplicate
;
Q
;
SOP(RESULT,DFN,ACNUMB,SITE,INSTR,STUDYUID,SERIESUID,SOPUID,DUPEFLAG) ; RPC - MAGV SOP UID CHECK
;
N NEWUID,TYPE,UID
S TYPE="SOP",DUPEFLAG=$G(DUPEFLAG)
;
; Check length of incoming UID and reject with fatal error message if >96 characters.
;
I $L(SOPUID)>96 S RESULT="-1~Fatal UID > 96 Characters" Q
;
;
; Check IMAGING DUPLICATE UID LOG (#2005.66) to determine if the Series UID has been replaced.
; If it has return the replacement UID and quit. Otherwise, continue with UID checking.
;
S UID=$$UIDLOOK^MAGVRS61(SOPUID,DFN,ACNUMB,TYPE,STUDYUID,SERIESUID)
I UID'=0 D Q
. I $$GETSOPUIDSTAT^MAGGETUIDSTATUS(UID)="I" S RESULT=0 Q ;P345-check if the replaced UID is accessible
. S RESULT="2~RERUNLog~"
;
I $$GETSOPUIDSTAT^MAGGETUIDSTATUS(SOPUID)="I" S RESULT=0 Q ;P345-check if the original UID is accessible
; Check and replace illegal SOP UID
;
I $L(SOPUID)>64 D Q RESULT ; Replace UID having Illegal Length
. S RESULT="3~Illegal UID Replacement~"
. S NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,SOPUID,TYPE,STUDYUID,SERIESUID)
. S RESULT=$S(+NEWUID=-1:NEWUID,1:RESULT_NEWUID)
. Q
;
S RESULT=$$UIDCHECK(SOPUID,TYPE) ; Check for illegal UID format and characters
;
I RESULT=1 D Q RESULT ; Replace UID having Illegal format or characters
. S RESULT="3~Illegal UID Replacement~"
. S NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,SOPUID,TYPE,STUDYUID,SERIESUID)
. S RESULT=$S(+NEWUID=-1:NEWUID,1:RESULT_NEWUID)
;
I RESULT'=0 Q
;
; Proceed with checking SOP UID
;
S RESULT=$$SOP^MAGVGUID(DFN,ACNUMB,STUDYUID,SERIESUID,SOPUID) ; Check SOP UID in ^MAG(2005)
;
I RESULT=1 D Q ; Create New SOP UID and Quit if duplicate is found in #2005
. S NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,SOPUID,TYPE,STUDYUID,SERIESUID)
. S RESULT=$S(+NEWUID=-1:NEWUID,1:RESULT_"~NewUIDToUse~"_NEWUID)
. Q
;
I RESULT=2 S RESULT=RESULT_"~RERUN" Q ; Quit with RERUN message if on file and not duplicate UID
;
S RESULT=$$DUPSOP^MAGVRS61(DFN,ACNUMB,STUDYUID,SERIESUID,SOPUID) ; Check Series UID in ^MAGV(2005.64)
;
I (RESULT=1)&('DUPEFLAG) D ; Create New SOP UID if duplicate is found in #2005.64
. S NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,SOPUID,TYPE,STUDYUID,SERIESUID)
. S RESULT=$S(+NEWUID=-1:NEWUID,1:RESULT_"~NewUIDToUse~"_NEWUID)
. Q
;
I (RESULT=1)&(DUPEFLAG) S RESULT=RESULT_"~NewUIDToUse~0" ; P172/DAC - If flag set do not store duplicate
I RESULT=2 S RESULT=RESULT_"~RERUN" ; Return RERUN message if on file and not duplicate UId
;
Q
;
UIDCHECK(UIDCHK,TYPE) ; Check UID for invalid UIDs
;
N I,X
S RESULT=0
;
; Check for Illegal Characters
;
F I=1:1:$L(UIDCHK,".") S X=$P(UIDCHK,".",I) D I RESULT'=0 Q
. I $L(X)>1,$E(X,1)=0 S RESULT=1 Q
. I X'?1.N S RESULT=1 Q
. Q
;
Q RESULT
;
NEWUID(DFN,ACNUMB,SITE,INSTR,OUID,TYPE,STUDYUID,SERIESUID) ; Utility to Generate new UID for TYPE
;
Q:SITE="" "-1~Invalid Site Number"
;
N UID
;
S STUDYUID=$G(STUDYUID),SERIESUID=$G(SERIESUID)
;
S UID=$$GENUID^MAGVUID2(ACNUMB,SITE,INSTR,TYPE) ; Generate a new UID
;
; Log duplicate UID error
;
;
D LOGDUP^MAGVRS61(OUID,.UID,ACNUMB,DFN,TYPE,STUDYUID,SERIESUID) ; Log duplicate UID and adjust new UID to be unique if already logged
;
Q UID ; Return new UID to use
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGVUID 9435 printed Nov 22, 2024@17:20:39 Page 2
MAGVUID ;WOIFO/RRB,NST,DAC,RRM - MAGV Duplicate UID Utilities and RPCs ; 24 Oct16 8:30 AM
+1 ;;3.0;IMAGING;**118,138,172,345**;Mar 19, 2002;Build 2
+2 ;; Per VA Directive 6402, 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 ;
+19 ;
STUDY(RESULT,DFN,ACNUMB,SITE,INSTR,STUDYUID,DUPEFLAG) ; RPC - MAGV STUDY UID CHECK - P172/DAC - Duplicate flag added
+1 ;
+2 NEW NEWUID,TYPE,UID
+3 SET TYPE="STUDY"
SET DUPEFLAG=$GET(DUPEFLAG)
+4 ;
+5 ; Check length of incoming UID and reject with fatal error message if >96 characters.
+6 ;
+7 IF $LENGTH(STUDYUID)>96
SET RESULT="-1~Fatal UID > 96 Characters"
QUIT
+8 ;
+9 ; Check IMAGING DUPLICATE UID LOG (#2005.66) to determine if the Study UID has been replaced.
+10 ; If it has return the replacement UID and quit. Otherwise, continue with UID checking.
+11 ;
+12 ; Check for illegal UID format and characters
SET RESULT=$$UIDCHECK(STUDYUID,TYPE)
+13 SET UID=$$UIDLOOK^MAGVRS61(STUDYUID,DFN,ACNUMB,TYPE,STUDYUID)
+14 IF RESULT=1
IF +UID>0
SET RESULT="3~Illegal UID Replacement~"_UID
QUIT
+15 IF UID'=0
Begin DoDot:1
+16 ;P345-check if the replaced UID is accessible
IF $$STUDYUIDSTAT^MAGGETUIDSTATUS(UID)="I"
SET RESULT=0
QUIT
+17 SET RESULT="1~LogUIDToUse~"_UID
End DoDot:1
QUIT
+18 ;
+19 ;P345-check if the original UID is accessible
IF $$STUDYUIDSTAT^MAGGETUIDSTATUS(STUDYUID)="I"
SET RESULT=0
QUIT
+20 ;
+21 ; Check and replace illegal Study UID
+22 ;
+23 ; Replace UID having Illegal Length
IF $LENGTH(STUDYUID)>64
Begin DoDot:1
+24 SET RESULT="3~Illegal UID Replacement~"
+25 SET NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,STUDYUID,TYPE)
+26 SET RESULT=$SELECT(+NEWUID=-1:NEWUID,1:RESULT_NEWUID)
+27 QUIT
End DoDot:1
QUIT RESULT
+28 ;
+29 ; S RESULT=$$UIDCHECK(STUDYUID,TYPE) ; Check for illegal UID format and characters
+30 ;
+31 ; Replace UID having Illegal format or characters
IF RESULT=1
Begin DoDot:1
+32 SET RESULT="3~Illegal UID Replacement~"
+33 SET NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,STUDYUID,TYPE)
+34 SET RESULT=$SELECT(+NEWUID=-1:NEWUID,1:RESULT_NEWUID)
End DoDot:1
QUIT RESULT
+35 ;
+36 IF RESULT'=0
QUIT
+37 ;
+38 ; Proceed with checking Study UID
+39 ;
+40 ; Check Study UID in ^MAG(2005)
SET RESULT=$$STUDY^MAGVGUID(DFN,ACNUMB,STUDYUID)
+41 ;
+42 ; FIX 10/21/206
IF (RESULT=1)
Begin DoDot:1
+43 SET NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,STUDYUID,TYPE)
+44 SET RESULT=$SELECT(+NEWUID=-1:NEWUID,1:RESULT_"~NewUIDToUse~"_NEWUID)
+45 QUIT
End DoDot:1
QUIT
+46 ;
+47 ; Check Study UID in ^MAGV(2005.62)
SET RESULT=$$DUPSTUD^MAGVRS61(DFN,ACNUMB,STUDYUID)
+48 ;
+49 ; Create New Study UID if duplicate is found in #2005.62 - P172/DAC - If flag not set store duplicate
IF (RESULT=1)
Begin DoDot:1
+50 SET NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,STUDYUID,TYPE)
+51 SET RESULT=$SELECT(+NEWUID=-1:NEWUID,1:RESULT_"~NewUIDToUse~"_NEWUID)
+52 QUIT
End DoDot:1
+53 ;
+54 QUIT
+55 ;
SERIES(RESULT,DFN,ACNUMB,SITE,INSTR,STUDYUID,SERIESUID,DUPEFLAG) ; RPC - MAGV SERIES UID CHECK
+1 ;
+2 NEW NEWUID,TYPE,UID
+3 SET TYPE="SERIES"
SET DUPEFLAG=$GET(DUPEFLAG)
+4 ;
+5 ; Check length of incoming UID and reject with fatal error message if >96 characters.
+6 ;
+7 IF $LENGTH(SERIESUID)>96
SET RESULT="-1~Fatal UID > 96 Characters"
QUIT
+8 ;
+9 ; Check IMAGING DUPLICATE UID LOG (#2005.66) to determine if the Series UID has been replaced.
+10 ; If it has return the replacement UID and quit. Otherwise, continue with UID checking.
+11 ;
+12 ; S UID=$$UIDLOOK^MAGVRS61(SERIESUID,DFN,ACNUMB,TYPE,STUDYUID)
+13 ; I UID'=0 S RESULT="1~LogUIDToUse~"_UID Q
+14 ;
+15 ; Check for illegal UID format and characters
SET RESULT=$$UIDCHECK(SERIESUID,TYPE)
+16 SET UID=$$UIDLOOK^MAGVRS61(SERIESUID,DFN,ACNUMB,TYPE,STUDYUID)
+17 IF RESULT=1
IF +UID>0
SET RESULT="3~Illegal UID Replacement~"_UID
QUIT
+18 IF UID'=0
Begin DoDot:1
+19 ;P345-check if the replaced UID is accessible
IF $$GETSERIESUIDSTAT^MAGGETUIDSTATUS(UID)="I"
SET RESULT=0
QUIT
+20 SET RESULT="1~LogUIDToUse~"_UID
End DoDot:1
QUIT
+21 ;
+22 ;P345-check if the original UID is accessible
IF $$GETSERIESUIDSTAT^MAGGETUIDSTATUS(SERIESUID)="I"
SET RESULT=0
QUIT
+23 ; Check and replace illegal Series UID
+24 ;
+25 ; Replace UID having Illegal Length
IF $LENGTH(SERIESUID)>64
Begin DoDot:1
+26 SET RESULT="3~Illegal UID Replacement~"
+27 SET NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,SERIESUID,TYPE,STUDYUID)
+28 SET RESULT=$SELECT(+NEWUID=-1:NEWUID,1:RESULT_NEWUID)
+29 QUIT
End DoDot:1
QUIT RESULT
+30 ;
+31 ; S RESULT=$$UIDCHECK(SERIESUID,TYPE) ; Check for illegal UID format and characters
+32 ;
+33 ; Replace UID having Illegal format or characters
IF RESULT=1
Begin DoDot:1
+34 SET RESULT="3~Illegal UID Replacement~"
+35 SET NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,SERIESUID,TYPE,STUDYUID)
+36 SET RESULT=$SELECT(+NEWUID=-1:NEWUID,1:RESULT_NEWUID)
End DoDot:1
QUIT RESULT
+37 ;
+38 IF RESULT'=0
QUIT
+39 ;
+40 ; Proceed with checking Series UID
+41 ;
+42 ; Check Series UID in ^MAG(2005) - P172/DAC - If flag not set store duplicate
SET RESULT=$$SERIES^MAGVGUID(DFN,ACNUMB,STUDYUID,SERIESUID)
+43 ;
+44 ; Create New Series UID and Quit if duplicate is found in #2005
IF (RESULT=1)&('DUPEFLAG)
Begin DoDot:1
+45 SET NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,SERIESUID,TYPE,STUDYUID)
+46 SET RESULT=$SELECT(+NEWUID=-1:NEWUID,1:RESULT_"~NewUIDToUse~"_NEWUID)
+47 QUIT
End DoDot:1
QUIT
+48 ;
+49 ; Check Series UID in ^MAGV(2005.63) - P172/DAC - If flag not set store duplicate
SET RESULT=$$DUPSER^MAGVRS61(DFN,ACNUMB,STUDYUID,SERIESUID)
+50 ;
+51 ; Create New Series UID if duplicate is found in #2005.63
IF (RESULT=1)&('DUPEFLAG)
Begin DoDot:1
+52 SET NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,SERIESUID,TYPE,STUDYUID)
+53 SET RESULT=$SELECT(+NEWUID=-1:NEWUID,1:RESULT_"~NewUIDToUse~"_NEWUID)
+54 QUIT
End DoDot:1
+55 ;
+56 ; P172/DAC - If flag set do not store duplicate
IF (RESULT=1)&(DUPEFLAG)
SET RESULT=RESULT_"~NewUIDToUse~0"
+57 ;
+58 QUIT
+59 ;
SOP(RESULT,DFN,ACNUMB,SITE,INSTR,STUDYUID,SERIESUID,SOPUID,DUPEFLAG) ; RPC - MAGV SOP UID CHECK
+1 ;
+2 NEW NEWUID,TYPE,UID
+3 SET TYPE="SOP"
SET DUPEFLAG=$GET(DUPEFLAG)
+4 ;
+5 ; Check length of incoming UID and reject with fatal error message if >96 characters.
+6 ;
+7 IF $LENGTH(SOPUID)>96
SET RESULT="-1~Fatal UID > 96 Characters"
QUIT
+8 ;
+9 ;
+10 ; Check IMAGING DUPLICATE UID LOG (#2005.66) to determine if the Series UID has been replaced.
+11 ; If it has return the replacement UID and quit. Otherwise, continue with UID checking.
+12 ;
+13 SET UID=$$UIDLOOK^MAGVRS61(SOPUID,DFN,ACNUMB,TYPE,STUDYUID,SERIESUID)
+14 IF UID'=0
Begin DoDot:1
+15 ;P345-check if the replaced UID is accessible
IF $$GETSOPUIDSTAT^MAGGETUIDSTATUS(UID)="I"
SET RESULT=0
QUIT
+16 SET RESULT="2~RERUNLog~"
End DoDot:1
QUIT
+17 ;
+18 ;P345-check if the original UID is accessible
IF $$GETSOPUIDSTAT^MAGGETUIDSTATUS(SOPUID)="I"
SET RESULT=0
QUIT
+19 ; Check and replace illegal SOP UID
+20 ;
+21 ; Replace UID having Illegal Length
IF $LENGTH(SOPUID)>64
Begin DoDot:1
+22 SET RESULT="3~Illegal UID Replacement~"
+23 SET NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,SOPUID,TYPE,STUDYUID,SERIESUID)
+24 SET RESULT=$SELECT(+NEWUID=-1:NEWUID,1:RESULT_NEWUID)
+25 QUIT
End DoDot:1
QUIT RESULT
+26 ;
+27 ; Check for illegal UID format and characters
SET RESULT=$$UIDCHECK(SOPUID,TYPE)
+28 ;
+29 ; Replace UID having Illegal format or characters
IF RESULT=1
Begin DoDot:1
+30 SET RESULT="3~Illegal UID Replacement~"
+31 SET NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,SOPUID,TYPE,STUDYUID,SERIESUID)
+32 SET RESULT=$SELECT(+NEWUID=-1:NEWUID,1:RESULT_NEWUID)
End DoDot:1
QUIT RESULT
+33 ;
+34 IF RESULT'=0
QUIT
+35 ;
+36 ; Proceed with checking SOP UID
+37 ;
+38 ; Check SOP UID in ^MAG(2005)
SET RESULT=$$SOP^MAGVGUID(DFN,ACNUMB,STUDYUID,SERIESUID,SOPUID)
+39 ;
+40 ; Create New SOP UID and Quit if duplicate is found in #2005
IF RESULT=1
Begin DoDot:1
+41 SET NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,SOPUID,TYPE,STUDYUID,SERIESUID)
+42 SET RESULT=$SELECT(+NEWUID=-1:NEWUID,1:RESULT_"~NewUIDToUse~"_NEWUID)
+43 QUIT
End DoDot:1
QUIT
+44 ;
+45 ; Quit with RERUN message if on file and not duplicate UID
IF RESULT=2
SET RESULT=RESULT_"~RERUN"
QUIT
+46 ;
+47 ; Check Series UID in ^MAGV(2005.64)
SET RESULT=$$DUPSOP^MAGVRS61(DFN,ACNUMB,STUDYUID,SERIESUID,SOPUID)
+48 ;
+49 ; Create New SOP UID if duplicate is found in #2005.64
IF (RESULT=1)&('DUPEFLAG)
Begin DoDot:1
+50 SET NEWUID=$$NEWUID(DFN,ACNUMB,SITE,INSTR,SOPUID,TYPE,STUDYUID,SERIESUID)
+51 SET RESULT=$SELECT(+NEWUID=-1:NEWUID,1:RESULT_"~NewUIDToUse~"_NEWUID)
+52 QUIT
End DoDot:1
+53 ;
+54 ; P172/DAC - If flag set do not store duplicate
IF (RESULT=1)&(DUPEFLAG)
SET RESULT=RESULT_"~NewUIDToUse~0"
+55 ; Return RERUN message if on file and not duplicate UId
IF RESULT=2
SET RESULT=RESULT_"~RERUN"
+56 ;
+57 QUIT
+58 ;
UIDCHECK(UIDCHK,TYPE) ; Check UID for invalid UIDs
+1 ;
+2 NEW I,X
+3 SET RESULT=0
+4 ;
+5 ; Check for Illegal Characters
+6 ;
+7 FOR I=1:1:$LENGTH(UIDCHK,".")
SET X=$PIECE(UIDCHK,".",I)
Begin DoDot:1
+8 IF $LENGTH(X)>1
IF $EXTRACT(X,1)=0
SET RESULT=1
QUIT
+9 IF X'?1.N
SET RESULT=1
QUIT
+10 QUIT
End DoDot:1
IF RESULT'=0
QUIT
+11 ;
+12 QUIT RESULT
+13 ;
NEWUID(DFN,ACNUMB,SITE,INSTR,OUID,TYPE,STUDYUID,SERIESUID) ; Utility to Generate new UID for TYPE
+1 ;
+2 if SITE=""
QUIT "-1~Invalid Site Number"
+3 ;
+4 NEW UID
+5 ;
+6 SET STUDYUID=$GET(STUDYUID)
SET SERIESUID=$GET(SERIESUID)
+7 ;
+8 ; Generate a new UID
SET UID=$$GENUID^MAGVUID2(ACNUMB,SITE,INSTR,TYPE)
+9 ;
+10 ; Log duplicate UID error
+11 ;
+12 ;
+13 ; Log duplicate UID and adjust new UID to be unique if already logged
DO LOGDUP^MAGVRS61(OUID,.UID,ACNUMB,DFN,TYPE,STUDYUID,SERIESUID)
+14 ;
+15 ; Return new UID to use
QUIT UID
+16 ;