MAGVRS43 ;WOIFO/MLH - RPC calls for DICOM file processing ; 03 Apr 2012 2:44 PM
;;3.0;IMAGING;**118,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
TIUCHK(OUT,STYIEN) ; is this image study attached to a consult with a TIU note?
N TIUIEN,PROCIEN,CONIEN,TIUPATIEN,DFN,PATIEN,PATID,PATREFDTA,STYDFN,TIUDFN,X
S STYIEN=$G(STYIEN)
I STYIEN'?1N.E S OUT(1)="-1`Study IEN must be numeric" Q
I STYIEN'>0 S OUT(1)="-2`Study IEN must be a positive integer" Q
I '$D(^MAGV(2005.62,STYIEN)) S OUT(1)="-3`No entry on file for Study IEN "_STYIEN Q
I $P($G(^MAGV(2005.62,STYIEN,5)),"^",2)="I" S OUT(1)="4`Study is inaccessible" Q
S PROCIEN=$P($G(^MAGV(2005.62,STYIEN,6)),"^",1)
I PROCIEN="" S OUT(1)="-4`No associated Procedure Reference IEN" Q
I '$D(^MAGV(2005.61,PROCIEN)) S OUT(1)="-5`No entry on file for associated Procedure Reference IEN "_PROCIEN Q
I $P($G(^MAGV(2005.61,PROCIEN,0)),"^",3)'="CON" S OUT(1)="1`Associated procedure is not a consult" Q
; find DFN of patient associated with procedure
S PATIEN=$P($G(^MAGV(2005.61,PROCIEN,6)),"^",1)
I PATIEN="" S OUT(1)="-6`Missing Patient Reference IEN" Q
I '$D(^MAGV(2005.6,PATIEN)) S OUT(1)="-7`No entry on file for associated Patient Reference IEN" Q
S PATREFDTA=$G(^MAGV(2005.6,PATIEN,0))
I $P(PATREFDTA,"^",2)'="V" S OUT(1)="2`Study is not associated with a VA patient" Q
I $P(PATREFDTA,"^",3)'="D" S OUT(1)="3`Study is not associated with a local DFN" Q
S STYDFN=$P(PATREFDTA,"^",1)
; find DFN of patient associated with consult
S CONIEN=$P($G(^MAGV(2005.61,PROCIEN,0)),"^",1)
S X=$$GMRCIEN^MAGDFCNV(CONIEN) I X S CONIEN=X
S TIUIEN=$$TIULAST^MAGDGMRC(CONIEN)
I "0"[TIUIEN S OUT(1)="5`No associated TIU note for associated consult "_CONIEN Q
S TIUDFN=$$GET1^DIQ(8925,TIUIEN,.02,"I") ; entry on VA patient file
I "0"[TIUDFN S OUT(1)="-8`No DFN on file for TIU note "_TIUIEN Q
; compare the two DFNs
I TIUDFN'=STYDFN S OUT(1)="-9`VA Patient IEN associated with TIU Document does not match Patient IEN associated with Study" Q
S OUT(1)="0``"_TIUIEN
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGVRS43 3049 printed Dec 13, 2024@02:10:19 Page 2
MAGVRS43 ;WOIFO/MLH - RPC calls for DICOM file processing ; 03 Apr 2012 2:44 PM
+1 ;;3.0;IMAGING;**118,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
TIUCHK(OUT,STYIEN) ; is this image study attached to a consult with a TIU note?
+1 NEW TIUIEN,PROCIEN,CONIEN,TIUPATIEN,DFN,PATIEN,PATID,PATREFDTA,STYDFN,TIUDFN,X
+2 SET STYIEN=$GET(STYIEN)
+3 IF STYIEN'?1N.E
SET OUT(1)="-1`Study IEN must be numeric"
QUIT
+4 IF STYIEN'>0
SET OUT(1)="-2`Study IEN must be a positive integer"
QUIT
+5 IF '$DATA(^MAGV(2005.62,STYIEN))
SET OUT(1)="-3`No entry on file for Study IEN "_STYIEN
QUIT
+6 IF $PIECE($GET(^MAGV(2005.62,STYIEN,5)),"^",2)="I"
SET OUT(1)="4`Study is inaccessible"
QUIT
+7 SET PROCIEN=$PIECE($GET(^MAGV(2005.62,STYIEN,6)),"^",1)
+8 IF PROCIEN=""
SET OUT(1)="-4`No associated Procedure Reference IEN"
QUIT
+9 IF '$DATA(^MAGV(2005.61,PROCIEN))
SET OUT(1)="-5`No entry on file for associated Procedure Reference IEN "_PROCIEN
QUIT
+10 IF $PIECE($GET(^MAGV(2005.61,PROCIEN,0)),"^",3)'="CON"
SET OUT(1)="1`Associated procedure is not a consult"
QUIT
+11 ; find DFN of patient associated with procedure
+12 SET PATIEN=$PIECE($GET(^MAGV(2005.61,PROCIEN,6)),"^",1)
+13 IF PATIEN=""
SET OUT(1)="-6`Missing Patient Reference IEN"
QUIT
+14 IF '$DATA(^MAGV(2005.6,PATIEN))
SET OUT(1)="-7`No entry on file for associated Patient Reference IEN"
QUIT
+15 SET PATREFDTA=$GET(^MAGV(2005.6,PATIEN,0))
+16 IF $PIECE(PATREFDTA,"^",2)'="V"
SET OUT(1)="2`Study is not associated with a VA patient"
QUIT
+17 IF $PIECE(PATREFDTA,"^",3)'="D"
SET OUT(1)="3`Study is not associated with a local DFN"
QUIT
+18 SET STYDFN=$PIECE(PATREFDTA,"^",1)
+19 ; find DFN of patient associated with consult
+20 SET CONIEN=$PIECE($GET(^MAGV(2005.61,PROCIEN,0)),"^",1)
+21 SET X=$$GMRCIEN^MAGDFCNV(CONIEN)
IF X
SET CONIEN=X
+22 SET TIUIEN=$$TIULAST^MAGDGMRC(CONIEN)
+23 IF "0"[TIUIEN
SET OUT(1)="5`No associated TIU note for associated consult "_CONIEN
QUIT
+24 ; entry on VA patient file
SET TIUDFN=$$GET1^DIQ(8925,TIUIEN,.02,"I")
+25 IF "0"[TIUDFN
SET OUT(1)="-8`No DFN on file for TIU note "_TIUIEN
QUIT
+26 ; compare the two DFNs
+27 IF TIUDFN'=STYDFN
SET OUT(1)="-9`VA Patient IEN associated with TIU Document does not match Patient IEN associated with Study"
QUIT
+28 SET OUT(1)="0``"_TIUIEN
+29 QUIT