GMRADSP1 ;HIRMFO/WAA-DISPLAY ALLERGY ;01-May-2012 14:15;DU
;;4.0;Adverse Reaction Tracking;**41,1002,1006**;Mar 29, 1996;Build 29
DISBLD(IEN,ARRAY) ; This subroutine will bulid the array that will
; be displayed for each reactant. The IEN for each reactant in
; stored in GMRAPA.
N CNT,X,NODE,SOURCE
S NODE=$G(^GMR(120.8,IEN,0)) Q:NODE="" S CNT=1
S SOURCE=$G(^GMR(120.8,IEN,9999999.11))
I $L(GMRANAME)>50 S ARRAY(CNT)=$E(GMRANAME,1,50),CNT=CNT+1,ARRAY(CNT)=$E(GMRANAME,51,999)
E S ARRAY(CNT)=GMRANAME
ING ;Find all the ingredents for a reactant.
I $O(^GMR(120.8,IEN,2,0))>0 D
.N GMRAFST,GMRAGBAL,GMRAING,GMRAINGR,GMRALLEG,GMRALST
.S GMRAINGR=0,GMRALLEG=0
.F S GMRAINGR=$O(^GMR(120.8,IEN,2,GMRAINGR)) Q:GMRAINGR'>0 S GMRAGBAL=^GMR(120.8,IEN,2,GMRAINGR,0) D
..;--41-1
..D ZERO^PSN50P41(GMRAGBAL,"","","ENCAP")
..I '$D(^TMP($J,"ENCAP",GMRAGBAL)) K ^TMP($J,"ENCAP") Q
..;--41-1
..;--41-2
..I $P(NODE,U,2)=$P(^TMP($J,"ENCAP",GMRAGBAL,.01),U) Q
..;--41-2
..;--41-3
..S GMRALLEG(IEN,$P(^TMP($J,"ENCAP",GMRAGBAL,.01),U))="",GMRALLEG=GMRALLEG+1
..K ^TMP($J,"ENCAP")
..;--41-3
..Q
.I GMRALLEG S (GMRAINGR,GMRAING)="",CNT=CNT+1,ARRAY(CNT)="",GMRAFST=1,GMRALST=0 F S GMRAINGR=$O(GMRALLEG(IEN,GMRAINGR)) Q:GMRAINGR="" D
..I $O(GMRALLEG(IEN,GMRAINGR))="" S GMRALST=1
..S GMRAING=GMRAINGR
..I GMRAFST S GMRAING=" ("_GMRAING,GMRAFST=0
..I 'GMRALST S GMRAING=GMRAING_", "
..I GMRALST S GMRAING=GMRAING_")"
..I $L(ARRAY(CNT)_GMRAING)>52 S CNT=CNT+1,ARRAY(CNT)=" "_GMRAING
..E S ARRAY(CNT)=ARRAY(CNT)_GMRAING
..Q
.Q
SIGN ;Get all the patient Sign/Symptoms
I $O(^GMR(120.8,IEN,10,0))>0 D
.N GMRAFST,GMRALST,GMRAOTH,GMRAREAC,GMRAREAN,GMRATONS,GMRASRC,GMRAIN
.N GMRAEA,GMRIDT,GMRIBY,GMRIRE,GMRIRE,GMRIREBY,SR,GMRABY
.S GMRAOTH=$O(^GMRD(120.83,"B","OTHER REACTION",0))
.S GMRAFST=1,GMRALST=0,CNT=CNT+1,ARRAY(CNT)=" Reactions:"
.S GMRAREAC=0 F S GMRAREAC=$O(^GMR(120.8,IEN,10,GMRAREAC)) Q:GMRAREAC'>0 S GMRAREAN=$P($G(^GMR(120.8,IEN,10,GMRAREAC,0)),U) I GMRAREAN'="" D
..N GMRAREC
..I '$O(^GMR(120.8,IEN,10,GMRAREAC)) S GMRALST=1
..S GMRATONS=$S(GMRAREAN'=GMRAOTH:$P(^GMRD(120.83,GMRAREAN,0),U),1:$P(^GMR(120.8,IEN,10,GMRAREAC,0),U,2))
..;IHS/MSC/MGH source returned patch 1006
..S GMRSRC=$P($G(^GMR(120.8,IEN,10,GMRAREAC,9999999.11)),U,1)
..S GMRSRC=$$GET1^DIQ(90460.05,GMRSRC,.01)
..S GMRAREC=GMRATONS_"(Source: "_GMRSRC_")"
..;S GMRAREC=GMRATONS
..;end mods
..I GMRAFST S GMRAREC=" "_GMRAREC,GMRAFST=0
..I 'GMRALST S GMRAREC=GMRAREC_", "
..I $L(ARRAY(CNT)_GMRAREC)>52 S CNT=CNT+1,ARRAY(CNT)=" "_GMRAREC
..E S ARRAY(CNT)=ARRAY(CNT)_GMRAREC
..Q
.Q
;IHS/MSC/MGH reentered code for inactive data patch 1006
S GMRAIN=0 F S GMRAIN=$O(^GMR(120.8,IEN,9999999.12,GMRAIN)) Q:'+GMRAIN D
.S GMRAZ2=$G(^GMR(120.8,IEN,9999999.12,GMRAIN,0))
.S IIEN=GMRAIN_","_IEN_","
.S GMREA=$$GET1^DIQ(120.899999912,IIEN,.01)
.S CNT=CNT+1,ARRAY(CNT)=" Inactive: "
.S GMRIDT=$$GET1^DIQ(120.899999912,IIEN,.01),GMREA=$$GET1^DIQ(120.899999912,IIEN,1),GMRABY=$$GET1^DIQ(120.899999912,IIEN,2)
.S GMRIRE=$$GET1^DIQ(120.899999912,IIEN,3)
.S ARRAY(CNT)=ARRAY(CNT)_GMRIDT_"( "_GMREA_" ) "
.I GMRIRE'="" D
..S CNT=CNT+1
..S ARRAY(CNT)=" Reactivated: "_GMRIRE
.K IIEN,GMRAZ2
;Added data to get the source of the reactions PATCH 1001 MSC/IHS/MGH
S %=$P(SOURCE,U,1) I % S SR=$P($G(^BEHOAR(90460.05,%,0)),U,1) S ARRAY(1)=ARRAY(1)_$J(" ",(40-$L(ARRAY(1))))_SR
S %=$S($P(NODE,U,16):"YES",1:" NO") I $P(NODE,U,16),$P(NODE,U,18)="" S %="AUTO"
S ARRAY(1)=ARRAY(1)_$J(" ",(53-$L(ARRAY(1))))_%
S %=$P(NODE,U,14),%=$S(%="P":"PHARM ",%="A":"ALLERGY",%="U":"UNKNOWN ",1:""),ARRAY(1)=ARRAY(1)_$J(" ",(59-$L(ARRAY(1))))_%
S %=$P(NODE,U,6),%=$S(%="o":"OBS",%="h":"HIST",1:""),ARRAY(1)=ARRAY(1)_$J(" ",(68-$L(ARRAY(1))))_%
TYPE S %="" F X=1:1:($L(GMRATYPE)) D
.S %=$P("^FOOD^DRUG^OTHER",U,$F("FDO",$E(GMRATYPE,X)))
.S ARRAY(X)=$G(ARRAY(X))
.S ARRAY(X)=ARRAY(X)_$J(" ",(74-$L(ARRAY(X))))_%
.Q
Q
GMRADSP1 ;HIRMFO/WAA-DISPLAY ALLERGY ;01-May-2012 14:15;DU
+1 ;;4.0;Adverse Reaction Tracking;**41,1002,1006**;Mar 29, 1996;Build 29
DISBLD(IEN,ARRAY) ; This subroutine will bulid the array that will
+1 ; be displayed for each reactant. The IEN for each reactant in
+2 ; stored in GMRAPA.
+3 NEW CNT,X,NODE,SOURCE
+4 SET NODE=$GET(^GMR(120.8,IEN,0))
IF NODE=""
QUIT
SET CNT=1
+5 SET SOURCE=$GET(^GMR(120.8,IEN,9999999.11))
+6 IF $LENGTH(GMRANAME)>50
SET ARRAY(CNT)=$EXTRACT(GMRANAME,1,50)
SET CNT=CNT+1
SET ARRAY(CNT)=$EXTRACT(GMRANAME,51,999)
+7 IF '$TEST
SET ARRAY(CNT)=GMRANAME
ING ;Find all the ingredents for a reactant.
+1 IF $ORDER(^GMR(120.8,IEN,2,0))>0
Begin DoDot:1
+2 NEW GMRAFST,GMRAGBAL,GMRAING,GMRAINGR,GMRALLEG,GMRALST
+3 SET GMRAINGR=0
SET GMRALLEG=0
+4 FOR
SET GMRAINGR=$ORDER(^GMR(120.8,IEN,2,GMRAINGR))
IF GMRAINGR'>0
QUIT
SET GMRAGBAL=^GMR(120.8,IEN,2,GMRAINGR,0)
Begin DoDot:2
+5 ;--41-1
+6 DO ZERO^PSN50P41(GMRAGBAL,"","","ENCAP")
+7 IF '$DATA(^TMP($JOB,"ENCAP",GMRAGBAL))
KILL ^TMP($JOB,"ENCAP")
QUIT
+8 ;--41-1
+9 ;--41-2
+10 IF $PIECE(NODE,U,2)=$PIECE(^TMP($JOB,"ENCAP",GMRAGBAL,.01),U)
QUIT
+11 ;--41-2
+12 ;--41-3
+13 SET GMRALLEG(IEN,$PIECE(^TMP($JOB,"ENCAP",GMRAGBAL,.01),U))=""
SET GMRALLEG=GMRALLEG+1
+14 KILL ^TMP($JOB,"ENCAP")
+15 ;--41-3
+16 QUIT
End DoDot:2
+17 IF GMRALLEG
SET (GMRAINGR,GMRAING)=""
SET CNT=CNT+1
SET ARRAY(CNT)=""
SET GMRAFST=1
SET GMRALST=0
FOR
SET GMRAINGR=$ORDER(GMRALLEG(IEN,GMRAINGR))
IF GMRAINGR=""
QUIT
Begin DoDot:2
+18 IF $ORDER(GMRALLEG(IEN,GMRAINGR))=""
SET GMRALST=1
+19 SET GMRAING=GMRAINGR
+20 IF GMRAFST
SET GMRAING=" ("_GMRAING
SET GMRAFST=0
+21 IF 'GMRALST
SET GMRAING=GMRAING_", "
+22 IF GMRALST
SET GMRAING=GMRAING_")"
+23 IF $LENGTH(ARRAY(CNT)_GMRAING)>52
SET CNT=CNT+1
SET ARRAY(CNT)=" "_GMRAING
+24 IF '$TEST
SET ARRAY(CNT)=ARRAY(CNT)_GMRAING
+25 QUIT
End DoDot:2
+26 QUIT
End DoDot:1
SIGN ;Get all the patient Sign/Symptoms
+1 IF $ORDER(^GMR(120.8,IEN,10,0))>0
Begin DoDot:1
+2 NEW GMRAFST,GMRALST,GMRAOTH,GMRAREAC,GMRAREAN,GMRATONS,GMRASRC,GMRAIN
+3 NEW GMRAEA,GMRIDT,GMRIBY,GMRIRE,GMRIRE,GMRIREBY,SR,GMRABY
+4 SET GMRAOTH=$ORDER(^GMRD(120.83,"B","OTHER REACTION",0))
+5 SET GMRAFST=1
SET GMRALST=0
SET CNT=CNT+1
SET ARRAY(CNT)=" Reactions:"
+6 SET GMRAREAC=0
FOR
SET GMRAREAC=$ORDER(^GMR(120.8,IEN,10,GMRAREAC))
IF GMRAREAC'>0
QUIT
SET GMRAREAN=$PIECE($GET(^GMR(120.8,IEN,10,GMRAREAC,0)),U)
IF GMRAREAN'=""
Begin DoDot:2
+7 NEW GMRAREC
+8 IF '$ORDER(^GMR(120.8,IEN,10,GMRAREAC))
SET GMRALST=1
+9 SET GMRATONS=$SELECT(GMRAREAN'=GMRAOTH:$PIECE(^GMRD(120.83,GMRAREAN,0),U),1:$PIECE(^GMR(120.8,IEN,10,GMRAREAC,0),U,2))
+10 ;IHS/MSC/MGH source returned patch 1006
+11 SET GMRSRC=$PIECE($GET(^GMR(120.8,IEN,10,GMRAREAC,9999999.11)),U,1)
+12 SET GMRSRC=$$GET1^DIQ(90460.05,GMRSRC,.01)
+13 SET GMRAREC=GMRATONS_"(Source: "_GMRSRC_")"
+14 ;S GMRAREC=GMRATONS
+15 ;end mods
+16 IF GMRAFST
SET GMRAREC=" "_GMRAREC
SET GMRAFST=0
+17 IF 'GMRALST
SET GMRAREC=GMRAREC_", "
+18 IF $LENGTH(ARRAY(CNT)_GMRAREC)>52
SET CNT=CNT+1
SET ARRAY(CNT)=" "_GMRAREC
+19 IF '$TEST
SET ARRAY(CNT)=ARRAY(CNT)_GMRAREC
+20 QUIT
End DoDot:2
+21 QUIT
End DoDot:1
+22 ;IHS/MSC/MGH reentered code for inactive data patch 1006
+23 SET GMRAIN=0
FOR
SET GMRAIN=$ORDER(^GMR(120.8,IEN,9999999.12,GMRAIN))
IF '+GMRAIN
QUIT
Begin DoDot:1
+24 SET GMRAZ2=$GET(^GMR(120.8,IEN,9999999.12,GMRAIN,0))
+25 SET IIEN=GMRAIN_","_IEN_","
+26 SET GMREA=$$GET1^DIQ(120.899999912,IIEN,.01)
+27 SET CNT=CNT+1
SET ARRAY(CNT)=" Inactive: "
+28 SET GMRIDT=$$GET1^DIQ(120.899999912,IIEN,.01)
SET GMREA=$$GET1^DIQ(120.899999912,IIEN,1)
SET GMRABY=$$GET1^DIQ(120.899999912,IIEN,2)
+29 SET GMRIRE=$$GET1^DIQ(120.899999912,IIEN,3)
+30 SET ARRAY(CNT)=ARRAY(CNT)_GMRIDT_"( "_GMREA_" ) "
+31 IF GMRIRE'=""
Begin DoDot:2
+32 SET CNT=CNT+1
+33 SET ARRAY(CNT)=" Reactivated: "_GMRIRE
End DoDot:2
+34 KILL IIEN,GMRAZ2
End DoDot:1
+35 ;Added data to get the source of the reactions PATCH 1001 MSC/IHS/MGH
+36 SET %=$PIECE(SOURCE,U,1)
IF %
SET SR=$PIECE($GET(^BEHOAR(90460.05,%,0)),U,1)
SET ARRAY(1)=ARRAY(1)_$JUSTIFY(" ",(40-$LENGTH(ARRAY(1))))_SR
+37 SET %=$SELECT($PIECE(NODE,U,16):"YES",1:" NO")
IF $PIECE(NODE,U,16)
IF $PIECE(NODE,U,18)=""
SET %="AUTO"
+38 SET ARRAY(1)=ARRAY(1)_$JUSTIFY(" ",(53-$LENGTH(ARRAY(1))))_%
+39 SET %=$PIECE(NODE,U,14)
SET %=$SELECT(%="P":"PHARM ",%="A":"ALLERGY",%="U":"UNKNOWN ",1:"")
SET ARRAY(1)=ARRAY(1)_$JUSTIFY(" ",(59-$LENGTH(ARRAY(1))))_%
+40 SET %=$PIECE(NODE,U,6)
SET %=$SELECT(%="o":"OBS",%="h":"HIST",1:"")
SET ARRAY(1)=ARRAY(1)_$JUSTIFY(" ",(68-$LENGTH(ARRAY(1))))_%
TYPE SET %=""
FOR X=1:1:($LENGTH(GMRATYPE))
Begin DoDot:1
+1 SET %=$PIECE("^FOOD^DRUG^OTHER",U,$FIND("FDO",$EXTRACT(GMRATYPE,X)))
+2 SET ARRAY(X)=$GET(ARRAY(X))
+3 SET ARRAY(X)=ARRAY(X)_$JUSTIFY(" ",(74-$LENGTH(ARRAY(X))))_%
+4 QUIT
End DoDot:1
+5 QUIT