MAGGSFL1 ;WOIFO/GEK/SG - Image list Filters utilities ; 3/9/09 12:51pm
;;3.0;IMAGING;**8,93**;Dec 02, 2009;Build 163
;; 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
;
;***** UPDATES/CREATES THE IMAGE FILTER DEFINITION
; RPC: MAG4 FILTER SAVE
;
; .MAGRY Reference to a local variable where the result
; is returned to.
;
; .MAGGZ Reference to a local array that stores the filter
; data and related parameters.
;
; MAGZ(i) Data item
; ^01: Field number
; ^02: Field value
;
; The following special names can be used in place of
; field numbers:
;
; FLAGS - Value contains flags that control the
; execution (can be combined):
;
; S Selective save. If this flag is
; provided, then only the fields listed
; in the MAGZ array are updated; other
; filter properties are not changed.
;
; By default, all filter properties,
; which do not have new values in the
; MAGZ array, are cleared.
;
; IEN - Value is the Internal Entry Number of the
; filter that has to be modified.
;
; USER - Value is the IEN of the user who this
; filter is saved for.
;
; Return Values
; =============
;
; In case of an error, the first ^-piece of the MAGRY contains 0, and
; the second one - the error message.
;
; Otherwise, IEN of the filter is returned in 1st ^-piece, and the
; filter name (value of the .01 field) - in the second one.
;
SET(MAGRY,MAGGZ) ;RPC [MAG4 FILTER SAVE]
N $ETRAP,$ESTACK,FLAGS,FLTIEN,FLTUSER,MAGGDA,MAGGDAT,MAGGFDA,MAGGFLD,MAGOK,MAGGXE,RES,Z
K MAGRY S (FLTIEN,FLTUSER)=0,MAGOK=1,FLAGS=""
S MAGRY="0^Starting: Saving Filter..."
S $ETRAP="D ERR^"_$T(+0)
I $D(MAGGZ)<10 S MAGRY="0^No input data, Operation CANCELED" Q
;
;--- Parse the parameters
S Z=""
F S Z=$O(MAGGZ(Z)) Q:Z="" D Q:'MAGOK
. S MAGGFLD=$P(MAGGZ(Z),U),MAGGDAT=$P(MAGGZ(Z),U,2,99)
. I MAGGFLD=""!(MAGGDAT="") D Q
. . S MAGOK="0^Field and Value are Required"
. . Q
. I MAGGFLD="FLAGS" S FLAGS=MAGGDAT Q
. I MAGGFLD="IEN" S FLTIEN=+MAGGDAT D Q
. . I FLTIEN>0,$D(^MAG(2005.87,FLTIEN)) Q
. . S MAGOK="0^Invalid Filter IEN: "_FLTIEN
. . Q
. I MAGGFLD="USER" S FLTUSER=+MAGGDAT,MAGGFLD=20
. I '$$VALID^MAGGSIV1(2005.87,MAGGFLD,.MAGGDAT,.RES) D Q
. . S MAGOK="0^"_RES
. . Q
. S MAGGFDA(2005.87,"+1,",MAGGFLD)=MAGGDAT
. Q
I 'MAGOK S MAGRY=MAGOK Q
;
;--- Lock the file header
L +^MAG(2005.87,0):10 E D Q
. S MAGRY="0^The File Image List Filters is locked."
. S MAGRY=MAGRY_" Operation canceled"
. Q
;
I FLTIEN>0 D
. N IENS
. S IENS=FLTIEN_","
. ;--- Clear the old values if not requested otherwise.
. I FLAGS'["S" F Z=1:1:16,20,21 S MAGGFDA(2005.87,IENS,Z)="@"
. M MAGGFDA(2005.87,IENS)=MAGGFDA(2005.87,"+1,")
. K MAGGFDA(2005.87,"+1,")
. ;--- Update the filter
. D FILE^DIE("","MAGGFDA","MAGGXE")
. I $D(DIERR) D RTRNERR(.MAGRY) Q
. S MAGRY=FLTIEN_U_$P(^MAG(2005.87,FLTIEN,0),U)
. Q
E D
. N MAGGIEN
. S MAGGFDA(2005.87,"+1,",22)=DUZ
. ;--- Store the new filter
. D UPDATE^DIE("S","MAGGFDA","MAGGIEN","MAGGXE")
. I $D(DIERR) D RTRNERR(.MAGRY) Q
. S MAGRY=MAGGIEN(1)_U_MAGGFDA(2005.87,"+1,",.01)
. Q
;
;--- Cleanup
L -^MAG(2005.87,0)
D CLEAN^DILF
Q
;
;+++++ RETURNS THE TEXT OF THE FILEMAN ERROR MESSAGE
RTRNERR(ETXT) ;
N MAGRESA
D MSG^DIALOG("A",.MAGRESA,245,5,"MAGGXE")
S ETXT="0^"_MAGRESA(1)
D CLEAN^DILF
Q
;
;+++++ ERROR HANDLER
ERR ;
N ERR
L -^MAG(2005.87,0)
S ERR=$$EC^%ZOSV
S (MAGRY,MAGOK)="0^Error Filter Add/Edit: "_ERR
D LOGERR^MAGGTERR(ERR)
D @^%ZOSF("ERRTN")
D CLEAN^DILF
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGGSFL1 5072 printed Dec 13, 2024@02:02:39 Page 2
MAGGSFL1 ;WOIFO/GEK/SG - Image list Filters utilities ; 3/9/09 12:51pm
+1 ;;3.0;IMAGING;**8,93**;Dec 02, 2009;Build 163
+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 ;; | |
+11 ;; | The Food and Drug Administration classifies this software as |
+12 ;; | a medical device. As such, it may not be changed in any way. |
+13 ;; | Modifications to this software may result in an adulterated |
+14 ;; | medical device under 21CFR820, the use of which is considered |
+15 ;; | to be a violation of US Federal Statutes. |
+16 ;; +---------------------------------------------------------------+
+17 ;;
+18 QUIT
+19 ;
+20 ;***** UPDATES/CREATES THE IMAGE FILTER DEFINITION
+21 ; RPC: MAG4 FILTER SAVE
+22 ;
+23 ; .MAGRY Reference to a local variable where the result
+24 ; is returned to.
+25 ;
+26 ; .MAGGZ Reference to a local array that stores the filter
+27 ; data and related parameters.
+28 ;
+29 ; MAGZ(i) Data item
+30 ; ^01: Field number
+31 ; ^02: Field value
+32 ;
+33 ; The following special names can be used in place of
+34 ; field numbers:
+35 ;
+36 ; FLAGS - Value contains flags that control the
+37 ; execution (can be combined):
+38 ;
+39 ; S Selective save. If this flag is
+40 ; provided, then only the fields listed
+41 ; in the MAGZ array are updated; other
+42 ; filter properties are not changed.
+43 ;
+44 ; By default, all filter properties,
+45 ; which do not have new values in the
+46 ; MAGZ array, are cleared.
+47 ;
+48 ; IEN - Value is the Internal Entry Number of the
+49 ; filter that has to be modified.
+50 ;
+51 ; USER - Value is the IEN of the user who this
+52 ; filter is saved for.
+53 ;
+54 ; Return Values
+55 ; =============
+56 ;
+57 ; In case of an error, the first ^-piece of the MAGRY contains 0, and
+58 ; the second one - the error message.
+59 ;
+60 ; Otherwise, IEN of the filter is returned in 1st ^-piece, and the
+61 ; filter name (value of the .01 field) - in the second one.
+62 ;
SET(MAGRY,MAGGZ) ;RPC [MAG4 FILTER SAVE]
+1 NEW $ETRAP,$ESTACK,FLAGS,FLTIEN,FLTUSER,MAGGDA,MAGGDAT,MAGGFDA,MAGGFLD,MAGOK,MAGGXE,RES,Z
+2 KILL MAGRY
SET (FLTIEN,FLTUSER)=0
SET MAGOK=1
SET FLAGS=""
+3 SET MAGRY="0^Starting: Saving Filter..."
+4 SET $ETRAP="D ERR^"_$TEXT(+0)
+5 IF $DATA(MAGGZ)<10
SET MAGRY="0^No input data, Operation CANCELED"
QUIT
+6 ;
+7 ;--- Parse the parameters
+8 SET Z=""
+9 FOR
SET Z=$ORDER(MAGGZ(Z))
if Z=""
QUIT
Begin DoDot:1
+10 SET MAGGFLD=$PIECE(MAGGZ(Z),U)
SET MAGGDAT=$PIECE(MAGGZ(Z),U,2,99)
+11 IF MAGGFLD=""!(MAGGDAT="")
Begin DoDot:2
+12 SET MAGOK="0^Field and Value are Required"
+13 QUIT
End DoDot:2
QUIT
+14 IF MAGGFLD="FLAGS"
SET FLAGS=MAGGDAT
QUIT
+15 IF MAGGFLD="IEN"
SET FLTIEN=+MAGGDAT
Begin DoDot:2
+16 IF FLTIEN>0
IF $DATA(^MAG(2005.87,FLTIEN))
QUIT
+17 SET MAGOK="0^Invalid Filter IEN: "_FLTIEN
+18 QUIT
End DoDot:2
QUIT
+19 IF MAGGFLD="USER"
SET FLTUSER=+MAGGDAT
SET MAGGFLD=20
+20 IF '$$VALID^MAGGSIV1(2005.87,MAGGFLD,.MAGGDAT,.RES)
Begin DoDot:2
+21 SET MAGOK="0^"_RES
+22 QUIT
End DoDot:2
QUIT
+23 SET MAGGFDA(2005.87,"+1,",MAGGFLD)=MAGGDAT
+24 QUIT
End DoDot:1
if 'MAGOK
QUIT
+25 IF 'MAGOK
SET MAGRY=MAGOK
QUIT
+26 ;
+27 ;--- Lock the file header
+28 LOCK +^MAG(2005.87,0):10
IF '$TEST
Begin DoDot:1
+29 SET MAGRY="0^The File Image List Filters is locked."
+30 SET MAGRY=MAGRY_" Operation canceled"
+31 QUIT
End DoDot:1
QUIT
+32 ;
+33 IF FLTIEN>0
Begin DoDot:1
+34 NEW IENS
+35 SET IENS=FLTIEN_","
+36 ;--- Clear the old values if not requested otherwise.
+37 IF FLAGS'["S"
FOR Z=1:1:16,20,21
SET MAGGFDA(2005.87,IENS,Z)="@"
+38 MERGE MAGGFDA(2005.87,IENS)=MAGGFDA(2005.87,"+1,")
+39 KILL MAGGFDA(2005.87,"+1,")
+40 ;--- Update the filter
+41 DO FILE^DIE("","MAGGFDA","MAGGXE")
+42 IF $DATA(DIERR)
DO RTRNERR(.MAGRY)
QUIT
+43 SET MAGRY=FLTIEN_U_$PIECE(^MAG(2005.87,FLTIEN,0),U)
+44 QUIT
End DoDot:1
+45 IF '$TEST
Begin DoDot:1
+46 NEW MAGGIEN
+47 SET MAGGFDA(2005.87,"+1,",22)=DUZ
+48 ;--- Store the new filter
+49 DO UPDATE^DIE("S","MAGGFDA","MAGGIEN","MAGGXE")
+50 IF $DATA(DIERR)
DO RTRNERR(.MAGRY)
QUIT
+51 SET MAGRY=MAGGIEN(1)_U_MAGGFDA(2005.87,"+1,",.01)
+52 QUIT
End DoDot:1
+53 ;
+54 ;--- Cleanup
+55 LOCK -^MAG(2005.87,0)
+56 DO CLEAN^DILF
+57 QUIT
+58 ;
+59 ;+++++ RETURNS THE TEXT OF THE FILEMAN ERROR MESSAGE
RTRNERR(ETXT) ;
+1 NEW MAGRESA
+2 DO MSG^DIALOG("A",.MAGRESA,245,5,"MAGGXE")
+3 SET ETXT="0^"_MAGRESA(1)
+4 DO CLEAN^DILF
+5 QUIT
+6 ;
+7 ;+++++ ERROR HANDLER
ERR ;
+1 NEW ERR
+2 LOCK -^MAG(2005.87,0)
+3 SET ERR=$$EC^%ZOSV
+4 SET (MAGRY,MAGOK)="0^Error Filter Add/Edit: "_ERR
+5 DO LOGERR^MAGGTERR(ERR)
+6 DO @^%ZOSF("ERRTN")
+7 DO CLEAN^DILF
+8 QUIT