source: FOIAVistA/trunk/r/IMAGING-MAG-ZMAG/MAGJLST1.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

File size: 7.7 KB
Line 
1MAGJLST1 ;WIRMFO/JHC VistARad RPC calls ; 29 Jul 2003 10:01 AM
2 ;;3.0;IMAGING;**16,22,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
20 ;
21 ; Subroutines for fetching Exam Info for Radiology Workstation
22 ; Exam listings:
23 ; PTLIST -- list subset of all exams for a patient
24 ; RPC Call: MAGJ PTRADEXAMS
25 ; PTLSTALL -- list ALL exams for a patient
26 ; RPC Call: MAGJ PT ALL EXAMS
27 ;
28 Q
29ERR N ERR S ERR=$$EC^%ZOSV S ^TMP($J,"RET",0)="0^4~"_ERR
30 S MAGGRY=$NA(^TMP($J,"RET"))
31 D @^%ZOSF("ERRTN")
32 Q:$Q 1 Q
33 ;
34PTLSTALL(MAGGRY,DATA) ; List ALL exams for a patient
35 ; RPC is MAGJ PT ALL EXAMS
36 N PARAM
37 I MAGJOB("P32") S PARAM="^99^999"
38 E S PARAM="^^^"_$P(DATA,U,2,3)
39 D PTLIST(.MAGGRY,$P(DATA,U)_PARAM)
40 Q
41 ;
42PTLIST(MAGGRY,DATA) ; get list of exams for a patient
43 ;
44 ; MAGGRY - indirect reference to return array of exams for a patient
45 ; DATA - DFN ^ LIMYEARS ^ LIMEXAMS ^ BEGDT ^ ONESHOT
46 ; DFN--Patient's DFN
47 ; LIMYRS--Restrict exams up to # Years back (defunct)
48 ; LIMEXAMS--Restrict exams up to # of exams
49 ; BEGDT--Begin date for exam fetch (Patch 18 addition--see below)
50 ; ONESHOT--Number days back to search, in one fell swoop
51 ; Returns data in ^TMP($J,"MAGRAEX",0:n)
52 ; RPC Call: MAGJ PTRADEXAMS
53 ;
54 ; Patch 18 eliminates "Patient Exams" / "All Patient Exams" distinction.
55 ; It always retrieves ALL exams, but uses multiple RPC calls, so the client
56 ; incrementally builds the list; this is to provide all the data, but without
57 ; incurring any long pauses to provide the info to the user.
58 ; Below, the P18 code fetches RAD data in one-year chunks, and repeats
59 ; until over 20 exams have been processed, at which point the RPC reply
60 ; is posted, along with the last date processed; this value is then used for
61 ; a subsequent RPC call to get the next chunk of the record; etc. till all done.
62 ; The P32 code is re-organized, and now exits only for LIMEXAMS (ignore LimYears)
63 ;
64 N CNT,DFN,ISS,PATNAME,DIQUIET,MAGRACNT,MAGRET,REPLY,REMOTE,SNDREMOT
65 N DAYCASE,DIV,EXCAT,MAGDT,XX,XX2,WHOLOCK,MODALITY,MYLOCK,PLACE,ENDLOOP
66 N LIMEXAMS,BEGDT,SAVBEGDT,ENDDT,MORE,SHOWPLAC,RDRIST,PSSN,CPT,PARAM
67 N CURPRIO,STATUS,RARPT,KEY,X2,REMOTE2,ONESHOT,LIMDAYS
68 N IMGCNT,LRFLAG,MSG,ONL,PROCMOD,RASTCAT,RASTORD
69 N $ETRAP,$ESTACK S $ETRAP="D ERR^MAGJLST1"
70 S DIQUIET=1 D DT^DICRW
71 S PARAM=$G(^MAG(2006.69,1,0))
72 S SNDREMOT=+$P(PARAM,U,11) ; Site routes images remotely?
73 I MAGJOB("P32") D
74 . S LIMEXAMS=+$P(PARAM,U,15)
75 . S:'LIMEXAMS LIMEXAMS=999 ; default to show ALL Exams
76 . I $P(DATA,U,3) S LIMEXAMS=+$P(DATA,U,3)
77 . I LIMEXAMS<20 S LIMEXAMS=20
78 . S BEGDT=""
79 E S BEGDT=$P(DATA,U,4),ONESHOT=$P(DATA,U,5) ; P65 chg
80 K MAGGRY S DFN=+DATA
81 S SHOWPLAC=$$SHOWPLAC^MAGJLS2B("")
82 S MAGRACNT=1,CNT=0 K ^TMP($J,"MAGRAEX"),^("MAGRAEX2")
83 S REPLY="0^4~Compiling list of Radiology Exams."
84 I DFN,$D(^DPT(DFN,0)) S PATNAME=$P(^(0),U),PSSN=$P(^(0),U,9) D
85 . S ENDLOOP=0,BEGDT=$S(+BEGDT:BEGDT,1:"")
86 . I MAGJOB("P32"),+$G(MAGJOB("P32STOP")) S REPLY="0^4~VistARad Patch 32 is no longer supported; contact Imaging Support for the current version of the VistARad client software." Q ; <*>
87 . F D Q:'MORE Q:ENDLOOP S BEGDT=MORE+1
88 . . I 'BEGDT S BEGDT=DT,X2=0
89 . . E S X2=-1
90 . . S LIMDAYS=365,MORE=1
91 . . I 'MAGJOB("P32") I ONESHOT,(ONESHOT>0) S LIMDAYS=+ONESHOT
92 . . S ENDDT=$$FMADD^XLFDT(BEGDT,X2)
93 . . S BEGDT=$$FMADD^XLFDT(ENDDT,-LIMDAYS)
94 . . D GETEXAM3^MAGJUTL1(DFN,BEGDT,ENDDT,.MAGRACNT,.MAGRET,.MORE)
95 . . I MAGJOB("P32") S ENDLOOP=(MAGRACNT>LIMEXAMS)
96 . . E S ENDLOOP=(MAGRACNT>20)!+ONESHOT ; For testing only, use >8
97 . I 'MORE S SAVBEGDT=0
98 . E S SAVBEGDT=MORE+1 ; adding 1 correctly inits value for subseqent call
99 . I MAGRACNT>1 D PTLOOP
100 E S REPLY="0^4~Invalid Radiology Patient"
101 I MAGRACNT<2 S:(REPLY["Compiling") REPLY="0^2~No Exams Found for "_PATNAME
102 I CNT!(REPLY["No Exams Found") D
103 . I 'MORE S MSG="ALL exams are listed."
104 . E S MORE=$$FMTE^XLFDT(MORE) S MSG="Patient has more exams on file."
105 . ; show SSN only if the user is a radiologist
106 . S X=+MAGJOB("USER",1) I '(X=12!(X=15)) S PSSN=""
107 . E S PSSN=" ("_$E(PSSN,1,3)_"-"_$E(PSSN,4,5)_"-"_$E(PSSN,6,9)_")"
108 . I CNT S REPLY=CNT_"^1~Radiology Exams for: "_PATNAME_PSSN_" -- "_MSG
109 . E S REPLY=REPLY_" -- "_MSG
110 . S ^TMP($J,"MAGRAEX2",1)="^Day/Case~S3~1^Lock~~2^Procedure~~6^Modifier~~25^Image Date/Time~S1~7^Status~~8^# Img~S2~9^Onl~~10"_$S($G(SNDREMOT):"^RC~~12",1:"")_$S(SHOWPLAC:"^Site~~23",1:"")_"^Mod~~15^Interp By~~20^Imaging Loc~~11^CPT~~27"
111 I MAGJOB("P32"),+$G(MAGJOB("P32STOP")) S ^TMP($J,"MAGRAEX2",1)="^^"
112 I 'MAGJOB("P32") S $P(REPLY,"|",2)=SAVBEGDT
113 S ^TMP($J,"MAGRAEX2",0)=REPLY
114 S MAGGRY=$NA(^TMP($J,"MAGRAEX2"))
115 K ^TMP($J,"RAE1"),^("MAGRAEX")
116 Q
117 ;
118PTLOOP ; loop through exam data & package it for VRAD use
119 S ISS=0
120 F S ISS=$O(^TMP($J,"MAGRAEX",ISS)) Q:'ISS S XX=^(ISS,1),XX2=^(2) D
121 . S CNT=CNT+1,RARPT=$P(XX,U,10)
122 . D IMGINFO^MAGJUTL2(RARPT,.Y)
123 . S IMGCNT=$P(Y,U),ONL=$P(Y,U,2),MAGDT=$P(Y,U,3),REMOTE=$P(Y,U,4),MODALITY=$P(Y,U,5),PLACE=$P(Y,U,6),KEY=$P(Y,U,7)
124 . S REMOTE2=REMOTE
125 . S:PLACE PLACE=$P($G(^MAG(2006.1,PLACE,0)),U,9)
126 . I PLACE]"",SHOWPLAC D
127 .. I SHOWPLAC'[(","_PLACE_",") S PLACE="" ; don't show user's logon pl ; <*> chg for p18?
128 . I SNDREMOT,REMOTE D
129 .. S T="" F I=1:1:$L(REMOTE,",") S T=T_$S(T="":"",1:",")_$P($G(^MAG(2005.2,$P(REMOTE,",",I),3)),U,5)
130 .. S REMOTE=T
131 . S DIV="",X=$P(XX2,U,5) I X'=DUZ(2) S DIV=$$STATN(X)
132 . I MAGDT="" S MAGDT=$P(XX,U,7)
133 . S MAGDT=$$FMTE^XLFDT(MAGDT,"5Z")
134 . S WHOLOCK=RARPT,MYLOCK="",DAYCASE=$P(XX,U,12)
135 . I WHOLOCK]"" S T=$$CHKLOCK^MAGJLS2B(WHOLOCK,DAYCASE),WHOLOCK=$P(T,U),MYLOCK=$P(T,U,2)
136 . S RDRIST=$P(XX2,U,3),PROCMOD=$P(XX2,U,8),CPT=$P(XX,U,17),RASTORD=$P(XX,U,15)
137 . S Y=U_DAYCASE_U_WHOLOCK_U_$E($P(XX,U,9),1,26)_U_PROCMOD_U_MAGDT_U_$E($P(XX,U,14),1,16)_U_IMGCNT_U_ONL
138 . I $G(SNDREMOT) S Y=Y_U_REMOTE
139 . S Y=Y_$S(SHOWPLAC:U_PLACE,1:"")_U_MODALITY_U_RDRIST_U_$E($P(XX,U,13),1,11)_U_CPT
140 . S STATUS=$P(XX,U,11),EXCAT="",CURPRIO=0,RASTCAT=$P(XX2,U,11),LRFLAG=$P(XX2,U,12)
141 . I STATUS]"" D
142 . . S EXCAT=RASTCAT
143 . . I RASTORD<2!(EXCAT="W")!('IMGCNT) S CURPRIO=0 ; Cancelled/Waiting/No images: Ignore exam
144 . . E I EXCAT="E" S CURPRIO=1 ; Examined="Current" exam
145 . . E S CURPRIO=2 ; must be a "prior" exam
146 . . I CURPRIO,'(ONL="Y") S CURPRIO=3 ; images on jukebox
147 . . I MAGJOB("P32"),'(EXCAT="E") S EXCAT="" Q ; P32 compat.
148 . . I RASTORD=9 S EXCAT="C" ; Complete
149 . . E I EXCAT="D"!(EXCAT="T") S EXCAT="I" ; just display one value meaning Interpreted
150 . S ^TMP($J,"MAGRAEX2",ISS)=Y_"^|"_$P(XX,U,1,3)_U_RARPT_"||"_EXCAT_U_WHOLOCK_U_MYLOCK_U_MODALITY_U_CPT_U_CURPRIO_U_RARPT_U_KEY_U_REMOTE2_U_LRFLAG
151 . ; * Note: Keep Pipe-pieces in sync with svmag2a^magjls3 & lstout^magjls2b *
152 Q
153 ;
154STATN(X) ; get station #, else return input value
155 N T
156 I X]"" D GETS^DIQ(4,X,99,"E","T") S T=$G(T(4,X_",",99,"E")) I T]"" S X=T
157 Q X
158 ;
159END Q ;
Note: See TracBrowser for help on using the repository browser.