2008-07-23 15:16:41 -04:00
|
|
|
GPLMEDS ; CCDCCR/CJE - CCR/CCD PROCESSING FOR MEDICATIONS ;07/23/08 14:33
|
2008-08-06 19:18:51 -04:00
|
|
|
;;0.1;CCDCCR;;JUL 16,2008;
|
|
|
|
;Copyright 2008 WorldVistA. 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.
|
|
|
|
;
|
2008-08-17 00:49:12 -04:00
|
|
|
W "NO ENTRY FROM TOP",!
|
|
|
|
Q
|
|
|
|
;
|
2008-07-23 15:16:41 -04:00
|
|
|
EXTRACT(MEDXML,DFN,MEDOUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
|
2008-08-06 19:18:51 -04:00
|
|
|
;
|
|
|
|
; MEDXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
|
|
|
|
; IMEDXML WILL CONTAIN ONLY THE MEDICATIONS SECTION OF THE OVERALL TEMPLATE
|
|
|
|
;
|
2008-08-17 00:49:12 -04:00
|
|
|
N MEDRSLT,I,J,K,MEDPTMP,X,MEDVMAP,TBUF
|
|
|
|
D ACTIVE^ORWPS(.MEDRSLT,DFN)
|
|
|
|
I '$D(MEDRSLT(1)) D ; NO MEDS FOR THIS PATIENT, EXIT
|
|
|
|
. W "ERROR RUNNINIG MEDICATIONS RPC",!
|
|
|
|
. S @MEDOUTXML@(0)=0
|
|
|
|
. Q
|
2008-08-19 16:50:47 -04:00
|
|
|
I DEBUG ZWR MEDRSLT
|
2008-08-17 00:49:12 -04:00
|
|
|
S MEDTVMAP=$NA(^TMP("GPLCCR",$J,"MEDICATIONS"))
|
|
|
|
S MEDTARYTMP=$NA(^TMP("GPLCCR",$J,"MEDARYTMP"))
|
2008-08-19 19:52:17 -04:00
|
|
|
K @MEDTVMAP,@MEDTARYTMP
|
2008-08-17 00:49:12 -04:00
|
|
|
F J=1:3 Q:'$D(MEDRSLT(J)) D ; FOR EACH MEDICATION IN THE LIST
|
2008-08-19 16:50:47 -04:00
|
|
|
. I DEBUG W "J IS ",J,!
|
2008-08-17 00:49:12 -04:00
|
|
|
. S MEDVMAP=$NA(@MEDTVMAP@(J))
|
|
|
|
. K @MEDVMAP
|
2008-08-19 16:54:52 -04:00
|
|
|
. I DEBUG W "VMAP= ",MEDVMAP,!
|
2008-08-17 00:49:12 -04:00
|
|
|
. S MEDPTMP=MEDRSLT(J) ; PULL OUT MEDICATION FROM RPC RETURN ARRAY
|
2008-08-28 11:53:50 -04:00
|
|
|
. S @MEDVMAP@("MEDOBJECTID")="MED"_J ; UNIQUE OBJID FOR MEDS
|
2008-08-17 00:49:12 -04:00
|
|
|
. ; PROCESSING FOR MEDS GOES HERE
|
2008-08-19 16:50:47 -04:00
|
|
|
. S @MEDVMAP@("MEDISSUEDATETXT")=$$FMDTOUTC^CCRUTIL($P(MEDPTMP,"^",11),"DT") ; GETS LAST FILL DATE
|
2008-08-28 11:53:50 -04:00
|
|
|
. S @MEDVMAP@("MEDDATETIMEAGE")=""
|
|
|
|
. S @MEDVMAP@("MEDDATETIMEAGEUNITS")=""
|
2008-08-19 16:50:47 -04:00
|
|
|
. S @MEDVMAP@("MEDTYPETEXT")="Medication"
|
|
|
|
. S @MEDVMAP@("MEDSTATUSTEXT")=$P(MEDPTMP,"^",10) ; STATUS FROM RPC
|
|
|
|
. S @MEDVMAP@("MEDSOURCEACTORID")="ACTORSYSTEM_1"
|
|
|
|
. S @MEDVMAP@("MEDPRODUCTNAMETEXT")=$P(MEDPTMP,"^",3)
|
2008-08-28 11:53:50 -04:00
|
|
|
. S @MEDVMAP@("MEDPRODUCTNAMECODEVALUE")=""
|
|
|
|
. S @MEDVMAP@("MEDPRODUCTNAMECODINGINGSYSTEM")=""
|
|
|
|
. S @MEDVMAP@("MEDPRODUCTNAMECODEVERSION")=""
|
2008-08-19 16:50:47 -04:00
|
|
|
. S @MEDVMAP@("MEDBRANDNAMETEXT")=""
|
2008-08-28 11:53:50 -04:00
|
|
|
. S @MEDVMAP@("MEDBRANDNAMECODEVALUE")=""
|
|
|
|
. S @MEDVMAP@("MEDBRANDNAMECODINGSYSTEM")=""
|
|
|
|
. S @MEDVMAP@("MEDBRANDNAMECODEVERSION")=""
|
2008-08-19 16:50:47 -04:00
|
|
|
. S @MEDVMAP@("MEDSTRENGTHVALUE")=""
|
|
|
|
. S @MEDVMAP@("MEDSTRENGTHUNIT")=""
|
|
|
|
. S @MEDVMAP@("MEDFORMTEXT")=""
|
|
|
|
. S @MEDVMAP@("MEDQUANTITYVALUE")=""
|
|
|
|
. S @MEDVMAP@("MEDQUANTITYUNIT")=""
|
|
|
|
. S @MEDVMAP@("MEDRFNO")=""
|
2008-08-26 23:57:10 -04:00
|
|
|
. I $D(MEDRSLT(J+1)) D ; IF SECOND LINE EXISTS
|
2008-08-28 11:53:50 -04:00
|
|
|
. . S @MEDVMAP@("MEDDESCRIPTIONTEXT")=$P(MEDRSLT(J+1)," *",2)
|
2008-08-26 23:57:10 -04:00
|
|
|
. I $D(MEDRSLT(J+2)) D ; IF THIRD LINE EXISTS
|
|
|
|
. . S @MEDVMAP@("MEDDIRECTIONDESCRIPTIONTEXT")=$P(MEDRSLT(J+2),"\ Sig: ",2)
|
2008-08-28 11:53:50 -04:00
|
|
|
. S @MEDVMAP@("MEDDIRECTIONDOSEVALUE")=""
|
|
|
|
. S @MEDVMAP@("MEDDIRECTIONROUTETEXT")=""
|
|
|
|
. S @MEDVMAP@("MEDDIRECTIONFREQUENCYVALUE")=""
|
2008-08-17 00:49:12 -04:00
|
|
|
. S MEDARYTMP=$NA(@MEDTARYTMP@(J))
|
|
|
|
. K @MEDARYTMP
|
|
|
|
. D MAP^GPLXPATH(MEDXML,MEDVMAP,MEDARYTMP)
|
|
|
|
. I J=1 D ; FIRST ONE IS JUST A COPY
|
|
|
|
. . ; W "FIRST ONE",!
|
|
|
|
. . D CP^GPLXPATH(MEDARYTMP,MEDOUTXML)
|
|
|
|
. I J>1 D ; AFTER THE FIRST, INSERT INNER XML
|
|
|
|
. . D INSINNER^GPLXPATH(MEDOUTXML,MEDARYTMP)
|
|
|
|
N MEDTMP,MEDI
|
|
|
|
D MISSING^GPLXPATH(MEDOUTXML,"MEDTMP") ; SEARCH XML FOR MISSING VARS
|
|
|
|
I MEDTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
|
|
|
|
. W "MEDICATION MISSING ",!
|
|
|
|
. F MEDI=1:1:MEDTMP(0) W MEDTMP(MEDI),!
|
|
|
|
Q
|
|
|
|
;
|