source: ccr/trunk/p/CCRMEDS.m@ 102

Last change on this file since 102 was 101, checked in by Sam Habiel, 16 years ago

First stab at CCRMEDS to replace GPLMEDS; Refactoring of GPLMEDS.

File size: 4.3 KB
Line 
1CCRMEDS ; WV/CCDCCR/SMH,CJE,GPL - CCR/CCD PROCESSING FOR MEDICATIONS ;08/24/08
2 ;;0.1;CCDCCR;;JUL 16,2008;
3 ; Copyright 2008 WorldVistA. 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 W "NO ENTRY FROM TOP",!
21 Q
22 ;
23EXTRACT(INXML,DFN,OUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
24 ;
25 ; INXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
26 ; INXML WILL CONTAIN ONLY THE MEDICATIONS SECTION OF THE OVERALL TEMPLATE
27 ;
28 ; MEDS is return array from RPC.
29 ; MAP is a mapping variable map (store result) for each med
30 ; MED is holds each array element from MEDS(J), one medicine
31 ; J is a counter.
32 ;
33 ; RX^PSO52API is a Pharmacy Re-Enginnering (PRE) API to get all
34 ; med data available.
35 ; http://www.va.gov/vdl/documents/Clinical/Pharm-Outpatient_Pharmacy/phar_1_api_r0807.pdf
36 ; Output of API is ^TMP($J,"SUBSCRIPT",DFN,RXIENS).
37
38 N MEDS,MAP
39 K ^TMP($J)
40 D RX^PSO52API(DFN,"CCDCCR")
41 M MEDS=^TMP($J,"CCDCCR",DFN)
42 ; @(0) contains the number of meds.
43 ; If there are no meds (@(0)=0), we quit.
44 I 'MEDS(0) S @OUTXML@(0)=0 QUIT
45 I DEBUG ZWR MEDS
46 N RXIEN S RXIEN=0
47 F S RXIEN=$O(MEDS(RXIEN)) Q:RXIEN="" D ; FOR EACH MEDICATION IN THE LIST
48 . I DEBUG W "RXIEN IS ",RXIEN,!
49 . S MAP=$NA(^TMP("GPLCCR",$J,"MEDMAP",J))
50 . K @MAP
51 . I DEBUG W "MAP= ",MAP,!
52 . N MED M MED=MEDS(RXIEN) ; PULL OUT MEDICATION FROM
53 . S @MAP@("MEDOBJECTID")="MED"_MED(.01) ;Rx Number
54 . S @MAP@("MEDISSUEDATETXT")
55 . S @MAP@("MEDISSUEDATE")
56 . S @MAP@("MEDLASTFILLDATETXT")
57 . S @MAP@("MEDLASTFILLDATE")
58 . S @MAP@("MEDRXNOTXT")
59 . S @MAP@("MEDRXNO")
60 . S @MAP@("MEDTYPETEXT")
61 . S @MAP@("MEDDETAILUNADORNED")
62 . S @MAP@("MEDSTATUSTEXT")
63 . S @MAP@("MEDSOURCEACTORID")
64 . S @MAP@("MEDPRODUCTNAMETEXT")
65 . S @MAP@("MEDPRODUCTNAMECODEVALUE")
66 . S @MAP@("MEDPRODUCTNAMECODINGINGSYSTEM")
67 . S @MAP@("MEDPRODUCTNAMECODEVERSION")
68 . S @MAP@("MEDBRANDNAMETEXT")
69 . S @MAP@("MEDSTRENGTHVALUE")
70 . S @MAP@("MEDSTRENGTHUNIT")
71 . S @MAP@("MEDFORMTEXT")
72 . S @MAP@("MEDCONCVALUE")
73 . S @MAP@("MEDCONCUNIT")
74 . S @MAP@("MEDSIZETEXT")
75 . S @MAP@("MEDQUANTITYVALUE")
76 . S @MAP@("MEDQUANTITYUNIT")
77 . S @MAP@("MEDDIRECTIONDESCRIPTIONTEXT")
78 . S @MAP@("MEDDOSEINDICATOR")
79 . S @MAP@("MEDDELIVERYMETHOD")
80 . S @MAP@("MEDDOSEVALUE")
81 . S @MAP@("MEDDOSEUNIT")
82 . S @MAP@("MEDRATEVALUE")
83 . S @MAP@("MEDRATEUNIT")
84 . S @MAP@("MEDVEHICLETEXT")
85 . S @MAP@("MEDDIRECTIONROUTETEXT")
86 . S @MAP@("MEDFREQUENCYVALUE")
87 . S @MAP@("MEDFREQUENCYUNIT")
88 . S @MAP@("MEDINTERVALVALUE")
89 . S @MAP@("MEDINTERVALUNIT")
90 . S @MAP@("MEDDURATIONVALUE")
91 . S @MAP@("MEDDURATIONUNIT")
92 . S @MAP@("MEDPRNFLAG")
93 . S @MAP@("MEDPROBLEMOBJECTID")
94 . S @MAP@("MEDPROBLEMDESCRIPTION")
95 . S @MAP@("MEDPROBLEMCODEVALUE")
96 . S @MAP@("MEDPROBLEMCODINGSYSTEM")
97 . S @MAP@("MEDPROBLEMCODINGVERSION")
98 . S @MAP@("MEDPROBLEMSOURCEACTORID")
99 . S @MAP@("MEDSTOPINDICATOR")
100 . S @MAP@("MEDDIRSEQ")
101 . S @MAP@("MEDMULDIRMOD")
102 . S @MAP@("MEDPTINSTRUCTIONS")
103 . S @MAP@("MEDFULLFILLMENTINSTRUCTIONS")
104 . S @MAP@("MEDRFNO")
105 . N RESULT S RESULT=$NA(^TMP("GPLCCR",$J,"RESULT",J))
106 . K @RESULT
107 . D MAP^GPLXPATH(INXML,MAP,RESULT)
108 . D:J=1 CP^GPLXPATH(RESULT,OUTXML) ; First one is a copy
109 . D:J>1 INSINNER^GPLXPATH(OUTXML,RESULT) ; AFTER THE FIRST, INSERT INNER XML
110 N MEDTMP,MEDI
111 D MISSING^GPLXPATH(OUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS
112 I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
113 . W "MEDICATION MISSING ",!
114 . F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),!
115 Q
116 ;
Note: See TracBrowser for help on using the repository browser.