Index: smart/trunk/p/C0SDEM.m
===================================================================
--- smart/trunk/p/C0SDEM.m	(revision 1590)
+++ smart/trunk/p/C0SDEM.m	(revision 1591)
@@ -1,20 +1,18 @@
-C0SDEM	  ; GPL - Smart Demographics Processing ;2/22/12  17:05
-	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 4
-	;Copyright 2012 George Lilly.  Licensed under the terms of the GNU
-	;General Public License See attached copy of the License.
-	;
-	;This program is free software; you can redistribute it and/or modify
-	;it under the terms of the GNU General Public License as published by
-	;the Free Software Foundation; either version 2 of the License, or
-	;(at your option) any later version.
-	;
-	;This program is distributed in the hope that it will be useful,
-	;but WITHOUT ANY WARRANTY; without even the implied warranty of
-	;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	;GNU General Public License for more details.
-	;
-	;You should have received a copy of the GNU General Public License along
-	;with this program; if not, write to the Free Software Foundation, Inc.,
-	;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+C0SDEM	  ; GPL - Smart Demographics Processing ; 10/30/12 10:59am
+	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 5
+	;Copyright 2012 George Lilly.  
+	;
+	; This program is free software: you can redistribute it and/or modify
+	; it under the terms of the GNU Affero General Public License as
+	; published by the Free Software Foundation, either version 3 of the
+	; License, or (at your option) any later version.
+	;
+	; This program is distributed in the hope that it will be useful,
+	; but WITHOUT ANY WARRANTY; without even the implied warranty of
+	; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	; GNU Affero General Public License for more details.
+	;
+	; You should have received a copy of the GNU Affero General Public License
+	; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 	;
 	Q
Index: smart/trunk/p/C0SDOM.m
===================================================================
--- smart/trunk/p/C0SDOM.m	(revision 1590)
+++ smart/trunk/p/C0SDOM.m	(revision 1591)
@@ -1,21 +1,18 @@
 C0SDOM	  ; GPL - Smart Container - DOM PROCESSING ROUTINES ;6/6/11  17:05
-	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 4
-	;Copyright 2011,2012 George Lilly.  Licensed under the terms of the GNU
-	;General Public License See attached copy of the License.
-	;
-	;This program is free software; you can redistribute it and/or modify
-	;it under the terms of the GNU General Public License as published by
-	;the Free Software Foundation; either version 2 of the License, or
-	;(at your option) any later version.
-	;
-	
-	;This program is distributed in the hope that it will be useful,
-	;but WITHOUT ANY WARRANTY; without even the implied warranty of
-	;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	;GNU General Public License for more details.
-	;
-	;You should have received a copy of the GNU General Public License along
-	;with this program; if not, write to the Free Software Foundation, Inc.,
-	;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 5
+	;Copyright 2011,2012 George Lilly.  
+	;
+	; This program is free software: you can redistribute it and/or modify
+	; it under the terms of the GNU Affero General Public License as
+	; published by the Free Software Foundation, either version 3 of the
+	; License, or (at your option) any later version.
+	;
+	; This program is distributed in the hope that it will be useful,
+	; but WITHOUT ANY WARRANTY; without even the implied warranty of
+	; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	; GNU Affero General Public License for more details.
+	;
+	; You should have received a copy of the GNU Affero General Public License
+	; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 	;
 	Q
Index: smart/trunk/p/C0SLAB.m
===================================================================
--- smart/trunk/p/C0SLAB.m	(revision 1590)
+++ smart/trunk/p/C0SLAB.m	(revision 1591)
@@ -1,20 +1,18 @@
 C0SLAB	  ; GPL - Smart Lab Processing ;4/15/12  17:05
