MAGGROI ;WOIFO/BNT/NST - Multiple image print ; 12 Oct 2010 9:55 AM
 ;;3.0;IMAGING;**117**;Mar 19, 2002;Build 2238;Jul 15, 2011
 ;; 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
 ;
 ;***** Log multiple images printed for a patient in the 
 ;      MULTI IMAGE PRINT file (#2006.961)
 ;
 ; RPC: MAGG MULTI IMAGE PRINT
 ;
 ; Input Parameters
 ; ================
 ; 
 ; DATA     "^" delimited string containing data inserted
 ;          into the MULTI IMAGE PRINT file #2006.961.
 ;          
 ;          ^01: PATIENT DFN  
 ;          ^02: REASON FOR PRINT
 ;
 ; e.g.: 123456^Authorized release of medical records or health information (ROI)
 ;
 ; IMGARR   An array of "^" delimited string of values for each image printed
 ; 
 ;          ^01: IEN for the image (Note: This may be a url for a remote image)
 ;          ^02: Local/remote indicator (0=local, 1=remote)
 ;          ^03: IMAGE PRINT STATUS 
 ;               (Note: The image information displayed to the user
 ;                in the client application.)
 ;
 ; e.g.: IMGARR(0)=^1^SLC-DIABETIC TELERETINAL IMAGING CONSULT REPORT
 ;                    -NOTE-04/13/2009 11:31: Image type not printable
 ;       IMGARR(1)=123456^0^SLC-AU 01 2-LAB-08/21/2001: Image printed
 ;
 ; Return Values
 ; =============
 ;     
 ; MAGRY = if error   "0^Error message"
 ;         if success "1^Printed Images Logged"
 ;
LOGPRNT(MAGRY,DATA,IMGARR) ;RPC [MAGG MULTI IMAGE PRINT]    
 N $ETRAP,$ESTACK S $ETRAP="D ERR^MAGGTERR"
 ;
 S MAGRY=$$ENTRY($P(DATA,U),$P(DATA,U,2),$G(DUZ),.IMGARR)
 ;
 Q
 ;
 ; Call With:
 ; MAGDFN = Patient IEN
 ; MAGREASN = Reason For Print
 ; MAGDUZ = User IEN
 ; MAGARR = Array of Multiple Images that have been printed
 ; 
 ; The Date/Time images printed is derived from current system time
ENTRY(MAGDFN,MAGREASN,MAGDUZ,MAGARR) ;
 N MAGX,MAGY,SFN,FN,NOW,MAGIENS,MAGIEN,MAGREM,MAGFDA
 N MAGERR,MAGRESA,MAGRY
 ; Initialize file number, image subfile number, date/time and return value
 S FN=2006.961
 S SFN=2006.9613
 S NOW=$$NOW^XLFDT()
 S MAGIEN="+1,"
 ;
 ; Set up FDA array
 S MAGFDA(FN,MAGIEN,.01)=MAGDFN  ; Patient
 S MAGFDA(FN,MAGIEN,1)=NOW       ; Print Date/Time
 S MAGFDA(FN,MAGIEN,2)=MAGDUZ    ; User
 S MAGFDA(FN,MAGIEN,3)=MAGREASN  ; Reason for Print
 S MAGX="",MAGY=1,MAGERR=0
 F  S MAGX=$O(MAGARR(MAGX)) Q:MAGX=""  D  Q:MAGERR
 . ; Patient mismatch check was done during the selection of images
 . S MAGY=MAGY+1,MAGIENS=MAGY_","_MAGIEN
 . ; Is Image Local or Remote? MAGREM = 1 for Remote, 0 for Local
 . S MAGREM=$P(MAGARR(MAGX),U,2)
 . S MAGFDA(SFN,"+"_MAGIENS,.01)=MAGX+1                        ; Image ID
 . I 'MAGREM S MAGFDA(SFN,"+"_MAGIENS,1)=$P(MAGARR(MAGX),U,1)  ; Local Image IEN
 . I MAGREM S MAGFDA(SFN,"+"_MAGIENS,3)=$P(MAGARR(MAGX),U,1)   ; Remote Image
 . S MAGFDA(SFN,"+"_MAGIENS,2)=$P(MAGARR(MAGX),U,3)            ; Image Print Status
 . Q
 I MAGERR Q MAGRY
 ; File data in MULTI IMAGE PRINT file
 D UPDATE^DIE("","MAGFDA","","MAGERR")
 I $D(MAGERR("DIERR","E")) D  Q
 . D MSG^DIALOG("A",.MAGRESA,245,5,"MAGERR")
 . S MAGRY="0^"_MAGRESA(1)
 . Q
 Q "1^Printed Images Logged"
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGGROI   4110     printed  Sep 23, 2025@19:38:47                                                                                                                                                                                                     Page 2
MAGGROI   ;WOIFO/BNT/NST - Multiple image print ; 12 Oct 2010 9:55 AM
 +1       ;;3.0;IMAGING;**117**;Mar 19, 2002;Build 2238;Jul 15, 2011
 +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      ;***** Log multiple images printed for a patient in the 
 +20      ;      MULTI IMAGE PRINT file (#2006.961)
 +21      ;
 +22      ; RPC: MAGG MULTI IMAGE PRINT
 +23      ;
 +24      ; Input Parameters
 +25      ; ================
 +26      ; 
 +27      ; DATA     "^" delimited string containing data inserted
 +28      ;          into the MULTI IMAGE PRINT file #2006.961.
 +29      ;          
 +30      ;          ^01: PATIENT DFN  
 +31      ;          ^02: REASON FOR PRINT
 +32      ;
 +33      ; e.g.: 123456^Authorized release of medical records or health information (ROI)
 +34      ;
 +35      ; IMGARR   An array of "^" delimited string of values for each image printed
 +36      ; 
 +37      ;          ^01: IEN for the image (Note: This may be a url for a remote image)
 +38      ;          ^02: Local/remote indicator (0=local, 1=remote)
 +39      ;          ^03: IMAGE PRINT STATUS 
 +40      ;               (Note: The image information displayed to the user
 +41      ;                in the client application.)
 +42      ;
 +43      ; e.g.: IMGARR(0)=^1^SLC-DIABETIC TELERETINAL IMAGING CONSULT REPORT
 +44      ;                    -NOTE-04/13/2009 11:31: Image type not printable
 +45      ;       IMGARR(1)=123456^0^SLC-AU 01 2-LAB-08/21/2001: Image printed
 +46      ;
 +47      ; Return Values
 +48      ; =============
 +49      ;     
 +50      ; MAGRY = if error   "0^Error message"
 +51      ;         if success "1^Printed Images Logged"
 +52      ;
LOGPRNT(MAGRY,DATA,IMGARR) ;RPC [MAGG MULTI IMAGE PRINT]    
 +1        NEW $ETRAP,$ESTACK
           SET $ETRAP="D ERR^MAGGTERR"
 +2       ;
 +3        SET MAGRY=$$ENTRY($PIECE(DATA,U),$PIECE(DATA,U,2),$GET(DUZ),.IMGARR)
 +4       ;
 +5        QUIT 
 +6       ;
 +7       ; Call With:
 +8       ; MAGDFN = Patient IEN
 +9       ; MAGREASN = Reason For Print
 +10      ; MAGDUZ = User IEN
 +11      ; MAGARR = Array of Multiple Images that have been printed
 +12      ; 
 +13      ; The Date/Time images printed is derived from current system time
ENTRY(MAGDFN,MAGREASN,MAGDUZ,MAGARR) ;
 +1        NEW MAGX,MAGY,SFN,FN,NOW,MAGIENS,MAGIEN,MAGREM,MAGFDA
 +2        NEW MAGERR,MAGRESA,MAGRY
 +3       ; Initialize file number, image subfile number, date/time and return value
 +4        SET FN=2006.961
 +5        SET SFN=2006.9613
 +6        SET NOW=$$NOW^XLFDT()
 +7        SET MAGIEN="+1,"
 +8       ;
 +9       ; Set up FDA array
 +10      ; Patient
           SET MAGFDA(FN,MAGIEN,.01)=MAGDFN
 +11      ; Print Date/Time
           SET MAGFDA(FN,MAGIEN,1)=NOW
 +12      ; User
           SET MAGFDA(FN,MAGIEN,2)=MAGDUZ
 +13      ; Reason for Print
           SET MAGFDA(FN,MAGIEN,3)=MAGREASN
 +14       SET MAGX=""
           SET MAGY=1
           SET MAGERR=0
 +15       FOR 
               SET MAGX=$ORDER(MAGARR(MAGX))
               if MAGX=""
                   QUIT 
               Begin DoDot:1
 +16      ; Patient mismatch check was done during the selection of images
 +17               SET MAGY=MAGY+1
                   SET MAGIENS=MAGY_","_MAGIEN
 +18      ; Is Image Local or Remote? MAGREM = 1 for Remote, 0 for Local
 +19               SET MAGREM=$PIECE(MAGARR(MAGX),U,2)
 +20      ; Image ID
                   SET MAGFDA(SFN,"+"_MAGIENS,.01)=MAGX+1
 +21      ; Local Image IEN
                   IF 'MAGREM
                       SET MAGFDA(SFN,"+"_MAGIENS,1)=$PIECE(MAGARR(MAGX),U,1)
 +22      ; Remote Image
                   IF MAGREM
                       SET MAGFDA(SFN,"+"_MAGIENS,3)=$PIECE(MAGARR(MAGX),U,1)
 +23      ; Image Print Status
                   SET MAGFDA(SFN,"+"_MAGIENS,2)=$PIECE(MAGARR(MAGX),U,3)
 +24               QUIT 
               End DoDot:1
               if MAGERR
                   QUIT 
 +25       IF MAGERR
               QUIT MAGRY
 +26      ; File data in MULTI IMAGE PRINT file
 +27       DO UPDATE^DIE("","MAGFDA","","MAGERR")
 +28       IF $DATA(MAGERR("DIERR","E"))
               Begin DoDot:1
 +29               DO MSG^DIALOG("A",.MAGRESA,245,5,"MAGERR")
 +30               SET MAGRY="0^"_MAGRESA(1)
 +31               QUIT 
               End DoDot:1
               QUIT 
 +32       QUIT "1^Printed Images Logged"