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

GMRADPT.m

Go to the documentation of this file.
  1. GMRADPT ;HIRMFO/RM,WAA-UTILITY TO GATHER PATIENT DATA ;18-Mar-2011 10:56;MGH
  1. ;;4.0;Adverse Reaction Tracking;**2,10,1002**;Mar 29, 1996;Build 32
  1. ;IHS/MSC/MGH Inactive node added
  1. EN1 ; ENTRY TO GATHER PATIENT A/AR DATA
  1. ;INPUT VARIABLES:
  1. ;
  1. ; DFN Pointer to Patient file.
  1. ; GMRA (OPTIONAL) A^B^C DEFAULT="0^0^111"
  1. ; where A = 0 return all reactions (allergic/non-allergic).
  1. ; 1 return allergies only.
  1. ; 2 return non-allergies only.
  1. ; B = 0 return all data (verified or non-verified).
  1. ; 1 return only verified data.
  1. ; 2 return only non-verified data.
  1. ; C = X_Y_Z
  1. ; where X, Y, and Z are either 0 or 1. 1 would mean to
  1. ; return an Adverse Reaction of that particular type,
  1. ; and zero means do not return an Adverse Reaction of
  1. ; that type.
  1. ; X is for TYPE=OTHER
  1. ; Y is for TYPE=FOOD
  1. ; Z is for TYPE=DRUG.
  1. ; E.g., 001 (return drug only), 111 (returns all types),
  1. ; and 010 (returns food only).
  1. ; D=1 Include inactive allergies
  1. ;OUTPUT VARIABLES:
  1. ; GMRAL = 1 if patient has Adverse Reaction
  1. ; 0 if patient has no known Adverse Reaction
  1. ; null if patient has not been asked about Adverse Reaction
  1. ; GMRAL(PTR TO 120.8) = A^B^C^D^E^F^G^H^I
  1. ; where A = Pointer to Patient file.
  1. ; B = Free text of causative agent.
  1. ; *C = Type of reaction, where D is drug, F is food, and O is
  1. ; other.
  1. ; D = 1 if Adverse Reaction has been verified
  1. ; 0 if Adverse Reaction has not been verified
  1. ; E = 0 if this is an allergic reaction
  1. ; 1 if this is not an allergic reaction
  1. ; **F = the mechanism of reaction in the format:
  1. ; External format;Internal format
  1. ; (ALLERGY;0, PHARMACOLOGIC;2, UNKNOWN;U).
  1. ; G = Type of reaction.
  1. ; where D = drug
  1. ; DF = drug/food
  1. ; DFO = drug/food/other
  1. ; DO = drug/other
  1. ; F = food
  1. ; FO = food/other
  1. ; O = other
  1. ; H = the mechanism of reaction in the format:
  1. ; External format;Internal format
  1. ; (ALLERGY;A, PHARMACOLOGIC;P, UNKNOWN;U)
  1. ; I = IEN and Global root of reactant (stored in piece B above)
  1. ; set equal to the GMR ALLERGY field (#1) of the PATIENT
  1. ; ALLERGY file (#120.8)
  1. ; GMRAL(PTR TO 120.8,"S",COUNT) = S
  1. ; where COUNT = number 1 to number of signs/symptoms for this
  1. ; reaction.
  1. ; S = a sign/symptom for this reaction in the format:
  1. ; External format;Internal format
  1. ;
  1. ;* NOTE: This piece will no longer be supported after 9/1/97,
  1. ; Please use piece G.
  1. ;** NOTE: This piece will no longer be supported after 9/1/97,
  1. ; Please use piece H.
  1. ;
  1. N GMRAOTH
  1. Q:'$D(DFN) S:'$D(GMRA)#2 GMRA="0^0^111" K GMRAL
  1. DPT ;
  1. ;Read NKA Node in file 120.86
  1. S GMRAL=$P($G(^GMR(120.86,DFN,0)),U,2)
  1. ;Do not set GMRAL array if patient is unassessed or NKA.
  1. I GMRAL=0 Q ;PATIENT HAS NO KNOWN ALLERGIES
  1. F GMRAREC=0:0 S GMRAREC=$O(^GMR(120.8,"B",DFN,GMRAREC)) Q:GMRAREC'>0 S GMRANODE=$S($D(^GMR(120.8,GMRAREC,0)):^(0),1:"") D:GMRANODE SETAL
  1. I GMRAL=1,+$O(GMRAL(0))'>0 S GMRAL=0 ;if flag is set to 1 (reactions exist), then make certain the reactions are passed in the GMRAL array
  1. K GMRA,GMRANODE,GMRAOSOF,GMRAREC,GMRATCNT
  1. Q
  1. SETAL ;
  1. N %,GMRAI,GMRASIGN,CHK
  1. ;Q:'$P(GMRANODE,"^",12)&'$D(GMRAOSOF) ;IF NOT SIGNED OFF MARK IT
  1. Q:+$G(^GMR(120.8,GMRAREC,"ER"))&'$D(GMRAERR) ;IF ENTERED IN ERROR QUIT
  1. S CHK=$$CHK(GMRAREC)
  1. Q:CHK=1
  1. I GMRAL'=1 S GMRAL=1 ; PATIENT HAS ALLERGIES
  1. S GMRAI=0 ; BEGIN CHECK FOR ADR/ALL CRITERIA
  1. I '$P(GMRA,"^") S GMRAI=1
  1. E I $P(GMRA,"^")=1 S:$F("AU",$P(GMRANODE,"^",14))>1 GMRAI=1
  1. E S:$F("P",$P(GMRANODE,"^",14))>1 GMRAI=1
  1. Q:'GMRAI ; QUIT IF ADR/ALL CRITERIA NOT MET
  1. Q:2-$P(GMRA,"^",2)=(1-$P(GMRANODE,"^",16)) ;QUIT IF VER/NON VER CRITERIA NOT MET
  1. S GMRAI=0 ; BEGIN CHECK FOR ALLERGY TYPE CRITERIA
  1. F %=1:1:3 I $E($P(GMRA,"^",3),%),$P(GMRANODE,"^",20)[$E("OFD",%) S GMRAI=1 Q
  1. Q:'GMRAI ; QUIT IF ALLERGY TYPE CRITERIA NOT MET
  1. D PASS(GMRAREC,.GMRAL)
  1. Q
  1. PASS(GMRAREC,GMRAL) ; Data filer
  1. ; This subroutine will store all the patient date for a reaction is an
  1. ; array.
  1. ; Input:
  1. ; GMRAREC = The IEN for the entry in 120.8
  1. ;Output:
  1. ; GMRAL(GMRAREC) the array entry for the record
  1. ;
  1. N GMRANODE,GMRAIN,GMRINODE,GMRAY2,GMRAZ2,GMRASRC,GMRAZSRC,GMRASNO,GMTAZT,GMRAX,GMRAY,GMRAY2,GMRAZ,GMRAZT
  1. S GMRANODE=$G(^GMR(120.8,GMRAREC,0)) Q:GMRANODE=""
  1. S GMRASRC=$P($G(^GMR(120.8,GMRAREC,9999999.11)),U,1)
  1. S GMRASNO=$P($G(^GMR(120.8,GMRAREC,9999999.11)),U,2)
  1. ;IHS/MSC/MGH Added node for inactive
  1. S GMRINODE=$G(^GMR(120.8,GMRAREC,9999999.12))
  1. S %=$P(GMRANODE,"^",14)
  1. S GMRAL(GMRAREC)=$P(GMRANODE,"^",1,2)_"^"_$E($P(GMRANODE,"^",20))_"^"_+$P(GMRANODE,"^",16)_"^"_$S(%="A"!(%="U"):0,1:1)
  1. S GMRAL(GMRAREC)=GMRAL(GMRAREC)_"^"_$S(%="A":"ALLERGY;0",%="P":"PHARMACOLOGIC;2",%="U":"UNKNOWN;U",1:"")_"^"_$P(GMRANODE,"^",20)_"^"_$S(%="A":"ALLERGY;A",%="P":"PHARMACOLOGIC;P",%="U":"UNKNOWN;U",1:"")
  1. S GMRAL(GMRAREC)=GMRAL(GMRAREC)_"^"_$P(GMRANODE,"^",3)
  1. S GMRAL(GMRAREC)=GMRAL(GMRAREC)_"^"_GMRASRC_"^"_GMRASNO
  1. Q:'$O(^GMR(120.8,GMRAREC,10,0)) ;QUIT IF NO SIGNS/SYMPTOMS
  1. S:'$D(GMRAOTH) GMRAOTH=$O(^GMRD(120.83,"B","OTHER REACTION",0))
  1. S GMRAX=0,GMRAY=1 F S GMRAX=$O(^GMR(120.8,GMRAREC,10,GMRAX)) Q:GMRAX<1 D I GMRAZ'="" S GMRAL(GMRAREC,"S",GMRAY)=GMRAZ(1),GMRAY=GMRAY+1
  1. .S GMRAZ=$G(^GMR(120.8,GMRAREC,10,GMRAX,0))
  1. .S GMRAZ(1)=$S(+GMRAZ'=GMRAOTH:$P($G(^GMRD(120.83,+GMRAZ,0)),U)_";"_+GMRAZ,1:$P(GMRAZ,U,2)_";"_+GMRAZ)
  1. .S GMRAZSRC=$P($G(^GMR(120.8,GMRAREC,10,GMRAX,9999999.11)),U,1)
  1. .S GMRAZT=$P($G(^GMR(120.8,GMRAREC,10,GMRAX,0)),U,4)
  1. .I GMRAZSRC S GMRAZ(1)=GMRAZ(1)_U_GMRAZT_U_GMRAZSRC
  1. .Q
  1. Q
  1. CHK(GMRAIEN) ;IHS/MSC/MGH Check to see if this allergy is inactive
  1. N Z,INACT,REACT,INZ
  1. S INZ=0
  1. I $P(GMRA,U,4)=1 Q 0
  1. S Z=$O(^GMR(120.8,GMRAIEN,9999999.12,$C(0)),-1) I +Z D
  1. .S INACT=$P($G(^GMR(120.8,GMRAIEN,9999999.12,Z,0)),U,1)
  1. .S REACT=$P($G(^GMR(120.8,GMRAIEN,9999999.12,Z,0)),U,4)
  1. .I +INACT&(REACT="") S INZ=1
  1. Q INZ