MAGGSERR ;WOIFO/GEK - IMAGING ERROR TRAP, AND ERROR LOG ; [ 12/27/2000 10:49 ]
 ;;3.0;IMAGING;**7**;Jul 12, 2002
 ;; +---------------------------------------------------------------+
 ;; | 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
 ;  Calling this error trap will enable logging Imaging errors and 
 ;  sending messages for certain errors etc. later
 ; set it using :
 ;    >N $ETRAP,$ESTACK S $ETRAP="D ERRA^MAGGSERR"
 ;
 ; This assumes the Return variable or array is MAGRY or MAGRY()
 ;
ERRA ; ERROR TRAP FOR Array Return variables
 N ERR S ERR=$$EC^%ZOSV
 S MAGRY(0)="0^"_ERR
 D LOGERR(ERR)
 D @^%ZOSF("ERRTN")
 Q
 ;
AERRA ; ERROR TRAP FOR Global Return Variables
 N ERR S ERR=$$EC^%ZOSV
 S @MAGRY@(0)="0^ERROR "_ERR
 D LOGERR(ERR)
 D @^%ZOSF("ERRTN")
 Q
ERR ; ERROR TRAP FOR String Return variables
 N ERR S ERR=$$EC^%ZOSV
 S MAGRY="0^ERROR "_ERR
 D LOGERR(ERR)
 D @^%ZOSF("ERRTN")
 Q
LOGERR(ERROR,MAGSESS) ;
 N SESSIEN
 S SESSIEN=$S($G(MAGSESS):MAGSESS,$D(MAGJOB("SESSION")):MAGJOB("SESSION"),1:0)
 I 'SESSIEN Q
 N MAGGFDA,MAGXERR,MAGXIEN,MAGNODE
 S MAGNODE="+1,"_+SESSIEN_","
 ;S MAGNODE="+1,10,"
 S MAGGFDA(2006.823,MAGNODE,.01)=ERROR
 D UPDATE^DIE("","MAGGFDA","MAGXIEN","MAGXERR")
 ; error flag for this session in workstation file
 I $G(MAGJOB("WRKSIEN")) D
 . S MAGNODE=+MAGJOB("WRKSIEN")_","
 . S MAGGFDA(2006.81,MAGNODE,11)=+MAGXIEN(1) ;
 . D UPDATE^DIE("","MAGGFDA","MAGXIEN","MAGXERR")
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGGSERR   2333     printed  Sep 23, 2025@19:38:49                                                                                                                                                                                                    Page 2
MAGGSERR  ;WOIFO/GEK - IMAGING ERROR TRAP, AND ERROR LOG ; [ 12/27/2000 10:49 ]
 +1       ;;3.0;IMAGING;**7**;Jul 12, 2002
 +2       ;; +---------------------------------------------------------------+
 +3       ;; | Property of the US Government.                                |
 +4       ;; | No permission to copy or redistribute this software is given. |
 +5       ;; | Use of unreleased versions of this software requires the user |
 +6       ;; | to execute a written test agreement with the VistA Imaging    |
 +7       ;; | Development Office of the Department of Veterans Affairs,     |
 +8       ;; | telephone (301) 734-0100.                                     |
 +9       ;; |                                                               |
 +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      ;  Calling this error trap will enable logging Imaging errors and 
 +19      ;  sending messages for certain errors etc. later
 +20      ; set it using :
 +21      ;    >N $ETRAP,$ESTACK S $ETRAP="D ERRA^MAGGSERR"
 +22      ;
 +23      ; This assumes the Return variable or array is MAGRY or MAGRY()
 +24      ;
ERRA      ; ERROR TRAP FOR Array Return variables
 +1        NEW ERR
           SET ERR=$$EC^%ZOSV
 +2        SET MAGRY(0)="0^"_ERR
 +3        DO LOGERR(ERR)
 +4        DO @^%ZOSF("ERRTN")
 +5        QUIT 
 +6       ;
AERRA     ; ERROR TRAP FOR Global Return Variables
 +1        NEW ERR
           SET ERR=$$EC^%ZOSV
 +2        SET @MAGRY@(0)="0^ERROR "_ERR
 +3        DO LOGERR(ERR)
 +4        DO @^%ZOSF("ERRTN")
 +5        QUIT 
ERR       ; ERROR TRAP FOR String Return variables
 +1        NEW ERR
           SET ERR=$$EC^%ZOSV
 +2        SET MAGRY="0^ERROR "_ERR
 +3        DO LOGERR(ERR)
 +4        DO @^%ZOSF("ERRTN")
 +5        QUIT 
LOGERR(ERROR,MAGSESS) ;
 +1        NEW SESSIEN
 +2        SET SESSIEN=$SELECT($GET(MAGSESS):MAGSESS,$DATA(MAGJOB("SESSION")):MAGJOB("SESSION"),1:0)
 +3        IF 'SESSIEN
               QUIT 
 +4        NEW MAGGFDA,MAGXERR,MAGXIEN,MAGNODE
 +5        SET MAGNODE="+1,"_+SESSIEN_","
 +6       ;S MAGNODE="+1,10,"
 +7        SET MAGGFDA(2006.823,MAGNODE,.01)=ERROR
 +8        DO UPDATE^DIE("","MAGGFDA","MAGXIEN","MAGXERR")
 +9       ; error flag for this session in workstation file
 +10       IF $GET(MAGJOB("WRKSIEN"))
               Begin DoDot:1
 +11               SET MAGNODE=+MAGJOB("WRKSIEN")_","
 +12      ;
                   SET MAGGFDA(2006.81,MAGNODE,11)=+MAGXIEN(1)
 +13               DO UPDATE^DIE("","MAGGFDA","MAGXIEN","MAGXERR")
               End DoDot:1
 +14       QUIT