-	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 4
-	;Copyright 2012 George Lilly.  Licensed under the terms of the GNU
-	;General Public License See attached copy of the License.
-	;
-	;This program is free software; you can redistribute it and/or modify
-	;it under the terms of the GNU General Public License as published by
-	;the Free Software Foundation; either version 2 of the License, or
-	;(at your option) any later version.
-	;
-	;This program is distributed in the hope that it will be useful,
-	;but WITHOUT ANY WARRANTY; without even the implied warranty of
-	;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	;GNU General Public License for more details.
-	;
-	;You should have received a copy of the GNU General Public License along
-	;with this program; if not, write to the Free Software Foundation, Inc.,
-	;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 5
+	;Copyright 2012 George Lilly.  
+	;
+	; This program is free software: you can redistribute it and/or modify
+	; it under the terms of the GNU Affero General Public License as
+	; published by the Free Software Foundation, either version 3 of the
+	; License, or (at your option) any later version.
+	;
+	; This program is distributed in the hope that it will be useful,
+	; but WITHOUT ANY WARRANTY; without even the implied warranty of
+	; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	; GNU Affero General Public License for more details.
+	;
+	; You should have received a copy of the GNU Affero General Public License
+	; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 	;
 	Q
Index: smart/trunk/p/C0SMART.m
===================================================================
--- smart/trunk/p/C0SMART.m	(revision 1590)
+++ smart/trunk/p/C0SMART.m	(revision 1591)
@@ -1,20 +1,18 @@
 C0SMART	  ; GPL - Smart Container Entry Points;2/22/12  17:05
-	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 4
-	;Copyright 2012 George Lilly.  Licensed under the terms of the GNU
-	;General Public License See attached copy of the License.
+	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 5
+	;Copyright 2012 George Lilly.  
 	;
-	;This program is free software; you can redistribute it and/or modify
-	;it under the terms of the GNU General Public License as published by
-	;the Free Software Foundation; either version 2 of the License, or
-	;(at your option) any later version.
+	; This program is free software: you can redistribute it and/or modify
+	; it under the terms of the GNU Affero General Public License as
+	; published by the Free Software Foundation, either version 3 of the
+	; License, or (at your option) any later version.
 	;
-	;This program is distributed in the hope that it will be useful,
-	;but WITHOUT ANY WARRANTY; without even the implied warranty of
-	;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	;GNU General Public License for more details.
+	; This program is distributed in the hope that it will be useful,
+	; but WITHOUT ANY WARRANTY; without even the implied warranty of
+	; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	; GNU Affero General Public License for more details.
 	;
-	;You should have received a copy of the GNU General Public License along
-	;with this program; if not, write to the Free Software Foundation, Inc.,
-	;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+	; You should have received a copy of the GNU Affero General Public License
+	; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 	;
 	Q
Index: smart/trunk/p/C0SMED.m
===================================================================
--- smart/trunk/p/C0SMED.m	(revision 1590)
+++ smart/trunk/p/C0SMED.m	(revision 1591)
@@ -1,20 +1,18 @@
 C0SMED	  ; GPL - Smart Meds Processing ;2/22/12  17:05
-	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 4
-	;Copyright 2012 George Lilly.  Licensed under the terms of the GNU
-	;General Public License See attached copy of the License.
+	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 5
+	;Copyright 2012 George Lilly.  
 	;
-	;This program is free software; you can redistribute it and/or modify
-	;it under the terms of the GNU General Public License as published by
-	;the Free Software Foundation; either version 2 of the License, or
-	;(at your option) any later version.
+	; This program is free software: you can redistribute it and/or modify
+	; it under the terms of the GNU Affero General Public License as
+	; published by the Free Software Foundation, either version 3 of the
+	; License, or (at your option) any later version.
 	;
-	;This program is distributed in the hope that it will be useful,
-	;but WITHOUT ANY WARRANTY; without even the implied warranty of
-	;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	;GNU General Public License for more details.
+	; This program is distributed in the hope that it will be useful,
+	; but WITHOUT ANY WARRANTY; without even the implied warranty of
+	; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	; GNU Affero General Public License for more details.
 	;
-	;You should have received a copy of the GNU General Public License along
-	;with this program; if not, write to the Free Software Foundation, Inc.,
-	;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+	; You should have received a copy of the GNU Affero General Public License
+	; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 	;
 	Q
