source: ccr/trunk/p/GPLMEDS.m@ 110

Last change on this file since 110 was 110, checked in by George Lilly, 16 years ago

more meds debugging

File size: 4.2 KB
Line 
1GPLMEDS ; CCDCCR/CJE - CCR/CCD PROCESSING FOR MEDICATIONS ;07/23/08 14:33
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(MEDXML,DFN,MEDOUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
24 ;
25 ; MEDXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
26 ; IMEDXML WILL CONTAIN ONLY THE MEDICATIONS SECTION OF THE OVERALL TEMPLATE
27 ;
28 N MEDRSLT,I,J,K,MEDPTMP,X,MEDVMAP,TBUF
29 D ACTIVE^ORWPS(.MEDRSLT,DFN)
30 I '$D(MEDRSLT(1)) D ; NO MEDS FOR THIS PATIENT, EXIT
31 . W "ERROR RUNNINIG MEDICATIONS RPC",!
32 . S @MEDOUTXML@(0)=0
33 . Q
34 I DEBUG ZWR MEDRSLT
35 M GPLMEDS=MEDRSLT
36 S MEDTVMAP=$NA(^TMP("GPLCCR",$J,"MEDICATIONS"))
37 S MEDTARYTMP=$NA(^TMP("GPLCCR",$J,"MEDARYTMP"))
38 K @MEDTVMAP,@MEDTARYTMP
39 N DONE S DONE=0
40 F J=1:3 Q:'$D(MEDRSLT(J))!DONE D ; FOR EACH MEDICATION IN THE LIST
41 . I DEBUG W "J IS ",J,!
42 . S MEDVMAP=$NA(@MEDTVMAP@(J))
43 . K @MEDVMAP
44 . I DEBUG W "VMAP= ",MEDVMAP,!
45 . S MEDPTMP=MEDRSLT(J) ; PULL OUT MEDICATION FROM RPC RETURN ARRAY
46 . S @MEDVMAP@("MEDOBJECTID")="MED"_J ; UNIQUE OBJID FOR MEDS
47 . ; PROCESSING FOR MEDS GOES HERE
48 . S @MEDVMAP@("MEDISSUEDATETXT")=$$FMDTOUTC^CCRUTIL($P(MEDPTMP,"^",11),"DT") ; GETS LAST FILL DATE
49 . S @MEDVMAP@("MEDDATETIMEAGE")=""
50 . S @MEDVMAP@("MEDDATETIMEAGEUNITS")=""
51 . S @MEDVMAP@("MEDTYPETEXT")="Medication"
52 . S @MEDVMAP@("MEDSTATUSTEXT")=$P(MEDPTMP,"^",10) ; STATUS FROM RPC
53 . S @MEDVMAP@("MEDSOURCEACTORID")="ACTORSYSTEM_1"
54 . S @MEDVMAP@("MEDPRODUCTNAMETEXT")=$P(MEDPTMP,"^",3)
55 . S @MEDVMAP@("MEDPRODUCTNAMECODEVALUE")=""
56 . S @MEDVMAP@("MEDPRODUCTNAMECODINGINGSYSTEM")=""
57 . S @MEDVMAP@("MEDPRODUCTNAMECODEVERSION")=""
58 . S @MEDVMAP@("MEDBRANDNAMETEXT")=""
59 . S @MEDVMAP@("MEDBRANDNAMECODEVALUE")=""
60 . S @MEDVMAP@("MEDBRANDNAMECODINGSYSTEM")=""
61 . S @MEDVMAP@("MEDBRANDNAMECODEVERSION")=""
62 . S @MEDVMAP@("MEDSTRENGTHVALUE")=""
63 . S @MEDVMAP@("MEDSTRENGTHUNIT")=""
64 . S @MEDVMAP@("MEDFORMTEXT")=""
65 . S @MEDVMAP@("MEDQUANTITYVALUE")=""
66 . S @MEDVMAP@("MEDQUANTITYUNIT")=""
67 . S @MEDVMAP@("MEDRFNO")=""
68 . I $D(MEDRSLT(J+1)) D ; IF SECOND LINE EXISTS
69 . . S @MEDVMAP@("MEDDESCRIPTIONTEXT")=$P(MEDRSLT(J+1)," *",2)
70 . I $D(MEDRSLT(J+2)) D ; IF THIRD LINE EXISTS
71 . . S @MEDVMAP@("MEDDIRECTIONDESCRIPTIONTEXT")=$P(MEDRSLT(J+2),"\ Sig: ",2)
72 . I $D(MEDRSLT(J+3)) D ; IF THERE IS ANOTHER LINE
73 . . I MEDRSLT(J+3)?1"t".E D ; CONTINUATION LINES
74 . . . I $D(MEDRSLT(J+6)) D ;
75 . . . . S J=J=3 ; SKIP THREE LINES TO NEXT MED
76 . . . E S DONE=1 ; ELSE NO MORE MEDS
77 . S @MEDVMAP@("MEDDOSEVALUE")=""
78 . S @MEDVMAP@("MEDDOSEUNIT")=""
79 . S @MEDVMAP@("MEDFREQUENCYVALUE")=""
80 . S @MEDVMAP@("MEDDURATIONVALUE")=""
81 . S @MEDVMAP@("MEDDURATIONUNIT")=""
82 . S @MEDVMAP@("MEDDIRECTIONROUTETEXT")=""
83 . S @MEDVMAP@("MEDDIRECTIONFREQUENCYVALUE")=""
84 . S MEDARYTMP=$NA(@MEDTARYTMP@(J))
85 . K @MEDARYTMP
86 . D MAP^GPLXPATH(MEDXML,MEDVMAP,MEDARYTMP)
87 . I J=1 D ; FIRST ONE IS JUST A COPY
88 . . ; W "FIRST ONE",!
89 . . D CP^GPLXPATH(MEDARYTMP,MEDOUTXML)
90 . I J>1 D ; AFTER THE FIRST, INSERT INNER XML
91 . . D INSINNER^GPLXPATH(MEDOUTXML,MEDARYTMP)
92 N MEDTMP,MEDI
93 D MISSING^GPLXPATH(MEDOUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS
94 I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
95 . W "MEDICATION MISSING ",!
96 . F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),!
97 Q
98 ;
Note: See TracBrowser for help on using the repository browser.