source: smart/trunk/p/C0SPROB.m@ 1540

Last change on this file since 1540 was 1540, checked in by Sam Habiel, 12 years ago

Updated routines per the KIDS build

File size: 16.4 KB
Line 
1C0SPROB ; GPL - Smart Problem Processing ;5/01/12 17:05
2 ;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 2
3 ;Copyright 2012 George Lilly. Licensed under the terms of the GNU
4 ;General Public License See attached copy of the License.
5 ;
6 ;This program is free software; you can redistribute it and/or modify
7 ;it under the terms of the GNU General Public License as published by
8 ;the Free Software Foundation; either version 2 of the License, or
9 ;(at your option) any later version.
10 ;
11 ;This program is distributed in the hope that it will be useful,
12 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;GNU General Public License for more details.
15 ;
16 ;You should have received a copy of the GNU General Public License along
17 ;with this program; if not, write to the Free Software Foundation, Inc.,
18 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ;
20 Q
21 ;
22 ; sample VistA NHIN problem list
23 ;
24 ;^TMP("C0STBL",91,"problem",1,"acuity@value")="C"
25 ;^TMP("C0STBL",91,"problem",1,"entered@value")=3110531
26 ;^TMP("C0STBL",91,"problem",1,"facility@code")=100
27 ;^TMP("C0STBL",91,"problem",1,"facility@name")="VOE OFFICE INSTITUTION"
28 ;^TMP("C0STBL",91,"problem",1,"icd@value")=414.9
29 ;^TMP("C0STBL",91,"problem",1,"id@value")=100
30 ;^TMP("C0STBL",91,"problem",1,"location@value")="DR OFFICE"
31 ;^TMP("C0STBL",91,"problem",1,"name@value")="Coronary Artery Disease"
32 ;^TMP("C0STBL",91,"problem",1,"onset@value")=3100201
33 ;^TMP("C0STBL",91,"problem",1,"provider@code")=63
34 ;^TMP("C0STBL",91,"problem",1,"provider@name")="KING,MATTHEW MICHAEL"
35 ;^TMP("C0STBL",91,"problem",1,"removed@value")=0
36 ;^TMP("C0STBL",91,"problem",1,"sc@value")=0
37 ;^TMP("C0STBL",91,"problem",1,"status@value")="A"
38 ;^TMP("C0STBL",91,"problem",1,"unverified@value")=0
39 ;^TMP("C0STBL",91,"problem",1,"updated@value")=3110531
40 ;^TMP("C0STBL",91,"problem",2,"acuity@value")="C"
41 ;^TMP("C0STBL",91,"problem",2,"entered@value")=3110602
42 ;^TMP("C0STBL",91,"problem",2,"facility@code")=100
43 ;^TMP("C0STBL",91,"problem",2,"facility@name")="VOE OFFICE INSTITUTION"
44 ;^TMP("C0STBL",91,"problem",2,"icd@value")=780.2
45 ;^TMP("C0STBL",91,"problem",2,"id@value")=108
46 ;^TMP("C0STBL",91,"problem",2,"name@value")="Syncope and collapse"
47 ;^TMP("C0STBL",91,"problem",2,"onset@value")=3110102
48 ;^TMP("C0STBL",91,"problem",2,"provider@code")=63
49 ;^TMP("C0STBL",91,"problem",2,"provider@name")="KING,MATTHEW MICHAEL"
50 ;^TMP("C0STBL",91,"problem",2,"removed@value")=0
51 ;^TMP("C0STBL",91,"problem",2,"sc@value")=0
52 ;^TMP("C0STBL",91,"problem",2,"status@value")="A"
53 ;^TMP("C0STBL",91,"problem",2,"unverified@value")=0
54 ;^TMP("C0STBL",91,"problem",2,"updated@value")=3110602
55 ;^TMP("C0STBL",91,"problem",3,"acuity@value")="C"
56 ;^TMP("C0STBL",91,"problem",3,"entered@value")=3110602
57 ;^TMP("C0STBL",91,"problem",3,"facility@code")=100
58 ;^TMP("C0STBL",91,"problem",3,"facility@name")="VOE OFFICE INSTITUTION"
59 ;^TMP("C0STBL",91,"problem",3,"icd@value")=433.91
60 ;^TMP("C0STBL",91,"problem",3,"id@value")=109
61 ;^TMP("C0STBL",91,"problem",3,"name@value")="Occlusion and Stenosis of Unspecifid Precerebral Artery with Cerebral Infarctio"
62 ;^TMP("C0STBL",91,"problem",3,"onset@value")=3100101
63 ;^TMP("C0STBL",91,"problem",3,"provider@code")=63
64 ;^TMP("C0STBL",91,"problem",3,"provider@name")="KING,MATTHEW MICHAEL"
65 ;^TMP("C0STBL",91,"problem",3,"removed@value")=0
66 ;^TMP("C0STBL",91,"problem",3,"sc@value")=0
67 ;^TMP("C0STBL",91,"problem",3,"status@value")="A"
68 ;^TMP("C0STBL",91,"problem",3,"unverified@value")=0
69 ;^TMP("C0STBL",91,"problem",3,"updated@value")=3110602
70 ;^TMP("C0STBL",91,"problem",4,"entered@value")=3110603
71 ;^TMP("C0STBL",91,"problem",4,"facility@code")=100
72 ;^TMP("C0STBL",91,"problem",4,"facility@name")="VOE OFFICE INSTITUTION"
73 ;^TMP("C0STBL",91,"problem",4,"icd@value")="00.66"
74 ;^TMP("C0STBL",91,"problem",4,"id@value")=115
75 ;^TMP("C0STBL",91,"problem",4,"location@value")="DR OFFICE"
76 ;^TMP("C0STBL",91,"problem",4,"name@value")="00.66"
77 ;^TMP("C0STBL",91,"problem",4,"provider@code")=63
78 ;^TMP("C0STBL",91,"problem",4,"provider@name")="KING,MATTHEW MICHAEL"
79 ;^TMP("C0STBL",91,"problem",4,"removed@value")=0
80 ;^TMP("C0STBL",91,"problem",4,"status@value")="A"
81 ;^TMP("C0STBL",91,"problem",4,"unverified@value")=0
82 ;^TMP("C0STBL",91,"problem",4,"updated@value")=3110603
83 ;^TMP("C0STBL",91,"problem",5,"entered@value")=3110603
84 ;^TMP("C0STBL",91,"problem",5,"facility@code")=100
85 ;^TMP("C0STBL",91,"problem",5,"facility@name")="VOE OFFICE INSTITUTION"
86 ;^TMP("C0STBL",91,"problem",5,"icd@value")=37.21
87 ;^TMP("C0STBL",91,"problem",5,"id@value")=116
88 ;^TMP("C0STBL",91,"problem",5,"location@value")="DR OFFICE"
89 ;^TMP("C0STBL",91,"problem",5,"name@value")=37.21
90 ;^TMP("C0STBL",91,"problem",5,"provider@code")=63
91 ;^TMP("C0STBL",91,"problem",5,"provider@name")="KING,MATTHEW MICHAEL"
92 ;^TMP("C0STBL",91,"problem",5,"removed@value")=0
93 ;^TMP("C0STBL",91,"problem",5,"status@value")="A"
94 ;^TMP("C0STBL",91,"problem",5,"unverified@value")=0
95 ;^TMP("C0STBL",91,"problem",5,"updated@value")=3110603
96 ;^TMP("C0STBL",91,"problem",6,"entered@value")=3110603
97 ;^TMP("C0STBL",91,"problem",6,"facility@code")=100
98 ;^TMP("C0STBL",91,"problem",6,"facility@name")="VOE OFFICE INSTITUTION"
99 ;^TMP("C0STBL",91,"problem",6,"icd@value")=81.51
100 ;^TMP("C0STBL",91,"problem",6,"id@value")=117
101 ;^TMP("C0STBL",91,"problem",6,"location@value")="DR OFFICE"
102 ;^TMP("C0STBL",91,"problem",6,"name@value")=81.51
103 ;^TMP("C0STBL",91,"problem",6,"provider@code")=63
104 ;^TMP("C0STBL",91,"problem",6,"provider@name")="KING,MATTHEW MICHAEL"
105 ;^TMP("C0STBL",91,"problem",6,"removed@value")=0
106 ;^TMP("C0STBL",91,"problem",6,"status@value")="A"
107 ;^TMP("C0STBL",91,"problem",6,"unverified@value")=0
108 ;^TMP("C0STBL",91,"problem",6,"updated@value")=3110603
109 ;^TMP("C0STBL",91,"problem",7,"entered@value")=3110603
110 ;^TMP("C0STBL",91,"problem",7,"facility@code")=100
111 ;^TMP("C0STBL",91,"problem",7,"facility@name")="VOE OFFICE INSTITUTION"
112 ;^TMP("C0STBL",91,"problem",7,"icd@value")=47.09
113 ;^TMP("C0STBL",91,"problem",7,"id@value")=118
114 ;^TMP("C0STBL",91,"problem",7,"location@value")="DR OFFICE"
115 ;^TMP("C0STBL",91,"problem",7,"name@value")=47.09
116 ;^TMP("C0STBL",91,"problem",7,"provider@code")=63
117 ;^TMP("C0STBL",91,"problem",7,"provider@name")="KING,MATTHEW MICHAEL"
118 ;^TMP("C0STBL",91,"problem",7,"removed@value")=0
119 ;^TMP("C0STBL",91,"problem",7,"status@value")="A"
120 ;^TMP("C0STBL",91,"problem",7,"unverified@value")=0
121 ;^TMP("C0STBL",91,"problem",7,"updated@value")=3110603
122 ;^TMP("C0STBL",91,"problem",8,"entered@value")=3110603
123 ;^TMP("C0STBL",91,"problem",8,"facility@code")=100
124 ;^TMP("C0STBL",91,"problem",8,"facility@name")="VOE OFFICE INSTITUTION"
125 ;^TMP("C0STBL",91,"problem",8,"icd@value")="250.00"
126 ;^TMP("C0STBL",91,"problem",8,"id@value")=119
127 ;^TMP("C0STBL",91,"problem",8,"location@value")="DR OFFICE"
128 ;^TMP("C0STBL",91,"problem",8,"name@value")="Diabetes Mellitus without mentionof Complication, type II or unspecified type,"
129 ;^TMP("C0STBL",91,"problem",8,"provider@code")=63
130 ;^TMP("C0STBL",91,"problem",8,"provider@name")="KING,MATTHEW MICHAEL"
131 ;^TMP("C0STBL",91,"problem",8,"removed@value")=0
132 ;^TMP("C0STBL",91,"problem",8,"status@value")="A"
133 ;^TMP("C0STBL",91,"problem",8,"unverified@value")=0
134 ;^TMP("C0STBL",91,"problem",8,"updated@value")=3110603
135 ;
136 ; sample Smart lab result triples
137 ;
138 ;G("node16rk1fgdvx10882","code")="snomed:40930008"
139 ;G("node16rk1fgdvx10882","dcterms:title")="Hypothyroidism"
140 ;G("node16rk1fgdvx10882","rdf:type")="sp:CodedValue"
141 ;G("node16rk1fgdvx11051","code")="snomed:188155002"
142 ;G("node16rk1fgdvx11051","dcterms:title")="Primary malignant neoplasm of lower outer quadrant of female breast"
143 ;G("node16rk1fgdvx11051","rdf:type")="sp:CodedValue"
144 ;G("node16rk1fgdvx11073","code")="snomed:353295004"
145 ;G("node16rk1fgdvx11073","dcterms:title")="Toxic diffuse goiter"
146 ;G("node16rk1fgdvx11073","rdf:type")="sp:CodedValue"
147 ;G("node16rk1fgdvx11089","code")="snomed:54302000"
148 ;G("node16rk1fgdvx11089","dcterms:title")="Disorder of breast"
149 ;G("node16rk1fgdvx11089","rdf:type")="sp:CodedValue"
150 ;G("node16rk1fgdvx11351","code")="snomed:38341003"
151 ;G("node16rk1fgdvx11351","dcterms:title")="Essential hypertension"
152 ;G("node16rk1fgdvx11351","rdf:type")="sp:CodedValue"
153 ;G("node16rk1fgdvx11390","code")="snomed:44054006"
154 ;G("node16rk1fgdvx11390","dcterms:title")="Diabetes mellitus type 2"
155 ;G("node16rk1fgdvx11390","rdf:type")="sp:CodedValue"
156 ;G("node16rk1fgdvx11558","code")="snomed:195967001"
157 ;G("node16rk1fgdvx11558","dcterms:title")="Asthma"
158 ;G("node16rk1fgdvx11558","rdf:type")="sp:CodedValue"
159 ;G("node16rk1fgdvx11578","code")="snomed:254837009"
160 ;G("node16rk1fgdvx11578","dcterms:title")="Primary malignant neoplasm of female breast"
161 ;G("node16rk1fgdvx11578","rdf:type")="sp:CodedValue"
162 ;G("node16rk1fgdvx11687","code")="snomed:8517006"
163 ;G("node16rk1fgdvx11687","dcterms:title")="History of tobacco use"
164 ;G("node16rk1fgdvx11687","rdf:type")="sp:CodedValue"
165 ;G("node16rk1fgdvx11716","code")="snomed:55822004"
166 ;G("node16rk1fgdvx11716","dcterms:title")="Hyperlipidemia"
167 ;G("node16rk1fgdvx11716","rdf:type")="sp:CodedValue"
168 ;G("smart:1577780/problems/69560e4721e1","belongsTo")="smart:1577780"
169 ;G("smart:1577780/problems/69560e4721e1","problemName")="node16rk1fgdvx11089"
170 ;G("smart:1577780/problems/69560e4721e1","rdf:type")="sp:Problem"
171 ;G("smart:1577780/problems/69560e4721e1","startDate")="2005-08-02"
172 ;G("smart:1577780/problems/06ef10c4e92c","belongsTo")="smart:1577780"
173 ;G("smart:1577780/problems/06ef10c4e92c","problemName")="node16rk1fgdvx11051"
174 ;G("smart:1577780/problems/06ef10c4e92c","rdf:type")="sp:Problem"
175 ;G("smart:1577780/problems/06ef10c4e92c","startDate")="2006-02-20"
176 ;G("smart:1577780/problems/9894ba9dfe5a","belongsTo")="smart:1577780"
177 ;G("smart:1577780/problems/9894ba9dfe5a","problemName")="node16rk1fgdvx11578"
178 ;G("smart:1577780/problems/9894ba9dfe5a","rdf:type")="sp:Problem"
179 ;G("smart:1577780/problems/9894ba9dfe5a","startDate")="2005-08-22"
180 ;G("smart:1577780/problems/c109aa7a0675","belongsTo")="smart:1577780"
181 ;G("smart:1577780/problems/c109aa7a0675","problemName")="node16rk1fgdvx11558"
182 ;G("smart:1577780/problems/c109aa7a0675","rdf:type")="sp:Problem"
183 ;G("smart:1577780/problems/c109aa7a0675","startDate")="2005-09-22"
184 ;G("smart:1577780/problems/1c50100614a2","belongsTo")="smart:1577780"
185 ;G("smart:1577780/problems/1c50100614a2","problemName")="node16rk1fgdvx11073"
186 ;G("smart:1577780/problems/1c50100614a2","rdf:type")="sp:Problem"
187 ;G("smart:1577780/problems/1c50100614a2","startDate")="2007-02-21"
188 ;G("smart:1577780/problems/083dffb2c4a0","belongsTo")="smart:1577780"
189 ;G("smart:1577780/problems/083dffb2c4a0","problemName")="node16rk1fgdvx11390"
190 ;G("smart:1577780/problems/083dffb2c4a0","rdf:type")="sp:Problem"
191 ;G("smart:1577780/problems/083dffb2c4a0","startDate")="2007-01-07"
192 ;G("smart:1577780/problems/762b5639a2d1","belongsTo")="smart:1577780"
193 ;G("smart:1577780/problems/762b5639a2d1","problemName")="node16rk1fgdvx11687"
194 ;G("smart:1577780/problems/762b5639a2d1","rdf:type")="sp:Problem"
195 ;G("smart:1577780/problems/762b5639a2d1","startDate")="2006-02-20"
196 ;G("smart:1577780/problems/9dc9053dd6f4","belongsTo")="smart:1577780"
197 ;G("smart:1577780/problems/9dc9053dd6f4","problemName")="node16rk1fgdvx11716"
198 ;G("smart:1577780/problems/9dc9053dd6f4","rdf:type")="sp:Problem"
199 ;G("smart:1577780/problems/9dc9053dd6f4","startDate")="2008-04-08"
200 ;G("smart:1577780/problems/e3fe9b7ee552","belongsTo")="smart:1577780"
201 ;G("smart:1577780/problems/e3fe9b7ee552","problemName")="node16rk1fgdvx10882"
202 ;G("smart:1577780/problems/e3fe9b7ee552","rdf:type")="sp:Problem"
203 ;G("smart:1577780/problems/e3fe9b7ee552","startDate")="2005-10-27"
204 ;G("smart:1577780/problems/9933307e8f95","belongsTo")="smart:1577780"
205 ;G("smart:1577780/problems/9933307e8f95","problemName")="node16rk1fgdvx11351"
206 ;G("smart:1577780/problems/9933307e8f95","rdf:type")="sp:Problem"
207 ;G("smart:1577780/problems/9933307e8f95","startDate")="2005-08-22"
208 ;G("snomed:188155002","dcterms:identifier")=188155002
209 ;G("snomed:188155002","dcterms:title")="Primary malignant neoplasm of lower outer quadrant of female breast"
210 ;G("snomed:188155002","rdf:type")="sp:Code"
211 ;G("snomed:188155002","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
212 ;G("snomed:195967001","dcterms:identifier")=195967001
213 ;G("snomed:195967001","dcterms:title")="Asthma"
214 ;G("snomed:195967001","rdf:type")="sp:Code"
215 ;G("snomed:195967001","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
216 ;G("snomed:254837009","dcterms:identifier")=254837009
217 ;G("snomed:254837009","dcterms:title")="Primary malignant neoplasm of female breast"
218 ;G("snomed:254837009","rdf:type")="sp:Code"
219 ;G("snomed:254837009","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
220 ;G("snomed:353295004","dcterms:identifier")=353295004
221 ;G("snomed:353295004","dcterms:title")="Toxic diffuse goiter"
222 ;G("snomed:353295004","rdf:type")="sp:Code"
223 ;G("snomed:353295004","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
224 ;G("snomed:38341003","dcterms:identifier")=38341003
225 ;G("snomed:38341003","dcterms:title")="Essential hypertension"
226 ;G("snomed:38341003","rdf:type")="sp:Code"
227 ;G("snomed:38341003","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
228 ;G("snomed:40930008","dcterms:identifier")=40930008
229 ;G("snomed:40930008","dcterms:title")="Hypothyroidism"
230 ;G("snomed:40930008","rdf:type")="sp:Code"
231 ;G("snomed:40930008","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
232 ;G("snomed:44054006","dcterms:identifier")=44054006
233 ;G("snomed:44054006","dcterms:title")="Diabetes mellitus type 2"
234 ;G("snomed:44054006","rdf:type")="sp:Code"
235 ;G("snomed:44054006","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
236 ;G("snomed:54302000","dcterms:identifier")=54302000
237 ;G("snomed:54302000","dcterms:title")="Disorder of breast"
238 ;G("snomed:54302000","rdf:type")="sp:Code"
239 ;G("snomed:54302000","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
240 ;G("snomed:55822004","dcterms:identifier")=55822004
241 ;G("snomed:55822004","dcterms:title")="Hyperlipidemia"
242 ;G("snomed:55822004","rdf:type")="sp:Code"
243 ;G("snomed:55822004","system")="http://purl.bioontology.org/ontology/SNOMEDCT"
244 ;G("snomed:8517006","dcterms:identifier")=8517006
245 ;G("snomed:8517006","dcterms:title")="History of tobacco use"
246 ;G("snomed:8517006","rdf:type")="sp:Code"
247 ;G("snomed:8517006","system")="http://purl.bioontology.org/ontology/SNOMEDCT/"
248
249 ;
250PROB(GRTN,C0SARY) ; GRTN, passed by reference,
251 ; is the return name of the graph created. "" if none
252 ; C0SARY is passed in by reference and is the NHIN array of problems
253 ;
254 I $O(C0SARY("problem",""))="" D Q ;
255 . I $D(DEBUG) W !,"No Problems"
256 S GRTN="" ; default to no problems
257 N C0SGRF
258 S C0SGRF="vistaSmart:"_ZPATID_"/problems"
259 I $D(DEBUG) W !,"Processing ",C0SGRF
260 D DELGRAPH^C0XF2N(C0SGRF) ; delete the old graph
261 D INITFARY^C0XF2N("C0XFARY") ; which triple store to use
262 N FARY S FARY="C0XFARY"
263 D USEFARY^C0XF2N(FARY)
264 D VOCINIT^C0XUTIL
265 ;
266 D STARTADD^C0XF2N ; initialize to create triples
267 ;
268 N ZI S ZI=""
269 F S ZI=$O(C0SARY("problem",ZI)) Q:ZI="" D ;
270 . N LRN,ZR ; ZR is the local array for building the new triples
271 . S LRN=$NA(C0SARY("problem",ZI)) ; base for values in this lab result
272 . ;
273 . N PROBID ; unique Id for this problem
274 . S PROBID=C0SGRF_"/"_$$LKY17^C0XF2N ; use a random number
275 . ;
276 . ; i don't like this because the same problems gets a
277 . ; different ID every time it's reported. Can't trace it back to VistA
278 . ; I'd rather be using id@value ie "id@value")="118"
279 . ;
280 . N SNOMED S SNOMED=$G(@LRN@("icd@value"))
281 . N SNOGRF S SNOGRF="snomed:"_SNOMED
282 . N SNOTIT S SNOTIT=$G(@LRN@("name@value"))
283 . I $D(DEBUG) D ;
284 . . W !,"Processing Problem List ",PROBID
285 . . W !,"problem: ",SNOTIT
286 . . W !,"code: ",SNOMED
287 . ;
288 . ; first do the base result graph
289 . ;
290 . S ZR("rdf:type")="sp:Problem"
291 . S ZR("sp:belongsTo")=C0SGRF ; the subject for this patient's problems
292 . ; ie /vista/smart/99912345/problems
293 . ;
294 . N PROBNAME S PROBNAME=$$ANONS^C0XF2N ; new node for problem name
295 . S ZR("sp:problemName")=PROBNAME
296 . ;
297 . N STARTDT S STARTDT=$$SPDATE^C0SUTIL($G(@LRN@("entered@value")))
298 . S ZR("sp:startDate")=STARTDT
299 . ;
300 . D ADDINN^C0XF2N(C0SGRF,PROBID,.ZR) ; addIfNotNull the triples
301 . K ZR ; clean up
302 . ;
303 . ; create the problemName graph
304 . ;
305 . S ZR("rdf:type")="sp:CodedValue"
306 . S ZR("sp:code")="snomed:"_SNOMED
307 . S ZR("dcterms:title")=$G(@LRN@("name@value"))
308 . D ADDINN^C0XF2N(C0SGRF,PROBNAME,.ZR)
309 . K ZR
310 . ;
311 . ; create snomed graph
312 . ;
313 . S ZR("rdf:type")="sp:Code"
314 . S ZR("sp:system")="http://purl.bioontology.org/ontology/SNOMEDCT"
315 . S ZR("dcterms:identifier")=SNOMED
316 . S ZR("dcterms:title")=SNOTIT
317 . D ADDINN^C0XF2N(C0SGRF,SNOGRF,.ZR)
318 . K ZR
319 . ;
320 D BULKLOAD^C0XF2N(.C0XFDA)
321 S GRTN=C0SGRF
322 Q
323 ;
Note: See TracBrowser for help on using the repository browser.