Index: smart/trunk/p/C0SMXMLB.m
===================================================================
--- smart/trunk/p/C0SMXMLB.m	(revision 1590)
+++ smart/trunk/p/C0SMXMLB.m	(revision 1591)
@@ -1,4 +1,5 @@
 MXMLBLD	;;ISF/RWF - Tool to build XML ;07/09/09  16:55 - Smart Container Ver.
-	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 4
+	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 5
+	; Public Domain
 	QUIT
 	;
Index: smart/trunk/p/C0SNHIN.m
===================================================================
--- smart/trunk/p/C0SNHIN.m	(revision 1590)
+++ smart/trunk/p/C0SNHIN.m	(revision 1591)
@@ -1,20 +1,18 @@
 C0SNHIN	  ; GPL - Smart Container - OUTPUT OF NHINV ROUTINES;6/3/11  17:05
-	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 4
-	;Copyright 2011-2012 George Lilly.  Licensed under the terms of the GNU
-	;General Public License See attached copy of the License.
-	;
-	;This program is free software; you can redistribute it and/or modify
-	;it under the terms of the GNU General Public License as published by
-	;the Free Software Foundation; either version 2 of the License, or
-	;(at your option) any later version.
-	;
-	;This program is distributed in the hope that it will be useful,
-	;but WITHOUT ANY WARRANTY; without even the implied warranty of
-	;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	;GNU General Public License for more details.
-	;
-	;You should have received a copy of the GNU General Public License along
-	;with this program; if not, write to the Free Software Foundation, Inc.,
-	;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 5
+	;Copyright 2011-2012 George Lilly.  
+	;
+	; This program is free software: you can redistribute it and/or modify
+	; it under the terms of the GNU Affero General Public License as
+	; published by the Free Software Foundation, either version 3 of the
+	; License, or (at your option) any later version.
+	;
+	; This program is distributed in the hope that it will be useful,
+	; but WITHOUT ANY WARRANTY; without even the implied warranty of
+	; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	; GNU Affero General Public License for more details.
+	;
+	; You should have received a copy of the GNU Affero General Public License
+	; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 	;
 	Q
Index: smart/trunk/p/C0SNHINV.m
===================================================================
--- smart/trunk/p/C0SNHINV.m	(revision 1590)
+++ smart/trunk/p/C0SNHINV.m	(revision 1591)
@@ -1,4 +1,4 @@
 C0SNHINV	;SLC/MKB - Serve VistA data as XML via RPC - Smart Container Version
-	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 4
+	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 5
 	;
 	; External References          DBIA#
Index: smart/trunk/p/C0SPROB.m
===================================================================
--- smart/trunk/p/C0SPROB.m	(revision 1590)
+++ smart/trunk/p/C0SPROB.m	(revision 1591)
@@ -1,20 +1,18 @@
 C0SPROB	  ; GPL - Smart Problem Processing ;5/01/12  17:05
-	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 4
-	;Copyright 2012 George Lilly.  Licensed under the terms of the GNU
-	;General Public License See attached copy of the License.
-	;
-	;This program is free software; you can redistribute it and/or modify
-	;it under the terms of the GNU General Public License as published by
-	;the Free Software Foundation; either version 2 of the License, or
-	;(at your option) any later version.
-	;
-	;This program is distributed in the hope that it will be useful,
-	;but WITHOUT ANY WARRANTY; without even the implied warranty of
-	;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	;GNU General Public License for more details.
-	;
-	;You should have received a copy of the GNU General Public License along
-	;with this program; if not, write to the Free Software Foundation, Inc.,
-	;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 5
+	;Copyright 2012 George Lilly.  
+	;
+	; This program is free software: you can redistribute it and/or modify
+	; it under the terms of the GNU Affero General Public License as
+	; published by the Free Software Foundation, either version 3 of the
+	; License, or (at your option) any later version.
+	;
+	; This program is distributed in the hope that it will be useful,
+	; but WITHOUT ANY WARRANTY; without even the implied warranty of
+	; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	; GNU Affero General Public License for more details.
+	;
+	; You should have received a copy of the GNU Affero General Public License
+	; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 	;
 	Q
