BPSUTIL ;BHAM ISC/FLS/SS - General Utility functions ;3/27/08  13:18
 ;;1.0;E CLAIMS MGMT ENGINE;**1,3,2,5,6,20,27,33**;JUN 2004;Build 5
 ;;Per VA Directive 6402, this routine should not be modified.
 ;
 ; ECMEON
 ;   Input:
 ;      SITE - Pointer to Outpatient Site file (#59)
 ;   Output
 ;      1 - ECME is turned ON for the Outpatient Site
 ;      0 - ECME is not turned ON for the Outpatient Site.
 ;   Note that ON means that the Outpatient site is linked to an active
 ;     BPS Pharmacy that has a Pharmacy ID AND IB has ncpdp flagged as
 ;     turned on.
ECMEON(SITE) ;
 I '$$EPHON^IBNCPDPI Q 0
 I '$G(SITE) Q 0
 N BPSPHARM,FACID
 S FACID=0
 S BPSPHARM=$$GETPHARM(SITE)
 I BPSPHARM="" Q 0
 S FACID=$$GET1^DIQ(9002313.56,BPSPHARM_",",41.01)
 I FACID="",'$$NPIREQ^BPSNPI(DT) S FACID=$$GET1^DIQ(9002313.56,BPSPHARM_",",.02)
 Q $S(FACID:1,1:0)
 ;
CMOPON(SITE) ; - Returns 1 if CMOP is turned ON for ECME or 0 if not
 ; SITE - Pointer to #59 (OUTPATIENT SITE)
 Q:'$G(SITE) 0
 N PHRM S PHRM=$O(^BPS(9002313.56,"C",SITE,0)) I 'PHRM Q 0
 Q $$GET1^DIQ(9002313.56,PHRM,1,"I")
 ;
 ;Function returns STATUS flag from BPS PHARMACIES (file #56)
 ; Returns '1' for active or '0' for inactive BPS Pharmacy
BPSACTV(BPSPHARM) ;
 Q:'$G(BPSPHARM) 0
 Q +$P($G(^BPS(9002313.56,BPSPHARM,0)),U,10)
 ;
BPSPLN(RXI,RXR) ; - Returns the insurance PLAN NAME (902.24) field from BPS TRANSACTION
 ;
 ; Input variables -> RXI - Internal Prescription File IEN
 ;                    RXR - Refill Number
 ;
 I '$G(RXI) Q ""
 I '$G(RXR) S RXR=0
 N IEN59 S IEN59=$$IEN59^BPSOSRX(RXI,RXR) Q:IEN59="" ""
 N CINS S CINS=$$GET1^DIQ(9002313.59,IEN59,901) Q:'CINS ""
 Q $$GET1^DIQ(9002313.59902,CINS_","_IEN59,902.24)
 ; 
BPSINSCO(RXI,RXR) ; - Returns the Insurance Company (902.33) field from BPS TRANSACTION
 ; MRD;BPS*1.0*20 - Created BPSINSCO by copying BPSPLN and modifying.
 ;
 ; Input variables -> RXI - Internal Prescription File IEN
 ;                    RXR - Refill Number
 ;
 I '$G(RXI) Q ""
 I '$G(RXR) S RXR=0
 N IEN59 S IEN59=$$IEN59^BPSOSRX(RXI,RXR) Q:IEN59="" ""
 N CINS S CINS=$$GET1^DIQ(9002313.59,IEN59,901) Q:'CINS ""
 Q $$GET1^DIQ(9002313.59902,CINS_","_IEN59,902.33,"I")
 ;
 ;API for IB (IA #4146) to select BPS PHARMACY
 ;returns results as a local array BPPHARM
 ; Select the ECME Pharmacy or Pharmacies
 ;
 ; Input Variable -> BPSPHAR is passed by reference to get the result of user's selection
 ; BPPHARM = 1 One or More Pharmacies Selected
 ;    = 0 User Entered 'ALL'
 ; If BPSPHAR = 1 then the BPSPHAR array will be defined where:
 ;    BPSPHAR(ptr) = ptr ^ BPS PHARMACY NAME and
 ;    ptr = Internal Pointer to BPS PHARMACIES file (#9002313.56)
 ;
 ; Return Value ->   "" = Valid Entry or Entries Selected
 ;                                        ^ = Exit
SELPHARM(BPSPHAR) ;
 N BPRET,BPPHARM
 S BPRET=$$SELPHARM^BPSRPT3()
 M BPSPHAR=BPPHARM
 Q BPRET
 ;
 ;
 ;API for IB (IA #4146) to determine whether is one or more BPS PHARMACIES in the system
 ;Function returns
 ;1 - if the site has more than one record in the file #9002313.56
 ;0 - if there are no any divisions
 ;0^NAME OF THE EPHARM - if only one division return 0 and its name
 ;  to use in the header of the report
MULTPHRM() ;
 N IBX
 S IBX=+$O(^BPS(9002313.56,0))
 I IBX=0 Q 0
 I $O(^BPS(9002313.56,IBX))>0 Q 1
 Q "0^"_$$GET1^DIQ(9002313.56,IBX,.01,"E")
 ;
 ; Function for IB (IA #4146) to return site linked to pharmacy
 ; Input
 ;   BPSDIV - Outpatient Site
 ; Returns
 ;   BPSPHARM - BPS Pharmacy IEN
GETPHARM(BPSDIV) ;
 N BPSPHARM
 I $G(BPSDIV)="" Q ""
 S BPSPHARM=$O(^BPS(9002313.56,"C",BPSDIV,0)) I 'BPSPHARM Q ""
 Q:'$$BPSACTV^BPSUTIL(BPSPHARM) ""
 Q BPSPHARM
 ;
 ;API  for the IB package (IA#4146)
 ;Input parameters:
 ; BPSRX  - Rx ien (file #52)
 ; BPSREFNO - refill number
 ;Returned value:
 ; 1st piece:
 ;  0 - status "non-payable" OR there is no response from the payer for whatever reason OR wasn't submitted OR invalid parameters
 ;  1- status "payable"
 ; 2nd piece:
 ;  amount the payer agreed to pay
 ; 3rd piece:
 ;  Date of Service
 ;
PAIDAMNT(BPSRX,BPSREFNO) ;
 I ($G(BPSRX)="")!($G(BPSREFNO)="") Q "0^"
 N BPSTAT,BPSRET,IEN59,BPSRESP,BPDOS
 S BPSTAT=$$STATUS^BPSOSRX(BPSRX,BPSREFNO)
 ;The status of the claim should be "payable" in order to get amount of the 3rd party payment
 ;If it was an attempt to reverse the payable claim AND reversal was rejected
 ;then the claim still is considered as "payable" and we still can get the amount paid by the 3rd party.
 ;In this case we return 1 (payable) in first piece and the amount paid in the 2nd piece of the returned value.
 ;All other statuses mean that we cannot get amount paid so we return 0 = "non payable"
 I $P(BPSTAT,U)'="E PAYABLE",$P(BPSTAT,U)'="E REVERSAL REJECTED",$P(BPSTAT,U)'="E DUPLICATE" Q "0^"
 ;get ien for BPS TRANSACTION file
 S IEN59=+$$IEN59^BPSOSRX(BPSRX,BPSREFNO)
 I IEN59="" Q "0^"  ;BPS Transaction IEN could not be calculated
 S BPSRESP=+$P($G(^BPST(IEN59,0)),U,5)
 ;response from the payer was not found  - either claim was never submitted OR there
 ;is no response for some reason - either way - we cannot provide the amount paid, so return "0"
 I BPSRESP=0 Q "0^"
 S BPDOS=+$P($G(^BPST(IEN59,12)),U,2)
 S BPSRET=+$$INSPAID^BPSOS03(BPSRESP)
 Q "1^"_BPSRET_U_BPDOS
 ;
 ; NPIEXTR
 ;   This API was written for the NPI extract (XUSNPIX2) and returns
 ;    the NCPDP and STATUS of the associated BPS Pharmacy
 ;   Input:
 ;      SITE - Pointer to Outpatient Site file (#59)
 ;   Output
 ;      NCPDP^STATUS (0 - inactive, 1 - active)
 ;      "" if no SITE passed in or no linkage
NPIEXTR(SITE) ;
 I '$G(SITE) Q ""
 N BPSPHARM,NCPDP,STATUS
 S BPSPHARM=$O(^BPS(9002313.56,"C",SITE,0))
 I 'BPSPHARM Q ""
 S STATUS=$$BPSACTV^BPSUTIL(BPSPHARM)
 S NCPDP=$$GET1^DIQ(9002313.56,BPSPHARM_",",.02)
 Q NCPDP_"^"_STATUS
 ;
 ; TOUCHED
 ;   Input:
 ;      BPS57 - IEN BPS LOG OF TRANSACTIONS file #9002313.57 - required
 ;   Output:
 ;      0 - No touch or automated transaction
 ;      1 - touched or manual transaction
 ;
TOUCHED(BPS57) ;
 ;
 N RXACTION
 I $G(BPS57)="" Q 1
 ;
 ; Get the RXACTION for the transaction.  This field is also referred
 ; to as BWHERE throughout the claims submission process.
 ;
 S RXACTION=$$GET1^DIQ(9002313.57,BPS57,1201)
 ;
 ; Transactions with the below actions are No Touch transactions.
 ;
 I ",AREV,CRLB,CRLR,CRLX,CRRL,DC,DE,HLD,OF,PC,PE,PL,PP,RF,RN,RRL,"[(","_RXACTION_",") Q 0
 ;
 Q 1
 ;
CSNPI(RX,RFL) ; BPS Pharmacy for CS NCPDP# and NPI
 ;
 ; Input -> RX  - Internal Prescription File IEN
 ;          RFL - Refill Number
 ;
 ; Determine if the drug on the Rx is a Controlled Substance (CS).
 ; CS drugs are defined as those which contain 2, 3, 4 or 5 in 
 ; field DEA, SPECIAL HDLG (#3) of the DRUG file (#50).
 ;
 ; If the drug is a CS, check BPS PHARMACIES (#9002313.56) to see if
 ; a different pharmacy is defined to dispense CS drugs.  Field #2
 ; of BPS PHARMACIES is BPS PHARMACY FOR CS.  This is a 
 ; pointer to another entry in BPS PHARMACIES.  This is the pharmacy
 ; assigned to dispense CS drugs for the original pharmacy.  
 ;
 ; Return the NCPDP# and NPI of the BPS PHARMACY FOR CS if it exists.
 ;
 N BPSCSID,BPSDEA,BPSDIV,BPSDRGI,BPSPHARM,NCPDP,NPI
 ;
 ; Get Drug IEN and DEA, SPECIAL HDLG info
 S BPSDRGI=$$GET1^DIQ(52,RX,6,"I")
 S BPSDEA=$$GET1^DIQ(50,BPSDRGI,3)
 ;
 ; Quit if not a Controlled Substance
 I '((BPSDEA["2")!(BPSDEA["3")!(BPSDEA["4")!(BPSDEA["5")) Q "-1^Non CS"
 ;
 ; Get Division and BPS Pharmacy info
 S BPSDIV=+$$RXSITE^PSOBPSUT(RX,RFL)
 S BPSPHARM=$$GETPHARM^BPSUTIL(BPSDIV)
 I BPSPHARM="" Q "-1^No BPS Pharm"
 ;
 ; Get BPS Pharmacy for CS info
 S BPSCSID=$$GET1^DIQ(9002313.56,BPSPHARM,2,"I")
 I BPSCSID="" Q "-1^No CS Pharm"
 ;
 ; Return NCPDP and NPI for BPS Pharmacy for CS
 S NCPDP=$$GET1^DIQ(9002313.56,BPSCSID,.02)
 S NPI=$$GET1^DIQ(9002313.56,BPSCSID,41.01)
 ;
 Q NCPDP_"^"_NPI
 ;
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HBPSUTIL   8032     printed  Sep 23, 2025@19:29:48                                                                                                                                                                                                     Page 2
BPSUTIL   ;BHAM ISC/FLS/SS - General Utility functions ;3/27/08  13:18
 +1       ;;1.0;E CLAIMS MGMT ENGINE;**1,3,2,5,6,20,27,33**;JUN 2004;Build 5
 +2       ;;Per VA Directive 6402, this routine should not be modified.
 +3       ;
 +4       ; ECMEON
 +5       ;   Input:
 +6       ;      SITE - Pointer to Outpatient Site file (#59)
 +7       ;   Output
 +8       ;      1 - ECME is turned ON for the Outpatient Site
 +9       ;      0 - ECME is not turned ON for the Outpatient Site.
 +10      ;   Note that ON means that the Outpatient site is linked to an active
 +11      ;     BPS Pharmacy that has a Pharmacy ID AND IB has ncpdp flagged as
 +12      ;     turned on.
ECMEON(SITE) ;
 +1        IF '$$EPHON^IBNCPDPI
               QUIT 0
 +2        IF '$GET(SITE)
               QUIT 0
 +3        NEW BPSPHARM,FACID
 +4        SET FACID=0
 +5        SET BPSPHARM=$$GETPHARM(SITE)
 +6        IF BPSPHARM=""
               QUIT 0
 +7        SET FACID=$$GET1^DIQ(9002313.56,BPSPHARM_",",41.01)
 +8        IF FACID=""
               IF '$$NPIREQ^BPSNPI(DT)
                   SET FACID=$$GET1^DIQ(9002313.56,BPSPHARM_",",.02)
 +9        QUIT $SELECT(FACID:1,1:0)
 +10      ;
CMOPON(SITE) ; - Returns 1 if CMOP is turned ON for ECME or 0 if not
 +1       ; SITE - Pointer to #59 (OUTPATIENT SITE)
 +2        if '$GET(SITE)
               QUIT 0
 +3        NEW PHRM
           SET PHRM=$ORDER(^BPS(9002313.56,"C",SITE,0))
           IF 'PHRM
               QUIT 0
 +4        QUIT $$GET1^DIQ(9002313.56,PHRM,1,"I")
 +5       ;
 +6       ;Function returns STATUS flag from BPS PHARMACIES (file #56)
 +7       ; Returns '1' for active or '0' for inactive BPS Pharmacy
BPSACTV(BPSPHARM) ;
 +1        if '$GET(BPSPHARM)
               QUIT 0
 +2        QUIT +$PIECE($GET(^BPS(9002313.56,BPSPHARM,0)),U,10)
 +3       ;
BPSPLN(RXI,RXR) ; - Returns the insurance PLAN NAME (902.24) field from BPS TRANSACTION
 +1       ;
 +2       ; Input variables -> RXI - Internal Prescription File IEN
 +3       ;                    RXR - Refill Number
 +4       ;
 +5        IF '$GET(RXI)
               QUIT ""
 +6        IF '$GET(RXR)
               SET RXR=0
 +7        NEW IEN59
           SET IEN59=$$IEN59^BPSOSRX(RXI,RXR)
           if IEN59=""
               QUIT ""
 +8        NEW CINS
           SET CINS=$$GET1^DIQ(9002313.59,IEN59,901)
           if 'CINS
               QUIT ""
 +9        QUIT $$GET1^DIQ(9002313.59902,CINS_","_IEN59,902.24)
 +10      ; 
BPSINSCO(RXI,RXR) ; - Returns the Insurance Company (902.33) field from BPS TRANSACTION
 +1       ; MRD;BPS*1.0*20 - Created BPSINSCO by copying BPSPLN and modifying.
 +2       ;
 +3       ; Input variables -> RXI - Internal Prescription File IEN
 +4       ;                    RXR - Refill Number
 +5       ;
 +6        IF '$GET(RXI)
               QUIT ""
 +7        IF '$GET(RXR)
               SET RXR=0
 +8        NEW IEN59
           SET IEN59=$$IEN59^BPSOSRX(RXI,RXR)
           if IEN59=""
               QUIT ""
 +9        NEW CINS
           SET CINS=$$GET1^DIQ(9002313.59,IEN59,901)
           if 'CINS
               QUIT ""
 +10       QUIT $$GET1^DIQ(9002313.59902,CINS_","_IEN59,902.33,"I")
 +11      ;
 +12      ;API for IB (IA #4146) to select BPS PHARMACY
 +13      ;returns results as a local array BPPHARM
 +14      ; Select the ECME Pharmacy or Pharmacies
 +15      ;
 +16      ; Input Variable -> BPSPHAR is passed by reference to get the result of user's selection
 +17      ; BPPHARM = 1 One or More Pharmacies Selected
 +18      ;    = 0 User Entered 'ALL'
 +19      ; If BPSPHAR = 1 then the BPSPHAR array will be defined where:
 +20      ;    BPSPHAR(ptr) = ptr ^ BPS PHARMACY NAME and
 +21      ;    ptr = Internal Pointer to BPS PHARMACIES file (#9002313.56)
 +22      ;
 +23      ; Return Value ->   "" = Valid Entry or Entries Selected
 +24      ;                                        ^ = Exit
SELPHARM(BPSPHAR) ;
 +1        NEW BPRET,BPPHARM
 +2        SET BPRET=$$SELPHARM^BPSRPT3()
 +3        MERGE BPSPHAR=BPPHARM
 +4        QUIT BPRET
 +5       ;
 +6       ;
 +7       ;API for IB (IA #4146) to determine whether is one or more BPS PHARMACIES in the system
 +8       ;Function returns
 +9       ;1 - if the site has more than one record in the file #9002313.56
 +10      ;0 - if there are no any divisions
 +11      ;0^NAME OF THE EPHARM - if only one division return 0 and its name
 +12      ;  to use in the header of the report
MULTPHRM() ;
 +1        NEW IBX
 +2        SET IBX=+$ORDER(^BPS(9002313.56,0))
 +3        IF IBX=0
               QUIT 0
 +4        IF $ORDER(^BPS(9002313.56,IBX))>0
               QUIT 1
 +5        QUIT "0^"_$$GET1^DIQ(9002313.56,IBX,.01,"E")
 +6       ;
 +7       ; Function for IB (IA #4146) to return site linked to pharmacy
 +8       ; Input
 +9       ;   BPSDIV - Outpatient Site
 +10      ; Returns
 +11      ;   BPSPHARM - BPS Pharmacy IEN
GETPHARM(BPSDIV) ;
 +1        NEW BPSPHARM
 +2        IF $GET(BPSDIV)=""
               QUIT ""
 +3        SET BPSPHARM=$ORDER(^BPS(9002313.56,"C",BPSDIV,0))
           IF 'BPSPHARM
               QUIT ""
 +4        if '$$BPSACTV^BPSUTIL(BPSPHARM)
               QUIT ""
 +5        QUIT BPSPHARM
 +6       ;
 +7       ;API  for the IB package (IA#4146)
 +8       ;Input parameters:
 +9       ; BPSRX  - Rx ien (file #52)
 +10      ; BPSREFNO - refill number
 +11      ;Returned value:
 +12      ; 1st piece:
 +13      ;  0 - status "non-payable" OR there is no response from the payer for whatever reason OR wasn't submitted OR invalid parameters
 +14      ;  1- status "payable"
 +15      ; 2nd piece:
 +16      ;  amount the payer agreed to pay
 +17      ; 3rd piece:
 +18      ;  Date of Service
 +19      ;
PAIDAMNT(BPSRX,BPSREFNO) ;
 +1        IF ($GET(BPSRX)="")!($GET(BPSREFNO)="")
               QUIT "0^"
 +2        NEW BPSTAT,BPSRET,IEN59,BPSRESP,BPDOS
 +3        SET BPSTAT=$$STATUS^BPSOSRX(BPSRX,BPSREFNO)
 +4       ;The status of the claim should be "payable" in order to get amount of the 3rd party payment
 +5       ;If it was an attempt to reverse the payable claim AND reversal was rejected
 +6       ;then the claim still is considered as "payable" and we still can get the amount paid by the 3rd party.
 +7       ;In this case we return 1 (payable) in first piece and the amount paid in the 2nd piece of the returned value.
 +8       ;All other statuses mean that we cannot get amount paid so we return 0 = "non payable"
 +9        IF $PIECE(BPSTAT,U)'="E PAYABLE"
               IF $PIECE(BPSTAT,U)'="E REVERSAL REJECTED"
                   IF $PIECE(BPSTAT,U)'="E DUPLICATE"
                       QUIT "0^"
 +10      ;get ien for BPS TRANSACTION file
 +11       SET IEN59=+$$IEN59^BPSOSRX(BPSRX,BPSREFNO)
 +12      ;BPS Transaction IEN could not be calculated
           IF IEN59=""
               QUIT "0^"
 +13       SET BPSRESP=+$PIECE($GET(^BPST(IEN59,0)),U,5)
 +14      ;response from the payer was not found  - either claim was never submitted OR there
 +15      ;is no response for some reason - either way - we cannot provide the amount paid, so return "0"
 +16       IF BPSRESP=0
               QUIT "0^"
 +17       SET BPDOS=+$PIECE($GET(^BPST(IEN59,12)),U,2)
 +18       SET BPSRET=+$$INSPAID^BPSOS03(BPSRESP)
 +19       QUIT "1^"_BPSRET_U_BPDOS
 +20      ;
 +21      ; NPIEXTR
 +22      ;   This API was written for the NPI extract (XUSNPIX2) and returns
 +23      ;    the NCPDP and STATUS of the associated BPS Pharmacy
 +24      ;   Input:
 +25      ;      SITE - Pointer to Outpatient Site file (#59)
 +26      ;   Output
 +27      ;      NCPDP^STATUS (0 - inactive, 1 - active)
 +28      ;      "" if no SITE passed in or no linkage
NPIEXTR(SITE) ;
 +1        IF '$GET(SITE)
               QUIT ""
 +2        NEW BPSPHARM,NCPDP,STATUS
 +3        SET BPSPHARM=$ORDER(^BPS(9002313.56,"C",SITE,0))
 +4        IF 'BPSPHARM
               QUIT ""
 +5        SET STATUS=$$BPSACTV^BPSUTIL(BPSPHARM)
 +6        SET NCPDP=$$GET1^DIQ(9002313.56,BPSPHARM_",",.02)
 +7        QUIT NCPDP_"^"_STATUS
 +8       ;
 +9       ; TOUCHED
 +10      ;   Input:
 +11      ;      BPS57 - IEN BPS LOG OF TRANSACTIONS file #9002313.57 - required
 +12      ;   Output:
 +13      ;      0 - No touch or automated transaction
 +14      ;      1 - touched or manual transaction
 +15      ;
TOUCHED(BPS57) ;
 +1       ;
 +2        NEW RXACTION
 +3        IF $GET(BPS57)=""
               QUIT 1
 +4       ;
 +5       ; Get the RXACTION for the transaction.  This field is also referred
 +6       ; to as BWHERE throughout the claims submission process.
 +7       ;
 +8        SET RXACTION=$$GET1^DIQ(9002313.57,BPS57,1201)
 +9       ;
 +10      ; Transactions with the below actions are No Touch transactions.
 +11      ;
 +12       IF ",AREV,CRLB,CRLR,CRLX,CRRL,DC,DE,HLD,OF,PC,PE,PL,PP,RF,RN,RRL,"[(","_RXACTION_",")
               QUIT 0
 +13      ;
 +14       QUIT 1
 +15      ;
CSNPI(RX,RFL) ; BPS Pharmacy for CS NCPDP# and NPI
 +1       ;
 +2       ; Input -> RX  - Internal Prescription File IEN
 +3       ;          RFL - Refill Number
 +4       ;
 +5       ; Determine if the drug on the Rx is a Controlled Substance (CS).
 +6       ; CS drugs are defined as those which contain 2, 3, 4 or 5 in 
 +7       ; field DEA, SPECIAL HDLG (#3) of the DRUG file (#50).
 +8       ;
 +9       ; If the drug is a CS, check BPS PHARMACIES (#9002313.56) to see if
 +10      ; a different pharmacy is defined to dispense CS drugs.  Field #2
 +11      ; of BPS PHARMACIES is BPS PHARMACY FOR CS.  This is a 
 +12      ; pointer to another entry in BPS PHARMACIES.  This is the pharmacy
 +13      ; assigned to dispense CS drugs for the original pharmacy.  
 +14      ;
 +15      ; Return the NCPDP# and NPI of the BPS PHARMACY FOR CS if it exists.
 +16      ;
 +17       NEW BPSCSID,BPSDEA,BPSDIV,BPSDRGI,BPSPHARM,NCPDP,NPI
 +18      ;
 +19      ; Get Drug IEN and DEA, SPECIAL HDLG info
 +20       SET BPSDRGI=$$GET1^DIQ(52,RX,6,"I")
 +21       SET BPSDEA=$$GET1^DIQ(50,BPSDRGI,3)
 +22      ;
 +23      ; Quit if not a Controlled Substance
 +24       IF '((BPSDEA["2")!(BPSDEA["3")!(BPSDEA["4")!(BPSDEA["5"))
               QUIT "-1^Non CS"
 +25      ;
 +26      ; Get Division and BPS Pharmacy info
 +27       SET BPSDIV=+$$RXSITE^PSOBPSUT(RX,RFL)
 +28       SET BPSPHARM=$$GETPHARM^BPSUTIL(BPSDIV)
 +29       IF BPSPHARM=""
               QUIT "-1^No BPS Pharm"
 +30      ;
 +31      ; Get BPS Pharmacy for CS info
 +32       SET BPSCSID=$$GET1^DIQ(9002313.56,BPSPHARM,2,"I")
 +33       IF BPSCSID=""
               QUIT "-1^No CS Pharm"
 +34      ;
 +35      ; Return NCPDP and NPI for BPS Pharmacy for CS
 +36       SET NCPDP=$$GET1^DIQ(9002313.56,BPSCSID,.02)
 +37       SET NPI=$$GET1^DIQ(9002313.56,BPSCSID,41.01)
 +38      ;
 +39       QUIT NCPDP_"^"_NPI
 +40      ;