source: WorldVistAEHR/trunk/r/IMAGING-MAG-ZMAG/MAGJEX1.m@ 1361

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

initial load of WorldVistAEHR

File size: 9.5 KB
Line 
1MAGJEX1 ;WIRMFO/JHC VistARad RPC calls ; 29 Jul 2003 9:56 AM
2 ;;3.0;IMAGING;**16,22,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
20 ; Entry Points:
21 ; OPENCASE--RPC: Open Exam
22 ;
23ERR N ERR S ERR=$$EC^%ZOSV S @MAGGRY@(0)="0^4~"_ERR
24 D @^%ZOSF("ERRTN")
25 Q:$Q 1 Q
26 ;
27OPENCASE(MAGGRY,DATA) ; RPC Call: MAGJ RADCASEIMAGES
28 ; MAGGRY holds $NA reference to ^TMP for rpc return
29 ; all ref's to MAGGRY use subscript indirection
30 ; input in DATA:
31 ; OPEN_FLAG^RADFN^RADTI^RACNI^RARPT^SERDISA^STK/LAY^USETGA
32 ; OPEN_FLAG = 1/0 - 1: OPEN the case for update; else, view-only
33 ; = /2 2: Reserve for Interp ; * P18
34 ; RADFN^RADTI^RACNI specify case of interest
35 ; SERDISA = 1/0 - Disable Mult Series processing if true * n/a for P18
36 ; STK/LAY = 1/0 - 1:Open in Stack; 0:Open in Layout * n/a for P18
37 ; USETGA = 1/0 - 1:Open .TGA file; 0:Open .BIG file
38 ;
39 ; * In P18, the SERDISA position is re-cycled to pass in PS_Indicator_Type values of interest
40 ; K/I/U for Key Image/ Interpretation/ User PS types; used in IMGLOOP^MAGJEX1B
41 ;
42 N $ETRAP,$ESTACK S $ETRAP="D ERR^MAGJEX1"
43 N RARPT,RADFN,RADTI,RACNI,RADIV
44 N DAYCASE,CURCASE,REPLY,CT,MAGS,STARTNOD,LOCKED,DATAOUT,RADATA,RIST,MDL
45 N IMAG,MAGXX,MAGFILE,MAGFILE1,MAGFILE2,MAGFILE3,MAGLST,MAGOBJT,MODALITY
46 N SERDISA,MAGSTRT,MAGEND,SERLBL,SERBRK,SERLIM,NSERIES,ALTPATH,CURPATHS
47 N MIXEDUP,VIEWOK,STKLAY,USETGA,OPENCNT,USELORES,IMGST,REMOTE,DIQUIET
48 N LOGDATA,MODIF,EXCAT,RADATA2,PSIND,RASTCAT,RASTORD,PROCDT,ACQSITE
49 S DIQUIET=1 D DT^DICRW
50 S CT=0,MODALITY="",DATAOUT="",DAYCASE="",MAGLST="MAGJOPENCASE",ALTPATH=""
51 S MIXEDUP=0,VIEWOK=1,OPENCNT=1,PROCDT="",ACQSITE=""
52 K MAGGRY S MAGGRY=$NA(^TMP($J,MAGLST)),STARTNOD=0 K @MAGGRY ; assign MAGGRY value
53 S CURCASE=$P(DATA,U),RARPT=+$P(DATA,U,5),SERDISA=+$P(DATA,U,6)
54 I 'MAGJOB("P32") S PSIND="",X=$P(DATA,U,6) I X]"" F I="K","I","U" I $F(X,I) S PSIND(I)=""
55 S STKLAY=+$P(DATA,U,7),USETGA=+$P(DATA,U,8)
56 S RADFN=$P(DATA,U,2),RADTI=$P(DATA,U,3),RACNI=$P(DATA,U,4)
57 I RADFN,RADTI,RACNI D GETEXAM2^MAGJUTL1(RADFN,RADTI,RACNI,"",.X)
58 I 'X S REPLY="4~Request Contains Invalid Case Pointer ("_RADFN_U_RADTI_U_RACNI_U_RARPT_")." G OPENCASZ
59 S RADATA=$G(^TMP($J,"MAGRAEX",1,1)),RADATA2=$G(^(2))
60 K ^TMP($J,"MAGRAEX")
61 S RADIV=$P(RADATA2,U,5),MODIF=$P(RADATA2,U,8),RASTCAT=$P(RADATA2,U,11),RASTORD=$P(RADATA,U,15)
62 S RARPT=+$P(RADATA,U,10),DAYCASE=$P(RADATA,U,12)
63 I 'RARPT!'$D(^RARPT(RARPT,2005)) S REPLY="4~This exam has no report entry for associating images; no images can be accessed." G OPENCASZ
64 D CKINTEG^MAGJRPT(.X,RADFN,RADTI,RACNI,RARPT,RADATA)
65 I X]"" S MIXEDUP=1,MIXEDUP("REPLY")=X ; DB corruption
66 S REPLY="4~Attempting to open/display case #"_DAYCASE
67 S IMGST=$$JBFETCH^MAGJUTL2(RARPT,.MAGS,USETGA) ; open only if NOT on JB
68 I +IMGST D G OPENCASZ
69 . I $D(MAGS("OFFLN")) N T,TT S T="",TT="" D
70 .. F S T=$O(MAGS("OFFLN",T)) Q:T="" S TT=TT_$S(TT="":"",1:", ")_T
71 .. S REPLY="2~Case #"_DAYCASE_"--Images for this exam are stored OFF-LINE. To view these images, contact your Imaging Coordinator, and request mounting of the following platters: "_TT
72 . E S REPLY="2~Case #"_DAYCASE_"--"_+IMGST_" Images have been requested from Jukebox; try again later."
73 I '$P(IMGST,U,2) S REPLY="2~No Images exist for Case #"_DAYCASE_"." G OPENCASZ
74 S USELORES=+$P(IMGST,U,3)_U_$P(IMGST,U,2)
75 ; set up series info (*back compat for P32)
76 I (STKLAY&SERDISA)!'MAGJOB("P32") S STKLAY=3 ; disable series in Stacker or post-patch 32
77 N SERHI S SERHI=$G(MAGS("SER",0))
78 K SERBRK
79 I SERHI>1,$P($G(^MAG(2006.69,1,0)),U,12) D ; Process for mult. Series
80 . Q:SERDISA ; user disabled from w/s
81 . Q:STKLAY ; Don't do this for Stacker
82 . N SERCT,SERSTR I '$D(SERLIM) S SERLIM=5 ; min size for a series
83 . S SERSTR="",SERCT=0,SERBRK(0)=0
84 . ; step 1: roll up "small" series at the bottom to next higher ones
85 . F Q:(MAGS("SER",SERHI)'<SERLIM)!(SERHI=1) D
86 .. S X=MAGS("SER",SERHI),Y=MAGS("SER",SERHI-1),Y=Y+X_U_$P(Y,U,2)_", "_$P(X,U,2)
87 .. S SERHI=SERHI-1,MAGS("SER",SERHI)=Y
88 . I SERHI<2 K SERBRK Q ; no "real" series to enumerate
89 . ; step 2: from top, fold "small" series into next lower ones
90 . F I=1:1:SERHI S X=MAGS("SER",I),SERCT=SERCT+X D
91 .. I +X'<SERLIM S SERBRK(SERCT)=SERSTR_$S(SERSTR="":"",1:", ")_$P(X,U,2),SERSTR="",SERBRK(0)=SERBRK(0)+1
92 .. E S SERSTR=SERSTR_$S(SERSTR="":"",1:", ")_$P(X,U,2)
93 . I '$D(SERBRK(SERCT)) S SERBRK(SERCT)=SERSTR,SERBRK(0)=SERBRK(0)+1
94 . I SERBRK(SERCT)<2 K SERBRK ; only one "series" resulted
95 I $D(SERBRK) S SERBRK=0,NSERIES=SERBRK(0) D
96 . F S MAGSTRT=SERBRK+1,SERBRK=$O(SERBRK(SERBRK)) Q:'SERBRK S MAGEND=SERBRK,SERLBL="*S^Series "_SERBRK(SERBRK) D IMGLOOP^MAGJEX1B
97 E S MAGSTRT=1,MAGEND=MAGS,NSERIES=1 D IMGLOOP^MAGJEX1B
98 I ACQSITE="" S ACQSITE=RADIV
99 S REPLY="0~Images for Case #"_DAYCASE
100 ;
101OPENCASZ I 'CT,(REPLY["Attempting") S REPLY="4~Unable to retrieve images for Case #"_DAYCASE_"."
102 ;
103 ; Contents of successful reply = 4 pipe ("|") pieces:
104 ;1: # nodes below ^ Reply Msg Type ~ Reply Msg display text
105 ;2: Exam ID String (= radfn^radti^racni^rarpt)
106 ;3: Pt Name ^ CASE # ^ # Images ^ Proc. Name ^ Exam Date ^ Time ^
107 ; modality ^ SSN ^ Stack/Layout ^ LOCKED? (1/2/0) [^ if only 1 series]
108 ;4: Is Radiologist? ^ # Series ^ Alt_Path Flag ^ Opened Exam Count?
109 ;
110 S REMOTE=+MAGJOB("REMOTE")
111 S LOCKED=0
112 I MIXEDUP D
113 . N IMIX,XDFN,XPTS S VIEWOK=$S($D(MAGJOB("KEYS","MAGJ SEE BAD IMAGES")):1,1:0)
114 . I MIXEDUP>1 D
115 .. S XPTS="",XDFN=0 F IMIX=0:1 S XDFN=$O(MIXEDUP(XDFN)) Q:'XDFN S XPTS=XPTS_$S(IMIX:" and ",1:" ")_$$PNAM(XDFN)
116 .. S XPTS=$S(IMIX=1:" ",1:"s ")_XPTS
117 .. S REPLY=(7-VIEWOK)_"~This exam is registered for "_$$PNAM(RADFN)_"; however, it is linked to images for patient"_XPTS_". This is a serious problem--immediately report it to Radiology management and Imaging support staff!"
118 . E S REPLY=(7-VIEWOK)_"~"_MIXEDUP("REPLY")
119 . I CURCASE S REPLY=REPLY_" The exam is NOT Locked." S CURCASE=0
120 I CT D
121 . S RIST=$S(+MAGJOB("USER",1):1,1:0),EXCAT=""
122 . S LOGDATA=RADFN_U_+$P(MAGS(1),U,4)_U_+MAGS_U_REMOTE ; for Img Access log
123 . I CURCASE D
124 . . I $G(MAGJOB("CONSOLIDATED")),'$D(MAGJOB("DIVSCRN",RADIV)) D S CURCASE=0 Q
125 . . . S REPLY="5~Exam is for Station #"_$$STATN(RADIV)_"; you are logged on to #"_$$STATN(DUZ(2))_". Exam is NOT Locked."
126 . . S XX=$P(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0),U,3)
127 . . I '$D(^RA(72,"AVC","E",XX)) D S CURCASE=0 Q
128 . . . I 'MAGJOB("P32") D
129 . . . . D LOCKACT^MAGJEX1A(RARPT,DAYCASE,100,.RESULT) ; between reserve and now, exam may have been Taken & Updated
130 . . . . I +RESULT(1)!+RESULT(2) D LOCKACT^MAGJEX1A(RARPT,DAYCASE,101,.RESULT) ; so, cancel any lock/reserve
131 . . . S REPLY="5~For Case #"_DAYCASE_", current Status is "_$P(^RA(72,XX,0),U)_"; Lock or Reserve NOT allowed."
132 . . E S EXCAT="E"
133 . . I RIST,'USELORES D ; lock only for Current Case, Radiologist, & Full Res images
134 . . . ; save data needed to later log Interpreted event
135 . . . D LOCKACT^MAGJEX1A(RARPT,DAYCASE,CURCASE,.RESULT,.REPLY,LOGDATA)
136 . . . S LOCKED=$S(+RESULT:1,+$P(RESULT,U,2):2,1:0)
137 . I EXCAT="" D
138 . . I RASTORD=9 S EXCAT="C" Q ; Complete
139 . . E S EXCAT=RASTCAT
140 . . I EXCAT="D"!(EXCAT="T") S EXCAT="I" ; just display one value meaning Interpreted
141 . I MAGJOB("P32") S DATAOUT=$P(RADATA,U,4)_U_DAYCASE_" ("_EXCAT_")"_U_$P(RADATA,U,9)
142 . E S DATAOUT=$P(RADATA,U,4)_U_DAYCASE_U_$P(RADATA,U,9)
143 . S X=$P(RADATA,U,6),T=$L(X," "),X=$P(X," ",1,T-1)_U_$P(X," ",T)
144 . S DATAOUT=DATAOUT_U_X
145 . S DATAOUT=DATAOUT_U_MODALITY_U_$P(RADATA,U,5)_U_STKLAY_U_LOCKED
146 . I MAGJOB("P32") D
147 . . S DATAOUT=DATAOUT_$S(NSERIES>1:"",1:U)
148 . . S DATAOUT=DATAOUT_"|"_RIST_U_NSERIES_U_ALTPATH_U_OPENCNT
149 . E S DATAOUT=DATAOUT_U_MODIF_U_EXCAT_U_"|"_RIST_U_ALTPATH_U_ACQSITE_U_PROCDT
150 . I USELORES D
151 . . I +USELORES=+$P(USELORES,U,2) S X="All"
152 . . E S X=+USELORES_" of "_+$P(USELORES,U,2)
153 . . I $E(REPLY,1,8)="0~Images" S REPLY="3~"
154 . . E S REPLY=REPLY_" -- "
155 . . S REPLY=REPLY_"Note: "_X_" images for Case #"_DAYCASE_" are REDUCED RESOLUTION images, using parameters set by your site Imaging Manager; to view full-resolution images, disable the Reduced Resolution option setting. Exam NOT Locked."
156 S @MAGGRY@(STARTNOD)=CT_U_REPLY_"|"_RADFN_U_RADTI_U_RACNI_U_RARPT_"|"_DATAOUT
157 ; if mixedup & not have keys to see images, delete image refs
158 ; & send only reply msg
159 I MIXEDUP,('VIEWOK) S CT=0 K @MAGGRY S @MAGGRY@(0)=CT_U_REPLY
160 E S $P(@MAGGRY@(0),U)=CT+STARTNOD
161 I CT,(LOCKED'=2) D LOG^MAGJUTL3("VR-VW",LOGDATA) ; Image access log
162 Q
163 ;
164PNAM(X) ; return pt name for input DFN
165 I X S X=$G(^DPT(+X,0)) I X]"" S X=$P(X,U)
166 E S X="UNKNOWN"
167 Q X
168 ;
169STATN(X) ; get station #, else return input value
170 N T
171 I X]"" D GETS^DIQ(4,X,99,"","T") S T=$G(T(4,X_",",99,"E")) I T]"" S X=T
172 Q X
173 ;
174END Q ;
175 ;
Note: See TracBrowser for help on using the repository browser.