source: WorldVistAEHR/trunk/r/IMAGING-MAG-ZMAG/MAGGSFLT.m@ 1211

Last change on this file since 1211 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 5.4 KB
Line 
1MAGGSFLT ;WOIFO/GEK - Image list Filters utilities ; [ 06/20/2001 08:57 ]
2 ;;3.0;IMAGING;**7,8**;Sep 15, 2004
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 Q
19DEL(MAGRY,FLTIEN) ;RPC [MAG4 FILTER DELETE] DELETE A FILTER
20 N DIK,DA
21 S DIK="^MAG(2005.87,"
22 S DA=FLTIEN
23 D ^DIK
24 D CLEAN^DILF
25 S MAGRY="1^Deleted"
26 Q
27GETLIST(MAGRY,USER,GETALL) ;RPC [MAG4 FILTER GET LIST] Return a list of filters for a USER
28 ; user = DUZ
29 ; if user = "" send list of public filters
30 ; if user > 0 and GETALL = 1 then send User Private and Public filters.
31 N I,MAGADMIN,MAGCLIN
32 S USER=$G(USER)
33 S MAGRY(0)="0^Retrieving Filter list..."
34 ; we'll get public if getall or no user
35 D CLSKEYS(.MAGADMIN,.MAGCLIN)
36 I $G(GETALL)!('USER) D
37 . S I=""
38 . F S I=$O(^MAG(2005.87,"D",1,I)) Q:I="" D
39 . . I '$$HASKEY(I) Q ; HERE HAVE TO USE DUZ, TO FILTER THE FILTERS BASED ON MAGDISP CLIN AND MAGDISP ADMIN
40 . . S MAGRY($O(MAGRY(""),-1)+1)=I_"^"_$P(^MAG(2005.87,I,0),"^",1)_"^"_$P(^MAG(2005.87,I,1),"^")
41 . . Q
42 I USER D
43 . S I=""
44 . F S I=$O(^MAG(2005.87,"C",USER,I)) Q:I="" D
45 . . I '$$HASKEY(I) Q
46 . . S MAGRY($O(MAGRY(""),-1)+1)=I_"^"_$P(^MAG(2005.87,I,0),"^",1)_"^"_$P(^MAG(2005.87,I,1),"^")
47 . . Q
48 S MAGRY(0)=$S($G(MAGRY(1)):$O(MAGRY(""),-1),1:"0^ERROR Retrieving Filter list.")
49 I MAGRY(0) D
50 . ; we have a list of filters, send the default as Piece 1 in 0 node.
51 . S $P(MAGRY(0),"^",1)=$$DFTFLT(USER)
52 Q
53HASKEY(IEN) ; True or False, Does user have Correct Key(s)(ADMIN and/or CLIN) to view this filter.
54 N CLS
55 S CLS=$P(^MAG(2005.87,IEN,0),"^",3)
56 I (CLS="") S CLS="CLIN,ADMIN" ; CLS="", now treat it as both. (Might rethink, treat it as any ? )
57 I (CLS["ADMIN"),(CLS["CLIN") Q (MAGCLIN&MAGADMIN)
58 I (CLS["CLIN") Q MAGCLIN
59 I (CLS["ADMIN") Q MAGADMIN
60 Q 0
61CLSKEYS(ADM,CLIN) ;
62 S (ADM,CLIN)=0
63 N I,MAGKEY
64 D USERKEYS^MAGGTU3(.MAGKEY)
65 S I="" F S I=$O(MAGKEY(I)) Q:I="" D
66 . I MAGKEY(I)="MAGDISP CLIN" S CLIN=1
67 . I MAGKEY(I)="MAGDISP ADMIN" S ADM=1
68 . Q
69 Q
70GET(MAGRY,FLTIEN,FLTNAME,USER) ;RPC [MAG4 FILTER DETAILS] Return a filter
71 ; Return the full FLTIEN Node, the Delphi App will Parse it.
72 K MAGV,FLTC
73 I '$G(FLTIEN) S FLTIEN=$$RSLVIEN($G(FLTNAME),$G(USER))
74 I 'FLTIEN S MAGRY(0)="0^Can not resolve Filter name in VistA." Q
75 I '$D(^MAG(2005.87,FLTIEN)) S MAGRY="0^Filter ID #"_FLTIEN_" Doesn't exist." Q
76 S FLTC=FLTIEN_","
77 S MAGRY(0)="1^Filter "_$P(^MAG(2005.87,FLTIEN,0),"^",1)_" # "_FLTIEN
78 ; S MAGRY(1)=FLTIEN_"^"_^MAG(2005.87,FLTIEN,0)
79 F I=1:1:9 D GETS^DIQ(2005.87,FLTC,".01:9","E","MAGV")
80 S MAGRY(1)=FLTIEN
81 S X=MAGV(2005.87,FLTC,6,"E") I X]"" S %DT="" D ^%DT S MAGV(2005.87,FLTC,6,"E")=$$FMTE^XLFDT(Y,"2Z")
82 S X=MAGV(2005.87,FLTC,7,"E") I X]"" S %DT="" D ^%DT S MAGV(2005.87,FLTC,7,"E")=$$FMTE^XLFDT(Y,"2Z")
83 S I="" F S I=$O(MAGV(2005.87,FLTC,I)) Q:I="" S MAGRY(1)=MAGRY(1)_"^"_MAGV(2005.87,FLTC,I,"E")
84 Q
85RSLVIEN(NAME,USER) ; Return an IEN from the NAME and USER
86 N I,IEN S I=""
87 I NAME="" Q 0
88 S IEN=0
89 F S I=$O(^MAG(2005.87,"B",NAME,I)) Q:'I D
90 . I $P(^MAG(2005.87,I,1),"^")=USER S IEN=I
91 Q IEN
92DFTFLT(USER) ; Create a Default Filter for user. Or Return Existing.
93 ; Plus this call, makes sure the Default Filter is valid.
94 ; USER is the IEN in the New Person file
95 ; default to DUZ if ""
96 N FLTIEN,XIEN
97 S USER=$S($G(USER):USER,1:$G(DUZ))
98 S XIEN=$O(^MAG(2006.18,"AC",USER,"")) Q:XIEN="" 0
99 S FLTIEN=$P($G(^MAG(2006.18,XIEN,"LISTWIN1")),"^",3)
100 I FLTIEN D Q FLTIEN
101 . I $D(^MAG(2005.87,FLTIEN)) Q ; Valid filter Quit.
102 . ; Users dflt filter invalid. Set dflt as first private or first public
103 . ; We dont' create the Admin All, or Clin All a second time.
104 . S FLTIEN=$O(^MAG(2005.87,"C",USER,"")) ; get first private
105 . I 'FLTIEN S FLTIEN=$O(^MAG(2005.87,"D",1,"")) ; return first public
106 . S $P(^MAG(2006.18,XIEN,"LISTWIN1"),"^",3)=FLTIEN
107 . Q
108 ;
109 ; Here we'll create Private filters for a user or send first existing
110 ; private filter as the default.
111 N MAGADMIN,MAGCLIN,MAGY,MAGX
112 S FLTIEN=$O(^MAG(2005.87,"C",USER,"")) ; get first private
113 I FLTIEN S $P(^MAG(2006.18,XIEN,"LISTWIN1"),"^",3)=FLTIEN Q FLTIEN
114 D CLSKEYS(.MAGADMIN,.MAGCLIN)
115 I MAGADMIN D
116 . ; Create a Filter for All Admin add to IMAGE LIST FILTERS File for this user.
117 . S MAGX(1)="USER^"_USER
118 . S MAGX(2)=".01^Admin All"
119 . S MAGX(3)="2^ADMIN"
120 . D SET^MAGGSFL1(.MAGY,.MAGX)
121 . S FLTIEN=$S(+MAGY:+MAGY,1:"")
122 . Q
123 K MAGY,MAGX
124 I MAGCLIN D
125 . ;Create a Filter for All Clin add to IMAGE LIST FILTERS File for this user.
126 . S MAGX(1)="USER^"_USER
127 . S MAGX(2)=".01^Clinical All"
128 . S MAGX(3)="2^CLIN"
129 . D SET^MAGGSFL1(.MAGY,.MAGX)
130 . S FLTIEN=$S(+MAGY:+MAGY,1:"")
131 . Q
132 Q:'FLTIEN 0
133 S $P(^MAG(2006.18,XIEN,"LISTWIN1"),"^",3)=FLTIEN
134 Q FLTIEN
Note: See TracBrowser for help on using the repository browser.