BPSNCPD5 ;ALB/SS - Pharmacy API part 5 ;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.
;
;schedule a reversal for the future
; BPNEWREQ - By ref to return new BPS REQUEST ien
; BRXIEN - IEN of Prescription file (#52)
; BFILL - Fill no
; DOS - Date of service
; BWHERE - See comments at the top of BPSNCPD3
; BILLNDC
; REVREAS
; DURREC
; BPOVRIEN
; BPSCLARF
; BPSAUTH
; IEN59
; BPCOBIND
; BPREVREQ - ien of the previous BPS REQUEST
; BPACTTYP - U - unclaim(reversal request), UC - reversal+resubmit, C - claim request
; BPSCLS - BPSCLOSE parameter of EN^BPSNCPDP
;returns:
; RESPONSE code^CLAMSTAT message^D(display message)^number of seconds to hang^IEN of the new request
; RESPONSE code = 0 - Submitted through ECME
; see EN^BPSNCPD4 for other RESPONSE values;
SCHREQ(BPNEWREQ,BRXIEN,BFILL,DOS,BWHERE,BILLNDC,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,IEN59,BPCOBIND,BPREVREQ,BPACTTYP,BPSCLS,BPSRTYPE,BPSPLAN,BPSPRDAT) ;
N RESP,RESPONSE,MOREDATA,BPRETV
N BPUSRMSG
;populate MOREDATA with basic data
D BASICMOR^BPSOSRX8(BWHERE,DOS,"",REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,.MOREDATA)
I BPCOBIND=2 D MORE4SEC^BPSPRRX2(.MOREDATA,.BPSPRDAT) S MOREDATA("RTYPE")=$G(BPSRTYPE)
; if the user has chosen to close the claim after reversal
; BPSCLS contains the value of the BPSCLOSE parameter of EN^BPSNCPDP
I $G(BPSCLS("CLOSE AFT REV"))=1 M MOREDATA=BPSCLS
;
; Needed for Turn-Around Stats - Do NOT delete/alter!!
D LOG^BPSOSL(IEN59,$T(+0)_"-Before Submit of Reversal")
S BPSTART=$$STTM^BPSNCPD4()
;schedule a request
S BPRETV=$$REQST^BPSOSRX(BPACTTYP,BRXIEN,BFILL,.MOREDATA,BPCOBIND,IEN59,$G(BILLNDC),1)
S BPNEWREQ=+$P(BPRETV,U,2)
;if error
I +BPRETV=0 D Q $$RSPCLMS^BPSOSRX8(BPACTTYP,4,.MOREDATA)
. D LOG^BPSOSL(IEN59,$T(+0)_"-Create request error: "_$P(BPRETV,U,2)_". Claim Will Not Be submitted.")
. L -^BPST
;if ok
D LOG^BPSOSL(IEN59,$T(+0)_"-BPS REQUEST: "_BPNEWREQ_" has been created")
;determine the last request
I +$$NXTREQST^BPSOSRX6(BPREVREQ,BPNEWREQ)=0 D Q $$RSPCLMS^BPSOSRX8("C",4,.MOREDATA)
. D LOG^BPSOSL(IEN59,$T(+0)_"-Cannot make "_BPNEWREQ_"as a NEXT REQUEST in "_BPREVREQ)
Q $$RSPCLMS^BPSOSRX8(BPACTTYP,0,.MOREDATA)_U_BPNEWREQ
;
;====== Schedule a reversal
;BPSCLS - BPSCLOSE parameter of EN^BPSNCPDP
REVERSAL(BPNEWREQ,BRXIEN,BFILL,OLDRESP,DOS,BWHERE,BILLNDC,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,IEN59,BPCOBIND,BPJOBFLG,BPACTTYP,BPSTART,BPREQIEN,BPSCLS,BPSRTYPE,BPSPRDAT) ;
N RESP,RESPONSE,MOREDATA,BPRETV
;populate MOREDATA with basic data
D BASICMOR^BPSOSRX8(BWHERE,DOS,"",REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,.MOREDATA)
I BPCOBIND=2 D MORE4SEC^BPSPRRX2(.MOREDATA,.BPSPRDAT) S MOREDATA("RTYPE")=$G(BPSRTYPE)
; if the user has chosen to close the claim after reversal
; BPSCLS contains the value of the BPSCLOSE parameter of EN^BPSNCPDP
I $G(BPSCLS("CLOSE AFT REV"))=1 M MOREDATA=BPSCLS
;
; Do a reversal for the appropriate actions
; If override flag is set, prompt for override values - TEST ONLY
;
I $$CHECK^BPSTEST D GETOVER^BPSTEST(BRXIEN,BFILL,OLDRESP,BWHERE,"R",BPCOBIND)
;
; Needed for Turn-Around Stats - Do NOT delete/alter!!
D LOG^BPSOSL(IEN59,$T(+0)_"-Before Submit of Reversal")
S BPSTART=$$STTM^BPSNCPD4()
;if background job
I BPJOBFLG="B" S BPRETV=$$ACTIVATE^BPSNCPD4(BPREQIEN,"U") Q $$RSPCLMS^BPSOSRX8(BPACTTYP,+BPRETV,.MOREDATA)_U_$P(BPRETV,U,2)
;if foreground job then schedule an UNCLAIM request
S BPRETV=$$REQST^BPSOSRX("U",BRXIEN,BFILL,.MOREDATA,BPCOBIND,IEN59,$G(BILLNDC))
S BPNEWREQ=+$P(BPRETV,U,2)
;if error
I +BPRETV=0 D Q $$RSPCLMS^BPSOSRX8(BPACTTYP,4,.MOREDATA)
. D LOG^BPSOSL(IEN59,$T(+0)_"-Create request error: "_$P(BPRETV,U,2)_". Claim Will Not Be submitted.")
. L -^BPST
;if ok
D LOG^BPSOSL(IEN59,$T(+0)_"-BPS REQUEST: "_BPNEWREQ_" has been created")
;activate the scheduled request
S BPRETV=$$ACTIVATE^BPSNCPD4(BPNEWREQ,"U")
Q $$RSPCLMS^BPSOSRX8(BPACTTYP,+BPRETV,.MOREDATA)_U_BPNEWREQ
;
;====== Process a brand new RX/RF, which never was processed by ECME yet
;returns:
; 0 - Submitted through ECME
; or
; RESPONSE code^CLAMSTAT^D(display message)^number of seconds to hang^additional info
; see EN^BPSNCPD1 for RESPONSE values
NEWCLM(BPNEWREQ,BRXIEN,BFILL,DOS,BWHERE,BILLNDC,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,BPCOBIND,BPJOBFLG,IEN59,BPACTTYP,DFN,BPSTART,BPREQIEN,BPSELIG,BPSRTYPE,BPSPLAN,BPSPRDAT) ;
N BPSITE,BPECMOFF,BPSARRY,MOREDATA,IB,BPRETV,BPZRET,BPCLMST,CERTIEN,BPRESP
I BPJOBFLG'="F",BPJOBFLG'="B" D LOG^BPSOSL(IEN59,$T(+0)_"-Job Flag missing") Q "5^Job Flag missing" ;RESPONSE^CLMSTAT
S BPCLMST=""
I BPACTTYP'="C" Q "1^Prescription not previously billed through ECME. Cannot Reverse claim.^D^2"
S BPSITE=+$$GETSITE^BPSOSRX8(BRXIEN,BFILL)
;check ECME availability
S BPECMOFF=$$ECMESITE^BPSOSRX5(BPSITE) I +BPECMOFF=1 Q BPECMOFF
;populate MOREDATA with basic data
D BASICMOR^BPSOSRX8(BWHERE,DOS,BPSITE,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,.MOREDATA)
I BPCOBIND=2 D MORE4SEC^BPSPRRX2(.MOREDATA,.BPSPRDAT) S MOREDATA("RTYPE")=$G(BPSRTYPE)
I $G(BPSRTYPE)'="" S MOREDATA("RTYPE")=$G(BPSRTYPE)
;Certification Testing - Sets CERTIEN which is used in BILLABLE
S BPRESP=$$CERTTEST^BPSNCPD4(.CERTIEN) I +BPRESP=1 Q BPRESP
;Populate BPSARRY
D STARRAY^BPSNCPD1(BRXIEN,BFILL,BWHERE,.BPSARRY,BPSITE,DOS,BILLNDC)
S BPSARRY("RXCOB")=BPCOBIND
S BPSARRY("PLAN")=$G(BPSPLAN),BPSARRY("RTYPE")=$G(BPSRTYPE) ;for secondary and TRICARE/dual eligibility billing, to be used by RX^IBNCPDP
;Billing determination
S IB=$$BILLABLE^BPSNCPD4(DFN,BWHERE,.MOREDATA,.BPSARRY,CERTIEN,.BPSELIG)
;if non-billable or no response from IB
I +IB'=1 Q $P(IB,U,2,5)_"^D^"
;check IB data
S BPRETV=$$IBDATAOK^BPSOSRX8(.MOREDATA,$G(BPSARRY("NO ECME INSURANCE"))) I BPRETV>0 Q BPRETV
; Needed for Turn-Around Stats - Do NOT delete/alter!!
D LOG^BPSOSL(IEN59,$T(+0)_"-Before submit of claim")
S BPSTART=$$STTM^BPSNCPD4()
;if background job
I BPJOBFLG="B",+$G(BPREQIEN)=0 D Q "5^BPS REQUEST IEN missing" ;should never happen
. D LOG^BPSOSL(IEN59,$T(+0)_"-BPS REQUEST IEN missing for background job. Claim cannot be processed.")
I BPJOBFLG="B" D Q $$RSPCLMS^BPSOSRX8(BPACTTYP,+BPRETV,.MOREDATA)_U_BPREQIEN
. ;Update IB data
. D UPDINSDT^BPSOSRX7(BPREQIEN,.MOREDATA,IEN59) ;
. S BPRETV=$$ACTIVATE^BPSNCPD4(BPREQIEN,"C")
;if foreground job then schedule a CLAIM request
;
; If override flag is set, prompt for override values - TEST ONLY
I $$CHECK^BPSTEST D GETOVER^BPSTEST(BRXIEN,BFILL,"",BWHERE,"S",BPCOBIND)
;
S BPRETV=$$REQST^BPSOSRX("C",BRXIEN,BFILL,.MOREDATA,BPCOBIND,IEN59,$G(BILLNDC))
S BPNEWREQ=+$P(BPRETV,U,2)
;if error
I +BPRETV=0 D Q $$RSPCLMS^BPSOSRX8(BPACTTYP,4,.MOREDATA,$P(BPRETV,U,2))
. D LOG^BPSOSL(IEN59,$T(+0)_"-Create request error: "_$P(BPRETV,U,2)_". Claim Will Not Be submitted.")
;if ok
D LOG^BPSOSL(IEN59,$T(+0)_"-BPS REQUEST: "_BPNEWREQ_" has been created")
;activate the scheduled request
S BPRETV=$$ACTIVATE^BPSNCPD4(BPNEWREQ,"C")
Q $$RSPCLMS^BPSOSRX8(BPACTTYP,+BPRETV,.MOREDATA)_U_BPNEWREQ
;
;Process RX/RF resubmit OR reversal+resubmit for non-payables
; also process RX/RF resubmit WITHOUT a Reversal no matter the payable status of the claim (bps*1*20)
;returns:
; 0 - Submitted through ECME
; or
; RESPONSE code^CLAMSTAT^D(display message)^number of seconds to hang^additional info
; see EN^BPSNCPDP for RESPONSE values
REVRESNP(BPNEWREQ,BRXIEN,BFILL,DOS,BWHERE,BILLNDC,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,BPCOBIND,BPJOBFLG,IEN59,BPACTTYP,DFN,BPSTART,BPREQIEN,OLDRESP,BPSELIG,BPSRTYPE,BPSPLAN,BPSPRDAT) ;
N BPSITE,BPECMOFF,BPSARRY,MOREDATA,IB,BPRETV,BPZRET,BPCLMST,CERTIEN,BPRESP
I BPJOBFLG'="F",BPJOBFLG'="B" D LOG^BPSOSL(IEN59,$T(+0)_"-Job Flag missing") Q "5^Job Flag missing" ;RESPONSE^CLMSTAT
S BPCLMST=""
I BPACTTYP="U" Q "1^Prescription is not payable. Cannot Reverse claim.^D^2"
S BPSITE=+$$GETSITE^BPSOSRX8(BRXIEN,BFILL)
;check ECME availability
S BPECMOFF=$$ECMESITE^BPSOSRX5(BPSITE) I +BPECMOFF=1 Q BPECMOFF
;
;populate MOREDATA with basic data
D BASICMOR^BPSOSRX8(BWHERE,DOS,BPSITE,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,.MOREDATA)
I BPCOBIND=2 D MORE4SEC^BPSPRRX2(.MOREDATA,.BPSPRDAT) S MOREDATA("RTYPE")=$G(BPSRTYPE)
I $G(BPSRTYPE)'="" S MOREDATA("RTYPE")=$G(BPSRTYPE)
;Certification Testing - Sets CERTIEN which is used in BILLABLE
S BPRESP=$$CERTTEST^BPSNCPD4(.CERTIEN) I +BPRESP=1 Q BPRESP
;Populate BPSARRY
D STARRAY^BPSNCPD1(BRXIEN,BFILL,BWHERE,.BPSARRY,BPSITE,DOS,BILLNDC)
S BPSARRY("RXCOB")=BPCOBIND
S BPSARRY("PLAN")=$G(BPSPLAN),BPSARRY("RTYPE")=$G(BPSRTYPE) ;for secondary and TRICARE/dual eligibility billing, to be used by RX^IBNCPDP
;set BPSARRY("SC/EI OVR") flag for scheduled requests
I $G(BPJOBFLG)="B",$G(BPREQIEN) S BPSARRY("SC/EI OVR")=$P($G(^BPS(9002313.77,+$G(BPREQIEN),2)),U,9)
;Billing determination
S IB=$$BILLABLE^BPSNCPD4(DFN,BWHERE,.MOREDATA,.BPSARRY,CERTIEN,.BPSELIG)
;if non-billable or no response from IB
I +IB'=1 Q $P(IB,U,2,5)_"^D^"
;check IB data
S BPRETV=$$IBDATAOK^BPSOSRX8(.MOREDATA,$G(BPSARRY("NO ECME INSURANCE"))) I BPRETV>0 Q BPRETV
; Needed for Turn-Around Stats - Do NOT delete/alter!!
D LOG^BPSOSL(IEN59,$T(+0)_"-Before submit of claim")
S BPSTART=$$STTM^BPSNCPD4()
;if background job
I BPJOBFLG="B" D Q $$RSPCLMS^BPSOSRX8(BPACTTYP,+BPRETV,.MOREDATA)_U_$P(BPRETV,U,2)
. ;Update IB data
. D UPDINSDT^BPSOSRX7(BPREQIEN,.MOREDATA,IEN59) ;
. S BPRETV=$$ACTIVATE^BPSNCPD4(BPREQIEN,"C")
;if foreground job then schedule a CLAIM request
;
; If override flag is set, prompt for override values - TEST ONLY
I $$CHECK^BPSTEST D GETOVER^BPSTEST(BRXIEN,BFILL,OLDRESP,BWHERE,"S",BPCOBIND)
;
S BPRETV=$$REQST^BPSOSRX("C",BRXIEN,BFILL,.MOREDATA,BPCOBIND,IEN59,$G(BILLNDC))
S BPNEWREQ=+$P(BPRETV,U,2)
;if error
I +BPRETV=0 D Q $$RSPCLMS^BPSOSRX8(BPACTTYP,4,.MOREDATA,$P(BPRETV,U,2))
. D LOG^BPSOSL(IEN59,$T(+0)_"-Create request error: "_$P(BPRETV,U,2)_". Claim Will Not Be submitted.")
;if ok
D LOG^BPSOSL(IEN59,$T(+0)_"-BPS REQUEST: "_BPNEWREQ_" has been created")
;activate the scheduled request
S BPRETV=$$ACTIVATE^BPSNCPD4(BPNEWREQ,"C")
Q $$RSPCLMS^BPSOSRX8(BPACTTYP,+BPRETV,.MOREDATA)_U_BPNEWREQ
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HBPSNCPD5 10477 printed Dec 13, 2024@01:51:17 Page 2
BPSNCPD5 ;ALB/SS - Pharmacy API part 5 ;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 ;schedule a reversal for the future
+5 ; BPNEWREQ - By ref to return new BPS REQUEST ien
+6 ; BRXIEN - IEN of Prescription file (#52)
+7 ; BFILL - Fill no
+8 ; DOS - Date of service
+9 ; BWHERE - See comments at the top of BPSNCPD3
+10 ; BILLNDC
+11 ; REVREAS
+12 ; DURREC
+13 ; BPOVRIEN
+14 ; BPSCLARF
+15 ; BPSAUTH
+16 ; IEN59
+17 ; BPCOBIND
+18 ; BPREVREQ - ien of the previous BPS REQUEST
+19 ; BPACTTYP - U - unclaim(reversal request), UC - reversal+resubmit, C - claim request
+20 ; BPSCLS - BPSCLOSE parameter of EN^BPSNCPDP
+21 ;returns:
+22 ; RESPONSE code^CLAMSTAT message^D(display message)^number of seconds to hang^IEN of the new request
+23 ; RESPONSE code = 0 - Submitted through ECME
+24 ; see EN^BPSNCPD4 for other RESPONSE values;
SCHREQ(BPNEWREQ,BRXIEN,BFILL,DOS,BWHERE,BILLNDC,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,IEN59,BPCOBIND,BPREVREQ,BPACTTYP,BPSCLS,BPSRTYPE,BPSPLAN,BPSPRDAT) ;
+1 NEW RESP,RESPONSE,MOREDATA,BPRETV
+2 NEW BPUSRMSG
+3 ;populate MOREDATA with basic data
+4 DO BASICMOR^BPSOSRX8(BWHERE,DOS,"",REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,.MOREDATA)
+5 IF BPCOBIND=2
DO MORE4SEC^BPSPRRX2(.MOREDATA,.BPSPRDAT)
SET MOREDATA("RTYPE")=$GET(BPSRTYPE)
+6 ; if the user has chosen to close the claim after reversal
+7 ; BPSCLS contains the value of the BPSCLOSE parameter of EN^BPSNCPDP
+8 IF $GET(BPSCLS("CLOSE AFT REV"))=1
MERGE MOREDATA=BPSCLS
+9 ;
+10 ; Needed for Turn-Around Stats - Do NOT delete/alter!!
+11 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-Before Submit of Reversal")
+12 SET BPSTART=$$STTM^BPSNCPD4()
+13 ;schedule a request
+14 SET BPRETV=$$REQST^BPSOSRX(BPACTTYP,BRXIEN,BFILL,.MOREDATA,BPCOBIND,IEN59,$GET(BILLNDC),1)
+15 SET BPNEWREQ=+$PIECE(BPRETV,U,2)
+16 ;if error
+17 IF +BPRETV=0
Begin DoDot:1
+18 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-Create request error: "_$PIECE(BPRETV,U,2)_". Claim Will Not Be submitted.")
+19 LOCK -^BPST
End DoDot:1
QUIT $$RSPCLMS^BPSOSRX8(BPACTTYP,4,.MOREDATA)
+20 ;if ok
+21 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-BPS REQUEST: "_BPNEWREQ_" has been created")
+22 ;determine the last request
+23 IF +$$NXTREQST^BPSOSRX6(BPREVREQ,BPNEWREQ)=0
Begin DoDot:1
+24 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-Cannot make "_BPNEWREQ_"as a NEXT REQUEST in "_BPREVREQ)
End DoDot:1
QUIT $$RSPCLMS^BPSOSRX8("C",4,.MOREDATA)
+25 QUIT $$RSPCLMS^BPSOSRX8(BPACTTYP,0,.MOREDATA)_U_BPNEWREQ
+26 ;
+27 ;====== Schedule a reversal
+28 ;BPSCLS - BPSCLOSE parameter of EN^BPSNCPDP
REVERSAL(BPNEWREQ,BRXIEN,BFILL,OLDRESP,DOS,BWHERE,BILLNDC,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,IEN59,BPCOBIND,BPJOBFLG,BPACTTYP,BPSTART,BPREQIEN,BPSCLS,BPSRTYPE,BPSPRDAT) ;
+1 NEW RESP,RESPONSE,MOREDATA,BPRETV
+2 ;populate MOREDATA with basic data
+3 DO BASICMOR^BPSOSRX8(BWHERE,DOS,"",REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,.MOREDATA)
+4 IF BPCOBIND=2
DO MORE4SEC^BPSPRRX2(.MOREDATA,.BPSPRDAT)
SET MOREDATA("RTYPE")=$GET(BPSRTYPE)
+5 ; if the user has chosen to close the claim after reversal
+6 ; BPSCLS contains the value of the BPSCLOSE parameter of EN^BPSNCPDP
+7 IF $GET(BPSCLS("CLOSE AFT REV"))=1
MERGE MOREDATA=BPSCLS
+8 ;
+9 ; Do a reversal for the appropriate actions
+10 ; If override flag is set, prompt for override values - TEST ONLY
+11 ;
+12 IF $$CHECK^BPSTEST
DO GETOVER^BPSTEST(BRXIEN,BFILL,OLDRESP,BWHERE,"R",BPCOBIND)
+13 ;
+14 ; Needed for Turn-Around Stats - Do NOT delete/alter!!
+15 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-Before Submit of Reversal")
+16 SET BPSTART=$$STTM^BPSNCPD4()
+17 ;if background job
+18 IF BPJOBFLG="B"
SET BPRETV=$$ACTIVATE^BPSNCPD4(BPREQIEN,"U")
QUIT $$RSPCLMS^BPSOSRX8(BPACTTYP,+BPRETV,.MOREDATA)_U_$PIECE(BPRETV,U,2)
+19 ;if foreground job then schedule an UNCLAIM request
+20 SET BPRETV=$$REQST^BPSOSRX("U",BRXIEN,BFILL,.MOREDATA,BPCOBIND,IEN59,$GET(BILLNDC))
+21 SET BPNEWREQ=+$PIECE(BPRETV,U,2)
+22 ;if error
+23 IF +BPRETV=0
Begin DoDot:1
+24 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-Create request error: "_$PIECE(BPRETV,U,2)_". Claim Will Not Be submitted.")
+25 LOCK -^BPST
End DoDot:1
QUIT $$RSPCLMS^BPSOSRX8(BPACTTYP,4,.MOREDATA)
+26 ;if ok
+27 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-BPS REQUEST: "_BPNEWREQ_" has been created")
+28 ;activate the scheduled request
+29 SET BPRETV=$$ACTIVATE^BPSNCPD4(BPNEWREQ,"U")
+30 QUIT $$RSPCLMS^BPSOSRX8(BPACTTYP,+BPRETV,.MOREDATA)_U_BPNEWREQ
+31 ;
+32 ;====== Process a brand new RX/RF, which never was processed by ECME yet
+33 ;returns:
+34 ; 0 - Submitted through ECME
+35 ; or
+36 ; RESPONSE code^CLAMSTAT^D(display message)^number of seconds to hang^additional info
+37 ; see EN^BPSNCPD1 for RESPONSE values
NEWCLM(BPNEWREQ,BRXIEN,BFILL,DOS,BWHERE,BILLNDC,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,BPCOBIND,BPJOBFLG,IEN59,BPACTTYP,DFN,BPSTART,BPREQIEN,BPSELIG,BPSRTYPE,BPSPLAN,BPSPRDAT) ;
+1 NEW BPSITE,BPECMOFF,BPSARRY,MOREDATA,IB,BPRETV,BPZRET,BPCLMST,CERTIEN,BPRESP
+2 ;RESPONSE^CLMSTAT
IF BPJOBFLG'="F"
IF BPJOBFLG'="B"
DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-Job Flag missing")
QUIT "5^Job Flag missing"
+3 SET BPCLMST=""
+4 IF BPACTTYP'="C"
QUIT "1^Prescription not previously billed through ECME. Cannot Reverse claim.^D^2"
+5 SET BPSITE=+$$GETSITE^BPSOSRX8(BRXIEN,BFILL)
+6 ;check ECME availability
+7 SET BPECMOFF=$$ECMESITE^BPSOSRX5(BPSITE)
IF +BPECMOFF=1
QUIT BPECMOFF
+8 ;populate MOREDATA with basic data
+9 DO BASICMOR^BPSOSRX8(BWHERE,DOS,BPSITE,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,.MOREDATA)
+10 IF BPCOBIND=2
DO MORE4SEC^BPSPRRX2(.MOREDATA,.BPSPRDAT)
SET MOREDATA("RTYPE")=$GET(BPSRTYPE)
+11 IF $GET(BPSRTYPE)'=""
SET MOREDATA("RTYPE")=$GET(BPSRTYPE)
+12 ;Certification Testing - Sets CERTIEN which is used in BILLABLE
+13 SET BPRESP=$$CERTTEST^BPSNCPD4(.CERTIEN)
IF +BPRESP=1
QUIT BPRESP
+14 ;Populate BPSARRY
+15 DO STARRAY^BPSNCPD1(BRXIEN,BFILL,BWHERE,.BPSARRY,BPSITE,DOS,BILLNDC)
+16 SET BPSARRY("RXCOB")=BPCOBIND
+17 ;for secondary and TRICARE/dual eligibility billing, to be used by RX^IBNCPDP
SET BPSARRY("PLAN")=$GET(BPSPLAN)
SET BPSARRY("RTYPE")=$GET(BPSRTYPE)
+18 ;Billing determination
+19 SET IB=$$BILLABLE^BPSNCPD4(DFN,BWHERE,.MOREDATA,.BPSARRY,CERTIEN,.BPSELIG)
+20 ;if non-billable or no response from IB
+21 IF +IB'=1
QUIT $PIECE(IB,U,2,5)_"^D^"
+22 ;check IB data
+23 SET BPRETV=$$IBDATAOK^BPSOSRX8(.MOREDATA,$GET(BPSARRY("NO ECME INSURANCE")))
IF BPRETV>0
QUIT BPRETV
+24 ; Needed for Turn-Around Stats - Do NOT delete/alter!!
+25 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-Before submit of claim")
+26 SET BPSTART=$$STTM^BPSNCPD4()
+27 ;if background job
+28 ;should never happen
IF BPJOBFLG="B"
IF +$GET(BPREQIEN)=0
Begin DoDot:1
+29 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-BPS REQUEST IEN missing for background job. Claim cannot be processed.")
End DoDot:1
QUIT "5^BPS REQUEST IEN missing"
+30 IF BPJOBFLG="B"
Begin DoDot:1
+31 ;Update IB data
+32 ;
DO UPDINSDT^BPSOSRX7(BPREQIEN,.MOREDATA,IEN59)
+33 SET BPRETV=$$ACTIVATE^BPSNCPD4(BPREQIEN,"C")
End DoDot:1
QUIT $$RSPCLMS^BPSOSRX8(BPACTTYP,+BPRETV,.MOREDATA)_U_BPREQIEN
+34 ;if foreground job then schedule a CLAIM request
+35 ;
+36 ; If override flag is set, prompt for override values - TEST ONLY
+37 IF $$CHECK^BPSTEST
DO GETOVER^BPSTEST(BRXIEN,BFILL,"",BWHERE,"S",BPCOBIND)
+38 ;
+39 SET BPRETV=$$REQST^BPSOSRX("C",BRXIEN,BFILL,.MOREDATA,BPCOBIND,IEN59,$GET(BILLNDC))
+40 SET BPNEWREQ=+$PIECE(BPRETV,U,2)
+41 ;if error
+42 IF +BPRETV=0
Begin DoDot:1
+43 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-Create request error: "_$PIECE(BPRETV,U,2)_". Claim Will Not Be submitted.")
End DoDot:1
QUIT $$RSPCLMS^BPSOSRX8(BPACTTYP,4,.MOREDATA,$PIECE(BPRETV,U,2))
+44 ;if ok
+45 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-BPS REQUEST: "_BPNEWREQ_" has been created")
+46 ;activate the scheduled request
+47 SET BPRETV=$$ACTIVATE^BPSNCPD4(BPNEWREQ,"C")
+48 QUIT $$RSPCLMS^BPSOSRX8(BPACTTYP,+BPRETV,.MOREDATA)_U_BPNEWREQ
+49 ;
+50 ;Process RX/RF resubmit OR reversal+resubmit for non-payables
+51 ; also process RX/RF resubmit WITHOUT a Reversal no matter the payable status of the claim (bps*1*20)
+52 ;returns:
+53 ; 0 - Submitted through ECME
+54 ; or
+55 ; RESPONSE code^CLAMSTAT^D(display message)^number of seconds to hang^additional info
+56 ; see EN^BPSNCPDP for RESPONSE values
REVRESNP(BPNEWREQ,BRXIEN,BFILL,DOS,BWHERE,BILLNDC,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,BPCOBIND,BPJOBFLG,IEN59,BPACTTYP,DFN,BPSTART,BPREQIEN,OLDRESP,BPSELIG,BPSRTYPE,BPSPLAN,BPSPRDAT) ;
+1 NEW BPSITE,BPECMOFF,BPSARRY,MOREDATA,IB,BPRETV,BPZRET,BPCLMST,CERTIEN,BPRESP
+2 ;RESPONSE^CLMSTAT
IF BPJOBFLG'="F"
IF BPJOBFLG'="B"
DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-Job Flag missing")
QUIT "5^Job Flag missing"
+3 SET BPCLMST=""
+4 IF BPACTTYP="U"
QUIT "1^Prescription is not payable. Cannot Reverse claim.^D^2"
+5 SET BPSITE=+$$GETSITE^BPSOSRX8(BRXIEN,BFILL)
+6 ;check ECME availability
+7 SET BPECMOFF=$$ECMESITE^BPSOSRX5(BPSITE)
IF +BPECMOFF=1
QUIT BPECMOFF
+8 ;
+9 ;populate MOREDATA with basic data
+10 DO BASICMOR^BPSOSRX8(BWHERE,DOS,BPSITE,REVREAS,DURREC,BPOVRIEN,BPSCLARF,BPSAUTH,BPSDELAY,.MOREDATA)
+11 IF BPCOBIND=2
DO MORE4SEC^BPSPRRX2(.MOREDATA,.BPSPRDAT)
SET MOREDATA("RTYPE")=$GET(BPSRTYPE)
+12 IF $GET(BPSRTYPE)'=""
SET MOREDATA("RTYPE")=$GET(BPSRTYPE)
+13 ;Certification Testing - Sets CERTIEN which is used in BILLABLE
+14 SET BPRESP=$$CERTTEST^BPSNCPD4(.CERTIEN)
IF +BPRESP=1
QUIT BPRESP
+15 ;Populate BPSARRY
+16 DO STARRAY^BPSNCPD1(BRXIEN,BFILL,BWHERE,.BPSARRY,BPSITE,DOS,BILLNDC)
+17 SET BPSARRY("RXCOB")=BPCOBIND
+18 ;for secondary and TRICARE/dual eligibility billing, to be used by RX^IBNCPDP
SET BPSARRY("PLAN")=$GET(BPSPLAN)
SET BPSARRY("RTYPE")=$GET(BPSRTYPE)
+19 ;set BPSARRY("SC/EI OVR") flag for scheduled requests
+20 IF $GET(BPJOBFLG)="B"
IF $GET(BPREQIEN)
SET BPSARRY("SC/EI OVR")=$PIECE($GET(^BPS(9002313.77,+$GET(BPREQIEN),2)),U,9)
+21 ;Billing determination
+22 SET IB=$$BILLABLE^BPSNCPD4(DFN,BWHERE,.MOREDATA,.BPSARRY,CERTIEN,.BPSELIG)
+23 ;if non-billable or no response from IB
+24 IF +IB'=1
QUIT $PIECE(IB,U,2,5)_"^D^"
+25 ;check IB data
+26 SET BPRETV=$$IBDATAOK^BPSOSRX8(.MOREDATA,$GET(BPSARRY("NO ECME INSURANCE")))
IF BPRETV>0
QUIT BPRETV
+27 ; Needed for Turn-Around Stats - Do NOT delete/alter!!
+28 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-Before submit of claim")
+29 SET BPSTART=$$STTM^BPSNCPD4()
+30 ;if background job
+31 IF BPJOBFLG="B"
Begin DoDot:1
+32 ;Update IB data
+33 ;
DO UPDINSDT^BPSOSRX7(BPREQIEN,.MOREDATA,IEN59)
+34 SET BPRETV=$$ACTIVATE^BPSNCPD4(BPREQIEN,"C")
End DoDot:1
QUIT $$RSPCLMS^BPSOSRX8(BPACTTYP,+BPRETV,.MOREDATA)_U_$PIECE(BPRETV,U,2)
+35 ;if foreground job then schedule a CLAIM request
+36 ;
+37 ; If override flag is set, prompt for override values - TEST ONLY
+38 IF $$CHECK^BPSTEST
DO GETOVER^BPSTEST(BRXIEN,BFILL,OLDRESP,BWHERE,"S",BPCOBIND)
+39 ;
+40 SET BPRETV=$$REQST^BPSOSRX("C",BRXIEN,BFILL,.MOREDATA,BPCOBIND,IEN59,$GET(BILLNDC))
+41 SET BPNEWREQ=+$PIECE(BPRETV,U,2)
+42 ;if error
+43 IF +BPRETV=0
Begin DoDot:1
+44 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-Create request error: "_$PIECE(BPRETV,U,2)_". Claim Will Not Be submitted.")
End DoDot:1
QUIT $$RSPCLMS^BPSOSRX8(BPACTTYP,4,.MOREDATA,$PIECE(BPRETV,U,2))
+45 ;if ok
+46 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-BPS REQUEST: "_BPNEWREQ_" has been created")
+47 ;activate the scheduled request
+48 SET BPRETV=$$ACTIVATE^BPSNCPD4(BPNEWREQ,"C")
+49 QUIT $$RSPCLMS^BPSOSRX8(BPACTTYP,+BPRETV,.MOREDATA)_U_BPNEWREQ
+50 ;