source: ccr/trunk/p/C0CMED.m@ 1767

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

Changed license to AGPL. Some clean-up for XINDEX

  • Property svn:mergeinfo set to (toggle deleted branches)
    /ccr/branches/ohum/o-old/p/C0CMED.m1290
    /ccr/branches/ohum/p/C0CMED.m1291-1543
    /ccr/branches/ohum/p/p/C0CMED.m1287-1289
File size: 4.7 KB
Line 
1C0CMED ; WV/CCDCCR/GPL/SMH - CCR/CCD Medications Driver; Mar 23 2009
2 ;;1.2;CCD/CCR GENERATION UTILITIES;;Oct 30, 2012;Build 50
3 ; Copyright 2008,2009 George Lilly, University of Minnesota and Sam Habiel.
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 ;
19 ; --Revision History
20 ; July 2008 - Initial Version/GPL
21 ; July 2008 - March 2009 various revisions
22 ; March 2009 - Reconstruction of routine as driver for other med routines/SMH
23 ;
24 Q
25EXTRACT(MEDXML,DFN,MEDOUTXML) ; Private; Extract medications into provided XML template
26 ; DFN passed by reference
27 ; MEDXML and MEDOUTXML are passed by Name
28 ; MEDXML is the input template
29 ; MEDOUTXML is the output template
30 ; Both of them refer to ^TMP globals where the XML documents are stored
31 ;
32 ; -- This ep is the driver for extracting medications into the provided XML template
33 ; 1. VA Outpatient Meds are in C0CMED1
34 ; 2. VA Pending Meds are in C0CMED2
35 ; 3. VA non-VA Meds are in C0CMED3
36 ; 4. VA Inpatient IV Meds are in C0CMED4 (not functional)
37 ; 5. VA Inpatient UD Meds are in C0CMED5 (doesn't exist yet)--March 2009
38 ; 6. RPMS Meds are in C0CMED6. Need to create other routines for subdivisions of RPMS Meds is not known at this time.
39 ;
40 ; --Get parameters for meds
41 S @MEDOUTXML@(0)=0 ; By default, empty.
42 N C0CMFLAG
43 S C0CMFLAG=$$GET^C0CPARMS("MEDALL")_"^"_$$GET^C0CPARMS("MEDLIMIT")_"^"_$$GET^C0CPARMS("MEDACTIVE")_"^"_$$GET^C0CPARMS("MEDPENDING")
44 W:$G(DEBUG) "Med Parameters: ",!
45 W:$G(DEBUG) "ALL: ",+C0CMFLAG,!
46 W:$G(DEBUG) "LIMIT: ",$P(C0CMFLAG,U,2),!
47 W:$G(DEBUG) "ACTIVE: ",$P(C0CMFLAG,U,3),!
48 W:$G(DEBUG) "PEND: ",$P(C0CMFLAG,U,4),!
49 ; --Find out what system we are on and branch out...
50 W:$G(DEBUG) "Agenecy: ",$G(DUZ("AG"))
51 I $$RPMS^C0CUTIL() D RPMS QUIT
52 I ($$VISTA^C0CUTIL())!($$WV^C0CUTIL())!($$OV^C0CUTIL()) D VISTA QUIT
53RPMS ;
54 ;D EXTRACT^C0CMED6(MEDXML,DFN,MEDOUTXML,C0CMFLAG) QUIT
55 N MEDCOUNT S MEDCOUNT=0
56 K ^TMP($J,"MED")
57 N HIST S HIST=$NA(^TMP($J,"MED","HIST")) ; Meds already dispensed
58 N NVA S NVA=$NA(^TMP($J,"MED","NVA")) ; non-VA Meds
59 S @HIST@(0)=0,@NVA@(0)=0 ; At first, they are all empty... (prevent undefined errors)
60 D EXTRACT^C0CMED6(MEDXML,DFN,HIST,.MEDCOUNT,C0CMFLAG) ; Historical OP Meds
61 D:+C0CMFLAG EXTRACT^C0CMED3(MEDXML,DFN,NVA,.MEDCOUNT) ; non-VA Meds
62 I @HIST@(0)>0 D
63 . D CP^C0CXPATH(HIST,MEDOUTXML)
64 . W:$G(DEBUG) "HAS ACTIVE OP MEDS",!
65 I @NVA@(0)>0 D
66 . I @HIST@(0)>0 D INSINNER^C0CXPATH(MEDOUTXML,NVA)
67 . ;E D CP^C0CXPATH(NVA,MEDOUTXML)
68 . W:$G(DEBUG) "HAS NON-VA MEDS",!
69 Q
70VISTA ;
71 N MEDCOUNT S MEDCOUNT=0
72 K ^TMP($J,"MED")
73 N HIST S HIST=$NA(^TMP($J,"MED","HIST")) ; Meds already dispensed
74 N PEND S PEND=$NA(^TMP($J,"MED","PEND")) ; Pending Meds
75 N NVA S NVA=$NA(^TMP($J,"MED","NVA")) ; non-VA Meds
76 K @HIST K @PEND K @NVA ; MAKE SURE THEY ARE EMPTY
77 S @HIST@(0)=0,@PEND@(0)=0,@NVA@(0)=0 ; At first, they are all empty... (prevent undefined errors)
78 ; N IPIV ; Inpatient IV Meds
79 N IPUD S IPUD=$NA(^TMP($J,"MED","IPUD")) ; Inpatient UD Meds
80 K @IPUD
81 S @IPUD@(0)=0
82 ;
83 D EXTRACT^C0CMED1(MEDXML,DFN,HIST,.MEDCOUNT,C0CMFLAG) ; Historical OP Meds
84 D:$P(C0CMFLAG,U,4) EXTRACT^C0CMED2(MEDXML,DFN,PEND,.MEDCOUNT) ; Pending Meds
85 ;D:+C0CMFLAG EXTRACT^C0CMED3(MEDXML,DFN,NVA,.MEDCOUNT) ; non-VA Meds
86 D EXTRACT^C0CMED3(MEDXML,DFN,NVA,.MEDCOUNT) ; non-VA Meds GPL
87 D EXTRACT^C0CNMED4(MEDXML,DFN,IPUD,.MEDCOUNT) ; inpatient gpl
88 I @HIST@(0)>0 D
89 . D CP^C0CXPATH(HIST,MEDOUTXML)
90 . W:$G(DEBUG) "HAS ACTIVE OP MEDS",!
91 I @PEND@(0)>0 D
92 . I @HIST@(0)>0 D INSINNER^C0CXPATH(MEDOUTXML,PEND) ;Add Pending to Historical
93 . E D CP^C0CXPATH(PEND,MEDOUTXML) ; No historical, just copy
94 . W:$G(DEBUG) "HAS OP PENDING MEDS",!
95 I @NVA@(0)>0 D
96 . I @HIST@(0)>0!(@PEND@(0)>0) D INSINNER^C0CXPATH(MEDOUTXML,NVA)
97 . E D CP^C0CXPATH(NVA,MEDOUTXML)
98 . W:$G(DEBUG) "HAS NON-VA MEDS",!
99 I @IPUD@(0)>0 D
100 . I @HIST@(0)>0!(@PEND@(0)>0)!(@NVA@(0)>0) D INSINNER^C0CXPATH(MEDOUTXML,IPUD)
101 . E D CP^C0CXPATH(IPUD,MEDOUTXML)
102 . W:$G(DEBUG) "HAS INPATIENT MEDS",!
103 N ZI
104 S ZI=$NA(^TMP("C0CCCR",$J,"MEDMAP"))
105 M ^TMP("C0CRIM","VARS",DFN,"MEDS")=@ZI ; PERSIST MEDS VARIABLES
106 K @ZI ; CLEAN UP MED MAP AFTER - GPL 10/10
107 K @PEND
108 K @HIST
109 K @NVA
110 K @IPUD
111 Q
Note: See TracBrowser for help on using the repository browser.