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

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

Updated license for routines

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