source: WorldVistAEHR/trunk/r/IMAGING-MAG-ZMAG/MAGJUTL2.m@ 613

Last change on this file since 613 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 8.6 KB
Line 
1MAGJUTL2 ;WIRMFO/JHC VistRad subroutines for RPC calls[ 2/21/97 10:53 AM ] ; 22 Mar 2001 2:24 PM
2 ;;3.0;IMAGING;**18,65,76**;Jun 22, 2007;Build 19
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 ;; | |
12 ;; | The Food and Drug Administration classifies this software as |
13 ;; | a medical device. As such, it may not be changed in any way. |
14 ;; | Modifications to this software may result in an adulterated |
15 ;; | medical device under 21CFR820, the use of which is considered |
16 ;; | to be a violation of US Federal Statutes. |
17 ;; +---------------------------------------------------------------+
18 ;;
19 Q
20IMGINFO(RARPT,RET) ; Fetch info from Image File for input RARPT:
21 ; Input: RARPT: Rad Report pointer
22 ; RET: see below
23 ; RET contents delimited by ^:
24 ; CT = # of images for case
25 ; ONL = Image Storage status (Y=On Magnetic disk, N=Jukebox
26 ; "n/a" for not available, e.g., film only)
27 ; note -- if last image in group is Online, considers ALL online
28 ; MAGDT = Date/Time of Image Capture
29 ; REMOTE = 1/0 to Indicate images were remotely cached
30 ; MODALITY= Modality abbrev
31 ; PLACE = Image storage PLace (ptr to 2006.1 entry)
32 ; KEY = 1/0 ind. Key Images exist for this exam
33 ;
34 N IRPT,MAGIEN,MAGIEN2,ONLCHK,NETLOC,STIEN
35 N CT,ONL,MAGDT,REMOTE,MODALITY,PLACE,REMCHK,KEY
36 S CT="",ONL="",MAGDT="",RET="",REMOTE="",MODALITY="",PLACE="",KEY=0 ; init return vars
37 G IMGINFQ:'RARPT G IMGINFQ:'$D(^RARPT(RARPT,2005,0))
38 I 'MAGJOB("P32") D
39 . S STIEN=$$STUDYID^MAGJUPD2("",RARPT,1)
40 . I STIEN S T=$O(^MAG(2005,STIEN,205,0)) I T S KEY=1
41 S IRPT=0 F S IRPT=$O(^RARPT(RARPT,2005,IRPT)) Q:'IRPT S MAGIEN=$P(^(IRPT,0),U) D
42 . Q:'$D(^MAG(2005,MAGIEN,0))
43 . I MAGDT="" S MAGDT=$P($G(^MAG(2005,MAGIEN,100)),U,6) S:MAGDT="" MAGDT=$P($G(^(2)),U)
44 . I $O(^MAG(2005,MAGIEN,1,0)) S CT=CT+$P(^(0),U,4),Y=$P(^(0),U,3),MAGIEN2=$P($G(^(Y,0)),U) S:(MAGIEN2]"") ONLCHK=$$ONLCHK(MAGIEN2),REMCHK=$$REMOTE(MAGIEN2) ; last image in group
45 . E S CT=CT+1,ONLCHK=$$ONLCHK(MAGIEN),REMCHK=$$REMOTE(MAGIEN)
46 . S ONL=$S(ONL="":+ONLCHK,+ONL:+ONLCHK,1:0) ; NOT Online if ANY img is 0
47 . S REMOTE=$S(REMOTE="":REMCHK,+REMOTE:REMCHK,1:0) ; NOT Remote if ANY img is 0
48 . S X=$P(ONLCHK,U,3)
49 . I MODALITY="" S MODALITY=X
50 . E I MODALITY'[X S MODALITY=MODALITY_","_X
51 . I PLACE="" S PLACE=$P(ONLCHK,U,4)
52IMGINFQ S ONL=$S(+ONL:"Y",ONL="":"n/a",1:"N")
53 S RET=CT_U_ONL_U_MAGDT_U_REMOTE_U_MODALITY_U_PLACE_U_KEY
54 Q
55 ;
56ONLCHK(MAGIEN,USETGA) ;
57 ; Input: MAGIEN: Image pointer
58 ; USETGA: 1/0 -- if 1, forces return of TGA (not .big) file
59 ;Return:
60 ; - T/F for Full-Res image on Mag. Disk that is Online
61 ; - File type (BIG/FULL)
62 ; - Modality
63 ; - Place
64 ; - DFN
65 ; - File Name IFF this image is stored Off-Line (else null)
66 ; - USETGA as calculated in the logic below
67 ; - PROCDT = Img Processing DtTime
68 ; - ACQSITE = Acquisition site code
69 ; USETGA is set to False (0) if a low-resolution image (TGA) is
70 ; requested, but none exists; calling routine would call by ref.
71 ;
72 N BIG,X,NOD,MAG0,MODALITY,RET,PLACE,DFN,FILNAM,MAG2,PROCDT,ACQSITE,MAG100
73 S USETGA=+$G(USETGA) ; Defaults to Full-Resolution image if not defined
74 S RET="",MODALITY="",PLACE="",ACQSITE=""
75 S MAG0=^MAG(2005,MAGIEN,0),BIG=$D(^("FBIG")),NOD=$S(BIG:^("FBIG"),1:MAG0)
76 S MAG2=^MAG(2005,MAGIEN,2),PROCDT=$P(MAG2,U)
77 S MAG100=$G(^MAG(2005,MAGIEN,100)),ACQSITE=$P(MAG100,U,3)
78 I USETGA D
79 . I 'BIG S USETGA=0 ; reply no low-res image available
80 . I BIG S NOD=MAG0,BIG=0 ; enable correct logic inside this subroutine
81 S MODALITY=$P(MAG0,U,8),DFN=$P(MAG0,U,7)
82 I BIG S X=+$P(NOD,U) ; $p 1 is Magnetic Disk/Volume (.big) <*> DCM--add to end: S:'X X=+$P(NOD,U,3)
83 E S X=+$P(NOD,U,3) ; $p 3 is Magnetic Disk/Volume (.tga)
84 I X D
85 . I '$D(NETLOC(X)) S NETLOC(X)=+$P(^MAG(2005.2,X,0),U,6)_U_$P(^(0),U,10)
86 . S RET=+NETLOC(X),PLACE=$P(NETLOC(X),U,2) ; NETLOC is global to this subrtn
87 . S FILNAM=""
88 E D
89 . S RET=0,FILNAM=$P(MAG0,U,2)
90 . S T=$S(BIG:$P(NOD,U,2),1:$P(NOD,U,5))
91 . I T S PLACE=$P(^MAG(2005.2,T,0),U,10) ; <*>DCM--add anything?
92 S RET=RET_U_$S(BIG:"BIG",1:"FULL")_U_MODALITY_U_PLACE_U_DFN_U_FILNAM_U_USETGA_U_PROCDT_U_ACQSITE
93 Q RET
94 ;
95REMOTE(MAGIEN) ;Return list of remote Cache Locations
96 ; else, return "" if none
97 N RET,LOC
98 S RET=""
99 I $D(^MAG(2005,MAGIEN,4,"LOC")) S LOC=0 D
100 . F S LOC=$O(^MAG(2005,MAGIEN,4,"LOC",LOC)) Q:'LOC S RET=RET_$S(RET="":"",1:",")_LOC
101 Q RET
102 ;
103IMGINF2(RARPT,RET,USETGA) ; Fetch info from Image File for input RARPT:
104 ; Input: RARPT: Rad Report pointer
105 ; RET: see below
106 ; USETGA: 1/0 -- if 1, forces return of TGA (not .big) file
107 ; RET holds array of return values:
108 ; RET = # Images stored for the case
109 ; RET(1:n) = 1/0 ^ FULL/BIG ^ Mod ^ ien ^ Series ^ Routed-to Locations ^ PLACE ^ DFN ^ FileName (if OffLine) ^ PS_Indicator
110 ; (1=Image is on Magnetic Disk)
111 ; * This subroutine may be called by other VistARad routines
112 ;
113 N BIG,IMG,MAGIEN,MAGIEN2,MAGPTR,MAGINDX,MAGREF,NETLOC,SERIES,SERCT,SERPREV
114 K RET S RET=0,SERCT=0,SERPREV=""
115 S USETGA=+$G(USETGA) ; Defaults to Full-Resolution image if not defined
116 G IMGINF2Q:'RARPT S IMG=0
117 S MAGINDX="ADCM" ; maybe others will exist in the future
118 ; *P18--this index is defunct for P18 & beyond
119 ; however, keep for bkwds-compat P18 to P32; remove later
120 F S IMG=$O(^RARPT(RARPT,2005,IMG)) Q:'IMG S MAGIEN=$P(^(IMG,0),U) D
121 . S MAGREF=$NA(^MAG(2005,MAGIEN,1,MAGINDX))
122 . I 'MAGJOB("P32")!'$D(@MAGREF) D ; use group multiple structure
123 .. Q:'$D(^MAG(2005,MAGIEN,0)) S MAGPTR=0
124 .. I '$O(^MAG(2005,MAGIEN,1,MAGPTR)) D Q
125 ... S T=$$ONLCHK(MAGIEN,USETGA)
126 ... S RET=RET+1,RET(RET)=$P(T,U,1,3)_U_MAGIEN_U_U_$$REMOTE(MAGIEN)_U_$P(T,U,4,7)_U_$$PSIND(MAGIEN)_U_$P(T,U,8)_U_$P(T,U,9)
127 .. E F S MAGPTR=$O(^MAG(2005,MAGIEN,1,MAGPTR)) Q:'MAGPTR S MAGIEN2=$P(^(MAGPTR,0),U) D
128 ... S T=$$ONLCHK(MAGIEN2,USETGA)
129 ... S RET=RET+1,RET(RET)=$P(T,U,1,3)_U_MAGIEN2_U_U_$$REMOTE(MAGIEN2)_U_$P(T,U,4,7)_U_$$PSIND(MAGIEN2)_U_$P(T,U,8)_U_$P(T,U,9)
130 . E I $D(@MAGREF) D ; use exam index, e.g., "ADCM"
131 .. F S MAGREF=$Q(@MAGREF) Q:($P(MAGREF,",",4)'=(""""_MAGINDX_"""")) D
132 ... S X=$L(MAGREF,","),MAGIEN2=$P(MAGREF,",",X-1),SERIES=$P(MAGREF,",",5)
133 ... S T=$$ONLCHK(MAGIEN2,USETGA)
134 ... S RET=RET+1,RET(RET)=$P(T,U,1,3)_U_MAGIEN2_U_SERIES_U_$$REMOTE(MAGIEN2)_U_$P(T,U,4,7)
135 ... I SERIES'=SERPREV S SERCT=SERCT+1,$P(RET("SER",SERCT),U,2)=SERIES,SERPREV=SERIES,RET("SER",0)=SERCT
136 ... S $P(RET("SER",SERCT),U)=RET("SER",SERCT)+1
137IMGINF2Q ;
138 Q
139 ;
140PSIND(MAGIEN) ; return Presentation State Indicator(s) for image
141 ; K=Key Image PStype; I=Interpretation PStyp; U=User PStyp
142 N RSL,IEN,X
143 S RSL="",IEN=0
144 I $D(^MAG(2005,MAGIEN,210,IEN)) F S IEN=$O(^MAG(2005,MAGIEN,210,IEN)) Q:'IEN S X=$P(^(IEN,0),U,2) Q:RSL[X S RSL=RSL_$S(RSL="":"",1:",")_X
145 Q:$Q RSL Q
146 ;
147JBFETCH(RARPT,MAGS,USETGA) ; fetch this case's images from Jukebox, if necessary
148 ; Input: RARPT: Rad Report pointer
149 ; MAGS: see below
150 ; USETGA: 1/0 -- if 1, forces return of TGA (not .big) file
151 ; This is a function that returns a string containing:
152 ; # Images fetched from JB ^ Total # Images for Case ^ # Low Res Imgs
153 ; The MAGS array will be returned to the calling
154 ; routine if MAGS is provided as an input parameter
155 ; MAGS is populated by call to IMGINF2.
156 ; IF any images are stored OffLine, then this node is set here:
157 ; MAGS("OFFLN",JBOFFLN)="" JBOFFLN = Platter ID from file 2006.033
158 ;
159 ; * This function may be called by other VistARad routines
160 ;
161 N MAGIEN,FETCH,IMAG,FILNAM,JBOFFLN,LORESCT
162 S USETGA=+$G(USETGA) ; Defaults to Full-Resolution image if not defined
163 S FETCH=0,LORESCT=0
164 D IMGINF2(RARPT,.MAGS,USETGA)
165 I MAGS F IMAG=1:1:MAGS S X=MAGS(IMAG) D
166 . I USETGA S LORESCT=LORESCT+$P(X,U,10)
167 . I '+X D ; Call params below depend on Consolidated Site status
168 .. S FILNAM=$P(X,U,9)
169 .. I FILNAM]"",$D(^MAGQUEUE(2006.033,"B",FILNAM)) S T=$O(^(FILNAM,"")) S JBOFFLN=$P($G(^MAGQUEUE(2006.033,T,0)),U,2) S FETCH=FETCH+1,MAGS("OFFLN",JBOFFLN)="" Q ; OffLine Image
170 .. I '$G(MAGJOB("CONSOLIDATED")) S X=$$JBTOHD^MAGBAPI($P(X,U,4)_"^"_$P(X,U,2)),FETCH=FETCH+1 ; pre-consolidation vs
171 .. E S X=$$JBTOHD^MAGBAPI($P(X,U,4)_"^"_$P(X,U,2),$P(X,U,7)),FETCH=FETCH+1
172 Q FETCH_U_MAGS_U_LORESCT
173 ;
174END Q ;
Note: See TracBrowser for help on using the repository browser.