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

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

revised back to 6/30/08 version

File size: 8.6 KB
RevLine 
[623]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**;Jul 27, 2006;Build 28
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)) I MAGDT="" S MAGDT=$P($G(^(2)),U)
43 . 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
44 . E S CT=CT+1,ONLCHK=$$ONLCHK(MAGIEN),REMCHK=$$REMOTE(MAGIEN)
45 . S ONL=$S(ONL="":+ONLCHK,+ONL:+ONLCHK,1:0) ; NOT Online if ANY img is 0
46 . S REMOTE=$S(REMOTE="":REMCHK,+REMOTE:REMCHK,1:0) ; NOT Remote if ANY img is 0
47 . S X=$P(ONLCHK,U,3)
48 . I MODALITY="" S MODALITY=X
49 . E I MODALITY'[X S MODALITY=MODALITY_","_X
50 . I PLACE="" S PLACE=$P(ONLCHK,U,4)
51IMGINFQ S ONL=$S(+ONL:"Y",ONL="":"n/a",1:"N")
52 S RET=CT_U_ONL_U_MAGDT_U_REMOTE_U_MODALITY_U_PLACE_U_KEY
53 Q
54 ;
55ONLCHK(MAGIEN,USETGA) ;
56 ; Input: MAGIEN: Image pointer
57 ; USETGA: 1/0 -- if 1, forces return of TGA (not .big) file
58 ;Return:
59 ; - T/F for Full-Res image on Mag. Disk that is Online
60 ; - File type (BIG/FULL)
61 ; - Modality
62 ; - Place
63 ; - DFN
64 ; - File Name IFF this image is stored Off-Line (else null)
65 ; - USETGA as calculated in the logic below
66 ; - PROCDT = Img Processing DtTime
67 ; - ACQSITE = Acquisition site code
68 ; USETGA is set to False (0) if a low-resolution image (TGA) is
69 ; requested, but none exists; calling routine would call by ref.
70 ;
71 N BIG,X,NOD,MAG0,MODALITY,RET,PLACE,DFN,FILNAM,MAG2,PROCDT,ACQSITE,MAG100
72 S USETGA=+$G(USETGA) ; Defaults to Full-Resolution image if not defined
73 S RET="",MODALITY="",PLACE="",ACQSITE=""
74 S MAG0=^MAG(2005,MAGIEN,0),BIG=$D(^("FBIG")),NOD=$S(BIG:^("FBIG"),1:MAG0)
75 S MAG2=^MAG(2005,MAGIEN,2),PROCDT=$P(MAG2,U)
76 S MAG100=$G(^MAG(2005,MAGIEN,100)),ACQSITE=$P(MAG100,U,3)
77 I USETGA D
78 . I 'BIG S USETGA=0 ; reply no low-res image available
79 . I BIG S NOD=MAG0,BIG=0 ; enable correct logic inside this subroutine
80 S MODALITY=$P(MAG0,U,8),DFN=$P(MAG0,U,7)
81 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)
82 E S X=+$P(NOD,U,3) ; $p 3 is Magnetic Disk/Volume (.tga)
83 I X D
84 . I '$D(NETLOC(X)) S NETLOC(X)=+$P(^MAG(2005.2,X,0),U,6)_U_$P(^(0),U,10)
85 . S RET=+NETLOC(X),PLACE=$P(NETLOC(X),U,2) ; NETLOC is global to this subrtn
86 . S FILNAM=""
87 E D
88 . S RET=0,FILNAM=$P(MAG0,U,2)
89 . S T=$S(BIG:$P(NOD,U,2),1:$P(NOD,U,5))
90 . I T S PLACE=$P(^MAG(2005.2,T,0),U,10) ; <*>DCM--add anything?
91 S RET=RET_U_$S(BIG:"BIG",1:"FULL")_U_MODALITY_U_PLACE_U_DFN_U_FILNAM_U_USETGA_U_PROCDT_U_ACQSITE
92 Q RET
93 ;
94REMOTE(MAGIEN) ;Return list of remote Cache Locations
95 ; else, return "" if none
96 N RET,LOC
97 S RET=""
98 I $D(^MAG(2005,MAGIEN,4,"LOC")) S LOC=0 D
99 . F S LOC=$O(^MAG(2005,MAGIEN,4,"LOC",LOC)) Q:'LOC S RET=RET_$S(RET="":"",1:",")_LOC
100 Q RET
101 ;
102IMGINF2(RARPT,RET,USETGA) ; Fetch info from Image File for input RARPT:
103 ; Input: RARPT: Rad Report pointer
104 ; RET: see below
105 ; USETGA: 1/0 -- if 1, forces return of TGA (not .big) file
106 ; RET holds array of return values:
107 ; RET = # Images stored for the case
108 ; RET(1:n) = 1/0 ^ FULL/BIG ^ Mod ^ ien ^ Series ^ Routed-to Locations ^ PLACE ^ DFN ^ FileName (if OffLine) ^ PS_Indicator
109 ; (1=Image is on Magnetic Disk)
110 ; * This subroutine may be called by other VistARad routines
111 ;
112 N BIG,IMG,MAGIEN,MAGIEN2,MAGPTR,MAGINDX,MAGREF,NETLOC,SERIES,SERCT,SERPREV
113 K RET S RET=0,SERCT=0,SERPREV=""
114 S USETGA=+$G(USETGA) ; Defaults to Full-Resolution image if not defined
115 G IMGINF2Q:'RARPT S IMG=0
116 S MAGINDX="ADCM" ; maybe others will exist in the future
117 ; *P18--this index is defunct for P18 & beyond
118 ; however, keep for bkwds-compat P18 to P32; remove later
119 F S IMG=$O(^RARPT(RARPT,2005,IMG)) Q:'IMG S MAGIEN=$P(^(IMG,0),U) D
120 . S MAGREF=$NA(^MAG(2005,MAGIEN,1,MAGINDX))
121 . I 'MAGJOB("P32")!'$D(@MAGREF) D ; use group multiple structure
122 .. Q:'$D(^MAG(2005,MAGIEN,0)) S MAGPTR=0
123 .. I '$O(^MAG(2005,MAGIEN,1,MAGPTR)) D Q
124 ... S T=$$ONLCHK(MAGIEN,USETGA)
125 ... 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)
126 .. E F S MAGPTR=$O(^MAG(2005,MAGIEN,1,MAGPTR)) Q:'MAGPTR S MAGIEN2=$P(^(MAGPTR,0),U) D
127 ... S T=$$ONLCHK(MAGIEN2,USETGA)
128 ... 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)
129 . E I $D(@MAGREF) D ; use exam index, e.g., "ADCM"
130 .. F S MAGREF=$Q(@MAGREF) Q:($P(MAGREF,",",4)'=(""""_MAGINDX_"""")) D
131 ... S X=$L(MAGREF,","),MAGIEN2=$P(MAGREF,",",X-1),SERIES=$P(MAGREF,",",5)
132 ... S T=$$ONLCHK(MAGIEN2,USETGA)
133 ... S RET=RET+1,RET(RET)=$P(T,U,1,3)_U_MAGIEN2_U_SERIES_U_$$REMOTE(MAGIEN2)_U_$P(T,U,4,7)
134 ... I SERIES'=SERPREV S SERCT=SERCT+1,$P(RET("SER",SERCT),U,2)=SERIES,SERPREV=SERIES,RET("SER",0)=SERCT
135 ... S $P(RET("SER",SERCT),U)=RET("SER",SERCT)+1
136IMGINF2Q ;
137 Q
138 ;
139PSIND(MAGIEN) ; return Presentation State Indicator(s) for image
140 ; K=Key Image PStype; I=Interpretation PStyp; U=User PStyp
141 N RSL,IEN,X
142 S RSL="",IEN=0
143 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
144 Q:$Q RSL Q
145 ;
146JBFETCH(RARPT,MAGS,USETGA) ; fetch this case's images from Jukebox, if necessary
147 ; Input: RARPT: Rad Report pointer
148 ; MAGS: see below
149 ; USETGA: 1/0 -- if 1, forces return of TGA (not .big) file
150 ; This is a function that returns a string containing:
151 ; # Images fetched from JB ^ Total # Images for Case ^ # Low Res Imgs
152 ; The MAGS array will be returned to the calling
153 ; routine if MAGS is provided as an input parameter
154 ; MAGS is populated by call to IMGINF2.
155 ; IF any images are stored OffLine, then this node is set here:
156 ; MAGS("OFFLN",JBOFFLN)="" JBOFFLN = Platter ID from file 2006.033
157 ;
158 ; * This function may be called by other VistARad routines
159 ;
160 N MAGIEN,FETCH,IMAG,FILNAM,JBOFFLN,LORESCT
161 S USETGA=+$G(USETGA) ; Defaults to Full-Resolution image if not defined
162 S FETCH=0,LORESCT=0
163 D IMGINF2(RARPT,.MAGS,USETGA)
164 I MAGS F IMAG=1:1:MAGS S X=MAGS(IMAG) D
165 . I USETGA S LORESCT=LORESCT+$P(X,U,10)
166 . I '+X D ; Call params below depend on Consolidated Site status
167 .. S FILNAM=$P(X,U,9)
168 .. 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
169 .. I '$G(MAGJOB("CONSOLIDATED")) S X=$$JBTOHD^MAGBAPI($P(X,U,4)_"^"_$P(X,U,2)),FETCH=FETCH+1 ; pre-consolidation vs
170 .. E S X=$$JBTOHD^MAGBAPI($P(X,U,4)_"^"_$P(X,U,2),$P(X,U,7)),FETCH=FETCH+1
171 Q FETCH_U_MAGS_U_LORESCT
172 ;
173END Q ;
Note: See TracBrowser for help on using the repository browser.