VistA-ccr/p/GPLALER2.m

112 lines
4.8 KiB
Mathematica
Raw Normal View History

2008-10-26 15:27:11 -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
;
; GET ADVERSE REACTIONS AND ALLERGIES
; N GMRA,GMRAL ; FOR DEBUGGING, DON'T NEW THESE VARIABLES
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 ALTG=$NA(GMRAL),ALTCNT=1
S ALTTMP="" ;
F S ALTTMP=$O(@ALTG@(ALTTMP)) Q:ALTTMP="" D ; CHANGED TO $O BY GPL
. W "ALTTMP="_ALTTMP,!
. ; I $QS(ALTTMP,2)="S" W !,"S FOUND",! Q
. S ALTVMAP=$NA(@ALTTVMAP@(ALTCNT))
. K @ALTVMAP
. S @ALTVMAP@("ALERTOBJECTID")="ALERT"_ALTCNT
2008-10-27 00:04:27 -04:00
. N A1 S A1=@ALTG@(ALTTMP) ; ALL THE PIECES
2008-10-27 11:42:09 -04:00
. N A2 S A2=$$GET1^DIQ(120.8,ALTTMP,"MECHANISM","I") ; MECHANISM
2008-10-27 00:04:27 -04:00
. N A3 S A3=$P(A1,U,5) ; ADVERSE FLAG
2008-10-26 15:27:11 -04:00
. N ADT S ADT="Patient has an " ; X $ZINT H 5
2008-10-27 11:42:09 -04:00
. S ADT=ADT_$S(A2="P":"ADVERSE",A2="A":"ALLERGIC",1:"UNKNOWN")
2008-10-26 15:27:11 -04:00
. S ADT=ADT_" reaction to "_$P(@ALTG@(ALTTMP),U,2)_"."
. S @ALTVMAP@("ALERTDESCRIPTIONTEXT")=ADT
2008-10-27 00:04:27 -04:00
. N ALTCDE ; SNOMED CODE THE THE ALERT
2008-10-27 11:42:09 -04:00
. S ALTCDE=$S(A2="P":"282100009",A2="A":"418634005",1:"") ; IF NOT ADVERSE, IT IS ALLERGIC
2008-10-27 00:04:27 -04:00
. S @ALTVMAP@("ALERTCODEVALUE")=ALTCDE ;
. ; WILL USE 418634005 FOR ALLERGIC REACTION TO A SUBSTANCE
. ; AND 282100009 FOR ADVERSE REACTION TO A SUBSTANCE
. I ALTCDE'="" D ; IF THERE IS A CODE
. . S @ALTVMAP@("ALERTCODESYSTEM")="SNOMED CT"
. . S @ALTVMAP@("ALERTCODESYSTEMVERSION")="2008"
. E D ; SET TO NULL
. . S @ALTVMAP@("ALERTCODESYSTEM")=""
. . S @ALTVMAP@("ALERTCODESYSTEMVERSION")=""
2008-10-27 00:04:27 -04:00
. S @ALTVMAP@("ALERTSTATUSTEXT")="" ; WHERE DO WE GET THIS?
2008-10-26 15:55:36 -04:00
. N ALTPROV S ALTPROV=$P(^GMR(120.8,ALTTMP,0),U,5) ; SOURCE PROVIDER IEN
. I ALTPROV'="" D ; PROVIDER PROVIDEED
. . S @ALTVMAP@("ALERTSOURCEID")="ACTORPROVIDER_"_ALTPROV
. E S @ALTVMAP@("ALERTSOURCEID")="" ; SOURCE NULL - SHOULD NOT HAPPEN
2008-10-26 15:27:11 -04:00
. W "RUNNING ALERTS, PROVIDER: ",@ALTVMAP@("ALERTSOURCEID"),!
2008-10-27 00:04:27 -04:00
. N ACGL1,ACGFI,ACIEN,ACVUID
. S ACGL1=$P(@ALTG@(ALTTMP),U,9) ; ADDRESS OF THE REACTANT XX;GLB(YY.Z,
. S ACGFI=$$PRSGLB($P(ACGL1,";",2)) ; FILE NUMBER
. S ACIEN=$P(ACGL1,";",1) ; IEN OF REACTANT
. S ACVUID=$$GET1^DIQ(ACGFI,ACIEN,"VUID") ; VUID OF THE REACTANT
. S @ALTVMAP@("ALERTAGENTPRODUCTOBJECTID")="PRODUCT_"_ACIEN ; IE OF REACTANT
. S @ALTVMAP@("ALERTAGENTPRODUCTSOURCEID")="" ; WHERE DO WE GET THIS?
. S @ALTVMAP@("ALERTAGENTPRODUCTNAMETEXT")=$P(@ALTG@(ALTTMP),U,2) ; REACTANT
. S @ALTVMAP@("ALERTAGENTPRODUCTCODEVALUE")=ACVUID
. I ACVUID'="" D ; IF VUID IS NOT NULL
. . S @ALTVMAP@("ALERTAGENTPRODUCTCODESYSTEM")="VUID"
2008-10-28 20:34:04 -04:00
. E D ; IF REACTANT CODE VALUE IS NULL
. . S @ALTVMAP@("ALERTAGENTPRODUCTCODESYSTEM")=""
. . S @ALTVMAP@("ALERTAGENTPRODUCTCODEVALUE")=""
2008-10-27 00:04:27 -04:00
. ; REACTIONS - THIS SHOULD BE MULTIPLE, IS SINGLE NOW
. N ARTMP,ARIEN,ARDES,ARVUID
2008-10-27 00:31:59 -04:00
. S (ARTMP,ARDES,ARVUID)=""
. I $D(@ALTG@(ALTTMP,"S",1)) D ; IF REACTION EXISTS
. . S ARTMP=@ALTG@(ALTTMP,"S",1)
. . W "REACTION:",ARTMP,!
. . S ARIEN=$P(ARTMP,";",2)
. . S ARDES=$P(ARTMP,";",1)
2008-10-27 00:35:18 -04:00
. . S ARVUID=$$GET1^DIQ(120.83,ARIEN,"VUID")
2008-10-27 00:04:27 -04:00
. S @ALTVMAP@("ALERTREACTIOINDESCRIPTIONTEXT")=ARDES
2008-10-28 20:14:30 -04:00
. I ARVUID'="" D ; IF REACTION VUID IS NOT NULL
. . S @ALTVMAP@("ALERTREACTIONCODEVALUE")=ARVUID
. . S @ALTVMAP@("ALERTREACTIONCODESYSTEM")="VUID"
. E D ; IF IT IS NULL DON'T SET CODE SYSTEM
. . S @ALTVMAP@("ALERTREACTIONCODEVALUE")=""
. . S @ALTVMAP@("ALERTREACTIONCODESYSTEM")=""
2008-10-26 15:27:11 -04:00
. 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-10-28 20:34:04 -04:00
S @ALTTVMAP@(0)=ALTCNT-1 ; RECORD THE NUMBER OF ALERTS
2008-10-26 15:27:11 -04:00
Q
2008-10-27 00:04:27 -04:00
PRSGLB(INGLB) ; EXTRINSIC TO PARSE GLOBALS AND RETURN THE FILE NUMBER
; INGLB IS OF THE FORM: PSNDF(50.6,
; RETURN 50.6
Q $P($P(INGLB,"(",2),",",1) ;