Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: GMRAY40

GMRAY40.m

Go to the documentation of this file.
  1. GMRAY40 ;SLC/DAN Installation Utilities ;7/10/07 12:38
  1. ;;4.0;Adverse Reaction Tracking;**40**;Mar 29, 1996;Build 2
  1. ;
  1. ;DBIA SECTION
  1. ;3744 - $$TESTPAT^VADPT
  1. ;10061 - VADPT
  1. ;10013 - DIK
  1. ;2056 - DIQ
  1. ;10018 - DIE
  1. ;10070 - XMD
  1. ;10103 - XLFDT
  1. ;2051 - DIC
  1. ;
  1. PRETRAN ;Load conversion table into KIDS build
  1. M @XPDGREF@("GMRAFIX40")=^XTMP("GMRAFIX40")
  1. Q
  1. ;
  1. POST ;Post installation processes
  1. K ^XTMP("GMRAFIX40")
  1. M ^XTMP("GMRAFIX40")=@XPDGREF@("GMRAFIX40")
  1. I '$D(^XTMP("GMRAFIX40")) W !,"Conversion table not loaded - INSTALLATION ABORTED" S XPDQUIT=2 Q
  1. D Q Q ;Queue clean up to background
  1. ;
  1. Q ;
  1. N ZTRTN,ZTDESC,ZTIO,ZTDTH,ZTSK
  1. S ZTRTN="DQ^GMRAY40",ZTDESC="GMRA*4*40 POST INSTALL ROUTINE",ZTIO="",ZTDTH=$H
  1. D ^%ZTLOAD I '$G(ZTSK) D BMES^XPDUTL("POST INSTALL NOT QUEUED - RUN DQ^GMRAY40 AFTER INSTALL FINISHES") Q
  1. D BMES^XPDUTL("Post-install queued as task # "_$G(ZTSK))
  1. Q
  1. ;
  1. DQ ;Process begins here
  1. N ERR,TU,TE,TF
  1. D FIXB
  1. D FIXALG
  1. D MAIL
  1. S ^XTMP("GMRAFIX40",0)=$$FMADD^XLFDT(DT,30)_"^"_DT_"^Patch GMRA*4*40 conversion table"
  1. K ^XTMP("GMRAFX","FREE") ;Kill free text list so it forces rebuild
  1. Q
  1. ;
  1. FIXB ;Kill and reset "B" xref on file 120.8 to be sure it's correct
  1. N DIK
  1. K ^GMR(120.8,"B")
  1. S DIK="^GMR(120.8,"
  1. S DIK(1)=".01^B"
  1. D ENALL^DIK ;Resets B xref
  1. Q
  1. ;
  1. FIXALG ;Loop through 120.8 update existing free text entries
  1. N GMRAI,FREE,REACTANT,ENTRY,GMRAR
  1. S GMRAI=0 F S GMRAI=$O(^GMR(120.8,GMRAI)) Q:'+GMRAI D
  1. .I '$D(^GMR(120.8,GMRAI,0))!($L($G(^GMR(120.8,GMRAI,0)),"^")=1) D DEL Q
  1. .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
  1. .S REACTANT=$P(^GMR(120.8,GMRAI,0),U,2)
  1. .I REACTANT["ANGIOTEN"&(REACTANT["( FREE TEXT )") D Q
  1. ..S GMRAR=$$UP^XLFSTR($E($P(REACTANT," ( FREE TEXT )"),1,30)) ;Get just term
  1. ..S ENTRY=$G(^XTMP("GMRAFIX40",GMRAR)) ;Is entry in the table
  1. ..I ENTRY="" Q ;Entry not found or designated free text - leave alone
  1. ..D UPDATE ;Update entry from table
  1. .I REACTANT="ACE INHIBITORS" S GMRAR=REACTANT I $$CHANGED(.GMRAR) D
  1. ..S GMRAR=$E(GMRAR,1,30) ;Get 1st 30 chars of term
  1. ..S ENTRY=$G(^XTMP("GMRAFIX40",GMRAR))
  1. ..I ENTRY="",$D(^XTMP("GMRAFIX40",GMRAR)) S REACTANT=GMRAR D UPDATEF Q ;Convert term to FREE TEXT as it should have been
  1. ..I $D(^XTMP("GMRAFIX40",GMRAR)) D UPDATE
  1. Q
  1. ;
  1. DEL ;No zero node, remove entry
  1. N DIK,DA,GMRADONT
  1. S GMRADONT=1 ;Stop HDR from receiving update as it's not needed
  1. S DIK="^GMR(120.8,",DA=GMRAI
  1. D ^DIK
  1. Q
  1. ;
  1. UPDATEF ;Update reactant to say free text so users know it isn't a standardized entry
  1. N FDA,COM,FREE
  1. S FREE=$O(^GMRD(120.82,"B","OTHER ALLERGY/ADVERSE REACTION",0)),FREE=FREE_";GMRD(120.82,"
  1. Q:$G(REACTANT)["FREE TEXT" ;Already updated to free text, can skip.
  1. S REACTANT=REACTANT_" ( FREE TEXT )"
  1. S FDA(120.8,(GMRAI_","),.02)=REACTANT
  1. S FDA(120.8,(GMRAI_","),1)=FREE
  1. D FILE^DIE(,"FDA")
  1. S TF=$G(TF)+1 ;Increment total free text updated counter
  1. S COM="Updated using the auto clean up process from GMRA*4*40. Changed reactant from ACE INIHIBITORS (file - 50.605) to "_REACTANT
  1. D ADCOM^GMRAFX(GMRAI,"O",COM)
  1. Q
  1. ;
  1. UPDATEE ;Mark as entered in error, check for NKA
  1. N DIE,DA,DR,DFN,USER,TIME
  1. S DFN=$P(^GMR(120.8,GMRAI,0),U) ;Patient's IEN
  1. S USER=$P(^GMR(120.8,GMRAI,0),U,5),TIME=$P(^(0),U,4)
  1. S DIE="^GMR(120.8,",DA=GMRAI,DR="22///1;23///NOW;24////"_$G(DUZ,.5)
  1. D ^DIE ;Entry is now entered in error
  1. D ADCOM^GMRAFX(GMRAI,"E","Marked entered in error by auto-update in patch GMRA*4*40") ;Adds comment to allergy record
  1. I $$NKASCR^GMRANKA(DFN) D
  1. .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
  1. .D CLN^GMRANKA ;Delete assessment
  1. S TE=$G(TE)+1 ;Increment total entered in error counter
  1. Q
  1. ;
  1. UPDATE ;Update free text entry to data found in table
  1. N DFN,DIE,DA,DR,AIFN,COM,SIEN,FILE,NAME,IEN,GMRAAR,GMRAPA,GMRASCR,ERRCODE
  1. S DFN=$P(^GMR(120.8,GMRAI,0),U)
  1. S GMRAPA=GMRAI
  1. S FILE=$P(ENTRY,U),NAME=$P(ENTRY,U,2)
  1. S IEN=$$FIND1^DIC(FILE,"",$S(FILE=120.82:"X",1:"MX"),NAME,$S(FILE=120.82:"B",1:""),,"ERRCODE")
  1. I '+IEN S IEN=$$FIND1^DIC(FILE,"","MX",NAME_" ","",,"ERRCODE")
  1. I '+IEN,NAME="ANTIMUSCARINICS/ANTISPASMODICS" S IEN=$$FIND1^DIC(FILE,"","MX","GA801","",,"ERRCODE")
  1. I '+IEN,$L($T(SCREEN^XTID)) S GMRASCR="I '$$SCREEN^XTID(FILE,,Y_"","")" S IEN=$$FIND1^DIC(FILE,"","MX",NAME,"",$G(GMRASCR),"ERRCODE")
  1. I '+IEN S ERR(2,DFN,REACTANT)=ENTRY D UPDATEF Q
  1. 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,")
  1. S GMRAAR(0)=NAME
  1. S GMRAAR("O")=$S(FILE=120.82:$P(^GMRD(120.82,IEN,0),U,2),1:"D")
  1. I $$DUP^GMRAFX3 S ERR(3,DFN,REACTANT)=ENTRY D UPDATEF Q ;Would create a duplicate if update occur
  1. ;Update reactant, allergy and signed off fields
  1. S DIE="^GMR(120.8,",DA=GMRAPA,DR=".02////"_GMRAAR(0)_";1////^S X=GMRAAR"_";3.1////"_GMRAAR("O")_";15///1" D ^DIE
  1. I $D(^GMR(120.85,"C",GMRAPA)) D ;Observed reaction, need to update data
  1. .S AIFN=0
  1. .F S AIFN=$O(^GMR(120.85,"C",GMRAPA,AIFN)) Q:'+AIFN D
  1. ..S SIEN=$O(^GMR(120.85,AIFN,3,"B",REACTANT,0)) Q:'+SIEN ;Was previous reactant stored as "suspected agent"
  1. ..S DA(1)=AIFN,DA=SIEN
  1. ..S DIE="^GMR(120.85,DA(1),3,",DR=".01////^S X=GMRAAR(0)" D ^DIE ;Update suspected agent to new value
  1. D DELMUL^GMRAFX3(2),DELMUL^GMRAFX3(3) ;Delete drug ingredient/drug classes multiples
  1. I GMRAAR("O")["D" D UPDATE^GMRAPES1 K LIST ;If reactant type is Drug then add appropriate ingredients and classes
  1. S COM="Updated using auto clean up process from GMRA*4*40. Changed reactant from ACE INHIBITORS (file - 50.605) to "_GMRAAR(0)_" (file - "_$P(GMRAAR,";",2)_")"
  1. D ADCOM^GMRAFX(GMRAPA,"O",COM) ;Add a comment for this update
  1. S TU=$G(TU)+1 ;Increment total updated counter
  1. Q
  1. ;
  1. MAIL ;Send message indicating post install is finished
  1. N XMSUB,XMTEXT,XMDUZ,XMY,XMZ,GMRATXT,CNT,VADM,DFN,REACTANT,LOOP,DIFROM,EXTRA
  1. S XMDUZ="PATCH GMRA*4*40 POST-INSTALL"
  1. S XMY("DAVID.NABER@DOMAIN.EXT")="",XMY("CATHERINE.HOANG2@DOMAIN.EXT")=""
  1. S XMY("HULET.LEE_ANN@DOMAIN.EXT")="",XMY("KEN.BARLOW@DOMAIN.EXT")=""
  1. S EXTRA=($D(ERR(2))!($D(ERR(3))))
  1. I 'EXTRA S XMY(.5)="" S:$G(DUZ) XMY(DUZ)=""
  1. S CNT=1
  1. S GMRATXT(CNT)="The post-install routine for patch GMRA*4*40",CNT=CNT+1
  1. S GMRATXT(CNT)="finished on "_$$FMTE^XLFDT($$NOW^XLFDT)_".",CNT=CNT+1
  1. S GMRATXT(CNT)="",CNT=CNT+1
  1. I $G(ERR)=1 D
  1. .S GMRATXT(CNT)="**NOTE: There was a problem with the installation!",CNT=CNT+1
  1. .S GMRATXT(CNT)="Required entry missing from file 120.82 - CONVERSION ABORTED.",CNT=CNT+1
  1. .S GMRATXT(CNT)="Contact the National Help Desk for Immediate assistance.",CNT=CNT+1
  1. I $G(TU)!($G(TE))!($G(TF)) D
  1. .S GMRATXT(CNT)="Here are the results of the update:",CNT=CNT+1
  1. .S GMRATXT(CNT)="",CNT=CNT+1
  1. .F LOOP="TU","TF","TE" D
  1. ..S GMRATXT(CNT)=$S(+$G(@LOOP)=0:"No entries were",$G(@LOOP)=1:"One entry was",1:$G(@LOOP)_" entries were")_" "
  1. ..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
  1. .S GMRATXT(CNT)="",CNT=CNT+1
  1. S XMTEXT="GMRATXT(",XMSUB="PATCH GMRA*4*40 Post Install COMPLETED"
  1. D ^XMD ;Send totals to OI reps, include local if no problems
  1. F LOOP=2,3 D
  1. .I $D(ERR(LOOP)) D
  1. ..S GMRATXT(CNT)="The following patients have allergies that couldn't be converted",CNT=CNT+1
  1. ..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
  1. ..S GMRATXT(CNT)="",CNT=CNT+1
  1. ..S DFN=0 F S DFN=$O(ERR(LOOP,DFN)) Q:'+DFN D
  1. ...K VADM D DEM^VADPT
  1. ...S GMRATXT(CNT)="PATIENT: "_VADM(1)_" ("_$E(VADM(2),6,9)_")",CNT=CNT+1
  1. ...S REACTANT="" F S REACTANT=$O(ERR(LOOP,DFN,REACTANT)) Q:REACTANT="" D
  1. ....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
  1. ...S GMRATXT(CNT)="",CNT=CNT+1
  1. ..S $P(GMRATXT(CNT),"*",70)="*",CNT=CNT+1,GMRATXT(CNT)="",CNT=CNT+1
  1. I EXTRA D
  1. .K XMY S XMY(.5)="" S:$G(DUZ) XMY(DUZ)="" ;Send full report to local site only
  1. .S XMTEXT="GMRATXT(",XMSUB="PATCH GMRA*4*40 Post Install COMPLETED"
  1. .D ^XMD
  1. Q
  1. ;
  1. CHANGED(GMRAR) ;Was entry changed by patch 29?
  1. N CHANGED,SUB
  1. S CHANGED=0
  1. S SUB=0 F S SUB=$O(^GMR(120.8,GMRAI,26,SUB)) Q:'+SUB!(CHANGED) D
  1. .I $G(^GMR(120.8,GMRAI,26,SUB,2,1,0))["GMRA*4*29" S GMRAR=$$UP^XLFSTR($P($P(^GMR(120.8,GMRAI,26,SUB,2,1,0),"reactant from ",2)," (free text)",1)) ;get term and upper case it
  1. .I $G(^GMR(120.8,GMRAI,26,SUB,2,1,0))["GMRA*4*29",$G(GMRAR)["ANGIOTEN" S CHANGED=1
  1. Q CHANGED