source: FOIAVistA/trunk/r/ADVERSE_REACTION_TRACKING-GMRA-GMA/GMRAFX3.m@ 1310

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

initial load of FOIAVistA 6/30/08 version

File size: 8.1 KB
Line 
1GMRAFX3 ;SLC/DAN Update existing entries to new reactant ;6/28/06 10:23
2 ;;4.0;Adverse Reaction Tracking;**17,19,23,20**;Mar 29, 1996;Build 1
3 ;DBIA SECTION
4 ;10018 - DIE
5 ;2056 - DIQ
6 ;3154 - ORQ1
7 ;4134 - ORCHECK
8 ;4135 - ORKCHK
9 ;10026 - DIR
10 ;
11UIE ;Update individual entries
12 N DFN,GMRAOUT,GMRAING,GMRADRCL,DIE,DA,DR,AIFN,SIGN,TIME,SUB,ORX,GMRAORX,GMRAOC,GI,FND,COM,SIEN,DIR,Y
13 S GMRADONE=0 ;Flag to keep track of updated entries
14 S DFN=$P($G(^GMR(120.8,GMRAPA,0)),U) Q:'+DFN
15 W !!,"For patient ",$$GET1^DIQ(2,DFN_",",.01),!
16 I $D(GMRAAR) D
17 .S DIR(0)="Y",DIR("A")="Use reactant "_GMRAAR(0),DIR("B")="Y" D ^DIR
18 .K:'Y GMRAAR
19 .Q
20 I '$D(GMRAAR) D ^GMRAFX2 I $D(GMRAAR) D RUSURE(.GMRASURE) ;20 Get new reactant
21 I '$D(GMRAAR)!('$G(GMRASURE)) K GMRAAR Q ;20 stop if no reactant selected or if user doesn't want to use selected reactant
22 S GMRAOUT=0
23 I $$DUP W !,"Patient already has an active allergy for this reactant.",!,"Duplicate not allowed.",! D WAIT Q
24 I $$DUPCHK^GMRAPES0(GMRAAR(0),DFN,GMRAPA) Q ;Checks to see if reactant previously entered in error.
25 ;Update reactant, allergy and signed off fields
26 S DIE="^GMR(120.8,",DA=GMRAPA,DR=".02////"_GMRAAR(0)_";1////^S X=GMRAAR"_";3.1////"_GMRAAR("O")_";15///1" D ^DIE
27 I $D(^GMR(120.85,"C",GMRAPA)) D ;Observed reaction, need to update data
28 .S AIFN=0
29 .F S AIFN=$O(^GMR(120.85,"C",GMRAPA,AIFN)) Q:'+AIFN D
30 ..S SIEN=$O(^GMR(120.85,AIFN,3,"B",$P(^XTMP("GMRAFX",LTYPE,"IDX",+NMBR),"^"),0)) Q:'+SIEN ;Was previous reactant stored as "suspected agent"
31 ..S DA(1)=AIFN,DA=SIEN
32 ..S DIE="^GMR(120.85,DA(1),3,",DR=".01////^S X=GMRAAR(0)" D ^DIE ;Update suspected agent to new value
33 D DELMUL(2),DELMUL(3) ;Delete drug ingredient/drug classes multiples
34 I GMRAAR("O")["D" D UPDATE^GMRAPES1 ;If reactant type is Drug then add appropriate ingredients and classes
35 S GMRADONE=1 ;Update complete
36 S COM="Updated using clean up process. Changed reactant from "_$P(^XTMP("GMRAFX",LTYPE,"IDX",+NMBR),"^",2)_$S(LTYPE="FREE":" (free text) ",LTYPE="ING":" (ingredient) ",1:" (drug class) ")_"to "_GMRAAR(0)_"(file - "_$P(GMRAAR,";",2)_")"
37 D ADCOM^GMRAFX(GMRAPA,"O",COM) ;Add a comment for this update
38 ;Do order checking here - compare existing orders against new allergy information.
39 W !,"Performing order checking..."
40 K ^TMP("ORR",$J),GMRAOC,ORX
41 D EN^ORQ1(DFN_";DPT(") ;Retrieve active orders
42 S TIME=$O(^TMP("ORR",$J,0))
43 I '^TMP("ORR",$J,TIME,"TOT") W "patient has no active orders." Q ;20 No orders found
44 S SUB=0 F S SUB=$O(^TMP("ORR",$J,TIME,SUB)) Q:'+SUB D
45 .D BLD^ORCHECK(+^TMP("ORR",$J,TIME,SUB)) ;Get "order" information in order checking format
46 M GMRAORX=ORX K ORX ;19
47 D EN^ORKCHK(.GMRAOC,DFN,.GMRAORX,"ACCEPT")
48 S GI=0,FND=0 F S GI=$O(GMRAOC(GI)) Q:'+GI D
49 .Q:$P(GMRAOC(GI),U,2)'=3 ;Quit if not allergy related
50 .Q:$D(^OR(100,$P(GMRAOC(GI),U),9,"B",3)) ;23 If order check exists can't be for this data
51 .W !,"Patient has a(n) ",$P($$STATUS^ORQOR2($P(GMRAOC(GI),U)),U,2)," order for",$P($P(GMRAOC(GI),U,4),":",2),", order #",$P(GMRAOC(GI),U)
52 .S FND=1
53 W:'FND "No problems found"
54 D WAIT
55 Q
56 ;
57DELMUL(FIELD) ;Delete multiple FIELD from GMR ALLERGY file
58 N MIEN,DA,DIE,DR
59 S MIEN=0 F S MIEN=$O(^GMR(120.8,GMRAPA,FIELD,MIEN)) Q:'+MIEN D
60 .S DA(1)=GMRAPA,DA=MIEN
61 .S DIE="^GMR(120.8,DA(1),FIELD,",DR=".01///@" D ^DIE ;Delete entry
62 Q
63 ;
64DUP() ;Function returns true (1) if selected reactant is a duplicate
65 N LOOP,FND
66 S LOOP=0,FND=0
67 F S LOOP=$O(^GMR(120.8,"B",DFN,LOOP)) Q:'+LOOP!(FND) D
68 .I $P(^GMR(120.8,LOOP,0),U,3)=GMRAAR&('$D(^GMR(120.8,LOOP,"ER"))) S FND=1
69 Q FND
70 ;
71WAIT ;Issues press enter to return prompt
72 N DIR
73 S DIR(0)="E",DIR("A")="Press enter to continue" D ^DIR
74 Q
75 ;
76GETNUM(ACTION) ; -- Return numbers to act on, if action chosen first
77 N X,Y,DIR,MAX
78 S MAX=$S($D(^TMP($J,LTYPE,"IDX2")):$G(^TMP($J,LTYPE,"IDX2",0)),1:$G(VALMCNT)) Q:MAX'>0 ""
79 I ACTION="DET" W !!,"Please choose only one entry for the detailed display."
80 S DIR(0)="LAO^1:"_MAX,DIR("A")="Select Entries from list: "
81 S DIR("?")="Enter the items you wish to act on, as a range or list of numbers."
82 D ^DIR S:$D(DTOUT) Y="^"
83 I $D(Y(1)) W !,">>>Too many entries selected, try using smaller ranges" H 2 S Y="^"
84 I $L($G(Y),",")>2,ACTION="DET" W !,">>You may only choose ONE group for detailed display." H 2 S Y="^"
85 Q Y
86 ;
87UPDATE ;Update display to account for changes to the list
88 N CNT,SP1,SP2,SP3
89 I VALMAR["GMRADET" N VALMAR S VALMAR="^XTMP(""GMRAFX"",LTYPE)"
90 S CNT=^XTMP("GMRAFX",LTYPE,"GMRAR",$P(ENTRY,U),$P(ENTRY,U,2))-1
91 S ^XTMP("GMRAFX",LTYPE,"GMRAR",$P(ENTRY,U),$P(ENTRY,U,2))=CNT K ^($P(ENTRY,U,2),GMRAJ)
92 S SP1=4-$L(+NUM),SP2=40-$L($P(ENTRY,U)),SP3=$S(CNT:16-$L(CNT)\2,1:2)
93 D SET^VALM10(+NUM,+NUM_$$REPEAT^XLFSTR(" ",SP1)_$P(ENTRY,U,2)_$$REPEAT^XLFSTR(" ",(SP2+SP3))_$S(CNT:CNT,1:"** FIXED **"))
94 Q
95 ;
96LOCK(ENTRY) ;Lock entry in 120.8
97 N LOCK
98 S LOCK=1
99 L +^XTMP("GMRAFX",LTYPE,"IDX",ENTRY):1
100 I '$T D FULL^VALM1 S VALMBCK="R" W !,"The ",$P(^XTMP("GMRAFX",LTYPE,"IDX",ENTRY),U)," group is being edited by another user" D WAIT S LOCK=0
101 Q LOCK
102 ;
103AR ;Add/edit patient reactions
104 N LCV,DFN,SUB
105 S VALMBCK="R" D FULL^VALM1
106 W !!,"You should use this option to add NEW reactions only. If you mark"
107 W !,"existing entries as entered in error from within this option it will"
108 W !,"not update the utility's display until the list is rebuilt upon re-entry"
109 W !,"of this option. This could cause confusion as the list will no longer"
110 W !,"be accurate.",!
111 I '$G(NMBR2) D WAIT,EN1^GMRAPEM0 Q
112 F LCV=1:1:$L(NMBR2,",")-1 S SUB=$P(NMBR2,",",LCV) S DFN=+$P($G(^GMR(120.8,+$P($G(^TMP($J,LTYPE,"IDX2",SUB)),U,2),0)),U) I DFN W !!,"Now working with patient ",$$GET1^DIQ(2,DFN,.01),! D WAIT D EN2^GMRAPEM0
113 Q
114 ;
115DSPREACT ;Display detailed information about the reactant
116 N DIC,DA,GMRAI,STOP,NUM2,DIR,Y
117 S VALMBCK="R" D FULL^VALM1
118 I '$G(NMBR2) S NMBR2=$$GETNUM("") Q:'+NMBR2
119 F GMRAI=1:1:($L(NMBR2,",")-1) D Q:$G(STOP)
120 .S NUM2=$P(NMBR2,",",GMRAI)
121 .S DA=$P(^TMP($J,LTYPE,"IDX2",NUM2),U,2) Q:'DA
122 .S DIC="^GMR(120.8,"
123 .W ! D EN^DIQ
124 .S DIR(0)="E",DIR("A")="Press return to continue or '^' to stop" D ^DIR
125 .S:$D(DIRUT) STOP=1
126 .Q
127 Q
128 ;
129GETTYPE(LTYPE) ;Function determines which list to work with
130 N DIR,X,Y
131 S DIR(0)="SO^1:Free Text;2:Ingredient;3:Drug Class"
132 S DIR("A")="Select the list you wish to work with"
133 D ^DIR K DIR
134 S LTYPE=$S(Y=1:"FREE",Y=2:"ING",Y=3:"DRUG",1:0)
135 Q LTYPE
136 ;
137EIE ;Mark individual entry as entered in error
138 N DIE,DA,DR,Y,DIK,DFN,OROLD,VAIN,X,GMRAOUT
139 S DIE="^GMR(120.8,",DA=GMRAPA,DR="15///1;22///1;23///NOW;24////"_$G(DUZ,.5) ;20
140 D ^DIE ;Entered in error on date/time by user
141 D ADCOM^GMRAFX(GMRAPA,"E","Marked Entered in Error during clean up process")
142 I $$NKASCR^GMRANKA($P(^GMR(120.8,GMRAPA,0),U)) D
143 .S DIK="^GMR(120.86,",DA=$P(^GMR(120.8,GMRAPA,0),U)
144 .D ^DIK ;If patient's last allergy marked as entered in error then delete assessment
145 .W !!,"**NOTE: By marking this reaction as entered in error, ",$$GET1^DIQ(2,DA,.01,"E"),!,"no longer has an assessment on file. You may reassess this patient",!
146 .W "now by answering the following prompt or hit return to do it later.",!
147 .D NKAASK^GMRANKA(DA)
148 S GMRAPA(0)=$G(^GMR(120.8,GMRAPA,0)) Q:GMRAPA(0)=""
149 S GMRAOUT=0
150 D EN1^GMRAEAB ;Sends entered in error bulletin to appropriate mail groups
151 S DFN=$P(GMRAPA(0),U)
152 D INP^VADPT S X=$$FIND1^DIC(101,,"BX","GMRA ENTERED IN ERROR")_";ORD(101," ;19
153 D:X EN^XQOR ;Process protocols hanging off of "entered in error" protocol
154 Q
155 ;
156RUSURE(GMRASURE) ;20 Make sure selection from ingredient or drug class file is ok
157 ;entire section added in patch 20
158 N DIR,Y,X
159 S GMRASURE=1
160 I $G(GMRAAR)["50.416"!($G(GMRAAR)["50.605") D
161 .S DIR("A")="Are you sure you want to use this reactant"
162 .S DIR("A",1)="You are about to update the entry with a selection from"
163 .S DIR("A",2)="the "_$S($G(GMRAAR)["50.416":"INGREDIENT",1:"VA DRUG CLASS")_" file. By doing that you are"
164 .S DIR("A",3)="limiting the information available for order checking."
165 .S DIR("A",4)=""
166 .S DIR("A",5)="In general, it is better to choose from one of the drug related files"
167 .S DIR("A",6)="as that ensures that drug class and ingredient information are part"
168 .S DIR("A",7)="of the patient's allergy definition and will provide better allergy"
169 .S DIR("A",8)="order checking."
170 .S DIR("A",9)=""
171 .S DIR(0)="Y",DIR("B")="NO"
172 .D ^DIR S GMRASURE=+Y
173 Q
Note: See TracBrowser for help on using the repository browser.