PSOTPCUL ;BIR/RTR-Utility Routine for TBP Project ;08/09/03 ;;7.0;OUTPATIENT PHARMACY;**145,160**;DEC 1997 ; EN(PSOTRXN) ;CPRS call to determine if an RX is a TPB Rx ;PSOTRXN = internal Rx number ;OUTPUT = 1 for TBP Rx, 0 for non-TPB Rx Q:'$G(PSOTRXN) 0 Q $S($P($G(^PSRX(PSOTRXN,"TPB")),"^"):1,1:0) ; ACTRX(DFN,TPB) ; Checks if Patient has at least one Active Rx on File ; Input: DFN: Patient IEN (#2) ; TPB: 0 - Looks for active VA prescriptions only (Default) ; 1 - Looks for active TPB prescriptions only ; 2 - Looks for active VA or TPB prescriptions ;Output: 1 - Active Rx found / 0 - None found ; N SEQ,ACTRX,EXPDT I '$G(DFN) Q 0 S TPB=+$G(TPB),(SEQ,ACTRX)=0 F S SEQ=$O(^PS(55,DFN,"P",SEQ)) Q:'SEQ D I ACTRX Q . S RX=$G(^PS(55,DFN,"P",SEQ,0)),TPBRX=+$G(^PSRX(RX,"TPB")) . I '$$ACTIVE(RX) Q . I TPB=2 S ACTRX=1 Q . I TPB=1,TPBRX S ACTRX=1 Q . I TPB=0,'TPBRX S ACTRX=1 Q ; Q ACTRX ; ACTIVE(RX) ; Checks if Rx is Active or not N RXSTS,TPBRX,EXPDT S RXSTS=+$G(^PSRX(RX,"STA")) I RXSTS>9,(RXSTS'=16) Q 0 S EXPDT=$P($G(^PSRX(RX,2)),"^",6) I EXPDT,EXPDT