MAGVDATE ;WOIFO/RRB - Convert DICOM date to VistA ; 06 Apr 2010 9:58 AM
;;3.0;IMAGING;**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. |
;; +---------------------------------------------------------------+
;;
;
;
; Date conversion from DICOM format to VA
;
Q
;
;
DATE(YYYYMMDD,FORMAT) ; convert date from DICOM format to displayable one
; FORMAT: B for birthday mm/dd/yyyy, S for short mm/dd/yy, L for long
N M
S FORMAT=$G(FORMAT)
I FORMAT'="B",FORMAT'="S",FORMAT'="L" Q "Wrong format: "_FORMAT
I YYYYMMDD="" Q ""
I YYYYMMDD="<unknown>" Q YYYYMMDD
I FORMAT="B" Q $E(YYYYMMDD,5,6)_"/"_$E(YYYYMMDD,7,8)_"/"_$E(YYYYMMDD,1,4)
I FORMAT="S" Q $E(YYYYMMDD,5,6)_"/"_$E(YYYYMMDD,7,8)_"/"_$E(YYYYMMDD,3,4)
; long format: Mmm [D]D, YYYY
S M=+$E(YYYYMMDD,5,6),M=(3*(M-1))+1
S M=$E("JanFebMarAprMayJunJulAugSepOctNovDec",M,M+2)
Q M_" "_(+$E(YYYYMMDD,7,8))_", "_$E(YYYYMMDD,1,4)
;
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGVDATE 1835 printed Dec 13, 2024@02:09:45 Page 2
MAGVDATE ;WOIFO/RRB - Convert DICOM date to VistA ; 06 Apr 2010 9:58 AM
+1 ;;3.0;IMAGING;**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 ;
+18 ;
+19 ; Date conversion from DICOM format to VA
+20 ;
+21 QUIT
+22 ;
+23 ;
DATE(YYYYMMDD,FORMAT) ; convert date from DICOM format to displayable one
+1 ; FORMAT: B for birthday mm/dd/yyyy, S for short mm/dd/yy, L for long
+2 NEW M
+3 SET FORMAT=$GET(FORMAT)
+4 IF FORMAT'="B"
IF FORMAT'="S"
IF FORMAT'="L"
QUIT "Wrong format: "_FORMAT
+5 IF YYYYMMDD=""
QUIT ""
+6 IF YYYYMMDD="<unknown>"
QUIT YYYYMMDD
+7 IF FORMAT="B"
QUIT $EXTRACT(YYYYMMDD,5,6)_"/"_$EXTRACT(YYYYMMDD,7,8)_"/"_$EXTRACT(YYYYMMDD,1,4)
+8 IF FORMAT="S"
QUIT $EXTRACT(YYYYMMDD,5,6)_"/"_$EXTRACT(YYYYMMDD,7,8)_"/"_$EXTRACT(YYYYMMDD,3,4)
+9 ; long format: Mmm [D]D, YYYY
+10 SET M=+$EXTRACT(YYYYMMDD,5,6)
SET M=(3*(M-1))+1
+11 SET M=$EXTRACT("JanFebMarAprMayJunJulAugSepOctNovDec",M,M+2)
+12 QUIT M_" "_(+$EXTRACT(YYYYMMDD,7,8))_", "_$EXTRACT(YYYYMMDD,1,4)
+13 ;
+14 QUIT