| 1 | MAGGTRA ;WOIFO/GEK - RPC Call to list Patient's Rad/Nuc Exams, Reports ; [ 06/20/2001 08:57 ] | 
|---|
| 2 | ;;3.0;IMAGING;**59**;Nov 27, 2007;Build 20 | 
|---|
| 3 | ;;Per VHA Directive 2004-038, this routine should not be modified. | 
|---|
| 4 | ;; +---------------------------------------------------------------+ | 
|---|
| 5 | ;; | Property of the US Government.                                | | 
|---|
| 6 | ;; | No permission to copy or redistribute this software is given. | | 
|---|
| 7 | ;; | Use of unreleased versions of this software requires the user | | 
|---|
| 8 | ;; | to execute a written test agreement with the VistA Imaging    | | 
|---|
| 9 | ;; | Development Office of the Department of Veterans Affairs,     | | 
|---|
| 10 | ;; | telephone (301) 734-0100.                                     | | 
|---|
| 11 | ;; | The Food and Drug Administration classifies this software as  | | 
|---|
| 12 | ;; | a medical device.  As such, it may not be changed in any way. | | 
|---|
| 13 | ;; | Modifications to this software may result in an adulterated   | | 
|---|
| 14 | ;; | medical device under 21CFR820, the use of which is considered | | 
|---|
| 15 | ;; | to be a violation of US Federal Statutes.                     | | 
|---|
| 16 | ;; +---------------------------------------------------------------+ | 
|---|
| 17 | ;; | 
|---|
| 18 | Q | 
|---|
| 19 | LIST(MAGRY,DATA) ; | 
|---|
| 20 | ; SOME OLD IMAGING EXECUTABLES (IMGVWP10) STILL CALL HERE | 
|---|
| 21 | ;  THIS HAS BEEN SWITCHED TO LIST^MAGGTRA1 | 
|---|
| 22 | ; | 
|---|
| 23 | ;MAGRY - return array of patient's exams. | 
|---|
| 24 | ;DATA   - RADFN - Radiology Patient's DFN  ^RADPT( | 
|---|
| 25 | ; | 
|---|
| 26 | D LIST^MAGGTRA1(.MAGRY,.DATA) | 
|---|
| 27 | Q | 
|---|
| 28 | MAGPTR(MAGRY,XDUZ,MAGIEN,DATA) ;RPC Call to file Image pointer into Radiology | 
|---|
| 29 | ;   File and Radiology pointer into Image File. | 
|---|
| 30 | ; | 
|---|
| 31 | ; MAGRY is the return string = 1^success     if things work okay. | 
|---|
| 32 | ;                               0^message     if things not okay. | 
|---|
| 33 | ;  DATA is The data that was sent in LIST^MAGGTRA | 
|---|
| 34 | ;        it is the display data _ to ^TMP($J,"RAEX",RACNT | 
|---|
| 35 | ;        the ^TMP is setup by RAPTLU, (and MAGGTRA) in the lookup | 
|---|
| 36 | ;        of patient exams, we keep it, and send it back in case | 
|---|
| 37 | ;        we need to create a new report. | 
|---|
| 38 | ; | 
|---|
| 39 | ;  XDUZ is not used from parameter list anymore. | 
|---|
| 40 | ;  MAGIEN is Image File IEN ^MAG(2005,IEN | 
|---|
| 41 | ; | 
|---|
| 42 | N Y,I,CT,MAGERR,DIQUIET | 
|---|
| 43 | N RADFN,RADTI,RACNI,RANME,RASSN,RADATE,RADTE,RACN,RAPRC,RARPT,RAST,MAGGP | 
|---|
| 44 | IF $$NEWERR^%ZTER N $ETRAP,$ESTACK S $ETRAP="D ERR^MAGGTERR" | 
|---|
| 45 | E  S X="ERR^MAGGTERR",@^%ZOSF("TRAP") | 
|---|
| 46 | S DIQUIET=1,MAGERR=0,CT=0 | 
|---|
| 47 | D DT^DICRW | 
|---|
| 48 | ;    The list entry selected has the following data associated with it | 
|---|
| 49 | ;    it was created using parts of RAPTLU routine to list rad exams | 
|---|
| 50 | ;^TMP($J,"RAEX",RACNT)=RADFN_"^"_RADTI_"^"_RACNI_"^"_RANME_"^"_RASSN_"^"_RADATE_"^"_RADTE_"^"_RACN_"^"_RAPRC_"^"_RARPT_"^"_RAST | 
|---|
| 51 | ; | 
|---|
| 52 | S DATA=$P(DATA,"^",7,99) | 
|---|
| 53 | F I="RADFN","RADTI","RACNI","RANME","RASSN","RADATE","RADTE","RACN","RAPRC","RARPT","RAST" S CT=CT+1,@I=$P(DATA,"^",CT) | 
|---|
| 54 | ; | 
|---|
| 55 | ; let us check a few things first | 
|---|
| 56 | ; Do we have a valid IMAGE IEN  ^MAG(2005, | 
|---|
| 57 | I '$D(^MAG(2005,MAGIEN,0)) S MAGRY="0^OPERATION CANCEDED: INVALID Imaging (2005) entry" Q | 
|---|
| 58 | ; Does this Imaging entry already point to a Report. | 
|---|
| 59 | I $D(^MAG(2005,MAGIEN,2)) S Z=^(2) D | 
|---|
| 60 | . F I=6,7,8 S X=$P(Z,U,I) I $L(X) S MAGERR=1 Q | 
|---|
| 61 | I MAGERR S MAGRY="0^OPERATION CANCELED: Imaging File entry already has an associated Report" Q | 
|---|
| 62 | ; Does the Imaging entry patient, match the Rad Exam entry patient | 
|---|
| 63 | I $P(^MAG(2005,MAGIEN,0),U,7)'=RADFN S MAGRY="0^OPERATION CANCELED: Imaging Patient doesn't match Radiology Patient" Q | 
|---|
| 64 | I RARPT,'$D(^RARPT(RARPT,0)) S MAGRY="0^OPERATION CANCELED: INVALID Radiology Report Number" Q | 
|---|
| 65 | I '$G(RARPT) D CREATE^RARIC I '$G(RARPT) S MAGRY="0^OPERATION FAILED creating new Radiology Report entry" Q | 
|---|
| 66 | ;    Now lets file the Image pointer in the ^RARPT(  file. | 
|---|
| 67 | S MAGGP=MAGIEN | 
|---|
| 68 | D PTR^RARIC | 
|---|
| 69 | I Y<1 S MAGRY="0^OPERATION FAILED Creating Image pointer in Report File" Q | 
|---|
| 70 | ; Now SET the Parent fields in the Image File | 
|---|
| 71 | S $P(^MAG(2005,MAGIEN,2),U,6,8)=74_U_RARPT_U_+Y | 
|---|
| 72 | ; DONE. | 
|---|
| 73 | S MAGRY="1^Image pointer filed successfully" | 
|---|
| 74 | D LINKDT^MAGGTU6(.X,MAGIEN) | 
|---|
| 75 | Q | 
|---|