MAGGAII ;WOIFO/GEK/SG/JSL - RETURNS IMAGE INFO ; 2/20/09 11:37am
;;3.0;IMAGING;**93,94,122**;Mar 19, 2002;Build 92;Aug 02, 2012
;; 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. |
;; +---------------------------------------------------------------+
;;
Q
;
;+++++ PERFORMS SPECIAL CONVERSION OF THE DATE/TIME
DTE(DTI) ;
Q $TR($$FMTE^XLFDT(DTI,"5Z"),"@"," ")
;
;+++++ RETURNS THE FULL NAME OF THE IMAGE FILE
;
; MAGXX IEN of the image record in the file #2005
;
; FILETYPE Type of the image: "ABSTRACT", "BIG", or "FULL"
;
; [.MAGTYPE] Reference to a local variable where the location
; code is returned to:
; A Accessible
; M Magnetic
; O Offline
; W WORM
;
; [.MAGJBOL] Reference to a local variable where the Jukebox
; offline message is returned to.
;
; Return Values
; =============
; <0 ErrorCode~ErrorMessage
; "" Name is not available or an error
;
FILENAME(MAGXX,FILETYPE,MAGTYPE,MAGJBOL) ;
N MAGFILE1,MAGJBCP,MAGOFFLN,MAGPREF
S MAGPREF=""
;--- Don't queue a copy from the JukeBox.
S MAGJBCP=0
;--- The FINDFILE^MAGFILEB returns:
; MAGFILE1 File name (e.g. "LA100066.ABS")
; if no Network Location pointer or INVALID Pointer
; then MAGFILE1=-1~NO NETWORK LOCATION POINTER
; or -1~INVALID NETWORK LOCATION POINTER
; MAGFILE1(.01) Image description (e.g. "ONE,PATIENT 111223333")
; MAGJBOL Description of the offline server
; MAGOFFLN Non-zero if the jukebox is offline
; MAGPREF Path (e.g. "C:\TEMP\LA\10\00\")
;--- MAGTYPE "MAG" or "WORM"
D FINDFILE^MAGFILEB
;--- The MAGFILE1 may contain '^' in case of an error
S MAGFILE1=$TR(MAGFILE1,"^","~")
S:$D(MAGFILE1("ERROR")) MAGFILE1=MAGFILE1("ERROR")
S MAGTYPE=$S($G(MAGOFFLN):"O",FILETYPE="FULL":"A",1:$E(MAGTYPE,1))
;--- The following line of code replicates the old functionality
Q:FILETYPE'="BIG" $G(MAGPREF)_MAGFILE1
;--- Return the full name or an empty string in case of an error
Q $S($E(MAGFILE1,1,2)="-1":"",1:$G(MAGPREF)_MAGFILE1)
;
;##### RETURNS THE IMAGE DESCRIPTOR
;
; MAGIEN IEN of the image record in the file #2005 or
; in file #2005.1
;
; FLAGS Flags that control the execution (can be combined):
;
; D Consider only deleted "child" images
; E Consider only existing "child" images
;
; If neither 'E' nor 'D' flag is provided, then an
; error code is returned.
;
; [[.]GRPCNTS] The $$INFO function need counts of images in the
; group. If these numbers are already available,
; they can be passed as the value of this parameter.
; ^01: Number of existing members of the group
; ^02: Number of deleted members of the group
;
; If this parameter is not defiend or empty, the
; $$INFO function calls the $$GRPCT^MAGGI14 and
; returns the counts in this parameter if it is
; passed by reference.
;
; Input Variables
; ===============
;
; MAGJOB(
; "NETPLC",...)
; "PTNM",...)
; "RPCPORT")
; "RPCSERVER")
;
; MAGNOCHK Skip the questionable integrity checks if this
; variable is defined and not zero.
;
; Output Variables
; ================
;
; MAGJOB(
; "NETPLC",...)
; "PTNM",...)
;
; Return Values
; =============
; <0 Error descriptor (see the $$ERROR^MAGUERR)
; >0 Image descriptor
; ^01: Image IEN
; ^02: Image full path and name
; ^03: Abstract full path and name
; ^04: SHORT DESCRIPTION field and description of
; offline JukeBox
; ^05: PROCEDURE/EXAM DATE/TIME field
; ^06: OBJECT TYPE
; ^07: PROCEDURE field
; ^08: display date
; ^09: PARENT DATA FILE image pointer
; ^10: ABSTYPE: 'M' magnetic, 'W' worm, 'O' offline
; ^11: 'A' accessible, 'O' offline
; ^12: DICOM Series Number
; ^13: DICOM Image Number
; ^14: Count of images in group; 1 if single image
; VISN15
; ^15: Site parameter IEN
; ^16: Site parameter CODE
; ^17: Error description of Integrity Check
; ^18: Image BIGPath and name
; ^19: Patient DFN
; ^20: Patient Name
; ^21: Image Class: Clin,Admin,Clin/Admin,Admin/Clin
; ^22: Date Time Image Saved (7)
; ^23: Document Date (110)
; ^24: Group IEN
; ^25: IEN of the 1s child of the group and child's
; type separated by colon
; ^26: RPC Broker server
; ^27: RPC Broker port
; ^28: Internal value of CONTROLLED IMAGE field (112)
; converted to a number {0|1}
; ^29: Viewable Status
; ^30: Internal value of STATUS field (113)
; ^31: Image annotated flag (0 or 1)
; ^32: Image TIU note is completed (0 or 1)
; ^33: Annotation operation Status
; ^34: Annotation operation Status Description
; ^35: Package is the package: RAD,LAB,MED,SUR,NONE,PHOTOID
;
INFO(MAGIEN,FLAGS,GRPCNTS) ;
N GROUP ; 1 if the entry referenced by MAGIEN is a group
N GRPCH1IEN ; IEN of the first image of the group
N GRPCH1NODE ; Global node of the 1st image od the group
N GRPCH1TYPE ; Type of the first image of the group
N GRPCHCNT ; Number of images in the group
N MAGNODE ; Global node of the image referenced by MAGIEN
N MAGRES ; Result value (image descriptor)
;
;N MAG3P59 ;gek/ out in P94t7
N MAGMSG,MAGN0,MAGN100,MAGN2,MAGN40,MAGJBOL
N MAGVST,MDFN,IEN,PLC,PLCODE,RC,TMP,X,ANNOTATED,TMPN2
;
;=== Validate control flags
S FLAGS=$G(FLAGS)
;--- Unknown/Unsupported flag(s)
Q:$TR(FLAGS,"DE")'="" $$IPVE^MAGUERR("FLAGS")
;--- Missing required flag
Q:$TR(FLAGS,"DE")=FLAGS $$ERROR^MAGUERR(-6,,"D,E")
;
;=== Get the global node of the record
S MAGNODE=$$NODE^MAGGI11(MAGIEN)
;
;=== Initialize variables
S MAGRES=MAGIEN,RC=0
;gek/ out in P94t7 S MAG3P59=$D(MAGJOB("RPCSERVER"))&$D(MAGJOB("RPCPORT"))
D:'$D(MAGJOB("NETPLC")) NETPLCS^MAGGTU6
I MAGNODE'="" D
. S MAGN0=$G(@MAGNODE@(0)),MAGN2=$G(@MAGNODE@(2))
. S MAGN40=$G(@MAGNODE@(40)),MAGN100=$G(@MAGNODE@(100))
E S (MAGN0,MAGN2,MAGN40,MAGN100)=""
;
;=== Cache patient names; call $$GET 1 time not 2000
S MDFN=$P(MAGN0,U,7) ; PATIENT (5)
I MDFN,'$D(MAGJOB("PTNM",MDFN)) D
. S MAGJOB("PTNM",MDFN)=$$GET1^DIQ(2,MDFN_",",.01)
. ;--- Cache no more than 10 records in the MAGJOB("PTNM")
. S TMP=+$P($G(MAGJOB("PTNM")),U,10)
. S MAGJOB("PTNM")=MDFN_U_$P($G(MAGJOB("PTNM")),U,1,9)
. K:TMP>0 MAGJOB("PTNM",TMP)
. Q
;
;=== Process the group header
S GRPCHCNT=0,(GRPCH1IEN,GRPCH1NODE,GRPCH1TYPE)=""
;--- Count the images of the group
S:$G(GRPCNTS)="" GRPCNTS=$$GRPCT^MAGGI14(MAGIEN)
D:GRPCNTS'<0
. S:FLAGS["E" GRPCHCNT=GRPCHCNT+$P(GRPCNTS,U,1) ; Existing entries
. S:FLAGS["D" GRPCHCNT=GRPCHCNT+$P(GRPCNTS,U,2) ; Deleted entries
. Q
;--- Check the object type
S GROUP=$$ISGRP^MAGGI11(MAGIEN)
I GROUP D
. ;--- Get the IEN of the first image of the group
. S GRPCH1IEN=$$GRPCH1^MAGGI14(MAGIEN,FLAGS)
. I GRPCH1IEN'>0 S GRPCH1IEN="" Q
. ;--- If we cannot get the global node of the 1st image of the
. ;--- group (this should never happen) clear its IEN as well.
. S GRPCH1NODE=$$NODE^MAGGI11(GRPCH1IEN,.TMP)
. I GRPCH1NODE="" S GRPCH1IEN="" Q
. ;--- Get the type of the first image of the group
. S GRPCH1TYPE=$P(@GRPCH1NODE@(0),U,6)
. Q
;--- Check the annotation info
S ANNOTATED=+$P($G(^MAG(2005.002,MAGIEN,1,0)),U,4) ;p122 - add IMAGE annotated flag
I 'ANNOTATED I $D(^MAG(2005,MAGIEN,210,0)) S ANNOTATED=1 ;VistARad annotation #2005.001/PS data #2005.05
I 'ANNOTATED I GROUP!$D(^MAG(2005,MAGIEN,1,0)) D ;p122 - find any child w/ annotation
. N NO,CH S NO=0
. F S NO=$O(^MAG(2005,MAGIEN,1,NO)) Q:'NO S CH=+$G(^(NO,0)) S:CH ANNOTATED=+$P($G(^MAG(2005.002,CH,1,0)),U,4) S:$D(^MAG(2005,CH,210,0)) ANNOTATED=1 Q:ANNOTATED
. Q
S:ANNOTATED ANNOTATED=1
;=== If this is a group and it is not empty, then use
; the first image to get the names of image files.
;=== Otherwise, get them from the group header itself.
S IEN=$S(GRPCH1IEN>0:GRPCH1IEN,1:MAGIEN)
;--- Get full path and file name of the Abstract.
S $P(MAGRES,U,3)=$$FILENAME(IEN,"ABSTRACT",.TMP,.MAGJBOL)
S $P(MAGRES,U,10)=TMP ; Abstract type ('M', 'O', or 'W')
;--- Get the full path and file name of the FULL RES image.
S $P(MAGRES,U,2)=$$FILENAME(IEN,"FULL",.TMP)
S $P(MAGRES,U,11)=TMP ; 'A' - accessible, 'O' - offline
;--- Get the full path and file name for the BIG image.
S $P(MAGRES,U,18)=$$FILENAME(IEN,"BIG")
;
;=== Get the site parameters IEN and code
S IEN=0
I 'GROUP D
. ;--- If the record is a standalone image entry, then
. ;--- get the location IEN from this entry.
. S IEN=+$S($P(MAGN0,U,3):$P(MAGN0,U,3),1:$P(MAGN0,U,5))
. Q
E I GRPCH1NODE'="" D
. ;--- If the group references "child" entries of requested kind(s),
. ;--- then get the network location IEN from the 1st one.
. S TMP=$G(@GRPCH1NODE@(0))
. S IEN=+$S($P(TMP,U,3):$P(TMP,U,3),1:$P(TMP,U,5))
. Q
E I (FLAGS'["D")!(FLAGS'["E") D
. ;--- Otherwise, try to get the location IEN from the 1st "child"
. ;--- image regardless of the requested kind (existing or deleted).
. N CH1IEN,CH1NODE
. S CH1IEN=$$GRPCH1^MAGGI14(MAGIEN,"DE") Q:CH1IEN'>0
. S CH1NODE=$$NODE^MAGGI11(CH1IEN) Q:CH1NODE=""
. S TMP=$G(@CH1NODE@(0))
. S IEN=+$S($P(TMP,U,3):$P(TMP,U,3),1:$P(TMP,U,5))
. Q
S PLC=$P($G(MAGJOB("NETPLC",IEN)),U,1) ; Site Parameters IEN
S PLCODE=$P($G(MAGJOB("NETPLC",IEN)),U,2) ; Site Code (e.g. "WAS")
;--- Groups of 0 images need this
S:PLC="" PLC=$G(MAGJOB("PLC")),PLCODE=$G(MAGJOB("PLCODE"))
;
;=== SHORT DESCRIPTION field (10) and description of offline JukeBox
S $P(MAGRES,U,4)=$P(MAGN2,U,4)_$G(MAGJBOL)
;
;=== Various fields
S $P(MAGRES,U,5)=$P(MAGN2,U,5) ; PROCEDURE/EXAM DATE/TIME (15)
S $P(MAGRES,U,6)=$P(MAGN0,U,6) ; OBJECT TYPE (3)
S $P(MAGRES,U,7)=$P(MAGN0,U,8) ; PROCEDURE (6)
S $P(MAGRES,U,8)=$$DTE($P(MAGN2,U,5)) ; Ext. PROCEDURE/EXAM DATE/TIME
S $P(MAGRES,U,9)=$P(MAGN2,U,8) ; PARENT DATA FILE IMAGE POINTER (18)
;
;=== 2/1/99 Dicom Series number and Dicom Image Number
; $p(12) and $p(13)
;
;=== Number of images of requested kind in the group
S $P(MAGRES,U,14)=$S(GRPCHCNT>0:GRPCHCNT,1:1)
;
;=== Site IEN and code
S $P(MAGRES,U,15,16)=PLC_U_PLCODE
;
;=== Data integrity checks
S TMP=$S('$G(MAGNOCHK):"Q",1:"")
S MAGVST=$$VIEWSTAT^MAGGI12(MAGIEN,TMP,.MAGMSG)
;;W !,"MAGVST : ",$G(MAGVST) ; TESTING, TAKE OUT THIS LINE.
I MAGVST["Q" D
. ;--- Remove the file name of the full resolution image
. S $P(MAGRES,U,2)="-1~Questionable Data Integrity"
. ;--- Replace the Abstract with the special bitmap
. S $P(MAGRES,U,3)=".\bmp\imageQA.bmp"
. ;--- Prevent the client from changing the Questionable
. ;--- Integrity abstract bitmap to the Offline bitmap.
. S:$P(MAGRES,U,6)'=11 $P(MAGRES,U,6)=99
. S $P(MAGRES,U,10)="M"
. ;--- Return the error message
. S $P(MAGRES,U,17)=MAGMSG("Q")
. Q
;
;=== Various fields
S $P(MAGRES,U,19)=MDFN ; Patient IEN (DFN)
S $P(MAGRES,U,20)=$S(MDFN:MAGJOB("PTNM",MDFN),1:MDFN)
S $P(MAGRES,U,22)=$$DTE($P(MAGN2,U)) ; DATE/TIME IMAGE SAVED (7)
S $P(MAGRES,U,23)=$$DTE($P(MAGN100,U,6)) ; CREATION DATE (110)
;
;=== Name of the image class
S IEN=+$P(MAGN40,U,3) ; TYPE INDEX (42)
S:IEN>0 $P(MAGRES,U,21)=$$GET1^DIQ(2005.83,IEN_",",1,,,"MAGMSG")
;
;=== If the client is newer than patch 59, then we can set beyond
; 25 pieces. Additional "^" at the end of the result prevents
;=== problems on the client side.
D ;gek/ out in P94t7 I MAG3P59 D
. S $P(MAGRES,U,24)=$P(MAGN0,U,10) ; GROUP PARENT (14)
. S:GRPCHCNT>1 $P(MAGRES,U,25)=GRPCH1IEN_":"_GRPCH1TYPE
. S $P(MAGRES,U,26)=$G(MAGJOB("RPCSERVER")) ; GEK P94 put in $G
. S $P(MAGRES,U,27)=$G(MAGJOB("RPCPORT")) ; GEK P94 put in $G
. S TMP=+$P(MAGN100,U,7) ; CONTROLLED IMAGE (112)
. S $P(MAGRES,U,28)=TMP
. S:TMP $P(MAGRES,U,3)=".\bmp\magsensitive.bmp"
. S TMP=+$P(MAGN100,U,8) ; STATUS (113)
. S $P(MAGRES,U,29)=$$VSTCODE(MAGVST,TMP)
. S $P(MAGRES,U,30)=TMP
. ; patch 122 new data pieces (31-35) for annotation.
. S $P(MAGRES,U,31)=$G(ANNOTATED) ;IMAGE annotated
. S TMP=""
. ; if it is a child of a Group, the Parent data is in the Group.
. S TMPN2=MAGN2 I $P(MAGN0,U,10) S TMPN2=$G(^MAG(2005,$P(MAGN0,U,10),2))
. I $P(TMPN2,U,6)=8925 D DATA^MAGGNTI(.TMP,$P(TMPN2,U,7)) S TMP=$P(TMP,U,6)
. S $P(MAGRES,U,32)=$S(TMP="":"",TMP="COMPLETED":1,1:0) ; if TIU check Note status
. S TMP="" ; use TMP to return Description.
. S $P(MAGRES,U,33)=$$ANNSTAT^MAGGI12(MAGIEN,$P(MAGRES,U,29),.TMP) ;Annotation Status
. S $P(MAGRES,U,34)=TMP ; This is Desc of Annotation Status
. S $P(MAGRES,U,35)=$P(MAGN40,U,1) ;the package RAD,LAB,MED,SUR...etc
. S $P(MAGRES,U,36)="" ; This forces "^" to be last character in string.
. Q:GRPCH1NODE=""
. ;--- If the group header is not marked as controlled but the 1st
. ; image is, override the sensitivity flag so that the image
. ;--- abstract is not shown in the image list.
. I '$P(MAGRES,U,28) D:$P($G(@GRPCH1NODE@(100)),U,7)
. . S $P(MAGRES,U,28)=1,$P(MAGRES,U,3)=".\bmp\magsensitive.bmp"
. . Q
. Q
;gek/ out in P94t7 E S $P(MAGRES,U,25)=""
;
;=== Stop displaying a group of 1 as a group
I GROUP,GRPCHCNT=1 D
. N CH1N100,CH1VST
. S $P(MAGRES,U,1)=GRPCH1IEN ; IEN of the 1st image of the group
. S $P(MAGRES,U,6)=GRPCH1TYPE ; OBJECT TYPE (3) of the 1st image
. ;gek/ out in P94t7 Q:'MAG3P59
. ;--- Get the viewable status of the 1st "child"
. S TMP=$S('$G(MAGNOCHK):"Q",1:"")
. S CH1VST=$$VIEWSTAT^MAGGI12(GRPCH1IEN,TMP)
. ;--- Get the image status of the 1st "child"
. S CH1N100=$S(GRPCH1NODE'="":$G(@GRPCH1NODE@(100)),1:"")
. S TMP=+$P(CH1N100,U,8) ; STATUS (113)
. ;--- Override the group's values with those of Child 1
. S $P(MAGRES,U,29)=$$VSTCODE(CH1VST,TMP) ; numeric code of 'View Status'
. S $P(MAGRES,U,30)=TMP ; Status
. ; ANNOTATED due to only child was annotated
. S $P(MAGRES,U,31)=$G(ANNOTATED,0) ; IMAGE been annotated
. ; Don't change to Child for Report Parent info.
. ; Parent Data values are stored in '2' node of the Group.
. S TMP=""
. I $P(MAGN2,U,6)=8925 D DATA^MAGGNTI(.TMP,$P(MAGN2,U,7)) S TMP=$P(TMP,U,6)
. S $P(MAGRES,U,32)=$S(TMP="COMPLETED":1,1:0)
. ; Now need to change the Annotation Status, cause change in 'View Status'
. S TMP="" ; use TMP to return Description.
. S $P(MAGRES,U,33)=$$ANNSTAT^MAGGI12(GRPCH1IEN,$P(MAGRES,U,29),.TMP) ;Annotation Status
. S $P(MAGRES,U,34)=TMP ; Annotation Status Description.
. ; $P(35) is package RAD,LAB,SUR,MED,NOTE etc defined in Group and Child.
. Q
;
;===
Q MAGRES
;
;+++++ CONVERTS THE VIEWABLE STATUS TO THE NUMERIC CODE
VSTCODE(VST,STATUS) ;
Q $S(VST["D":12,VST["Q":21,VST["T":22,VST["R":23,1:+STATUS)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGGAII 16752 printed Oct 16, 2024@18:03:09 Page 2
MAGGAII ;WOIFO/GEK/SG/JSL - RETURNS IMAGE INFO ; 2/20/09 11:37am
+1 ;;3.0;IMAGING;**93,94,122**;Mar 19, 2002;Build 92;Aug 02, 2012
+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 QUIT
+18 ;
+19 ;+++++ PERFORMS SPECIAL CONVERSION OF THE DATE/TIME
DTE(DTI) ;
+1 QUIT $TRANSLATE($$FMTE^XLFDT(DTI,"5Z"),"@"," ")
+2 ;
+3 ;+++++ RETURNS THE FULL NAME OF THE IMAGE FILE
+4 ;
+5 ; MAGXX IEN of the image record in the file #2005
+6 ;
+7 ; FILETYPE Type of the image: "ABSTRACT", "BIG", or "FULL"
+8 ;
+9 ; [.MAGTYPE] Reference to a local variable where the location
+10 ; code is returned to:
+11 ; A Accessible
+12 ; M Magnetic
+13 ; O Offline
+14 ; W WORM
+15 ;
+16 ; [.MAGJBOL] Reference to a local variable where the Jukebox
+17 ; offline message is returned to.
+18 ;
+19 ; Return Values
+20 ; =============
+21 ; <0 ErrorCode~ErrorMessage
+22 ; "" Name is not available or an error
+23 ;
FILENAME(MAGXX,FILETYPE,MAGTYPE,MAGJBOL) ;
+1 NEW MAGFILE1,MAGJBCP,MAGOFFLN,MAGPREF
+2 SET MAGPREF=""
+3 ;--- Don't queue a copy from the JukeBox.
+4 SET MAGJBCP=0
+5 ;--- The FINDFILE^MAGFILEB returns:
+6 ; MAGFILE1 File name (e.g. "LA100066.ABS")
+7 ; if no Network Location pointer or INVALID Pointer
+8 ; then MAGFILE1=-1~NO NETWORK LOCATION POINTER
+9 ; or -1~INVALID NETWORK LOCATION POINTER
+10 ; MAGFILE1(.01) Image description (e.g. "ONE,PATIENT 111223333")
+11 ; MAGJBOL Description of the offline server
+12 ; MAGOFFLN Non-zero if the jukebox is offline
+13 ; MAGPREF Path (e.g. "C:\TEMP\LA\10\00\")
+14 ;--- MAGTYPE "MAG" or "WORM"
+15 DO FINDFILE^MAGFILEB
+16 ;--- The MAGFILE1 may contain '^' in case of an error
+17 SET MAGFILE1=$TRANSLATE(MAGFILE1,"^","~")
+18 if $DATA(MAGFILE1("ERROR"))
SET MAGFILE1=MAGFILE1("ERROR")
+19 SET MAGTYPE=$SELECT($GET(MAGOFFLN):"O",FILETYPE="FULL":"A",1:$EXTRACT(MAGTYPE,1))
+20 ;--- The following line of code replicates the old functionality
+21 if FILETYPE'="BIG"
QUIT $GET(MAGPREF)_MAGFILE1
+22 ;--- Return the full name or an empty string in case of an error
+23 QUIT $SELECT($EXTRACT(MAGFILE1,1,2)="-1":"",1:$GET(MAGPREF)_MAGFILE1)
+24 ;
+25 ;##### RETURNS THE IMAGE DESCRIPTOR
+26 ;
+27 ; MAGIEN IEN of the image record in the file #2005 or
+28 ; in file #2005.1
+29 ;
+30 ; FLAGS Flags that control the execution (can be combined):
+31 ;
+32 ; D Consider only deleted "child" images
+33 ; E Consider only existing "child" images
+34 ;
+35 ; If neither 'E' nor 'D' flag is provided, then an
+36 ; error code is returned.
+37 ;
+38 ; [[.]GRPCNTS] The $$INFO function need counts of images in the
+39 ; group. If these numbers are already available,
+40 ; they can be passed as the value of this parameter.
+41 ; ^01: Number of existing members of the group
+42 ; ^02: Number of deleted members of the group
+43 ;
+44 ; If this parameter is not defiend or empty, the
+45 ; $$INFO function calls the $$GRPCT^MAGGI14 and
+46 ; returns the counts in this parameter if it is
+47 ; passed by reference.
+48 ;
+49 ; Input Variables
+50 ; ===============
+51 ;
+52 ; MAGJOB(
+53 ; "NETPLC",...)
+54 ; "PTNM",...)
+55 ; "RPCPORT")
+56 ; "RPCSERVER")
+57 ;
+58 ; MAGNOCHK Skip the questionable integrity checks if this
+59 ; variable is defined and not zero.
+60 ;
+61 ; Output Variables
+62 ; ================
+63 ;
+64 ; MAGJOB(
+65 ; "NETPLC",...)
+66 ; "PTNM",...)
+67 ;
+68 ; Return Values
+69 ; =============
+70 ; <0 Error descriptor (see the $$ERROR^MAGUERR)
+71 ; >0 Image descriptor
+72 ; ^01: Image IEN
+73 ; ^02: Image full path and name
+74 ; ^03: Abstract full path and name
+75 ; ^04: SHORT DESCRIPTION field and description of
+76 ; offline JukeBox
+77 ; ^05: PROCEDURE/EXAM DATE/TIME field
+78 ; ^06: OBJECT TYPE
+79 ; ^07: PROCEDURE field
+80 ; ^08: display date
+81 ; ^09: PARENT DATA FILE image pointer
+82 ; ^10: ABSTYPE: 'M' magnetic, 'W' worm, 'O' offline
+83 ; ^11: 'A' accessible, 'O' offline
+84 ; ^12: DICOM Series Number
+85 ; ^13: DICOM Image Number
+86 ; ^14: Count of images in group; 1 if single image
+87 ; VISN15
+88 ; ^15: Site parameter IEN
+89 ; ^16: Site parameter CODE
+90 ; ^17: Error description of Integrity Check
+91 ; ^18: Image BIGPath and name
+92 ; ^19: Patient DFN
+93 ; ^20: Patient Name
+94 ; ^21: Image Class: Clin,Admin,Clin/Admin,Admin/Clin
+95 ; ^22: Date Time Image Saved (7)
+96 ; ^23: Document Date (110)
+97 ; ^24: Group IEN
+98 ; ^25: IEN of the 1s child of the group and child's
+99 ; type separated by colon
+100 ; ^26: RPC Broker server
+101 ; ^27: RPC Broker port
+102 ; ^28: Internal value of CONTROLLED IMAGE field (112)
+103 ; converted to a number {0|1}
+104 ; ^29: Viewable Status
+105 ; ^30: Internal value of STATUS field (113)
+106 ; ^31: Image annotated flag (0 or 1)
+107 ; ^32: Image TIU note is completed (0 or 1)
+108 ; ^33: Annotation operation Status
+109 ; ^34: Annotation operation Status Description
+110 ; ^35: Package is the package: RAD,LAB,MED,SUR,NONE,PHOTOID
+111 ;
INFO(MAGIEN,FLAGS,GRPCNTS) ;
+1 ; 1 if the entry referenced by MAGIEN is a group
NEW GROUP
+2 ; IEN of the first image of the group
NEW GRPCH1IEN
+3 ; Global node of the 1st image od the group
NEW GRPCH1NODE
+4 ; Type of the first image of the group
NEW GRPCH1TYPE
+5 ; Number of images in the group
NEW GRPCHCNT
+6 ; Global node of the image referenced by MAGIEN
NEW MAGNODE
+7 ; Result value (image descriptor)
NEW MAGRES
+8 ;
+9 ;N MAG3P59 ;gek/ out in P94t7
+10 NEW MAGMSG,MAGN0,MAGN100,MAGN2,MAGN40,MAGJBOL
+11 NEW MAGVST,MDFN,IEN,PLC,PLCODE,RC,TMP,X,ANNOTATED,TMPN2
+12 ;
+13 ;=== Validate control flags
+14 SET FLAGS=$GET(FLAGS)
+15 ;--- Unknown/Unsupported flag(s)
+16 if $TRANSLATE(FLAGS,"DE")'=""
QUIT $$IPVE^MAGUERR("FLAGS")
+17 ;--- Missing required flag
+18 if $TRANSLATE(FLAGS,"DE")=FLAGS
QUIT $$ERROR^MAGUERR(-6,,"D,E")
+19 ;
+20 ;=== Get the global node of the record
+21 SET MAGNODE=$$NODE^MAGGI11(MAGIEN)
+22 ;
+23 ;=== Initialize variables
+24 SET MAGRES=MAGIEN
SET RC=0
+25 ;gek/ out in P94t7 S MAG3P59=$D(MAGJOB("RPCSERVER"))&$D(MAGJOB("RPCPORT"))
+26 if '$DATA(MAGJOB("NETPLC"))
DO NETPLCS^MAGGTU6
+27 IF MAGNODE'=""
Begin DoDot:1
+28 SET MAGN0=$GET(@MAGNODE@(0))
SET MAGN2=$GET(@MAGNODE@(2))
+29 SET MAGN40=$GET(@MAGNODE@(40))
SET MAGN100=$GET(@MAGNODE@(100))
End DoDot:1
+30 IF '$TEST
SET (MAGN0,MAGN2,MAGN40,MAGN100)=""
+31 ;
+32 ;=== Cache patient names; call $$GET 1 time not 2000
+33 ; PATIENT (5)
SET MDFN=$PIECE(MAGN0,U,7)
+34 IF MDFN
IF '$DATA(MAGJOB("PTNM",MDFN))
Begin DoDot:1
+35 SET MAGJOB("PTNM",MDFN)=$$GET1^DIQ(2,MDFN_",",.01)
+36 ;--- Cache no more than 10 records in the MAGJOB("PTNM")
+37 SET TMP=+$PIECE($GET(MAGJOB("PTNM")),U,10)
+38 SET MAGJOB("PTNM")=MDFN_U_$PIECE($GET(MAGJOB("PTNM")),U,1,9)
+39 if TMP>0
KILL MAGJOB("PTNM",TMP)
+40 QUIT
End DoDot:1
+41 ;
+42 ;=== Process the group header
+43 SET GRPCHCNT=0
SET (GRPCH1IEN,GRPCH1NODE,GRPCH1TYPE)=""
+44 ;--- Count the images of the group
+45 if $GET(GRPCNTS)=""
SET GRPCNTS=$$GRPCT^MAGGI14(MAGIEN)
+46 if GRPCNTS'<0
Begin DoDot:1
+47 ; Existing entries
if FLAGS["E"
SET GRPCHCNT=GRPCHCNT+$PIECE(GRPCNTS,U,1)
+48 ; Deleted entries
if FLAGS["D"
SET GRPCHCNT=GRPCHCNT+$PIECE(GRPCNTS,U,2)
+49 QUIT
End DoDot:1
+50 ;--- Check the object type
+51 SET GROUP=$$ISGRP^MAGGI11(MAGIEN)
+52 IF GROUP
Begin DoDot:1
+53 ;--- Get the IEN of the first image of the group
+54 SET GRPCH1IEN=$$GRPCH1^MAGGI14(MAGIEN,FLAGS)
+55 IF GRPCH1IEN'>0
SET GRPCH1IEN=""
QUIT
+56 ;--- If we cannot get the global node of the 1st image of the
+57 ;--- group (this should never happen) clear its IEN as well.
+58 SET GRPCH1NODE=$$NODE^MAGGI11(GRPCH1IEN,.TMP)
+59 IF GRPCH1NODE=""
SET GRPCH1IEN=""
QUIT
+60 ;--- Get the type of the first image of the group
+61 SET GRPCH1TYPE=$PIECE(@GRPCH1NODE@(0),U,6)
+62 QUIT
End DoDot:1
+63 ;--- Check the annotation info
+64 ;p122 - add IMAGE annotated flag
SET ANNOTATED=+$PIECE($GET(^MAG(2005.002,MAGIEN,1,0)),U,4)
+65 ;VistARad annotation #2005.001/PS data #2005.05
IF 'ANNOTATED
IF $DATA(^MAG(2005,MAGIEN,210,0))
SET ANNOTATED=1
+66 ;p122 - find any child w/ annotation
IF 'ANNOTATED
IF GROUP!$DATA(^MAG(2005,MAGIEN,1,0))
Begin DoDot:1
+67 NEW NO,CH
SET NO=0
+68 FOR
SET NO=$ORDER(^MAG(2005,MAGIEN,1,NO))
if 'NO
QUIT
SET CH=+$GET(^(NO,0))
if CH
SET ANNOTATED=+$PIECE($GET(^MAG(2005.002,CH,1,0)),U,4)
if $DATA(^MAG(2005,CH,210,0))
SET ANNOTATED=1
if ANNOTATED
QUIT
+69 QUIT
End DoDot:1
+70 if ANNOTATED
SET ANNOTATED=1
+71 ;=== If this is a group and it is not empty, then use
+72 ; the first image to get the names of image files.
+73 ;=== Otherwise, get them from the group header itself.
+74 SET IEN=$SELECT(GRPCH1IEN>0:GRPCH1IEN,1:MAGIEN)
+75 ;--- Get full path and file name of the Abstract.
+76 SET $PIECE(MAGRES,U,3)=$$FILENAME(IEN,"ABSTRACT",.TMP,.MAGJBOL)
+77 ; Abstract type ('M', 'O', or 'W')
SET $PIECE(MAGRES,U,10)=TMP
+78 ;--- Get the full path and file name of the FULL RES image.
+79 SET $PIECE(MAGRES,U,2)=$$FILENAME(IEN,"FULL",.TMP)
+80 ; 'A' - accessible, 'O' - offline
SET $PIECE(MAGRES,U,11)=TMP
+81 ;--- Get the full path and file name for the BIG image.
+82 SET $PIECE(MAGRES,U,18)=$$FILENAME(IEN,"BIG")
+83 ;
+84 ;=== Get the site parameters IEN and code
+85 SET IEN=0
+86 IF 'GROUP
Begin DoDot:1
+87 ;--- If the record is a standalone image entry, then
+88 ;--- get the location IEN from this entry.
+89 SET IEN=+$SELECT($PIECE(MAGN0,U,3):$PIECE(MAGN0,U,3),1:$PIECE(MAGN0,U,5))
+90 QUIT
End DoDot:1
+91 IF '$TEST
IF GRPCH1NODE'=""
Begin DoDot:1
+92 ;--- If the group references "child" entries of requested kind(s),
+93 ;--- then get the network location IEN from the 1st one.
+94 SET TMP=$GET(@GRPCH1NODE@(0))
+95 SET IEN=+$SELECT($PIECE(TMP,U,3):$PIECE(TMP,U,3),1:$PIECE(TMP,U,5))
+96 QUIT
End DoDot:1
+97 IF '$TEST
IF (FLAGS'["D")!(FLAGS'["E")
Begin DoDot:1
+98 ;--- Otherwise, try to get the location IEN from the 1st "child"
+99 ;--- image regardless of the requested kind (existing or deleted).
+100 NEW CH1IEN,CH1NODE
+101 SET CH1IEN=$$GRPCH1^MAGGI14(MAGIEN,"DE")
if CH1IEN'>0
QUIT
+102 SET CH1NODE=$$NODE^MAGGI11(CH1IEN)
if CH1NODE=""
QUIT
+103 SET TMP=$GET(@CH1NODE@(0))
+104 SET IEN=+$SELECT($PIECE(TMP,U,3):$PIECE(TMP,U,3),1:$PIECE(TMP,U,5))
+105 QUIT
End DoDot:1
+106 ; Site Parameters IEN
SET PLC=$PIECE($GET(MAGJOB("NETPLC",IEN)),U,1)
+107 ; Site Code (e.g. "WAS")
SET PLCODE=$PIECE($GET(MAGJOB("NETPLC",IEN)),U,2)
+108 ;--- Groups of 0 images need this
+109 if PLC=""
SET PLC=$GET(MAGJOB("PLC"))
SET PLCODE=$GET(MAGJOB("PLCODE"))
+110 ;
+111 ;=== SHORT DESCRIPTION field (10) and description of offline JukeBox
+112 SET $PIECE(MAGRES,U,4)=$PIECE(MAGN2,U,4)_$GET(MAGJBOL)
+113 ;
+114 ;=== Various fields
+115 ; PROCEDURE/EXAM DATE/TIME (15)
SET $PIECE(MAGRES,U,5)=$PIECE(MAGN2,U,5)
+116 ; OBJECT TYPE (3)
SET $PIECE(MAGRES,U,6)=$PIECE(MAGN0,U,6)
+117 ; PROCEDURE (6)
SET $PIECE(MAGRES,U,7)=$PIECE(MAGN0,U,8)
+118 ; Ext. PROCEDURE/EXAM DATE/TIME
SET $PIECE(MAGRES,U,8)=$$DTE($PIECE(MAGN2,U,5))
+119 ; PARENT DATA FILE IMAGE POINTER (18)
SET $PIECE(MAGRES,U,9)=$PIECE(MAGN2,U,8)
+120 ;
+121 ;=== 2/1/99 Dicom Series number and Dicom Image Number
+122 ; $p(12) and $p(13)
+123 ;
+124 ;=== Number of images of requested kind in the group
+125 SET $PIECE(MAGRES,U,14)=$SELECT(GRPCHCNT>0:GRPCHCNT,1:1)
+126 ;
+127 ;=== Site IEN and code
+128 SET $PIECE(MAGRES,U,15,16)=PLC_U_PLCODE
+129 ;
+130 ;=== Data integrity checks
+131 SET TMP=$SELECT('$GET(MAGNOCHK):"Q",1:"")
+132 SET MAGVST=$$VIEWSTAT^MAGGI12(MAGIEN,TMP,.MAGMSG)
+133 ;;W !,"MAGVST : ",$G(MAGVST) ; TESTING, TAKE OUT THIS LINE.
+134 IF MAGVST["Q"
Begin DoDot:1
+135 ;--- Remove the file name of the full resolution image
+136 SET $PIECE(MAGRES,U,2)="-1~Questionable Data Integrity"
+137 ;--- Replace the Abstract with the special bitmap
+138 SET $PIECE(MAGRES,U,3)=".\bmp\imageQA.bmp"
+139 ;--- Prevent the client from changing the Questionable
+140 ;--- Integrity abstract bitmap to the Offline bitmap.
+141 if $PIECE(MAGRES,U,6)'=11
SET $PIECE(MAGRES,U,6)=99
+142 SET $PIECE(MAGRES,U,10)="M"
+143 ;--- Return the error message
+144 SET $PIECE(MAGRES,U,17)=MAGMSG("Q")
+145 QUIT
End DoDot:1
+146 ;
+147 ;=== Various fields
+148 ; Patient IEN (DFN)
SET $PIECE(MAGRES,U,19)=MDFN
+149 SET $PIECE(MAGRES,U,20)=$SELECT(MDFN:MAGJOB("PTNM",MDFN),1:MDFN)
+150 ; DATE/TIME IMAGE SAVED (7)
SET $PIECE(MAGRES,U,22)=$$DTE($PIECE(MAGN2,U))
+151 ; CREATION DATE (110)
SET $PIECE(MAGRES,U,23)=$$DTE($PIECE(MAGN100,U,6))
+152 ;
+153 ;=== Name of the image class
+154 ; TYPE INDEX (42)
SET IEN=+$PIECE(MAGN40,U,3)
+155 if IEN>0
SET $PIECE(MAGRES,U,21)=$$GET1^DIQ(2005.83,IEN_",",1,,,"MAGMSG")
+156 ;
+157 ;=== If the client is newer than patch 59, then we can set beyond
+158 ; 25 pieces. Additional "^" at the end of the result prevents
+159 ;=== problems on the client side.
+160 ;gek/ out in P94t7 I MAG3P59 D
Begin DoDot:1
+161 ; GROUP PARENT (14)
SET $PIECE(MAGRES,U,24)=$PIECE(MAGN0,U,10)
+162 if GRPCHCNT>1
SET $PIECE(MAGRES,U,25)=GRPCH1IEN_":"_GRPCH1TYPE
+163 ; GEK P94 put in $G
SET $PIECE(MAGRES,U,26)=$GET(MAGJOB("RPCSERVER"))
+164 ; GEK P94 put in $G
SET $PIECE(MAGRES,U,27)=$GET(MAGJOB("RPCPORT"))
+165 ; CONTROLLED IMAGE (112)
SET TMP=+$PIECE(MAGN100,U,7)
+166 SET $PIECE(MAGRES,U,28)=TMP
+167 if TMP
SET $PIECE(MAGRES,U,3)=".\bmp\magsensitive.bmp"
+168 ; STATUS (113)
SET TMP=+$PIECE(MAGN100,U,8)
+169 SET $PIECE(MAGRES,U,29)=$$VSTCODE(MAGVST,TMP)
+170 SET $PIECE(MAGRES,U,30)=TMP
+171 ; patch 122 new data pieces (31-35) for annotation.
+172 ;IMAGE annotated
SET $PIECE(MAGRES,U,31)=$GET(ANNOTATED)
+173 SET TMP=""
+174 ; if it is a child of a Group, the Parent data is in the Group.
+175 SET TMPN2=MAGN2
IF $PIECE(MAGN0,U,10)
SET TMPN2=$GET(^MAG(2005,$PIECE(MAGN0,U,10),2))
+176 IF $PIECE(TMPN2,U,6)=8925
DO DATA^MAGGNTI(.TMP,$PIECE(TMPN2,U,7))
SET TMP=$PIECE(TMP,U,6)
+177 ; if TIU check Note status
SET $PIECE(MAGRES,U,32)=$SELECT(TMP="":"",TMP="COMPLETED":1,1:0)
+178 ; use TMP to return Description.
SET TMP=""
+179 ;Annotation Status
SET $PIECE(MAGRES,U,33)=$$ANNSTAT^MAGGI12(MAGIEN,$PIECE(MAGRES,U,29),.TMP)
+180 ; This is Desc of Annotation Status
SET $PIECE(MAGRES,U,34)=TMP
+181 ;the package RAD,LAB,MED,SUR...etc
SET $PIECE(MAGRES,U,35)=$PIECE(MAGN40,U,1)
+182 ; This forces "^" to be last character in string.
SET $PIECE(MAGRES,U,36)=""
+183 if GRPCH1NODE=""
QUIT
+184 ;--- If the group header is not marked as controlled but the 1st
+185 ; image is, override the sensitivity flag so that the image
+186 ;--- abstract is not shown in the image list.
+187 IF '$PIECE(MAGRES,U,28)
if $PIECE($GET(@GRPCH1NODE@(100)),U,7)
Begin DoDot:2
+188 SET $PIECE(MAGRES,U,28)=1
SET $PIECE(MAGRES,U,3)=".\bmp\magsensitive.bmp"
+189 QUIT
End DoDot:2
+190 QUIT
End DoDot:1
+191 ;gek/ out in P94t7 E S $P(MAGRES,U,25)=""
+192 ;
+193 ;=== Stop displaying a group of 1 as a group
+194 IF GROUP
IF GRPCHCNT=1
Begin DoDot:1
+195 NEW CH1N100,CH1VST
+196 ; IEN of the 1st image of the group
SET $PIECE(MAGRES,U,1)=GRPCH1IEN
+197 ; OBJECT TYPE (3) of the 1st image
SET $PIECE(MAGRES,U,6)=GRPCH1TYPE
+198 ;gek/ out in P94t7 Q:'MAG3P59
+199 ;--- Get the viewable status of the 1st "child"
+200 SET TMP=$SELECT('$GET(MAGNOCHK):"Q",1:"")
+201 SET CH1VST=$$VIEWSTAT^MAGGI12(GRPCH1IEN,TMP)
+202 ;--- Get the image status of the 1st "child"
+203 SET CH1N100=$SELECT(GRPCH1NODE'="":$GET(@GRPCH1NODE@(100)),1:"")
+204 ; STATUS (113)
SET TMP=+$PIECE(CH1N100,U,8)
+205 ;--- Override the group's values with those of Child 1
+206 ; numeric code of 'View Status'
SET $PIECE(MAGRES,U,29)=$$VSTCODE(CH1VST,TMP)
+207 ; Status
SET $PIECE(MAGRES,U,30)=TMP
+208 ; ANNOTATED due to only child was annotated
+209 ; IMAGE been annotated
SET $PIECE(MAGRES,U,31)=$GET(ANNOTATED,0)
+210 ; Don't change to Child for Report Parent info.
+211 ; Parent Data values are stored in '2' node of the Group.
+212 SET TMP=""
+213 IF $PIECE(MAGN2,U,6)=8925
DO DATA^MAGGNTI(.TMP,$PIECE(MAGN2,U,7))
SET TMP=$PIECE(TMP,U,6)
+214 SET $PIECE(MAGRES,U,32)=$SELECT(TMP="COMPLETED":1,1:0)
+215 ; Now need to change the Annotation Status, cause change in 'View Status'
+216 ; use TMP to return Description.
SET TMP=""
+217 ;Annotation Status
SET $PIECE(MAGRES,U,33)=$$ANNSTAT^MAGGI12(GRPCH1IEN,$PIECE(MAGRES,U,29),.TMP)
+218 ; Annotation Status Description.
SET $PIECE(MAGRES,U,34)=TMP
+219 ; $P(35) is package RAD,LAB,SUR,MED,NOTE etc defined in Group and Child.
+220 QUIT
End DoDot:1
+221 ;
+222 ;===
+223 QUIT MAGRES
+224 ;
+225 ;+++++ CONVERTS THE VIEWABLE STATUS TO THE NUMERIC CODE
VSTCODE(VST,STATUS) ;
+1 QUIT $SELECT(VST["D":12,VST["Q":21,VST["T":22,VST["R":23,1:+STATUS)