Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: MAGGSFLT

MAGGSFLT.m

Go to the documentation of this file.
  1. 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
  1. ;; Per VHA Directive 2004-038, this routine should not be modified.
  1. ;; +---------------------------------------------------------------+
  1. ;; | Property of the US Government. |
  1. ;; | No permission to copy or redistribute this software is given. |
  1. ;; | Use of unreleased versions of this software requires the user |
  1. ;; | to execute a written test agreement with the VistA Imaging |
  1. ;; | Development Office of the Department of Veterans Affairs, |
  1. ;; | telephone (301) 734-0100. |
  1. ;; | |
  1. ;; | The Food and Drug Administration classifies this software as |
  1. ;; | a medical device. As such, it may not be changed in any way. |
  1. ;; | Modifications to this software may result in an adulterated |
  1. ;; | medical device under 21CFR820, the use of which is considered |
  1. ;; | to be a violation of US Federal Statutes. |
  1. ;; +---------------------------------------------------------------+
  1. ;;
  1. Q
  1. ;
  1. DEL(MAGRY,FLTIEN) ;RPC [MAG4 FILTER DELETE] DELETE A FILTER
  1. N DIK,DA
  1. S DIK="^MAG(2005.87,"
  1. S DA=FLTIEN
  1. D ^DIK
  1. D CLEAN^DILF
  1. S MAGRY="1^Deleted"
  1. Q
  1. ;
  1. GETLIST(MAGRY,USER,GETALL) ;RPC [MAG4 FILTER GET LIST] Return a list of filters for a USER
  1. ; user = DUZ
  1. ; if user = "" send list of public filters
  1. ; if user > 0 and GETALL = 1 then send User Private and Public filters.
  1. N I,MAGADMIN,MAGCLIN
  1. K ^TMP($J,"MAGGSFLT","RES")
  1. S USER=$G(USER)
  1. S MAGRY(0)="0^Retrieving Filter list..."
  1. ; we'll get public if getall or no user
  1. D CLSKEYS(.MAGADMIN,.MAGCLIN)
  1. I $G(GETALL)!('USER) D
  1. . S I=""
  1. . F S I=$O(^MAG(2005.87,"D",1,I)) Q:I="" D
  1. . . I '$$HASKEY(I) Q ; HERE HAVE TO USE DUZ, TO FILTER THE FILTERS BASED ON MAGDISP CLIN AND MAGDISP ADMIN
  1. . . 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),"^")
  1. . . ;S MAGRY($O(MAGRY(""),-1)+1)=I_"^"_$P(^MAG(2005.87,I,0),"^",1)_"^"_$P(^MAG(2005.87,I,1),"^")
  1. . . Q
  1. I USER D
  1. . S I=""
  1. . F S I=$O(^MAG(2005.87,"C",USER,I)) Q:I="" D
  1. . . I '$$HASKEY(I) Q
  1. . . 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),"^")
  1. . . ;S MAGRY($O(MAGRY(""),-1)+1)=I_"^"_$P(^MAG(2005.87,I,0),"^",1)_"^"_$P(^MAG(2005.87,I,1),"^")
  1. . . Q
  1. ;S MAGRY(0)=$S($G(MAGRY(1)):$O(MAGRY(""),-1),1:"0^ERROR Retrieving Filter list.")
  1. S MAGRY(0)=$S($D(^TMP($J,"MAGGSFLT","RES")):1,1:"0^ERROR Retrieving Filter list.")
  1. I MAGRY(0) D
  1. . ; we have a list of filters, send the default as Piece 1 in 0 node.
  1. . S $P(MAGRY(0),"^",1)=$$DFTFLT(USER)
  1. S I=""
  1. F S I=$O(^TMP($J,"MAGGSFLT","RES",I),-1) Q:I="" D
  1. . S MAGRY($O(MAGRY(""),-1)+1)=^TMP($J,"MAGGSFLT","RES",I)
  1. Q
  1. ;
  1. HASKEY(IEN) ; True or False, Does user have Correct Key(s)(ADMIN and/or CLIN) to view this filter.
  1. N CLS
  1. S CLS=$P(^MAG(2005.87,IEN,0),"^",3)
  1. I (CLS="") S CLS="CLIN,ADMIN" ; CLS="", now treat it as both. (Might rethink, treat it as any ? )
  1. I (CLS["ADMIN"),(CLS["CLIN") Q (MAGCLIN&MAGADMIN)
  1. I (CLS["CLIN") Q MAGCLIN
  1. I (CLS["ADMIN") Q MAGADMIN
  1. Q 0
  1. ;
  1. CLSKEYS(ADM,CLIN) ;
  1. S (ADM,CLIN)=0
  1. N I,MAGKEY
  1. D USERKEYS^MAGGTU3(.MAGKEY)
  1. S I="" F S I=$O(MAGKEY(I)) Q:I="" D
  1. . I MAGKEY(I)="MAGDISP CLIN" S CLIN=1
  1. . I MAGKEY(I)="MAGDISP ADMIN" S ADM=1
  1. . Q
  1. Q
  1. ;
  1. GET(MAGRY,FLTIEN,FLTNAME,USER) ;RPC [MAG4 FILTER DETAILS] Return a filter
  1. N FLTC,I,MAGV,X
  1. K MAGRY
  1. ;--- Validate parameters
  1. I '$G(FLTIEN) S FLTIEN=$$RSLVIEN($G(FLTNAME),$G(USER))
  1. I 'FLTIEN S MAGRY(0)="0^Can not resolve Filter name in VistA." Q
  1. I '$D(^MAG(2005.87,FLTIEN)) D Q
  1. . S MAGRY(0)="0^Filter ID #"_FLTIEN_" Doesn't exist."
  1. . Q
  1. ;--- Load the filter data
  1. S FLTC=FLTIEN_","
  1. S MAGRY(0)="1^Filter "_$P(^MAG(2005.87,FLTIEN,0),"^",1)_" # "_FLTIEN
  1. D GETS^DIQ(2005.87,FLTC,".01:16","EI","MAGV")
  1. ;--- Reformat the dates (FROM and UNTIL)
  1. F I=6,7 S X=$G(MAGV(2005.87,FLTC,I,"I")) D:X'=""
  1. . S MAGV(2005.87,FLTC,I,"E")=$$FMTE^XLFDT(X,"2Z")
  1. . Q
  1. ;--- Add the filter data to the result array
  1. S MAGRY(1)=FLTIEN
  1. F I=.01,1:1:9 S MAGRY(1)=MAGRY(1)_U_$G(MAGV(2005.87,FLTC,I,"E"))
  1. F I=10:1:16 S MAGRY(1)=MAGRY(1)_U_$G(MAGV(2005.87,FLTC,I,"I"))
  1. Q
  1. ;
  1. RSLVIEN(NAME,USER) ; Return an IEN from the NAME and USER
  1. N I,IEN S I=""
  1. I NAME="" Q 0
  1. S IEN=0
  1. F S I=$O(^MAG(2005.87,"B",NAME,I)) Q:'I D
  1. . I $P(^MAG(2005.87,I,1),"^")=USER S IEN=I
  1. Q IEN
  1. ;
  1. DFTFLT(USER) ; Create a Default Filter for user. Or Return Existing.
  1. ; Plus this call, makes sure the Default Filter is valid.
  1. ; USER is the IEN in the New Person file
  1. ; default to DUZ if ""
  1. N FLTIEN,XIEN
  1. S USER=$S($G(USER):USER,1:$G(DUZ))
  1. S XIEN=$O(^MAG(2006.18,"AC",USER,"")) Q:XIEN="" 0
  1. S FLTIEN=$P($G(^MAG(2006.18,XIEN,"LISTWIN1")),"^",3)
  1. I FLTIEN D Q FLTIEN
  1. . I $D(^MAG(2005.87,FLTIEN)) Q ; Valid filter Quit.
  1. . ; Users dflt filter invalid. Set dflt as first private or first public
  1. . ; We dont' create the Admin All, or Clin All a second time.
  1. . S FLTIEN=$O(^MAG(2005.87,"C",USER,"")) ; get first private
  1. . I 'FLTIEN S FLTIEN=$O(^MAG(2005.87,"D",1,"")) ; return first public
  1. . S $P(^MAG(2006.18,XIEN,"LISTWIN1"),"^",3)=FLTIEN
  1. . Q
  1. ;
  1. ; Here we'll create Private filters for a user or send first existing
  1. ; private filter as the default.
  1. N MAGADMIN,MAGCLIN,MAGY,MAGX
  1. S FLTIEN=$O(^MAG(2005.87,"C",USER,"")) ; get first private
  1. I FLTIEN S $P(^MAG(2006.18,XIEN,"LISTWIN1"),"^",3)=FLTIEN Q FLTIEN
  1. D CLSKEYS(.MAGADMIN,.MAGCLIN)
  1. I MAGADMIN D
  1. . ; Create a Filter for All Admin add to IMAGE LIST FILTERS File for this user.
  1. . S MAGX(1)="USER^"_USER
  1. . S MAGX(2)=".01^Admin All"
  1. . S MAGX(3)="2^ADMIN"
  1. . D SET^MAGGSFL1(.MAGY,.MAGX)
  1. . S FLTIEN=$S(+MAGY:+MAGY,1:"")
  1. . Q
  1. K MAGY,MAGX
  1. I MAGCLIN D
  1. . ;Create a Filter for All Clin add to IMAGE LIST FILTERS File for this user.
  1. . S MAGX(1)="USER^"_USER
  1. . S MAGX(2)=".01^Clinical All"
  1. . S MAGX(3)="2^CLIN"
  1. . D SET^MAGGSFL1(.MAGY,.MAGX)
  1. . S FLTIEN=$S(+MAGY:+MAGY,1:"")
  1. . Q
  1. Q:'FLTIEN 0
  1. S $P(^MAG(2006.18,XIEN,"LISTWIN1"),"^",3)=FLTIEN
  1. Q FLTIEN