source: smart/trunk/p/C0SVITAL.m@ 1742

Last change on this file since 1742 was 1526, checked in by George Lilly, 12 years ago

initial release of the VistA Smart Container demo

File size: 4.1 KB
RevLine 
[1526]1C0SPROB ; GPL - Smart Problem Processing ;5/01/12 17:05
2 ;;0.1;C0S;nopatch;noreleasedate;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 ;
24G("node16rk1fgdvx276397","code")="loinc:8480-6"
25G("node16rk1fgdvx276397","dcterms:title")="systolic blood pressure"
26G("node16rk1fgdvx276397","rdf:type")="sp:CodedValue"
27G("node16rk1fgdvx276398","rdf:type")="sp:VitalSign"
28G("node16rk1fgdvx276398","unit")="mm[Hg]"
29G("node16rk1fgdvx276398","value")="113.0"
30G("node16rk1fgdvx276398","vitalName")="node16rk1fgdvx276397"
31
32 ;
33VITALS(GRTN,C0SARY) ; GRTN, passed by reference,
34 ; is the return name of the graph created. "" if none
35 ; C0SARY is passed in by reference and is the NHIN array of problems
36 ;
37 I $O(C0SARY("vital",""))="" D Q ;
38 . I $D(DEBUG) W !,"No Vital Signs"
39 S GRTN="" ; default to no vital signs
40 N C0SGRF
41 S C0SGRF="/vista/smart/"_ZPATID_"/vitals"
42 I $D(DEBUG) W !,"Processing ",C0SGRF
43 D DELGRAPH^C0XF2N(C0SGRF) ; delete the old graph
44 D INITFARY^C0XF2N("C0XFARY") ; which triple store to use
45 N FARY S FARY="C0XFARY"
46 D USEFARY^C0XF2N(FARY)
47 D VOCINIT^C0XUTIL
48 ;
49 D STARTADD^C0XF2N ; initialize to create triples
50 ;
51 N ZI S ZI=""
52 F S ZI=$O(C0SARY("vital",ZI)) Q:ZI="" D ;
53 . N LRN,ZR ; ZR is the local array for building the new triples
54 . S LRN=$NA(C0SARY("problem",ZI)) ; base for values in this lab result
55 . ;
56 . N PROBID ; unique Id for this problem
57 . S PROBID=C0SGRF_"/"_$$LKY17^C0XF2N ; use a random number
58 . ;
59 . ; i don't like this because the same problems gets a
60 . ; different ID every time it's reported. Can't trace it back to VistA
61 . ; I'd rather be using id@value ie "id@value")="118"
62 . ;
63 . N SNOMED,ICD S ICD=$G(@LRN@("icd@value"))
64 . S SNOMED=$$SNOMED(ICD) ; look up the snomed code in the map
65 . I SNOMED="" S SNOMED=ICD ; if not found, return the ICD code
66 . N SNOGRF S SNOGRF="snomed:"_SNOMED
67 . N SNOTIT S SNOTIT=$G(@LRN@("name@value"))
68 . I $D(DEBUG) D ;
69 . . W !,"Processing Problem List ",PROBID
70 . . W !,"problem: ",SNOTIT
71 . . W !,"code: ",SNOMED
72 . ;
73 . ; first do the base result graph
74 . ;
75 . S ZR("rdf:type")="sp:Problem"
76 . S ZR("sp:belongsTo")=C0SGRF ; the subject for this patient's problems
77 . ; ie /vista/smart/99912345/problems
78 . ;
79 . N PROBNAME S PROBNAME=$$ANONS^C0XF2N ; new node for problem name
80 . S ZR("sp:problemName")=PROBNAME
81 . ;
82 . N STARTDT S STARTDT=$$SPDATE^C0SUTIL($G(@LRN@("entered@value")))
83 . S ZR("sp:startDate")=STARTDT
84 . ;
85 . D ADDINN^C0XF2N(C0SGRF,PROBID,.ZR) ; addIfNotNull the triples
86 . K ZR ; clean up
87 . ;
88 . ; create the problemName graph
89 . ;
90 . S ZR("rdf:type")="sp:CodedValue"
91 . S ZR("sp:code")="snomed:"_SNOMED
92 . S ZR("dcterms:title")=$G(@LRN@("name@value"))
93 . D ADDINN^C0XF2N(C0SGRF,PROBNAME,.ZR)
94 . K ZR
95 . ;
96 . ; create snomed graph
97 . ;
98 . S ZR("rdf:type")="sp:Code"
99 . S ZR("sp:system")="http://purl.bioontology.org/ontology/SNOMEDCT"
100 . S ZR("dcterms:identifier")=SNOMED
101 . S ZR("dcterms:title")=SNOTIT
102 . D ADDINN^C0XF2N(C0SGRF,SNOGRF,.ZR)
103 . K ZR
104 . ;
105 D BULKLOAD^C0XF2N(.C0XFDA)
106 S GRTN=C0SGRF
107 Q
108 ;
109SNOMED(ZICD) ; extrinsic which returns SNOMED code given an ICD9 code
110 ; requires the mapping table installed in the triplestore
111 ;
112 N ZSN,ZARY,ZSUB
113 S ZSUB=$$subject^C0XGET1(,ZICD) ; subject of the ICD9 code
114 D objects^C0XGET1(.ZARY,ZSUB,"cg:ontology#toCode")
115 S ZSN=$O(ZARY(""))
116 I $D(DEBUG) W !,ZSN," ",$$object^C0XGET1(ZSUB,"rdfs:label")
117 Q ZSN
118 ;
Note: See TracBrowser for help on using the repository browser.