source: WorldVistAEHR/trunk/r/AUTOMATED_INFO_COLLECTION_SYS-IBD/IBDECLN.m@ 862

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

initial load of WorldVistAEHR

File size: 9.2 KB
Line 
1IBDECLN ;ALB/AAS - Clean up Data Qualifiers and Package interfaces ; 23-JUN-97
2 ;;3.0;AUTOMATED INFO COLLECTION SYS;**14,36**;APR 24, 1997
3 ;
4UPDATE(TALK) ; -- update both qualifiers and package interface file
5 ; -- do the qualifiers first to rename bad ones
6 ;
7 ; -- input Talk, 1=send messages through mes^xpdutl (default is 1)
8 ; 0=no messages
9 ;
10 S:$G(TALK)="" TALK=1
11 S TALK=$TR(TALK,"yesnomaybe","YESNOMAYBE")
12 S:$G(TALK)="YES" TALK=1
13 S TALK=+$G(TALK)
14 D CLNQLF(TALK),CLNPI(TALK)
15 D CLNSEL^IBDECLN1(TALK)
16 Q
17 ;
18CLNPI(TALK) ;
19 ; -- update/delete Allowable Qualifiers in Package Interface file
20 N I,J,K,L,X,Y,CNT,CNT1,CNT2,CNT3,CNT4,ENTRY,PI,QLF,NODE,FILE
21 N IEN,PROBLEM,QLFNODE,DATA,QLFNUM,NNODE,ONODE,NLEN,TOT
22 K ^TMP($J,"IBDE CLN")
23 S (CNT,CNT1,CNT2,CNT3,CNT4)=0
24 ;
25 S (X(1),X(3))=" "
26 S X(2)=">>> Now checking the PACKAGE INTERFACE file for inappropriate data qualifiers."
27 D:TALK MES^XPDUTL(.X)
28 ;
29 ; -- build array of input package interfaces and qualifiers
30 ; sent out with version 3.0
31 S I=0
32 F I=1:1 S ENTRY=$P($T(OUTPUT+I^IBDECLN2),";;",2) Q:ENTRY="" D
33 . I $E(ENTRY)="~" Q
34 . I $E(ENTRY)'="+" D Q
35 .. S PI=$E($P(ENTRY,":",1),1,30)
36 .. S DATA=$P(ENTRY,":",2)
37 .. S ^TMP($J,"IBDE CLN",PI,12)=DATA
38 . I $E(ENTRY)="+" D Q
39 .. S QLF=$E($P(ENTRY,":",1),2,99)
40 .. S QLFNUM=+$O(^IBD(357.98,"B",$E(QLF,1,30),0))
41 .. Q:QLFNUM=0
42 .. S DATA=QLFNUM_$P(ENTRY,":",2)
43 .. S ^TMP($J,"IBDE CLN",PI,"QLF",QLF)=DATA
44 ;
45 ; -- now go through the supported list of Package Interface entries
46 ; and make sure that the main PCE DIM data is correct (node 12)
47 ;
48 S PI=""
49 F S PI=$O(^TMP($J,"IBDE CLN",PI)) Q:PI="" D
50 . S (J,K)=0
51 . F S J=$O(^IBE(357.6,"B",PI,J)) Q:'J D
52 .. S NNODE=$G(^TMP($J,"IBDE CLN",PI,12))
53 .. Q:NNODE=""
54 .. S ONODE=$G(^IBE(357.6,J,12))
55 .. S NLEN=$L(NNODE)
56 .. I $E(ONODE,1,NLEN)'=NNODE D DEL(TALK,PI,J,K,20,NNODE,ONODE)
57 ;
58 ; -- now go through the qualifiers for the package interface
59 ; and make sure that only supported qualifiers are listed,
60 ; no duplicates, and that the data is correct.
61 ;
62 S PI=""
63 S (CNT1,CNT3)=0
64 F S PI=$O(^TMP($J,"IBDE CLN",PI)) Q:PI="" D
65 . S (J,K)=0
66 . F S J=$O(^IBE(357.6,"B",PI,J)) Q:'J D
67 .. N CNT1,ONODE,NNODE,PIQLF
68 .. S K=0
69 .. F S K=$O(^IBE(357.6,J,13,K)) Q:K="" D
70 ... ;
71 ... S ONODE=$G(^IBE(357.6,J,13,K,0)) Q:ONODE=""
72 ... S FILE=$P($P(ONODE,"^",1),";",2)
73 ... Q:FILE'="IBD(357.98,"
74 ... S IEN=+ONODE
75 ... S QLF=$P($G(^IBD(357.98,IEN,0),"UNKNOWN"),"^",1)
76 ... S PIQLF(QLF)=""
77 ... ;
78 ... ; -- now if there is a duplicate, delete the duplicate
79 ... S NNODE=$G(^TMP($J,"IBDE CLN",PI,"QLF",QLF))
80 ... I NNODE="" D DEL(TALK,PI,J,K,1) Q
81 ... S CNT1(PI,QLF)=$G(CNT1(PI,QLF))+1
82 ... I CNT1(PI,QLF)>1 D DEL(TALK,PI,J,K,2) Q
83 ... ;
84 ... S NLEN=$L(NNODE)
85 ... I $E(ONODE,1,NLEN)'=NNODE D DEL(TALK,PI,J,K,21,NNODE,ONODE)
86 .. ; --check to see if all allowable qualifiers exist if not, add
87 .. S QLF="" F S QLF=$O(^TMP($J,"IBDE CLN",PI,"QLF",QLF)) Q:QLF']"" D
88 ... N FILE,DATA,IBDFDA,QLFNODE,NIEN,ERROR
89 ... Q:$D(PIQLF(QLF))
90 ... S FILE=357.613,IBDFDA(1)=J
91 ... S QLFNODE=$G(^TMP($J,"IBDE CLN",PI,"QLF",QLF))
92 ... S DATA(.01)=$P(QLFNODE,"^")
93 ... Q:DATA(.01)=""
94 ... S NIEN=$$ADD^IBDFDBS(FILE,.IBDFDA,.DATA,.ERROR)
95 ... D:+NIEN>0 DEL(TALK,PI,J,NIEN,22,QLFNODE)
96 ;
97 G:'TALK END
98 ;
99 ; -- Find out if Problem is in PCE DIM NODE in 357.6
100 ; if so, then user is warned to contact customer service
101 ; to be manually corrected
102 D PROBLEM^IBDECLN1(.PROBLEM)
103 I PROBLEM>0 D
104 . S X(1)=" ",X(2)=" >> WARNING: The following interfaces use the PROBLEM node to transmit data"
105 . D:TALK MES^XPDUTL(.X)
106 . S I=0 ;skip the zero node, contains PI stuff
107 . F S I=$O(PROBLEM(I)) Q:I="" D:TALK MES^XPDUTL(" Package Interface "_PROBLEM(I))
108 . D:TALK MES^XPDUTL(" Contact Customer Support for assistance updating the package interface file.")
109 ;
110 ;
111SUM ; -- summary of package interface file check
112 K X
113 S TOT=2
114 S X(1)=" "
115 S X(2)=" >> Summary of the Package Interface Check:"
116 ;
117 I CNT<1,CNT2<1,CNT3<1,CNT4<1 D
118 . S TOT=TOT+1,X(TOT)=" No required changes were found."
119 ;
120 I CNT>0 D
121 . S TOT=TOT+1
122 . S X(TOT)=" A total of "_CNT_" qualifier"_$S(CNT=1:" was",1:"s were")_" removed from Package Interface Entries."
123 ;
124 ;
125 I CNT2>0 D
126 . S TOT=TOT+1
127 . S X(TOT)=" The PCE DIM data fields for "_CNT2_" Package Interface"_$S(CNT2=1:" was",1:"s were")_" updated."
128 ;
129 I CNT3>0 D
130 . S TOT=TOT+1
131 . S X(TOT)=" The PCE DIM data fields for "_CNT3_" Allowable Qualifier"_$S(CNT3=1:" was",1:"s were")_" updated."
132 ;
133 I CNT4>0 D
134 . S TOT=TOT+1
135 . S X(TOT)=" A total of "_CNT4_" Allowable Qualifier"_$S(CNT4=1:" was",1:"s were")_" added."
136 I PROBLEM>0 D
137 . S TOT=TOT+1,X(TOT)=" Contact Customer Support for assistance updating the package interface file."
138 ;
139 D:TALK MES^XPDUTL(.X)
140 ;
141END K ^TMP($J,"IBDE CLN")
142 Q
143 ;
144DEL(TALK,PI,J,K,REASON,NNODE,ONODE) ; -- delete inappropriate entries
145 ;
146 ; reasons for deletion or warnings
147 ; 1- invalid qualifier
148 ; 2- duplicate qualifier
149 ; 9- bad qualifier, not deleted, user warned
150 ; 20-node ^IBE(357.6,IEN,12) not correct
151 ; 21-node ^IBE(357.6,IEN,13,allow qual,0) not correct
152 ;
153 N I,X,Y,DA,DIC,DIK
154 I (REASON=1!(REASON=2)) S CNT=CNT+1
155 S CNT(PI)=+$G(CNT(PI))+1
156 I CNT(PI)=1 D
157 . S X(1)=" ",X(2)=" The Package Interface "_PI_" had: "
158 . D:TALK MES^XPDUTL(.X) N X
159 D:(TALK&(REASON=1)) MES^XPDUTL(" an invalid qualifier of "_QLF_" deleted.")
160 D:(TALK&(REASON=2)) MES^XPDUTL(" a duplicate qualifier of "_QLF_" deleted.")
161 I TALK&(REASON=9) D MES^XPDUTL(" a bad qualifier of "_QLF_" not deleted, PCE DIM NODE='PROBLEM'") Q ;don't delete, save for manual update
162 ;
163 I REASON<10 S DA=K,DA(1)=J,DIK="^IBE(357.6,"_DA(1)_",13," D ^DIK Q
164 ;
165 I TALK&(REASON=20) D
166 . N X
167 . S X(1)=" The PCE Device Interface Data Updated."
168 . S X(2)=" Old Data: "_ONODE
169 . S X(3)=" New Data: "_NNODE
170 . D:TALK MES^XPDUTL(.X)
171 . S CNT2=CNT2+1
172 . S ^IBE(357.6,J,12)=NNODE
173 ;
174 I TALK&(REASON=21) D
175 . N X
176 . S X(1)=" The PCE Device Interface Data for the Data Qualifier "_QLF_" was updated."
177 . S X(2)=" Old Data: "_ONODE
178 . S X(3)=" New Data: "_NNODE
179 . D:TALK MES^XPDUTL(.X)
180 . S CNT3=CNT3+1
181 . S ^IBE(357.6,J,13,K,0)=NNODE
182 ;
183 I TALK&(REASON=22) D
184 . S CNT4=CNT4+1
185 . D MES^XPDUTL(" "_QLF_" was added.")
186 . S ^IBE(357.6,J,13,K,0)=NNODE
187 Q
188 ;
189CLNQLF(TALK) ;
190 ; -- update codes in AICS DATA QUALIFIERS file (357.98)
191 ; according to version 3.0
192 N I,J,K,L,X,Y,CNT,CNT1,CNT2,CNT3,ENTRY,NAME,CODE,NEWNAME,IBQUIT,DIC,DIE,DIK,DA,DR
193 S (CNT,CNT1)=0,CNT2=1
194 ;
195 S (X(1),X(3))=" "
196 S X(2)=">>> Now checking the AICS DATA QUALIFIERS file for inappropriate entries."
197 D:TALK MES^XPDUTL(.X)
198 ;
199 ; -- Go through AICS Data Qualifiers and set up correctly
200 F I=1:1:28 S ENTRY=$P($T(DATA+I),";;",2) Q:ENTRY="" D
201 . S CNT=CNT+1
202 . S NAME=$P(ENTRY,"^",1)
203 . S CODE=$P(ENTRY,"^",2)
204 . S J=""
205 . F S J=$O(^IBD(357.98,"B",NAME,J)) Q:J="" D
206 .. I $P($G(^IBD(357.98,J,0)),"^",2)=CODE Q
207 .. ;
208 .. ; -- don't change Active=1 and Inactive=0 if Problem
209 .. I $P($G(^IBE(357.6,J,12)),"^",1)="PROBLEM",NAME="ACTIVE"!(NAME="INACTIVE") D Q:IBQUIT
210 ... S IBQUIT=0
211 ... I NAME="ACTIVE",($P($G(^IBD(357.98,J,0)),"^",2)=1) D
212 ....S IBQUIT=1
213 ....D MES^XPDUTL(" The qualifier ACTIVE with a code of 1 needs to be changed but is used.")
214 ... I NAME="INACTIVE",($P($G(^IBD(357.98,J,0)),"^",2)=0) D
215 ....S IBQUIT=1
216 ....D MES^XPDUTL(" The qualifier of INACTIVE with a code of 0 needs to be changed but is used.")
217 ..
218 .. ; -- keep track of what was changed
219 .. S CNT(NAME)=$G(CNT(NAME))+1
220 .. S CNT1=CNT1+1,CNT2=CNT2+1
221 .. S CNT3(CNT2)=" The Entry "_$G(^IBD(357.98,J,0))_" changed to ZZBAD-"_ENTRY
222 .. ;
223 .. ; -- see if it's used
224 .. S K=0 F S K=$O(^IBE(357.6,K)) Q:'K I $D(^IBE(357.6,K,13)) D
225 ... S L=0 F S L=$O(^IBE(357.6,K,13,L)) Q:'L I $P($G(^IBE(357.6,K,13,L,0)),"^",1)=(J_";IBD(357.98,") D
226 .... S CNT2=CNT2+1
227 .... S CNT3(CNT2)=" and was used by Package File entry "_$P($G(^IBE(357.6,K,0)),"^",1)
228 .. ;
229 .. ; -- finally, make the change
230 .. S NEWNAME=$E("ZZBAD-"_$P(^IBD(357.98,J,0),"^",1),1,30)
231 .. S DIE="^IBD(357.98,",DA=J,DR=".01////^S X=NEWNAME;.02////^S X=CODE"
232 .. N I,J,K,L,X,Y D ^DIE K DIE,DA,DR
233 ;
234 ;
235 ; -- reindex the file
236 S DIK="^IBD(357.98,"
237 D IXALL^DIK
238 ;
239 ; summary of the aics data qualifiers check
240 ;
241 K X
242 S X(1)=" ",X(2)=" >> Summary of the AICS Data Qualifiers Check:"
243 D:TALK MES^XPDUTL(.X)
244 K X
245 I $G(CNT1)>0 M X=CNT3 S X(1)=" The number of changes made was "_CNT1
246 I CNT1=0 S X(1)=" No required changes were found.",X(2)=" "
247 I CNT1>1 S (X(CNT2+1),X(CNT2+3))=" ",X(CNT2+2)=" >> Done updating the AICS DATA QUALIFIERS file"
248 D:TALK MES^XPDUTL(.X)
249 Q
250 ;
251DATA ;;
252 ;;NONE APPLICABLE^
253 ;;PRIMARY^P^P
254 ;;SECONDARY^S^S
255 ;;ACTIVE^A^A
256 ;;INACTIVE^I^I
257 ;;HISTORICAL^H
258 ;;ADD TO PROBLEM LIST^1^ADD
259 ;;SERVICE CONNECTED^1^SC
260 ;;AGENT ORANGE RELATED^1^AO
261 ;;IONIZING RADIATION RELATED^1^IR
262 ;;ENVIRONMENTAL CONTAMINANTS RELATED^1^EC
263 ;;MILITARY SEXUAL TRAUMA^1^MST
264 ;;ABNORMAL RESULT^A^ABNORM
265 ;;NORMAL RESULT^N^NORM
266 ;;POOR UNDERSTANDING^1^POOR
267 ;;FAIR UNDERSTANDING^2^FAIR
268 ;;GOOD UNDERSTANDING^3^GOOD
269 ;;UNDERSTANDING NOT ASSESSED^4^N/A
270 ;;PATIENT ED REFUSED^5^REFUSED
271 ;;MINIMAL SEVERITY^M^MINIMAL
272 ;;MODERATE SEVERITY^MO^MODERATE
273 ;;HEAVY SEVERITY^H^SEVERE
274 ;;YES^1^YES
275 ;;NO^0^NO
276 ;;CONTRAINDICATED^1^CONTRA.
277 ;;GIVEN^0^GIV
278 ;;REFUSED^1^REFUSED
279 ;;NON-SERVICE CONNECTED^0^NSC
280 ;;NO CLASSIFICATIONS^1^NO CLASSIF
281 ;;
Note: See TracBrowser for help on using the repository browser.