MAGGTII ;WOIFO/GEK - RETURN IMAGE INFO ; 08 Jan 2010 2:28 PM
 ;;3.0;IMAGING;**8,48,63,59,83**;Mar 19, 2002;Build 1690;Mar 29, 2010
 ;; 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.                     |
 ;; +---------------------------------------------------------------+
 ;;
 ; CALL WITH MAGXX=IEN of IMAGE FILE (2005)
 ; RETURNS MAGFILE='^' delimited string of Image information.
 ; 
 ; 
INFO ;Get info for an Image File entry
 ; We assume that MAGXX exists and is the Image File entry
 ; We return a '^' delimited string for the Image entry.
 ; $P(1^2^3)   IEN^Image FullPath and name^Abstract FullPath and Name
 ; $P(4)       SHORT DESCRIPTION field and desc of offline JukeBox
 ; $P(5)       PROCEDURE/ EXAM DATE/TIME field
 ; $P(6)       OBJECT TYPE
 ; $P(7)       PROCEDURE field
 ; $P(8)       display date
 ; $P(9)       to return the PARENT DATA FILE image pointer
 ; $p(10)      return the ABSTYPE  'M' magnetic 'W' worm  'O' offline
 ; change $p(11) from A or O to 'M' 'W' or 'O'.  Same as Abs
 ; $p(11)      is 'M' magnetic 'W' worm  'O' offline for FullType
 ; $p(12^13)   Dicom Series Number  $p(12) and   Image Number  $p(13)
 ; $p(14)      is count of images in group, 1 if single image.
 ; VISN15
 ; $p(15^16)   SiteParameter IEN ^ SiteParameter CODE
 ; $P(17)      is err description of Integrity Check
 ; $P(18)      Image BIGPath and name             //Patch 5
 ; $P(19^20)   Patient DFN  ^ Patient Name; // Patch 3.8
 ; $P(21)          Image Class: Clin,Admin,Clin/Admin,Admin/Clin
 ; $p(22)      Date Time Image Saved(FLD 7)
 ; $p(23)      Document Date    (FLD 110)
 ;
 N FILETYPE,MAGPREF,MAGJBCP,GRPTYPE,GRPIEN,ABSTYPE,MAGTYPE,MAGJBOL
 N MAGOFFLN,FULLTYPE,MAGOBJT,MAGQI,X
 N ABSFILE,FULLFILE,BIGFILE,PATCH,MDFN,FNL,PLC,PLCODE
 N MAGN0,MAGN2,MAGN40,MAGN100
 ;    set the Variables for the Global Nodes of the Image Entry
 S MAGN0=$G(^MAG(2005,MAGXX,0))
 S MDFN=$P(MAGN0,"^",7)
 S MAGN2=$G(^MAG(2005,MAGXX,2))
 S MAGN40=$G(^MAG(2005,MAGXX,40))
 S MAGN100=$G(^MAG(2005,MAGXX,100))
 ; Set Name in Variable, Call $$GET 1 time not 2000
 I MDFN I '$D(MAGJOB("PTNM",MDFN)) S MAGJOB("PTNM",MDFN)=$$GET1^DIQ(2,MDFN_",",.01)
 I '$D(MAGJOB("NETPLC")) D NETPLCS^MAGGTU6
 ;  Object Type
 S MAGOBJT=$P(MAGN0,"^",6)
 ; if this is a group, change MAGXX to first image in group to get
 ;  that abstract to use for the group abstract
 I MAGOBJT=11!(MAGOBJT=16) S GRPTYPE=MAGOBJT D
 . S X=$O(^MAG(2005,MAGXX,1,0))
 . ; next line to account for group of NO images for whatever reason.
 . ;  we change Object Type to XRAY (3)  or STILL IMAGE (1)
 . I 'X S MAGOBJT=$S(MAGOBJT=11:3,MAGOBJT=16:1,1:1) K GRPTYPE Q
 . S X=^MAG(2005,MAGXX,1,X,0)
 . ;  keep the Real IEN, so we can change back later
 . S GRPIEN=MAGXX,MAGXX=+X
 . Q
 S MAGJBCP=0 ; Don't Queue a copy from JukeBox.
 ;  The call to FINDFILE returns:
 ; MAGFILE1=LA100066.ABS   filename
 ;          if no Network Location pointer or INVALID Pointer
 ;          then MAGFILE1=-1~NO NETWORK LOCATION POINTER  
 ;          or -1~INVALID NETWORK LOCATION POINTER
 ; MAGFILE1(.01)=ONE,PATIENT   111223333 image desc
 ; MAGJBOL=    desc of Offline server
 ; MAGOFFLN=    if JB is offline
 ; MAGPREF=C:\TEMP\LA\10\00\  path
 ; MAGTYPE=MAG    MAG or WORM
 ;
 ;   first get Full Path and File Name of the Abstract
 S FILETYPE="ABSTRACT" K MAGFILE1("ERROR")
 S MAGPREF="" D FINDFILE^MAGFILEB
 S MAGFILE1=$TR(MAGFILE1,"^","~") ; MAGFILE1 has '^' in it if errors
 I $D(MAGFILE1("ERROR")) S MAGFILE1=MAGFILE1("ERROR")
 S ABSTYPE=$E(MAGTYPE,1) I MAGOFFLN S ABSTYPE="O"
 ;   Here we must test for +MAGFILE1 = -1  which means we don't have
 ;   any entry in the Image File for the Abstract Network Location 
 ;   pointer.
 S MAGPREF=$G(MAGPREF)
 S ABSFILE=MAGPREF_MAGFILE1
 ;
 ;    now lets get the Full Path and file name FULL RES image.
 ;p83 S FULLTYPE="A" ; Accessible
 S FILETYPE="FULL" K MAGFILE1("ERROR")
 S MAGPREF="" D FINDFILE^MAGFILEB
 S MAGFILE1=$TR(MAGFILE1,"^","~") ; MAGFILE1 has '^' in it if errors
 I $D(MAGFILE1("ERROR")) S MAGFILE1=MAGFILE1("ERROR")
 ;p83 MAGTYPE is "MAG... " or "WORM...", use instead of 'A'
 S FULLTYPE=$E(MAGTYPE,1) I MAGOFFLN S FULLTYPE="O"
 ;  here we have to do the same test as above. for bad data.
 S MAGPREF=$G(MAGPREF)
 S FULLFILE=MAGPREF_MAGFILE1
 ;
 ;    now lets get the Full Path and file name for BIG image.
 S FILETYPE="BIG" K MAGFILE1("ERROR")
 S MAGPREF="" D FINDFILE^MAGFILEB
 S MAGFILE1=$TR(MAGFILE1,"^","~") ; MAGFILE1 has '^' in it if errors
 I $D(MAGFILE1("ERROR")) S MAGFILE1=MAGFILE1("ERROR")
 S MAGPREF=$G(MAGPREF)
 S BIGFILE=$S($E(MAGFILE1,1,2)="-1":"",1:MAGPREF_MAGFILE1)
 ;
 K MAGFILE1 ; Cleanup
 ; Site and Site Code are in Entry of first Image in Group
 ; so we need to set here, before MAGXX is changed back.
 S X=$G(^MAG(2005,MAGXX,0))
 S FNL=$S(+$P(X,"^",3):$P(X,"^",3),1:+$P(X,"^",5))
 S PLC=$P($G(MAGJOB("NETPLC",FNL)),"^",1)
 S PLCODE=$P($G(MAGJOB("NETPLC",FNL)),"^",2)
 I PLC="" S PLC=$G(MAGJOB("PLC")),PLCODE=$G(MAGJOB("PLCODE")) ; Group of 0 need this.
 ;   if we were using first image of a group, reset the Real IEN 
 I $G(GRPIEN) S MAGXX=GRPIEN
 ;
 ;   we have to change the OBJECT TYPE variable back to real value
 ;   MAGOBJT might have been changed if we had Group of no images.
 ;   but we need to keep it changed, because Delphi window checks this
 ;   entry to determine which window to open.
 ;   i.e. Group window, Single image window, 
 S MAGOBJT=$P(MAGN0,U,6)
 ;
 ; now start building the return string
 ;
 S PATCH=$P($G(MAGJOB("VERSION")),".",3) ; //'="3.0.8")
 K MAGFILE
 S $P(MAGFILE,U,25)="" ; We put extra '^^^' on end of String to stop error in Delphi.
 ; Pieces 26 BrokerServer and 27 Broker Port are set if this is P59 Client.
 ; Clients Prior to Patch 59, the String must only be 25 pieces. - Patch 45 snafu
 ; 
 ; $P(1^2^3) IEN^Image FullPath and name^Abstract FullPath and Name 
 S $P(MAGFILE,U,1,3)=MAGXX_U_FULLFILE_U_ABSFILE
 ;
 ; now set $P(4) SHORT DESCRIPTION field and desc of offline JukeBox
 S $P(MAGFILE,U,4)=$P(MAGN2,U,4)_$G(MAGJBOL)
 ;
 ; now set $P(5)PROCEDURE/ EXAM DATE/TIME field
 S $P(MAGFILE,U,5)=$P(MAGN2,U,5)
 ;
 ; now set $P(6) OBJECT TYPE
 S $P(MAGFILE,U,6)=MAGOBJT
 ;
 ; now set $P(7) PROCEDURE field
 S $P(MAGFILE,U,7)=$P(MAGN0,U,8)
 ;
 ; now we're making a DATE to display and will use it for a sort in  
 ;  the delphi TStringGrid so we display mm/dd/yyyy
 ; now set $P(8) display date
 S X=$$FMTE^XLFDT($P(MAGN2,U,5),"5Z")
 S X=$TR(X,"@"," ")
 S $P(MAGFILE,U,8)=X
 ;
 ; now return the PARENT DATA FILE image pointer
 S $P(MAGFILE,U,9)=$P(MAGN2,U,8)
 ;
 ; now return the ABSTYPE ( this is 'M' or 'W' or 'O' )
 ; 'M' magnetic 'W' worm  'O' offline
 S $P(MAGFILE,U,10)=ABSTYPE
 ;
 ; now return the code to show if full res image is offline 'A' or 'O'
 ; 'A' accessible   'O' offline
 S $P(MAGFILE,U,11)=FULLTYPE
 ;
 ;  2/1/99 Dicom Series number and Dicom Image Number  
 ;    $p(12) and $p(13)
 ;
 ; 14 - count of images , if this is a group
 S X=+$P($G(^MAG(2005,MAGXX,1,0)),U,4),$P(MAGFILE,U,14)=$S(X:X,1:1)
 ;
 ; $p(15^16 ) are SiteIEN and SiteCode Consolidation - DBI
 ; We use SiteIEN and SiteCODE from above 
 S $P(MAGFILE,"^",15)=PLC
 S $P(MAGFILE,"^",16)=PLCODE
 ;
 ; $p(17)           8/22/01 GEK Mod for integrity check.
 I '$G(MAGNOCHK) D CHK^MAGGSQI(.MAGQI,MAGXX) I 'MAGQI(0) D
 . ; remove the Abstract and Image File Names ; 2/14/03 remove c:\program files... with .\bmp\
 . S $P(MAGFILE,U,2,3)="-1~Questionable Data Integrity^.\bmp\imageQA.bmp"
 . ;this stops Delphi App from changing Abstract BMP to OFFLINE IMAGE
 . S $P(MAGFILE,U,6)=$S(($P(MAGFILE,U,6)'=11):"99",1:11)
 . S $P(MAGFILE,U,10)="M"
 . ;Send the error message
 . S $P(MAGFILE,U,17)=$P(MAGQI(0),U,2)
 ; $p(18) is BIGFile Full name and path.
 S $P(MAGFILE,U,18)=BIGFILE
 ; DFN
 S $P(MAGFILE,U,19)=$P(MAGN0,U,7)
 ; Patient Name
 S $P(MAGFILE,U,20)=$S(MDFN:MAGJOB("PTNM",MDFN),1:MDFN)
 S $P(MAGFILE,U,21)=$S(+$P(MAGN40,U,2):$P(^MAG(2005.82,$P(MAGN40,U,2),0),U),1:"")
 S X=$$FMTE^XLFDT($P(MAGN2,U,1),"5Z") ; Date/Time Image Saved  #7
 S X=$TR(X,"@"," ")
 S $P(MAGFILE,U,22)=X
 S X=$$FMTE^XLFDT($P(MAGN100,U,6),"5Z")   ; DocumentDate #110
 S X=$TR(X,"@"," ")
 S $P(MAGFILE,U,23)=X
 ; If Patch 59 Client - we can set beyond 25 pieces.
 I $D(MAGJOB("RPCSERVER"))&$D(MAGJOB("RPCPORT")) D
 . S $P(MAGFILE,U,26)=MAGJOB("RPCSERVER")
 . S $P(MAGFILE,U,27)=MAGJOB("RPCPORT")
 . S $P(MAGFILE,U,28)="" ; "^" at end, stops problems in delphi
 . Q
 ; Stop displaying a Group of 1 as a Group, so here we'll change Object type
 ;  to that of the '1ST' image in the group of 1.
 I $P($G(^MAG(2005,MAGXX,1,0)),U,4)=1 D
 . S X=$O(^MAG(2005,MAGXX,1,0))
 . S X=+^MAG(2005,MAGXX,1,X,0)
 . S $P(MAGFILE,U,6)=$P(^MAG(2005,X,0),U,6) ; OBJECT TYPE OF 1ST IMAGE IN GROUP
 . S $P(MAGFILE,U,1)=X
 . Q
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGGTII   9776     printed  Sep 23, 2025@19:39:15                                                                                                                                                                                                     Page 2
MAGGTII   ;WOIFO/GEK - RETURN IMAGE INFO ; 08 Jan 2010 2:28 PM
 +1       ;;3.0;IMAGING;**8,48,63,59,83**;Mar 19, 2002;Build 1690;Mar 29, 2010
 +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      ; CALL WITH MAGXX=IEN of IMAGE FILE (2005)
 +18      ; RETURNS MAGFILE='^' delimited string of Image information.
 +19      ; 
 +20      ; 
INFO      ;Get info for an Image File entry
 +1       ; We assume that MAGXX exists and is the Image File entry
 +2       ; We return a '^' delimited string for the Image entry.
 +3       ; $P(1^2^3)   IEN^Image FullPath and name^Abstract FullPath and Name
 +4       ; $P(4)       SHORT DESCRIPTION field and desc of offline JukeBox
 +5       ; $P(5)       PROCEDURE/ EXAM DATE/TIME field
 +6       ; $P(6)       OBJECT TYPE
 +7       ; $P(7)       PROCEDURE field
 +8       ; $P(8)       display date
 +9       ; $P(9)       to return the PARENT DATA FILE image pointer
 +10      ; $p(10)      return the ABSTYPE  'M' magnetic 'W' worm  'O' offline
 +11      ; change $p(11) from A or O to 'M' 'W' or 'O'.  Same as Abs
 +12      ; $p(11)      is 'M' magnetic 'W' worm  'O' offline for FullType
 +13      ; $p(12^13)   Dicom Series Number  $p(12) and   Image Number  $p(13)
 +14      ; $p(14)      is count of images in group, 1 if single image.
 +15      ; VISN15
 +16      ; $p(15^16)   SiteParameter IEN ^ SiteParameter CODE
 +17      ; $P(17)      is err description of Integrity Check
 +18      ; $P(18)      Image BIGPath and name             //Patch 5
 +19      ; $P(19^20)   Patient DFN  ^ Patient Name; // Patch 3.8
 +20      ; $P(21)          Image Class: Clin,Admin,Clin/Admin,Admin/Clin
 +21      ; $p(22)      Date Time Image Saved(FLD 7)
 +22      ; $p(23)      Document Date    (FLD 110)
 +23      ;
 +24       NEW FILETYPE,MAGPREF,MAGJBCP,GRPTYPE,GRPIEN,ABSTYPE,MAGTYPE,MAGJBOL
 +25       NEW MAGOFFLN,FULLTYPE,MAGOBJT,MAGQI,X
 +26       NEW ABSFILE,FULLFILE,BIGFILE,PATCH,MDFN,FNL,PLC,PLCODE
 +27       NEW MAGN0,MAGN2,MAGN40,MAGN100
 +28      ;    set the Variables for the Global Nodes of the Image Entry
 +29       SET MAGN0=$GET(^MAG(2005,MAGXX,0))
 +30       SET MDFN=$PIECE(MAGN0,"^",7)
 +31       SET MAGN2=$GET(^MAG(2005,MAGXX,2))
 +32       SET MAGN40=$GET(^MAG(2005,MAGXX,40))
 +33       SET MAGN100=$GET(^MAG(2005,MAGXX,100))
 +34      ; Set Name in Variable, Call $$GET 1 time not 2000
 +35       IF MDFN
               IF '$DATA(MAGJOB("PTNM",MDFN))
                   SET MAGJOB("PTNM",MDFN)=$$GET1^DIQ(2,MDFN_",",.01)
 +36       IF '$DATA(MAGJOB("NETPLC"))
               DO NETPLCS^MAGGTU6
 +37      ;  Object Type
 +38       SET MAGOBJT=$PIECE(MAGN0,"^",6)
 +39      ; if this is a group, change MAGXX to first image in group to get
 +40      ;  that abstract to use for the group abstract
 +41       IF MAGOBJT=11!(MAGOBJT=16)
               SET GRPTYPE=MAGOBJT
               Begin DoDot:1
 +42               SET X=$ORDER(^MAG(2005,MAGXX,1,0))
 +43      ; next line to account for group of NO images for whatever reason.
 +44      ;  we change Object Type to XRAY (3)  or STILL IMAGE (1)
 +45               IF 'X
                       SET MAGOBJT=$SELECT(MAGOBJT=11:3,MAGOBJT=16:1,1:1)
                       KILL GRPTYPE
                       QUIT 
 +46               SET X=^MAG(2005,MAGXX,1,X,0)
 +47      ;  keep the Real IEN, so we can change back later
 +48               SET GRPIEN=MAGXX
                   SET MAGXX=+X
 +49               QUIT 
               End DoDot:1
 +50      ; Don't Queue a copy from JukeBox.
           SET MAGJBCP=0
 +51      ;  The call to FINDFILE returns:
 +52      ; MAGFILE1=LA100066.ABS   filename
 +53      ;          if no Network Location pointer or INVALID Pointer
 +54      ;          then MAGFILE1=-1~NO NETWORK LOCATION POINTER  
 +55      ;          or -1~INVALID NETWORK LOCATION POINTER
 +56      ; MAGFILE1(.01)=ONE,PATIENT   111223333 image desc
 +57      ; MAGJBOL=    desc of Offline server
 +58      ; MAGOFFLN=    if JB is offline
 +59      ; MAGPREF=C:\TEMP\LA\10\00\  path
 +60      ; MAGTYPE=MAG    MAG or WORM
 +61      ;
 +62      ;   first get Full Path and File Name of the Abstract
 +63       SET FILETYPE="ABSTRACT"
           KILL MAGFILE1("ERROR")
 +64       SET MAGPREF=""
           DO FINDFILE^MAGFILEB
 +65      ; MAGFILE1 has '^' in it if errors
           SET MAGFILE1=$TRANSLATE(MAGFILE1,"^","~")
 +66       IF $DATA(MAGFILE1("ERROR"))
               SET MAGFILE1=MAGFILE1("ERROR")
 +67       SET ABSTYPE=$EXTRACT(MAGTYPE,1)
           IF MAGOFFLN
               SET ABSTYPE="O"
 +68      ;   Here we must test for +MAGFILE1 = -1  which means we don't have
 +69      ;   any entry in the Image File for the Abstract Network Location 
 +70      ;   pointer.
 +71       SET MAGPREF=$GET(MAGPREF)
 +72       SET ABSFILE=MAGPREF_MAGFILE1
 +73      ;
 +74      ;    now lets get the Full Path and file name FULL RES image.
 +75      ;p83 S FULLTYPE="A" ; Accessible
 +76       SET FILETYPE="FULL"
           KILL MAGFILE1("ERROR")
 +77       SET MAGPREF=""
           DO FINDFILE^MAGFILEB
 +78      ; MAGFILE1 has '^' in it if errors
           SET MAGFILE1=$TRANSLATE(MAGFILE1,"^","~")
 +79       IF $DATA(MAGFILE1("ERROR"))
               SET MAGFILE1=MAGFILE1("ERROR")
 +80      ;p83 MAGTYPE is "MAG... " or "WORM...", use instead of 'A'
 +81       SET FULLTYPE=$EXTRACT(MAGTYPE,1)
           IF MAGOFFLN
               SET FULLTYPE="O"
 +82      ;  here we have to do the same test as above. for bad data.
 +83       SET MAGPREF=$GET(MAGPREF)
 +84       SET FULLFILE=MAGPREF_MAGFILE1
 +85      ;
 +86      ;    now lets get the Full Path and file name for BIG image.
 +87       SET FILETYPE="BIG"
           KILL MAGFILE1("ERROR")
 +88       SET MAGPREF=""
           DO FINDFILE^MAGFILEB
 +89      ; MAGFILE1 has '^' in it if errors
           SET MAGFILE1=$TRANSLATE(MAGFILE1,"^","~")
 +90       IF $DATA(MAGFILE1("ERROR"))
               SET MAGFILE1=MAGFILE1("ERROR")
 +91       SET MAGPREF=$GET(MAGPREF)
 +92       SET BIGFILE=$SELECT($EXTRACT(MAGFILE1,1,2)="-1":"",1:MAGPREF_MAGFILE1)
 +93      ;
 +94      ; Cleanup
           KILL MAGFILE1
 +95      ; Site and Site Code are in Entry of first Image in Group
 +96      ; so we need to set here, before MAGXX is changed back.
 +97       SET X=$GET(^MAG(2005,MAGXX,0))
 +98       SET FNL=$SELECT(+$PIECE(X,"^",3):$PIECE(X,"^",3),1:+$PIECE(X,"^",5))
 +99       SET PLC=$PIECE($GET(MAGJOB("NETPLC",FNL)),"^",1)
 +100      SET PLCODE=$PIECE($GET(MAGJOB("NETPLC",FNL)),"^",2)
 +101     ; Group of 0 need this.
           IF PLC=""
               SET PLC=$GET(MAGJOB("PLC"))
               SET PLCODE=$GET(MAGJOB("PLCODE"))
 +102     ;   if we were using first image of a group, reset the Real IEN 
 +103      IF $GET(GRPIEN)
               SET MAGXX=GRPIEN
 +104     ;
 +105     ;   we have to change the OBJECT TYPE variable back to real value
 +106     ;   MAGOBJT might have been changed if we had Group of no images.
 +107     ;   but we need to keep it changed, because Delphi window checks this
 +108     ;   entry to determine which window to open.
 +109     ;   i.e. Group window, Single image window, 
 +110      SET MAGOBJT=$PIECE(MAGN0,U,6)
 +111     ;
 +112     ; now start building the return string
 +113     ;
 +114     ; //'="3.0.8")
           SET PATCH=$PIECE($GET(MAGJOB("VERSION")),".",3)
 +115      KILL MAGFILE
 +116     ; We put extra '^^^' on end of String to stop error in Delphi.
           SET $PIECE(MAGFILE,U,25)=""
 +117     ; Pieces 26 BrokerServer and 27 Broker Port are set if this is P59 Client.
 +118     ; Clients Prior to Patch 59, the String must only be 25 pieces. - Patch 45 snafu
 +119     ; 
 +120     ; $P(1^2^3) IEN^Image FullPath and name^Abstract FullPath and Name 
 +121      SET $PIECE(MAGFILE,U,1,3)=MAGXX_U_FULLFILE_U_ABSFILE
 +122     ;
 +123     ; now set $P(4) SHORT DESCRIPTION field and desc of offline JukeBox
 +124      SET $PIECE(MAGFILE,U,4)=$PIECE(MAGN2,U,4)_$GET(MAGJBOL)
 +125     ;
 +126     ; now set $P(5)PROCEDURE/ EXAM DATE/TIME field
 +127      SET $PIECE(MAGFILE,U,5)=$PIECE(MAGN2,U,5)
 +128     ;
 +129     ; now set $P(6) OBJECT TYPE
 +130      SET $PIECE(MAGFILE,U,6)=MAGOBJT
 +131     ;
 +132     ; now set $P(7) PROCEDURE field
 +133      SET $PIECE(MAGFILE,U,7)=$PIECE(MAGN0,U,8)
 +134     ;
 +135     ; now we're making a DATE to display and will use it for a sort in  
 +136     ;  the delphi TStringGrid so we display mm/dd/yyyy
 +137     ; now set $P(8) display date
 +138      SET X=$$FMTE^XLFDT($PIECE(MAGN2,U,5),"5Z")
 +139      SET X=$TRANSLATE(X,"@"," ")
 +140      SET $PIECE(MAGFILE,U,8)=X
 +141     ;
 +142     ; now return the PARENT DATA FILE image pointer
 +143      SET $PIECE(MAGFILE,U,9)=$PIECE(MAGN2,U,8)
 +144     ;
 +145     ; now return the ABSTYPE ( this is 'M' or 'W' or 'O' )
 +146     ; 'M' magnetic 'W' worm  'O' offline
 +147      SET $PIECE(MAGFILE,U,10)=ABSTYPE
 +148     ;
 +149     ; now return the code to show if full res image is offline 'A' or 'O'
 +150     ; 'A' accessible   'O' offline
 +151      SET $PIECE(MAGFILE,U,11)=FULLTYPE
 +152     ;
 +153     ;  2/1/99 Dicom Series number and Dicom Image Number  
 +154     ;    $p(12) and $p(13)
 +155     ;
 +156     ; 14 - count of images , if this is a group
 +157      SET X=+$PIECE($GET(^MAG(2005,MAGXX,1,0)),U,4)
           SET $PIECE(MAGFILE,U,14)=$SELECT(X:X,1:1)
 +158     ;
 +159     ; $p(15^16 ) are SiteIEN and SiteCode Consolidation - DBI
 +160     ; We use SiteIEN and SiteCODE from above 
 +161      SET $PIECE(MAGFILE,"^",15)=PLC
 +162      SET $PIECE(MAGFILE,"^",16)=PLCODE
 +163     ;
 +164     ; $p(17)           8/22/01 GEK Mod for integrity check.
 +165      IF '$GET(MAGNOCHK)
               DO CHK^MAGGSQI(.MAGQI,MAGXX)
               IF 'MAGQI(0)
                   Begin DoDot:1
 +166     ; remove the Abstract and Image File Names ; 2/14/03 remove c:\program files... with .\bmp\
 +167                  SET $PIECE(MAGFILE,U,2,3)="-1~Questionable Data Integrity^.\bmp\imageQA.bmp"
 +168     ;this stops Delphi App from changing Abstract BMP to OFFLINE IMAGE
 +169                  SET $PIECE(MAGFILE,U,6)=$SELECT(($PIECE(MAGFILE,U,6)'=11):"99",1:11)
 +170                  SET $PIECE(MAGFILE,U,10)="M"
 +171     ;Send the error message
 +172                  SET $PIECE(MAGFILE,U,17)=$PIECE(MAGQI(0),U,2)
                   End DoDot:1
 +173     ; $p(18) is BIGFile Full name and path.
 +174      SET $PIECE(MAGFILE,U,18)=BIGFILE
 +175     ; DFN
 +176      SET $PIECE(MAGFILE,U,19)=$PIECE(MAGN0,U,7)
 +177     ; Patient Name
 +178      SET $PIECE(MAGFILE,U,20)=$SELECT(MDFN:MAGJOB("PTNM",MDFN),1:MDFN)
 +179      SET $PIECE(MAGFILE,U,21)=$SELECT(+$PIECE(MAGN40,U,2):$PIECE(^MAG(2005.82,$PIECE(MAGN40,U,2),0),U),1:"")
 +180     ; Date/Time Image Saved  #7
           SET X=$$FMTE^XLFDT($PIECE(MAGN2,U,1),"5Z")
 +181      SET X=$TRANSLATE(X,"@"," ")
 +182      SET $PIECE(MAGFILE,U,22)=X
 +183     ; DocumentDate #110
           SET X=$$FMTE^XLFDT($PIECE(MAGN100,U,6),"5Z")
 +184      SET X=$TRANSLATE(X,"@"," ")
 +185      SET $PIECE(MAGFILE,U,23)=X
 +186     ; If Patch 59 Client - we can set beyond 25 pieces.
 +187      IF $DATA(MAGJOB("RPCSERVER"))&$DATA(MAGJOB("RPCPORT"))
               Begin DoDot:1
 +188              SET $PIECE(MAGFILE,U,26)=MAGJOB("RPCSERVER")
 +189              SET $PIECE(MAGFILE,U,27)=MAGJOB("RPCPORT")
 +190     ; "^" at end, stops problems in delphi
                   SET $PIECE(MAGFILE,U,28)=""
 +191              QUIT 
               End DoDot:1
 +192     ; Stop displaying a Group of 1 as a Group, so here we'll change Object type
 +193     ;  to that of the '1ST' image in the group of 1.
 +194      IF $PIECE($GET(^MAG(2005,MAGXX,1,0)),U,4)=1
               Begin DoDot:1
 +195              SET X=$ORDER(^MAG(2005,MAGXX,1,0))
 +196              SET X=+^MAG(2005,MAGXX,1,X,0)
 +197     ; OBJECT TYPE OF 1ST IMAGE IN GROUP
                   SET $PIECE(MAGFILE,U,6)=$PIECE(^MAG(2005,X,0),U,6)
 +198              SET $PIECE(MAGFILE,U,1)=X
 +199              QUIT 
               End DoDot:1
 +200      QUIT