source: smart/trunk/p/C0STBL.m@ 1688

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

Updated license for routines

File size: 4.4 KB
RevLine 
[1571]1C0STBL ; GPL - Smart Container CREATE A TABLE OF NHINV VALUES;2/22/12 17:05
[1591]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
19EN(BEGDFN,DFNCNT,ZPART) ; START IS A DFN
20 I '$D(BEGDFN) S BDGDFN=""
21 I '$D(DFNCNT) S DFNCNT=150
22 I '$D(ZPART) S ZPART=""
23 N ZTBL S ZTBL=$NA(^TMP("C0STBL"))
24 N ZI,ZCNT,ZG
25 S ZI=$O(^DPT(BEGDFN),-1)
26 S ZCNT=1
27 F S ZI=$O(^DPT(ZI)) Q:((+ZI=0)!(ZCNT>DFNCNT)) D ;
28 . S ZCNT=ZCNT+1
29 . W ZI," "
30 . K ZG
31 . D EN^C0SNHIN(.ZG,ZI,ZPART)
32 . M @ZTBL@(ZI)=ZG
33 . K G
34 . N GDIR S GDIR="/home/vista/p/"
35 . D EN^C0SMART(.G,ZI,"med")
36 . I $D(G) W !,$$output^C0XGET1("G",ZI_"-med.rdf",GDIR)
37 . k G
38 . D EN^C0SMART(.G,ZI,"patient")
39 . I $D(G) W !,$$output^C0XGET1("G",ZI_"-patient.rdf",GDIR)
40 . K G
41 . D EN^C0SMART(.G,ZI,"lab")
42 . I $D(G) W !,$$output^C0XGET1("G",ZI_"-lab.rdf",GDIR)
43 . K G
44 . D EN^C0SMART(.G,ZI,"problem")
45 . I $D(G) W !,$$output^C0XGET1("G",ZI_"-problem.rdf",GDIR)
46 Q
47 ;
48LOADHACK ;
49 N ZI
50 F ZI=2:1:374 D ;
51 . D IMPORT^C0XF2N("hack"_ZI_".xml","/home/vista/hack/")
52 Q
53 ;
54LABCNT ; COUNT LAB TESTS AND LOINC CODES
55 K LABCNT,GLOINC,PATCNT
56 S (LABCNT,GLOINC,PATCNT)=0
57 N ZI S ZI=""
58 N GN S GN=$NA(^TMP("C0STBL"))
59 F S ZI=$O(@GN@(ZI)) Q:ZI="" D ;
60 . S PATCNT=PATCNT+1
61 . I '$D(@GN@(ZI,"lab")) Q ;
62 . N ZJ S ZJ=""
63 . F S ZJ=$O(@GN@(ZI,"lab",ZJ)) Q:ZJ="" D ;
64 . . S LABCNT=LABCNT+1
65 . . S X=$G(@GN@(ZI,"lab",ZJ,"loinc@value"))
66 . . I X'="" S GLOINC=GLOINC+1
67 W !,"Total number of patients: ",PATCNT
68 W !,"Total number of lab results: ",LABCNT
69 W !,"Total number of lab results with loinc codes: ",GLOINC
70 W !,"Percentage of lab tests with loinc codes: ",$P((GLOINC/LABCNT)*100,".")_"%"
71 Q
72 ;
73PROBCNT ; COUNT PROBLEMS AND SNOMED CODES
74 K PROBCNT,GSNO,PATCNT
75 S (PROBCNT,GSNO,PATCNT)=0
76 N ZI S ZI=""
77 N GN S GN=$NA(^TMP("C0STBL"))
78 F S ZI=$O(@GN@(ZI)) Q:ZI="" D ;
79 . S PATCNT=PATCNT+1
80 . I '$D(@GN@(ZI,"problem")) Q ;
81 . N ZJ S ZJ=""
82 . F S ZJ=$O(@GN@(ZI,"problem",ZJ)) Q:ZJ="" D ;
83 . . S PROBCNT=PROBCNT+1
84 . . S X=$G(@GN@(ZI,"problem",ZJ,"icd@value"))
85 . . S Y=$$SNOMED^C0SPROB2(X)
86 . . I Y'="" S GSNO=GSNO+1
87 W !,"Total number of patients: ",PATCNT
88 W !,"Total number of problems: ",PROBCNT
89 W !,"Total number of problems with snomed codes: ",GSNO
90 W !,"Percentage of problems with SNOMED codes: ",$P((GSNO/PROBCNT)*100,".")_"%"
91 Q
92 ;
93MEDCNT ; COUNT INPATIENT VS OUTPATIENT MEDICATIONS
94 K MEDCNT,OMED,PATCNT,DOSE,UNITS,FORM,SCHED,ROUTE
95 S (MEDCNT,OMED,GSNO,PATCNT)=0
96 N ZI S ZI=""
97 N GN S GN=$NA(^TMP("C0STBL"))
98 F S ZI=$O(@GN@(ZI)) Q:ZI="" D ;
99 . S PATCNT=PATCNT+1
100 . I '$D(@GN@(ZI,"med")) Q ;
101 . N ZJ S ZJ=""
102 . F S ZJ=$O(@GN@(ZI,"med",ZJ)) Q:ZJ="" D ;
103 . . S MEDCNT=MEDCNT+1
104 . . I $G(@GN@(ZI,"med",ZJ,"vaStatus@value"))="EXPIRED" D Q ;
105 . . . I $D(DEBUG) W !,"Expired Mediation, Skipping"
106 . . I $G(@GN@(ZI,"med",ZJ,"vaType@value"))="I" D Q ;
107 . . . I $D(DEBUG) W !,"Inpatient Med, skipping"
108 . . I $G(@GN@(ZI,"med",ZI,"vaType@value"))="V" D Q ;
109 . . . I $D(DEBUG) W !,"IV Inpatient Med, skipping"
110 . . S OMED=OMED+1
111 . . S X=$G(@GN@(ZI,"med",ZJ,"form@value"))
112 . . S FORM(X)=$G(FORM(X))+1
113 . . S X=$G(@GN@(ZI,"med",ZJ,"doses.dose@dose"))
114 . . I X="" S X="UNKNOWN"
115 . . S DOSE(X)=$G(DOSE(X))+1
116 . . S X=$G(@GN@(ZI,"med",ZJ,"doses.dose@units"))
117 . . I X="" S X="UNKNOWN"
118 . . S UNITS(X)=$G(UNITS(X))+1
119 . . S X=$G(@GN@(ZI,"med",ZJ,"doses.dose@schedule"))
120 . . I X="" S X="UNKNOWN"
121 . . S SCHED(X)=$G(SCHED(X))+1
122 . . S X=$G(@GN@(ZI,"med",ZJ,"doses.dosc@route"))
123 . . I X="" S X="UNKNOWN"
124 . . S ROUTE(X)=$G(ROUTE(X))+1
125 W !,"Total number of patients: ",PATCNT
126 W !,"Total number of medications: ",MEDCNT
127 W !,"Total number of outpatient medications: ",OMED
128 W !,"Percentage of outpatient medications: ",$P((OMED/MEDCNT)*100,".")_"%",!
129 ZWR FORM
130 ZWR DOSE
131 ZWR UNITS
132 ZWR SCHED
133 ZWR ROUTE
134 Q
135 ;
Note: See TracBrowser for help on using the repository browser.