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

PSODGAL.m

Go to the documentation of this file.
  1. PSODGAL ;BIR/LC-DRUG ALLERGY REACTION CHECKING ;03-Oct-2012 16:10;DU
  1. ;;7.0;OUTPATIENT PHARMACY;**26,243,1015**;DEC 1997;Build 62
  1. ;External reference to ^GMRADPT supported by DBIA 10099
  1. ;External reference to ORCHK^GMRAOR supported by DBIA 2378
  1. ;External reference to $P(^GMR(120.8,LP,3),"^",3) supp. by DBIA 2214
  1. ;External reference to ^PS(50.605 supported by DBIA 696
  1. ;External reference to EN1^GMRAOR2 supported by DBIA 2422
  1. ;External reference to GETDATA^GMRAOR supported by DBIA 4847
  1. ;External reference to ^TMP("GMRAOC" supported by DBIA 4848
  1. ;External reference to ^XUSEC("PSORPH" supported by DBIA 10076
  1. ;Modified - IHS/MSC/MGH - 04/06/2012 - Allergy reactions added patch 1014
  1. CHK(DFN,TYP,PTR) ;matched to ndf
  1. ;IHS/MSC/MGH - 04/06/2012
  1. ;K ^TMP("PSODAI",$J) S PSOACK=$$ORCHK^GMRAOR(DFN,TYP,PTR) D:$G(PSOACK)=1
  1. K ^TMP("PSODAI",$J) S PSOACK=$$ORCHK^GMRAOR(DFN,TYP,PTR,"",1,1) D:$G(PSOACK)=1
  1. .Q:$D(^XUSEC("PSORPH",DUZ))
  1. .S ^TMP("PSODAI",$J,0)=1
  1. .S I=0 F S I=$O(GMRAING(I)) Q:'I S ^TMP("PSODAI",$J,I,0)=GMRAING(I)
  1. D:$G(PSOACK)=1 DSPLY
  1. ;IHS/MSC/MGH - 04/06/12
  1. ;K PSOACK,GMRAING,I
  1. K PSOACK,GMRAING,GMRAREAC,I,GMRACOM
  1. Q
  1. CHK1(DFN) ;not matched to ndf
  1. K ^TMP("PSODAI",$J)
  1. S GMRA="0^0^001" D ^GMRADPT F LP=0:0 S LP=$O(GMRAL(LP)) Q:'LP!($G(PSOACK)) D:$D(^GMR(120.8,LP,0))
  1. .S:'$D(PSOACK) APTR=$P(^GMR(120.8,LP,0),"^",3)
  1. .I $P(APTR,";",2)="PSDRUG(",$P(APTR,";")=PSODRUG("IEN") S PSOACK=1
  1. .Q:$D(^XUSEC("PSORPH",DUZ)) S:$G(PSOACK)=1 ^TMP("PSODAI",$J,0)=1
  1. .;IHS/MSC/MGH Updated for reactions patch 1015
  1. .D GETREAC^GMRAOR(LP)
  1. .D GETCOM^GMRAOR(LP)
  1. D:$G(PSOACK)=1 DSPLY
  1. K APTR,GMRA,GMRAL,LP,PSOACK
  1. Q
  1. ;
  1. CLASS(DFN) ;
  1. N CPT,CLCHK,CT,AGNL,CC,GMRA,LEN
  1. S LEN=4
  1. I $E(PSODRUG("VA CLASS"),1,4)="CN10" S LEN=5 ;look at 5 chars if ANALGESICS
  1. K ^TMP($J,"PSODRCLS")
  1. I $T(GETDATA^GMRAOR)]"" G CLASS2 ; CHECK FOR EXISTENCE OF NEW ENTRY POINT BEFORE USING
  1. S CLCHK=""
  1. S GMRA="0^0^111" D ^GMRADPT F CC=0:0 S CC=$O(GMRAL(CC)) Q:'CC D
  1. .K AGNL D EN1^GMRAOR2(CC,"AGNL")
  1. .I $D(AGNL("V")) F CT=0:1 S CPT=$O(AGNL("V",CT)) Q:'CPT I $E($P($G(AGNL("V",CPT)),"^"),1,LEN)=$E(PSODRUG("VA CLASS"),1,LEN) D
  1. ..S CLCHK=$G(CLCHK)+1,^TMP($J,"PSODRCLS",CLCHK)=$P($G(AGNL("V",CPT)),"^")_" "_$P($G(AGNL("V",CPT)),"^",2)
  1. ..;IHS/MSC/MGH Updated for reactions Patch 1015
  1. ..N K S K=0 S K=$O(AGNL("S",K)) Q:'+K D
  1. ...I K=1 S ^TMP($J,"PSODRCLS","REAC",K)="Reactions: "_$G(AGNL("S",K))
  1. ...E S ^TMP($J,"PSODRCLS","REAC",K)=$G(AGNL("S",K))
  1. ..;IHS/MSC/MGH Updated for reactions Patch 1015
  1. ..N K S K=0 S K=$O(AGNL("C",K)) Q:'+K D
  1. ...I K=1 S ^TMP($J,"PSODRCLS","COM",K)="Comments: "_$G(AGNL("C",K))
  1. ...E S ^TMP($J,"PSODRCLS","COM",K)=$G(AGNL("C",K))
  1. ..;END MOD
  1. G CLASSDSP
  1. CLASS2 ;
  1. N RET,K,L
  1. S RET=$$DRCL(DFN)
  1. I '$G(RET) Q
  1. S CLCHK="",CT="" F S CT=$O(GMRADRCL(CT)) Q:CT="" D
  1. .I $E(PSODRUG("VA CLASS"),1,LEN)=$E(CT,1,LEN) D
  1. ..S CLCHK=$G(CLCHK)+1,^TMP($J,"PSODRCLS",CLCHK)=CT_" "_$P(GMRADRCL(CT),"^",2)
  1. ..;IHS/MSC/MGH Modified for adding reactions patch 1015
  1. ..S K=0 F S K=$O(GMRAREAC(CT,K)) Q:'+K D
  1. ...I K=1 S ^TMP($J,"PSODRCLS","REAC",K)="Reactions: "_$G(GMRAREAC(CT,K))
  1. ...E S ^TMP($J,"PSODRCLS",CLCHK,"REAC",K)=$G(GMRAREAC(CT,K))
  1. ..;IHS/MSC/MGH Modified for adding comments patch 1015
  1. ..S K=0 F S K=$O(GMRACOM(CT,K)) Q:'+K D
  1. ...I K=1 S ^TMP($J,"PSODRCLS",CLCHK,"COM",K)="Comments: "_$G(GMRACOM(CT,K))
  1. ...E S ^TMP($J,"PSODRCLS",CLCHK,"COM",K)=$G(GMRACOM(CT,K))
  1. ..;END MOD
  1. CLASSDSP ;
  1. I '$D(^TMP($J,"PSODRCLS")) Q
  1. W $C(7),!,"A Drug-Allergy Reaction exists for this medication and/or class!",!
  1. W !,"Drug: "_PSODRUG("NAME")
  1. S CT="" F S CT=$O(^TMP($J,"PSODRCLS",CT)) Q:'CT W !,"Drug Class: "_^TMP($J,"PSODRCLS",CT)
  1. ;IHS/MSC/MGH added patch 1015 for reactions
  1. S K=0 F S K=$O(^TMP($J,"PSODRCLS","REAC",K)) Q:K="" D
  1. .W !,$G(^TMP($J,"PSODRCLS","REAC",K))
  1. ;IHS/MSC/MGH added patch 1015 for comments
  1. S K=0 F S K=$O(^TMP($J,"PSODRCLS","COM",K)) Q:K="" D
  1. .W !,$G(^TMP($J,"PSODRCLS","COM",K))
  1. ;END MOD
  1. K ^TMP($J,"PSODRCLS")
  1. S DIR("?",1)="Answer 'YES' if you DO want to enter a reaction for this medication,"
  1. S DIR("?")=" 'NO' if you DON'T want to enter a reaction for this medication,"
  1. S DIR(0)="SA^1:YES;0:NO",DIR("A")="Do you want to Intervene? ",DIR("B")="Y" W ! D ^DIR
  1. I Y D ^PSORXI
  1. I '$G(Y) K DIR,DTOUT,DIRUT,DIROUT,DUOUT,Y Q
  1. Q
  1. DSPLY ;
  1. W $C(7),!,"A Drug-Allergy Reaction exists for this medication and/or class!",!
  1. I $D(^XUSEC("PSORPH",DUZ)) D
  1. .W !,"Drug: "_PSODRUG("NAME") I $O(GMRAING(0)) W !,?6,"Ingredients: "
  1. .S DIR("?",1)="Answer 'YES' if you DO want to enter a reaction for this medication,"
  1. .S DIR("?")=" 'NO' if you DON'T want to enter a reaction for this medication,"
  1. .W ?19 S I=0 F S I=$O(GMRAING(I)) Q:'I W:$X+$L($G(GMRAING(I)))+2>IOM !?19 W $G(GMRAING(I))_", "
  1. .;IHS/MSC/MGH Added for reactions
  1. .I $O(GMRAREAC(0)) D
  1. ..W !,?6,"Reactions: "
  1. ..W ?19 S I=0 F S I=$O(GMRAREAC(I)) Q:'I W:$X+$L($G(GMRAREAC(I)))+2>IOM !?19 W $G(GMRAREAC(I))_", "
  1. .;IHS/MSC/MGH Added for comments
  1. .I $O(GMRACOM(0)) D
  1. ..W !,?6,"Comments: "
  1. ..S K=0 F S K=$O(GMRACOM(K)) Q:'+K D
  1. ...S L=0 F S L=$O(GMRACOM(K,L)) Q:'+L D
  1. ....W ?19,$G(GMRACOM(K,L,0))_" "
  1. .;END MOD
  1. .S DIR(0)="SA^1:YES;0:NO",DIR("A")="Do you want to Intervene? ",DIR("B")="Y" W ! D ^DIR
  1. .I 'Y K DIR,DTOUT,DIRUT,DIROUT,DUOUT,Y Q
  1. .I Y D ^PSORXI
  1. K DIR,DTOUT,DIRUT,DIROUT,DUOUT,Y,I,K,L
  1. Q
  1. ;
  1. DRCL(DFN) ;
  1. ;IHS/MSC/MGH - 04/06/12
  1. ;N RET
  1. N RET,J
  1. S RET=0
  1. K GMRADRCL
  1. D GETDATA^GMRAOR(DFN)
  1. Q:'$D(^TMP("GMRAOC",$J,"APC")) 0
  1. N GMRACL
  1. S GMRACL="" F S GMRACL=$O(^TMP("GMRAOC",$J,"APC",GMRACL)) Q:'$L(GMRACL) D
  1. .N GMRANM,GMRALOC
  1. .S GMRALOC=^TMP("GMRAOC",$J,"APC",GMRACL)
  1. .S GMRANM=$P(^PS(50.605,+$O(^PS(50.605,"B",GMRACL,0)),0),U,2)
  1. .S GMRADRCL(GMRACL)=GMRACL_U_GMRANM_" ("_GMRALOC_")"
  1. .;IHS/MSC/MGH added for reaction data
  1. .S J=0 F S J=$O(^TMP("GMRAOC",$J,"APC",GMRACL,"REAC",J)) Q:'+J D
  1. ..S GMRAREAC(GMRACL,J)=$G(^TMP("GMRAOC",$J,"APC",GMRACL,"REAC",J))
  1. .;IHS/MSC/MGH added for comment data
  1. .S J=0 F S J=$O(^TMP("GMRAOC",$J,"APC",GMRACL,"COM",J)) Q:'+J D
  1. ..S GMRACOM(GMRACL,J)=$G(^TMP("GMRAOC",$J,"APC",GMRACL,"COM",J))
  1. .;END MOD
  1. .S RET=RET+1
  1. K ^TMP("GMRAOC",$J)
  1. Q RET