FBNHEDPA ;AISC/GRR - EDIT PAYMENT FOR COMMUNITY NURSING HOME ;10/7/14 17:55
;;3.5;FEE BASIS;**61,124,132,154**;JAN 30, 1995;Build 12
;;Per VA Directive 6402, this routine should not be modified.
EDIT ;ENTRY POINT TO EDIT PAYMENT
S IOP=$S($D(ION):ION,1:"HOME") D ^%ZIS K IOP
BT S DIC="^FBAA(161.7,",DIC(0)="AEQMZ",DIC("S")="I $P(^(0),U,3)=""B9""",DIC("S")=$S($D(^XUSEC("FBAA LEVEL 2",DUZ)):DIC("S"),1:DIC("S")_"&($P(^(0),U,5)=DUZ)") D ^DIC
G END:X=""!(X="^"),BT:Y<0 S FBN=+Y,FBN(0)=Y(0)
S FBSTAT=^FBAA(161.7,FBN,"ST")
I FBSTAT="C"&('$D(^XUSEC("FBAA LEVEL 2",DUZ))) W !!,*7,?3,"You must Reopen the batch prior to editing the invoice.",! G END
I FBSTAT="S"!(FBSTAT="P")!(FBSTAT="R")&('$D(^XUSEC("FBAA LEVEL 2",DUZ))) W !!,*7,?3,"You must be a holder of the 'FBAA LEVEL 2' security key",!,?3,"to edit this invoice.",! G END
I FBSTAT="T"!(FBSTAT="F")!(FBSTAT="V") W !!,?3,"Batch has already been sent to Austin for payment.",! G END
INV W ! S DIC("A")="Select Invoice Number: ",DIC="^FBAAI(",DIC(0)="AEQMZ",DIC("S")="I $P(^(0),U,17)=FBN" D ^DIC K DIC G BT:X=""!(X="^"),INV:Y<0 S FBI=+Y,FBOLD(0)=Y(0)
S FBLISTC="",FBHDI=FBI W @IOF D START^FBCHDI S FBI=FBHDI K FBHDI
;
; enforce separation of duties
S DFN=$P(FBOLD(0),U,4)
S FB7078I=$P(FBOLD(0),U,5)
S FTP=$S(FB7078I]"":$O(^FBAAA("AG",FB7078I,DFN,0)),1:"")
I '$$UOKPAY^FBUTL9(DFN,FTP) D G INV
. W !!,"You cannot process a payment associated with authorization ",DFN,"-",FTP
. W !,"due to separation of duties."
;
K FBHAP,FBAP
S (DIE,DIC)="^FBAAI(",DIC(0)="AEQM",DA=FBI,DR="[FBNH EDIT PAYMENT]",DIE("NO^")=""
W !
N FBHAC
; get values of FPPS Claim ID and Line Item
S FBFPPSC=$P($G(^FBAAI(FBI,3)),U)
S FBFPPSL=$P($G(^FBAAI(FBI,3)),U,2)
; load current adjustment data
D LOADADJ^FBCHFA(FBI_",",.FBADJ)
; save adjustment data prior to edit session in sorted list
S FBADJL(0)=$$ADJL^FBUTL2(.FBADJ) ; sorted list of original adjustments
; load current remittance remark data
D LOADRR^FBCHFR(FBI_",",.FBRRMK)
; save remittance remarks prior to edit session in sorted list
S FBRRMKL(0)=$$RRL^FBUTL4(.FBRRMK)
D ^DIE K DIE("NO^")
I $D(DTOUT) S DR="5///^S X="_$P(FBOLD(0),U,6)_";6///^S X="_$P(FBOLD(0),U,7) D ^DIE
; if adjustment data changed then file
I $$ADJL^FBUTL2(.FBADJ)'=FBADJL(0) D FILEADJ^FBCHFA(FBI_",",.FBADJ)
; if remit remark data changed then file
I $$RRL^FBUTL4(.FBRRMK)'=FBRRMKL(0) D FILERR^FBCHFR(FBI_",",.FBRRMK)
I $D(FBHAP),$D(FBAP),FBAP-FBHAP S FBDIF=FBAP-FBHAP,$P(^FBAA(161.7,FBN,0),"^",9)=$P(^FBAA(161.7,FBN,0),"^",9)+FBDIF
END K DA,DFN,DIC,DIE,DR,FBAAOUT,FBDX,FBI,FBIN,FBLISTC,FBN,FBPROC,FBSTAT,FBVEN,FBVID,J,K,L,POP,Q,VA,VADM,X,Y,FBAC,FBAP,FBBAL,FBHAP,FBDIF
K FBADJ,FBADJL,FBRRMK,FBRRMKL,FBFPPSC,FBFPPSL,FB7078I,FTP
D KILL^FBPAY K FBOLD,FBINODE,FBPAT,FBPRGNAM
Q
;
BADDATE(INVRCVDT,TEMPDA) ;Compare edited Invoice Received Date to Treatment Date, reject if before
I INVRCVDT="" Q 0 ;Inv Date not changed, no check necessary
N TDAT,SHODAT S TDAT=$$GET1^DIQ(162.5,TEMPDA_",",6,"I") I TDAT]"" S SHODAT="TO"
I TDAT="" S TDAT=$$GET1^DIQ(162.5,TEMPDA_",",5,"I"),SHODAT="FROM"
I INVRCVDT<TDAT D Q 1 ;Reject entered date
.N SHOTDAT S SHOTDAT=$E(TDAT,4,5)_"/"_$E(TDAT,6,7)_"/"_$E(TDAT,2,3) ;Convert TDAT into display format for error message
.N MSG1,MSG2 S MSG1="*** Invoice Received Date cannot be before",MSG2=" Treatment "_SHODAT_" Date ("_SHOTDAT_") !!!"
.W !!?5,*7,MSG1,!?8,MSG2
Q 0 ;Date entered is OK
;
BADTDATE(TDAT,INVRCVDT,SHODAT) ;Compare edited Treatment TO or FROM Date to Invoice Received Date, reject if AFTER
I INVRCVDT<TDAT D Q 1 ;Reject entered date
.N SHOIRDAT S SHOIRDAT=$E(INVRCVDT,4,5)_"/"_$E(INVRCVDT,6,7)_"/"_$E(INVRCVDT,2,3) ;Convert INVRCVDT into display format for error message.
.N MSG1,MSG2 S MSG1="*** Treatment "_SHODAT_" Date cannot be after",MSG2=" Invoice Received Date ("_SHOIRDAT_") !!!"
.W !!?5,*7,MSG1,!?8,MSG2
Q 0 ;Date entered is OK
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HFBNHEDPA 3951 printed Oct 16, 2024@17:59:48 Page 2
FBNHEDPA ;AISC/GRR - EDIT PAYMENT FOR COMMUNITY NURSING HOME ;10/7/14 17:55
+1 ;;3.5;FEE BASIS;**61,124,132,154**;JAN 30, 1995;Build 12
+2 ;;Per VA Directive 6402, this routine should not be modified.
EDIT ;ENTRY POINT TO EDIT PAYMENT
+1 SET IOP=$SELECT($DATA(ION):ION,1:"HOME")
DO ^%ZIS
KILL IOP
BT SET DIC="^FBAA(161.7,"
SET DIC(0)="AEQMZ"
SET DIC("S")="I $P(^(0),U,3)=""B9"""
SET DIC("S")=$SELECT($DATA(^XUSEC("FBAA LEVEL 2",DUZ)):DIC("S"),1:DIC("S")_"&($P(^(0),U,5)=DUZ)")
DO ^DIC
+1 if X=""!(X="^")
GOTO END
if Y<0
GOTO BT
SET FBN=+Y
SET FBN(0)=Y(0)
+2 SET FBSTAT=^FBAA(161.7,FBN,"ST")
+3 IF FBSTAT="C"&('$DATA(^XUSEC("FBAA LEVEL 2",DUZ)))
WRITE !!,*7,?3,"You must Reopen the batch prior to editing the invoice.",!
GOTO END
+4 IF FBSTAT="S"!(FBSTAT="P")!(FBSTAT="R")&('$DATA(^XUSEC("FBAA LEVEL 2",DUZ)))
WRITE !!,*7,?3,"You must be a holder of the 'FBAA LEVEL 2' security key",!,?3,"to edit this invoice.",!
GOTO END
+5 IF FBSTAT="T"!(FBSTAT="F")!(FBSTAT="V")
WRITE !!,?3,"Batch has already been sent to Austin for payment.",!
GOTO END
INV WRITE !
SET DIC("A")="Select Invoice Number: "
SET DIC="^FBAAI("
SET DIC(0)="AEQMZ"
SET DIC("S")="I $P(^(0),U,17)=FBN"
DO ^DIC
KILL DIC
if X=""!(X="^")
GOTO BT
if Y<0
GOTO INV
SET FBI=+Y
SET FBOLD(0)=Y(0)
+1 SET FBLISTC=""
SET FBHDI=FBI
WRITE @IOF
DO START^FBCHDI
SET FBI=FBHDI
KILL FBHDI
+2 ;
+3 ; enforce separation of duties
+4 SET DFN=$PIECE(FBOLD(0),U,4)
+5 SET FB7078I=$PIECE(FBOLD(0),U,5)
+6 SET FTP=$SELECT(FB7078I]"":$ORDER(^FBAAA("AG",FB7078I,DFN,0)),1:"")
+7 IF '$$UOKPAY^FBUTL9(DFN,FTP)
Begin DoDot:1
+8 WRITE !!,"You cannot process a payment associated with authorization ",DFN,"-",FTP
+9 WRITE !,"due to separation of duties."
End DoDot:1
GOTO INV
+10 ;
+11 KILL FBHAP,FBAP
+12 SET (DIE,DIC)="^FBAAI("
SET DIC(0)="AEQM"
SET DA=FBI
SET DR="[FBNH EDIT PAYMENT]"
SET DIE("NO^")=""
+13 WRITE !
+14 NEW FBHAC
+15 ; get values of FPPS Claim ID and Line Item
+16 SET FBFPPSC=$PIECE($GET(^FBAAI(FBI,3)),U)
+17 SET FBFPPSL=$PIECE($GET(^FBAAI(FBI,3)),U,2)
+18 ; load current adjustment data
+19 DO LOADADJ^FBCHFA(FBI_",",.FBADJ)
+20 ; save adjustment data prior to edit session in sorted list
+21 ; sorted list of original adjustments
SET FBADJL(0)=$$ADJL^FBUTL2(.FBADJ)
+22 ; load current remittance remark data
+23 DO LOADRR^FBCHFR(FBI_",",.FBRRMK)
+24 ; save remittance remarks prior to edit session in sorted list
+25 SET FBRRMKL(0)=$$RRL^FBUTL4(.FBRRMK)
+26 DO ^DIE
KILL DIE("NO^")
+27 IF $DATA(DTOUT)
SET DR="5///^S X="_$PIECE(FBOLD(0),U,6)_";6///^S X="_$PIECE(FBOLD(0),U,7)
DO ^DIE
+28 ; if adjustment data changed then file
+29 IF $$ADJL^FBUTL2(.FBADJ)'=FBADJL(0)
DO FILEADJ^FBCHFA(FBI_",",.FBADJ)
+30 ; if remit remark data changed then file
+31 IF $$RRL^FBUTL4(.FBRRMK)'=FBRRMKL(0)
DO FILERR^FBCHFR(FBI_",",.FBRRMK)
+32 IF $DATA(FBHAP)
IF $DATA(FBAP)
IF FBAP-FBHAP
SET FBDIF=FBAP-FBHAP
SET $PIECE(^FBAA(161.7,FBN,0),"^",9)=$PIECE(^FBAA(161.7,FBN,0),"^",9)+FBDIF
END KILL DA,DFN,DIC,DIE,DR,FBAAOUT,FBDX,FBI,FBIN,FBLISTC,FBN,FBPROC,FBSTAT,FBVEN,FBVID,J,K,L,POP,Q,VA,VADM,X,Y,FBAC,FBAP,FBBAL,FBHAP,FBDIF
+1 KILL FBADJ,FBADJL,FBRRMK,FBRRMKL,FBFPPSC,FBFPPSL,FB7078I,FTP
+2 DO KILL^FBPAY
KILL FBOLD,FBINODE,FBPAT,FBPRGNAM
+3 QUIT
+4 ;
BADDATE(INVRCVDT,TEMPDA) ;Compare edited Invoice Received Date to Treatment Date, reject if before
+1 ;Inv Date not changed, no check necessary
IF INVRCVDT=""
QUIT 0
+2 NEW TDAT,SHODAT
SET TDAT=$$GET1^DIQ(162.5,TEMPDA_",",6,"I")
IF TDAT]""
SET SHODAT="TO"
+3 IF TDAT=""
SET TDAT=$$GET1^DIQ(162.5,TEMPDA_",",5,"I")
SET SHODAT="FROM"
+4 ;Reject entered date
IF INVRCVDT<TDAT
Begin DoDot:1
+5 ;Convert TDAT into display format for error message
NEW SHOTDAT
SET SHOTDAT=$EXTRACT(TDAT,4,5)_"/"_$EXTRACT(TDAT,6,7)_"/"_$EXTRACT(TDAT,2,3)
+6 NEW MSG1,MSG2
SET MSG1="*** Invoice Received Date cannot be before"
SET MSG2=" Treatment "_SHODAT_" Date ("_SHOTDAT_") !!!"
+7 WRITE !!?5,*7,MSG1,!?8,MSG2
End DoDot:1
QUIT 1
+8 ;Date entered is OK
QUIT 0
+9 ;
BADTDATE(TDAT,INVRCVDT,SHODAT) ;Compare edited Treatment TO or FROM Date to Invoice Received Date, reject if AFTER
+1 ;Reject entered date
IF INVRCVDT<TDAT
Begin DoDot:1
+2 ;Convert INVRCVDT into display format for error message.
NEW SHOIRDAT
SET SHOIRDAT=$EXTRACT(INVRCVDT,4,5)_"/"_$EXTRACT(INVRCVDT,6,7)_"/"_$EXTRACT(INVRCVDT,2,3)
+3 NEW MSG1,MSG2
SET MSG1="*** Treatment "_SHODAT_" Date cannot be after"
SET MSG2=" Invoice Received Date ("_SHOIRDAT_") !!!"
+4 WRITE !!?5,*7,MSG1,!?8,MSG2
End DoDot:1
QUIT 1
+5 ;Date entered is OK
QUIT 0
+6 ;