source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCMSVUT3.m@ 1406

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

initial load of WorldVistAEHR

File size: 6.4 KB
RevLine 
[613]1SCMSVUT3 ;BP/JRP - HL7 segment & field validation utilities ;8/11/99 9:54am
2 ;;5.3;Scheduling;**142,180,208,239,395**;AUG 13, 1993
3 ;
4 ;Standard input parameters
5 ; DATA - Value to validate
6 ; DFN - Point to PATIENT file (#2)
7 ; ENCDT - Date/time of encounter (FileMan format)
8 ; HLFS - HL7 field seperator
9 ; HLECH - HL7 encoding characters
10 ; HLQ - HL7 null designation
11 ;
12 ;Standard output
13 ; 1 - Valid
14 ; 0 - Invalid
15 ;
16 ;
17POWLOC(DATA,DFN) ;Prisoner of war location
18 ;Note: Use of DFN is optional. Use of the DFN will validate the POW
19 ; location and also verify that it is consistant with patient's
20 ; POW status (i.e. must also have been a POW). Non-use of DFN
21 ; will only validate the POW location.
22 ;
23 Q:('$D(DATA)) 0
24 N POW,NODE
25 S DFN=+$G(DFN)
26 ;Patient a POW ?
27 S POW=1
28 I (DFN) D
29 .S NODE=$G(^DPT(DFN,.52))
30 .S POW=$TR($P(NODE,"^",5),"YNU","100")
31 ;Invalid location code
32 I (DATA'="")&("456789AB"'[DATA) Q 0
33 ;Location code not consistant with POW status
34 I (DATA) Q:('POW) 0
35 I (DATA="") Q:((DFN)&(POW)) 0
36 ;Valid location code
37 Q 1
38RADMTHD(DATA,DFN) ;Radiation exposure method
39 ;Note: Use of DFN is optional. Use of the DFN will validate the
40 ; radiation method and also verify that it is consistant with
41 ; patient's radiation exposure (i.e. must also have claimed
42 ; exposure). Non-use of DFN will only validate the radiation
43 ; method.
44 ;
45 Q:('$D(DATA)) 0
46 N RAD,NODE
47 S DFN=+$G(DFN)
48 ;Patient claim exposure ?
49 S RAD=1
50 I (DFN) D
51 .S NODE=$G(^DPT(DFN,.321))
52 .S RAD=$TR($P(NODE,"^",3),"YNU","100")
53 ;Invalid method code
54 I (DATA'="") Q:((DATA'?1N)!(DATA<2)!(DATA>4)) 0
55 ;Method code not consistant with exposure status
56 I (DATA) Q:('RAD) 0
57 I (DATA="") Q:((DFN)&(RAD)) 0
58 ;Valid method code
59 Q 1
60NUMRANK(DATA,MINVAL,MAXVAL,DECCNT) ;Numeric ranking validation
61 ;Input : MINVAL - Minimum value (defaults to no lower limit)
62 ; MAXVAL - Maximum value (defaults to no upper limit)
63 ; DECCNT - Decimal places allowed (defaults to no limit)
64 ;Note : DATA considered invalid if NULL
65 Q:('$D(DATA)) 0
66 Q:(DATA="") 0
67 Q:(DATA=".") 0
68 N INVALID
69 S INVALID=0
70 ;General numeric check
71 Q:(DATA'?.1"-".N.1".".N) 0
72 ;Min value check
73 I ($G(MINVAL)'="") D
74 .S INVALID=(DATA<MINVAL)
75 Q:(INVALID) 0
76 ;Max value check
77 I ($G(MAXVAL)'="") D
78 .S INVALID=(DATA>MAXVAL)
79 Q:(INVALID) 0
80 ;Decimal check
81 I ($G(DECCNT)'="") D
82 .X "S INVALID=DATA'?.1""-"".N.1"".""."_DECCNT_"N"
83 Q:(INVALID) 0
84 ;Valid
85 Q 1
86VALFAC(DATA) ;Determine if given facility number is valid
87 Q:('$D(DATA)) 0
88 Q:(DATA="") 0
89 ;Invalid
90 Q:('$D(^DIC(4,"D",DATA))) 0
91 ;Valid
92 Q 1
93ACTFAC(DATA) ;Determine if given facility number is active
94 Q:('$D(DATA)) 0
95 Q:(DATA="") 0
96 N PTR4,ACTIVE,NODE
97 ;Check all entries in INSTITUTION file (#4) with given facility number
98 ; (quits when first active entry is found)
99 S ACTIVE=0
100 S PTR4=0
101 F S PTR4=+$O(^DIC(4,"D",DATA,PTR4)) Q:('PTR4) D Q:(ACTIVE)
102 .;Get node with inactive flag
103 .S NODE=$G(^DIC(4,PTR4,99))
104 .;Inactive
105 .Q:($P(NODE,"^",4)="y")
106 .;Active
107 .S ACTIVE=1
108 ;Done
109 Q ACTIVE
110PROVID(DATA,HLECH) ;External Provider ID
111 Q:('$D(DATA)) 0
112 Q:(DATA="") 0
113 N PRVDUZ,PRVFAC,SUBSEP,VALID
114 S SUBSEP=$E(HLECH,4)
115 S PRVDUZ=$P(DATA,SUBSEP,1)
116 S PRVFAC=$P(DATA,SUBSEP,2)
117 S VALID=0
118 I $$NUMRANK(PRVDUZ,1,,0),$$VALFAC(PRVFAC),$$ACTFAC(PRVFAC) S VALID=1
119 Q VALID
120ROLEID(DATA) ;Role Instance ID
121 Q:('$D(DATA)) 0
122 Q:(DATA="") 0
123 N ROLEID,SEQID,VALID
124 S ROLEID=$P(DATA,"*",1)
125 S SEQID=$P(DATA,"*",2)
126 S VALID=0
127 I ROLEID'="" I $$NUMRANK(SEQID,1,,0) S VALID=1
128 Q VALID
129VA01(DATA) ;VA Table 1 (Yes/No/Unknown)
130 ;Notes: Table VA01 allows values of Y,N,U,1,0
131 ; : NULL is an accepted value
132 Q:('$D(DATA)) 0
133 Q:(DATA="") 1
134 Q:($L(DATA)'=1) 0
135 N TMP
136 S TMP=$TR(DATA,"YNU0","1111")
137 Q:(TMP'=1) 0
138 Q 1
139CLAMST(VALUE,DFN) ;
140 ;Error code 9030
141 ;Validating whether or not the visit is related to MST
142 ;
143 ;INPUT
144 ; ENCDT - Date of encounter
145 ; DFN - IEN pointer from the Outpatient Encounter (#409.68) file
146 ; VALUE - Is encounter related (1=Yes,0=No)
147 ;
148 ;OUTPUT
149 ; 1 = Visit is related to MST
150 ; 0 = Visit Not related to MST
151 ;
152 ;
153 N MSTSTAT
154 I '$D(VALUE) Q 0
155 S MSTSTAT=$$GETSTAT^DGMSTAPI(DFN)
156 S MSTSTAT=$P(MSTSTAT,"^",2)
157 S MSTSTAT=$S(MSTSTAT="Y":1,1:0)
158 Q $S(MSTSTAT=0&(VALUE=1):0,1:1)
159MSTSTAT(DATA) ;
160 ;Error code 7040
161 ;Check for valid MST status codes Y,N,D,U
162 ;
163 ;INPUT
164 ; DATA - the MST Status passed in by routine SCMSVZEL
165 ;
166 ;OUTPUT
167 ; 1 - Valid MST Status
168 ; 0 - Invalid MST Status
169 ;
170 I '$D(DATA) Q 0
171 I ("Y,N,U,D"[DATA)!(DATA="") Q 1
172 Q 0
173MSTDATE(DATA) ;
174 ;Error code 7060
175 ;Check for valid date and that MST status is either Y,N,D or U
176 ; Variable X must be passed to ^%DT for date verification
177 ; Variable Y is returned from ^%DT
178 ;
179 ;INPUT
180 ; DATA - MST Date Status Changed^MST Status from SCMSVZEL
181 ;
182 ;OUTPUT
183 ; 1 - Valid MST Status and date in a valid format
184 ; 0 - Invalid MST Status or date in an invalid format
185 ;
186 N X,MSTSTAT
187 S X=$P(DATA,"^",2)
188 S MSTSTAT=$P(DATA,"^",1)
189 I X=""&("Y,N,D"'[MSTSTAT!(MSTSTAT="")) Q 1
190 S X=$$FMDATE^HLFNC(X),%DT="T"
191 D ^%DT
192 Q $S(Y>0&("U,Y,N,D"[MSTSTAT):1,1:0)
193 ;
194AO(DATA,DFN) ;Validate Agent Orange expos. (error 7120)
195 ;INPUT : DATA - Value to validate
196 ; DFN - Pointer to PATIENT file (#2)
197 ;OUTPUT : 1 - Valid claim of exposure to Agent Orange
198 ; 0 - Invalid claim of exposure to Agent Orange
199 I '$D(DATA) Q 0
200 I '$D(DFN) Q 0
201 I DATA=1 Q 1 ;$$CANBEAO(DFN) SD*5.3*395 rem check for period of service
202 I (DATA=0)!(DATA="") Q 1
203 Q 0
204CANBEAO(DFN) ;Check to determine if patient can claim Agent Orange expos.
205 ;INPUT : DFN - Pointer to PATIENT file (#2)
206 ;OUTPUT : 1 - Valid claim of exposure to Agent Orange
207 ; 0 - Invalid claim of exposure to Agent Orange
208 ;
209 N VAEL
210 I '$G(DFN) Q 0
211 I '$D(^DPT(DFN,0)) Q 0
212 ;Get data needed to perform check
213 D ELIG^VADPT
214 ;Must be a veteran
215 I 'VAEL(4) Q 0
216 ;Must have POS 7
217 I $P($G(^DIC(21,+VAEL(2),0)),"^",3)=7 Q 1
218 ;Can't claim AO
219 Q 0
220AOLOC(DATA,DFN) ;Validate Agent Orange exposure location (error 7130)
221 ;INPUT : DATA - Value to validate
222 ; DFN - Pointer to PATIENT file (#2)
223 ;OUTPUT : 1 - Valid Agent Orange exposure location
224 ; 0 - Invalid/missing Agent Orange exposure location
225 ;NOTES : Patient's claiming exposure must have an exposure location
226 N VASV
227 I '$G(DFN) Q 0
228 I '$D(^DPT(DFN,0)) Q 0
229 I '$D(DATA) Q 0
230 ;Get data needed to perform check
231 D SVC^VADPT
232 ;No claim - shouldn't have a location
233 I 'VASV(2) Q $S(DATA="":1,1:0)
234 ;Claims exposure - must have a valid location
235 Q $S(DATA="":0,"VK"[DATA:1,1:0)
Note: See TracBrowser for help on using the repository browser.