Index: smart/trunk/p/C0SPROB2.m
===================================================================
--- smart/trunk/p/C0SPROB2.m	(revision 1590)
+++ smart/trunk/p/C0SPROB2.m	(revision 1591)
@@ -1,20 +1,18 @@
 C0SPROB	  ; GPL - Smart Problem Processing ;5/01/12  17:05
-	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 4
-	;Copyright 2012 George Lilly.  Licensed under the terms of the GNU
-	;General Public License See attached copy of the License.
-	;
-	;This program is free software; you can redistribute it and/or modify
-	;it under the terms of the GNU General Public License as published by
-	;the Free Software Foundation; either version 2 of the License, or
-	;(at your option) any later version.
-	;
-	;This program is distributed in the hope that it will be useful,
-	;but WITHOUT ANY WARRANTY; without even the implied warranty of
-	;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	;GNU General Public License for more details.
-	;
-	;You should have received a copy of the GNU General Public License along
-	;with this program; if not, write to the Free Software Foundation, Inc.,
-	;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 5
+	;Copyright 2012 George Lilly.  
+	;
+	; This program is free software: you can redistribute it and/or modify
+	; it under the terms of the GNU Affero General Public License as
+	; published by the Free Software Foundation, either version 3 of the
+	; License, or (at your option) any later version.
+	;
+	; This program is distributed in the hope that it will be useful,
+	; but WITHOUT ANY WARRANTY; without even the implied warranty of
+	; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	; GNU Affero General Public License for more details.
+	;
+	; You should have received a copy of the GNU Affero General Public License
+	; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 	;
 	Q
Index: smart/trunk/p/C0STBL.m
===================================================================
--- smart/trunk/p/C0STBL.m	(revision 1590)
+++ smart/trunk/p/C0STBL.m	(revision 1591)
@@ -1,137 +1,135 @@
 C0STBL	  ; GPL - Smart Container CREATE A TABLE OF NHINV VALUES;2/22/12  17:05
