MAGNUID2 ;WOIFO/NST - Checks for duplicates UIDs ; 11 Oct 2010 3:42 AM
 ;;3.0;IMAGING;**106**;Mar 19, 2002;Build 2002;Feb 28, 2011
 ;; 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
 ;
 ;*****  Check for duplicate DICOM UIDs
 ;       in IMAGE file (#2005)
 ;       
 ; RPC: N/A
 ; 
 ; Input Parameters
 ; ================
 ;   MAGTYPE = Type UID - "STUDY", "SERIES", "SOP"
 ;   UID     = DICOM UID
 ;
 ; Return Values
 ; =============
 ; If no duplicate UID found returns 0
 ; If duplicate found returns 1
 ;                              
ISDUP(MAGTYPE,UID) ;
 I UID="" Q 0
 I MAGTYPE="STUDY" Q:'$D(^MAG(2005,"P",UID)) 0 Q 1
 I MAGTYPE="SERIES" Q:'$D(^MAG(2005,"SERIESUID",UID)) 0 Q 1
 I MAGTYPE="SOP" Q:'$D(^MAG(2005,"P",UID)) 0 Q 1
 Q 0  ; nothing to check
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGNUID2   1734     printed  Sep 23, 2025@19:43:48                                                                                                                                                                                                    Page 2
MAGNUID2  ;WOIFO/NST - Checks for duplicates UIDs ; 11 Oct 2010 3:42 AM
 +1       ;;3.0;IMAGING;**106**;Mar 19, 2002;Build 2002;Feb 28, 2011
 +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      ;
 +19      ;*****  Check for duplicate DICOM UIDs
 +20      ;       in IMAGE file (#2005)
 +21      ;       
 +22      ; RPC: N/A
 +23      ; 
 +24      ; Input Parameters
 +25      ; ================
 +26      ;   MAGTYPE = Type UID - "STUDY", "SERIES", "SOP"
 +27      ;   UID     = DICOM UID
 +28      ;
 +29      ; Return Values
 +30      ; =============
 +31      ; If no duplicate UID found returns 0
 +32      ; If duplicate found returns 1
 +33      ;                              
ISDUP(MAGTYPE,UID) ;
 +1        IF UID=""
               QUIT 0
 +2        IF MAGTYPE="STUDY"
               if '$DATA(^MAG(2005,"P",UID))
                   QUIT 0
               QUIT 1
 +3        IF MAGTYPE="SERIES"
               if '$DATA(^MAG(2005,"SERIESUID",UID))
                   QUIT 0
               QUIT 1
 +4        IF MAGTYPE="SOP"
               if '$DATA(^MAG(2005,"P",UID))
                   QUIT 0
               QUIT 1
 +5       ; nothing to check
           QUIT 0