- BPSECX1 ;BHAM ISC/FCS/DRS/VA/DLF - Create new Claim ID for Claim Submission file ;05/17/2004
- ;;1.0;E CLAIMS MGMT ENGINE;**1,2,5,33,38**;JUN 2004;Build 7
- ;;Per VA Directive 6402, this routine should not be modified.
- ;----------------------------------------------------------------------
- ;Create new Claim ID for Claim Submission file (9002313.02)
- ;
- ;Function Returns: VA<YYYY>=<Pharmacy ID>=<Plan ID>=<Sequence Number>
- ; Where: <YYYY> is the year
- ; <Pharmacy ID> NPI or NCPDP# of the BPS Pharmacy
- ; <Plan ID> is the VA National Plan ID w/o leading alphas
- ; <Sequence #> is a unique counter stored in BPS SETUP
- ;----------------------------------------------------------------------
- ;
- CLAIMID(IEN59) ;EP - Called from BPSOSCE (billing requests) and BPSECA8 (reversals)
- ; Check parameters
- I '$G(IEN59) Q ""
- ;
- ; Initialization
- N BPSCS,FIRST,FOURTH,I,PHARMACY,PLAN,RFL,RX,SECOND,THIRD
- ;
- ; First piece of Transmission ID = "VA"_Year
- ; Length=6
- ;
- S FIRST="VA"_($E(DT,1,3)+1700)
- ;
- ; Second piece of Transmission ID = NPI or NCPDP#
- ; 1. Try to get NPI first.
- ; 2. If we do not get the NPI, get the NCPDP and left-pad it with zeros
- ; up to seven characters.
- ; 3. Right-pad the final ID with spaces up to 10 characters
- ;
- S PHARMACY=+$P($G(^BPST(IEN59,1)),U,7)
- S SECOND=$P($G(^BPS(9002313.56,PHARMACY,"NPI")),U,1)
- ;
- ; Check for Controlled Substance Drug and if BPS Pharmacy for CS
- ; has been defined. If so, use NPI for the CS Pharmacy.
- S RX=$$GET1^DIQ(9002313.59,IEN59,1.11,"I")
- S RFL=$$GET1^DIQ(9002313.59,IEN59,9)
- S BPSCS=$$CSNPI^BPSUTIL(RX,RFL)
- I $P(BPSCS,"^")'="-1" D
- . S SECOND=$P(BPSCS,"^",2)
- . I SECOND="" S SECOND=$P(BPSCS,"^")
- ;
- I SECOND="" D
- . S SECOND=$P($G(^BPS(9002313.56,PHARMACY,0)),U,2)
- . S SECOND=$TR($J("",7-$L(SECOND))," ","0")_SECOND
- S SECOND=$RE($J($RE(SECOND),10))
- ;
- ; Third piece of Transmission ID = National Plan ID
- ; Left-padded with zeros
- ; Length = 6
- ;
- S THIRD="",PLAN=$$GET1^DIQ(9002313.59902,"1,"_IEN59_",","902.27")
- I PLAN]"" D
- . F I=1:1:$L(PLAN) I $E(PLAN,I)?1N Q
- . S PLAN=$E(PLAN,I,$L(PLAN))
- . S THIRD=PLAN
- ;
- S THIRD=$TR($J("",6-$L(THIRD))," ","0")_THIRD
- ;
- ; Fourth piece of Transmission ID = Sequence Number
- ; Left-padded with zeros
- ; Length = 7
- ;
- L +^BPS(9002313.99,1,3):15
- I '$T D IMPOSS^BPSOSUE("DB,P","TI","",,"Can't lock BPS(9002313.99,1,3)",$T(+0))
- S FOURTH=+$G(^BPS(9002313.99,1,3)),^BPS(9002313.99,1,3)=FOURTH+1
- I $L(FOURTH<7) S FOURTH=$E($TR($J("",7-$L(FOURTH))," ","0")_FOURTH,1,7)
- L -^BPS(9002313.99,1,3)
- ;
- ; Create the Transmission ID
- Q FIRST_"="_SECOND_"="_THIRD_"="_FOURTH
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HBPSECX1 2759 printed Feb 18, 2025@23:17:17 Page 2
- BPSECX1 ;BHAM ISC/FCS/DRS/VA/DLF - Create new Claim ID for Claim Submission file ;05/17/2004
- +1 ;;1.0;E CLAIMS MGMT ENGINE;**1,2,5,33,38**;JUN 2004;Build 7
- +2 ;;Per VA Directive 6402, this routine should not be modified.
- +3 ;----------------------------------------------------------------------
- +4 ;Create new Claim ID for Claim Submission file (9002313.02)
- +5 ;
- +6 ;Function Returns: VA<YYYY>=<Pharmacy ID>=<Plan ID>=<Sequence Number>
- +7 ; Where: <YYYY> is the year
- +8 ; <Pharmacy ID> NPI or NCPDP# of the BPS Pharmacy
- +9 ; <Plan ID> is the VA National Plan ID w/o leading alphas
- +10 ; <Sequence #> is a unique counter stored in BPS SETUP
- +11 ;----------------------------------------------------------------------
- +12 ;
- CLAIMID(IEN59) ;EP - Called from BPSOSCE (billing requests) and BPSECA8 (reversals)
- +1 ; Check parameters
- +2 IF '$GET(IEN59)
- QUIT ""
- +3 ;
- +4 ; Initialization
- +5 NEW BPSCS,FIRST,FOURTH,I,PHARMACY,PLAN,RFL,RX,SECOND,THIRD
- +6 ;
- +7 ; First piece of Transmission ID = "VA"_Year
- +8 ; Length=6
- +9 ;
- +10 SET FIRST="VA"_($EXTRACT(DT,1,3)+1700)
- +11 ;
- +12 ; Second piece of Transmission ID = NPI or NCPDP#
- +13 ; 1. Try to get NPI first.
- +14 ; 2. If we do not get the NPI, get the NCPDP and left-pad it with zeros
- +15 ; up to seven characters.
- +16 ; 3. Right-pad the final ID with spaces up to 10 characters
- +17 ;
- +18 SET PHARMACY=+$PIECE($GET(^BPST(IEN59,1)),U,7)
- +19 SET SECOND=$PIECE($GET(^BPS(9002313.56,PHARMACY,"NPI")),U,1)
- +20 ;
- +21 ; Check for Controlled Substance Drug and if BPS Pharmacy for CS
- +22 ; has been defined. If so, use NPI for the CS Pharmacy.
- +23 SET RX=$$GET1^DIQ(9002313.59,IEN59,1.11,"I")
- +24 SET RFL=$$GET1^DIQ(9002313.59,IEN59,9)
- +25 SET BPSCS=$$CSNPI^BPSUTIL(RX,RFL)
- +26 IF $PIECE(BPSCS,"^")'="-1"
- Begin DoDot:1
- +27 SET SECOND=$PIECE(BPSCS,"^",2)
- +28 IF SECOND=""
- SET SECOND=$PIECE(BPSCS,"^")
- End DoDot:1
- +29 ;
- +30 IF SECOND=""
- Begin DoDot:1
- +31 SET SECOND=$PIECE($GET(^BPS(9002313.56,PHARMACY,0)),U,2)
- +32 SET SECOND=$TRANSLATE($JUSTIFY("",7-$LENGTH(SECOND))," ","0")_SECOND
- End DoDot:1
- +33 SET SECOND=$REVERSE($JUSTIFY($REVERSE(SECOND),10))
- +34 ;
- +35 ; Third piece of Transmission ID = National Plan ID
- +36 ; Left-padded with zeros
- +37 ; Length = 6
- +38 ;
- +39 SET THIRD=""
- SET PLAN=$$GET1^DIQ(9002313.59902,"1,"_IEN59_",","902.27")
- +40 IF PLAN]""
- Begin DoDot:1
- +41 FOR I=1:1:$LENGTH(PLAN)
- IF $EXTRACT(PLAN,I)?1N
- QUIT
- +42 SET PLAN=$EXTRACT(PLAN,I,$LENGTH(PLAN))
- +43 SET THIRD=PLAN
- End DoDot:1
- +44 ;
- +45 SET THIRD=$TRANSLATE($JUSTIFY("",6-$LENGTH(THIRD))," ","0")_THIRD
- +46 ;
- +47 ; Fourth piece of Transmission ID = Sequence Number
- +48 ; Left-padded with zeros
- +49 ; Length = 7
- +50 ;
- +51 LOCK +^BPS(9002313.99,1,3):15
- +52 IF '$TEST
- DO IMPOSS^BPSOSUE("DB,P","TI","",,"Can't lock BPS(9002313.99,1,3)",$TEXT(+0))
- +53 SET FOURTH=+$GET(^BPS(9002313.99,1,3))
- SET ^BPS(9002313.99,1,3)=FOURTH+1
- +54 IF $LENGTH(FOURTH<7)
- SET FOURTH=$EXTRACT($TRANSLATE($JUSTIFY("",7-$LENGTH(FOURTH))," ","0")_FOURTH,1,7)
- +55 LOCK -^BPS(9002313.99,1,3)
- +56 ;
- +57 ; Create the Transmission ID
- +58 QUIT FIRST_"="_SECOND_"="_THIRD_"="_FOURTH