MAGGSFLT ;WOIFO/GEK/SG - Image list Filters utilities ; 3/9/09 12:51pm
;;3.0;IMAGING;**7,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
;
DEL(MAGRY,FLTIEN) ;RPC [MAG4 FILTER DELETE] DELETE A FILTER
N DIK,DA
S DIK="^MAG(2005.87,"
S DA=FLTIEN
D ^DIK
D CLEAN^DILF
S MAGRY="1^Deleted"
Q
;
GETLIST(MAGRY,USER,GETALL) ;RPC [MAG4 FILTER GET LIST] Return a list of filters for a USER
; user = DUZ
; if user = "" send list of public filters
; if user > 0 and GETALL = 1 then send User Private and Public filters.
N I,MAGADMIN,MAGCLIN
K ^TMP($J,"MAGGSFLT","RES")
S USER=$G(USER)
S MAGRY(0)="0^Retrieving Filter list..."
; we'll get public if getall or no user
D CLSKEYS(.MAGADMIN,.MAGCLIN)
I $G(GETALL)!('USER) D
. S I=""
. F S I=$O(^MAG(2005.87,"D",1,I)) Q:I="" D
. . I '$$HASKEY(I) Q ; HERE HAVE TO USE DUZ, TO FILTER THE FILTERS BASED ON MAGDISP CLIN AND MAGDISP ADMIN
. . S ^TMP($J,"MAGGSFLT","RES",$P(^MAG(2005.87,I,0),"^",1)_"-"_I)=I_"^"_$P(^MAG(2005.87,I,0),"^",1)_"^"_$P(^MAG(2005.87,I,1),"^")
. . ;S MAGRY($O(MAGRY(""),-1)+1)=I_"^"_$P(^MAG(2005.87,I,0),"^",1)_"^"_$P(^MAG(2005.87,I,1),"^")
. . Q
I USER D
. S I=""
. F S I=$O(^MAG(2005.87,"C",USER,I)) Q:I="" D
. . I '$$HASKEY(I) Q
. . S ^TMP($J,"MAGGSFLT","RES",$P(^MAG(2005.87,I,0),"^",1)_"-"_I)=I_"^"_$P(^MAG(2005.87,I,0),"^",1)_"^"_$P(^MAG(2005.87,I,1),"^")
. . ;S MAGRY($O(MAGRY(""),-1)+1)=I_"^"_$P(^MAG(2005.87,I,0),"^",1)_"^"_$P(^MAG(2005.87,I,1),"^")
. . Q
;S MAGRY(0)=$S($G(MAGRY(1)):$O(MAGRY(""),-1),1:"0^ERROR Retrieving Filter list.")
S MAGRY(0)=$S($D(^TMP($J,"MAGGSFLT","RES")):1,1:"0^ERROR Retrieving Filter list.")
I MAGRY(0) D
. ; we have a list of filters, send the default as Piece 1 in 0 node.
. S $P(MAGRY(0),"^",1)=$$DFTFLT(USER)
S I=""
F S I=$O(^TMP($J,"MAGGSFLT","RES",I),-1) Q:I="" D
. S MAGRY($O(MAGRY(""),-1)+1)=^TMP($J,"MAGGSFLT","RES",I)
Q
;
HASKEY(IEN) ; True or False, Does user have Correct Key(s)(ADMIN and/or CLIN) to view this filter.
N CLS
S CLS=$P(^MAG(2005.87,IEN,0),"^",3)
I (CLS="") S CLS="CLIN,ADMIN" ; CLS="", now treat it as both. (Might rethink, treat it as any ? )
I (CLS["ADMIN"),(CLS["CLIN") Q (MAGCLIN&MAGADMIN)
I (CLS["CLIN") Q MAGCLIN
I (CLS["ADMIN") Q MAGADMIN
Q 0
;
CLSKEYS(ADM,CLIN) ;
S (ADM,CLIN)=0
N I,MAGKEY
D USERKEYS^MAGGTU3(.MAGKEY)
S I="" F S I=$O(MAGKEY(I)) Q:I="" D
. I MAGKEY(I)="MAGDISP CLIN" S CLIN=1
. I MAGKEY(I)="MAGDISP ADMIN" S ADM=1
. Q
Q
;
GET(MAGRY,FLTIEN,FLTNAME,USER) ;RPC [MAG4 FILTER DETAILS] Return a filter
N FLTC,I,MAGV,X
K MAGRY
;--- Validate parameters
I '$G(FLTIEN) S FLTIEN=$$RSLVIEN($G(FLTNAME),$G(USER))
I 'FLTIEN S MAGRY(0)="0^Can not resolve Filter name in VistA." Q
I '$D(^MAG(2005.87,FLTIEN)) D Q
. S MAGRY(0)="0^Filter ID #"_FLTIEN_" Doesn't exist."
. Q
;--- Load the filter data
S FLTC=FLTIEN_","
S MAGRY(0)="1^Filter "_$P(^MAG(2005.87,FLTIEN,0),"^",1)_" # "_FLTIEN
D GETS^DIQ(2005.87,FLTC,".01:16","EI","MAGV")
;--- Reformat the dates (FROM and UNTIL)
F I=6,7 S X=$G(MAGV(2005.87,FLTC,I,"I")) D:X'=""
. S MAGV(2005.87,FLTC,I,"E")=$$FMTE^XLFDT(X,"2Z")
. Q
;--- Add the filter data to the result array
S MAGRY(1)=FLTIEN
F I=.01,1:1:9 S MAGRY(1)=MAGRY(1)_U_$G(MAGV(2005.87,FLTC,I,"E"))
F I=10:1:16 S MAGRY(1)=MAGRY(1)_U_$G(MAGV(2005.87,FLTC,I,"I"))
Q
;
RSLVIEN(NAME,USER) ; Return an IEN from the NAME and USER
N I,IEN S I=""
I NAME="" Q 0
S IEN=0
F S I=$O(^MAG(2005.87,"B",NAME,I)) Q:'I D
. I $P(^MAG(2005.87,I,1),"^")=USER S IEN=I
Q IEN
;
DFTFLT(USER) ; Create a Default Filter for user. Or Return Existing.
; Plus this call, makes sure the Default Filter is valid.
; USER is the IEN in the New Person file
; default to DUZ if ""
N FLTIEN,XIEN
S USER=$S($G(USER):USER,1:$G(DUZ))
S XIEN=$O(^MAG(2006.18,"AC",USER,"")) Q:XIEN="" 0
S FLTIEN=$P($G(^MAG(2006.18,XIEN,"LISTWIN1")),"^",3)
I FLTIEN D Q FLTIEN
. I $D(^MAG(2005.87,FLTIEN)) Q ; Valid filter Quit.
. ; Users dflt filter invalid. Set dflt as first private or first public
. ; We dont' create the Admin All, or Clin All a second time.
. S FLTIEN=$O(^MAG(2005.87,"C",USER,"")) ; get first private
. I 'FLTIEN S FLTIEN=$O(^MAG(2005.87,"D",1,"")) ; return first public
. S $P(^MAG(2006.18,XIEN,"LISTWIN1"),"^",3)=FLTIEN
. Q
;
; Here we'll create Private filters for a user or send first existing
; private filter as the default.
N MAGADMIN,MAGCLIN,MAGY,MAGX
S FLTIEN=$O(^MAG(2005.87,"C",USER,"")) ; get first private
I FLTIEN S $P(^MAG(2006.18,XIEN,"LISTWIN1"),"^",3)=FLTIEN Q FLTIEN
D CLSKEYS(.MAGADMIN,.MAGCLIN)
I MAGADMIN D
. ; Create a Filter for All Admin add to IMAGE LIST FILTERS File for this user.
. S MAGX(1)="USER^"_USER
. S MAGX(2)=".01^Admin All"
. S MAGX(3)="2^ADMIN"
. D SET^MAGGSFL1(.MAGY,.MAGX)
. S FLTIEN=$S(+MAGY:+MAGY,1:"")
. Q
K MAGY,MAGX
I MAGCLIN D
. ;Create a Filter for All Clin add to IMAGE LIST FILTERS File for this user.
. S MAGX(1)="USER^"_USER
. S MAGX(2)=".01^Clinical All"
. S MAGX(3)="2^CLIN"
. D SET^MAGGSFL1(.MAGY,.MAGX)
. S FLTIEN=$S(+MAGY:+MAGY,1:"")
. Q
Q:'FLTIEN 0
S $P(^MAG(2006.18,XIEN,"LISTWIN1"),"^",3)=FLTIEN
Q FLTIEN
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGGSFLT 6308 printed Dec 13, 2024@02:02:39 Page 2
MAGGSFLT ;WOIFO/GEK/SG - Image list Filters utilities ; 3/9/09 12:51pm
+1 ;;3.0;IMAGING;**7,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 ;
DEL(MAGRY,FLTIEN) ;RPC [MAG4 FILTER DELETE] DELETE A FILTER
+1 NEW DIK,DA
+2 SET DIK="^MAG(2005.87,"
+3 SET DA=FLTIEN
+4 DO ^DIK
+5 DO CLEAN^DILF
+6 SET MAGRY="1^Deleted"
+7 QUIT
+8 ;
GETLIST(MAGRY,USER,GETALL) ;RPC [MAG4 FILTER GET LIST] Return a list of filters for a USER
+1 ; user = DUZ
+2 ; if user = "" send list of public filters
+3 ; if user > 0 and GETALL = 1 then send User Private and Public filters.
+4 NEW I,MAGADMIN,MAGCLIN
+5 KILL ^TMP($JOB,"MAGGSFLT","RES")
+6 SET USER=$GET(USER)
+7 SET MAGRY(0)="0^Retrieving Filter list..."
+8 ; we'll get public if getall or no user
+9 DO CLSKEYS(.MAGADMIN,.MAGCLIN)
+10 IF $GET(GETALL)!('USER)
Begin DoDot:1
+11 SET I=""
+12 FOR
SET I=$ORDER(^MAG(2005.87,"D",1,I))
if I=""
QUIT
Begin DoDot:2
+13 ; HERE HAVE TO USE DUZ, TO FILTER THE FILTERS BASED ON MAGDISP CLIN AND MAGDISP ADMIN
IF '$$HASKEY(I)
QUIT
+14 SET ^TMP($JOB,"MAGGSFLT","RES",$PIECE(^MAG(2005.87,I,0),"^",1)_"-"_I)=I_"^"_$PIECE(^MAG(2005.87,I,0),"^",1)_"^"_$PIECE(^MAG(2005.87,I,1),"^")
+15 ;S MAGRY($O(MAGRY(""),-1)+1)=I_"^"_$P(^MAG(2005.87,I,0),"^",1)_"^"_$P(^MAG(2005.87,I,1),"^")
+16 QUIT
End DoDot:2
End DoDot:1
+17 IF USER
Begin DoDot:1
+18 SET I=""
+19 FOR
SET I=$ORDER(^MAG(2005.87,"C",USER,I))
if I=""
QUIT
Begin DoDot:2
+20 IF '$$HASKEY(I)
QUIT
+21 SET ^TMP($JOB,"MAGGSFLT","RES",$PIECE(^MAG(2005.87,I,0),"^",1)_"-"_I)=I_"^"_$PIECE(^MAG(2005.87,I,0),"^",1)_"^"_$PIECE(^MAG(2005.87,I,1),"^")
+22 ;S MAGRY($O(MAGRY(""),-1)+1)=I_"^"_$P(^MAG(2005.87,I,0),"^",1)_"^"_$P(^MAG(2005.87,I,1),"^")
+23 QUIT
End DoDot:2
End DoDot:1
+24 ;S MAGRY(0)=$S($G(MAGRY(1)):$O(MAGRY(""),-1),1:"0^ERROR Retrieving Filter list.")
+25 SET MAGRY(0)=$SELECT($DATA(^TMP($JOB,"MAGGSFLT","RES")):1,1:"0^ERROR Retrieving Filter list.")
+26 IF MAGRY(0)
Begin DoDot:1
+27 ; we have a list of filters, send the default as Piece 1 in 0 node.
+28 SET $PIECE(MAGRY(0),"^",1)=$$DFTFLT(USER)
End DoDot:1
+29 SET I=""
+30 FOR
SET I=$ORDER(^TMP($JOB,"MAGGSFLT","RES",I),-1)
if I=""
QUIT
Begin DoDot:1
+31 SET MAGRY($ORDER(MAGRY(""),-1)+1)=^TMP($JOB,"MAGGSFLT","RES",I)
End DoDot:1
+32 QUIT
+33 ;
HASKEY(IEN) ; True or False, Does user have Correct Key(s)(ADMIN and/or CLIN) to view this filter.
+1 NEW CLS
+2 SET CLS=$PIECE(^MAG(2005.87,IEN,0),"^",3)
+3 ; CLS="", now treat it as both. (Might rethink, treat it as any ? )
IF (CLS="")
SET CLS="CLIN,ADMIN"
+4 IF (CLS["ADMIN")
IF (CLS["CLIN")
QUIT (MAGCLIN&MAGADMIN)
+5 IF (CLS["CLIN")
QUIT MAGCLIN
+6 IF (CLS["ADMIN")
QUIT MAGADMIN
+7 QUIT 0
+8 ;
CLSKEYS(ADM,CLIN) ;
+1 SET (ADM,CLIN)=0
+2 NEW I,MAGKEY
+3 DO USERKEYS^MAGGTU3(.MAGKEY)
+4 SET I=""
FOR
SET I=$ORDER(MAGKEY(I))
if I=""
QUIT
Begin DoDot:1
+5 IF MAGKEY(I)="MAGDISP CLIN"
SET CLIN=1
+6 IF MAGKEY(I)="MAGDISP ADMIN"
SET ADM=1
+7 QUIT
End DoDot:1
+8 QUIT
+9 ;
GET(MAGRY,FLTIEN,FLTNAME,USER) ;RPC [MAG4 FILTER DETAILS] Return a filter
+1 NEW FLTC,I,MAGV,X
+2 KILL MAGRY
+3 ;--- Validate parameters
+4 IF '$GET(FLTIEN)
SET FLTIEN=$$RSLVIEN($GET(FLTNAME),$GET(USER))
+5 IF 'FLTIEN
SET MAGRY(0)="0^Can not resolve Filter name in VistA."
QUIT
+6 IF '$DATA(^MAG(2005.87,FLTIEN))
Begin DoDot:1
+7 SET MAGRY(0)="0^Filter ID #"_FLTIEN_" Doesn't exist."
+8 QUIT
End DoDot:1
QUIT
+9 ;--- Load the filter data
+10 SET FLTC=FLTIEN_","
+11 SET MAGRY(0)="1^Filter "_$PIECE(^MAG(2005.87,FLTIEN,0),"^",1)_" # "_FLTIEN
+12 DO GETS^DIQ(2005.87,FLTC,".01:16","EI","MAGV")
+13 ;--- Reformat the dates (FROM and UNTIL)
+14 FOR I=6,7
SET X=$GET(MAGV(2005.87,FLTC,I,"I"))
if X'=""
Begin DoDot:1
+15 SET MAGV(2005.87,FLTC,I,"E")=$$FMTE^XLFDT(X,"2Z")
+16 QUIT
End DoDot:1
+17 ;--- Add the filter data to the result array
+18 SET MAGRY(1)=FLTIEN
+19 FOR I=.01,1:1:9
SET MAGRY(1)=MAGRY(1)_U_$GET(MAGV(2005.87,FLTC,I,"E"))
+20 FOR I=10:1:16
SET MAGRY(1)=MAGRY(1)_U_$GET(MAGV(2005.87,FLTC,I,"I"))
+21 QUIT
+22 ;
RSLVIEN(NAME,USER) ; Return an IEN from the NAME and USER
+1 NEW I,IEN
SET I=""
+2 IF NAME=""
QUIT 0
+3 SET IEN=0
+4 FOR
SET I=$ORDER(^MAG(2005.87,"B",NAME,I))
if 'I
QUIT
Begin DoDot:1
+5 IF $PIECE(^MAG(2005.87,I,1),"^")=USER
SET IEN=I
End DoDot:1
+6 QUIT IEN
+7 ;
DFTFLT(USER) ; Create a Default Filter for user. Or Return Existing.
+1 ; Plus this call, makes sure the Default Filter is valid.
+2 ; USER is the IEN in the New Person file
+3 ; default to DUZ if ""
+4 NEW FLTIEN,XIEN
+5 SET USER=$SELECT($GET(USER):USER,1:$GET(DUZ))
+6 SET XIEN=$ORDER(^MAG(2006.18,"AC",USER,""))
if XIEN=""
QUIT 0
+7 SET FLTIEN=$PIECE($GET(^MAG(2006.18,XIEN,"LISTWIN1")),"^",3)
+8 IF FLTIEN
Begin DoDot:1
+9 ; Valid filter Quit.
IF $DATA(^MAG(2005.87,FLTIEN))
QUIT
+10 ; Users dflt filter invalid. Set dflt as first private or first public
+11 ; We dont' create the Admin All, or Clin All a second time.
+12 ; get first private
SET FLTIEN=$ORDER(^MAG(2005.87,"C",USER,""))
+13 ; return first public
IF 'FLTIEN
SET FLTIEN=$ORDER(^MAG(2005.87,"D",1,""))
+14 SET $PIECE(^MAG(2006.18,XIEN,"LISTWIN1"),"^",3)=FLTIEN
+15 QUIT
End DoDot:1
QUIT FLTIEN
+16 ;
+17 ; Here we'll create Private filters for a user or send first existing
+18 ; private filter as the default.
+19 NEW MAGADMIN,MAGCLIN,MAGY,MAGX
+20 ; get first private
SET FLTIEN=$ORDER(^MAG(2005.87,"C",USER,""))
+21 IF FLTIEN
SET $PIECE(^MAG(2006.18,XIEN,"LISTWIN1"),"^",3)=FLTIEN
QUIT FLTIEN
+22 DO CLSKEYS(.MAGADMIN,.MAGCLIN)
+23 IF MAGADMIN
Begin DoDot:1
+24 ; Create a Filter for All Admin add to IMAGE LIST FILTERS File for this user.
+25 SET MAGX(1)="USER^"_USER
+26 SET MAGX(2)=".01^Admin All"
+27 SET MAGX(3)="2^ADMIN"
+28 DO SET^MAGGSFL1(.MAGY,.MAGX)
+29 SET FLTIEN=$SELECT(+MAGY:+MAGY,1:"")
+30 QUIT
End DoDot:1
+31 KILL MAGY,MAGX
+32 IF MAGCLIN
Begin DoDot:1
+33 ;Create a Filter for All Clin add to IMAGE LIST FILTERS File for this user.
+34 SET MAGX(1)="USER^"_USER
+35 SET MAGX(2)=".01^Clinical All"
+36 SET MAGX(3)="2^CLIN"
+37 DO SET^MAGGSFL1(.MAGY,.MAGX)
+38 SET FLTIEN=$SELECT(+MAGY:+MAGY,1:"")
+39 QUIT
End DoDot:1
+40 if 'FLTIEN
QUIT 0
+41 SET $PIECE(^MAG(2006.18,XIEN,"LISTWIN1"),"^",3)=FLTIEN
+42 QUIT FLTIEN