source: WorldVistAEHR/trunk/r/CLINICAL_CASE_REGISTRIES-ROR/RORRP015.m@ 1087

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

initial load of WorldVistAEHR

File size: 7.9 KB
Line 
1RORRP015 ;HCIOFO/SG - RPC: DIVISIONS AND HOSPITAL LOCATIONS ; 3/13/06 9:25am
2 ;;1.5;CLINICAL CASE REGISTRIES;**1**;Feb 17, 2006;Build 24
3 ;
4 ; This routine uses the following IAs:
5 ;
6 ; #1246 WIN^DGPMDDCF (supported)
7 ; #2438 Access to the file #40.8 (controlled)
8 ; #10040 Access to the HOSPITAL LOCATION file (supported)
9 ;
10 Q
11 ;
12 ;***** CHECKS IF THE HOSPITAL LOCATION IS ACTIVE
13 ;
14 ; LOCIEN IEN of the hospital location
15 ;
16ACTLOC(LOCIEN) ;
17 N D0,DGPMOS,RDT,X
18 Q:$G(^SC(LOCIEN,"OOS")) 0 ; An OOS entry
19 S D0=+$G(^SC(LOCIEN,42))
20 I D0>0 D WIN^DGPMDDCF Q 'X ; Check if ward is inactive
21 S X=$G(^SC(LOCIEN,"I")) Q:'$P(X,U) 1 ; No inactivation date
22 S RDT=+$P(X,U,2)
23 I DT>$P(X,U) Q:'RDT!(DT<RDT) 0 ; Check reactivation date
24 Q 1
25 ;
26 ;***** RETURNS THE LIST OF DIVISIONS
27 ; RPC: [ROR LIST DIVISIONS]
28 ;
29 ; .RESULTS Reference to a local variable where the results
30 ; are returned to.
31 ;
32 ; [PART] The partial match restriction.
33 ;
34 ; [FLAGS] Flags that control the execution (can be combined)
35 ; B Backwards. Traverses the index in the opposite
36 ; direction of normal traversal.
37 ;
38 ; [NUMBER] Maximum number of entries to return. A value of "*"
39 ; or no value in this parameter designates all entries.
40 ;
41 ; [FROM] The index entry(s) from which to begin the list
42 ; ^01: FromName
43 ; ^02: FromIEN
44 ;
45 ; For example, a FROM value of "VA" would list entries
46 ; following VA. You can use the 2-nd and 3-rd "^"-
47 ; pieces of the @RESULTS@(0) node to continue the
48 ; listing in the subsequent procedure calls.
49 ;
50 ; NOTE: The FROM value itself is not included in
51 ; the resulting list.
52 ;
53 ; The ^TMP("DILIST",$J) global node is used by the procedure.
54 ;
55 ; See description of the LIST^DIC for more details about the
56 ; PART, NUMBER and FROM parameters.
57 ;
58 ; Return Values:
59 ;
60 ; A negative value of the first "^"-piece of the @RESULTS@(0)
61 ; indicates an error (see the RPCSTK^RORERR procedure for more
62 ; details).
63 ;
64 ; Otherwise, number of divisions and the value of the FROM parameter
65 ; for the next procedure call are returned in the @RESULTS@(0) and
66 ; the subsequent nodes of the global array contain the divisions.
67 ;
68 ; @RESULTS@(0) Result Descriptor
69 ; ^01: Number of divisions
70 ; ^02: FromName
71 ; ^03: FromIEN
72 ;
73 ; @RESULTS@(i) Division
74 ; ^01: IEN
75 ; ^02: Name
76 ; ^03: Facility Number
77 ; ^04: Institution IEN
78 ;
79DIVLIST(RESULTS,PART,FLAGS,NUMBER,FROM) ;
80 N BUF,RC,RORERRDL,RORMSG,TMP
81 D CLEAR^RORERR("DIVLIST^RORRP015",1)
82 K RESULTS S RESULTS=$NA(^TMP("DILIST",$J)) K @RESULTS
83 ;--- Check the parameters
84 S PART=$G(PART),FLAGS=$G(FLAGS)
85 S NUMBER=$S($G(NUMBER)>0:+NUMBER,1:"*")
86 ;--- Setup the start point
87 I $G(FROM)'="" D S FROM=$P(FROM,U)
88 . S:$P(FROM,U,2)>0 FROM("IEN")=+$P(FROM,U,2)
89 ;--- Get the list of divisions
90 S BUF="@;.01;1;.07I",TMP="P"_$S(FLAGS["B":"B",1:"")
91 D LIST^DIC(40.8,,BUF,TMP,NUMBER,.FROM,PART,"B",,,,"RORMSG")
92 I $G(DIERR) D D RPCSTK^RORERR(.RESULTS,RC) Q
93 . S RC=$$DBS^RORERR("RORMSG",-9,,,40.8)
94 . K ^TMP("DILIST",$J)
95 ;--- Success
96 S TMP=$G(^TMP("DILIST",$J,0)),BUF=+$P(TMP,U)
97 K ^TMP("DILIST",$J,0)
98 S:$P(TMP,U,3) $P(BUF,U,2,3)=$G(FROM)_U_$G(FROM("IEN"))
99 S @RESULTS@(0)=BUF
100 Q
101 ;
102 ;***** RETURNS THE LIST OF HOSPITAL LOCATIONS
103 ; RPC: [ROR LIST HOSPITAL LOCATIONS]
104 ;
105 ; .RESULTS Reference to a local variable where the results
106 ; are returned to.
107 ;
108 ; [HLTYPES] List of location types separated by commas (internal
109 ; values of the TYPE field of the HOSPITAL LOCATION
110 ; file). Only locations of the types defined by this
111 ; parameter are selected by the procedure. By default
112 ; ($G(HLTYPES)=""), all locations are selected.
113 ;
114 ; [DIVIEN] Division IEN. If this parameter is defined and
115 ; greater than zero then only the locations associated
116 ; with this division will be selected.
117 ;
118 ; [PART] The partial match restriction.
119 ;
120 ; [FLAGS] Flags that control the execution (can be combined):
121 ; A Include active locations (default)
122 ; B Backwards. Traverses the index in the opposite
123 ; direction of normal traversal.
124 ; I Include inactive locations
125 ;
126 ; [NUMBER] Maximum number of entries to return. A value of "*"
127 ; or no value in this parameter designates all entries.
128 ;
129 ; [FROM] The index entry(s) from which to begin the list
130 ; ^01: FromName
131 ; ^02: FromIEN
132 ;
133 ; For example, a FROM value of "VA" would list entries
134 ; following VA. You can use the 2-nd and 3-rd "^"-
135 ; pieces of the @RESULTS@(0) node to continue the
136 ; listing in the subsequent procedure calls.
137 ;
138 ; NOTE: The FROM value itself is not included in
139 ; the resulting list.
140 ;
141 ; The ^TMP("DILIST",$J) global node is used by the procedure.
142 ;
143 ; See description of the LIST^DIC for more details about the
144 ; PART, NUMBER and FROM parameters.
145 ;
146 ; Return Values:
147 ;
148 ; A negative value of the first "^"-piece of the @RESULTS@(0)
149 ; indicates an error (see the RPCSTK^RORERR procedure for more
150 ; details).
151 ;
152 ; Otherwise, number of hospital locations and the value of the
153 ; FROM parameter for the next procedure call are returned in
154 ; the @RESULTS@(0) and the subsequent nodes of the global array
155 ; contain the locations.
156 ;
157 ; @RESULTS@(0) Result Descriptor
158 ; ^01: Number of locations
159 ; ^02: FromName
160 ; ^03: FromIEN
161 ;
162 ; @RESULTS@(i) Hospital Location
163 ; ^01: IEN
164 ; ^02: Name
165 ; ^03: Type (internal)
166 ; ^04: Institution IEN
167 ; ^05: Division IEN
168 ; ^06: Active (0/1)
169 ;
170 ; NOTE: The 6th "^"-piece of the location record (Active) is
171 ; populated only if both "A" and "I" flags are used.
172 ;
173HLOCLIST(RESULTS,HLTYPES,DIVIEN,PART,FLAGS,NUMBER,FROM) ;
174 N BUF,I,RC,RORERRDL,RORHLT,RORMSG,SCR,TMP
175 D CLEAR^RORERR("HLOCLIST^RORRP015",1)
176 K RESULTS S RESULTS=$NA(^TMP("DILIST",$J)) K @RESULTS
177 ;--- Check the parameters
178 S HLTYPES=$$UP^XLFSTR($TR($G(HLTYPES)," "))
179 F I=1:1 S TMP=$P(HLTYPES,",",I) Q:TMP="" S RORHLT(TMP)=""
180 S DIVIEN=$S($G(DIVIEN)>0:+DIVIEN,1:0)
181 S PART=$G(PART),FLAGS=$G(FLAGS)
182 S NUMBER=$S($G(NUMBER)>0:+NUMBER,1:"*")
183 ;--- If neither "A" nor "I" flag is provided, add the "A" (default)
184 S:$TR(FLAGS,"AI")=FLAGS FLAGS=FLAGS_"A"
185 ;--- Setup the start point
186 I $G(FROM)'="" D S FROM=$P(FROM,U)
187 . S:$P(FROM,U,2)>0 FROM("IEN")=+$P(FROM,U,2)
188 ;--- Compile the screen logic (be careful with naked references)
189 S SCR=""
190 D:$D(RORHLT)>1
191 . S SCR=SCR_"S D=$P($G(^(0)),U,3) I D'="""",$D(RORHLT(D)) "
192 S:DIVIEN SCR=SCR_"I $P($G(^(0)),U,15)=DIVIEN "
193 S:FLAGS'["A" SCR=SCR_"I '$$ACTLOC^RORRP015(+Y) "
194 S:FLAGS'["I" SCR=SCR_"I $$ACTLOC^RORRP015(+Y) "
195 ;--- Get the list of locations
196 S BUF="@;.01;2I;3I;3.5I",TMP="P"_$S(FLAGS["B":"B",1:"")
197 D LIST^DIC(44,,BUF,TMP,NUMBER,.FROM,PART,"B",SCR,,,"RORMSG")
198 I $G(DIERR) D D RPCSTK^RORERR(.RESULTS,RC) Q
199 . S RC=$$DBS^RORERR("RORMSG",-9,,,44)
200 . K ^TMP("DILIST",$J)
201 ;--- Populate the Active field if both flags are used
202 I FLAGS["I",FLAGS["A" S I=0 D
203 . F S I=$O(@RESULTS@(I)) Q:I="" D
204 . . S $P(@RESULTS@(I,0),U,6)=$$ACTLOC(+@RESULTS@(I,0))
205 ;--- Success
206 S TMP=$G(^TMP("DILIST",$J,0)),BUF=+$P(TMP,U)
207 K ^TMP("DILIST",$J,0)
208 S:$P(TMP,U,3) $P(BUF,U,2,3)=$G(FROM)_U_$G(FROM("IEN"))
209 S @RESULTS@(0)=BUF
210 Q
Note: See TracBrowser for help on using the repository browser.