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

GMRAPED3.m

Go to the documentation of this file.
GMRAPED3 ;HIRMFO/YMP,RM-VALIDATE ENTRY FOR .02 FIELD IN FILE 120.8 ;16-Mar-2011 09:16;DU
 ;;4.0;Adverse Reaction Tracking;**1002**;Mar 29, 1996;Build 32
EN1 ; GIVEN DFN, SELECT PATIENT ALLERGY
 K GMRAAR S GMRAAR=""
 W !!,"CAUSATIVE AGENT: "_$P(GMRAPA(0),"^",2)_"//  (Uneditable)"
 Q
REAC ;EP Called to reactivate an inactive entry
 N GMRAOUT,GMRA,DFN
 S GMRAOUT=0
 W @IOF D PAT^GMRAPAT ; Select A Patient
 D:'GMRAOUT EN21
 ;G:'GMRAOUT REAC
 K DFN,DIC,GMRAOUT,GMRARET,GMA,GMRAUSER
 D EN1^GMRAKILL
 Q
EN21 ;Load the inactive allergies and ask user to select one
 N GMRAIEN,GMALAR,GMRAOUT,GMRACNT,VADM,GMRALOC,GMRANAM,GMRASEX,X
 S GMRACNT=0 D 1^VADPT
 S GMRALOC=$P(VAIN(4),U,2),GMRANAM=VADM(1),GMRASEX=VADM(5)
 D LIST(DFN,.GMRAL)
 I GMRAL=0  W !,"This patient has no inactive allergies" Q
 I GMRAL D EN1^GMRADSP0(.GMRAL) Q:GMRAOUT
 R !!,"Enter Item to Reactivate: ",GMRALAR:DTIME S:'$T GMRALAR="^^" S:GMRALAR="" GMRARET=1 I "^^"[GMRALAR S GMRAOUT='$L(GMRALAR)+1 G REAC
 I GMRALAR?1P.E!($L(GMRALAR)<3)!($L(GMRALAR)>30) S GMRAHLP=1 D EN1^GMRAHLP0 G EN1:'GMRAOUT
 I GMRALAR?.E1L.E S GMRALAR=$$UP^XLFSTR(GMRALAR)
 K Y,DTOUT,DUOUT S DGSENFLG="",DIC="^GMR(120.8,",DIC(0)="SEZ",X=GMRANAM,DIC("S")="I '+$G(^(""ER"")),$P(^(0),U,2)?@(""1""""""_GMRALAR_"""""".E""),$D(^GMR(120.8,""B"",DFN,+Y))",DIC("W")="W $P(^(0),U,2)"
 W !!,"Checking existing PATIENT ALLERGIES (#120.8) file for matches..."
 D ^DIC S X=$P($G(Y(0)),"^",2) K DIC,DGSENFLG,DTOUT,DUOUT D DIC I GMRAOUT S GMRAOUT=GMRAOUT-1 G:GMRAOUT Q1 G REAC
 S:+Y>0 GMRAPA=+Y G Q1:+Y<1!GMRAOUT
 I +GMRAPA D
 .D REACT(DFN,GMRAPA)
 .S X=$$FIND1^DIC(101,,"BX","GMRA ALLERGY UPDATE")_";ORD(101,"
 .D:X EN^XQOR ;Process protocols hanging off this protocol
 Q
REACT(DFN,GMRAPA) ;Find the entry to inactivate
 N Z,INACT,REACT,VAL,DATA
 S Z=9999999 S Z=$O(^GMR(120.8,GMRAPA,9999999.12,Z),-1) I +Z D
 .S INACT=$P($G(^GMR(120.8,GMRAPA,9999999.12,Z,0)),U,1)
 .S REACT=$P($G(^GMR(120.8,GMRAPA,9999999.12,Z,0)),U,4)
 .I +INACT&(REACT="") D
 ..S VAL("GMRAINACT")=INACT
 ..D RESET(.DATA,GMRAPA,DFN,.VAL)
 ..I DATA=GMRAPA W !,"Reaction has been reactivated" D HANGT^GMRAPEH0 G REAC
 Q
LIST(DFN,GMRA) ;Get all the reaction for a patient
 N GMRAPA,Z,INACT,REACT,INZ
 S (GMRAPA,GMRA)=0
 F  S GMRAPA=$O(^GMR(120.8,"B",DFN,GMRAPA)) Q:GMRAPA<1  D
 .Q:$G(^GMR(120.8,GMRAPA,0))=""
 .Q:+$G(^GMR(120.8,GMRAPA,"ER"))
 .S INZ=0
 .S Z=9999999 S Z=$O(^GMR(120.8,GMRAPA,9999999.12,Z),-1) I +Z D
 ..S INACT=$P($G(^GMR(120.8,GMRAPA,9999999.12,Z,0)),U,1)
 ..S REACT=$P($G(^GMR(120.8,GMRAPA,9999999.12,Z,0)),U,4)
 ..I +INACT&(REACT="") S INZ=1
 .I INZ=1 D
 ..D PASS^GMRADPT(GMRAPA,.GMRA)
 ..I 'GMRA S GMRA=1
 .Q
 Q
Q1 ;
 S:GMRAPA>0 GMRAPA(0)=$S($D(^GMR(120.8,+GMRAPA,0)):^(0),1:"")
 K %,D,DA,DIC,DTOUT,DUOUT,GMRAAR,GMRAHLP,GMRAING,GMRALAGO,GMRALAR,PSNDA,PSODA,X,Y
 Q
DIC ; VALIDATE LOOKUP FOR A/AR
 S:$D(DTOUT) X="^^" I X="^^" S GMRAOUT=1 Q
 S:$D(DUOUT) Y=0 Q:+Y'>0
YNOK W !?3,X,"   OK" S %=1 D YN^DICN S:%=-1 GMRAOUT=1,Y=-1 Q:GMRAOUT
 S:%=2 Y=-1 Q:Y=-1  I % W ! Q  ;19
 W !?5,$C(7),"ANSWER YES IF THIS IS THE CORRECT ALLERGY/ADVERSE REACTION,",!?5,"ELSE ANSWER NO."
 G YNOK
 ;reactivate allergy
RESET(DATA,GMRAPA,DFN,VAL) ;Reactivate
 N X,Y,STOP,FNUM,AIEN,BIEN,ERR,SIEN,SIEN,MIEN,IEN,CANVER,VER
 I GMRAPA="" S DATA="-1^Missing entry to reactivate" Q
 D CKIN^BEHOARMU(DFN)
 S STOP=0,FNUM=120.899999912,BIEN=GMRAPA
 S SIEN=$O(^GMR(120.8,GMRAPA,9999999.12,$C(0)),-1)
 I STOP!'SIEN S DATA="-1^Unable to find entry to reactivate" Q
 S AIEN=SIEN_","_GMRAPA_","
 I $G(VAL("GMRAINREBY"))="" S VAL("GMRAINREBY")=DUZ
 I $G(VAL("GMRAINRE"))="" S VAL("GMRAINRE")=$$NOW^XLFDT
 S FDA(120.899999912,AIEN,3)=$G(VAL("GMRAINRE"))
 S FDA(120.899999912,AIEN,4)=$G(VAL("GMRAINREBY"))
 D UPDATE^DIE(,"FDA","IEN","ERR")
 I $G(ERR("DIERR",1)) S DATA=-ERR("DIERR",1)_U_ERR("DIERR",1,"TEXT",1) Q
 S DATA=GMRAPA
 K FDA,ERR
 ;Remove the verification, must be redone
 S AIEN=BIEN_","
 S FDA(120.8,AIEN,19)="@"
 S FDA(120.8,AIEN,20)="@"
 S FDA(120.8,AIEN,21)="@"
 D FILE^DIE("","FDA","ERR")
 S CANVER=$$HASKEY^BEHOUSCX("GMRA-ALLERGY VERIFY")
 I $$CANVERIF^BEHOART(GMRAPA,.VER)!(CANVER=1) D
 .S AIEN=BIEN_","
 .S FDA(120.8,AIEN,19)=1
 .S FDA(120.8,AIEN,20)=$$NOW^XLFDT
 .S FDA(120.8,AIEN,21)=DUZ
 .D UPDATE^DIE(,"FDA","IEN","ERR")
 D FIREEVT^BEHOART(DFN,1,GMRAPA)
 K FDA,ERR
 Q