VistA-ccr/p/GPLMEDS.m

80 lines
3.9 KiB
Mathematica
Raw Normal View History

GPLMEDS ; CCDCCR/CJE - CCR/CCD PROCESSING FOR MEDICATIONS ; 07/16/08
2008-07-16 14:42:13 -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.
;
W "NO ENTRY FROM TOP",!
W !
Q
;
2008-07-16 14:42:13 -04:00
EXTRACT(MEDXML,DFN,MEDOUTXML) ; EXTRACT MEDICATIONS INTO PROVIDED XML TEMPLATE
;
; MEDXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
; IMEDXML WILL CONTAIN ONLY THE MEDICATIONS SECTION OF THE OVERALL TEMPLATE
;
N MEDRSLT,J,K,MEDPTMP,X,MEDVMAP,TBUF
D ACTIVE^ORWPS(.MEDRSLT,DFN)
ZWR MEDRSLT
Q
2008-07-16 14:42:13 -04:00
I '$D(MEDRSLT(1)) W "ERROR RUNNINIG MEDICATIONS RPC",! Q
S MEDTVMAP=$NA(^TMP("GPLCCR",$J,"MEDICATIONS"))
S MEDTARYTMP=$NA(^TMP("GPLCCR",$J,"MEDARYTMP"))
F J=1:1 Q:'$D(MEDRSLT(J)) D ; FOR EACH MEDICATION IN THE LIST
. S MEDVMAP=$NA(@MEDTVMAP@(J))
. K @MEDVMAP
. I DEBUG W "VMAP= ",VMAP,!
. S MEDPTMP=MEDRSLT(J) ; PULL OUT MEDICATION FROM RPC RETURN ARRAY
. S @MEDVMAP@("MEDICATIONOBJECTID")="MED"_J ; UNIQUE OBJID FOR MEDICATION
. ; PROCESSING FOR MEDS GOES HERE
. S @MEDVMAP@("MEDICATIONDATETIMETEXT")=$$FMDTOUTC^CCRUTIL($P(MEDPTMP,"^",11),"DT")
. S @MEDVMAP@("MEDICATIONDATETIMEAGE")="TEST2"
. S @MEDVMAP@("MEDICATIONDATETIMEAGEUNITS")="TEST3"
. S @MEDVMAP@("MEDICATIONTYPETEXT")="TEST4"
. S @MEDVMAP@("MEDICATIONSTATUSTEXT")=$P(MEDPTMP,"^",10)
. S @MEDVMAP@("MEDICATIONSOURCEACTORID")="TEST6"
. S @MEDVMAP@("MEDICATIONPRODUCTNAMETEXT")="TEST7"
. S @MEDVMAP@("MEDICATIONPRODUCTNAMECODEVALUE")="TEST8"
. S @MEDVMAP@("MEDICATIONPRODUCTNAMECODINGINGSYSTEM")="TEST9"
. S @MEDVMAP@("MEDICATIONPRODUCTNAMECODEVERSION")="TEST10"
. S @MEDVMAP@("MEDICATIONBRANDNAMETEXT")="TEST11"
. S @MEDVMAP@("MEDICATIONBRANDNAMECODEVALUE")="TEST12"
. S @MEDVMAP@("MEDICATIONBRANDNAMECODINGSYSTEM")="TEST13"
. S @MEDVMAP@("MEDICATIONBRANDNAMECODEVERSION")="TEST14"
. S @MEDVMAP@("MEDICATIONSTRENGTHVALUE")="TEST15"
. S @MEDVMAP@("MEDICATIONSTRENGTHUNIT")="TEST16"
. S @MEDVMAP@("MEDICATIONFORMTEXT")="TEST17"
. S @MEDVMAP@("MEDICATIONDIRECTIONDESCRIPTIONTEXT")="TEST18"
. S @MEDVMAP@("MEDICATIONDIRECTIONDOSEVALUE")="TEST19"
. S @MEDVMAP@("MEDICATIONDIRECTIONROUTETEXT")="TEST20"
. S @MEDVMAP@("MEDICATIONDIRECTIONFREQUENCYVALUE")="TEST21"
. S J=J+3
. 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)
2008-07-16 14:42:13 -04:00
N MEDTMP,I
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 I=1:1:MEDTMP(0) W MEDTMP(I),!
Q
;