MAGJEX1 ;WIRMFO/JHC,ISI/JL - VistARad RPC calls ; 10/17/2022
;;3.0;IMAGING;**16,22,18,65,101,115,104,120,133,341**;Dec 21, 2022;Build 28
;; Per VHA Directive 2004-038, this routine should not be modified.
;; +---------------------------------------------------------------+
;; | Property of the US Government. |
;; | No permission to copy or redistribute this software is given. |
;; | Use of unreleased versions of this software requires the user |
;; | to execute a written test agreement with the VistA Imaging |
;; | Development Office of the Department of Veterans Affairs, |
;; | telephone (301) 734-0100. |
;; | The Food and Drug Administration classifies this software as |
;; | a medical device. As such, it may not be changed in any way. |
;; | Modifications to this software may result in an adulterated |
;; | medical device under 21CFR820, the use of which is considered |
;; | to be a violation of US Federal Statutes. |
;; +---------------------------------------------------------------+
;;
; Reference to EN2^RAUTL20 in ICR #3270
;; ISI IMAGING;**99,101**
Q
;
;
ERR N ERR S ERR=$$EC^%ZOSV S @MAGGRY@(0)="0^4~"_ERR
D @^%ZOSF("ERRTN")
Q:$Q 1 Q
;
;***** Open an exam.
; RPC: MAGJ RADCASEIMAGES
;
OPENCASE(MAGGRY,DATA) ;
; MAGGRY holds $NA reference to ^TMP for rpc return
; all ref's to MAGGRY use subscript indirection
; input in DATA:
; OPEN_FLAG ^ RADFN^RADTI^RACNI^RARPT ^ PSINDGET ^ <unused> ^ USETGA (forced to zero) ; ISI
; OPEN_FLAG = 0: Open, view only
; 1: Open, lock the case for status update
; 2: Open, Reserve for Interpretation
; VIX: Fetching metadata only; Jukebox retrieval occurs (P115 & earlier)
; VIX-Metadata: Fetching metadata only; no JB Retrieval (P104,ff)
; VIX-Open: Fetching metadata with JB Retrieval (P104,ff)
; RADFN^RADTI^RACNI^RARPT = Exam ID string, specifies case of interest
; PSINDGET= Presentation State indicators of interest to client
; K/I/U for Key Image/ Interpretation/ User PS types
; USETGA = hard-code to "0": Open BIG file ; ISI remove support for downsampled image fetch
;
; Details of Reply message are below tag OPENCASZ
;
N $ETRAP,$ESTACK S $ETRAP="D ERR^MAGJEX1"
N RARPT,RADFN,RADTI,RACNI,RADIV
N DAYCASE,CURCASE,REPLY,CT,MAGS,STARTNOD,LOCKED,DATAOUT,RADATA,RIST,MDL
N IMAG,MAGXX,MAGFILE,MAGFILE1,MAGFILE2,MAGFILE3,MAGLST,MAGOBJT,MODALITY
N MAGSTRT,MAGEND,CURPATHS
N MIXEDUP,VIEWOK,USETGA,USELORES,IMGST,REMOTE,DIQUIET
N LOGDATA,MODIF,EXCAT,RADATA2,PSIND,RACPT,RASTCAT,RASTORD,ACQSITE,ALTPATH,PROCDT
N YNMAMMO,YNREVANN,PSINDGET,JBDISABLE,STANUM
N ASIGDUZ,ASIGRIST,ASIGREPL,RADATA9,PLACE ; ISI
S DIQUIET=1 D DT^DICRW
S (CT,MIXEDUP)=0,MODALITY="",DATAOUT="",DAYCASE="",MAGLST="MAGJOPENCASE",(ACQSITE,ALTPATH,PROCDT,STANUM)=""
S VIEWOK=1
K MAGGRY S MAGGRY=$NA(^TMP($J,MAGLST)),STARTNOD=0 K @MAGGRY ; assign MAGGRY value
S CURCASE=$P(DATA,U),RARPT=+$P(DATA,U,5),PSINDGET=+$P(DATA,U,6)
S PSIND="" I PSINDGET]"" F I="K","I","U" I $F(PSINDGET,I) S PSIND(I)=""
S USETGA=0 ; ISI hard-code to "0"
S RADFN=$P(DATA,U,2),RADTI=$P(DATA,U,3),RACNI=$P(DATA,U,4)
I RADFN,RADTI,RACNI D GETEXAM2^MAGJUTL1(RADFN,RADTI,RACNI,"",.X)
I 'X S REPLY="4~Request Contains Invalid Case Pointer ("_RADFN_U_RADTI_U_RACNI_U_RARPT_")." G OPENCASZ
S RADATA=$G(^TMP($J,"MAGRAEX",1,1)),RADATA2=$G(^(2)),RADATA9=$G(^("ISI")) ; ISI
K ^TMP($J,"MAGRAEX")
S RADIV=$P(RADATA2,U,5),MODIF=$P(RADATA2,U,8),RASTCAT=$P(RADATA2,U,11),RASTORD=$P(RADATA,U,15)
S PLACE=$P(RADATA2,U,6) ; ISI
S RARPT=+$P(RADATA,U,10),DAYCASE=$P(RADATA,U,12),RACPT=$P(RADATA,U,17)
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
D CKINTEG^MAGJRPT(.X,RADFN,RADTI,RACNI,RARPT,RADATA)
I X]"" S MIXEDUP=1,MIXEDUP("REPLY")=X ; DB corruption
; ISI begin ...
S ASIGDUZ=+$P(RADATA9,U,3),ASIGRIST=0,ASIGREPL=0 ; ISI
I ASIGDUZ D
. F X="S","R" I $D(^VA(200,"ARC",X,ASIGDUZ)) S ASIGRIST=1 Q
; check if an assignment conflict exists for current user:
; exam is lockable (curcase = 1 or 2); if a rist is attempting to open, & exam is assigned, then block:
; Rist vs Tech has Assign? tech: allow View/Cancel; Rist: View/Override/Cancel
; Note that reply code 10 is a special value, used ONLY to enable the Assign over-ride for a rist
I CURCASE,'$$ASIGME^ISIJUTL1(ASIGDUZ) I CURCASE'=11 D G OPENCASZ:'(+REPLY=5) S CURCASE=0,ASIGREPL=1
. I ASIGRIST,(CURCASE=1) S REPLY="10~Case #"_DAYCASE_" is Assigned to "_$$USERINF^MAGJUTL3(ASIGDUZ,1)_". You may View only, Override the assignment, or Cancel. " ; #10=View/Override/Cancel"
. E I ASIGRIST S REPLY="2~Case #"_DAYCASE_" is Assigned to "_$$USERINF^MAGJUTL3(ASIGDUZ,1)_"; Reserve not allowed."
. E S REPLY="5~Case #"_DAYCASE_" is Assigned to "_$$USERINF^MAGJUTL3(ASIGDUZ,1)_"; exam NOT Locked. "
I CURCASE=11 S CURCASE=1 ; Came through Override pathway--allow override lock attempt
I ASIGREPL ; Assign conflict logic has already created a reply code/msg
E S REPLY="4~Attempting to open/display case #"_DAYCASE
; ISI ... end
S JBDISABLE=0
I CURCASE="VIX-Metadata" S JBDISABLE=1 ; metadata only, do not trigger JB fetches
;
; Note in several reply messages below the use of "2~"
; This value triggers specific behaviors in vrad client and VIX
; -- client displays an Information message box
; -- VIX 'tags' the exam to refresh the file list metadata from the source
; on any subsequent access for this exam
; These respective behaviours are mutually appropriate for both parts of
; the system for all the messages involved; avoid using "2~" unless the
; same functionality applies for any given new functionality
;
S IMGST=$$JBFETCH^MAGJUTL2(RARPT,.MAGS,USETGA,JBDISABLE) ; open only if NOT on JB
I +IMGST D G OPENCASZ ; some images are on JB
. I $D(MAGS("OFFLN")) N T,TT S T="",TT="" D
. . F S T=$O(MAGS("OFFLN",T)) Q:T="" S TT=TT_$S(TT="":"",1:", ")_T
. . 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
. E I JBDISABLE S REPLY="2~Case #"_DAYCASE_"--"_+IMGST_" Images are on Jukebox."
. E S REPLY="2~Case #"_DAYCASE_"--"_+IMGST_" Images have been requested from Jukebox; try again later."
I '$P(IMGST,U,2) S REPLY="2~No Images exist for Case #"_DAYCASE_"." G OPENCASZ
S USELORES=+$P(IMGST,U,3)_U_$P(IMGST,U,2)
S MAGSTRT=1,MAGEND=MAGS D IMGLOOP^MAGJEX1B
;
I ACQSITE="" S ACQSITE=RADIV
;
; Conditionally support revising an unlocked exam's annotations as a function
; of exam status and credentials of (current & original) interpreter (P101).
S YNREVANN=$$ZRUREVAN^MAGJUTL4(RADFN,RADTI,RACNI)
;
; Return flag to allow display of disclaimer text if ExamType="Mammogram".
; Note the VRad client may override based on image metadata (P101).
S YNMAMMO=$$ZRUMAMMO^MAGJUTL4(RACPT)
;
;
I ASIGREPL ; ISI ; Assign conflict logic has already created a reply code/msg
E S REPLY="0~Images for Case #"_DAYCASE ; ISI
;
OPENCASZ I 'CT,(REPLY["Attempting") S REPLY="4~Unable to retrieve images for Case #"_DAYCASE_"."
;
; Contents of successful reply = 4 pipe-delimited ("|") pieces:
; 1: # Image nodes ^ Reply Msg Type ~ Reply Msg display text
; 2: RADFN^RADTI^RACNI^RARPT --> Exam ID String
; 3: Pt Name ^ CASE # ^ Proc. Name ^ Exam Date ^ Time ^ Modality ^
; SSN ^ <unused> ^ LOCKED Status ^ Modifier ^ Exam Status Category
; 4: Is Radiologist? ^ Alt_Path Flag ^ Acquisition Site ^ Procedure Date ^
; Revise Annotations? ^ Mammography? ^ Station Number | Regional image(0/1)
;
S REMOTE=+$G(MAGJOB("REMOTE")) ; ISI
S LOCKED=0
I MIXEDUP D
. N IMIX,XDFN,XPTS S VIEWOK=$S($D(MAGJOB("KEYS","MAGJ SEE BAD IMAGES")):1,1:0)
. I MIXEDUP>1 D
. . S XPTS="",XDFN=0 F IMIX=0:1 S XDFN=$O(MIXEDUP(XDFN)) Q:'XDFN S XPTS=XPTS_$S(IMIX:" and ",1:" ")_$$PNAM(XDFN)
. . S XPTS=$S(IMIX=1:" ",1:"s ")_XPTS
. . 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!"
. E S REPLY=(7-VIEWOK)_"~"_MIXEDUP("REPLY")
. I CURCASE S REPLY=REPLY_" The exam is NOT Locked." S CURCASE=0
I CT D
. S RIST=$S(+MAGJOB("USER",1):1,1:0),EXCAT=""
. S LOGDATA=RADFN_U_+$P(MAGS(1),U,4)_U_+MAGS_U_REMOTE ; for Img Access log
. I CURCASE D
. . I $G(MAGJOB("CONSOLIDATED")),'$D(MAGJOB("DIVSCRN",RADIV)) D S CURCASE=0 Q
. . . S REPLY="5~Exam is for Station #"_$$STATN(RADIV)_"; you are logged on to #"_$$STATN(DUZ(2))_". Exam is NOT Locked."
. . S XX=$P(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0),U,3)
. . I '$D(^RA(72,"AVC","E",XX)) D S CURCASE=0 Q
. . . D LOCKACT^MAGJEX1A(RARPT,DAYCASE,100,.RESULT) ; between reserve and now, exam may have been Taken & Updated
. . . I +RESULT(1)!+RESULT(2) D LOCKACT^MAGJEX1A(RARPT,DAYCASE,101,.RESULT) ; so, cancel any lock/reserve
. . . S REPLY="5~For Case #"_DAYCASE_", current Status is "_$P(^RA(72,XX,0),U)_"; Lock or Reserve NOT allowed."
. . E S EXCAT="E"
. . I RIST D ; lock only for Current Case, Radiologist, & Full Res images ; ISI remove deprecated logic re usetga
. . . ; save data needed to later log Interpreted event
. . . D LOCKACT^MAGJEX1A(RARPT,DAYCASE,CURCASE,.RESULT,.REPLY,LOGDATA)
. . . S LOCKED=$S(+RESULT:1,+$P(RESULT,U,2):2,1:0)
. I EXCAT="" D
. . I RASTORD=9 S EXCAT="C" Q ; Complete
. . E S EXCAT=RASTCAT
. . I EXCAT="D"!(EXCAT="T") S EXCAT="I" ; just display one value meaning Interpreted
. S DATAOUT=$P(RADATA,U,4)_U_DAYCASE_U_$P(RADATA,U,9)
. S X=$P(RADATA,U,6),T=$L(X," "),X=$P(X," ",1,T-1)_U_$P(X," ",T)
. S DATAOUT=DATAOUT_U_X
. S DATAOUT=DATAOUT_U_MODALITY_U_$P(RADATA,U,5)_U_U_LOCKED
. S DATAOUT=DATAOUT_U_MODIF_U_EXCAT_U_"|"_RIST_U_ALTPATH_U_ACQSITE_U_PROCDT_U_YNREVANN_U_YNMAMMO_U_STANUM_U_"|"_$$REGIONAL(.MAGS)_U_PLACE ; ISI adds pipe-piece 5!
. ; ISI remove deprecated logic re usetga
S @MAGGRY@(STARTNOD)=CT_U_REPLY_"|"_RADFN_U_RADTI_U_RACNI_U_RARPT_"|"_DATAOUT
; if mixedup & not have keys to see images, delete image refs
; & send only reply msg
I MIXEDUP,('VIEWOK) S CT=0 K @MAGGRY S @MAGGRY@(0)=CT_U_REPLY
E S $P(@MAGGRY@(0),U)=CT+STARTNOD
I CT,(LOCKED'=2),(CURCASE'["VIX") D LOG^MAGJUTL3("VR-VW",LOGDATA,$$PSETLST(RADFN,RADTI,RACNI)) ; Image access log
Q
;
PSETLST(RADFN,RADTI,RACNI) ; Return list of Printset Case #'s for exam
N I,MAGPSET,PSETLST,RAPRTSET,X
S PSETLST="" ; initialize return value
I +$G(RADFN),+$G(RADTI),+$G(RACNI) D
. D EN2^RAUTL20(.MAGPSET)
. Q:'RAPRTSET ; variable set by above call; stop if not a printset
. S X=""
. F I=0:1 S X=$O(MAGPSET(X)) Q:'X S PSETLST=PSETLST_$S(I:U,1:"")_$P(MAGPSET(X),U)
Q:$Q PSETLST Q
;
PNAM(X) ; return pt name for input DFN
I X S X=$G(^DPT(+X,0)) I X]"" S X=$P(X,U)
E S X="UNKNOWN"
Q X
;
STATN(X) ; get station #, else return input value
N T
I X]"" D GETS^DIQ(4,X,99,"","T") S T=$G(T(4,X_",",99,"E")) I T]"" S X=T
Q X
;
END Q ;
;
REGIONAL(MAGS) ; ISI -- return 1 if image storage loc is regional
N IEN,LOC,RSL
S RSL=""
I $G(MAGS) D ;aft called jbfetch^magjutl2
. S IEN=+$P($G(MAGS(1)),U,4) Q:'IEN ;MAG IEN 1st image
. S LOC=+$P($G(^MAG(2005,+IEN,0)),"^",3) ;NETWORK LOCATION
. I $G(^MAG(2005.2,LOC,"REGIONAL")) S RSL=1
Q RSL
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGJEX1 11672 printed Dec 13, 2024@02:06:39 Page 2
MAGJEX1 ;WIRMFO/JHC,ISI/JL - VistARad RPC calls ; 10/17/2022
+1 ;;3.0;IMAGING;**16,22,18,65,101,115,104,120,133,341**;Dec 21, 2022;Build 28
+2 ;; Per VHA Directive 2004-038, this routine should not be modified.
+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 ;; | The Food and Drug Administration classifies this software as |
+11 ;; | a medical device. As such, it may not be changed in any way. |
+12 ;; | Modifications to this software may result in an adulterated |
+13 ;; | medical device under 21CFR820, the use of which is considered |
+14 ;; | to be a violation of US Federal Statutes. |
+15 ;; +---------------------------------------------------------------+
+16 ;;
+17 ; Reference to EN2^RAUTL20 in ICR #3270
+18 ;; ISI IMAGING;**99,101**
+19 QUIT
+20 ;
+21 ;
ERR NEW ERR
SET ERR=$$EC^%ZOSV
SET @MAGGRY@(0)="0^4~"_ERR
+1 DO @^%ZOSF("ERRTN")
+2 if $QUIT
QUIT 1
QUIT
+3 ;
+4 ;***** Open an exam.
+5 ; RPC: MAGJ RADCASEIMAGES
+6 ;
OPENCASE(MAGGRY,DATA) ;
+1 ; MAGGRY holds $NA reference to ^TMP for rpc return
+2 ; all ref's to MAGGRY use subscript indirection
+3 ; input in DATA:
+4 ; OPEN_FLAG ^ RADFN^RADTI^RACNI^RARPT ^ PSINDGET ^ <unused> ^ USETGA (forced to zero) ; ISI
+5 ; OPEN_FLAG = 0: Open, view only
+6 ; 1: Open, lock the case for status update
+7 ; 2: Open, Reserve for Interpretation
+8 ; VIX: Fetching metadata only; Jukebox retrieval occurs (P115 & earlier)
+9 ; VIX-Metadata: Fetching metadata only; no JB Retrieval (P104,ff)
+10 ; VIX-Open: Fetching metadata with JB Retrieval (P104,ff)
+11 ; RADFN^RADTI^RACNI^RARPT = Exam ID string, specifies case of interest
+12 ; PSINDGET= Presentation State indicators of interest to client
+13 ; K/I/U for Key Image/ Interpretation/ User PS types
+14 ; USETGA = hard-code to "0": Open BIG file ; ISI remove support for downsampled image fetch
+15 ;
+16 ; Details of Reply message are below tag OPENCASZ
+17 ;
+18 NEW $ETRAP,$ESTACK
SET $ETRAP="D ERR^MAGJEX1"
+19 NEW RARPT,RADFN,RADTI,RACNI,RADIV
+20 NEW DAYCASE,CURCASE,REPLY,CT,MAGS,STARTNOD,LOCKED,DATAOUT,RADATA,RIST,MDL
+21 NEW IMAG,MAGXX,MAGFILE,MAGFILE1,MAGFILE2,MAGFILE3,MAGLST,MAGOBJT,MODALITY
+22 NEW MAGSTRT,MAGEND,CURPATHS
+23 NEW MIXEDUP,VIEWOK,USETGA,USELORES,IMGST,REMOTE,DIQUIET
+24 NEW LOGDATA,MODIF,EXCAT,RADATA2,PSIND,RACPT,RASTCAT,RASTORD,ACQSITE,ALTPATH,PROCDT
+25 NEW YNMAMMO,YNREVANN,PSINDGET,JBDISABLE,STANUM
+26 ; ISI
NEW ASIGDUZ,ASIGRIST,ASIGREPL,RADATA9,PLACE
+27 SET DIQUIET=1
DO DT^DICRW
+28 SET (CT,MIXEDUP)=0
SET MODALITY=""
SET DATAOUT=""
SET DAYCASE=""
SET MAGLST="MAGJOPENCASE"
SET (ACQSITE,ALTPATH,PROCDT,STANUM)=""
+29 SET VIEWOK=1
+30 ; assign MAGGRY value
KILL MAGGRY
SET MAGGRY=$NAME(^TMP($JOB,MAGLST))
SET STARTNOD=0
KILL @MAGGRY
+31 SET CURCASE=$PIECE(DATA,U)
SET RARPT=+$PIECE(DATA,U,5)
SET PSINDGET=+$PIECE(DATA,U,6)
+32 SET PSIND=""
IF PSINDGET]""
FOR I="K","I","U"
IF $FIND(PSINDGET,I)
SET PSIND(I)=""
+33 ; ISI hard-code to "0"
SET USETGA=0
+34 SET RADFN=$PIECE(DATA,U,2)
SET RADTI=$PIECE(DATA,U,3)
SET RACNI=$PIECE(DATA,U,4)
+35 IF RADFN
IF RADTI
IF RACNI
DO GETEXAM2^MAGJUTL1(RADFN,RADTI,RACNI,"",.X)
+36 IF 'X
SET REPLY="4~Request Contains Invalid Case Pointer ("_RADFN_U_RADTI_U_RACNI_U_RARPT_")."
GOTO OPENCASZ
+37 ; ISI
SET RADATA=$GET(^TMP($JOB,"MAGRAEX",1,1))
SET RADATA2=$GET(^(2))
SET RADATA9=$GET(^("ISI"))
+38 KILL ^TMP($JOB,"MAGRAEX")
+39 SET RADIV=$PIECE(RADATA2,U,5)
SET MODIF=$PIECE(RADATA2,U,8)
SET RASTCAT=$PIECE(RADATA2,U,11)
SET RASTORD=$PIECE(RADATA,U,15)
+40 ; ISI
SET PLACE=$PIECE(RADATA2,U,6)
+41 SET RARPT=+$PIECE(RADATA,U,10)
SET DAYCASE=$PIECE(RADATA,U,12)
SET RACPT=$PIECE(RADATA,U,17)
+42 IF 'RARPT!'$DATA(^RARPT(RARPT,2005))
SET REPLY="4~This exam has no report entry for associating images; no images can be accessed."
GOTO OPENCASZ
+43 DO CKINTEG^MAGJRPT(.X,RADFN,RADTI,RACNI,RARPT,RADATA)
+44 ; DB corruption
IF X]""
SET MIXEDUP=1
SET MIXEDUP("REPLY")=X
+45 ; ISI begin ...
+46 ; ISI
SET ASIGDUZ=+$PIECE(RADATA9,U,3)
SET ASIGRIST=0
SET ASIGREPL=0
+47 IF ASIGDUZ
Begin DoDot:1
+48 FOR X="S","R"
IF $DATA(^VA(200,"ARC",X,ASIGDUZ))
SET ASIGRIST=1
QUIT
End DoDot:1
+49 ; check if an assignment conflict exists for current user:
+50 ; exam is lockable (curcase = 1 or 2); if a rist is attempting to open, & exam is assigned, then block:
+51 ; Rist vs Tech has Assign? tech: allow View/Cancel; Rist: View/Override/Cancel
+52 ; Note that reply code 10 is a special value, used ONLY to enable the Assign over-ride for a rist
+53 IF CURCASE
IF '$$ASIGME^ISIJUTL1(ASIGDUZ)
IF CURCASE'=11
Begin DoDot:1
+54 ; #10=View/Override/Cancel"
IF ASIGRIST
IF (CURCASE=1)
SET REPLY="10~Case #"_DAYCASE_" is Assigned to "_$$USERINF^MAGJUTL3(ASIGDUZ,1)_". You may View only, Override the assignment, or Cancel. "
+55 IF '$TEST
IF ASIGRIST
SET REPLY="2~Case #"_DAYCASE_" is Assigned to "_$$USERINF^MAGJUTL3(ASIGDUZ,1)_"; Reserve not allowed."
+56 IF '$TEST
SET REPLY="5~Case #"_DAYCASE_" is Assigned to "_$$USERINF^MAGJUTL3(ASIGDUZ,1)_"; exam NOT Locked. "
End DoDot:1
if '(+REPLY=5)
GOTO OPENCASZ
SET CURCASE=0
SET ASIGREPL=1
+57 ; Came through Override pathway--allow override lock attempt
IF CURCASE=11
SET CURCASE=1
+58 ; Assign conflict logic has already created a reply code/msg
IF ASIGREPL
+59 IF '$TEST
SET REPLY="4~Attempting to open/display case #"_DAYCASE
+60 ; ISI ... end
+61 SET JBDISABLE=0
+62 ; metadata only, do not trigger JB fetches
IF CURCASE="VIX-Metadata"
SET JBDISABLE=1
+63 ;
+64 ; Note in several reply messages below the use of "2~"
+65 ; This value triggers specific behaviors in vrad client and VIX
+66 ; -- client displays an Information message box
+67 ; -- VIX 'tags' the exam to refresh the file list metadata from the source
+68 ; on any subsequent access for this exam
+69 ; These respective behaviours are mutually appropriate for both parts of
+70 ; the system for all the messages involved; avoid using "2~" unless the
+71 ; same functionality applies for any given new functionality
+72 ;
+73 ; open only if NOT on JB
SET IMGST=$$JBFETCH^MAGJUTL2(RARPT,.MAGS,USETGA,JBDISABLE)
+74 ; some images are on JB
IF +IMGST
Begin DoDot:1
+75 IF $DATA(MAGS("OFFLN"))
NEW T,TT
SET T=""
SET TT=""
Begin DoDot:2
+76 FOR
SET T=$ORDER(MAGS("OFFLN",T))
if T=""
QUIT
SET TT=TT_$SELECT(TT="":"",1:", ")_T
+77 SET 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
End DoDot:2
+78 IF '$TEST
IF JBDISABLE
SET REPLY="2~Case #"_DAYCASE_"--"_+IMGST_" Images are on Jukebox."
+79 IF '$TEST
SET REPLY="2~Case #"_DAYCASE_"--"_+IMGST_" Images have been requested from Jukebox; try again later."
End DoDot:1
GOTO OPENCASZ
+80 IF '$PIECE(IMGST,U,2)
SET REPLY="2~No Images exist for Case #"_DAYCASE_"."
GOTO OPENCASZ
+81 SET USELORES=+$PIECE(IMGST,U,3)_U_$PIECE(IMGST,U,2)
+82 SET MAGSTRT=1
SET MAGEND=MAGS
DO IMGLOOP^MAGJEX1B
+83 ;
+84 IF ACQSITE=""
SET ACQSITE=RADIV
+85 ;
+86 ; Conditionally support revising an unlocked exam's annotations as a function
+87 ; of exam status and credentials of (current & original) interpreter (P101).
+88 SET YNREVANN=$$ZRUREVAN^MAGJUTL4(RADFN,RADTI,RACNI)
+89 ;
+90 ; Return flag to allow display of disclaimer text if ExamType="Mammogram".
+91 ; Note the VRad client may override based on image metadata (P101).
+92 SET YNMAMMO=$$ZRUMAMMO^MAGJUTL4(RACPT)
+93 ;
+94 ;
+95 ; ISI ; Assign conflict logic has already created a reply code/msg
IF ASIGREPL
+96 ; ISI
IF '$TEST
SET REPLY="0~Images for Case #"_DAYCASE
+97 ;
OPENCASZ IF 'CT
IF (REPLY["Attempting")
SET REPLY="4~Unable to retrieve images for Case #"_DAYCASE_"."
+1 ;
+2 ; Contents of successful reply = 4 pipe-delimited ("|") pieces:
+3 ; 1: # Image nodes ^ Reply Msg Type ~ Reply Msg display text
+4 ; 2: RADFN^RADTI^RACNI^RARPT --> Exam ID String
+5 ; 3: Pt Name ^ CASE # ^ Proc. Name ^ Exam Date ^ Time ^ Modality ^
+6 ; SSN ^ <unused> ^ LOCKED Status ^ Modifier ^ Exam Status Category
+7 ; 4: Is Radiologist? ^ Alt_Path Flag ^ Acquisition Site ^ Procedure Date ^
+8 ; Revise Annotations? ^ Mammography? ^ Station Number | Regional image(0/1)
+9 ;
+10 ; ISI
SET REMOTE=+$GET(MAGJOB("REMOTE"))
+11 SET LOCKED=0
+12 IF MIXEDUP
Begin DoDot:1
+13 NEW IMIX,XDFN,XPTS
SET VIEWOK=$SELECT($DATA(MAGJOB("KEYS","MAGJ SEE BAD IMAGES")):1,1:0)
+14 IF MIXEDUP>1
Begin DoDot:2
+15 SET XPTS=""
SET XDFN=0
FOR IMIX=0:1
SET XDFN=$ORDER(MIXEDUP(XDFN))
if 'XDFN
QUIT
SET XPTS=XPTS_$SELECT(IMIX:" and ",1:" ")_$$PNAM(XDFN)
+16 SET XPTS=$SELECT(IMIX=1:" ",1:"s ")_XPTS
+17 SET 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!"
End DoDot:2
+18 IF '$TEST
SET REPLY=(7-VIEWOK)_"~"_MIXEDUP("REPLY")
+19 IF CURCASE
SET REPLY=REPLY_" The exam is NOT Locked."
SET CURCASE=0
End DoDot:1
+20 IF CT
Begin DoDot:1
+21 SET RIST=$SELECT(+MAGJOB("USER",1):1,1:0)
SET EXCAT=""
+22 ; for Img Access log
SET LOGDATA=RADFN_U_+$PIECE(MAGS(1),U,4)_U_+MAGS_U_REMOTE
+23 IF CURCASE
Begin DoDot:2
+24 IF $GET(MAGJOB("CONSOLIDATED"))
IF '$DATA(MAGJOB("DIVSCRN",RADIV))
Begin DoDot:3
+25 SET REPLY="5~Exam is for Station #"_$$STATN(RADIV)_"; you are logged on to #"_$$STATN(DUZ(2))_". Exam is NOT Locked."
End DoDot:3
SET CURCASE=0
QUIT
+26 SET XX=$PIECE(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0),U,3)
+27 IF '$DATA(^RA(72,"AVC","E",XX))
Begin DoDot:3
+28 ; between reserve and now, exam may have been Taken & Updated
DO LOCKACT^MAGJEX1A(RARPT,DAYCASE,100,.RESULT)
+29 ; so, cancel any lock/reserve
IF +RESULT(1)!+RESULT(2)
DO LOCKACT^MAGJEX1A(RARPT,DAYCASE,101,.RESULT)
+30 SET REPLY="5~For Case #"_DAYCASE_", current Status is "_$PIECE(^RA(72,XX,0),U)_"; Lock or Reserve NOT allowed."
End DoDot:3
SET CURCASE=0
QUIT
+31 IF '$TEST
SET EXCAT="E"
+32 ; lock only for Current Case, Radiologist, & Full Res images ; ISI remove deprecated logic re usetga
IF RIST
Begin DoDot:3
+33 ; save data needed to later log Interpreted event
+34 DO LOCKACT^MAGJEX1A(RARPT,DAYCASE,CURCASE,.RESULT,.REPLY,LOGDATA)
+35 SET LOCKED=$SELECT(+RESULT:1,+$PIECE(RESULT,U,2):2,1:0)
End DoDot:3
End DoDot:2
+36 IF EXCAT=""
Begin DoDot:2
+37 ; Complete
IF RASTORD=9
SET EXCAT="C"
QUIT
+38 IF '$TEST
SET EXCAT=RASTCAT
+39 ; just display one value meaning Interpreted
IF EXCAT="D"!(EXCAT="T")
SET EXCAT="I"
End DoDot:2
+40 SET DATAOUT=$PIECE(RADATA,U,4)_U_DAYCASE_U_$PIECE(RADATA,U,9)
+41 SET X=$PIECE(RADATA,U,6)
SET T=$LENGTH(X," ")
SET X=$PIECE(X," ",1,T-1)_U_$PIECE(X," ",T)
+42 SET DATAOUT=DATAOUT_U_X
+43 SET DATAOUT=DATAOUT_U_MODALITY_U_$PIECE(RADATA,U,5)_U_U_LOCKED
+44 ; ISI adds pipe-piece 5!
SET DATAOUT=DATAOUT_U_MODIF_U_EXCAT_U_"|"_RIST_U_ALTPATH_U_ACQSITE_U_PROCDT_U_YNREVANN_U_YNMAMMO_U_STANUM_U_"|"_$$REGIONAL(.MAGS)_U_PLACE
+45 ; ISI remove deprecated logic re usetga
End DoDot:1
+46 SET @MAGGRY@(STARTNOD)=CT_U_REPLY_"|"_RADFN_U_RADTI_U_RACNI_U_RARPT_"|"_DATAOUT
+47 ; if mixedup & not have keys to see images, delete image refs
+48 ; & send only reply msg
+49 IF MIXEDUP
IF ('VIEWOK)
SET CT=0
KILL @MAGGRY
SET @MAGGRY@(0)=CT_U_REPLY
+50 IF '$TEST
SET $PIECE(@MAGGRY@(0),U)=CT+STARTNOD
+51 ; Image access log
IF CT
IF (LOCKED'=2)
IF (CURCASE'["VIX")
DO LOG^MAGJUTL3("VR-VW",LOGDATA,$$PSETLST(RADFN,RADTI,RACNI))
+52 QUIT
+53 ;
PSETLST(RADFN,RADTI,RACNI) ; Return list of Printset Case #'s for exam
+1 NEW I,MAGPSET,PSETLST,RAPRTSET,X
+2 ; initialize return value
SET PSETLST=""
+3 IF +$GET(RADFN)
IF +$GET(RADTI)
IF +$GET(RACNI)
Begin DoDot:1
+4 DO EN2^RAUTL20(.MAGPSET)
+5 ; variable set by above call; stop if not a printset
if 'RAPRTSET
QUIT
+6 SET X=""
+7 FOR I=0:1
SET X=$ORDER(MAGPSET(X))
if 'X
QUIT
SET PSETLST=PSETLST_$SELECT(I:U,1:"")_$PIECE(MAGPSET(X),U)
End DoDot:1
+8 if $QUIT
QUIT PSETLST
QUIT
+9 ;
PNAM(X) ; return pt name for input DFN
+1 IF X
SET X=$GET(^DPT(+X,0))
IF X]""
SET X=$PIECE(X,U)
+2 IF '$TEST
SET X="UNKNOWN"
+3 QUIT X
+4 ;
STATN(X) ; get station #, else return input value
+1 NEW T
+2 IF X]""
DO GETS^DIQ(4,X,99,"","T")
SET T=$GET(T(4,X_",",99,"E"))
IF T]""
SET X=T
+3 QUIT X
+4 ;
END ;
QUIT
+1 ;
REGIONAL(MAGS) ; ISI -- return 1 if image storage loc is regional
+1 NEW IEN,LOC,RSL
+2 SET RSL=""
+3 ;aft called jbfetch^magjutl2
IF $GET(MAGS)
Begin DoDot:1
+4 ;MAG IEN 1st image
SET IEN=+$PIECE($GET(MAGS(1)),U,4)
if 'IEN
QUIT
+5 ;NETWORK LOCATION
SET LOC=+$PIECE($GET(^MAG(2005,+IEN,0)),"^",3)
+6 IF $GET(^MAG(2005.2,LOC,"REGIONAL"))
SET RSL=1
End DoDot:1
+7 QUIT RSL
+8 ;