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

GMRAFX3.m

Go to the documentation of this file.
  1. GMRAFX3 ;SLC/DAN Update existing entries to new reactant ;09-May-2013 09:54;MGH
  1. ;;4.0;Adverse Reaction Tracking;**17,19,23,20,1007**;Mar 29, 1996;Build 18
  1. ;DBIA SECTION
  1. ;10018 - DIE
  1. ;2056 - DIQ
  1. ;3154 - ORQ1
  1. ;4134 - ORCHECK
  1. ;4135 - ORKCHK
  1. ;10026 - DIR
  1. ;
  1. UIE ;Update individual entries
  1. N DFN,GMRAOUT,GMRAING,GMRADRCL,DIE,DA,DR,AIFN,SIGN,TIME,SUB,ORX,GMRAORX,GMRAOC,GI,FND,COM,SIEN,DIR,Y
  1. S GMRADONE=0 ;Flag to keep track of updated entries
  1. S DFN=$P($G(^GMR(120.8,GMRAPA,0)),U) Q:'+DFN
  1. W !!,"For patient ",$$GET1^DIQ(2,DFN_",",.01),!
  1. I $D(GMRAAR) D
  1. .S DIR(0)="Y",DIR("A")="Use reactant "_GMRAAR(0),DIR("B")="Y" D ^DIR
  1. .K:'Y GMRAAR
  1. .Q
  1. I '$D(GMRAAR) D ^GMRAFX2 I $D(GMRAAR) D RUSURE(.GMRASURE) ;20 Get new reactant
  1. I '$D(GMRAAR)!('$G(GMRASURE)) K GMRAAR Q ;20 stop if no reactant selected or if user doesn't want to use selected reactant
  1. S GMRAOUT=0
  1. I $$DUP W !,"Patient already has an active allergy for this reactant.",!,"Duplicate not allowed.",! D WAIT Q
  1. I $$DUPCHK^GMRAPES0(GMRAAR(0),DFN,GMRAPA) Q ;Checks to see if reactant previously entered in error.
  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",$P(^XTMP("GMRAFX",LTYPE,"IDX",+NMBR),"^"),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(2),DELMUL(3) ;Delete drug ingredient/drug classes multiples
  1. I GMRAAR("O")["D" D UPDATE^GMRAPES1 ;If reactant type is Drug then add appropriate ingredients and classes
  1. S GMRADONE=1 ;Update complete
  1. 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)_")"
  1. D ADCOM^GMRAFX(GMRAPA,"O",COM) ;Add a comment for this update
  1. ;Do order checking here - compare existing orders against new allergy information.
  1. W !,"Performing order checking..."
  1. K ^TMP("ORR",$J),GMRAOC,ORX
  1. D EN^ORQ1(DFN_";DPT(") ;Retrieve active orders
  1. S TIME=$O(^TMP("ORR",$J,0))
  1. I '^TMP("ORR",$J,TIME,"TOT") W "patient has no active orders." Q ;20 No orders found
  1. S SUB=0 F S SUB=$O(^TMP("ORR",$J,TIME,SUB)) Q:'+SUB D
  1. .D BLD^ORCHECK(+^TMP("ORR",$J,TIME,SUB)) ;Get "order" information in order checking format
  1. M GMRAORX=ORX K ORX ;19
  1. D EN^ORKCHK(.GMRAOC,DFN,.GMRAORX,"ACCEPT")
  1. S GI=0,FND=0 F S GI=$O(GMRAOC(GI)) Q:'+GI D
  1. .Q:$P(GMRAOC(GI),U,2)'=3 ;Quit if not allergy related
  1. .Q:$D(^OR(100,$P(GMRAOC(GI),U),9,"B",3)) ;23 If order check exists can't be for this data
  1. .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)
  1. .S FND=1
  1. W:'FND "No problems found"
  1. D WAIT
  1. Q
  1. ;
  1. DELMUL(FIELD) ;Delete multiple FIELD from GMR ALLERGY file
  1. N MIEN,DA,DIE,DR
  1. S MIEN=0 F S MIEN=$O(^GMR(120.8,GMRAPA,FIELD,MIEN)) Q:'+MIEN D
  1. .S DA(1)=GMRAPA,DA=MIEN
  1. .;IHS/MSC/MGH remove SNOMED and UNI patch 1007
  1. .I FIELD=2 S DIE="^GMR(120.8,DA(1),FIELD,",DR=".01///@;9999999.01///@;9999999.02///@"
  1. .I FIELD=3 S DIE="^GMR(120.8,DA(1),FIELD,",DR=".01///@"
  1. .D ^DIE ;Delete entry
  1. Q
  1. ;
  1. DUP() ;Function returns true (1) if selected reactant is a duplicate
  1. N LOOP,FND
  1. S LOOP=0,FND=0
  1. F S LOOP=$O(^GMR(120.8,"B",DFN,LOOP)) Q:'+LOOP!(FND) D
  1. .I $P(^GMR(120.8,LOOP,0),U,3)=GMRAAR&('$D(^GMR(120.8,LOOP,"ER"))) S FND=1
  1. Q FND
  1. ;
  1. WAIT ;Issues press enter to return prompt
  1. N DIR
  1. S DIR(0)="E",DIR("A")="Press enter to continue" D ^DIR
  1. Q
  1. ;
  1. GETNUM(ACTION) ; -- Return numbers to act on, if action chosen first
  1. N X,Y,DIR,MAX
  1. S MAX=$S($D(^TMP($J,LTYPE,"IDX2")):$G(^TMP($J,LTYPE,"IDX2",0)),1:$G(VALMCNT)) Q:MAX'>0 ""
  1. I ACTION="DET" W !!,"Please choose only one entry for the detailed display."
  1. S DIR(0)="LAO^1:"_MAX,DIR("A")="Select Entries from list: "
  1. S DIR("?")="Enter the items you wish to act on, as a range or list of numbers."
  1. D ^DIR S:$D(DTOUT) Y="^"
  1. I $D(Y(1)) W !,">>>Too many entries selected, try using smaller ranges" H 2 S Y="^"
  1. I $L($G(Y),",")>2,ACTION="DET" W !,">>You may only choose ONE group for detailed display." H 2 S Y="^"
  1. Q Y
  1. ;
  1. UPDATE ;Update display to account for changes to the list
  1. N CNT,SP1,SP2,SP3
  1. I VALMAR["GMRADET" N VALMAR S VALMAR="^XTMP(""GMRAFX"",LTYPE)"
  1. S CNT=^XTMP("GMRAFX",LTYPE,"GMRAR",$P(ENTRY,U),$P(ENTRY,U,2))-1
  1. S ^XTMP("GMRAFX",LTYPE,"GMRAR",$P(ENTRY,U),$P(ENTRY,U,2))=CNT K ^($P(ENTRY,U,2),GMRAJ)
  1. S SP1=4-$L(+NUM),SP2=40-$L($P(ENTRY,U)),SP3=$S(CNT:16-$L(CNT)\2,1:2)
  1. D SET^VALM10(+NUM,+NUM_$$REPEAT^XLFSTR(" ",SP1)_$P(ENTRY,U,2)_$$REPEAT^XLFSTR(" ",(SP2+SP3))_$S(CNT:CNT,1:"** FIXED **"))
  1. Q
  1. ;
  1. LOCK(ENTRY) ;Lock entry in 120.8
  1. N LOCK
  1. S LOCK=1
  1. L +^XTMP("GMRAFX",LTYPE,"IDX",ENTRY):1
  1. 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
  1. Q LOCK
  1. ;
  1. AR ;Add/edit patient reactions
  1. N LCV,DFN,SUB
  1. S VALMBCK="R" D FULL^VALM1
  1. W !!,"You should use this option to add NEW reactions only. If you mark"
  1. W !,"existing entries as entered in error from within this option it will"
  1. W !,"not update the utility's display until the list is rebuilt upon re-entry"
  1. W !,"of this option. This could cause confusion as the list will no longer"
  1. W !,"be accurate.",!
  1. I '$G(NMBR2) D WAIT,EN1^GMRAPEM0 Q
  1. 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
  1. Q
  1. ;
  1. DSPREACT ;Display detailed information about the reactant
  1. N DIC,DA,GMRAI,STOP,NUM2,DIR,Y
  1. S VALMBCK="R" D FULL^VALM1
  1. I '$G(NMBR2) S NMBR2=$$GETNUM("") Q:'+NMBR2
  1. F GMRAI=1:1:($L(NMBR2,",")-1) D Q:$G(STOP)
  1. .S NUM2=$P(NMBR2,",",GMRAI)
  1. .S DA=$P(^TMP($J,LTYPE,"IDX2",NUM2),U,2) Q:'DA
  1. .S DIC="^GMR(120.8,"
  1. .W ! D EN^DIQ
  1. .S DIR(0)="E",DIR("A")="Press return to continue or '^' to stop" D ^DIR
  1. .S:$D(DIRUT) STOP=1
  1. .Q
  1. Q
  1. ;
  1. GETTYPE(LTYPE) ;Function determines which list to work with
  1. N DIR,X,Y
  1. S DIR(0)="SO^1:Free Text;2:Ingredient;3:Drug Class"
  1. S DIR("A")="Select the list you wish to work with"
  1. D ^DIR K DIR
  1. S LTYPE=$S(Y=1:"FREE",Y=2:"ING",Y=3:"DRUG",1:0)
  1. Q LTYPE
  1. ;
  1. EIE ;Mark individual entry as entered in error
  1. N DIE,DA,DR,Y,DIK,DFN,OROLD,VAIN,X,GMRAOUT
  1. S DIE="^GMR(120.8,",DA=GMRAPA,DR="15///1;22///1;23///NOW;24////"_$G(DUZ,.5) ;20
  1. D ^DIE ;Entered in error on date/time by user
  1. D ADCOM^GMRAFX(GMRAPA,"E","Marked Entered in Error during clean up process")
  1. I $$NKASCR^GMRANKA($P(^GMR(120.8,GMRAPA,0),U)) D
  1. .S DIK="^GMR(120.86,",DA=$P(^GMR(120.8,GMRAPA,0),U)
  1. .D ^DIK ;If patient's last allergy marked as entered in error then delete assessment
  1. .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",!
  1. .W "now by answering the following prompt or hit return to do it later.",!
  1. .D NKAASK^GMRANKA(DA)
  1. S GMRAPA(0)=$G(^GMR(120.8,GMRAPA,0)) Q:GMRAPA(0)=""
  1. S GMRAOUT=0
  1. D EN1^GMRAEAB ;Sends entered in error bulletin to appropriate mail groups
  1. S DFN=$P(GMRAPA(0),U)
  1. D INP^VADPT S X=$$FIND1^DIC(101,,"BX","GMRA ENTERED IN ERROR")_";ORD(101," ;19
  1. D:X EN^XQOR ;Process protocols hanging off of "entered in error" protocol
  1. Q
  1. ;
  1. RUSURE(GMRASURE) ;20 Make sure selection from ingredient or drug class file is ok
  1. ;entire section added in patch 20
  1. N DIR,Y,X
  1. S GMRASURE=1
  1. I $G(GMRAAR)["50.416"!($G(GMRAAR)["50.605") D
  1. .S DIR("A")="Are you sure you want to use this reactant"
  1. .S DIR("A",1)="You are about to update the entry with a selection from"
  1. .S DIR("A",2)="the "_$S($G(GMRAAR)["50.416":"INGREDIENT",1:"VA DRUG CLASS")_" file. By doing that you are"
  1. .S DIR("A",3)="limiting the information available for order checking."
  1. .S DIR("A",4)=""
  1. .S DIR("A",5)="In general, it is better to choose from one of the drug related files"
  1. .S DIR("A",6)="as that ensures that drug class and ingredient information are part"
  1. .S DIR("A",7)="of the patient's allergy definition and will provide better allergy"
  1. .S DIR("A",8)="order checking."
  1. .S DIR("A",9)=""
  1. .S DIR(0)="Y",DIR("B")="NO"
  1. .D ^DIR S GMRASURE=+Y
  1. Q