source: WorldVistAEHR/trunk/r/ADVERSE_REACTION_TRACKING-GMRA-GMA/GMRAY29.m@ 771

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

initial load of WorldVistAEHR

File size: 7.4 KB
Line 
1GMRAY29 ;SLC/DAN Installation Utilities ;3/1/07 14:34
2 ;;4.0;Adverse Reaction Tracking;**29**;Mar 29, 1996;Build 15
3 ;
4 ;DBIA SECTION
5 ;3744 - $$TESTPAT^VADPT
6 ;10061 - VADPT
7 ;10013 - DIK
8 ;2056 - DIQ
9 ;10018 - DIE
10 ;10070 - XMD
11 ;10103 - XLFDT
12 ;2051 - DIC
13 ;
14PRETRAN ;Load conversion table into KIDS build
15 M @XPDGREF@("GMRAFIX")=^XTMP("GMRAFIX")
16 Q
17 ;
18POST ;Post installation processes
19 K ^XTMP("GMRAFIX")
20 M ^XTMP("GMRAFIX")=@XPDGREF@("GMRAFIX")
21 I '$D(^XTMP("GMRAFIX")) W !,"Conversion table not loaded - INSTALLATION ABORTED" S XPDQUIT=2 Q
22 D Q Q ;Queue clean up to background
23 ;
24Q ;
25 N ZTRTN,ZTDESC,ZTIO,ZTDTH,ZTSK
26 S ZTRTN="DQ^GMRAY29",ZTDESC="GMRA*4*29 POST INSTALL ROUTINE",ZTIO="",ZTDTH=$H
27 D ^%ZTLOAD I '$G(ZTSK) D BMES^XPDUTL("POST INSTALL NOT QUEUED - RUN DQ^GMRA29 AFTER INSTALL FINISHES") Q
28 D BMES^XPDUTL("Post-install queued as task # "_$G(ZTSK))
29 Q
30 ;
31DQ ;Process begins here
32 N ERR,TU,TE,TF
33 D FIXALG
34 D MAIL
35 S ^XTMP("GMRAFIX",0)=$$FMADD^XLFDT(DT,30)_"^"_DT_"^Patch GMRA*4*29 conversion table"
36 K ^XTMP("GMRAFX","FREE") ;Kill free text list so it forces rebuild
37 Q
38 ;
39FIXALG ;Loop through 120.8 update existing free text entries
40 N GMRAI,FREE,REACTANT,ENTRY
41 S FREE=$O(^GMRD(120.82,"B","OTHER ALLERGY/ADVERSE REACTION",0)) S:'+FREE ERR=1 S:FREE FREE=FREE_";GMRD(120.82," Q:$G(ERR)
42 S GMRAI=0 F S GMRAI=$O(^GMR(120.8,GMRAI)) Q:'+GMRAI D
43 .I '$D(^GMR(120.8,GMRAI,0))!($L($G(^GMR(120.8,GMRAI,0)),"^")=1) D DEL Q
44 .Q:+$G(^GMR(120.8,GMRAI,"ER"))!($$TESTPAT^VADPT($P(^GMR(120.8,GMRAI,0),U)))!($$DECEASED^GMRAFX($P(^GMR(120.8,GMRAI,0),U))) ;stop if entered in error, test patient or deceased patient
45 .I $P(^GMR(120.8,GMRAI,0),U,3)=FREE D
46 ..S REACTANT=$P(^GMR(120.8,GMRAI,0),U,2) Q:REACTANT[" ( FREE TEXT )" ;Entry has already been updated
47 ..S ENTRY=$G(^XTMP("GMRAFIX",$$UP^XLFSTR($E(REACTANT,1,30)))) ;For matching purposes, only use the 1st 30 characters
48 ..I ENTRY="" D UPDATEF Q ;Entry not found or designated free text
49 ..I $P(ENTRY,U)="Entered In Error" D UPDATEE Q ;Mark as entered in error
50 ..D UPDATE ;Update free text entry from table
51 Q
52 ;
53DEL ;No zero node, remove entry
54 N DIK,DA,GMRADONT
55 S GMRADONT=1 ;Stop HDR from receiving update as it's not needed
56 S DIK="^GMR(120.8,",DA=GMRAI
57 D ^DIK
58 Q
59 ;
60UPDATEF ;Update reactant to say free text so users know it isn't a standardized entry
61 N FDA
62 S REACTANT=REACTANT_" ( FREE TEXT )"
63 S FDA(120.8,(GMRAI_","),.02)=REACTANT
64 D FILE^DIE(,"FDA")
65 S TF=$G(TF)+1 ;Increment total free text updated counter
66 Q
67 ;
68UPDATEE ;Mark as entered in error, check for NKA
69 N DIE,DA,DR,DFN,USER,TIME
70 S DFN=$P(^GMR(120.8,GMRAI,0),U) ;Patient's IEN
71 S USER=$P(^GMR(120.8,GMRAI,0),U,5),TIME=$P(^(0),U,4)
72 S DIE="^GMR(120.8,",DA=GMRAI,DR="22///1;23///NOW;24////"_$G(DUZ,.5)
73 D ^DIE ;Entry is now entered in error
74 D ADCOM^GMRAFX(GMRAI,"E","Marked entered in error by auto-update in patch GMRA*4*29") ;Adds comment to allergy record
75 I $$NKASCR^GMRANKA(DFN) D
76 .I $P(ENTRY,U,2)="NKDA" S DA=DFN,DIE="^GMR(120.86,",DR="1////0;2////"_$G(USER,DUZ)_";3////"_$G(TIME,$$NOW^XLFDT) D ^DIE Q ;Set assessment to NKA
77 .D CLN^GMRANKA ;Delete assessment
78 S TE=$G(TE)+1 ;Increment total entered in error counter
79 Q
80 ;
81UPDATE ;Update free text entry to data found in table
82 N DFN,DIE,DA,DR,AIFN,COM,SIEN,FILE,NAME,IEN,GMRAAR,GMRAPA,GMRASCR,ERRCODE
83 S DFN=$P(^GMR(120.8,GMRAI,0),U)
84 S GMRAPA=GMRAI
85 S FILE=$P(ENTRY,U),NAME=$P(ENTRY,U,2)
86 S IEN=$$FIND1^DIC(FILE,"",$S(FILE=120.82:"X",1:"MX"),NAME,$S(FILE=120.82:"B",1:""),,"ERRCODE")
87 I '+IEN S IEN=$$FIND1^DIC(FILE,"","MX",NAME_" ","",,"ERRCODE")
88 I '+IEN,NAME="ANTIMUSCARINICS/ANTISPASMODICS" S IEN=$$FIND1^DIC(FILE,"","MX","GA801","",,"ERRCODE")
89 I '+IEN,$L($T(SCREEN^XTID)) S GMRASCR="I '$$SCREEN^XTID(FILE,,Y_"","")" S IEN=$$FIND1^DIC(FILE,"","MX",NAME,"",$G(GMRASCR),"ERRCODE")
90 I '+IEN S ERR(2,DFN,REACTANT)=ENTRY D UPDATEF Q
91 S GMRAAR=IEN_";"_$S(FILE=50:"PSDRUG(",FILE=50.416:"PS(50.416,",FILE=50.605:"PS(50.605,",FILE=120.82:"GMRD(120.82,",1:"PSNDF(50.6,")
92 S GMRAAR(0)=NAME
93 S GMRAAR("O")=$S(FILE=120.82:$P(^GMRD(120.82,IEN,0),U,2),1:"D")
94 I $$DUP^GMRAFX3 S ERR(3,DFN,REACTANT)=ENTRY D UPDATEF Q ;Would create a duplicate if update occur
95 ;Update reactant, allergy and signed off fields
96 S DIE="^GMR(120.8,",DA=GMRAPA,DR=".02////"_GMRAAR(0)_";1////^S X=GMRAAR"_";3.1////"_GMRAAR("O")_";15///1" D ^DIE
97 I $D(^GMR(120.85,"C",GMRAPA)) D ;Observed reaction, need to update data
98 .S AIFN=0
99 .F S AIFN=$O(^GMR(120.85,"C",GMRAPA,AIFN)) Q:'+AIFN D
100 ..S SIEN=$O(^GMR(120.85,AIFN,3,"B",REACTANT,0)) Q:'+SIEN ;Was previous reactant stored as "suspected agent"
101 ..S DA(1)=AIFN,DA=SIEN
102 ..S DIE="^GMR(120.85,DA(1),3,",DR=".01////^S X=GMRAAR(0)" D ^DIE ;Update suspected agent to new value
103 D DELMUL^GMRAFX3(2),DELMUL^GMRAFX3(3) ;Delete drug ingredient/drug classes multiples
104 I GMRAAR("O")["D" D UPDATE^GMRAPES1 K LIST ;If reactant type is Drug then add appropriate ingredients and classes
105 S COM="Updated using auto clean up process from GMRA*4*29. Changed reactant from "_REACTANT_" (free text) "_"to "_GMRAAR(0)_"(file - "_$P(GMRAAR,";",2)_")"
106 D ADCOM^GMRAFX(GMRAPA,"O",COM) ;Add a comment for this update
107 S TU=$G(TU)+1 ;Increment total updated counter
108 Q
109 ;
110MAIL ;Send message indicating post install is finished
111 N XMSUB,XMTEXT,XMDUZ,XMY,XMZ,GMRATXT,CNT,VADM,DFN,REACTANT,LOOP,DIFROM,EXTRA
112 S XMDUZ="PATCH GMRA*4*29 POST-INSTALL"
113 S XMY("DAVID.NABER@VA.GOV")="",XMY("CATHERINE.HOANG2@VA.GOV")=""
114 S XMY("HULET.LEE_ANN@FORUM.VA.GOV")=""
115 S EXTRA=($D(ERR(2))!($D(ERR(3))))
116 I 'EXTRA S XMY(.5)="" S:$G(DUZ) XMY(DUZ)=""
117 S CNT=1
118 S GMRATXT(CNT)="The post-install routine for patch GMRA*4*29",CNT=CNT+1
119 S GMRATXT(CNT)="finished on "_$$FMTE^XLFDT($$NOW^XLFDT)_".",CNT=CNT+1
120 S GMRATXT(CNT)="",CNT=CNT+1
121 I $G(ERR)=1 D
122 .S GMRATXT(CNT)="**NOTE: There was a problem with the installation!",CNT=CNT+1
123 .S GMRATXT(CNT)="Required entry missing from file 120.82 - CONVERSION ABORTED.",CNT=CNT+1
124 .S GMRATXT(CNT)="Contact the National Help Desk for Immediate assistance.",CNT=CNT+1
125 I $G(TU)!($G(TE))!($G(TF)) D
126 .S GMRATXT(CNT)="Here are the results of the update:",CNT=CNT+1
127 .S GMRATXT(CNT)="",CNT=CNT+1
128 .F LOOP="TU","TF","TE" D
129 ..S GMRATXT(CNT)=$S(+$G(@LOOP)=0:"No entries were",$G(@LOOP)=1:"One entry was",1:$G(@LOOP)_" entries were")_" "
130 ..S GMRATXT(CNT)=GMRATXT(CNT)_$S(LOOP="TU":"updated to new terms",LOOP="TF":"updated to have (FREE TEXT) appended to the term",1:"marked entered in error")_".",CNT=CNT+1
131 .S GMRATXT(CNT)="",CNT=CNT+1
132 S XMTEXT="GMRATXT(",XMSUB="PATCH GMRA*4*29 Post Install COMPLETED"
133 D ^XMD ;Send totals to OI reps, include local if no problems
134 F LOOP=2,3 D
135 .I $D(ERR(LOOP)) D
136 ..S GMRATXT(CNT)="The following patients have allergies that couldn't be converted",CNT=CNT+1
137 ..S GMRATXT(CNT)=$S(LOOP=2:"because the term to update them to couldn't be found in the local files.",1:"because it would create a duplicate entry."),CNT=CNT+1
138 ..S GMRATXT(CNT)="",CNT=CNT+1
139 ..S DFN=0 F S DFN=$O(ERR(LOOP,DFN)) Q:'+DFN D
140 ...K VADM D DEM^VADPT
141 ...S GMRATXT(CNT)="PATIENT: "_VADM(1)_" ("_$E(VADM(2),6,9)_")",CNT=CNT+1
142 ...S REACTANT="" F S REACTANT=$O(ERR(LOOP,DFN,REACTANT)) Q:REACTANT="" D
143 ....S GMRATXT(CNT)="Can't convert "_REACTANT_" to "_$P(ERR(LOOP,DFN,REACTANT),U,2)_" (file: "_$P(ERR(LOOP,DFN,REACTANT),U)_")",CNT=CNT+1
144 ...S GMRATXT(CNT)="",CNT=CNT+1
145 ..S $P(GMRATXT(CNT),"*",70)="*",CNT=CNT+1,GMRATXT(CNT)="",CNT=CNT+1
146 I EXTRA D
147 .K XMY S XMY(.5)="" S:$G(DUZ) XMY(DUZ)="" ;Send full report to local site only
148 .S XMTEXT="GMRATXT(",XMSUB="PATCH GMRA*4*29 Post Install COMPLETED"
149 .D ^XMD
150 Q
Note: See TracBrowser for help on using the repository browser.