-	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 4
- ;Copyright 2012 George Lilly.  Licensed under the terms of the GNU
- ;General Public License See attached copy of the License.
- ;
- ;This program is free software; you can redistribute it and/or modify
- ;it under the terms of the GNU General Public License as published by
- ;the Free Software Foundation; either version 2 of the License, or
- ;(at your option) any later version.
- ;
- ;This program is distributed in the hope that it will be useful,
- ;but WITHOUT ANY WARRANTY; without even the implied warranty of
- ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- ;GNU General Public License for more details.
- ;
- ;You should have received a copy of the GNU General Public License along
- ;with this program; if not, write to the Free Software Foundation, Inc.,
- ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- ;
- Q
-EN(BEGDFN,DFNCNT,ZPART) ; START IS A DFN
- I '$D(BEGDFN) S BDGDFN=""
- I '$D(DFNCNT) S DFNCNT=150
- I '$D(ZPART) S ZPART=""
- N ZTBL S ZTBL=$NA(^TMP("C0STBL"))
- N ZI,ZCNT,ZG
- S ZI=$O(^DPT(BEGDFN),-1)
- S ZCNT=1
- F  S ZI=$O(^DPT(ZI)) Q:((+ZI=0)!(ZCNT>DFNCNT))  D  ;
- . S ZCNT=ZCNT+1
- . W ZI," "
- . K ZG
- . D EN^C0SNHIN(.ZG,ZI,ZPART)
- . M @ZTBL@(ZI)=ZG
- . K G
- . N GDIR S GDIR="/home/vista/p/"
- . D EN^C0SMART(.G,ZI,"med")
- . I $D(G) W !,$$output^C0XGET1("G",ZI_"-med.rdf",GDIR)
- . k G
- . D EN^C0SMART(.G,ZI,"patient")
- . I $D(G) W !,$$output^C0XGET1("G",ZI_"-patient.rdf",GDIR)
- . K G
- . D EN^C0SMART(.G,ZI,"lab")
- . I $D(G) W !,$$output^C0XGET1("G",ZI_"-lab.rdf",GDIR)
- . K G
- . D EN^C0SMART(.G,ZI,"problem")
- . I $D(G) W !,$$output^C0XGET1("G",ZI_"-problem.rdf",GDIR)
- Q
- ;
-LOADHACK ;
- N ZI
- F ZI=2:1:374 D  ;
- . D IMPORT^C0XF2N("hack"_ZI_".xml","/home/vista/hack/")
- Q
- ;
-LABCNT ; COUNT LAB TESTS AND LOINC CODES
- K LABCNT,GLOINC,PATCNT
- S (LABCNT,GLOINC,PATCNT)=0
- N ZI S ZI=""
- N GN S GN=$NA(^TMP("C0STBL"))
- F  S ZI=$O(@GN@(ZI)) Q:ZI=""  D  ;
- . S PATCNT=PATCNT+1
- . I '$D(@GN@(ZI,"lab")) Q  ;
- . N ZJ S ZJ=""
- . F  S ZJ=$O(@GN@(ZI,"lab",ZJ)) Q:ZJ=""  D  ;
- . . S LABCNT=LABCNT+1
- . . S X=$G(@GN@(ZI,"lab",ZJ,"loinc@value"))
- . . I X'="" S GLOINC=GLOINC+1
- W !,"Total number of patients: ",PATCNT
- W !,"Total number of lab results: ",LABCNT
- W !,"Total number of lab results with loinc codes: ",GLOINC
- W !,"Percentage of lab tests with loinc codes: ",$P((GLOINC/LABCNT)*100,".")_"%"
- Q
- ;
-PROBCNT ; COUNT PROBLEMS AND SNOMED CODES
- K PROBCNT,GSNO,PATCNT
- S (PROBCNT,GSNO,PATCNT)=0
- N ZI S ZI=""
- N GN S GN=$NA(^TMP("C0STBL"))
- F  S ZI=$O(@GN@(ZI)) Q:ZI=""  D  ;
- . S PATCNT=PATCNT+1
- . I '$D(@GN@(ZI,"problem")) Q  ;
- . N ZJ S ZJ=""
- . F  S ZJ=$O(@GN@(ZI,"problem",ZJ)) Q:ZJ=""  D  ;
- . . S PROBCNT=PROBCNT+1
- . . S X=$G(@GN@(ZI,"problem",ZJ,"icd@value"))
- . . S Y=$$SNOMED^C0SPROB2(X)
- . . I Y'="" S GSNO=GSNO+1
- W !,"Total number of patients: ",PATCNT
- W !,"Total number of problems: ",PROBCNT
- W !,"Total number of problems with snomed codes: ",GSNO
- W !,"Percentage of problems with SNOMED codes: ",$P((GSNO/PROBCNT)*100,".")_"%"
- Q
- ;
-MEDCNT ; COUNT INPATIENT VS OUTPATIENT MEDICATIONS
- K MEDCNT,OMED,PATCNT,DOSE,UNITS,FORM,SCHED,ROUTE
- S (MEDCNT,OMED,GSNO,PATCNT)=0
- N ZI S ZI=""
- N GN S GN=$NA(^TMP("C0STBL"))
- F  S ZI=$O(@GN@(ZI)) Q:ZI=""  D  ;
- . S PATCNT=PATCNT+1
- . I '$D(@GN@(ZI,"med")) Q  ;
- . N ZJ S ZJ=""
- . F  S ZJ=$O(@GN@(ZI,"med",ZJ)) Q:ZJ=""  D  ;
- . . S MEDCNT=MEDCNT+1
- . . I $G(@GN@(ZI,"med",ZJ,"vaStatus@value"))="EXPIRED" D  Q  ;
- . . . I $D(DEBUG) W !,"Expired Mediation, Skipping"
- . . I $G(@GN@(ZI,"med",ZJ,"vaType@value"))="I" D  Q  ;
- . . . I $D(DEBUG) W !,"Inpatient Med, skipping"
- . . I $G(@GN@(ZI,"med",ZI,"vaType@value"))="V" D  Q  ;
- . . . I $D(DEBUG) W !,"IV Inpatient Med, skipping"
- . . S OMED=OMED+1
- . . S X=$G(@GN@(ZI,"med",ZJ,"form@value"))
- . . S FORM(X)=$G(FORM(X))+1
- . . S X=$G(@GN@(ZI,"med",ZJ,"doses.dose@dose"))
- . . I X="" S X="UNKNOWN"
- . . S DOSE(X)=$G(DOSE(X))+1
- . . S X=$G(@GN@(ZI,"med",ZJ,"doses.dose@units"))
- . . I X="" S X="UNKNOWN"
- . . S UNITS(X)=$G(UNITS(X))+1
- . . S X=$G(@GN@(ZI,"med",ZJ,"doses.dose@schedule"))
- . . I X="" S X="UNKNOWN"
- . . S SCHED(X)=$G(SCHED(X))+1
- . . S X=$G(@GN@(ZI,"med",ZJ,"doses.dosc@route"))
- . . I X="" S X="UNKNOWN"
- . . S ROUTE(X)=$G(ROUTE(X))+1
- W !,"Total number of patients: ",PATCNT
- W !,"Total number of medications: ",MEDCNT
- W !,"Total number of outpatient medications: ",OMED
- W !,"Percentage of outpatient medications: ",$P((OMED/MEDCNT)*100,".")_"%",!
- ZWR FORM
- ZWR DOSE
- ZWR UNITS
- ZWR SCHED
- ZWR ROUTE
- Q
- ;
+	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 5
+	;Copyright 2012 George Lilly.  
+	;
+	; This program is free software: you can redistribute it and/or modify
+	; it under the terms of the GNU Affero General Public License as
+	; published by the Free Software Foundation, either version 3 of the
+	; License, or (at your option) any later version.
+	;
+	; This program is distributed in the hope that it will be useful,
+	; but WITHOUT ANY WARRANTY; without even the implied warranty of
+	; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	; GNU Affero General Public License for more details.
+	;
+	; You should have received a copy of the GNU Affero General Public License
+	; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+	;
+	Q
+EN(BEGDFN,DFNCNT,ZPART)	; START IS A DFN
+	I '$D(BEGDFN) S BDGDFN=""
+	I '$D(DFNCNT) S DFNCNT=150
+	I '$D(ZPART) S ZPART=""
+	N ZTBL S ZTBL=$NA(^TMP("C0STBL"))
+	N ZI,ZCNT,ZG
+	S ZI=$O(^DPT(BEGDFN),-1)
+	S ZCNT=1
+	F  S ZI=$O(^DPT(ZI)) Q:((+ZI=0)!(ZCNT>DFNCNT))  D  ;
+	. S ZCNT=ZCNT+1
+	. W ZI," "
+	. K ZG
+	. D EN^C0SNHIN(.ZG,ZI,ZPART)
+	. M @ZTBL@(ZI)=ZG
+	. K G
+	. N GDIR S GDIR="/home/vista/p/"
+	. D EN^C0SMART(.G,ZI,"med")
+	. I $D(G) W !,$$output^C0XGET1("G",ZI_"-med.rdf",GDIR)
+	. k G
+	. D EN^C0SMART(.G,ZI,"patient")
+	. I $D(G) W !,$$output^C0XGET1("G",ZI_"-patient.rdf",GDIR)
+	. K G
+	. D EN^C0SMART(.G,ZI,"lab")
+	. I $D(G) W !,$$output^C0XGET1("G",ZI_"-lab.rdf",GDIR)
+	. K G
+	. D EN^C0SMART(.G,ZI,"problem")
+	. I $D(G) W !,$$output^C0XGET1("G",ZI_"-problem.rdf",GDIR)
+	Q
+	;
+LOADHACK	;
+	N ZI
+	F ZI=2:1:374 D  ;
+	. D IMPORT^C0XF2N("hack"_ZI_".xml","/home/vista/hack/")
+	Q
+	;
+LABCNT	; COUNT LAB TESTS AND LOINC CODES
+	K LABCNT,GLOINC,PATCNT
+	S (LABCNT,GLOINC,PATCNT)=0
+	N ZI S ZI=""
+	N GN S GN=$NA(^TMP("C0STBL"))
+	F  S ZI=$O(@GN@(ZI)) Q:ZI=""  D  ;
+	. S PATCNT=PATCNT+1
+	. I '$D(@GN@(ZI,"lab")) Q  ;
+	. N ZJ S ZJ=""
+	. F  S ZJ=$O(@GN@(ZI,"lab",ZJ)) Q:ZJ=""  D  ;
+	. . S LABCNT=LABCNT+1
+	. . S X=$G(@GN@(ZI,"lab",ZJ,"loinc@value"))
+	. . I X'="" S GLOINC=GLOINC+1
+	W !,"Total number of patients: ",PATCNT
+	W !,"Total number of lab results: ",LABCNT
+	W !,"Total number of lab results with loinc codes: ",GLOINC
+	W !,"Percentage of lab tests with loinc codes: ",$P((GLOINC/LABCNT)*100,".")_"%"
+	Q
+	;
+PROBCNT	; COUNT PROBLEMS AND SNOMED CODES
+	K PROBCNT,GSNO,PATCNT
+	S (PROBCNT,GSNO,PATCNT)=0
+	N ZI S ZI=""
+	N GN S GN=$NA(^TMP("C0STBL"))
+	F  S ZI=$O(@GN@(ZI)) Q:ZI=""  D  ;
+	. S PATCNT=PATCNT+1
+	. I '$D(@GN@(ZI,"problem")) Q  ;
+	. N ZJ S ZJ=""
+	. F  S ZJ=$O(@GN@(ZI,"problem",ZJ)) Q:ZJ=""  D  ;
+	. . S PROBCNT=PROBCNT+1
+	. . S X=$G(@GN@(ZI,"problem",ZJ,"icd@value"))
+	. . S Y=$$SNOMED^C0SPROB2(X)
+	. . I Y'="" S GSNO=GSNO+1
+	W !,"Total number of patients: ",PATCNT
+	W !,"Total number of problems: ",PROBCNT
+	W !,"Total number of problems with snomed codes: ",GSNO
+	W !,"Percentage of problems with SNOMED codes: ",$P((GSNO/PROBCNT)*100,".")_"%"
+	Q
+	;
+MEDCNT	; COUNT INPATIENT VS OUTPATIENT MEDICATIONS
+	K MEDCNT,OMED,PATCNT,DOSE,UNITS,FORM,SCHED,ROUTE
+	S (MEDCNT,OMED,GSNO,PATCNT)=0
+	N ZI S ZI=""
+	N GN S GN=$NA(^TMP("C0STBL"))
+	F  S ZI=$O(@GN@(ZI)) Q:ZI=""  D  ;
+	. S PATCNT=PATCNT+1
+	. I '$D(@GN@(ZI,"med")) Q  ;
+	. N ZJ S ZJ=""
+	. F  S ZJ=$O(@GN@(ZI,"med",ZJ)) Q:ZJ=""  D  ;
+	. . S MEDCNT=MEDCNT+1
+	. . I $G(@GN@(ZI,"med",ZJ,"vaStatus@value"))="EXPIRED" D  Q  ;
+	. . . I $D(DEBUG) W !,"Expired Mediation, Skipping"
+	. . I $G(@GN@(ZI,"med",ZJ,"vaType@value"))="I" D  Q  ;
+	. . . I $D(DEBUG) W !,"Inpatient Med, skipping"
+	. . I $G(@GN@(ZI,"med",ZI,"vaType@value"))="V" D  Q  ;
+	. . . I $D(DEBUG) W !,"IV Inpatient Med, skipping"
+	. . S OMED=OMED+1
+	. . S X=$G(@GN@(ZI,"med",ZJ,"form@value"))
+	. . S FORM(X)=$G(FORM(X))+1
+	. . S X=$G(@GN@(ZI,"med",ZJ,"doses.dose@dose"))
+	. . I X="" S X="UNKNOWN"
+	. . S DOSE(X)=$G(DOSE(X))+1
+	. . S X=$G(@GN@(ZI,"med",ZJ,"doses.dose@units"))
+	. . I X="" S X="UNKNOWN"
+	. . S UNITS(X)=$G(UNITS(X))+1
+	. . S X=$G(@GN@(ZI,"med",ZJ,"doses.dose@schedule"))
+	. . I X="" S X="UNKNOWN"
+	. . S SCHED(X)=$G(SCHED(X))+1
+	. . S X=$G(@GN@(ZI,"med",ZJ,"doses.dosc@route"))
+	. . I X="" S X="UNKNOWN"
+	. . S ROUTE(X)=$G(ROUTE(X))+1
+	W !,"Total number of patients: ",PATCNT
+	W !,"Total number of medications: ",MEDCNT
+	W !,"Total number of outpatient medications: ",OMED
+	W !,"Percentage of outpatient medications: ",$P((OMED/MEDCNT)*100,".")_"%",!
+	ZWR FORM
+	ZWR DOSE
+	ZWR UNITS
+	ZWR SCHED
+	ZWR ROUTE
+	Q
+	;
Index: smart/trunk/p/C0SUTIL.m
===================================================================
--- smart/trunk/p/C0SUTIL.m	(revision 1590)
+++ smart/trunk/p/C0SUTIL.m	(revision 1591)
@@ -1,20 +1,18 @@
 C0SUTIL	  ; GPL - Smart Processing Utilities ;2/22/12  17:05
