BPSOSIY ;BHAM ISC/FCS/DRS/DLF - Updating BPS Transaction record ;11/7/07 17:29
;;1.0;E CLAIMS MGMT ENGINE;**1,3,5,6,7,8,10,11,20,26,29,36**;JUN 2004;Build 16
;;Per VA Directive 6402, this routine should not be modified.
;
Q
;
; INIT - Update BPS Transaction
; Input
; IEN59 - BPS Transaction
; MOREDATA is not passed but assumed to exist
; BP77 - BPS REQUEST ien
; BPSNB - Flag indicating a Non-Billable Entry
; Returns
; ERROR - 0 or error number
INIT(IEN59,BP77,BPSNB) ;EP - from BPSOSIZ
N BPCOB,BPSTIME
S BPSNB=+$G(BPSNB)
;
; Update the BPS Request with the Transaction IEN
I $G(BP77)>0 D UPD7759^BPSOSRX4(BP77,IEN59)
;
; Initialize variables
N FDA,MSG,FN,IENS,REC,B1,X1,X2,X3,ERROR,SEQ,X4
N DIV,RXI,RXR
S FN=9002313.59,REC=IEN59_",",ERROR=0
;
; Change status to 0% (Waiting to Start), which will reset START TIME,
; and then to 10% (Building transaction)
D SETSTAT^BPSOSU(IEN59,0)
D SETSTAT^BPSOSU(IEN59,10)
;
; Get the Outpatient Site
S DIV=MOREDATA("DIVISION")
I 'DIV,MOREDATA("REQ TYPE")="C" S RXI=$P(IEN59,".",1),RXR=+$E($P(IEN59,".",2),1,4),DIV=$$GETDIV^BPSOSQC(RXI,RXR)
;
; If there are Prior Auth or Sub Clar Code override, create override
; record. Note that setting of MOREDATA("BPOVRIEN") in this routine
; will not conflict with prior setting of this value of BPOVRIEN
; since BPOVRIEN and BPSAUTH/BPSCLARF are mutually exclusive
I $G(MOREDATA("BPSAUTH"))]""!($G(MOREDATA("BPSCLARF"))]"")!($G(MOREDATA("BPSDELAY"))]"") S MOREDATA("BPOVRIEN")=$$OVERRIDE(IEN59)
;
; Set BPSDATA into local variable
S B1=$G(MOREDATA("BPSDATA",1))
;
; Get first record from MOREDATA("IBDATA") as there are some
; non-multiple fields that need it
S X2="",SEQ=$O(MOREDATA("IBDATA",""))
I SEQ S X2=$G(MOREDATA("IBDATA",SEQ,2))
;
; Set non-multiple fields
S FDA(FN,REC,1.05)=$G(MOREDATA("POLICY")) ; Policy Number
S FDA(FN,REC,1.07)=$$GETPHARM^BPSUTIL(DIV) ;BPS Pharmacy
S FDA(FN,REC,1.08)=1 ;PINS piece
S FDA(FN,REC,1.11)=$G(MOREDATA("RX")) ;Prescription
I $P($G(^BPST(IEN59,1)),U,12)=1 S FDA(FN,REC,1.12)=2 ;Resubmit after reversal
S FDA(FN,REC,1.13)=$G(MOREDATA("BPOVRIEN")) ;NCPDP Overrides
S FDA(FN,REC,5)=$G(MOREDATA("PATIENT")) ;Patient
I '$P($G(^BPST(IEN59,1)),U,12) S FDA(FN,REC,6)=$G(MOREDATA("SUBMIT TIME")) ;Submit Date/Time
S FDA(FN,REC,9)=$P(B1,U,4) ;Fill
S FDA(FN,REC,10)=$P(B1,U,3) ;NDC
S FDA(FN,REC,11)=DIV ;Outpatient Site
S FDA(FN,REC,13)=$G(MOREDATA("USER")) ;User
S FDA(FN,REC,16)=$G(MOREDATA("REQ IEN")) ;Request IEN
S FDA(FN,REC,17)=$G(MOREDATA("REQ DTTM")) ;Request Date/Time
S FDA(FN,REC,18)=$G(MOREDATA("PAYER SEQUENCE")) ;COB Indicator
S FDA(FN,REC,19)=$G(MOREDATA("REQ TYPE")) ;Transaction Type
I BPSNB S FDA(FN,REC,301)=$G(MOREDATA("NON-BILLABLE REASON")) ;Non-Billable reason text from IB
I BPSNB S FDA(FN,REC,302)=$G(MOREDATA("NON-BILLABLE CLOSED")) ;Non-Billable closed flag
S FDA(FN,REC,501)=$P(B1,U,1) ;Drug/Billing Quantity
S FDA(FN,REC,502)=$P(B1,U,2) ;Unit Price
S FDA(FN,REC,504)=$P(X2,U,1) ;Dispense Fee
S FDA(FN,REC,505)=$P(X2,U,4) ;Total Price
S FDA(FN,REC,507)=$P(X2,U,5) ;Administrative Fee
S FDA(FN,REC,508)=$E($P(B1,U,7),1,2) ;Dispense Unit
S FDA(FN,REC,509)=$P(B1,U,8) ;Billing Quantity
S FDA(FN,REC,510)=$P(B1,U,9) ;Billing Unit
S FDA(FN,REC,901)=1 ;Current VA Insurer
S FDA(FN,REC,1201)=$G(MOREDATA("RX ACTION")) ;RX Action
;
; If the expiration date of the prescription is on or before
; the date of service, then attempt to use the date of
; service from the initial claim sent for this transaction.
;
S FDA(FN,REC,1202)=$G(MOREDATA("DATE OF SERVICE")) ;Date of Service
N EXPDATE
S EXPDATE=$$GET1^DIQ(52,MOREDATA("RX"),26,"I")
I EXPDATE'="",EXPDATE'>MOREDATA("DATE OF SERVICE") D
. ; Determine DOS from initial submission.
. N DOS,INITTRAN
. S INITTRAN=$O(^BPSTL("B",IEN59,""))
. I INITTRAN="" Q
. S DOS=$$GET1^DIQ(9002313.57,INITTRAN,1202,"I")
. I DOS'="" S FDA(FN,REC,1202)=DOS
. Q
;
S FDA(FN,REC,901.04)=$G(MOREDATA("ELIG")) ;Eligibility info returned from billing determination
;
; File secondary billing fields
I $$COB59^BPSUTIL2(IEN59)=2 D SECBIL59^BPSPRRX6(.MOREDATA,IEN59)
; File non-multiple fields - Record is already defined
D FILE^DIE("","FDA","MSG")
I $D(MSG) D Q ERROR
. S ERROR=12
. D LOG^BPSOSL(IEN59,$T(+0)_"-Non-multiple fields did not file")
. D LOG^BPSOSL(IEN59,"MSG Array:")
. D LOGARRAY^BPSOSL(IEN59,"MSG")
. D LOG^BPSOSL(IEN59,"FDA Array:")
. D LOGARRAY^BPSOSL(IEN59,"FDA")
;
; Build Multiple
S SEQ=""
F S SEQ=$O(MOREDATA("IBDATA",SEQ)) Q:SEQ="" D I ERROR Q
. I $G(MOREDATA("NON-BILLABLE REASON"))="NOT INSURED" Q
. K FDA,MSG,IENS
. S FN=9002313.59902,IENS="+1,"_REC,IENS(1)=SEQ
. S X1=$G(MOREDATA("IBDATA",SEQ,1)),X2=$G(MOREDATA("IBDATA",SEQ,2)),X3=$G(MOREDATA("IBDATA",SEQ,3)),X4=$G(MOREDATA("IBDATA",SEQ,4))
. ;
. ; Update fields
. S FDA(FN,IENS,.01)=$P(X1,U,1) ;Plan ID
. S FDA(FN,IENS,902.02)=$P(X1,U,16) ;B1 Payer Sheet (Billing Request)
. S FDA(FN,IENS,902.03)=$P(X1,U,2) ;BIN
. S FDA(FN,IENS,902.04)=$P(X1,U,3) ;PCN
. S FDA(FN,IENS,902.05)=$P(X1,U,5) ;Group ID
. S FDA(FN,IENS,902.06)=$P(X1,U,6) ;Cardholder ID
. S FDA(FN,IENS,902.07)=$P(X1,U,7) ;Patient Relationship Code
. S FDA(FN,IENS,902.08)=$P($P(X1,U,8)," ") ;Cardholder First Name
. S FDA(FN,IENS,902.09)=$P(X1,U,9) ;Cardholder Last Name
. S FDA(FN,IENS,902.1)=$P(X1,U,20) ;Person Code
. S FDA(FN,IENS,902.11)=$P(X1,U,10) ;Home Plan State
. S FDA(FN,IENS,902.12)=$P(X2,U,1) ;Dispense Fee
. S FDA(FN,IENS,902.13)=$P(X2,U,2) ;Basis of Cost Determination
. S FDA(FN,IENS,902.14)=$P(X2,U,7) ;Usual & Customary Charge
. S FDA(FN,IENS,902.15)=$P(X2,U,4) ;Gross Amt Due
. S FDA(FN,IENS,902.16)=$P(X2,U,5) ;Administrative Fee
. S FDA(FN,IENS,902.17)=$P(B1,U,4) ;Fill Number
. S FDA(FN,IENS,902.18)=$P(X1,U,13) ;Software/Vendor Cert ID
. S FDA(FN,IENS,902.19)=$P(X1,U,17) ;B2 Payer Sheet (Reversal)
. S FDA(FN,IENS,902.2)=$P(X2,U,6) ;Ingredient Cost
. S FDA(FN,IENS,902.21)=$P(X1,U,18) ;B3 Payer Sheet (Rebill)
. S FDA(FN,IENS,902.22)=$P(B1,U,5) ;Certify Mode
. S FDA(FN,IENS,902.23)=$P(B1,U,6) ;Certification IEN
. S FDA(FN,IENS,902.24)=$P(X1,U,14) ;Plan Name
. S FDA(FN,IENS,902.25)=$P(X3,U,1) ;Group Name
. S FDA(FN,IENS,902.26)=$P(X3,U,2) ;Insurance Co Phone #
. S FDA(FN,IENS,902.27)=$P(X3,U,3) ;Pharmacy Plan ID
. S FDA(FN,IENS,902.28)=$P(X3,U,4) ;Eligibility
. S FDA(FN,IENS,902.32)=$P(X3,U,6) ;COB Indicator
. S FDA(FN,IENS,902.33)=$P(X3,U,5) ;Insurance Co IEN
. S FDA(FN,IENS,902.34)=$P(X1,U,19) ;E1 Payer Sheet (Eligibility)
. S FDA(FN,IENS,902.35)=$P(X3,U,7) ;Policy Number
. S FDA(FN,IENS,902.36)=$P(X3,U,8) ;Max Transactions/Transmission
. ;the following fields are used only for secondary billing and for primary Tricare billing
. ;in both cases only entry = 1 in the multiple will be created EVEN if the sequence is 2 (for secondary)
. ;Note: actually only the entry = 1 is used for primary billing as well, others are never used
. I SEQ=1 D
. . S FDA(FN,IENS,902.29)=$G(MOREDATA("RTYPE")) ;Rate Type
. . S FDA(FN,IENS,902.3)=$G(MOREDATA("PRIMARY BILL")) ;Primary bill ien
. . S FDA(FN,IENS,902.31)=$G(MOREDATA("PRIOR PAYMENT")) ;Prior payment amount
. ;
. ; File the data
. D UPDATE^DIE("","FDA","IENS","MSG")
. I $D(MSG) D
.. S ERROR=13
.. D LOG^BPSOSL(IEN59,$T(+0)_"-Multiple fields did not file, SEQ="_SEQ)
.. D LOG^BPSOSL(IEN59,"MSG Array:")
.. D LOGARRAY^BPSOSL(IEN59,"MSG")
.. D LOG^BPSOSL(IEN59,"IENS Array:")
.. D LOGARRAY^BPSOSL(IEN59,"IENS")
.. D LOG^BPSOSL(IEN59,"FDA Array:")
.. D LOGARRAY^BPSOSL(IEN59,"FDA")
;
; Quit if there was an error filing the Insurance multiple
I ERROR Q ERROR
;
; Store DUR multiple if it exists
N DUR,DURREC
S FN=9002313.5913,DUR=0
F S DUR=$O(MOREDATA("DUR",DUR)) Q:DUR="" D I ERROR Q
. K FDA,MSG,IENS
. S DURREC=$G(MOREDATA("DUR",DUR,0))
. S IENS="+1,"_REC,IENS(1)=DUR
. S FDA(FN,IENS,.01)=DUR ; DUR Counter
. S FDA(FN,IENS,1)=$P(DURREC,U,2) ; DUR Professional Service Code
. S FDA(FN,IENS,2)=$P(DURREC,U,1) ; DUR Reason for Service Code
. S FDA(FN,IENS,3)=$P(DURREC,U,3) ; DUR Result of Service Code
. D UPDATE^DIE("","FDA","IENS","MSG")
. I $D(MSG) D
.. S ERROR=15
.. D LOG^BPSOSL(IEN59,$T(+0)_"-DUR fields did not file, DUR="_DUR)
.. D LOG^BPSOSL(IEN59,"DURREC="_DURREC)
.. D LOG^BPSOSL(IEN59,"MSG Array:")
.. D LOGARRAY^BPSOSL(IEN59,"MSG")
.. D LOG^BPSOSL(IEN59,"IENS Array:")
.. D LOGARRAY^BPSOSL(IEN59,"IENS")
.. D LOG^BPSOSL(IEN59,"FDA Array:")
.. D LOGARRAY^BPSOSL(IEN59,"FDA")
;
Q ERROR
;
; OVERRIDE - Function to create override record
OVERRIDE(IEN59) ;
;Save values into BPS NCPDP OVERRIDES (#9002313.511)
N BPSFDA,BPSFLD,BPOVRIEN,BPSMSG,BPSQ,BPSVALUE
;
; Set Name (.01) to transaction number
S BPSFDA(9002313.511,"+1,",.01)=IEN59
;
; Set Created On (.02) to current date/time
S BPSFDA(9002313.511,"+1,",.02)=$$NOW^BPSOSRX()
;
; Submission Clarification Code
I $G(MOREDATA("BPSCLARF"))]"" D
. S BPSFLD=$O(^BPSF(9002313.91,"B",420,""))
. I BPSFLD]"" S BPSFDA(9002313.5111,"+2,+1,",.01)=BPSFLD,BPSFDA(9002313.5111,"+2,+1,",.02)=$E(MOREDATA("BPSCLARF"),1,8)
;
; Prior Auth Fields (Code and Number)
I $G(MOREDATA("BPSAUTH"))]"" D
. S BPSFLD=$O(^BPSF(9002313.91,"B",461,""))
. I BPSFLD]"" S BPSFDA(9002313.5111,"+3,+1,",.01)=BPSFLD,BPSFDA(9002313.5111,"+3,+1,",.02)=$E($P(MOREDATA("BPSAUTH"),U,1),1,2)
. S BPSFLD=$O(^BPSF(9002313.91,"B",462,""))
. I BPSFLD]"" S BPSFDA(9002313.5111,"+4,+1,",.01)=BPSFLD,BPSFDA(9002313.5111,"+4,+1,",.02)=$E($P(MOREDATA("BPSAUTH"),U,2),1,11)
;
; Delay Reason Code - This is the IEN of the database
I $G(MOREDATA("BPSDELAY"))]"" D
. S BPSVALUE=$P($G(^BPS(9002313.29,MOREDATA("BPSDELAY"),0)),U,1)
. I BPSVALUE="" Q
. S BPSFLD=$O(^BPSF(9002313.91,"B",357,""))
. I BPSFLD]"" S BPSFDA(9002313.5111,"+5,+1,",.01)=BPSFLD,BPSFDA(9002313.5111,"+5,+1,",.02)=$E(MOREDATA("BPSDELAY"),1,2)
;
; Create the record
D UPDATE^DIE("","BPSFDA","BPOVRIEN","BPSMSG")
;
I $G(BPOVRIEN(1))]"" S BPSQ=BPOVRIEN(1)
E S BPSQ=""
Q BPSQ
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HBPSOSIY 10304 printed Oct 16, 2024@17:52:32 Page 2
BPSOSIY ;BHAM ISC/FCS/DRS/DLF - Updating BPS Transaction record ;11/7/07 17:29
+1 ;;1.0;E CLAIMS MGMT ENGINE;**1,3,5,6,7,8,10,11,20,26,29,36**;JUN 2004;Build 16
+2 ;;Per VA Directive 6402, this routine should not be modified.
+3 ;
+4 QUIT
+5 ;
+6 ; INIT - Update BPS Transaction
+7 ; Input
+8 ; IEN59 - BPS Transaction
+9 ; MOREDATA is not passed but assumed to exist
+10 ; BP77 - BPS REQUEST ien
+11 ; BPSNB - Flag indicating a Non-Billable Entry
+12 ; Returns
+13 ; ERROR - 0 or error number
INIT(IEN59,BP77,BPSNB) ;EP - from BPSOSIZ
+1 NEW BPCOB,BPSTIME
+2 SET BPSNB=+$GET(BPSNB)
+3 ;
+4 ; Update the BPS Request with the Transaction IEN
+5 IF $GET(BP77)>0
DO UPD7759^BPSOSRX4(BP77,IEN59)
+6 ;
+7 ; Initialize variables
+8 NEW FDA,MSG,FN,IENS,REC,B1,X1,X2,X3,ERROR,SEQ,X4
+9 NEW DIV,RXI,RXR
+10 SET FN=9002313.59
SET REC=IEN59_","
SET ERROR=0
+11 ;
+12 ; Change status to 0% (Waiting to Start), which will reset START TIME,
+13 ; and then to 10% (Building transaction)
+14 DO SETSTAT^BPSOSU(IEN59,0)
+15 DO SETSTAT^BPSOSU(IEN59,10)
+16 ;
+17 ; Get the Outpatient Site
+18 SET DIV=MOREDATA("DIVISION")
+19 IF 'DIV
IF MOREDATA("REQ TYPE")="C"
SET RXI=$PIECE(IEN59,".",1)
SET RXR=+$EXTRACT($PIECE(IEN59,".",2),1,4)
SET DIV=$$GETDIV^BPSOSQC(RXI,RXR)
+20 ;
+21 ; If there are Prior Auth or Sub Clar Code override, create override
+22 ; record. Note that setting of MOREDATA("BPOVRIEN") in this routine
+23 ; will not conflict with prior setting of this value of BPOVRIEN
+24 ; since BPOVRIEN and BPSAUTH/BPSCLARF are mutually exclusive
+25 IF $GET(MOREDATA("BPSAUTH"))]""!($GET(MOREDATA("BPSCLARF"))]"")!($GET(MOREDATA("BPSDELAY"))]"")
SET MOREDATA("BPOVRIEN")=$$OVERRIDE(IEN59)
+26 ;
+27 ; Set BPSDATA into local variable
+28 SET B1=$GET(MOREDATA("BPSDATA",1))
+29 ;
+30 ; Get first record from MOREDATA("IBDATA") as there are some
+31 ; non-multiple fields that need it
+32 SET X2=""
SET SEQ=$ORDER(MOREDATA("IBDATA",""))
+33 IF SEQ
SET X2=$GET(MOREDATA("IBDATA",SEQ,2))
+34 ;
+35 ; Set non-multiple fields
+36 ; Policy Number
SET FDA(FN,REC,1.05)=$GET(MOREDATA("POLICY"))
+37 ;BPS Pharmacy
SET FDA(FN,REC,1.07)=$$GETPHARM^BPSUTIL(DIV)
+38 ;PINS piece
SET FDA(FN,REC,1.08)=1
+39 ;Prescription
SET FDA(FN,REC,1.11)=$GET(MOREDATA("RX"))
+40 ;Resubmit after reversal
IF $PIECE($GET(^BPST(IEN59,1)),U,12)=1
SET FDA(FN,REC,1.12)=2
+41 ;NCPDP Overrides
SET FDA(FN,REC,1.13)=$GET(MOREDATA("BPOVRIEN"))
+42 ;Patient
SET FDA(FN,REC,5)=$GET(MOREDATA("PATIENT"))
+43 ;Submit Date/Time
IF '$PIECE($GET(^BPST(IEN59,1)),U,12)
SET FDA(FN,REC,6)=$GET(MOREDATA("SUBMIT TIME"))
+44 ;Fill
SET FDA(FN,REC,9)=$PIECE(B1,U,4)
+45 ;NDC
SET FDA(FN,REC,10)=$PIECE(B1,U,3)
+46 ;Outpatient Site
SET FDA(FN,REC,11)=DIV
+47 ;User
SET FDA(FN,REC,13)=$GET(MOREDATA("USER"))
+48 ;Request IEN
SET FDA(FN,REC,16)=$GET(MOREDATA("REQ IEN"))
+49 ;Request Date/Time
SET FDA(FN,REC,17)=$GET(MOREDATA("REQ DTTM"))
+50 ;COB Indicator
SET FDA(FN,REC,18)=$GET(MOREDATA("PAYER SEQUENCE"))
+51 ;Transaction Type
SET FDA(FN,REC,19)=$GET(MOREDATA("REQ TYPE"))
+52 ;Non-Billable reason text from IB
IF BPSNB
SET FDA(FN,REC,301)=$GET(MOREDATA("NON-BILLABLE REASON"))
+53 ;Non-Billable closed flag
IF BPSNB
SET FDA(FN,REC,302)=$GET(MOREDATA("NON-BILLABLE CLOSED"))
+54 ;Drug/Billing Quantity
SET FDA(FN,REC,501)=$PIECE(B1,U,1)
+55 ;Unit Price
SET FDA(FN,REC,502)=$PIECE(B1,U,2)
+56 ;Dispense Fee
SET FDA(FN,REC,504)=$PIECE(X2,U,1)
+57 ;Total Price
SET FDA(FN,REC,505)=$PIECE(X2,U,4)
+58 ;Administrative Fee
SET FDA(FN,REC,507)=$PIECE(X2,U,5)
+59 ;Dispense Unit
SET FDA(FN,REC,508)=$EXTRACT($PIECE(B1,U,7),1,2)
+60 ;Billing Quantity
SET FDA(FN,REC,509)=$PIECE(B1,U,8)
+61 ;Billing Unit
SET FDA(FN,REC,510)=$PIECE(B1,U,9)
+62 ;Current VA Insurer
SET FDA(FN,REC,901)=1
+63 ;RX Action
SET FDA(FN,REC,1201)=$GET(MOREDATA("RX ACTION"))
+64 ;
+65 ; If the expiration date of the prescription is on or before
+66 ; the date of service, then attempt to use the date of
+67 ; service from the initial claim sent for this transaction.
+68 ;
+69 ;Date of Service
SET FDA(FN,REC,1202)=$GET(MOREDATA("DATE OF SERVICE"))
+70 NEW EXPDATE
+71 SET EXPDATE=$$GET1^DIQ(52,MOREDATA("RX"),26,"I")
+72 IF EXPDATE'=""
IF EXPDATE'>MOREDATA("DATE OF SERVICE")
Begin DoDot:1
+73 ; Determine DOS from initial submission.
+74 NEW DOS,INITTRAN
+75 SET INITTRAN=$ORDER(^BPSTL("B",IEN59,""))
+76 IF INITTRAN=""
QUIT
+77 SET DOS=$$GET1^DIQ(9002313.57,INITTRAN,1202,"I")
+78 IF DOS'=""
SET FDA(FN,REC,1202)=DOS
+79 QUIT
End DoDot:1
+80 ;
+81 ;Eligibility info returned from billing determination
SET FDA(FN,REC,901.04)=$GET(MOREDATA("ELIG"))
+82 ;
+83 ; File secondary billing fields
+84 IF $$COB59^BPSUTIL2(IEN59)=2
DO SECBIL59^BPSPRRX6(.MOREDATA,IEN59)
+85 ; File non-multiple fields - Record is already defined
+86 DO FILE^DIE("","FDA","MSG")
+87 IF $DATA(MSG)
Begin DoDot:1
+88 SET ERROR=12
+89 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-Non-multiple fields did not file")
+90 DO LOG^BPSOSL(IEN59,"MSG Array:")
+91 DO LOGARRAY^BPSOSL(IEN59,"MSG")
+92 DO LOG^BPSOSL(IEN59,"FDA Array:")
+93 DO LOGARRAY^BPSOSL(IEN59,"FDA")
End DoDot:1
QUIT ERROR
+94 ;
+95 ; Build Multiple
+96 SET SEQ=""
+97 FOR
SET SEQ=$ORDER(MOREDATA("IBDATA",SEQ))
if SEQ=""
QUIT
Begin DoDot:1
+98 IF $GET(MOREDATA("NON-BILLABLE REASON"))="NOT INSURED"
QUIT
+99 KILL FDA,MSG,IENS
+100 SET FN=9002313.59902
SET IENS="+1,"_REC
SET IENS(1)=SEQ
+101 SET X1=$GET(MOREDATA("IBDATA",SEQ,1))
SET X2=$GET(MOREDATA("IBDATA",SEQ,2))
SET X3=$GET(MOREDATA("IBDATA",SEQ,3))
SET X4=$GET(MOREDATA("IBDATA",SEQ,4))
+102 ;
+103 ; Update fields
+104 ;Plan ID
SET FDA(FN,IENS,.01)=$PIECE(X1,U,1)
+105 ;B1 Payer Sheet (Billing Request)
SET FDA(FN,IENS,902.02)=$PIECE(X1,U,16)
+106 ;BIN
SET FDA(FN,IENS,902.03)=$PIECE(X1,U,2)
+107 ;PCN
SET FDA(FN,IENS,902.04)=$PIECE(X1,U,3)
+108 ;Group ID
SET FDA(FN,IENS,902.05)=$PIECE(X1,U,5)
+109 ;Cardholder ID
SET FDA(FN,IENS,902.06)=$PIECE(X1,U,6)
+110 ;Patient Relationship Code
SET FDA(FN,IENS,902.07)=$PIECE(X1,U,7)
+111 ;Cardholder First Name
SET FDA(FN,IENS,902.08)=$PIECE($PIECE(X1,U,8)," ")
+112 ;Cardholder Last Name
SET FDA(FN,IENS,902.09)=$PIECE(X1,U,9)
+113 ;Person Code
SET FDA(FN,IENS,902.1)=$PIECE(X1,U,20)
+114 ;Home Plan State
SET FDA(FN,IENS,902.11)=$PIECE(X1,U,10)
+115 ;Dispense Fee
SET FDA(FN,IENS,902.12)=$PIECE(X2,U,1)
+116 ;Basis of Cost Determination
SET FDA(FN,IENS,902.13)=$PIECE(X2,U,2)
+117 ;Usual & Customary Charge
SET FDA(FN,IENS,902.14)=$PIECE(X2,U,7)
+118 ;Gross Amt Due
SET FDA(FN,IENS,902.15)=$PIECE(X2,U,4)
+119 ;Administrative Fee
SET FDA(FN,IENS,902.16)=$PIECE(X2,U,5)
+120 ;Fill Number
SET FDA(FN,IENS,902.17)=$PIECE(B1,U,4)
+121 ;Software/Vendor Cert ID
SET FDA(FN,IENS,902.18)=$PIECE(X1,U,13)
+122 ;B2 Payer Sheet (Reversal)
SET FDA(FN,IENS,902.19)=$PIECE(X1,U,17)
+123 ;Ingredient Cost
SET FDA(FN,IENS,902.2)=$PIECE(X2,U,6)
+124 ;B3 Payer Sheet (Rebill)
SET FDA(FN,IENS,902.21)=$PIECE(X1,U,18)
+125 ;Certify Mode
SET FDA(FN,IENS,902.22)=$PIECE(B1,U,5)
+126 ;Certification IEN
SET FDA(FN,IENS,902.23)=$PIECE(B1,U,6)
+127 ;Plan Name
SET FDA(FN,IENS,902.24)=$PIECE(X1,U,14)
+128 ;Group Name
SET FDA(FN,IENS,902.25)=$PIECE(X3,U,1)
+129 ;Insurance Co Phone #
SET FDA(FN,IENS,902.26)=$PIECE(X3,U,2)
+130 ;Pharmacy Plan ID
SET FDA(FN,IENS,902.27)=$PIECE(X3,U,3)
+131 ;Eligibility
SET FDA(FN,IENS,902.28)=$PIECE(X3,U,4)
+132 ;COB Indicator
SET FDA(FN,IENS,902.32)=$PIECE(X3,U,6)
+133 ;Insurance Co IEN
SET FDA(FN,IENS,902.33)=$PIECE(X3,U,5)
+134 ;E1 Payer Sheet (Eligibility)
SET FDA(FN,IENS,902.34)=$PIECE(X1,U,19)
+135 ;Policy Number
SET FDA(FN,IENS,902.35)=$PIECE(X3,U,7)
+136 ;Max Transactions/Transmission
SET FDA(FN,IENS,902.36)=$PIECE(X3,U,8)
+137 ;the following fields are used only for secondary billing and for primary Tricare billing
+138 ;in both cases only entry = 1 in the multiple will be created EVEN if the sequence is 2 (for secondary)
+139 ;Note: actually only the entry = 1 is used for primary billing as well, others are never used
+140 IF SEQ=1
Begin DoDot:2
+141 ;Rate Type
SET FDA(FN,IENS,902.29)=$GET(MOREDATA("RTYPE"))
+142 ;Primary bill ien
SET FDA(FN,IENS,902.3)=$GET(MOREDATA("PRIMARY BILL"))
+143 ;Prior payment amount
SET FDA(FN,IENS,902.31)=$GET(MOREDATA("PRIOR PAYMENT"))
End DoDot:2
+144 ;
+145 ; File the data
+146 DO UPDATE^DIE("","FDA","IENS","MSG")
+147 IF $DATA(MSG)
Begin DoDot:2
+148 SET ERROR=13
+149 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-Multiple fields did not file, SEQ="_SEQ)
+150 DO LOG^BPSOSL(IEN59,"MSG Array:")
+151 DO LOGARRAY^BPSOSL(IEN59,"MSG")
+152 DO LOG^BPSOSL(IEN59,"IENS Array:")
+153 DO LOGARRAY^BPSOSL(IEN59,"IENS")
+154 DO LOG^BPSOSL(IEN59,"FDA Array:")
+155 DO LOGARRAY^BPSOSL(IEN59,"FDA")
End DoDot:2
End DoDot:1
IF ERROR
QUIT
+156 ;
+157 ; Quit if there was an error filing the Insurance multiple
+158 IF ERROR
QUIT ERROR
+159 ;
+160 ; Store DUR multiple if it exists
+161 NEW DUR,DURREC
+162 SET FN=9002313.5913
SET DUR=0
+163 FOR
SET DUR=$ORDER(MOREDATA("DUR",DUR))
if DUR=""
QUIT
Begin DoDot:1
+164 KILL FDA,MSG,IENS
+165 SET DURREC=$GET(MOREDATA("DUR",DUR,0))
+166 SET IENS="+1,"_REC
SET IENS(1)=DUR
+167 ; DUR Counter
SET FDA(FN,IENS,.01)=DUR
+168 ; DUR Professional Service Code
SET FDA(FN,IENS,1)=$PIECE(DURREC,U,2)
+169 ; DUR Reason for Service Code
SET FDA(FN,IENS,2)=$PIECE(DURREC,U,1)
+170 ; DUR Result of Service Code
SET FDA(FN,IENS,3)=$PIECE(DURREC,U,3)
+171 DO UPDATE^DIE("","FDA","IENS","MSG")
+172 IF $DATA(MSG)
Begin DoDot:2
+173 SET ERROR=15
+174 DO LOG^BPSOSL(IEN59,$TEXT(+0)_"-DUR fields did not file, DUR="_DUR)
+175 DO LOG^BPSOSL(IEN59,"DURREC="_DURREC)
+176 DO LOG^BPSOSL(IEN59,"MSG Array:")
+177 DO LOGARRAY^BPSOSL(IEN59,"MSG")
+178 DO LOG^BPSOSL(IEN59,"IENS Array:")
+179 DO LOGARRAY^BPSOSL(IEN59,"IENS")
+180 DO LOG^BPSOSL(IEN59,"FDA Array:")
+181 DO LOGARRAY^BPSOSL(IEN59,"FDA")
End DoDot:2
End DoDot:1
IF ERROR
QUIT
+182 ;
+183 QUIT ERROR
+184 ;
+185 ; OVERRIDE - Function to create override record
OVERRIDE(IEN59) ;
+1 ;Save values into BPS NCPDP OVERRIDES (#9002313.511)
+2 NEW BPSFDA,BPSFLD,BPOVRIEN,BPSMSG,BPSQ,BPSVALUE
+3 ;
+4 ; Set Name (.01) to transaction number
+5 SET BPSFDA(9002313.511,"+1,",.01)=IEN59
+6 ;
+7 ; Set Created On (.02) to current date/time
+8 SET BPSFDA(9002313.511,"+1,",.02)=$$NOW^BPSOSRX()
+9 ;
+10 ; Submission Clarification Code
+11 IF $GET(MOREDATA("BPSCLARF"))]""
Begin DoDot:1
+12 SET BPSFLD=$ORDER(^BPSF(9002313.91,"B",420,""))
+13 IF BPSFLD]""
SET BPSFDA(9002313.5111,"+2,+1,",.01)=BPSFLD
SET BPSFDA(9002313.5111,"+2,+1,",.02)=$EXTRACT(MOREDATA("BPSCLARF"),1,8)
End DoDot:1
+14 ;
+15 ; Prior Auth Fields (Code and Number)
+16 IF $GET(MOREDATA("BPSAUTH"))]""
Begin DoDot:1
+17 SET BPSFLD=$ORDER(^BPSF(9002313.91,"B",461,""))
+18 IF BPSFLD]""
SET BPSFDA(9002313.5111,"+3,+1,",.01)=BPSFLD
SET BPSFDA(9002313.5111,"+3,+1,",.02)=$EXTRACT($PIECE(MOREDATA("BPSAUTH"),U,1),1,2)
+19 SET BPSFLD=$ORDER(^BPSF(9002313.91,"B",462,""))
+20 IF BPSFLD]""
SET BPSFDA(9002313.5111,"+4,+1,",.01)=BPSFLD
SET BPSFDA(9002313.5111,"+4,+1,",.02)=$EXTRACT($PIECE(MOREDATA("BPSAUTH"),U,2),1,11)
End DoDot:1
+21 ;
+22 ; Delay Reason Code - This is the IEN of the database
+23 IF $GET(MOREDATA("BPSDELAY"))]""
Begin DoDot:1
+24 SET BPSVALUE=$PIECE($GET(^BPS(9002313.29,MOREDATA("BPSDELAY"),0)),U,1)
+25 IF BPSVALUE=""
QUIT
+26 SET BPSFLD=$ORDER(^BPSF(9002313.91,"B",357,""))
+27 IF BPSFLD]""
SET BPSFDA(9002313.5111,"+5,+1,",.01)=BPSFLD
SET BPSFDA(9002313.5111,"+5,+1,",.02)=$EXTRACT(MOREDATA("BPSDELAY"),1,2)
End DoDot:1
+28 ;
+29 ; Create the record
+30 DO UPDATE^DIE("","BPSFDA","BPOVRIEN","BPSMSG")
+31 ;
+32 IF $GET(BPOVRIEN(1))]""
SET BPSQ=BPOVRIEN(1)
+33 IF '$TEST
SET BPSQ=""
+34 QUIT BPSQ