MAGVUID2 ;WOIFO/NST - MAGV Generate UID ; 26 Jun 2013 5:09 PM
;;3.0;IMAGING;**138**;Mar 19, 2002;Build 5380;Sep 03, 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
;
;***** Generate a new UID that is not unique
;
; RPC:MAGV GENERATE UID
;
; Input Parameters
; ================
;
; MAGPARAM("ACCESSION NUMBER")
; MAGPARAM("SITE")
; MAGPARAM("INSTRUMENT")
; MAGPARAM("TYPE") = "STUDY" or "SERIES" or "SOP"
;
; Return Values
; =============
; if error MAGRY = Failure status ^Error message^
; if success MAGRY = Success status ^^New UID
;
GENNWUID(MAGRY,MAGPARAM) ; RPC [MAGV GENERATE UID]
N SSEP,UID
;
S ACNUMB=$G(MAGPARAM("ACCESSION NUMBER"))
S SITE=$G(MAGPARAM("SITE"))
S INSTR=$G(MAGPARAM("INSTRUMENT"))
S TYPE=$G(MAGPARAM("TYPE"))
;
S SSEP=$$STATSEP^MAGVRS41
;
; Verify input parameters
I ACNUMB="" S MAGRY="-1"_SSEP_"Invalid ACCESSION NUMBER parameter" Q
I SITE="" S MAGRY="-2"_SSEP_"Invalid SITE parameter" Q
I INSTR="" S MAGRY="-3"_SSEP_"Invalid INSTRUMENT parameter" Q
I (TYPE'="STUDY"),(TYPE'="SERIES"),(TYPE'="SOP") S MAGRY="-4"_SSEP_"Invalid TYPE parameter" Q
;
S UID=$$GENUID(ACNUMB,SITE,INSTR,TYPE) ; Generate a new UID
; Check for errors
I $P(UID,"~")<0 S MAGRY="-5"_SSEP_$P(UID,"~",2) Q
I UID="" S MAGRY="-6"_SSEP_"Unexpected UID generation error" Q
;
S MAGRY="0"_SSEP_UID
Q
;
GENUID(ACNUMB,SITE,INSTR,TYPE) ; Utility to Generate new UID for TYPE
; ACNUMB -- Accession Number
; SITE -- Site
; INSTR -- Instrument
; TYPE -- "STUDY" or "SERIES" or "SOP"
;
; Remove alpha characters from SITE/STATION number
;
N I,ID,STAMP,UID,UINST,PGM
;
S SITE=$E(SITE,1,3)
;
S (UID,UINST)=""
;
S ID=$S($E($P(ACNUMB,"-"),1)'?1N:$TR($H,",","")_$P(ACNUMB,"-",2),1:$TR(ACNUMB,"-",""))
F I=1:1:$L(INSTR) S UINST=UINST+$A($E(INSTR,I))
S SITE=SITE_"."_UINST
S STAMP=$$NOW^XLFDT
S STAMP=$TR($TR(STAMP,".","")," ","")
S ID=+ID_+STAMP
S PGM=TYPE_"^MAGVUID1(.UID,SITE,ID)"
D @PGM
Q UID
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGVUID2 2985 printed Nov 22, 2024@17:20:41 Page 2
MAGVUID2 ;WOIFO/NST - MAGV Generate UID ; 26 Jun 2013 5:09 PM
+1 ;;3.0;IMAGING;**138**;Mar 19, 2002;Build 5380;Sep 03, 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 ;
+19 ;***** Generate a new UID that is not unique
+20 ;
+21 ; RPC:MAGV GENERATE UID
+22 ;
+23 ; Input Parameters
+24 ; ================
+25 ;
+26 ; MAGPARAM("ACCESSION NUMBER")
+27 ; MAGPARAM("SITE")
+28 ; MAGPARAM("INSTRUMENT")
+29 ; MAGPARAM("TYPE") = "STUDY" or "SERIES" or "SOP"
+30 ;
+31 ; Return Values
+32 ; =============
+33 ; if error MAGRY = Failure status ^Error message^
+34 ; if success MAGRY = Success status ^^New UID
+35 ;
GENNWUID(MAGRY,MAGPARAM) ; RPC [MAGV GENERATE UID]
+1 NEW SSEP,UID
+2 ;
+3 SET ACNUMB=$GET(MAGPARAM("ACCESSION NUMBER"))
+4 SET SITE=$GET(MAGPARAM("SITE"))
+5 SET INSTR=$GET(MAGPARAM("INSTRUMENT"))
+6 SET TYPE=$GET(MAGPARAM("TYPE"))
+7 ;
+8 SET SSEP=$$STATSEP^MAGVRS41
+9 ;
+10 ; Verify input parameters
+11 IF ACNUMB=""
SET MAGRY="-1"_SSEP_"Invalid ACCESSION NUMBER parameter"
QUIT
+12 IF SITE=""
SET MAGRY="-2"_SSEP_"Invalid SITE parameter"
QUIT
+13 IF INSTR=""
SET MAGRY="-3"_SSEP_"Invalid INSTRUMENT parameter"
QUIT
+14 IF (TYPE'="STUDY")
IF (TYPE'="SERIES")
IF (TYPE'="SOP")
SET MAGRY="-4"_SSEP_"Invalid TYPE parameter"
QUIT
+15 ;
+16 ; Generate a new UID
SET UID=$$GENUID(ACNUMB,SITE,INSTR,TYPE)
+17 ; Check for errors
+18 IF $PIECE(UID,"~")<0
SET MAGRY="-5"_SSEP_$PIECE(UID,"~",2)
QUIT
+19 IF UID=""
SET MAGRY="-6"_SSEP_"Unexpected UID generation error"
QUIT
+20 ;
+21 SET MAGRY="0"_SSEP_UID
+22 QUIT
+23 ;
GENUID(ACNUMB,SITE,INSTR,TYPE) ; Utility to Generate new UID for TYPE
+1 ; ACNUMB -- Accession Number
+2 ; SITE -- Site
+3 ; INSTR -- Instrument
+4 ; TYPE -- "STUDY" or "SERIES" or "SOP"
+5 ;
+6 ; Remove alpha characters from SITE/STATION number
+7 ;
+8 NEW I,ID,STAMP,UID,UINST,PGM
+9 ;
+10 SET SITE=$EXTRACT(SITE,1,3)
+11 ;
+12 SET (UID,UINST)=""
+13 ;
+14 SET ID=$SELECT($EXTRACT($PIECE(ACNUMB,"-"),1)'?1N:$TRANSLATE($HOROLOG,",","")_$PIECE(ACNUMB,"-",2),1:$TRANSLATE(ACNUMB,"-",""))
+15 FOR I=1:1:$LENGTH(INSTR)
SET UINST=UINST+$ASCII($EXTRACT(INSTR,I))
+16 SET SITE=SITE_"."_UINST
+17 SET STAMP=$$NOW^XLFDT
+18 SET STAMP=$TRANSLATE($TRANSLATE(STAMP,".","")," ","")
+19 SET ID=+ID_+STAMP
+20 SET PGM=TYPE_"^MAGVUID1(.UID,SITE,ID)"
+21 DO @PGM
+22 QUIT UID