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

BPXRMAL1.m

Go to the documentation of this file.
BPXRMAL1 ;IHS/MSC/MGH - Handle Allergy findings for drugs ;30-Mar-2018 14:29;DU
 ;;2.0;CLINICAL REMINDERS;**1001,1002,1009**;Feb 04, 2005;Build 17
 ;--------------------------------------------------------------
 ;Patch 1009 added Statin drugs
 ;ROUTINE TO TEST ALLERGY STATUS
 ;ENTRY POINT REM JUST NEEDS THE PSODFN.NOT NECESSARILY THE TERM WILL FIND ALL
 ;TERMS THAT HAVE DRUGS IN THEM EITHER DRUG OR VA GENERIC
 Q
 ;
ASAREM(PSODFN,TEST,DATE,VALUE,TEXT) ; EP ASPIRIN COMPUTED ALLERGY CHECK RETURN TEST=1 IF ALLERGY
 S TERM="IHS-ASPIRIN"
 D REM(PSODFN,.TEST,.DATE,.VALUE,.TEXT)
 Q
 ;
STATREM(PSODFN,TEST,DATE,VALUE,TEXT) ;EP Statin computed allergy check added patch 1009
 S TERM="IHS-STATIN DRUGS"
 D REM(PSODFN,.TEST,.DATE,.VALUE,.TEXT)
 Q
 ;
AAREM(PSODFN,TEST,DATE,VALUE,TEXT) ; EP ACE/ARB COMPUTED ALLERGY CHECK RETURN TEST=1 IF ALLERGY
 N VALUE,TEST1,TEXT1,TEST2,TEXT2
 S VALUE="",DATE=DT,CHECK=""
 S I="CV800"
 S CHECK=$$FIND1^DIC(50.605,"","MX",I)_"C"
 I CHECK="" S TEST=0,TEXT="VA DRUG CLASSES FOR 'CV800' NOT DEFINED!!" Q
 D ALLER(PSODFN,CHECK,.TEST1,.TEXT1)
 S I="CV805"
 S CHECK=$$FIND1^DIC(50.605,"","MX",I)_"C"
 I CHECK="" S TEST=0,TEXT="VA DRUG CLASSES FOR 'CV805' NOT DEFINED!!" Q
 D ALLER(PSODFN,CHECK,.TEST2,.TEXT2)
 I TEST1=1&(TEST2=1) S TEST=1,TEXT="ALLERGIES TO BOTH"
 E  S TEST=0,TEXT="ALLERGIES TO BOTH CLASSES NOT FOUND"
 Q
 ;
REM(PSODFN,TEST,DATE,VALUE,TEXT) ; EP YOU GIVE THE PSODFN AND THE TERM DEFINDED BELOW
 ;MAIN ENTRY POINT ABOVE GIVEN PSODFN AND TERM
 ;TERM IS THE NAME OF THE REMINDER TERM TO QUERY
 ;IF I DON'T HAVE A TERM I'LL QUERY THE REMINDER TERM LOOKING FOR A DRUG OR VA DRUG TERM
 ;--------------------------------------------------------------------
 S DATE=DT,VALUE=""
 N RESULT,TERMLONG,TERMS,I
 I $G(TERM)']"" D  ;ADD THIS BELOW FOR CASE WHEN NO TERM DEFINED IHS/OKCAO/POC 11/7/2006
 .D LIST^DIC(811.902,","_PXRMITEM_",",.01,"I",,,,,,,"TERMLONG")
 .M TERMS=TERMLONG("DILIST",1)
 .S I="" F  S I=$O(TERMS(I)) Q:I=""  I $P(TERMS(I),";",2)'="PXRMD(811.5," K TERMS(I)  ;JUST THE TERMS
 .I '$D(TERMS) S TEST=0,TEXT="THERE ARE NO VALID TERM FINDINGS (DRUG OR VA DRUG) IN THE REMINDER TAXONMY "_$$GET1^DIQ(811.9,PXRMITEM_",",.01) Q  ;NO VALID TERM DRUG OR VA DRUG FINDINGS IN THE REMINDER TERM
 .S I="" F  S I=$O(TERMS(I)) Q:I=""  Q:$G(TEST)  S TERM="`"_$P(TERMS(I),";") D  ;QUIT IS TEST=1 FOUND ALLERGY TO SOMETHING DON'T OVERWRITE IT
 ..D TERM(TERM,.RETURN)
 ..I '$G(RETURN) S TEST=0,TEXT="THERE ARE NO VALID FINDINGS IN THE REMINDER TAXONMY "_$$GET1^DIQ(811.9,PXRMITEM_",",.01) Q  ;NO VALID FINDINGS IN THE REMINDER TERM
 ..D ALLER(PSODFN,RETURN,.TEST,.TEXT)
 ;I $G(TERM)']"" S TEST=0,TEXT="NEED TO DEFINE THE TERM.  CALL PROGRAMMER!" Q
 ;GIVE THE TERM ALSO  <---
 E  D
 .D TERM(TERM,.RETURN)
 .I '$G(RETURN) S TEST=0,TEXT="THERE ARE NO VALID FINDINGS IN THE REMINDER TAXONMY "_TERM Q  ;NO VALID FINDINGS IN THE REMINDER TERM
 .D ALLER(PSODFN,RETURN,.TEST,.TEXT)
 Q
 ;END OF CHANGES IHS/OKCAO/POC 11/7/2006
 ;
