FBFHLD3 ;OIFO/SAB-GET DATA FOR OUT/ANC INVOICE ;9/9/2003
;;3.5;FEE BASIS;**61,122**;JUNE 6, 2011;Build 8
;;Per VHA Directive 10-93-142, this routine should not be modified.
Q
;
EN ;
; input
; FBAAIN - invoice number
; output
; If transaction type = "X" then only * items are output
; Claim Level Data
; FBD(0,"AMT") = Amount Disbursed^Amount Interest
; *FBD(0,"CAN") = Cancel Date^Cancel Reason^Cancel Activity
; FBD(0,"DT") = Invoice Date
; *FBD(0,"FPPS") = FPPS Claim ID
; *FBD(0,"INV") = Invoice #^Transaction Type^Station #
;
; Line Level Data (# is a sequential number)
; FBD(#,"ADJ") = AdjReason1^AdjGrp1^AdjAmt1^AdjReason2^AdjGrp2^AdjAmt2
; FBD(#,"AMT") = Amount Claimed^Amount Paid
; FBD(#,"CK") = Check Number^Check Date^Payment Method
; FBD(#,"835") = Routing Number^Financial Institution^^Account Number ; FB*3.5*122
; FBD(#,"DT") = Date of Service
; FBD(#,"FPPS") = FPPS Line Item
; FBD(#,"RMK") = Remittance Remark1,Remittance Remark2
; FBD(#,"SVC") = Service Code^Qualifier^Mod1,Mod2,Mod3,Mod4^Units
;
; If exceptions for invoice
; ^TMP($J,"FBE",FBAAIN,seq number)=message
; If warnings for invoice
; ^TMP($J,"FBW",FBAAIN,seq number)=message
;
; initialize variables
N DA,FBC,FBI,FBIENS,FBSTA,FBTTYP,FBY
K FBD
S FBC=0 ; line count
;
; loop thru lines on invoice
S DA(3)=0
F S DA(3)=$O(^FBAAC("C",FBAAIN,DA(3))) Q:'DA(3) D
.S DA(2)=0
.F S DA(2)=$O(^FBAAC("C",FBAAIN,DA(3),DA(2))) Q:'DA(2) D
..S DA(1)=0
..F S DA(1)=$O(^FBAAC("C",FBAAIN,DA(3),DA(2),DA(1))) Q:'DA(1) D
...S DA=0
...F S DA=$O(^FBAAC("C",FBAAIN,DA(3),DA(2),DA(1),DA)) Q:'DA D
....S FBIENS=DA_","_DA(1)_","_DA(2)_","_DA(3)_","
....F FBI=0,2,3,"FBREJ" S FBY(FBI)=$G(^FBAAC(DA(3),1,DA(2),1,DA(1),1,DA,FBI))
....Q:'$$CKLNST() ; skip line if status not OK to transmit
....S FBC=FBC+1
....; if 1st line then get invoice level data
....I FBC=1 D INVOICE
....I FBTTYP="L" D LINE
Q
;
INVOICE ; determine invoice data from 1st line item
; FBD(0,"AMT") = Amount Disbursed^Amount Interest
; FBD(0,"CAN") = Cancel Date^Cancel Reason^Cancel Activity
; FBD(0,"DT") = Invoice Date
; FBD(0,"FPPS") = FPPS Claim ID
; FBD(0,"INV") = Invoice #^Transaction Type^Station #
; FBSTA = station number
; FBTTYP = transaction type (L or X)
;
N FBDT,FBOB,FBX
; determine Transaction Type (based on CANCELLATION DATE)
S FBTTYP=$S($P(FBY(2),U,4)]"":"X",1:"L")
;
; determine station number
S FBSTA=$$STANO^FBFHLU($P(FBY(0),U,8))
;
;INV
S FBD(0,"INV")=FBAAIN_U_FBTTYP_U_FBSTA
;
;FPPS
S FBD(0,"FPPS")=$P(FBY(3),U)
;
;CAN
; if cancel then get cancel data
I FBTTYP="X" D Q
. S FBD(0,"CAN")=$P(FBY(2),U,4)_U_$$GET1^DIQ(162.03,FBIENS,"37:1")_U_$P(FBY(2),U,6)
;
;AMT
S FBD(0,"AMT")="0^0" ; initialize sums
;
;DT
; determine invoice date
; (date finalized or date paid or date supervisor closed batch)
S FBDT=$P(FBY(0),U,6) ; date finalized
I FBDT="" S FBDT=$P(FBY(0),U,14) ; date paid
I FBDT="",$P(FBY(0),U,8) S FBDT=$P(^FBAA(161.7,$P(FBY(0),U,8),0),U,6) ; date supv closed batch (for 0.00 invoices)
S FBD(0,"DT")=FBDT
;
Q
;
LINE ; FBC
; FBD(#,"ADJ") = AdjReason1^AdjGrp1^AdjAmt1^AdjReason2^AdjGrp2^AdjAmt2
; FBD(#,"AMT") = Amount Claimed^Amount Paid
; FBD(#,"CK") = Check Number^Check Date^Payment Method
; FBD(#,"835") = Routing Number^Financial Institution^^Account Number ; FB*3.5*122
; FBD(#,"DT") = Date of Service
; FBD(#,"FPPS") = FPPS Line Item
; FBD(#,"RMK") = Remittance Remark1^Remittance Remark2
; FBD(#,"SVC") = Service Code^Qualifier^Mod1,Mod2,Mod3,Mod4^Units
;
N FBAARCE,FBADJ,FBMODLE
; compare invoice transaction type (L,X) with line cancel status
I ((FBTTYP="X")&($P(FBY(2),U,4)=""))!((FBTTYP="L")&($P(FBY(2),U,4)]"")) D POST^FBFHLU(FBAAIN,"E","ALL LINES DO NOT HAVE SAME CANCEL STATUS") Q
;
; SVC
S FBAARCE=$$GET1^DIQ(162.03,FBIENS,48)
I FBAARCE]"" S FBD(FBC,"SVC")=FBAARCE_U_"NU"
E D
. S FBD(FBC,"SVC")=$$GET1^DIQ(162.03,FBIENS,.01)_U_"HC"
. S FBMODLE=$$MODL^FBAAUTL4("^FBAAC("_DA(3)_",1,"_DA(2)_",1,"_DA(1)_",1,"_DA_",""M"")","E")
. I $L(FBMODLE,",")>4 S FBMODLE=$P(FBMODLE,",",1,4)
. S $P(FBD(FBC,"SVC"),U,3)=FBMODLE
S $P(FBD(FBC,"SVC"),U,4)=$P(FBY(2),U,14) ; units paid
;
;FPPS
S FBD(FBC,"FPPS")=$P(FBY(3),U,2)
;
;DT
S FBD(FBC,"DT")=$P($G(^FBAAC(DA(3),1,DA(2),1,DA(1),0)),U)
;
;AMT
S FBD(FBC,"AMT")=$P(FBY(0),U,2)_U_$P(FBY(0),U,3)
;
;ADJ
D LOADADJ^FBAAFA(FBIENS,.FBADJ)
I $D(FBADJ) S FBD(FBC,"ADJ")=$$ADJL^FBUTL2(.FBADJ)
;
;RMK
S FBD(FBC,"RMK")=$$RRL^FBAAFR(FBIENS)
;
;CK
S FBD(FBC,"CK")=$P(FBY(2),U,3)_U_$P(FBY(0),U,14)_U_$$PAYMETH^FBFHLU($P(FBY(2),U,3))
;
;835 FB*3.5*122
I $P(FBY(2),U,17),$P(FBY(2),U,18),$P(FBY(2),U,19)'="" S FBD(FBC,"835")=$P(FBY(2),U,17)_U_$P(FBY(2),U,18)_U_$P(FBY(2),U,19)
;
;CAMT ; add disbursed and interest amounts to claim (0) level
; note - disbursed amount on file includes the interest
; since FPPS wants it w/o interest - interest is subtracted
S $P(FBD(0,"AMT"),U)=$P(FBD(0,"AMT"),U)+($P(FBY(2),U,8)-$P(FBY(2),U,9))
S $P(FBD(0,"AMT"),U,2)=$P(FBD(0,"AMT"),U,2)+$P(FBY(2),U,9)
Q
;
CKLNST() ; check line status extrinsic function
; result (0 or 1)
; 0 when line should not be sent to FPPS
; 1 when line should be sent to FPPS
N FBRET
S FBRET=1
;
; check if rejected line
I $P(FBY("FBREJ"),U)]"" S FBRET=0
;
Q FBRET
;
;FBFHLD3
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HFBFHLD3 5538 printed Nov 22, 2024@17:08:28 Page 2
FBFHLD3 ;OIFO/SAB-GET DATA FOR OUT/ANC INVOICE ;9/9/2003
+1 ;;3.5;FEE BASIS;**61,122**;JUNE 6, 2011;Build 8
+2 ;;Per VHA Directive 10-93-142, this routine should not be modified.
+3 QUIT
+4 ;
EN ;
+1 ; input
+2 ; FBAAIN - invoice number
+3 ; output
+4 ; If transaction type = "X" then only * items are output
+5 ; Claim Level Data
+6 ; FBD(0,"AMT") = Amount Disbursed^Amount Interest
+7 ; *FBD(0,"CAN") = Cancel Date^Cancel Reason^Cancel Activity
+8 ; FBD(0,"DT") = Invoice Date
+9 ; *FBD(0,"FPPS") = FPPS Claim ID
+10 ; *FBD(0,"INV") = Invoice #^Transaction Type^Station #
+11 ;
+12 ; Line Level Data (# is a sequential number)
+13 ; FBD(#,"ADJ") = AdjReason1^AdjGrp1^AdjAmt1^AdjReason2^AdjGrp2^AdjAmt2
+14 ; FBD(#,"AMT") = Amount Claimed^Amount Paid
+15 ; FBD(#,"CK") = Check Number^Check Date^Payment Method
+16 ; FBD(#,"835") = Routing Number^Financial Institution^^Account Number ; FB*3.5*122
+17 ; FBD(#,"DT") = Date of Service
+18 ; FBD(#,"FPPS") = FPPS Line Item
+19 ; FBD(#,"RMK") = Remittance Remark1,Remittance Remark2
+20 ; FBD(#,"SVC") = Service Code^Qualifier^Mod1,Mod2,Mod3,Mod4^Units
+21 ;
+22 ; If exceptions for invoice
+23 ; ^TMP($J,"FBE",FBAAIN,seq number)=message
+24 ; If warnings for invoice
+25 ; ^TMP($J,"FBW",FBAAIN,seq number)=message
+26 ;
+27 ; initialize variables
+28 NEW DA,FBC,FBI,FBIENS,FBSTA,FBTTYP,FBY
+29 KILL FBD
+30 ; line count
SET FBC=0
+31 ;
+32 ; loop thru lines on invoice
+33 SET DA(3)=0
+34 FOR
SET DA(3)=$ORDER(^FBAAC("C",FBAAIN,DA(3)))
if 'DA(3)
QUIT
Begin DoDot:1
+35 SET DA(2)=0
+36 FOR
SET DA(2)=$ORDER(^FBAAC("C",FBAAIN,DA(3),DA(2)))
if 'DA(2)
QUIT
Begin DoDot:2
+37 SET DA(1)=0
+38 FOR
SET DA(1)=$ORDER(^FBAAC("C",FBAAIN,DA(3),DA(2),DA(1)))
if 'DA(1)
QUIT
Begin DoDot:3
+39 SET DA=0
+40 FOR
SET DA=$ORDER(^FBAAC("C",FBAAIN,DA(3),DA(2),DA(1),DA))
if 'DA
QUIT
Begin DoDot:4
+41 SET FBIENS=DA_","_DA(1)_","_DA(2)_","_DA(3)_","
+42 FOR FBI=0,2,3,"FBREJ"
SET FBY(FBI)=$GET(^FBAAC(DA(3),1,DA(2),1,DA(1),1,DA,FBI))
+43 ; skip line if status not OK to transmit
if '$$CKLNST()
QUIT
+44 SET FBC=FBC+1
+45 ; if 1st line then get invoice level data
+46 IF FBC=1
DO INVOICE
+47 IF FBTTYP="L"
DO LINE
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+48 QUIT
+49 ;
INVOICE ; determine invoice data from 1st line item
+1 ; FBD(0,"AMT") = Amount Disbursed^Amount Interest
+2 ; FBD(0,"CAN") = Cancel Date^Cancel Reason^Cancel Activity
+3 ; FBD(0,"DT") = Invoice Date
+4 ; FBD(0,"FPPS") = FPPS Claim ID
+5 ; FBD(0,"INV") = Invoice #^Transaction Type^Station #
+6 ; FBSTA = station number
+7 ; FBTTYP = transaction type (L or X)
+8 ;
+9 NEW FBDT,FBOB,FBX
+10 ; determine Transaction Type (based on CANCELLATION DATE)
+11 SET FBTTYP=$SELECT($PIECE(FBY(2),U,4)]"":"X",1:"L")
+12 ;
+13 ; determine station number
+14 SET FBSTA=$$STANO^FBFHLU($PIECE(FBY(0),U,8))
+15 ;
+16 ;INV
+17 SET FBD(0,"INV")=FBAAIN_U_FBTTYP_U_FBSTA
+18 ;
+19 ;FPPS
+20 SET FBD(0,"FPPS")=$PIECE(FBY(3),U)
+21 ;
+22 ;CAN
+23 ; if cancel then get cancel data
+24 IF FBTTYP="X"
Begin DoDot:1
+25 SET FBD(0,"CAN")=$PIECE(FBY(2),U,4)_U_$$GET1^DIQ(162.03,FBIENS,"37:1")_U_$PIECE(FBY(2),U,6)
End DoDot:1
QUIT
+26 ;
+27 ;AMT
+28 ; initialize sums
SET FBD(0,"AMT")="0^0"
+29 ;
+30 ;DT
+31 ; determine invoice date
+32 ; (date finalized or date paid or date supervisor closed batch)
+33 ; date finalized
SET FBDT=$PIECE(FBY(0),U,6)
+34 ; date paid
IF FBDT=""
SET FBDT=$PIECE(FBY(0),U,14)
+35 ; date supv closed batch (for 0.00 invoices)
IF FBDT=""
IF $PIECE(FBY(0),U,8)
SET FBDT=$PIECE(^FBAA(161.7,$PIECE(FBY(0),U,8),0),U,6)
+36 SET FBD(0,"DT")=FBDT
+37 ;
+38 QUIT
+39 ;
LINE ; FBC
+1 ; FBD(#,"ADJ") = AdjReason1^AdjGrp1^AdjAmt1^AdjReason2^AdjGrp2^AdjAmt2
+2 ; FBD(#,"AMT") = Amount Claimed^Amount Paid
+3 ; FBD(#,"CK") = Check Number^Check Date^Payment Method
+4 ; FBD(#,"835") = Routing Number^Financial Institution^^Account Number ; FB*3.5*122
+5 ; FBD(#,"DT") = Date of Service
+6 ; FBD(#,"FPPS") = FPPS Line Item
+7 ; FBD(#,"RMK") = Remittance Remark1^Remittance Remark2
+8 ; FBD(#,"SVC") = Service Code^Qualifier^Mod1,Mod2,Mod3,Mod4^Units
+9 ;
+10 NEW FBAARCE,FBADJ,FBMODLE
+11 ; compare invoice transaction type (L,X) with line cancel status
+12 IF ((FBTTYP="X")&($PIECE(FBY(2),U,4)=""))!((FBTTYP="L")&($PIECE(FBY(2),U,4)]""))
DO POST^FBFHLU(FBAAIN,"E","ALL LINES DO NOT HAVE SAME CANCEL STATUS")
QUIT
+13 ;
+14 ; SVC
+15 SET FBAARCE=$$GET1^DIQ(162.03,FBIENS,48)
+16 IF FBAARCE]""
SET FBD(FBC,"SVC")=FBAARCE_U_"NU"
+17 IF '$TEST
Begin DoDot:1
+18 SET FBD(FBC,"SVC")=$$GET1^DIQ(162.03,FBIENS,.01)_U_"HC"
+19 SET FBMODLE=$$MODL^FBAAUTL4("^FBAAC("_DA(3)_",1,"_DA(2)_",1,"_DA(1)_",1,"_DA_",""M"")","E")
+20 IF $LENGTH(FBMODLE,",")>4
SET FBMODLE=$PIECE(FBMODLE,",",1,4)
+21 SET $PIECE(FBD(FBC,"SVC"),U,3)=FBMODLE
End DoDot:1
+22 ; units paid
SET $PIECE(FBD(FBC,"SVC"),U,4)=$PIECE(FBY(2),U,14)
+23 ;
+24 ;FPPS
+25 SET FBD(FBC,"FPPS")=$PIECE(FBY(3),U,2)
+26 ;
+27 ;DT
+28 SET FBD(FBC,"DT")=$PIECE($GET(^FBAAC(DA(3),1,DA(2),1,DA(1),0)),U)
+29 ;
+30 ;AMT
+31 SET FBD(FBC,"AMT")=$PIECE(FBY(0),U,2)_U_$PIECE(FBY(0),U,3)
+32 ;
+33 ;ADJ
+34 DO LOADADJ^FBAAFA(FBIENS,.FBADJ)
+35 IF $DATA(FBADJ)
SET FBD(FBC,"ADJ")=$$ADJL^FBUTL2(.FBADJ)
+36 ;
+37 ;RMK
+38 SET FBD(FBC,"RMK")=$$RRL^FBAAFR(FBIENS)
+39 ;
+40 ;CK
+41 SET FBD(FBC,"CK")=$PIECE(FBY(2),U,3)_U_$PIECE(FBY(0),U,14)_U_$$PAYMETH^FBFHLU($PIECE(FBY(2),U,3))
+42 ;
+43 ;835 FB*3.5*122
+44 IF $PIECE(FBY(2),U,17)
IF $PIECE(FBY(2),U,18)
IF $PIECE(FBY(2),U,19)'=""
SET FBD(FBC,"835")=$PIECE(FBY(2),U,17)_U_$PIECE(FBY(2),U,18)_U_$PIECE(FBY(2),U,19)
+45 ;
+46 ;CAMT ; add disbursed and interest amounts to claim (0) level
+47 ; note - disbursed amount on file includes the interest
+48 ; since FPPS wants it w/o interest - interest is subtracted
+49 SET $PIECE(FBD(0,"AMT"),U)=$PIECE(FBD(0,"AMT"),U)+($PIECE(FBY(2),U,8)-$PIECE(FBY(2),U,9))
+50 SET $PIECE(FBD(0,"AMT"),U,2)=$PIECE(FBD(0,"AMT"),U,2)+$PIECE(FBY(2),U,9)
+51 QUIT
+52 ;
CKLNST() ; check line status extrinsic function
+1 ; result (0 or 1)
+2 ; 0 when line should not be sent to FPPS
+3 ; 1 when line should be sent to FPPS
+4 NEW FBRET
+5 SET FBRET=1
+6 ;
+7 ; check if rejected line
+8 IF $PIECE(FBY("FBREJ"),U)]""
SET FBRET=0
+9 ;
+10 QUIT FBRET
+11 ;
+12 ;FBFHLD3