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

PSNXREF.m

Go to the documentation of this file.
PSNXREF ;BIR/DMA-Cross references ;04 Dec 98 / 10:44 AM
 ;;4.0; NATIONAL DRUG FILE;**3,54,78**; 30 Oct 98
 ;
ING ;From active ingredients in VA product file - set drug ingredient multiple
 N PSNDATA,PSNARG
 S PSNDATA=$P(^PSNDF(50.68,DA(1),0),"^",2)_"A"_DA(1) Q:'$P(PSNDATA,"A")
 I '$D(^PS(50.416,DA,1,"B",PSNDATA)) S PSNARG=$O(^PS(50.416,DA,1," "),-1)+1,^(PSNARG,0)=PSNDATA,^PS(50.416,DA,1,"B",PSNDATA,PSNARG)=""
 S PSNARG=$P(^PS(50.416,DA,0),"^",2),PSNARG=$S(PSNARG:PSNARG,1:DA),^PS(50.416,"APD",PSNDATA,PSNARG)=""
 ;
INGINT ;now the interactions - get primary - check Xref in 56 - loop thru
 ;APS in 50.416
 N J,PSNAR,PSN0,PSN1,PSN2,PSN3,PSNC,PSNDA,PSNINT,PSND1
 S J=$P(^PS(50.416,DA,0),"^",2),PSNDA=$S(J:J,1:DA)
 K PSN2 S PSN2=0,PSNC=0 F  S PSN2=$O(^PS(56,"AE",PSNDA,PSN2)) Q:'PSN2  K PSNAR S PSNAR(PSN2)="",PSNINT=0 F  S PSNINT=$O(^PS(56,"AE",PSNDA,PSN2,PSNINT)) Q:'PSNINT  D
 .S PSN0=0 F  S PSN0=$O(^PS(50.416,"APS",PSN2,PSN0)) Q:'PSN0  S PSNAR(PSN0)=""
 .S PSN0=0 F  S PSN0=$O(PSNAR(PSN0)),PSN1=0 Q:'PSN0  F  S PSN1=$O(^PS(50.416,PSN0,1,PSN1)) Q:'PSN1  S PSND1=$P(^(PSN1,0),"^"),^PS(56,"APD",PSNDATA,PSND1,PSNINT)="",^PS(56,"APD",PSND1,PSNDATA,PSNINT)="",PSNC=PSNC+2
 .I PSNC S $P(^(0),"^",6)=$P(^PS(56,PSNINT,0),"^",6)+PSNC
 Q
 ;
