- BPSNCPD6 ;ALB/SS - Pharmacy API part 6 ;10-JAN-08
- ;;1.0;E CLAIMS MGMT ENGINE;**7,8,10,11,20**;JUN 2004;Build 27
- ;;Per VA Directive 6402, this routine should not be modified.
- ;
- ;All of the entry points in this routine except LOOK77 were
- ; created from code that was copied from BPSNCPDP because BPSNCPDP
- ; was too big. The variables are newed in BPSNCPDP and returned back
- ; to BPSNCPDP
- ;== New Claim
- NEWCLAIM ;
- S BPRETV=$$NEWCLM^BPSNCPD5(.BP77NEW,BRXIEN,BFILL,DOS,BWHERE,BILLNDC,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,BPCOBIND,BPJOBFLG,IEN59,BPACTTYP,DFN,.BPSTART,$G(BPREQIEN),.BPSELIG,$G(BPSRTYPE),$G(BPSPLAN),.BPSPRDAT)
- S RESPONSE=+BPRETV
- ;to make LOG backward compatible
- D LOG^BPSOSL(IEN59,$T(+0)_"-After Submit of Claim. Return Value: "_$S(RESPONSE=0:1,1:0))
- S CLMSTAT=$P(BPRETV,U,2)
- D DISPL^BPSNCPD4(WFLG,BPRETV,$G(BPSELIG))
- I RESPONSE=0 Q
- D LOG^BPSOSL(IEN59,$T(+0)_"-"_CLMSTAT)
- Q
- ;
- ;== Reversals for Payable claims
- ;(Note: BPSCLOSE parameter of EN^BPSNCPDP can be used in this case)
- RVPAID ;
- S BPRETV=$$REVERSAL^BPSNCPD5(.BP77NEW,BRXIEN,BFILL,OLDRESP,DOS,BWHERE,$G(BILLNDC),REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,IEN59,BPCOBIND,BPJOBFLG,BPACTTYP,.BPSTART,$G(BPREQIEN),.BPSCLOSE,$G(BPSRTYPE),.BPSPRDAT)
- S RESPONSE=+BPRETV
- ;to make LOG backward compatible
- D LOG^BPSOSL(IEN59,$T(+0)_"-After Submit of Reversal. Return Value: "_$S(RESPONSE=0:1,1:0))
- S CLMSTAT=$P(BPRETV,U,2)
- I BWHERE'="EREV" D DISPL^BPSNCPD4(WFLG,BPRETV,$G(BPSELIG))
- I RESPONSE=0 Q
- D LOG^BPSOSL(IEN59,$T(+0)_"-"_CLMSTAT)
- Q
- ;
- ;== Reversals+Resubmits for Payable claims
- RVRSPAID ;
- S BPRETV=$$REVRESUB^BPSNCPD4(.BP77NEW,BRXIEN,BFILL,DOS,BWHERE,BILLNDC,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,BPCOBIND,BPJOBFLG,IEN59,DFN,.BPSTART,$G(BPREQIEN),OLDRESP,.BPSELIG,$G(BPSRTYPE),$G(BPSPLAN),.BPSPRDAT)
- S RESPONSE=+BPRETV
- ;if "Reversal only not resubmit" - display a message for the user
- I RESPONSE=10 D DISPL^BPSNCPD4(WFLG,"10^Claim Will Be Reversed But Will Not Be Resubmitted^D^2",$G(BPSELIG))
- ;to make LOG backward compatible
- D LOG^BPSOSL(IEN59,$T(+0)_"-After Submit of Reversal. Return Value: "_$S(RESPONSE=0:1,1:0))
- D DISPL^BPSNCPD4(WFLG,BPRETV,$G(BPSELIG))
- I RESPONSE=10 S CLMSTAT=$P(BPRETV,U,5) Q
- S CLMSTAT=$P(BPRETV,U,2)
- I RESPONSE=0 Q
- D LOG^BPSOSL(IEN59,$T(+0)_"-"_CLMSTAT)
- Q
- ;
- ;== Resubmits for Payable claims - DO NOT resubmit
- RSPAID ;
- S RESPONSE=1
- ; Message varies depending the the previous response
- ; Reversal Accepted would not get here so this must be rejected, stranded, or other
- I OLDRESP["REVERSAL" S CLMSTAT="Can not resubmit a rejected or stranded reversal"
- E S CLMSTAT="Previously billed through ECME: "_OLDRESP
- D DISPL^BPSNCPD4(WFLG,RESPONSE_U_CLMSTAT_"^D^2",$G(BPSELIG))
- D LOG^BPSOSL(IEN59,$T(+0)_"-"_CLMSTAT)
- Q
- ;== Reversals for Non-Payable claims - DO NOT reverse
- RVNPAID ;
- ;if this is return to stock OR delete - close the claim
- I ",RS,DE,"[(","_BWHERE_",") D Q
- . D CLOSE2^BPSBUTL(BRXIEN,BFILL,BWHERE)
- . S RESPONSE=3
- . S CLMSTAT="Claim was not payable so it has been closed. No ECME claim created."
- . D DISPL^BPSNCPD4(WFLG,RESPONSE_U_CLMSTAT_"^D^2",$G(BPSELIG))
- . D LOG^BPSOSL(IEN59,$T(+0)_"-"_CLMSTAT)
- S RESPONSE=1
- S CLMSTAT="Claim has status "_OLDRESP_". Not reversed."
- D DISPL^BPSNCPD4(WFLG,RESPONSE_U_CLMSTAT_"^D^2",$G(BPSELIG))
- D LOG^BPSOSL(IEN59,$T(+0)_"-"_CLMSTAT)
- Q
- ;
- ;== Resubmits AND Reversals+Resubmits for Non-Payable claims
- ;== Also used for Resubmits without Reversals no matter the claim status (BPS*1*20)
- RVRSNPD ;
- ; resubmit a claim
- S BPRETV=$$REVRESNP^BPSNCPD5(.BP77NEW,BRXIEN,BFILL,DOS,BWHERE,BILLNDC,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,BPCOBIND,BPJOBFLG,IEN59,BPACTTYP,DFN,.BPSTART,$G(BPREQIEN),OLDRESP,.BPSELIG,$G(BPSRTYPE),$G(BPSPLAN),.BPSPRDAT)
- S RESPONSE=+BPRETV
- ;to make LOG backward compatible
- I BWHERE'="ERWV" D LOG^BPSOSL(IEN59,$T(+0)_"-After Submit of Reversal. Return Value: "_$S(RESPONSE=0:1,1:0))
- I BWHERE="ERWV" D LOG^BPSOSL(IEN59,$T(+0)_"-After Submit of Claim w/o Reversal. Return Value: "_$S(RESPONSE=0:1,1:0))
- S CLMSTAT=$P(BPRETV,U,2)
- D DISPL^BPSNCPD4(WFLG,BPRETV,$G(BPSELIG))
- I RESPONSE=0 Q
- D LOG^BPSOSL(IEN59,$T(+0)_"-"_CLMSTAT)
- Q
- ;
- ; if Back Billing
- BB ;
- S RESPONSE=1
- S CLMSTAT="Previously billed through ECME: "_OLDRESP
- D DISPL^BPSNCPD4(WFLG,RESPONSE_U_CLMSTAT_"^D^2",$G(BPSELIG))
- D LOG^BPSOSL(IEN59,$T(+0)_"-"_CLMSTAT)
- Q
- ;
- ; if we do not have a status for pre-existing claim AND this is a reversal request - DO NOT reverse
- RVNEW ;
- S RESPONSE=1
- S CLMSTAT="Prescription not previously billed through ECME. Cannot Reverse claim."
- D DISPL^BPSNCPD4(WFLG,RESPONSE_U_CLMSTAT_"^D^2",$G(BPSELIG))
- D LOG^BPSOSL(IEN59,$T(+0)_"-"_CLMSTAT)
- Q
- ;
- ; This was meant to called by BPSSCR04 to collect requests for the User Screen that don't have BPS TRANSACTION records
- ; However, it is currently not called. This is still here in case, it is needed in the future. The call that should
- ; be used is D LOOK77^BPSNCPD6(BPBDT,BPEDT,BPTMP1)
- LOOK77(BPBEGDT,BPENDDT,BPTMP) ;
- N BPLDT77,BP77,BP59,BPRXRF
- S BPLDT77=BPBEGDT-0.00001
- F S BPLDT77=+$O(^BPS(9002313.77,"E",BPLDT77)) Q:BPLDT77=0!(BPLDT77>BPENDDT) D
- . S BP77=0 F S BP77=$O(^BPS(9002313.77,"E",BPLDT77,BP77)) Q:+BP77=0 D
- . . S BPRXRF=$P($G(^BPS(9002313.77,BP77,0)),U,1,2)
- . . S BP59=$$IEN59^BPSOSRX(+BPRXRF,$P(BPRXRF,U,2)) ;calculate BPS TRANSACTION ien (even if it doesn't exist yet)
- . . I $D(@BPTMP@(BP59)) Q ;don't create an entry if the claim is already there
- . . S @BPTMP@(BP59)=(BPLDT77\1)_"^77-"
- Q
- ;
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HBPSNCPD6 5655 printed Mar 13, 2025@20:55:58 Page 2
- BPSNCPD6 ;ALB/SS - Pharmacy API part 6 ;10-JAN-08
- +1 ;;1.0;E CLAIMS MGMT ENGINE;**7,8,10,11,20**;JUN 2004;Build 27
- +2 ;;Per VA Directive 6402, this routine should not be modified.
- +3 ;
- +4 ;All of the entry points in this routine except LOOK77 were
- +5 ; created from code that was copied from BPSNCPDP because BPSNCPDP
- +6 ; was too big. The variables are newed in BPSNCPDP and returned back
- +7 ; to BPSNCPDP
- +8 ;== New Claim
- NEWCLAIM ;
- +1 SET BPRETV=$$NEWCLM^BPSNCPD5(.BP77NEW,BRXIEN,BFILL,DOS,BWHERE,BILLNDC,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,BPCOBIND,BPJOBFLG,IEN59,BPACTTYP,DFN,.BPSTART,$GET(BPREQIEN),.BPSELIG,$GET(BPSRTYPE),$GET(BPSPLAN),.BPSPRDAT)
- +2 SET RESPONSE=+BPRETV
- +3 ;to make LOG backward compatible
- +4 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-After Submit of Claim. Return Value: "_$SELECT(RESPONSE=0:1,1:0))
- +5 SET CLMSTAT=$PIECE(BPRETV,U,2)
- +6 DO DISPL^BPSNCPD4(WFLG,BPRETV,$GET(BPSELIG))
- +7 IF RESPONSE=0
- QUIT
- +8 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-"_CLMSTAT)
- +9 QUIT
- +10 ;
- +11 ;== Reversals for Payable claims
- +12 ;(Note: BPSCLOSE parameter of EN^BPSNCPDP can be used in this case)
- RVPAID ;
- +1 SET BPRETV=$$REVERSAL^BPSNCPD5(.BP77NEW,BRXIEN,BFILL,OLDRESP,DOS,BWHERE,$GET(BILLNDC),REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,IEN59,BPCOBIND,BPJOBFLG,BPACTTYP,.BPSTART,$GET(BPREQIEN),.BPSCLOSE,$GET(BPSRTYPE),.BPSPRDAT)
- +2 SET RESPONSE=+BPRETV
- +3 ;to make LOG backward compatible
- +4 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-After Submit of Reversal. Return Value: "_$SELECT(RESPONSE=0:1,1:0))
- +5 SET CLMSTAT=$PIECE(BPRETV,U,2)
- +6 IF BWHERE'="EREV"
- DO DISPL^BPSNCPD4(WFLG,BPRETV,$GET(BPSELIG))
- +7 IF RESPONSE=0
- QUIT
- +8 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-"_CLMSTAT)
- +9 QUIT
- +10 ;
- +11 ;== Reversals+Resubmits for Payable claims
- RVRSPAID ;
- +1 SET BPRETV=$$REVRESUB^BPSNCPD4(.BP77NEW,BRXIEN,BFILL,DOS,BWHERE,BILLNDC,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,BPCOBIND,BPJOBFLG,IEN59,DFN,.BPSTART,$GET(BPREQIEN),OLDRESP,.BPSELIG,$GET(BPSRTYPE),$GET(BPSPLAN),.BPSPRDAT)
- +2 SET RESPONSE=+BPRETV
- +3 ;if "Reversal only not resubmit" - display a message for the user
- +4 IF RESPONSE=10
- DO DISPL^BPSNCPD4(WFLG,"10^Claim Will Be Reversed But Will Not Be Resubmitted^D^2",$GET(BPSELIG))
- +5 ;to make LOG backward compatible
- +6 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-After Submit of Reversal. Return Value: "_$SELECT(RESPONSE=0:1,1:0))
- +7 DO DISPL^BPSNCPD4(WFLG,BPRETV,$GET(BPSELIG))
- +8 IF RESPONSE=10
- SET CLMSTAT=$PIECE(BPRETV,U,5)
- QUIT
- +9 SET CLMSTAT=$PIECE(BPRETV,U,2)
- +10 IF RESPONSE=0
- QUIT
- +11 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-"_CLMSTAT)
- +12 QUIT
- +13 ;
- +14 ;== Resubmits for Payable claims - DO NOT resubmit
- RSPAID ;
- +1 SET RESPONSE=1
- +2 ; Message varies depending the the previous response
- +3 ; Reversal Accepted would not get here so this must be rejected, stranded, or other
- +4 IF OLDRESP["REVERSAL"
- SET CLMSTAT="Can not resubmit a rejected or stranded reversal"
- +5 IF '$TEST
- SET CLMSTAT="Previously billed through ECME: "_OLDRESP
- +6 DO DISPL^BPSNCPD4(WFLG,RESPONSE_U_CLMSTAT_"^D^2",$GET(BPSELIG))
- +7 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-"_CLMSTAT)
- +8 QUIT
- +9 ;== Reversals for Non-Payable claims - DO NOT reverse
- RVNPAID ;
- +1 ;if this is return to stock OR delete - close the claim
- +2 IF ",RS,DE,"[(","_BWHERE_",")
- Begin DoDot:1
- +3 DO CLOSE2^BPSBUTL(BRXIEN,BFILL,BWHERE)
- +4 SET RESPONSE=3
- +5 SET CLMSTAT="Claim was not payable so it has been closed. No ECME claim created."
- +6 DO DISPL^BPSNCPD4(WFLG,RESPONSE_U_CLMSTAT_"^D^2",$GET(BPSELIG))
- +7 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-"_CLMSTAT)
- End DoDot:1
- QUIT
- +8 SET RESPONSE=1
- +9 SET CLMSTAT="Claim has status "_OLDRESP_". Not reversed."
- +10 DO DISPL^BPSNCPD4(WFLG,RESPONSE_U_CLMSTAT_"^D^2",$GET(BPSELIG))
- +11 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-"_CLMSTAT)
- +12 QUIT
- +13 ;
- +14 ;== Resubmits AND Reversals+Resubmits for Non-Payable claims
- +15 ;== Also used for Resubmits without Reversals no matter the claim status (BPS*1*20)
- RVRSNPD ;
- +1 ; resubmit a claim
- +2 SET BPRETV=$$REVRESNP^BPSNCPD5(.BP77NEW,BRXIEN,BFILL,DOS,BWHERE,BILLNDC,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,BPCOBIND,BPJOBFLG,IEN59,BPACTTYP,DFN,.BPSTART,$GET(BPREQIEN),OLDRESP,.BPSELIG,$GET(BPSRTYPE),$GET(BPSPLAN),.BPSPRDAT)
- +3 SET RESPONSE=+BPRETV
- +4 ;to make LOG backward compatible
- +5 IF BWHERE'="ERWV"
- DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-After Submit of Reversal. Return Value: "_$SELECT(RESPONSE=0:1,1:0))
- +6 IF BWHERE="ERWV"
- DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-After Submit of Claim w/o Reversal. Return Value: "_$SELECT(RESPONSE=0:1,1:0))
- +7 SET CLMSTAT=$PIECE(BPRETV,U,2)
- +8 DO DISPL^BPSNCPD4(WFLG,BPRETV,$GET(BPSELIG))
- +9 IF RESPONSE=0
- QUIT
- +10 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-"_CLMSTAT)
- +11 QUIT
- +12 ;
- +13 ; if Back Billing
- BB ;
- +1 SET RESPONSE=1
- +2 SET CLMSTAT="Previously billed through ECME: "_OLDRESP
- +3 DO DISPL^BPSNCPD4(WFLG,RESPONSE_U_CLMSTAT_"^D^2",$GET(BPSELIG))
- +4 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-"_CLMSTAT)
- +5 QUIT
- +6 ;
- +7 ; if we do not have a status for pre-existing claim AND this is a reversal request - DO NOT reverse
- RVNEW ;
- +1 SET RESPONSE=1
- +2 SET CLMSTAT="Prescription not previously billed through ECME. Cannot Reverse claim."
- +3 DO DISPL^BPSNCPD4(WFLG,RESPONSE_U_CLMSTAT_"^D^2",$GET(BPSELIG))
- +4 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-"_CLMSTAT)
- +5 QUIT
- +6 ;
- +7 ; This was meant to called by BPSSCR04 to collect requests for the User Screen that don't have BPS TRANSACTION records
- +8 ; However, it is currently not called. This is still here in case, it is needed in the future. The call that should
- +9 ; be used is D LOOK77^BPSNCPD6(BPBDT,BPEDT,BPTMP1)
- LOOK77(BPBEGDT,BPENDDT,BPTMP) ;
- +1 NEW BPLDT77,BP77,BP59,BPRXRF
- +2 SET BPLDT77=BPBEGDT-0.00001
- +3 FOR
- SET BPLDT77=+$ORDER(^BPS(9002313.77,"E",BPLDT77))
- if BPLDT77=0!(BPLDT77>BPENDDT)
- QUIT
- Begin DoDot:1
- +4 SET BP77=0
- FOR
- SET BP77=$ORDER(^BPS(9002313.77,"E",BPLDT77,BP77))
- if +BP77=0
- QUIT
- Begin DoDot:2
- +5 SET BPRXRF=$PIECE($GET(^BPS(9002313.77,BP77,0)),U,1,2)
- +6 ;calculate BPS TRANSACTION ien (even if it doesn't exist yet)
- SET BP59=$$IEN59^BPSOSRX(+BPRXRF,$PIECE(BPRXRF,U,2))
- +7 ;don't create an entry if the claim is already there
- IF $DATA(@BPTMP@(BP59))
- QUIT
- +8 SET @BPTMP@(BP59)=(BPLDT77\1)_"^77-"
- End DoDot:2
- End DoDot:1
- +9 QUIT
- +10 ;