VistA-ccr/p/GPLALERT.m

66 lines
3.2 KiB
Mathematica
Raw Normal View History

2008-09-11 22:54:27 -04:00
GPLALERT ; CCDCCR/CKU - CCR/CCD PROCESSING FOR ALERTS ; 09/11/08
;;0.1;CCDCCR;;SEP 11,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",!
Q
;
EXTRACT(ALTXML,DFN,ALTOUTXML) ; EXTRACT ALERTS INTO PROVIDED XML TEMPLATE
;
; ALTXML AND ALTOUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
2008-09-11 22:54:27 -04:00
;
; GET ADVERSE REACTIONS AND ALLERGIES
N GMRA,GMRAL S GMRA="0^0^111"
D EN1^GMRADPT
I $G(GMRAL)'=1 D Q ; NO ALLERGIES FOUND THUS *QUIT*
. S @ALTOUTXML@(0)=0
; DEFINE MAPPING
N ALTTVMAP,ALTVMAP,ALTTARYTMP,ALTARYTMP
S ALTTVMAP=$NA(^TMP("GPLALERT",$J,"ALERTS"))
S ALTTARYTMP=$NA(^TMP("GPLALERT",$J,"ALERTSARYTMP"))
K @ALTTVMAP,@ALTTARYTMP
N ALTTMP,ALTCNT S ALTTMP=$NA(GMRAL),ALTCNT=1
F S ALTTMP=$Q(@ALTTMP) Q:ALTTMP="" D
. I $QS(ALTTMP,2)="S" W !,"S FOUND",! Q
. S ALTVMAP=$NA(@ALTTVMAP@(ALTCNT))
. K @ALTVMAP
. S @ALTVMAP@("ALERTOBJECTID")="ALERT"_ALTCNT
. N ALERTDESCRIPTIONTEXT S ALERTDESCRIPTIONTEXT="Patient has an " ; X $ZINT H 5
. S ALERTDESCRIPTIONTEXT=ALERTDESCRIPTIONTEXT_$S($P(@ALTTMP,U,4)=1:"ADVERSE",$P(@ALTTMP,U,5)=1:"ALLERGIC",1:"UNKNOWN")
. S ALERTDESCRIPTIONTEXT=ALERTDESCRIPTIONTEXT_" reaction to "_$P(@ALTTMP,U,2)_"."
. S @ALTVMAP@("ALERTDESCRIPTIONTEXT")=ALERTDESCRIPTIONTEXT
. S @ALTVMAP@("ALERTCODEVALUE")="ALERT CODE VALUE"
. S @ALTVMAP@("ALERTCODESYSTEM")="ALERT CODE SYSTEM"
. S @ALTVMAP@("ALERTSTATUSTEXT")="ALERT STATUS TEXT"
. S @ALTVMAP@("ALERTSOURCEID")="ALERT SOURCE ID"
. S @ALTVMAP@("ALERTAGENTPRODUCTOBJECTID")="ALERT AGENT PRODUCT OBJECT ID"
. S @ALTVMAP@("ALERTAGENTPRODUCTSOURCEID")="A"
. S @ALTVMAP@("ALERTAGENTPRODUCTNAMETEXT")="B"
. S @ALTVMAP@("ALERTAGENTPRODUCTCODEVALUE")="C"
. S @ALTVMAP@("ALERTAGENTPRODUCTCODESYSTEM")="D"
. S ALTARYTMP=$NA(@ALTTARYTMP@(ALTCNT))
. K @ALTARYTMP
. D MAP^GPLXPATH(ALTXML,ALTVMAP,ALTARYTMP)
. I ALTCNT=1 D CP^GPLXPATH(ALTARYTMP,ALTOUTXML)
. I ALTCNT>1 D INSINNER^GPLXPATH(ALTOUTXML,ALTARYTMP)
. S ALTCNT=ALTCNT+1
2008-09-11 22:54:27 -04:00
Q