source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCMSVUT1.m@ 1780

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

initial load of WorldVistAEHR

File size: 8.7 KB
Line 
1SCMSVUT1 ;ALB/JLU;validation utility routine;06/19/99 ; 4/30/03 11:58am
2 ;;5.3;Scheduling;**66,143,180,239,247,258,296,295,321,341,387,459,394,442**;AUG 13,1993
3 ;06/19/99 ACS - Added CPT Modifier API calls to PROCCOD(DATA)
4 ;
5SEGERR(DATA,HLFS) ;
6 ;INPUT DATA - This is a check for the segment errors of null
7 ; HLFS - The string separator character
8 I '$D(DATA) Q 0
9 I DATA="" Q 0
10 I $L(DATA,HLFS)'>2 Q 0
11 Q 1
12 ;
13DODA(DATA) ;
14 ;INPUT DATA - The FM date of death.
15 ;
16 I '$D(DATA) Q 0
17 I DATA="" Q 1
18 N %DT,X,Y
19 S %DT="T",%DT(0)="-NOW",X=DATA
20 D ^%DT
21 Q $S(Y=-1:0,1:1)
22 ;
23DODB(DATA,ENCDT) ;
24 ;INPUT DATA - The FM date of death
25 ; ENCDT - The FM date of encounter
26 I '$D(DATA) Q 0
27 I DATA="" Q 1
28 N %DT,X,Y
29 S %DT="T",%DT(0)=ENCDT,X=DATA
30 D ^%DT
31 Q $S(Y=-1:0,1:1)
32 ;
33DODL(DATA,ENCDT) ;
34 ;INPUT DATA - The FM date of death
35 ; ENCDT - The FM date of the encounter
36 I '$D(DATA) Q 0
37 I '$D(ENCDT) Q 0
38 I DATA="" Q 1
39 I ENCDT<DATA Q 1
40 I ENCDT=DATA Q 1
41 N X1,X2,X
42 S X1=ENCDT,X2=DATA
43 D ^%DTC
44 I X>14 Q 0
45 Q 1
46 ;
47HOME(DATA) ;
48 ;INPUT DATA - THe homeless indicator to be validated.
49 ;
50 I '$D(DATA) Q 0
51 I DATA'=1,DATA'=0 Q 0
52 Q 1
53 ;
54POW(DATA) ;
55 ;INPUT DATA - The POW indicatort to be validated.
56 ;
57 I '$D(DATA) Q 0
58 I DATA="" Q 1
59 I DATA'="N",DATA'="U",DATA'="Y" Q 0
60 Q 1
61 ;
62TYPINS(DATA) ;
63 ;INPUT DATA - Type if insurance indicator to be validated.
64 ;
65 I '$D(DATA) Q 0
66 I DATA="" Q 1
67 I DATA?.A Q 0
68 I DATA>-1,(DATA<13) Q 1
69 Q 0
70 ;
71PATCLSS(DATA) ;
72 ;INPUT DATA - the patient's class
73 ;
74 I '$D(DATA) Q 0
75 I ("^O^I^")'[("^"_DATA_"^") Q 0
76 Q 1
77 ;
78POV(DATA) ;
79 ;
80 ;INPUT DATA - the purpose of visit.
81 ;SD*5.3*394 - Correction for addition POV.
82 ;
83 N VAR
84 I '$D(DATA) Q 0
85 I $L(DATA)'=4 Q 0
86 I DATA?.A Q 0
87 S VAR=$E(DATA,1,2)
88 I VAR<1!(VAR>4) Q 0
89 S VAR=$E(DATA,3,4)
90 I VAR<1!(VAR=10) Q 0
91 Q 1
92 ;
93COMPGEN(DATA) ;
94 ;INPUT DATA - checking computer generated.
95 ;
96 N VAR
97 S VAR=$E(DATA,3,4)
98 I VAR=10 Q 0
99 Q 1
100 ;
101LOCVIS(DATA) ;
102 ;INPUT DATA - Location of visit
103 ;
104 I DATA'=1,DATA'=6 Q 0
105 Q 1
106 ;
107FACNMBR(DATA) ;
108 ;INPUT DATA - The facility number
109 ;
110 I '$D(DATA) Q 0
111 I DATA'?3N.AN Q 0
112 I '$D(^DIC(4,"D",DATA)) Q 0
113 Q 1
114 ;
115FACACT(DATA,ENCDT,DIV) ;
116 ;INPUT DATA - The active flag of the facility number.
117 ;
118 I '$D(DATA) Q 0
119 I '$D(ENCDT) Q 0
120 I '$D(DIV) Q 0
121 I DATA="" Q 0
122 N SITE
123 I DIV]"" S SITE=$$SITE^VASITE(ENCDT,DIV)
124 I DIV']"" S SITE=$$SITE^VASITE(ENCDT)
125 I DATA'=$P(SITE,U,3) Q 0
126 Q 1
127 ;
128ENCDT(DATA,XMTFLG) ;
129 ;INPUT DATA - The date/time of the encounter
130 ; XMTFLG - Flag to check $$OKTOXMIT^SCDXFU04(DATA)
131 ;
132 I '$D(DATA) Q 0
133 S XMTFLG=$G(XMTFLG,0)
134 N %DT,X,Y
135 S %DT="T"
136 S X=DATA
137 D ^%DT
138 I Y=-1 Q 0
139 I XMTFLG Q 1
140 N VAR
141 S VAR=$$OKTOXMIT^SCDXFU04(DATA)
142 I +VAR<4&(VAR'<0) Q 1 ;SD*5.3*247
143 Q 0
144 ;
145UNIQNMBR(DATA) ;
146 ;INPUT DATA - The unique number from PCE for the encounter
147 ;
148 I '$D(DATA) Q 0
149 I DATA="" Q 0
150 I DATA=-1 Q 0
151 I DATA=0 Q 0
152 Q 1
153 ;
154SEGCHK(DATA,HLFS) ;
155 ;INPUT DATA - The segment to be checked.
156 ; HLFS - The HL7 field separator
157 ;
158 I '$D(DATA) Q 0
159 I DATA="" Q 0
160 I $L(DATA,HLFS)'>2 Q 0
161 Q 1
162 ;
163SEQNBR(DATA,SEQNBR) ;
164 ;INPUT DATA - The sequence number to be checked.
165 ; SEQNBR - This is the previous seq number to compare to
166 ;
167 I '$D(DATA) Q 0
168 I DATA="" Q 0
169 I +DATA'=+SEQNBR Q 0
170 S SEQNBR=SEQNBR+1
171 Q 1
172 ;
173DCODMTHD(DATA) ;
174 ;INPUT DATA - This is the coding method to be checked.
175 ;
176 I '$D(DATA) Q 0
177 I DATA'="I9" Q 0
178 Q 1
179 ;
180DIAGCOD(DATA,ENCDT) ;
181 ;INPUT DATA - This is the diagnosis code
182 ; ENCDT - This is the encounter date
183 ;
184 N VAR
185 I '$D(DATA) Q 0
186 I DATA="" Q 0
187 ;
188 Q $P($$ICDDX^ICDCODE(DATA,ENCDT),"^",10)
189 ;
190PRIOR(DATA) ;
191 ;INPUT DATA - The priority of the diagnosis found
192 ;
193 I '$D(DATA) Q 0
194 I DATA="" Q 1
195 I DATA=1 Q 1
196 Q 0
197 ;
198ELIGCODM(DATA) ;
199 ;INPUT DATA - The eligibility code
200 ;A CHECK FOR MISSING
201 I '$D(DATA) Q 0
202 I DATA="" Q 0
203 I '$D(^DIC(8.1,DATA,0)) Q 0
204 Q 1
205 ;
206ELIGINCV(DATA) ;
207 ;INPUT DATA - Contains the eligibility code in the first piece and
208 ;the veteran status in the second.
209 ;
210 ;the following quit is to stop this edit check.
211 ;Per Austin 9/97 this is not needed.
212 Q 1
213 N VET,ELIG
214 S VET=$P(DATA,U,2)
215 S ELIG=$P(DATA,U,1)
216 I VET=1&((ELIG<1)!(ELIG>18)) Q 0
217 I VET=1,ELIG>5,ELIG<15 Q 0
218 I VET=0,ELIG<6 Q 0
219 I VET=0,ELIG=11 Q 0
220 I VET=0,ELIG>14,ELIG'=19 Q 0
221 Q 1
222 ;
223ELIGINCS(DATA) ;
224 ;INPUT DATA - Eligibility code
225 ;
226 I '$D(DATA) Q 0
227 I DATA="" Q 0
228 I '$D(^DIC(8.1,DATA,0)) Q 0
229 I +$P(^DIC(8.1,DATA,0),U,7) Q 0
230 Q 1
231 ;
232VETSTAT(DATA) ;
233 ;INPUT DATA - The veteran status indicator
234 ;
235 I '$D(DATA) Q 0
236 I DATA'=0,DATA'=1 Q 0
237 Q 1
238 ;
239VETPOW(DATA,DFN) ;
240 ;INPUT DATA - veteran status to check with POW status.
241 ; DFN - The DFN of the patient.
242 ;
243 N VAR,POW
244 I DATA=0 Q 1
245 S VAR=$G(^DPT(DFN,.52))
246 S POW=$S(VAR]"":$P(VAR,U,5),1:VAR)
247 I POW="" Q 1
248 I POW="Y"!(POW="N")!(POW="U") Q 1
249 Q 0
250 ;
251NMBRDEP(DATA) ;
252 ;INPUT DATA - the number of dependents
253 ;
254 I '$D(DATA) Q 0
255 I DATA="" Q 0
256 I DATA="XX" Q 1
257 I DATA'?1.2N Q 0
258 I +DATA>99!(+DATA<0) Q 0
259 Q 1
260 ;
261PATINC(DATA) ;
262 ;INPUT DATA - The patient's income
263 ;
264 I '$D(DATA) Q 0
265 I DATA="" Q 0
266 I DATA<0 Q 0
267 I DATA'?.N.1".".N Q 0
268 Q 1
269 ;
270MEANSTST(DATA) ;
271 ;INPUT DATA - The means test indicator
272 ;
273 I '$D(DATA) Q 0
274 S DATA=","_DATA_","
275 ; ** SD*296, added 'U' means test indicator to allowed list.
276 I ",AS,AN,N,X,C,G,U,"'[DATA Q 0
277 Q 1
278 ;
279DEPMEANS(DATA) ;
280 ;INPUT DATA - This variable contains the number of dependents in the
281 ; first peice and the means test indicator in the second.
282 ;
283 N MT,DEP
284 I '$D(DATA) Q 0
285 S DEP=$P(DATA,U,1)
286 S MT=","_$P(DATA,U,2)_","
287 I DEP="XX",(",AS,N,X,U,"'[MT) Q 0
288 Q 1
289 ;
290CLASSQUE(DATA) ;
291 ;INPUT DATA - Classification question value.
292 ;
293 I '$D(DATA) Q 0
294 I DATA'=1,DATA'=0,DATA'="" Q 0
295 Q 1
296 ;
297CLAQUETY(DATA) ;
298 ;INPUT DATA - Outpatient classification type to be checked.
299 ;
300 I '$D(DATA) Q 0
301 I DATA="" Q 0
302 I '$D(^SD(409.41,DATA,0)) Q 0
303 Q 1
304 ;
305CLAVET(DATA,DFN,TYPE,ENCPTR) ; SD*5.3*341 added parameter ENCPTR
306 ;INPUT DATA - Classification question information to compare to VET
307 ; status
308 ; DFN - The patient to compare this info to.
309 ; TYPE - The classification type.
310 ; ENCPTR - Pointer to Outpatient Encounter
311 ;
312 I '$D(DATA) Q 0
313 I '$D(DFN) Q 0
314 I '$D(TYPE) Q 0 ; SD*5.3*341
315 N VET,SDELG0,SDDT ; SD*5.3*341
316 S ENCPTR=$G(ENCPTR) ; SD*5.3*341 added this plus next 3 lines
317 S SDDT=+$G(^SCE(ENCPTR,0)) S:'SDDT SDDT=$$DT^XLFDT()
318 S SDELG0=$$EL^SDCO22(DFN,ENCPTR)
319 S VET=$P(SDELG0,U,5)
320 I VET="Y",DATA'=1,DATA'=0,DATA'="" Q 0
321 ;This edit check is per a mail message from austin
322 I TYPE=4,VET'="Y",DATA'="","^A^B^C^D^"'[("^"_($P($G(^DIC(21,+$P($G(^DPT(DFN,.32)),"^",3),0)),"^",3))_"^") Q 0
323 I VET'="Y",DATA'="" Q $$SCR^SDCO21(TYPE,DFN,SDDT,ENCPTR) ; SD*5.3*341
324 Q 1
325 ;
326STPCOD(DATA) ;
327 ;INPUT DATA - stop code data to be checked
328 ;
329 I '$D(DATA) Q 0
330 I DATA="" Q 0
331 I '$D(^DIC(40.7,"C",DATA)) Q 0
332 Q 1
333 ;
334ACTSTP(DATA,ENCDT) ;
335 ;INPUT DATA - IEN of the stop code to be checked.
336 ; ENCDT - the encounter date in question
337 ;
338 N STPCOD,%DT,X,Y
339 I '$D(DATA) Q 0
340 I DATA="" Q 0
341 S STPCOD=$G(^DIC(40.7,DATA,0))
342 I STPCOD="" Q 0
343 I '$P(STPCOD,U,3) Q 1
344 S %DT(0)="-"_$P(STPCOD,U,3),%DT="T",X=ENCDT
345 D ^%DT
346 Q $S(Y=-1:0,1:1)
347 ;
348SERCON(DATA) ;
349 ;INPUT DATA - Service connection to be checked, missing or invalid
350 ;
351 I '$D(DATA) Q 0
352 I DATA="" Q 0
353 I DATA'=1,DATA'=0 Q 0
354 Q 1
355 ;
356SCPER(DATA) ;
357 ;INPUT DATA - Service connected % to be tested
358 ;
359 I '$D(DATA) Q 0
360 I DATA="" Q 1
361 I DATA'?.N.1".".N Q 0
362 Q 1
363 ;
364PRDSER(DATA) ;
365 ;INPUT DATA - period of service to be tested.
366 ;
367 I '$D(DATA) Q 0
368 I DATA="" Q 0
369 I '$D(^DIC(21,"D",DATA)) Q 0
370 Q 1
371 ;
372VIETSER1(DATA) ;
373 ;INPUT DATA - Vietnam service to be checked
374 ;
375 I '$D(DATA) Q 0
376 I DATA="" Q 1
377 I DATA'="Y",DATA'="N",DATA'="U" Q 0
378 Q 1
379 ;
380VIETSER2(DATA,DFN) ;
381 ;INPUT DATA - Vietnam service to be checked against vet status
382 ;
383 I '$D(DATA) Q 0
384 N VAR
385 S VAR=$G(^DPT(DFN,"VET"))
386 I DATA="",VAR'="Y" Q 1
387 I (DATA="Y"!(DATA="N")!(DATA="U")),VAR="Y" Q 1
388 Q 0
389 ;
390ACTPRD(DATA) ;
391 ;INPUT DATA - period of serivce indicator to be check to ensure active
392 ;
393 N VAR
394 I '$D(DATA) Q 0
395 I DATA="" Q 0
396 S VAR=+$O(^DIC(21,"D",DATA,0))
397 S VAR=$P($G(^DIC(21,VAR,0)),U,8)
398 I VAR Q 0
399 Q 1
400 ;
401PCODMTHD(DATA) ;
402 ;INPUT DATA - The coding method to be checked.
403 ;
404 I '$D(DATA) Q 0
405 I DATA'="C4" Q 0
406 Q 1
407 ;
408PROCCOD(DATA,ENCDT) ;
409 ;INPUT DATA - The procedure code to be checked.
410 ;This call makes the assumption that leading zeros are intact in the
411 ;input.
412 ;
413 N VAR
414 I '$D(DATA) Q 0
415 I DATA="" Q 0
416 I $$CPT^ICPTCOD(DATA,ENCDT,1)'>0 Q 0
417 Q 1
418 ;
419PROVCLS(DATA) ;
420 ;INPUT DATA - The practitioner class to be checked.
421 ;
422 N INACT S INACT=""
423 I '$D(DATA) Q 0
424 I DATA="" Q 0
425 I $$CODE2TXT^XUA4A72(DATA)']"" Q 0
426 S INACT=$P($$IEN2DATA^XUA4A72($$VCLK^XUA4A72(DATA)),U,5) ;SD*5.3*442
427 I INACT'="" I ENCDT>INACT Q 0 ;SD*5.3*442
428 Q 1
429 ;
430ERI(DATA) ;
431 ;INPUT DATA - The Emergency Response indicator to be validated.
432 ;
433 I '$D(DATA) Q 0
434 I DATA="" Q 1
435 I DATA'="K" Q 0
436 Q 1
437 ;
Note: See TracBrowser for help on using the repository browser.