-	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 4
-	;Copyright 2012 George Lilly.  Licensed under the terms of the GNU
-	;General Public License See attached copy of the License.
+	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 5
+	;Copyright 2012 George Lilly.  
 	;
-	;This program is free software; you can redistribute it and/or modify
-	;it under the terms of the GNU General Public License as published by
-	;the Free Software Foundation; either version 2 of the License, or
-	;(at your option) any later version.
+	; This program is free software: you can redistribute it and/or modify
+	; it under the terms of the GNU Affero General Public License as
+	; published by the Free Software Foundation, either version 3 of the
+	; License, or (at your option) any later version.
 	;
-	;This program is distributed in the hope that it will be useful,
-	;but WITHOUT ANY WARRANTY; without even the implied warranty of
-	;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	;GNU General Public License for more details.
+	; This program is distributed in the hope that it will be useful,
+	; but WITHOUT ANY WARRANTY; without even the implied warranty of
+	; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	; GNU Affero General Public License for more details.
 	;
-	;You should have received a copy of the GNU General Public License along
-	;with this program; if not, write to the Free Software Foundation, Inc.,
-	;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+	; You should have received a copy of the GNU Affero General Public License
+	; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 	;
 	Q
Index: smart/trunk/p/C0SXPATH.m
===================================================================
--- smart/trunk/p/C0SXPATH.m	(revision 1590)
+++ smart/trunk/p/C0SXPATH.m	(revision 1591)
@@ -1,20 +1,18 @@
 C0SXPATH	  ; CCDCCR/GPL - XPATH XML manipulation utilities; 6/1/08 ; 9/26/12 10:45am
