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

APSQALLE.m

Go to the documentation of this file.
APSQALLE ;IHS/ASDS/ENM/POC - ROUTINE TO CHECK FOR ALLERGIES   [ 01/13/2003  12:38 PM ]
 ;;6.0;IHS PHARMACY MODIFICATIONS;**3,4**;11/27/2002
 ;;A LITTLE SOMETHING EXTRA
 Q
EN ;EP HERE WE START
 W !!,"CHECKING FOR DRUG ALLERGIES..."  ;FIX TYPO IHS/OKCAO/POC 11/27/2002
 Q:'$D(PSODFN)
 Q:'$D(^GMR(120.8,"B",PSODFN))
 Q:$O(^GMR(120.8,"ANKA",PSODFN,""))="n"  ;PT HAS NKA XREF
 S AZOQUIT=0  ;AZOQUIT=1=NONDF AZOQUIT=2=NO CLASS
 ;AZOXREF IS SPECIAL XREF OF DRUG INGREDIENT FILE
 S AZOXREF=$G(PSODRUG("NDF"),0) S:AZOXREF="" AZOXREF=0,AZOQUIT=1
 IF '(AZOXREF?1.N1"A"1.N) S AZOXREF=0,AZOQUIT=1  ;GOT TO KNOW WHEN NO NDF
 ;S:AZOXREF="" AZOXREF=0 ;JUST TO BE SAFE
 S AZOCLASS=$G(PSODRUG("VA CLASS"),0) S:AZOCLASS="" AZOCLASS=0
 S:AZOCLASS=0 AZOQUIT=2
 D:AZOQUIT=0 XREF  ;GOT A SPECIAL XREF
 D:AZOQUIT=1 CLASS  ;GOT A CLASS ONLY
 D:AZOQUIT=2 DRUG  ;GOT A DRUG NAME ONLY
 ;WORK THRU THE PATIENT ALLERGY FILE USING EITHER SPECIAL XREF OR CLASS
 D FULL:AZOQUIT=0,HALF:AZOQUIT=1,QUAR:AZOQUIT=2,NONE:AZOQUIT=3
 D END
 Q
 ;SUBROUTINES
 ;
NONE ;SHOULD NOT GET HERE BUT!!!
END ;CLEAN UP TIME
 D EN^XBVK("AZO")
 Q
XREF ;GET THE DRUG COMPONENTS TO BE CHECKED
 S AZODRCOM=0 F I=1:1 S AZODRCOM=$O(^PS(50.416,"APD",AZOXREF,AZODRCOM)) Q:AZODRCOM=""  D
 .IF $P(^PS(50.416,AZODRCOM,0),U,2)]"" S AZODREF(I)=$P(^(0),U,2)  ;THIS IS A LITTLE TRICKY
 .E  S AZODREF(I)=AZODRCOM
 .Q
 IF '$D(AZODREF) S AZO("MESS")="THERE IS NO DRUG COMPONENT (NO NDF ENTRY) FOR THE DRUG "_PSODRUG("NAME")_".  IT CANNOT BE CHECKED WITH CERTAINTY FOR ALLERGIES.",AZOQUIT=1 D CLASS  ;SEE IF CAN BE CHECKED WITH CLASS
 Q
 ;
CLASS ;CHECKS FOR CLASS IF NO ENTRY IN NDF
 ;S AZOCLASS=$G(PSODRUG("VA CLASS"),0) S:AZOCLASS="" AZOCLASS=0
 ;IF AZOCLASS=0 S AZO("MESS")="THERE IS NO DRUG COMPONENT (NO NDF ENTRY) OR CLASS FOR THE DRUG "_PSODRUG("NAME")_".  IT CANNOT BE CHECKED PROPERLY FOR ALLERGIES.",AZOQUIT=2 D DRUG
 ;WRITES MESSAGE TO BE DISPLAY IF GOT CLASS ONLY
 S AZO("MESS")="THERE IS NO DRUG COMPONENT (NO NDF ENTRY) FOR THE DRUG "_PSODRUG("NAME")_".  IT CANNOT BE CHECKED PROPERLY FOR ALLERGIES."
 Q
 ;
DRUG ;GO HERE IF NO NDF OR CLASS
 IF AZOCLASS=0 S AZOQUIT=2,AZO("MESS")="THERE IS NO DRUG COMPONENT (NO NDF ENTRY) OR CLASS FOR THE DRUG "_PSODRUG("NAME")_".  IT CANNOT BE CHECKED PROPERLY FOR ALLERGIES."
 Q
 ;
 ;
