MAGUE002 ;WOIFO/MLH - database encapsulation - radiology order record ; 29 Feb 2012 5:50 PM
;;3.0;IMAGING;**54,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. |
;; +---------------------------------------------------------------+
;;
Q
;
RORDRR(MAGRRPTI,ERR) ;FUNCTION - return a radiology order record
; input: MAGRRPTI radiology report index from image record
; output: ERR error message if couldn't get record
; function return: radiology order record
;
N MAGRRPTR ; -- radiology report record
N MAGD0 ; ----- Radiology patient file IEN
N MAGD1 ; ----- date index to order record in rad pt file
N MAGD2 ; ----- subdate index to order record in rad pt file
N V ; --------- scratch var
N MAGRORDR ; -- radiology order record
N MAGRPROC ; -- radiology procedure code
S ERR=""
I MAGRRPTI="" S ERR="5~Radiology report pointer required" Q
S MAGRRPTR=$G(^RARPT(MAGRRPTI,0))
S MAGD0=$P(MAGRRPTR,"^",2)
I 'MAGD0 S ERR="1~Radiology patient not found" Q ""
S MAGD1=9999999.9999-$P(MAGRRPTR,"^",3)
S V=$P(MAGRRPTR,"^",4)
S MAGD2=$O(^RADPT(MAGD0,"DT",MAGD1,"P","B",V,"")) ; IA # 1172
I 'MAGD2 S ERR="3~Order record pointer not found" Q ""
S MAGRORDR=$G(^RADPT(MAGD0,"DT",MAGD1,"P",MAGD2,0)) ; IA # 1172
I 'MAGRORDR S ERR="4~Radiology order record not found" Q ""
S ERR=""
Q MAGRORDR
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGUE002 2263 printed Dec 13, 2024@02:08:49 Page 2
MAGUE002 ;WOIFO/MLH - database encapsulation - radiology order record ; 29 Feb 2012 5:50 PM
+1 ;;3.0;IMAGING;**54,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 QUIT
+18 ;
RORDRR(MAGRRPTI,ERR) ;FUNCTION - return a radiology order record
+1 ; input: MAGRRPTI radiology report index from image record
+2 ; output: ERR error message if couldn't get record
+3 ; function return: radiology order record
+4 ;
+5 ; -- radiology report record
NEW MAGRRPTR
+6 ; ----- Radiology patient file IEN
NEW MAGD0
+7 ; ----- date index to order record in rad pt file
NEW MAGD1
+8 ; ----- subdate index to order record in rad pt file
NEW MAGD2
+9 ; --------- scratch var
NEW V
+10 ; -- radiology order record
NEW MAGRORDR
+11 ; -- radiology procedure code
NEW MAGRPROC
+12 SET ERR=""
+13 IF MAGRRPTI=""
SET ERR="5~Radiology report pointer required"
QUIT
+14 SET MAGRRPTR=$GET(^RARPT(MAGRRPTI,0))
+15 SET MAGD0=$PIECE(MAGRRPTR,"^",2)
+16 IF 'MAGD0
SET ERR="1~Radiology patient not found"
QUIT ""
+17 SET MAGD1=9999999.9999-$PIECE(MAGRRPTR,"^",3)
+18 SET V=$PIECE(MAGRRPTR,"^",4)
+19 ; IA # 1172
SET MAGD2=$ORDER(^RADPT(MAGD0,"DT",MAGD1,"P","B",V,""))
+20 IF 'MAGD2
SET ERR="3~Order record pointer not found"
QUIT ""
+21 ; IA # 1172
SET MAGRORDR=$GET(^RADPT(MAGD0,"DT",MAGD1,"P",MAGD2,0))
+22 IF 'MAGRORDR
SET ERR="4~Radiology order record not found"
QUIT ""
+23 SET ERR=""
+24 QUIT MAGRORDR