-	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 4
-	;Copyright 2008-2012 George Lilly.  Licensed under the terms of the GNU
-	;General Public License See attached copy of the License.
-	;
-	;This program is free software; you can redistribute it and/or modify
-	;it under the terms of the GNU General Public License as published by
-	;the Free Software Foundation; either version 2 of the License, or
-	;(at your option) any later version.
-	;
-	;This program is distributed in the hope that it will be useful,
-	;but WITHOUT ANY WARRANTY; without even the implied warranty of
-	;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	;GNU General Public License for more details.
-	;
-	;You should have received a copy of the GNU General Public License along
-	;with this program; if not, write to the Free Software Foundation, Inc.,
-	;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+	;;1.0;VISTA SMART CONTAINER;;Sep 26, 2012;Build 5
+	;Copyright 2008-2012 George Lilly.  
+	;
+	; This program is free software: you can redistribute it and/or modify
+	; it under the terms of the GNU Affero General Public License as
+	; published by the Free Software Foundation, either version 3 of the
+	; License, or (at your option) any later version.
+	;
+	; This program is distributed in the hope that it will be useful,
+	; but WITHOUT ANY WARRANTY; without even the implied warranty of
+	; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	; GNU Affero General Public License for more details.
+	;
+	; You should have received a copy of the GNU Affero General Public License
+	; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 	;
 	W "This is an XML XPATH utility library",!