FULL ;
 S AZOALLD=0 F  S AZOALLD=$O(^GMR(120.8,"API",PSODFN,AZOALLD)) Q:AZOALLD=""  D  ;AZOALLD=SPECIAL XREF FOR ALLERGY IN FILE 50.416
 .S AZOALLI=$O(^GMR(120.8,"API",PSODFN,AZOALLD,""))
 .;Q:$D(^GMR(120.8,AZOALLI,"ER"))  ;ENTERED IN ERROR NODE
 .Q:$$TEST(AZOALLI)
 .S AZOALLDR=$S($P(^PS(50.416,AZOALLD,0),U,2)["":$P(^(0),U,2),1:AZOALLD)  ;THIS IS TRICKY NOTE SOME DRUG INGREDIENTS MAY "POINT" TO OTHER DRUG INGREDEINTS
 .;NOW TO LOOP THRU OUR DRUG BEING CHECKED=AZODREF(I)'S WITH THIS AZOALLDR=ALLERGY DRUG
 .S I=0 F  S I=$O(AZODREF(I)) Q:I=""  D
 ..IF AZODREF(I)=AZOALLD S AZOHIT=1,AZO("HITE"_$P(^GMR(120.8,AZOALLI,0),U,2))="THE DRUG "_PSODRUG("NAME")_" IS 'MATCHED' WITH PATIENT'S ALLERGY FILE NAME "_$P(^GMR(120.8,AZOALLI,0),U,2)  ;GET ONLY 1 MSG FOR A DRUG W/ MULTI DRUG COMPONENTS
 ..Q
 .Q
 D:$G(AZOHIT) ASK
 KILL AZOHIT
 Q
 ;
HALF ;THIS IS USED TO CHECK IF ONLY HAVE A CLASS
 ;DONE LIKE FULL EXCEPT USE APC XREF FOR CLASS
 S AZOALLC=0 F  S AZOALLC=$O(^GMR(120.8,"APC",PSODFN,AZOALLC)) Q:AZOALLC=""  D
 .S AZOALLI=$O(^GMR(120.8,"APC",PSODFN,AZOALLC,""))
 .;Q:$D(^GMR(120.8,AZOALLC,"ER"))
 .Q:$$TEST(AZOALLI)
 .IF AZOCLASS=AZOALLC S AZOHIT=1,AZO("HITC"_AZOALLI)="THE DRUG "_PSODRUG("NAME")_" IS 'CLASSED' WITH PATIENT ALLERGY FILE AS "_$P(^GMR(120.8,AZOALLI,0),U,2)
 .Q
 D:$G(AZOHIT) ASK
 K AZOHIT
 Q
 ;
QUAR ;WELL NOTHING IS LEFT BUT TO CHECK THE DRUG ITSELF
 S AZODRUG=PSODRUG("IEN")  ;OUR DRUG TO COMPARE WITH ALLERGIES
 S AZODRUGC=0 F  S AZODRUGC=$O(^GMR(120.8,"B",PSODFN,AZODRUGC)) Q:AZODRUGC=""  D
 .Q:$$TEST(AZODRUGC)
 .IF $P($P(^GMR(120.8,AZODRUGC,0),U,3),";",2)="PSDRUG(" S AZODRUGI=+$P(^(0),U,3) IF $G(AZODRUGI)=AZODRUG D
 ..S AZOHIT=1,AZO("HITD"_$P(^GMR(120.8,AZODRUGC,0),U,2))="THE DRUG "_PSODRUG("NAME")_" IS 'IDENTICAL' WITH PATIENT ALLERGY FILE NAME "_$P(^GMR(120.8,AZODRUGC,0),U,2)
 ..Q
 .Q
 D:$G(AZOHIT) ASK
 K AZOHIT
 Q
 ;
ASK ;ASK WHAT IS TO BE DONE
 ;LETS DO REVERSE VIDEO
 S X="IORVON;IORVOFF" D ENDR^%ZISS
 ;FIRST WRITE MESSAGES
 S I="" F  S I=$O(AZO(I)) Q:I=""  W:I="MESS" IORVON W !,*7,AZO(I) W:I="MESS" IORVOFF
 ;S DIR("A")="WHAT IS YOUR POISON?  "
 S DIR("A")="WHAT IS YOUR CHOICE?  "
 S DIR("A",1)="1  DO YOU WANT TO DELETE THIS DRUG?"
 S DIR("A",2)="2  DO AN INTERVENTION?"
 S DIR("A",3)="3  DO BOTH 1 AND 2?"
 S DIR("A",4)="4  JUST CONTINUE?"
 S DIR("B")=1
 S DIR(0)="N^1:4:0"
 D ^DIR
 ;IF (Y="")!(Y["^") S Y=1
 IF $D(DIRUT)!($D(DIROUT)) S Y=1
 K DIR,DTOUT,DIRUT,DUOUT,DIROUT
 D @Y
 Q
 ;
TEST(AZOIT)        ;CHECK FOR ERRORS AND VERIFED STATUS
 S AZOCHECK=0
 S:$D(^GMR(120.8,AZOIT,"ER")) AZOCHECK=1
 S:$P(^GMR(120.8,AZOIT,0),U,16)'="1" AZOCHECK=1
 Q AZOCHECK
 ;
1 ;DELETE THE DRUG
 S PSORX("DFLG")=1,DGI=""
 Q
2 ;DO AN INTERVENTION
 S PSORX("INTERVENE")=3,DGI=""
 Q
3 ;DO BOTH 1 AND 2
 D 2,1
 Q
4 ;DO NOTHING
 Q