KING ;from active ingredient - kill drug identifier multiple
 S PSNDATA=$P(^PSNDF(50.68,DA(1),0),"^",2)_"A"_DA(1)
 S PSNARG=$O(^PS(50.416,DA,1,"B",PSNDATA,0)) I PSNARG K ^PS(50.416,DA,1,PSNARG),^PS(50.416,DA,1,"B",PSNDATA)
 S PSNARG=$P(^PS(50.416,DA,0),"^",2),PSNARG=$S(PSNARG:PSNARG,1:DA) K ^PS(50.416,"APD",PSNDATA,PSNARG)
 ;GET RID OF ALL INTERACTIONS FOR THIS COMBO
 S PSNB="^PS(56,""APD"","""_PSNDATA_""")"
 F  S PSNB=$Q(@PSNB) Q:$QS(PSNB,3)'=PSNDATA  S PSNC=^PS(56,$QS(PSNB,5),0) I $P(PSNC,"^",2)=PSNARG!($P(PSNC,"^",3)=PSNARG) D
 .K @PSNB S PSND=$P(PSNB,",",1,2)_","_$P(PSNB,",",4)_","_$P(PSNB,",",3)_","_$P(PSNB,",",5) K @PSND
 Q
 ;
INT ;INTERACTIONS
 N PSN,PSN1,PSN2,PSN3,PSNA,PSNB,PSNC
 S PSN1=$P(^PS(56,DA,0),"^",2),PSN2=$P(^(0),"^",3) Q:PSN1=""  Q:PSN2=""  S PSN1(PSN1)="",PSN2(PSN2)=""
 S PSN=0 F  S PSN=$O(^PS(50.416,"APS",PSN1,PSN)) Q:'PSN  S PSN1(PSN)=""
 S PSN=0 F  S PSN=$O(^PS(50.416,"APS",PSN2,PSN)) Q:'PSN  S PSN2(PSN)=""
 S PSN1=0,PSN2=0,PSNC=0 F  S PSN1=$O(PSN1(PSN1)) Q:'PSN1  F  S PSN2=$O(PSN2(PSN2)) Q:'PSN2  D
 .S PSN3=0,PSN4=0 F  S PSN3=$O(^PS(50.416,PSN1,1,PSN3)),PSN4=0 Q:'PSN3  S PSNA=^(PSN3,0) F  S PSN4=$O(^PS(50.416,PSN2,1,PSN4)) Q:'PSN4  S PSNB=^(PSN4,0) S ^PS(56,"APD",PSNA,PSNB,DA)="",^PS(56,"APD",PSNB,PSNA,DA)="",PSNC=PSNC+2
 S $P(^PS(56,DA,0),"^",6)=PSNC
 Q
 ;
KINT ;DELETE INTERACTIONS
 N PSN,PSN1,PSN2,PSN3,PSN4,PSNA,PSNB
 S PSN1=$P(^PS(56,DA,0),"^",2),PSN2=$P(^(0),"^",3),PSN1(PSN1)="",PSN2(PSN2)=""
 S PSN=0 F  S PSN=$O(^PS(50.416,"APS",PSN1,PSN)) Q:'PSN  S PSN1(PSN)=""
 S PSN=0 F  S PSN=$O(^PS(50.416,"APS",PSN2,PSN)) Q:'PSN  S PSN2(PSN)=""
 S PSN1=0,PSN2=0 F  S PSN1=$O(PSN1(PSN1)) Q:'PSN1  F  S PSN2=$O(PSN2(PSN2)) Q:'PSN2  D
 .S PSN3=0,PSN4=0 F  S PSN3=$O(^PS(50.416,PSN1,1,PSN3)) Q:'PSN3  S PSNA=^(PSN3,0) F  S PSN4=$O(^PS(50.416,PSN2,1,PSN4)) Q:'PSN4  S PSNB=^(PSN4,0) K ^PS(56,"APD",PSNA,PSNB,DA),^PS(56,"APD",PSNB,PSNA,DA)
 Q
 ;
GENER ;INACTIVE PRODUCTS WHEN GENERIC IS INACTIVATED
 N DA1,DA2 S DA1=0 F  S DA1=$O(^PSNDF(50.6,"APRO",DA,DA1)) Q:'DA1  S $P(^PSNDF(50.68,DA1,7),"^",3)=X S DA2=0 F  S DA2=$O(^PSNDF(50.68,"ANDC",DA1,DA2)) Q:'DA2  S $P(^PSNDF(50.67,DA2,0),"^",7)=X
 Q
 ;
KGENER ;REACTIVATE PRODUCTS WHEN GENERIC IS MADE ACTIVE
 N DA1,DA2 S DA1=0 F  S DA1=$O(^PSNDF(50.6,"APRO",DA,DA1)) Q:'DA1  S $P(^PSNDF(50.68,DA1,7),"^",3)="" S DA2=0 F  S DA2=$O(^PSNDF(50.68,"ANDC",DA1,DA2)) Q:'DA2  S $P(^PSNDF(50.67,DA2,0),"^",7)=""
 Q
 ;
PROD ;INACTIVATE NDCS WHEN PRODUCTS ARE INACTIVE
 N DA2 S DA2=0 F  S DA2=$O(^PSNDF(50.68,"ANDC",DA,DA2)) Q:'DA2  S $P(^PSNDF(50.67,DA2,0),"^",7)=X
 Q
 ;
KPROD ;REACTIVATE NDCS WHEN PRODUCTS ARE MADE ACTIVE
 N DA2 S DA2=0 F  S DA2=$O(^PSNDF(50.68,"ANDC",DA,DA2)) Q:'DA2  S $P(^PSNDF(50.67,DA,0),"^",7)=""
 Q
 ;
ING2 ;from VA generic name in file 50.68
 N PSNDATA,PSNK,PSNO,PSN1,PSN2,PSN3,PSNINT
 S PSNDATA=X_"A"_DA,PSNK=0 F  S PSNK=$O(^PSNDF(50.68,DA,2,PSNK)) Q:'PSNK  S ENT=$O(^PS(50.416,PSNK,1," "),-1)+1,^(ENT,0)=PSNDATA,^PS(50.416,PSNK,1,"B",PSNDATA,ENT)="" D
 .;
 .;and the interactions
 .S PSNO=^PS(50.416,PSNK,0),PSN1=$S($P(PSNO,"^",2):$P(PSNO,"^",2),1:PSNK) Q:'$D(^PS(56,"AE",PSN1))
 .S PSN2=0 F  S PSN2=$O(^PS(56,"AE",PSN1,PSN2)) Q:'PSN2  S PSNINT=$O(^(PSN2,0)) D
 ..S PSN0=0 F J=0:1 S PSN0=$O(^PS(50.416,"APS",PSN2,PSN0)) Q:'PSN0  S PSN3=0  F  S PSN3=$O(^PS(50.416,PSN0,1,PSN3)) Q:'PSN3  S PSND1=$P(^(PSN3,0),"^"),^PS(56,"APD",PSNDATA,PSND1,PSNINT)="",^PS(56,"APD",PSND1,PSNDATA,PSNINT)=""
 ..S $P(^(0),"^",6)=$P(^PS(56,PSNINT,0),"^",6)+J
 Q
 ;
KING2 ;from VA generic name in file 50.68
 N PSNDATA,PSNARG,PSNJ,PSNK
 S PSNDATA=X_"^"_DA,PSNK=0
 F  S PSNK=$O(^PSNDF(50.68,2,PSNK)) Q:'PSNK  D
 .S PSNJ=$O(^PS(50.416,PSNK,1,"B",PSNDATA,0)) I PSNJ K ^(PSNJ),^PS(50.416,PSNK,1,PSNJ)
 .S PSNO="" F  S PSNO=$O(^PS(56,"APD",PSNDATA,PSNO)) Q:PSNO=""  K ^(PSNO),^PS(56,"APD",PSNO,PSNDATA)
 Q
 ;