TERM(TERM,RETURN) ;GIVEN REMINDER TERM  RETURN THE STRING TO PASS TO ALLER
 ;FINDINGS MUST BE FROM THE DRUG FILE!!
 N TARLONG,IEN,FINDINGS,TERMIEN
 K RETURN
 S TERMIEN=$$FIND1^DIC(811.5,"","MX",TERM)  ;REMINDER TERM
 I 'TERMIEN S TEST=0,TEXT="NO REMINDER TERM "_TERM_" FOUND!!" Q
 D LIST^DIC(811.52,","_TERMIEN_",",".01","I","","","","",,"","TARLONG")
 M FINDINGS=TARLONG("DILIST",1) ;FINDINGS FOR THIS REMINDER
 S IEN="" F  S IEN=$O(FINDINGS(IEN)) Q:'IEN  D
 .;WE'LL ONLY LOOK AT ENTRIES POINTING TO DRUGS OR VA GENERICS NOT VA CLASSES IHS/OKCAO/POC 5/11/2006
 .S RETURN=$G(RETURN)_"^"_$S(FINDINGS(IEN)["PSDRUG":+FINDINGS(IEN)_"D",FINDINGS(IEN)["PSNDF(50.6,":+FINDINGS(IEN)_"G",1:"")
 S RETURN=$E($G(RETURN),2,$L($G(RETURN)))   ;GET RID OF FIRST '^')
 Q
 ;
ALLER(PSODFN,CHECK,TEST,TEXT) ; EP
 ;TEST =1 IF ALLERGY 0 IF NO ALLERGY   TEXT IS WRITTEN TEXT
 ;PSODFN=DFN CHECK=IS THE ENTITY TO CHECK SEE STING TAG
 ;CHECK CAN BE MUTIPLES SEPARATED BY '^'
 ;INPUT GMRAAR LIKE THIS FOR FILE 120.82=IEN_"A", FILE 50=IEN_"D", FILE 50.6=IEN_"G", FILE 50.605=IEN_"C", FILE 50.416=IEN_"I"
 ;EXAMPLE CHECK="305D^276C WOULD BE IEN 305 IN FILE 50 AND IEN 276 IN 50.605
 ;-------------------------------------------------------------------
 N REACTION
 S TEST=0,TEXT=""
 S REACTION=$$NKA^GMRANKA(PSODFN)
 I REACTION="" S TEXT="NO ALLERGY INFORMATION FOR THIS PATIENT HAS BEEN RECORDED" Q
 I REACTION=0 S TEXT="THIS PATIENT HAS BEEN RECORDED AS 'NKA'" Q
 K ING,CLASS,DRUG
 F I=1:1 S GMRAAR=$P(CHECK,"^",I) Q:GMRAAR=""  D STING(GMRAAR,.ING,.CLASS,.DRUG)
 ;NOW YOU HAVE ARRAY OF ING-VA INGREDIENT IEN, CLASS- VA DRUG CLASS IENS, AND DRUG-DRUG IEN
 ;START LOOPING THROUGH THE GMR(120.8 GLOBAL
 N IEN
 S IEN=0 F  S IEN=$O(^GMR(120.8,"B",PSODFN,IEN)) Q:IEN'=+IEN!TEST  D
 .Q:$$TEST(IEN)  ;NOT VERIFIED OR IS AN ERROR OR IS INACTIVE
 .N INGIEN
 .S INGIEN=0 F  S INGIEN=$O(^GMR(120.8,IEN,2,"B",INGIEN)) Q:INGIEN'=+INGIEN!TEST  D
 ..I $D(ING(INGIEN)) S TEST=1,DATE=DT,TEXT="PT ALLERGIC TO DRUG INGREDIENT "_$P($G(^PS(50.416,INGIEN,0)),"^")_" IN PATIENT ALLERGY "_$P($G(^GMR(120.8,IEN,0)),"^",2)_"-"_IEN
 .Q:TEST
 .N CLASSIEN
 .S CLASSIEN=0 F  S CLASSIEN=$O(^GMR(120.8,IEN,3,"B",CLASSIEN)) Q:CLASSIEN'=+CLASSIEN!TEST  D
 ..I $D(CLASS(CLASSIEN)) S TEST=1,DATE=DT,TEXT="PT ALLERGIC TO DRUG CLASS "_$P($G(^PS(50.605,CLASSIEN,0)),"^")_" IN PATIENT ALLERGY "_$P($G(^GMR(120.8,IEN,0)),"^",2)_"-"_IEN
 .Q:TEST
 .N DRUGIEN
 .S DRUGIEN=$P(^GMR(120.8,IEN,0),"^",3)
 .I DRUGIEN["PSDRUG(" S:$D(DRUG(+DRUGIEN)) TEST=1,DATE=DT,TEXT="PT ALLERGIC TO DRUG "_$P($G(^PSDRUG(+DRUGIEN,0)),"^")_" IN PATIENT ALLERGY "_$P($G(^GMR(120.8,IEN,0)),"^",2)_"-"_IEN
 Q
 ;
STING(GMRAAR,GMRAING,GMRADRCL,PSODRUG) ;
 ;INPUT GMRAAR LIKE THIS FOR FILE 120.82=IEN_"A", FILE 50=IEN_"D", FILE 50.6=IEN_"G", FILE 50.605=IEN_"C", FILE 50.416=IEN_"I"
 ;GMRAING=DRUG INGREDIENTS, AND GMRADRCL=VA DRUG CLASS, AND PSODRUG=DRUG ARE RETURNED IN ARRAY
 ;K GMRAING,GMRADRCL  ;GMRAING=DRUG INGREDIENTS GMRADRCL=CLASSES
 ;------------------------------------------------------------------------
 N Y
 I GMRAAR["I" S GMRAING(+GMRAAR)=""
 ;If the Reacant is a Drug Class
 I GMRAAR["C" D VACLASS(+GMRAAR,.GMRADRCL)
 ;If the Reactant is a entry in the GMR ALLERGY file
 I GMRAAR["A" D
 .S Y=0 F  S Y=$O(^GMRD(120.82,+GMRAAR,"ING",Y)) Q:Y'>0  I $D(^GMRD(120.82,+GMRAAR,"ING",Y,0)),+^(0)>0 S GMRAING(+^(0))=""
 .S Y=0 F  S Y=$O(^GMRD(120.82,+GMRAAR,"CLASS",Y)) Q:Y'>0  I $D(^GMRD(120.82,+GMRAAR,"CLASS",Y,0)),+^(0)>0 S GMRADRCL(+^(0))=""
 .Q
 I GMRAAR["D" D
 .S PSODRUG(+GMRAAR)=$P($G(^PSDRUG(+GMRAAR,0)),"^")  ;ADD PSODRUG
 .N PSODA
 .S PSODA=+GMRAAR K ^TMP("PSO",$J) D ^PSONGR F Y=0:0 S Y=$O(^TMP("PSO",$J,Y)) Q:Y'>0  S GMRAING(Y)=""
 .N GMRAX,GMRAY
 .S GMRAX=$P($G(^PSDRUG(+GMRAAR,"ND")),U,6) S:GMRAX>0 GMRADRCL(GMRAX)="" Q
 .S GMRAX=$P($G(^PSDRUG(+GMRAAR,0)),U,2) Q:GMRAX=""
 .S GMRAY=$O(^PS(50.605,"B",GMRAX,"")) S:GMRAY>0 GMRADRCL(GMRAY)=""
 .Q
 I GMRAAR["G" D
 .N PSNDA
 .S PSNDA=+GMRAAR K ^TMP("PSN",$J) D ^PSNNGR F Y=0:0 S Y=$O(^TMP("PSN",$J,Y)) Q:Y'>0  S GMRAING(Y)=""
 .; all classes for NDF entry returned in GMRADRCL
 .N CLASS
 .S CLASS=$$CLIST^PSNAPIS(+GMRAAR,.GMRADRCL)
 .Q
 K ^TMP("PSO",$J),^TMP("PSN",$J),PSOID,PSNID
 Q
 ;
VACLASS(ENTRY,PICK) ;EXPAND THE CLASSES
 N TEMP
 D TEMP
 N CHILD
 S CHILD=0 F  S CHILD=$O(TEMP(ENTRY,CHILD)) Q:CHILD=""  D
 .S PICK(CHILD)=""  ;$P(^PS(50.605,CHILD,0),"^",1)
 .D:CHILD'=ENTRY PICK1(CHILD)
 Q
 ;
TEMP ; MAKE YOUR TEMP GLOBAL OF TEMP(PARENT,CHILD)=""
 N CHILD,PARENT
 S CHILD=0 F  S CHILD=$O(^PS(50.605,CHILD)) Q:CHILD'=+CHILD  D
 .S TEMP(CHILD,CHILD)=""  ;ALWAYS SET THE ENTRY TO ITSELF
 .S PARENT=$P(^PS(50.605,CHILD,0),"^",3)
 .Q:'PARENT
 .S TEMP(PARENT,CHILD)=""
 Q
 ;
PICK1(ENTRY) ;Part of expansion
 N CHILD
 S CHILD=0 F  S CHILD=$O(TEMP(ENTRY,CHILD)) Q:CHILD=""  D
 .S PICK(CHILD)=$P(^PS(50.605,CHILD,0),"^",1)
 .D:CHILD'=ENTRY PICK2(CHILD)
 Q
 ;
PICK2(ENTRY) ;Part of expansion
 N CHILD
 S CHILD=0 F  S CHILD=$O(TEMP(ENTRY,CHILD)) Q:CHILD=""  D
 .S PICK(CHILD)=$P(^PS(50.605,CHILD,0),"^",1)
 .D:CHILD'=ENTRY PICK3(CHILD)
 Q
 ;
PICK3(ENTRY) ;THIS SHOULD BE EN
 N CHILD S CHILD=0 F  S CHILD=$O(TEMP(ENTRY,CHILD)) Q:CHILD=""  D
 .S PICK(CHILD)=$P(^PS(50.605,CHILD,0),"^",1)
 Q
 ;
 ;
TEST(AZOIT) ;CHECK FOR ERRORS AND VERIFED STATUS
 N AZOCHECK,INAC
 S AZOCHECK=0
 S:+$G(^GMR(120.8,AZOIT,"ER")) AZOCHECK=1
 ;S:$P(^GMR(120.8,AZOIT,0),U,16)'="1" AZOCHECK=1
 S INAC=$$INACTIVE^GMRADSP6(AZOIT)        ;PATCH 1008
 I +INAC S AZOCHECK=1    ;Quit if inactive
 Q AZOCHECK