MAGVRD01 ;WOIFO/DAC - Radiation Dosage - Attach Instance ; 25 April 2013 10:41 AM
;;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
INPUTSEP() ; Name value separator for input data ie. NAME`TESTPATIENT
Q "`"
OUTSEP() ; Name value separator for output data ie. NAME|TESTPATIENT
Q "|"
STATSEP() ; Status and Result separator ie. -3``No record IEN
Q "`"
;
; Add an irradiation instance entry
;
; RPC: MAGV ATTACH IRRADIATION DOSE
;
; Input Variables:
; PATIENT - Patient DFN
; PROC - Accession Number
; TYPE - "FLUORO" or "CT"
; STUDYUID - Study UID
; SERUID - Series UID
; IIUID - Irradiation Instance UID
; ATTS - Array of name value pairs separated by an input separator
; Output Variables:
; OUT - Returns success and new record IEN or error and error message
;
ATTACH(OUT,PATIENT,PROC,TYPE,STUDYUID,SERUID,IIUID,ATTS) ; RPC [MAGV ATTACH IRRADIATION DOSE]
N FDA,OSEP,ISEP,SSEP,NAM,VAL,I,ATTNAMS,STUDYIEN,SERIEN
S OSEP=$$OUTSEP,ISEP=$$INPUTSEP,SSEP=$$STATSEP
; Quit with error if any input variable not defined
I $G(PATIENT)="" S OUT="-10"_SSEP_"Patient not defined" Q
I $G(PROC)="" S OUT="-11"_SSEP_"Procedure not defined" Q
I $G(TYPE)="" S OUT="-12"_SSEP_"Type not defined" Q
I $G(STUDYUID)="" S OUT="-1"_SSEP_"Study UID not defined" Q
I $G(SERUID)="" S OUT="-2"_SSEP_"Series UID not defined" Q
I $G(IIUID)="" S OUT="-3"_SSEP_"Irradiation Instance UID not defined" Q
I '$D(ATTS) S OUT="-13"_SSEP_"Attribute array not defined" Q
; Quit if Study not defined or not active
I '$D(^MAGV(2005.62,"B",STUDYUID)) S OUT="-4"_SSEP_"Study UID not on file" Q
S STUDYIEN=$O(^MAGV(2005.62,"B",STUDYUID,""))
I $P($G(^MAGV(2005.62,STUDYIEN,5)),U,2)'="A" S OUT="-5"_SSEP_"Study not accessible"
; Quit if Series not defined or not active
I '$D(^MAGV(2005.63,"B",SERUID)) S OUT="-6"_SSEP_"Series UID not on file" Q
S SERIEN=$O(^MAGV(2005.63,"B",SERUID,""))
I $P($G(^MAGV(2005.63,SERIEN,6)),U,1)'=STUDYIEN S OUT="-7"_SSEP_"Series not attached to study"
I $P($G(^MAGV(2005.63,SERIEN,9)),U,1)'="A" S OUT="-8"_SSEP_"Series not accessible"
; If atts not defined quit with error
S I=0
F S I=$O(ATTS(I)) Q:'I D Q:$D(OUT(1))
. S NAM=$P(ATTS(I),ISEP,1),VAL=$P(ATTS(I),ISEP,2)
. I NAM="" S OUT="-9"_SSEP_"Attribute name(s) missing from attribute array" Q
. S ATTNAMS(NAM)=VAL
. Q
Q:$D(OUT)
; Add Irradiation Instance to attribute array
S ATTNAMS("IRRADIATION INSTANCE UID")=IIUID
; Update Irradiation Instance table
I TYPE="FLUORO" D FLUORO^MAGVRD02(.OUT,.ATTNAMS,SERUID,IIUID)
I TYPE="CT" D CT^MAGVRD02(.OUT,.ATTNAMS,SERUID,IIUID)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGVRD01 3801 printed Dec 13, 2024@02:10:02 Page 2
MAGVRD01 ;WOIFO/DAC - Radiation Dosage - Attach Instance ; 25 April 2013 10:41 AM
+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
INPUTSEP() ; Name value separator for input data ie. NAME`TESTPATIENT
+1 QUIT "`"
OUTSEP() ; Name value separator for output data ie. NAME|TESTPATIENT
+1 QUIT "|"
STATSEP() ; Status and Result separator ie. -3``No record IEN
+1 QUIT "`"
+2 ;
+3 ; Add an irradiation instance entry
+4 ;
+5 ; RPC: MAGV ATTACH IRRADIATION DOSE
+6 ;
+7 ; Input Variables:
+8 ; PATIENT - Patient DFN
+9 ; PROC - Accession Number
+10 ; TYPE - "FLUORO" or "CT"
+11 ; STUDYUID - Study UID
+12 ; SERUID - Series UID
+13 ; IIUID - Irradiation Instance UID
+14 ; ATTS - Array of name value pairs separated by an input separator
+15 ; Output Variables:
+16 ; OUT - Returns success and new record IEN or error and error message
+17 ;
ATTACH(OUT,PATIENT,PROC,TYPE,STUDYUID,SERUID,IIUID,ATTS) ; RPC [MAGV ATTACH IRRADIATION DOSE]
+1 NEW FDA,OSEP,ISEP,SSEP,NAM,VAL,I,ATTNAMS,STUDYIEN,SERIEN
+2 SET OSEP=$$OUTSEP
SET ISEP=$$INPUTSEP
SET SSEP=$$STATSEP
+3 ; Quit with error if any input variable not defined
+4 IF $GET(PATIENT)=""
SET OUT="-10"_SSEP_"Patient not defined"
QUIT
+5 IF $GET(PROC)=""
SET OUT="-11"_SSEP_"Procedure not defined"
QUIT
+6 IF $GET(TYPE)=""
SET OUT="-12"_SSEP_"Type not defined"
QUIT
+7 IF $GET(STUDYUID)=""
SET OUT="-1"_SSEP_"Study UID not defined"
QUIT
+8 IF $GET(SERUID)=""
SET OUT="-2"_SSEP_"Series UID not defined"
QUIT
+9 IF $GET(IIUID)=""
SET OUT="-3"_SSEP_"Irradiation Instance UID not defined"
QUIT
+10 IF '$DATA(ATTS)
SET OUT="-13"_SSEP_"Attribute array not defined"
QUIT
+11 ; Quit if Study not defined or not active
+12 IF '$DATA(^MAGV(2005.62,"B",STUDYUID))
SET OUT="-4"_SSEP_"Study UID not on file"
QUIT
+13 SET STUDYIEN=$ORDER(^MAGV(2005.62,"B",STUDYUID,""))
+14 IF $PIECE($GET(^MAGV(2005.62,STUDYIEN,5)),U,2)'="A"
SET OUT="-5"_SSEP_"Study not accessible"
+15 ; Quit if Series not defined or not active
+16 IF '$DATA(^MAGV(2005.63,"B",SERUID))
SET OUT="-6"_SSEP_"Series UID not on file"
QUIT
+17 SET SERIEN=$ORDER(^MAGV(2005.63,"B",SERUID,""))
+18 IF $PIECE($GET(^MAGV(2005.63,SERIEN,6)),U,1)'=STUDYIEN
SET OUT="-7"_SSEP_"Series not attached to study"
+19 IF $PIECE($GET(^MAGV(2005.63,SERIEN,9)),U,1)'="A"
SET OUT="-8"_SSEP_"Series not accessible"
+20 ; If atts not defined quit with error
+21 SET I=0
+22 FOR
SET I=$ORDER(ATTS(I))
if 'I
QUIT
Begin DoDot:1
+23 SET NAM=$PIECE(ATTS(I),ISEP,1)
SET VAL=$PIECE(ATTS(I),ISEP,2)
+24 IF NAM=""
SET OUT="-9"_SSEP_"Attribute name(s) missing from attribute array"
QUIT
+25 SET ATTNAMS(NAM)=VAL
+26 QUIT
End DoDot:1
if $DATA(OUT(1))
QUIT
+27 if $DATA(OUT)
QUIT
+28 ; Add Irradiation Instance to attribute array
+29 SET ATTNAMS("IRRADIATION INSTANCE UID")=IIUID
+30 ; Update Irradiation Instance table
+31 IF TYPE="FLUORO"
DO FLUORO^MAGVRD02(.OUT,.ATTNAMS,SERUID,IIUID)
+32 IF TYPE="CT"
DO CT^MAGVRD02(.OUT,.ATTNAMS,SERUID,IIUID)
+33 QUIT