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**;JUN 2004;Build 5
;;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 NCPDPP 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,DEL,FACID,I,PHARMACY,PLAN,RFL,RX,SEQNUM,THIRD
;
; Get and format the Facility ID (second piece of the transmission ID)
; 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 FACID=$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 FACID=$P(BPSCS,"^",2)
. I FACID="" S FACID=$P(BPSCS,"^")
;
I FACID="" D
. S FACID=$P($G(^BPS(9002313.56,PHARMACY,0)),U,2)
. S FACID=$TR($J("",7-$L(FACID))," ","0")_FACID
S FACID=$RE($J($RE(FACID),10))
;
; Get the third piece of the transmission ID
; If the National Plan ID is available, use it with '=' delimiter (new format)
; If not, it will need to be the BIN with the '-' delimiter (old format)
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,DEL="="
;
; If no plan, get BIN and use '-' delimiter (old format)
I THIRD="" S DEL="-",THIRD=$$GET1^DIQ(9002313.59902,"1,"_IEN59_",","902.03")
;
; Pad third piece with zeros
S THIRD=$TR($J("",6-$L(THIRD))," ","0")_THIRD
;
; Get and format the sequence number (fourth piece)
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 SEQNUM=+$G(^BPS(9002313.99,1,3)),^BPS(9002313.99,1,3)=SEQNUM+1
I $L(SEQNUM<7) S SEQNUM=$E($TR($J("",7-$L(SEQNUM))," ","0")_SEQNUM,1,7)
L -^BPS(9002313.99,1,3)
;
; Create the Transmission ID
Q "VA"_($E(DT,1,3)+1700)_DEL_FACID_DEL_THIRD_DEL_SEQNUM
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HBPSECX1 2914 printed Oct 16, 2024@17:51:43 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**;JUN 2004;Build 5
+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 NCPDPP 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,DEL,FACID,I,PHARMACY,PLAN,RFL,RX,SEQNUM,THIRD
+6 ;
+7 ; Get and format the Facility ID (second piece of the transmission ID)
+8 ; 1. Try to get NPI first.
+9 ; 2. If we do not get the NPI, get the NCPDP and left-pad it with zeros
+10 ; up to seven characters.
+11 ; 3. Right-pad the final ID with spaces up to 10 characters
+12 SET PHARMACY=+$PIECE($GET(^BPST(IEN59,1)),U,7)
+13 SET FACID=$PIECE($GET(^BPS(9002313.56,PHARMACY,"NPI")),U,1)
+14 ;
+15 ; Check for Controlled Substance Drug and if BPS Pharmacy for CS
+16 ; has been defined. If so, use NPI for the CS Pharmacy.
+17 SET RX=$$GET1^DIQ(9002313.59,IEN59,1.11,"I")
+18 SET RFL=$$GET1^DIQ(9002313.59,IEN59,9)
+19 SET BPSCS=$$CSNPI^BPSUTIL(RX,RFL)
+20 IF $PIECE(BPSCS,"^")'="-1"
Begin DoDot:1
+21 SET FACID=$PIECE(BPSCS,"^",2)
+22 IF FACID=""
SET FACID=$PIECE(BPSCS,"^")
End DoDot:1
+23 ;
+24 IF FACID=""
Begin DoDot:1
+25 SET FACID=$PIECE($GET(^BPS(9002313.56,PHARMACY,0)),U,2)
+26 SET FACID=$TRANSLATE($JUSTIFY("",7-$LENGTH(FACID))," ","0")_FACID
End DoDot:1
+27 SET FACID=$REVERSE($JUSTIFY($REVERSE(FACID),10))
+28 ;
+29 ; Get the third piece of the transmission ID
+30 ; If the National Plan ID is available, use it with '=' delimiter (new format)
+31 ; If not, it will need to be the BIN with the '-' delimiter (old format)
+32 SET THIRD=""
SET PLAN=$$GET1^DIQ(9002313.59902,"1,"_IEN59_",","902.27")
+33 IF PLAN]""
Begin DoDot:1
+34 FOR I=1:1:$LENGTH(PLAN)
IF $EXTRACT(PLAN,I)?1N
QUIT
+35 SET PLAN=$EXTRACT(PLAN,I,$LENGTH(PLAN))
+36 SET THIRD=PLAN
SET DEL="="
End DoDot:1
+37 ;
+38 ; If no plan, get BIN and use '-' delimiter (old format)
+39 IF THIRD=""
SET DEL="-"
SET THIRD=$$GET1^DIQ(9002313.59902,"1,"_IEN59_",","902.03")
+40 ;
+41 ; Pad third piece with zeros
+42 SET THIRD=$TRANSLATE($JUSTIFY("",6-$LENGTH(THIRD))," ","0")_THIRD
+43 ;
+44 ; Get and format the sequence number (fourth piece)
+45 LOCK +^BPS(9002313.99,1,3):15
+46 IF '$TEST
DO IMPOSS^BPSOSUE("DB,P","TI","",,"Can't lock BPS(9002313.99,1,3)",$TEXT(+0))
+47 SET SEQNUM=+$GET(^BPS(9002313.99,1,3))
SET ^BPS(9002313.99,1,3)=SEQNUM+1
+48 IF $LENGTH(SEQNUM<7)
SET SEQNUM=$EXTRACT($TRANSLATE($JUSTIFY("",7-$LENGTH(SEQNUM))," ","0")_SEQNUM,1,7)
+49 LOCK -^BPS(9002313.99,1,3)
+50 ;
+51 ; Create the Transmission ID
+52 QUIT "VA"_($EXTRACT(DT,1,3)+1700)_DEL_FACID_DEL_THIRD_DEL_SEQNUM