source: FOIAVistA/trunk/r/ADVERSE_REACTION_TRACKING-GMRA-GMA/GMRAOR5.m@ 1742

Last change on this file since 1742 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 4.9 KB
Line 
1GMRAOR5 ;HIRMFO/WAA,FPT-OERR HL7 UTILITY ;3/5/04 14:02
2 ;;4.0;Adverse Reaction Tracking;**4,12,13,19**;Mar 29, 1996
3 ;MSG = HL7 Message array
4 ;GMRANODE = IEN of MSG array
5 ;GMRAND = Date from MSG(GMRANODE)
6 ;GMRAMTP = Message type
7 ;Allergy Loader
8 ;building GMRAL Array to be used to stuff only new data
9 ;GMRAID=sequence number of allergy
10 ;~=continuation
11 ;GMRAIDO = Sequence # OBSERVED
12 ;GMRAIDS = Sequence # SIGN
13 ;GMRAIDN = Sequence # NOTES
14 ; GMRADFN=DFN of patient in ^DPT(DFN) Patient (2) file
15 ; GMRAL(GMRAID)=type^file ien^VA Free text drug^file^OERR entry date
16 ; ^NKA Status^Originator Pt to 200^Observed/Historical
17 ; GMRAL(GMRAID,"O",GMRAIDO)=Observed date^Severity^Observer's DUZ
18 ; GMRAL(GMRAID,"S",GMRAIDS)=IEN of file^Free Text of entry^File of SS
19 ; ^Date/Time of the SS
20 ; GMRAL(GMRAID,"N",GMRAIDN)=Source of comments(Originator always)
21 ;----------------------------------------------------------------------
22 ; Example of data
23 ; GMRADFN=270
24 ; GMRAL(1)="D^5^SHELL FISH^99ALL^2940415.06^n^1270^o"
25 ; GMRAL(1,"O",1)="2940401.1^3^1234"
26 ; GMRAL(1,"S",1)="32^SEVERE RASH^99ALS^2951211.1120"
27 ; GMRAL(1,"N",1)="n"
28 ; GMRAL(1,"N",1,1)=FREE TEXT
29 ;******************************************************************
30EN1 ;Main entry point to file data
31 N %,GMRADUP,GMRAFDN,GMRANKA,GNRAY,X,Y
32 Q:'$G(GMRADFN)
33 S GMRAL=0
34 S GMRAPA=0,GMRADUP=0
35 ; See if the patient has been ask about allergies
36 S (GMRAYN,GMRANKA)=0,GMRAYN=$P($G(^GMR(120.86,GMRADFN,0)),U,2)
37 ;Loop through for each allergy
38 F S GMRAL=$O(GMRAL(GMRAL)) Q:GMRAL<1 D
39 .;If GMRANKA="" add the entry into the file
40 .I '$D(^GMR(120.86,GMRADFN,0)) K DD,DO,DIC,DINUM,DLAYGO S DIC="^GMR(120.86,",DLAYGO=120.86,DIC(0)="L",(DINUM,X)=GMRADFN D FILE^DICN K DD,DO,DIC,DINUM,DLAYGO D
41 ..Q:Y=-1
42 ..S GMRAYN=$S($P(GMRAL(GMRAL),U,6)="y":1,1:0)
43 ..S $P(^GMR(120.86,GMRADFN,0),U,2,4)=GMRAYN_U_$P(GMRAL(GMRAL),U,7)_U_$P(GMRAL(GMRAL),U,5)
44 ..Q
45 .N GMRALL,GMRAFN,%
46 .S GMRALL=$P(GMRAL(GMRAL),U,3)
47 .I $P(GMRAL(GMRAL),U,6)="n" D Q:GMRALL'=""
48 ..; Change to no for allergies
49 ..Q:GMRAYN="1"!$D(^GMR(120.86,GMRADFN,0))
50 ..S $P(^GMR(120.86,GMRADFN,0),U,2,4)="0"_U_$P(GMRAL(GMRAL),U,7)_U_$P(GMRAL(GMRAL),U,5)
51 ..S:'$D(^GMR(120.86,"B",GMRADFN,GMRADFN)) ^(GMRADFN)=""
52 ..Q
53 .I GMRAYN="0",$P(GMRAL(GMRAL),U,6)="n" Q
54 .; see If the entry needs to be added
55 .; If the entry is an allergy set 120.86 to "y"
56 .I GMRALL'="",$D(^GMR(120.86,GMRADFN,0)) S GMRAYN=1 D
57 ..; Change to yes for allergies
58 ..S $P(^GMR(120.86,GMRADFN,0),U,2,4)=GMRAYN_U_$P(GMRAL(GMRAL),U,7)_U_$P(GMRAL(GMRAL),U,5)
59 ..S:'$D(^GMR(120.86,"B",GMRADFN,GMRADFN)) ^(GMRADFN)=""
60 ..Q
61 .; Quit if the reaction is a Dup
62 .Q:$$DUPCHK^GMRAOR0(GMRADFN,GMRALL)>0
63 .S GMRAPA=0
64 .K DD,DO,DIC,DINUM,DLAYGO S DIC="^GMR(120.8,",DLAYGO=120.8,DIC(0)="L",X=GMRADFN D FILE^DICN
65 .K DD,DO,DIC,DINUM,DLAYGO
66 .Q:Y=-1 S GMRAPA=+Y
67 .Q:$G(^GMR(120.8,GMRAPA,0))=""
68 .F Q:$$LOCK^GMRAUTL(120.8,GMRAPA)
69 .N GMRALN,GMRAVR
70 .S GMRALN=$G(^GMR(120.8,GMRAPA,0))
71 .S $P(GMRALN,U,4)=$P(GMRAL(GMRAL),U,5) ; Orig. DT
72 .S $P(GMRALN,U,5)=$P(GMRAL(GMRAL),U,7) ; Originator
73 .S %=$P(GMRAL(GMRAL),U,4),%=$S(%="99ALL"!(%="99OTH"):"GMRD(120.82,",%="99NDF":$P($$NDFREF^GMRAOR,U,2),%="99PSC":"PS(50.605,",1:"") Q:%="" ;Bad entry
74 .S:$P(GMRAL(GMRAL),U,2)="NOS" $P(GMRAL(GMRAL),U,2)=$S($O(^GMRD(120.82,"B","OTHER ALLERGY/ADVERSE REACTION",0))>0:$O(^GMRD(120.82,"B","OTHER ALLERGY/ADVERSE REACTION",0)),1:1)
75 .S GMRAAR=$P(GMRAL(GMRAL),U,2)_";"_%,$P(GMRALN,U,3)=GMRAAR ;File Ptr
76 .I $P(GMRAL(GMRAL),U,3)'="" S $P(GMRALN,U,2)=$P(GMRAL(GMRAL),U,3) ;Free text
77 .E D ; This code will resolve the free text pointer for the reaction
78 ..N GMRALOC,GMRADATA
79 ..S GMRALOC="^"_$P($P(GMRALN,U,3),";",2)_+$P(GMRALN,U,3)_",0)"
80 ..S GMRADATA=@GMRALOC
81 ..S $P(GMRALN,U,2)=$P(GMRADATA,U)
82 ..Q
83 .S $P(GMRALN,U,20)=$P(GMRAL(GMRAL),U) ;Type of reaction
84 .S $P(GMRALN,U,6)=$P(GMRAL(GMRAL),U,8) ;Obs/Hist
85 .S $P(GMRALN,U,14)="U" ;Mechanism
86 .S $P(GMRALN,U,12)=1 ;Sign-off the reaction
87 .; auto-verify?
88 .S GMRAVR="",GMRAVR(0)=GMRALN
89 .S $P(GMRALN,U,16)=$$VFY^GMRASIGN(.GMRAVR)
90 .I $P(GMRALN,U,16) S $P(GMRALN,U,17)=$$NOW^XLFDT
91 .; save
92 .S ^GMR(120.8,GMRAPA,0)=GMRALN
93 .I $D(GMRAL(GMRAL,"S",1)) D SIGN^GMRAOR6(120.8,GMRAPA,.GMRAL) ; S/S
94 .; Comments
95 .I $D(GMRAL(GMRAL,"N",1)) D COMM^GMRAOR8(GMRAPA,.GMRAL) ; Add comments
96 .D EN1^GMRAOR9 K GMRAAR ;stuff ingredients & classes
97 .;Re-Index Whole file entry
98 .K DIK,DA S DIK="^GMR(120.8,",DA=GMRAPA D IX^DIK K DIK,DA
99 .D UNLOCK^GMRAUTL(120.8,GMRAPA)
100 .S ^TMP($J,"GMRASF",1,GMRAPA)="" D RANGE^GMRASIGN(1) ;**19 Send bulletins upon signing-off
101 .S GMRASITE(0)=$G(^GMRD(120.84,+GMRASITE,0)) D VAD^GMRAUTL1($P(^GMR(120.8,GMRAPA,0),U),"",.GMRALOC,.GMRANAM,"",.GMRASSN),BULLT^GMRASEND ;19 Send mark chart bulletin
102 .Q:($P(GMRAL(GMRAL),U,1)'["D"!($P(GMRAL(GMRAL),U,8)'["o")) ;quit if not an observed drug reaction
103 .; add Adverse Reaction report.
104 .I $G(GMRAL(GMRAL,"O",1))'="" D ADVERSE^GMRAOR7(GMRAPA,.GMRAL)
105 .Q
106 Q
Note: See TracBrowser for help on using the repository browser.