1 | GPLALERT ; CCDCCR/CKU - CCR/CCD PROCESSING FOR ALERTS ; 09/11/08
|
---|
2 | ;;0.1;CCDCCR;;SEP 11,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 | ;
|
---|
23 | EXTRACT(ALTXML,DFN,ALTOUTXML) ; EXTRACT ALERTS INTO PROVIDED XML TEMPLATE
|
---|
24 | ;
|
---|
25 | ; ALTXML AND ALTOUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
|
---|
26 | ;
|
---|
27 | ; GET ADVERSE REACTIONS AND ALLERGIES
|
---|
28 | ; N GMRA,GMRAL ; FOR DEBUGGING, DON'T NEW THESE VARIABLES
|
---|
29 | S GMRA="0^0^111"
|
---|
30 | D EN1^GMRADPT
|
---|
31 | I $G(GMRAL)'=1 D Q ; NO ALLERGIES FOUND THUS *QUIT*
|
---|
32 | . S @ALTOUTXML@(0)=0
|
---|
33 | ; DEFINE MAPPING
|
---|
34 | N ALTTVMAP,ALTVMAP,ALTTARYTMP,ALTARYTMP
|
---|
35 | S ALTTVMAP=$NA(^TMP("GPLCCR",$J,"ALERTS"))
|
---|
36 | S ALTTARYTMP=$NA(^TMP("GPLCCR",$J,"ALERTSARYTMP"))
|
---|
37 | K @ALTTVMAP,@ALTTARYTMP
|
---|
38 | N ALTTMP,ALTCNT S ALTG=$NA(GMRAL),ALTCNT=1
|
---|
39 | S ALTTMP="" ;
|
---|
40 | F S ALTTMP=$O(@ALTG@(ALTTMP)) Q:ALTTMP="" D ; CHANGED TO $O BY GPL
|
---|
41 | . W "ALTTMP="_ALTTMP,!
|
---|
42 | . ; I $QS(ALTTMP,2)="S" W !,"S FOUND",! Q
|
---|
43 | . S ALTVMAP=$NA(@ALTTVMAP@(ALTCNT))
|
---|
44 | . K @ALTVMAP
|
---|
45 | . S @ALTVMAP@("ALERTOBJECTID")="ALERT"_ALTCNT
|
---|
46 | . N A1 S A1=@ALTG@(ALTTMP) ; ALL THE PIECES
|
---|
47 | . N A2 S A2=$$GET1^DIQ(120.8,ALTTMP,"MECHANISM","I") ; MECHANISM
|
---|
48 | . N A3 S A3=$P(A1,U,5) ; ADVERSE FLAG
|
---|
49 | . N ADT S ADT="Patient has an " ; X $ZINT H 5
|
---|
50 | . S ADT=ADT_$S(A2="P":"ADVERSE",A2="A":"ALLERGIC",1:"UNKNOWN")
|
---|
51 | . S ADT=ADT_" reaction to "_$P(@ALTG@(ALTTMP),U,2)_"."
|
---|
52 | . S @ALTVMAP@("ALERTDESCRIPTIONTEXT")=ADT
|
---|
53 | . N ALTCDE ; SNOMED CODE THE THE ALERT
|
---|
54 | . S ALTCDE=$S(A2="P":"282100009",A2="A":"418634005",1:"") ; IF NOT ADVERSE, IT IS ALLERGIC
|
---|
55 | . S @ALTVMAP@("ALERTCODEVALUE")=ALTCDE ;
|
---|
56 | . ; WILL USE 418634005 FOR ALLERGIC REACTION TO A SUBSTANCE
|
---|
57 | . ; AND 282100009 FOR ADVERSE REACTION TO A SUBSTANCE
|
---|
58 | . I ALTCDE'="" D ; IF THERE IS A CODE
|
---|
59 | . . S @ALTVMAP@("ALERTCODESYSTEM")="SNOMED CT"
|
---|
60 | . . S @ALTVMAP@("ALERTCODESYSTEMVERSION")="2008"
|
---|
61 | . E D ; SET TO NULL
|
---|
62 | . . S @ALTVMAP@("ALERTCODESYSTEM")=""
|
---|
63 | . . S @ALTVMAP@("ALERTCODESYSTEMVERSION")=""
|
---|
64 | . S @ALTVMAP@("ALERTSTATUSTEXT")="" ; WHERE DO WE GET THIS?
|
---|
65 | . N ALTPROV S ALTPROV=$P(^GMR(120.8,ALTTMP,0),U,5) ; SOURCE PROVIDER IEN
|
---|
66 | . I ALTPROV'="" D ; PROVIDER PROVIDEED
|
---|
67 | . . S @ALTVMAP@("ALERTSOURCEID")="ACTORPROVIDER_"_ALTPROV
|
---|
68 | . E S @ALTVMAP@("ALERTSOURCEID")="" ; SOURCE NULL - SHOULD NOT HAPPEN
|
---|
69 | . W "RUNNING ALERTS, PROVIDER: ",@ALTVMAP@("ALERTSOURCEID"),!
|
---|
70 | . N ACGL1,ACGFI,ACIEN,ACVUID
|
---|
71 | . S ACGL1=$P(@ALTG@(ALTTMP),U,9) ; ADDRESS OF THE REACTANT XX;GLB(YY.Z,
|
---|
72 | . S ACGFI=$$PRSGLB($P(ACGL1,";",2)) ; FILE NUMBER
|
---|
73 | . S ACIEN=$P(ACGL1,";",1) ; IEN OF REACTANT
|
---|
74 | . S ACVUID=$$GET1^DIQ(ACGFI,ACIEN,"VUID") ; VUID OF THE REACTANT
|
---|
75 | . S @ALTVMAP@("ALERTAGENTPRODUCTOBJECTID")="PRODUCT_"_ACIEN ; IE OF REACTANT
|
---|
76 | . S @ALTVMAP@("ALERTAGENTPRODUCTSOURCEID")="" ; WHERE DO WE GET THIS?
|
---|
77 | . S @ALTVMAP@("ALERTAGENTPRODUCTNAMETEXT")=$P(@ALTG@(ALTTMP),U,2) ; REACTANT
|
---|
78 | . S @ALTVMAP@("ALERTAGENTPRODUCTCODEVALUE")=ACVUID
|
---|
79 | . I ACVUID'="" D ; IF VUID IS NOT NULL
|
---|
80 | . . S @ALTVMAP@("ALERTAGENTPRODUCTCODESYSTEM")="VUID"
|
---|
81 | . E D ; IF REACTANT CODE VALUE IS NULL
|
---|
82 | . . S @ALTVMAP@("ALERTAGENTPRODUCTCODESYSTEM")=""
|
---|
83 | . . S @ALTVMAP@("ALERTAGENTPRODUCTCODEVALUE")=""
|
---|
84 | . ; REACTIONS - THIS SHOULD BE MULTIPLE, IS SINGLE NOW
|
---|
85 | . N ARTMP,ARIEN,ARDES,ARVUID
|
---|
86 | . S (ARTMP,ARDES,ARVUID)=""
|
---|
87 | . I $D(@ALTG@(ALTTMP,"S",1)) D ; IF REACTION EXISTS
|
---|
88 | . . S ARTMP=@ALTG@(ALTTMP,"S",1)
|
---|
89 | . . W "REACTION:",ARTMP,!
|
---|
90 | . . S ARIEN=$P(ARTMP,";",2)
|
---|
91 | . . S ARDES=$P(ARTMP,";",1)
|
---|
92 | . . S ARVUID=$$GET1^DIQ(120.83,ARIEN,"VUID")
|
---|
93 | . S @ALTVMAP@("ALERTREACTIOINDESCRIPTIONTEXT")=ARDES
|
---|
94 | . I ARVUID'="" D ; IF REACTION VUID IS NOT NULL
|
---|
95 | . . S @ALTVMAP@("ALERTREACTIONCODEVALUE")=ARVUID
|
---|
96 | . . S @ALTVMAP@("ALERTREACTIONCODESYSTEM")="VUID"
|
---|
97 | . E D ; IF IT IS NULL DON'T SET CODE SYSTEM
|
---|
98 | . . S @ALTVMAP@("ALERTREACTIONCODEVALUE")=""
|
---|
99 | . . S @ALTVMAP@("ALERTREACTIONCODESYSTEM")=""
|
---|
100 | . S ALTARYTMP=$NA(@ALTTARYTMP@(ALTCNT))
|
---|
101 | . K @ALTARYTMP
|
---|
102 | . D MAP^GPLXPATH(ALTXML,ALTVMAP,ALTARYTMP)
|
---|
103 | . I ALTCNT=1 D CP^GPLXPATH(ALTARYTMP,ALTOUTXML)
|
---|
104 | . I ALTCNT>1 D INSINNER^GPLXPATH(ALTOUTXML,ALTARYTMP)
|
---|
105 | . S ALTCNT=ALTCNT+1
|
---|
106 | S @ALTTVMAP@(0)=ALTCNT-1 ; RECORD THE NUMBER OF ALERTS
|
---|
107 | Q
|
---|
108 | PRSGLB(INGLB) ; EXTRINSIC TO PARSE GLOBALS AND RETURN THE FILE NUMBER
|
---|
109 | ; INGLB IS OF THE FORM: PSNDF(50.6,
|
---|
110 | ; RETURN 50.6
|
---|
111 | Q $P($P(INGLB,"(",2),",",1) ;
|
---|