source: FOIAVistA/trunk/r/CLINICAL_CASE_REGISTRIES-ROR/RORRP024.m@ 1203

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

initial load of FOIAVistA 6/30/08 version

File size: 6.4 KB
Line 
1RORRP024 ;HCIOFO/SG - RPC: VISTA USERS ; 12/15/05 4:31pm
2 ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
3 ;
4 ; This routine uses the following IAs:
5 ;
6 ; #10060 Read access (FileMan) to the NEW PERSON file
7 ;
8 Q
9 ;
10 ;***** RETURNS THE DEFAULT DIVISION FOR THE USER
11 ;
12 ; USER User IEN in file #200 (DUZ)
13 ;
14 ; Return Values:
15 ; ... Default Division
16 ; ^01: IEN (in the INSTITUTION file)
17 ; ^02: Name
18 ;
19DFLTDIV(USER) ;
20 N DIV,IENS,IR,RORBUF,RORMSG,TMP
21 S IENS=","_(+USER)_",",TMP="@;.01I;.01E;1I"
22 D LIST^DIC(200.02,IENS,TMP,"PQ",,,,"#",,,"RORBUF","RORMSG")
23 D:$G(DIERR) DBS^RORERR("RORMSG",-9,,,200,IENS)
24 S DIV=""
25 ;--- Look for default division
26 D:$G(RORBUF("DILIST",0))>0
27 . S IR=0
28 . F S IR=$O(RORBUF("DILIST",IR)) Q:IR'>0 D Q:DIV'=""
29 . . S TMP=$G(RORBUF("DILIST",IR,0))
30 . . S:$P(TMP,U,4) DIV=$P(TMP,U,2,3)
31 . ;--- If name of the default division is not available
32 . ; and the only division is associated with the user
33 . ;--- then use this division as the default one.
34 . I $P(DIV,U,2)="" D:RORBUF("DILIST",0)<2
35 . . S DIV=$P($G(RORBUF("DILIST",1,0)),U,2,3)
36 ;--- If default division is not available, use the site
37 Q $S($P(DIV,U,2)'="":DIV,1:$P($$SITE^VASITE(),U,1,2))
38 ;
39 ;***** RETURNS INFORMATION ABOUT THE USER
40 ; RPC: [ROR GET USER IFNO]
41 ;
42 ; .RESULTS Reference to a local variable where the results
43 ; are returned to.
44 ;
45 ; [USER] User IEN in the NEW PERSON file. By default
46 ; (if $G(USER)'>0), the DUZ is used).
47 ;
48 ; Return Values:
49 ;
50 ; A negative value of the first "^"-piece of the RESULTS(0)
51 ; indicates an error (see the RPCSTK^RORERR procedure for more
52 ; details).
53 ;
54 ; Otherwise, the user info is returned in the RESULTS(0).
55 ;
56 ; RESULTS(0) User Info
57 ; ^01: IEN
58 ; ^02: Name
59 ; ^03: Office Phone
60 ; ^04: Nickname
61 ; ^05: Read Timeout
62 ; ^06: Default Division IEN
63 ; ^07: Default Division Name
64 ; ^08: Institution IEN
65 ; ^09: Institution Name
66 ; ^10: Station Number (with suffix)
67 ;
68USERINFO(RESULTS,USER) ;
69 N IENS,RORBUF,RORERRDL,RORMSG,TMP
70 D CLEAR^RORERR("USERINFO^RORRP024",1)
71 K RESULTS S RESULTS(0)=0
72 I $G(USER)'>0 S USER=+$G(DUZ) Q:USER'>0
73 ;--- Load the data
74 S IENS=USER_","
75 D GETS^DIQ(200,IENS,".01;.132;13",,"RORBUF","RORMSG")
76 I $G(DIERR) D D RPCSTK^RORERR(.RESULTS,RC) Q
77 . S RC=$$DBS^RORERR("RORMSG",-9,,,200) K ^TMP("DILIST",$J)
78 ;--- Compile the result
79 S RESULTS(0)=USER
80 S $P(RESULTS(0),U,2)=$G(RORBUF(200,IENS,.01)) ; Name
81 S $P(RESULTS(0),U,3)=$G(RORBUF(200,IENS,.132)) ; Office Phone
82 S $P(RESULTS(0),U,4)=$G(RORBUF(200,IENS,13)) ; Nick Name
83 S $P(RESULTS(0),U,5)=$$DTIME^XUP(USER) ; Read Timeout
84 S TMP=$$DFLTDIV(USER)
85 S $P(RESULTS(0),U,6,7)=$P(TMP,U,1,2) ; Default Division
86 S $P(RESULTS(0),U,8,10)=$$SITE^VASITE()
87 Q
88 ;
89 ;***** RETURNS THE LIST OF VISTA USERS
90 ; RPC: [ROR LIST VISTA USERS]
91 ;
92 ; .RESULTS Reference to a local variable where the results
93 ; are returned to.
94 ;
95 ; PART The search pattern (partial match restriction)
96 ;
97 ; [FLAGS] Flags that control the execution (can be combined):
98 ; B Backwards. Traverses the index in the opposite
99 ; direction of normal traversal.
100 ; D Get default division for each user
101 ; P Select providers only (check for the PROVIDER
102 ; security key)
103 ;
104 ; [NUMBER] Maximum number of entries to return. A value of "*"
105 ; or no value in this parameter designates all entries.
106 ;
107 ; [FROM] The index entry(s) from which to begin the list.
108 ; You should use the pieces of the @RESULTS@(0) node
109 ; (starting from the second one) to continue the
110 ; listing in the subsequent procedure calls.
111 ;
112 ; NOTE: The FROM value itself is not included in
113 ; the resulting list.
114 ;
115 ; The ^TMP("DILIST",$J) global node is used by the procedure.
116 ;
117 ; See description of the LIST^DIC for more details about the
118 ; PART, NUMBER and FROM parameters.
119 ;
120 ; Return Values:
121 ;
122 ; A negative value of the first "^"-piece of the RESULTS(0)
123 ; indicates an error (see the RPCSTK^RORERR procedure for more
124 ; details).
125 ;
126 ; Otherwise, number of VistA users and the value of the FROM
127 ; parameter for the next procedure call are returned in the
128 ; @RESULTS@(0) and the subsequent nodes of the global array
129 ; contain the users.
130 ;
131 ; @RESULTS@(0) Result Descriptor
132 ; ^01: Number of users
133 ; ^02: Values that comprise the FROM
134 ; ^nn: parameter for the subsequent call
135 ;
136 ; @RESULTS@(i) User
137 ; ^01: IEN
138 ; ^02: Name
139 ; ^03: Office Phone
140 ; ^04: Nickname
141 ; ^05: reserved
142 ; ^06: Default Division IEN (only if D flag)
143 ; ^07: Default Division Name (only if D flag)
144 ;
145USERLIST(RESULTS,PART,FLAGS,NUMBER,FROM) ;
146 N BUF,FIELDS,I,RC,RORERRDL,SCR,TMP
147 D CLEAR^RORERR("USERLIST^RORRP024",1)
148 K RESULTS S RESULTS=$NA(^TMP("DILIST",$J)) K @RESULTS
149 ;--- Check the parameters
150 S RC=0 D I RC<0 D RPCSTK^RORERR(.RESULTS,RC) Q
151 . ;--- Flags
152 . S FLAGS=$$UP^XLFSTR($G(FLAGS))
153 . ;--- Others
154 . S PART=$G(PART),FROM=$G(FROM)
155 . S NUMBER=$S($G(NUMBER)>0:+NUMBER,1:"*")
156 ;--- Setup the start point
157 F I=1:1 S TMP=$P(FROM,U,I) Q:TMP="" S FROM(I)=TMP
158 S FROM=$G(FROM(1))
159 ;--- Compile the screen logic (be careful with naked references)
160 S SCR=""
161 S:FLAGS["P" SCR=SCR_"I $D(^XUSEC(""PROVIDER"",Y))"
162 ;--- Query the file
163 S FIELDS="@;.01;.132;13",TMP="P"_$S(FLAGS["B":"B",1:"")
164 D LIST^DIC(200,,FIELDS,TMP,NUMBER,.FROM,PART,"B",SCR,,,"RORMSG")
165 I $G(DIERR) D D RPCSTK^RORERR(.RESULTS,RC) Q
166 . S RC=$$DBS^RORERR("RORMSG",-9,,,200) K ^TMP("DILIST",$J)
167 ;--- Add default divisions
168 I FLAGS["D" S I=0 D
169 . F S I=$O(@RESULTS@(I)) Q:I'>0 D
170 . . S $P(@RESULTS@(I,0),U,6,7)=$P($$DFLTDIV(+@RESULTS@(I,0)),U,1,2)
171 ;--- Success
172 S TMP=$G(^TMP("DILIST",$J,0)),BUF=+$P(TMP,U)
173 K ^TMP("DILIST",$J,0)
174 I $P(TMP,U,3) S I=0 D
175 . F S I=$O(FROM(I)) Q:I'>0 S TMP=FROM(I) S:TMP'="" BUF=BUF_U_TMP
176 S @RESULTS@(0)=BUF
177 Q
Note: See TracBrowser for help on using the repository browser.