source: FOIAVistA/tag/r/IMAGING-MAG-ZMAG/MAGJEX3.m@ 1779

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

initial load of FOIAVistA 6/30/08 version

File size: 7.5 KB
Line 
1MAGJEX3 ;WIRMFO/JHC VistaRad RPCs-Get PS & KEY Img data ; 1 Nov 2004 10:05 AM
2 ;;3.0;IMAGING;**18**;Mar 07, 2006
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 ;; | |
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
19ERR N ERR S ERR=$$EC^%ZOSV S @MAGGRY@(0)="0^4~"_ERR
20 D @^%ZOSF("ERRTN")
21 Q:$Q 1 Q
22 ;
23RPCIN(MAGGRY,PARAMS,DATA) ; RPC: MAGJ STUDY_DATA
24 ; Retrieve Key Image and/or Presentation State data for an Exam
25 ; PARAMS--TXID ^ DFN ^ DTI ^ CNI ^ RARPT ^ MAGIEN ^ PSDETAIL
26 ; TXID: Required; designates action to take:
27 ; 1 -- Key Image only
28 ; 2 -- Interp Images only
29 ; 3 -- Key and Interp Images
30 ; 4 -- PS data for input (in DATA): ImgIEN & PS_UID or PS_Indicators
31 ;
32 ; For TXID 1, 2, 3 either RARPT or MAGIEN is required to identify the exam
33 ; PSDETAIL--1/0; 1=Include PS data for above
34 ; RARPT--Rad report pointer; IMGIEN--can be Image or Group IEN
35 ; DATA--required for TXID=4 --array of input DATA: IMGIEN ^ [PSUID] ^ [PSIND]
36 ; If both PSUID and PSIND appear, the PSIND is IGNORED
37 ;
38 ; Results returned in @MAGGRY
39 ;
40 N $ETRAP,$ESTACK S $ETRAP="D ERR^MAGJEX3"
41 N REPLY,MAGLST,DIQUIET,TXID,RARPT,MAGIEN,STIEN,IMGIEN,PSUID,PSIND
42 N PSDETAIL,COUNTS,IMGCT,KEYCT,PSCT,INTCT,STRPT,KEYINT,PSLS,CT
43 S MAGLST="MAGJRPC" K MAGGRY S MAGGRY=$NA(^TMP($J,MAGLST)) K @MAGGRY
44 ; Note--return data is stored with indirection references to MAGGRY
45 S DIQUIET=1 D DT^DICRW
46 S TXID=+PARAMS,STRPT=""
47 I '(TXID>0&(TXID<5)) S REPLY="0~Invalid transaction (TX="_TXID_") requested by MAGJ STUDYDATA rpc call." G RPCINZ
48 S RARPT=$P(PARAMS,U,5),MAGIEN=$P(PARAMS,U,6),PSDETAIL=+$P(PARAMS,U,7)
49 S CT=0,PSCT=0
50 I TXID<4 D G RPCINZ
51 . S STIEN=$$STUDYID^MAGJUPD2(MAGIEN,RARPT,1)
52 . S STRPT=$S(RARPT:RARPT,1:$P($$GETRPT^MAGJUPD2(MAGIEN),U))
53 . I TXID=3 S KEYINT="KI" ; Key & Interp Images
54 . E I TXID=1 S KEYINT="K" ; Key Images
55 . E I TXID=2 S KEYINT="I" ; Interp Images
56 . D GETDAT("PSLS",STIEN,KEYINT)
57 . D GETKEY("@MAGGRY",.CT,PSDETAIL,.COUNTS)
58 . S IMGCT=+COUNTS,KEYCT=+$P(COUNTS,U,2),INTCT=+$P(COUNTS,U,3),PSCT=+$P(COUNTS,U,4)
59 . I 'KEYCT,'INTCT S REPLY="1~No Key/Interpretation Images defined for exam." Q
60 . S REPLY=1_"~: "
61 . S REPLY=REPLY_PSCT_" PS def"_$S(PSCT-1:"s",1:"")_" for "
62 . S REPLY=REPLY_KEYCT_" Key Image"_$S(KEYCT-1:"s",1:"")_"; "_INTCT_" Interpretation Image"_$S(INTCT-1:"s",1:"")_"; "_IMGCT_" Image"_$S(IMGCT-1:"s",1:"")_" checked."
63 ;
64 I TXID=4 D ; PS data for input ImgIEN & PS_UID or PS_Inds
65 . S IDATA="",IMGCT=0
66 . F S IDATA=$O(DATA(IDATA)) Q:IDATA="" S X=DATA(IDATA) I X]"" D
67 . . S IMGIEN=$P(X,U),PSUID=$P(X,U,2),PSIND=$P(X,U,3),IMGCT=IMGCT+1,COUNTS=0
68 . . I PSUID]"" S PSIND="" ; ignore psind if uid is supplied
69 . . I 'STRPT S STRPT=$P($$GETRPT^MAGJUPD2(IMGIEN),U)
70 . . E I STRPT'=$P($$GETRPT^MAGJUPD2(IMGIEN),U) Q ; don't intermix diff. studies, but continue
71 . . I '((PSUID]""!(PSIND]""))&IMGIEN) S REPLY="0~For MAGJ STUDYDATA (TX="_TXID_") invalid params passed to rpc call." Q
72 . . I PSUID]"" D GETPSID1("@MAGGRY",.CT,IMGIEN,PSUID,.COUNTS)
73 . . E I PSIND]"" D GETPSID2("@MAGGRY",.CT,IMGIEN,PSIND,.COUNTS)
74 . . S PSCT=PSCT+COUNTS
75 . . S REPLY=1_"~: "_PSCT_" PS def"_$S(PSCT-1:"s",1:"")_" for "_IMGCT_" Image"_$S(IMGCT-1:"s",1:"")_" checked."
76RPCINZ S @MAGGRY@(0)=CT_U_REPLY
77 Q
78 ;
79GETKEY(RET,CT,PSFLAG,COUNTS) ; Get Key images for study STIEN w/ PS refs
80 ; Results returned by indirection in array @RET, indexed by CT
81 ; if PSFLAG is true, return Pres State data
82 ; COUNTS contains ^-delim list of various counts (see below)
83 ;
84 N IMGIEN,UID,IMGCT,KEYCT,PSCT,INTCT,TYPE,IMGTRAK,LASTIMG,QREF
85 S CT=+$G(CT),PSFLAG=+$G(PSFLAG),(IMGCT,KEYCT,PSCT,INTCT)=0
86 I 'STIEN G GETKEYZ
87 S QREF="PSLS",LASTIMG=0
88 F S QREF=$Q(@QREF) Q:QREF="" S X=@QREF D
89 . S IMGIEN=+X,UID=$P(X,U,2),TYPE=$P(X,U,3)
90 . I IMGIEN'=LASTIMG D
91 . . I LASTIMG S CT=CT+1,@RET@(CT)="*END_IMAGE"
92 . . S CT=CT+1,@RET@(CT)="*IMAGE"
93 . . S CT=CT+1,@RET@(CT)=IMGIEN_U
94 . . S LASTIMG=IMGIEN S IMGCT=IMGCT+'$D(IMGTRAK(IMGIEN)),IMGTRAK(IMGIEN)=""
95 . Q:UID=""
96 . S CT=CT+1,@RET@(CT)="*PS",PSCT=PSCT+1
97 . S CT=CT+1,@RET@(CT)=UID_U_$S(TYPE="K":"KEY",TYPE="I":"INTERP",1:TYPE)
98 . I PSFLAG D GETPSDAT(.RET,.CT,IMGIEN,UID)
99 . S CT=CT+1,@RET@(CT)="*END_PS"
100 . I TYPE="K" S KEYCT=KEYCT+1
101 . I TYPE="I" S INTCT=INTCT+1
102 I LASTIMG S CT=CT+1,@RET@(CT)="*END_IMAGE"
103GETKEYZ S COUNTS=IMGCT_U_KEYCT_U_INTCT_U_PSCT
104 Q
105 ;
106 ;
107GETDAT(RET,STIEN,KEYINT) ; Get data for Key Interp images for study STIEN
108 ; Results returned by indirection in array @RET
109 N IMGIEN,UID,KIEN,PSIEN,STUDYREF,PSCT,TYPE,SEQNUM
110 S PSCT=0
111 I 'STIEN G GETDATZ
112 S STUDYREF=$NA(^MAG(2005.001,STIEN))
113 S KIEN=0
114 F S KIEN=$O(@STUDYREF@(1,KIEN)) Q:'KIEN S IMGIEN=$P($G(^(KIEN,0)),U),PSIEN=0 D
115 . F S PSIEN=$O(@STUDYREF@(1,KIEN,1,PSIEN)) Q:'PSIEN S X=$G(^(PSIEN,0)) D
116 . . S UID=$P(X,U),TYPE=$P(X,U,2),SEQNUM=$P(X,U,3),PSCT=PSCT+1
117 . . I UID]"" S:TYPE="" TYPE="I" S:SEQNUM="" SEQNUM=PSCT+10000
118 . . E Q
119 . . I TYPE="K",(KEYINT[TYPE) S @RET@(TYPE,SEQNUM,IMGIEN)=IMGIEN_U_UID_U_TYPE
120 . . I TYPE="I",(KEYINT[TYPE) S @RET@(TYPE,IMGIEN,SEQNUM)=IMGIEN_U_UID_U_TYPE
121GETDATZ Q
122 ;
123 ;
124GETPSDAT(RET,CT,IMGIEN,UID) ; Get PS text lines for input IMGIEN & UID
125 ; Results returned by indirection in array @RET, indexed by CT
126 ;
127 N IMGREF,UIDIEN,IEN
128 S CT=+$G(CT),UID=$G(UID)
129 I '(UID]""&IMGIEN) G GETPSDAZ
130 S IMGREF=$NA(^MAG(2005,IMGIEN))
131 S UIDIEN=$O(@IMGREF@(210,"B",UID,"")) Q:'UIDIEN S IEN=0 D
132 . F S IEN=$O(@IMGREF@(210,UIDIEN,1,IEN)) Q:'IEN S CT=CT+1,@RET@(CT)=^(IEN,0)
133GETPSDAZ Q
134 ;
135GETPSID1(RET,CT,IMGIEN,PSUID,HIT) ; For input IMGIEN & PSUID, return PS data
136 ; Results returned by indirection in array @RET, indexed by CT
137 ; HIT=1 if the image has a PS_UID stored
138 N X,TYP,IEN
139 S CT=+$G(CT),HIT=0
140 I '(PSUID]""&IMGIEN) G GETPSI1Z
141 S IMGREF=$NA(^MAG(2005,IMGIEN))
142 S IEN=$O(@IMGREF@(210,"B",PSUID,"")) I 'IEN G GETPSI1Z
143 S TYP=$P(@IMGREF@(210,IEN,0),U,2)
144 S CT=CT+1,@RET@(CT)="*IMAGE",HIT=1
145 S CT=CT+1,@RET@(CT)=IMGIEN_U
146 S CT=CT+1,@RET@(CT)="*PS"
147 S CT=CT+1,@RET@(CT)=PSUID_U_$S(TYP="K":"KEY",TYP="I":"INTERP",1:TYP)
148 D GETPSDAT(.RET,.CT,IMGIEN,PSUID)
149 S CT=CT+1,@RET@(CT)="*END_PS"
150 S CT=CT+1,@RET@(CT)="*END_IMAGE"
151GETPSI1Z Q
152 ;
153GETPSID2(RET,CT,IMGIEN,PSIND,HIT) ; For input IMGIEN & PSIND, return PS data
154 ; Results returned by indirection in array @RET, indexed by CT
155 ; HIT= incremented for each image with a PS stored for input psind
156 N X,TYP,IEN
157 S CT=+$G(CT),HIT=0
158 I '(PSIND]""&IMGIEN) G GETPSI2Z
159 S IMGREF=$NA(^MAG(2005,IMGIEN)),IEN=0
160 F S IEN=$O(@IMGREF@(210,IEN)) Q:'IEN S X=^(IEN,0),PSUID=$P(X,U),TYP=$P(X,U,2) I PSIND[TYP D
161 . I 'HIT D
162 . . S CT=CT+1,@RET@(CT)="*IMAGE"
163 . . S CT=CT+1,@RET@(CT)=IMGIEN_U
164 . S CT=CT+1,@RET@(CT)="*PS"
165 . S CT=CT+1,@RET@(CT)=PSUID_U_$S(TYP="K":"KEY",TYP="I":"INTERP",1:TYP)
166 . S HIT=HIT+1
167 . D GETPSDAT(.RET,.CT,IMGIEN,PSUID)
168 . S CT=CT+1,@RET@(CT)="*END_PS"
169 I HIT S CT=CT+1,@RET@(CT)="*END_IMAGE"
170GETPSI2Z Q
171 ;
172END ;
Note: See TracBrowser for help on using the repository browser.