BARPST3 ; IHS/SD/LSL - PAYMENT COMMAND PROCESSOR ; 12/29/2008
;;1.8;IHS ACCOUNTS RECEIVABLE;**3,4,6,7,10,20,21,23,24**;OCT 26, 2005;Build 69
;** 'Select Command' processor
; IHS/SD/PKD 1.8*21 HEAT20490 - 3/18/11
; Prevent Cashier from continuing to post in the same Session
; if Session t
;
;
; IHS/SD/POTT HEAT76683 07/12 LIMIT COMMAND FORMAT & LENGTH - BAR 1.8*23
; IHS/SD/POTT 04/13 CONDITIONAL DISPLAY OF TXD AND MESSSAGES - BAR 1.8*23
; IHS/SD/POTT HEAT148695 01/13/2014 BLOCK INVALID ENTRY (100;200;300 AS COMMANDS) - BAR 1.8*24
; ********************************************************************
;
EN ;EP - command processor
K DIR,^TEMP($J,"BARPOST"),BARTR
S (BARADJ,BARPMT)=0
S BARDFLT=""
W !!
; -------------------------------
EN1 ;
;K BARCOM,BARTYP,BARCAT,BARATYP,BARAMT,BARLIN
K BARCOM,BARTYP,BARCAT,BARATYP,BARAMT,BARLIN,REVERSAL,REVSCHED ;BAR*1.8*4
S BARDSP=1
D HIT1^BARPST2(BARPASS)
; -------------------------------
EN2 ;
W !!
K BARCOM,BARAMT
D:$D(BARHLP)<10 SETHLP^BARPSTU
; -------------------------------
ASKLIN ;
I BARCNT=1 S (BARLIN,BARDFLT)=1 G ASKCOM1
D ASKLIN^BARFPST3
I $G(BARLIN)["^" G FINISH
I $G(BARLIN)=0 G FINISH
I BARLIN>0,BARLIN<(BARCNT+1) G ASKCOM1
;
LNHLP ;
ASKCOM ;EP - select command
K BARCOM,BARTYP,BARCAT,BARATYP,BARAMT
S BARDSP=1
D HIT1^BARPST2(BARPASS)
W !
; -------------------------------
ASKCOM1 ;
I $$NOTOPEN^BARUFUT(.DUZ,$G(UFMSESID)) Q ;IS SESSION STILL OPEN
K REVERSAL,REVSCHED ;BAR*1.8*4 SCR56,SCR58
W !,"Select Command (Line # "_BARLIN_") : "
;IHS/SD/TPF BAR*1.8*21 8/3/2011 HEAT 20490
;-------
;K DIR
;S DIR(0)="FAO"
;S DIR("A")="Select Command (Line # "_BARLIN_") "
;S DIR("T")=DTIME
;D ^DIR
;K DIR
;S BARCOM=$$UPC^BARUTL(X)
XYZ R BARCOM:DTIME
S BARCOM=$$UPC^BARUTL(BARCOM)
S BARCOM=$E(BARCOM,1,10) ;BAR*1.8*23
0 ;start new code IHS/SD/SDR bar*1.8*4 DD item 4.1.7.1
I ("P1A2"[BARCOM) D I $D(DIROUT)!$D(DIRUT)!$D(DTOUT)!$D(DUOUT)!($G(Y)=0) G ASKCOM
.S BARBLDA=$O(^BARTMP($J,"B",BARLIN,""))
.S BARTPB=$$FIND3PB^BARUTL(DUZ(2),BARBLDA)
.K DIROUT,DIRUT,DTOUT,DUOUT
.K DIR,DIE,DIC,X,Y,DA,DR
.Q:$G(BARTPB)=""
.S BARSTAT=$P($G(^ABMDBILL($P(BARTPB,","),$P(BARTPB,",",2),0)),U,4)
.Q:BARSTAT'="X"
.W !!,"STOP! 3P BILL ",$P($P($G(^BARBL(DUZ(2),BARBLDA,0)),U),"-")," has been cancelled."
.S DIR(0)="Y"
.S DIR("A")="Are you sure you want to post to this invoice"
.S DIR("B")="N"
.D ^DIR K DIR
;end new code IHS/SD/SDR bar*1.8*4 DD item 4.1.7.1
S Q=0
F J=1:1 D Q:Q ;HEAT#76683 - BAR*1.8*.24
. ;S BARCOM(J)=$E($P(BARCOM,",",J)) ;OLD CODE ;1/13/2014 HEAT148695 - BAR 1.8*24
.S BARCOM(J)=$P(BARCOM,",",J) ;NEW CODE - BAR 1.8*24
.Q:$L(BARCOM(J))
.K BARCOM(J)
.S J=J-1
.S Q=1 Q
I 'J!($L($G(BARCOM(1)))=0) G ASKCOM
I BARCOM(1)=1 S BARCOM(1)="P" W *7,*7,*7
I BARCOM(1)=2 S BARCOM(1)="A" W *7,*7,*7
I BARCOM(1)=3 S BARCOM(1)="Q" W *7,*7,*7
I '$D(BARHLP(BARCOM(1))) G COMHLP
I J=1,BARCOM(J)="M" D G ASKCOM
.N DA,DIC,BARBLDA,BARACC
.S DA=BARITDA
.S DA(1)=BARCOL
.S DIC="^BARCOL(DUZ(2),DA(1),1,"
.S BARACC=$$GET1^DIQ(DIC,.DA,7,"I")
.S BARBLDA=$O(^BARTMP($J,"B",BARLIN,""))
.D EN^BARPST6(BARPAT,BARBLDA,BARACC)
.Q
I J=1,BARCOM(J)="T" D G ASKCOM
.S Y=$$DSPLY^BARPST4(BARLIN)
.D EOP^BARUTL(1)
I J=1,BARCOM(J)="H" D HISTORY^BARBAD3 G ASKCOM
; -------------------------------
GOQ ;
;I J=1,BARCOM(J)="Q" G:BARCNT>1 EN1 G FINISH ;BAR*1.8*4 DD 4.1.7.2
I J=1,BARCOM(J)="Q" D G:BARCNT>1 EN1 G FINISH ;BAR*1.8*4 DD 4.1.7.2
.D CKNEG(BARLIN) ;BAR*1.8*4 DD 4.1.7.2
GOP ;
I J=1,BARCOM(J)="P" S BARTYP="P" G ASKAMT
I J=1,BARCOM(J)="1" S BARTYP="P" G ASKAMT
I J=1,BARCOM(J)="R" D ROLL G ASKCOM
; enable posting rollback
GOA ;
I J=1,BARCOM(J)="A" S BARTYP="A" G ASKAMT
I J=1,BARCOM(J)="2" S BARTYP="A" G ASKAMT
GOD ;
I J=1,BARCOM(J)="D" D G ASKCOM
. S DFN=BARPAT
. D VIEWR^XBLM("START^AGFACE")
GOB ;
I J=1,BARCOM(J)="B" D G ASKCOM
. S BARBLDA=$O(^BARTMP($J,"B",BARLIN,""))
. D DIQ^XBLM(90050.01,BARBLDA)
I J=1,BARCOM(J)="E" G ^BARPST4
B I J=2,BARCOM(1)="P" D G:'BARAMT ASKCOM D SETTMP^BARPST3A(BARTYP,BARAMT,BARLIN,BARCAT,,0) G ASKCOM
.S BARAMT=0,BARTYP="P"
.S X=$$AMT^BARPSTU(BARCOM(2))
.I X="^"!(X="?") W *7," (You must enter a valid number)" Q
.S BARAMT=BARCOM(2)
.S BARCAT=$O(^BAR(90052.01,"B","PAYMENT TYPE",""))
.W " ($"_$J(BARAMT,0,2)_" payment applied to Line # "_BARLIN_")" H 2
W *7
W " Sorry.. ["_BARHLP(BARCOM(1))_"] not active!"
G ASKCOM
; *********************************************************************
ASKAMT ;
S (BARCAT,BARATYP)=""
S BARASK=$S(BARTYP="P":"Payment ",BARTYP="A":"Adjustment ",1:"")_"Amount: "
;W !,BARASK R X:DTIME
K DIR
S DIR(0)="FAO"
S DIR("A")=BARASK
S DIR("T")=DTIME
D ^DIR
K DIR
S X=$$AMT^BARPSTU(X,-9999999.99,9999999.99) ;bar*1.8*20
I X="^" G ASKCOM
I X="?" W *7," Must be a valid number!" G ASKAMT
S BARAMT=X
;IHS/SD/TPF BAR*1.8*3 UFMS REQUEST FOR REVERSAL RECEIPT
;ONLY FOR IHS AFFILIATED SITES AND TRIBALS WITH FLAG 'RESTRICT POSTING NEG BAL'
I $$IHS^BARUFUT(DUZ(2)),(+BARAMT<0),(BARTYP="P") D G:'REVERSAL!$D(DTOUT)!$D(DUOUT)!(Y="") ASKCOM ;bar*1.8*20
. K REVERSAL,REVSCHED,REVERS
. S REVERS=$$REVERSAL()
. S REVERSAL=$P(REVERS,U)
. S REVSCHED=$P(REVERS,U,2)
. S Y=$G(Y) ;BAR*1.8*4 DD 4.1.7.3
;END IHS/SD/TPF BAR*1.8*3, BAR*1.8*4
;ONLY ALLOW ZERO DOLLAR PAYMENTS ON NONPAYMENT BATCHES; BAR*1.8*4 DD4.1.5.6
;
I $$IHS^BARUFUT(DUZ(2)),(+BARAMT'=0),(BARTYP="P"),$P(BARCOL(0),U,28)["NONP" D G ASKCOM ;MRS:BAR*1.8*7 IM??
. W !!,"You can not post a payment of anything other than $0 if the TDN is NONPAYMENT"
. D EOP^BARUTL(1)
;
I BARTYP="P" D G S1
. S BARCAT=$O(^BAR(90052.01,"B","PAYMENT TYPE",""))
;
;** adjustment category/type dialog
S DIC=90052.01
S DIC(0)="AEMNQZ"
S DIC("A")="Adjustment Category: "
S DIC("S")="I "",3,4,13,14,15,16,20,21,22,""[("",""_Y_"","")"
K DD,DO
D ^DIC
K DIC
I +Y<0 W *7 K BARAMT W !! G ASKAMT
S BARCAT=+Y
S:BARCAT=16 BARAMT=-BARAMT ;grouper
S BARX=0,BARJ=0
K BARATYP
F S BARX=$O(^BARTBL("D",BARCAT,BARX)) Q:'BARX D Q:BARJ>1
.S BARJ=BARJ+1
.Q:BARJ>1
.S BARATYP=BARX
I BARJ=1,$G(BARATYP) G S1
S DIC=90052.02
S DIC(0)="AEMNQZ"
S DIC("A")="Adjustment Type: "
S DIC("S")="I $P(^(0),U,2)=BARCAT"
K DD,DO
D ^DIC
K DIC
I +Y<0 K BARAMT W *7,!! G ASKAMT
S BARATYP=+Y
;--------------------------------
S1 ;
D SETTMP^BARPST3A(BARTYP,BARAMT,BARLIN,BARCAT,BARATYP,0) ;BAR*1.8*4 DD 4.1.7.2
;D SETTMP^BARPST3A(BARTYP,BARAMT,BARLIN,BARCAT,BARATYP) ;BAR*1.8*4 DD 4.1.7.2
G ASKCOM
; *********************************************************************
COMHLP ;
D COMHLP^BARPSTU
G ASKCOM1
; *********************************************************************
FINISH ;
I '$G(BARPMT)&('$G(BARADJ))&('$D(BARROLL))&'$D(BARTR) D CANCEL Q
; enable posting rollback
FIN S BARQ=$$POST() ;BAR*1.8*4 DD 4.1.7.2
I BARQ="M" G EN1
I BARQ="C" D CANCEL Q
;I BARQ="P" D POSTTX^BARPSTU,EN^BARROLL Q ;BAR*1.8*4 DD 4.1.7.2
I BARQ="P" D POSTTX^BARPSTU
;IHS/SD/TPF BAR*1.8*21 8/3/2011 HEAT20490
I $$NOTOPEN^BARUFUT(.DUZ,$G(UFMSESID)) D CANCEL Q ;IS SESSION STILL OPEN
I $G(BARSTOP)=1 G FIN ;BAR*1.8*4 DD 4.1.7.2
D EN^BARROLL
K ^BARTMP($J) ;BAR*1.8*4 DD 4.1.7.2
Q
;--------------------------------
POST() ;
P1 ;
D HIT1^BARPST2(BARPASS)
D EOP^BARUTL(2)
PDIR ;
K DIR
S DIR(0)="SAO^P:POST TO A/R;M:MORE;C:CANCEL"
S DIR("A")="Select Action (P/M/C): "
D ^DIR
K DIR
I $D(DUOUT)!(Y="") W *7 G PDIR
Q Y
; *********************************************************************
ROLL ;EP - tag a bill for rollback to 3P
; enable posting rollback
N BARBLDA
S BARBLDA=$O(^BARTMP($J,"B",BARLIN,""))
S BARROLL(BARBLDA)=""
K DIC,DIE
S DIE="^BARBL(DUZ(2),"
S DA=BARBLDA
S DR="214///@"
D ^DIE
K DIC,DIE,X,Y,DR
K DIR
S DIR("A")="TAGGED for Rolling. Enter RETURN to continue."
D EOP^BARUTL(0)
ROLLE Q
; *********************************************************************
CANCEL ;
;B "S+"
K ^BARTMP($J)
K BARPMT,BARADJ,BARTR,BARROLL
Q
;IHS/SD/TPF BAR*1.8*3 UFMS LATE REQUEST FOR RECEIPT REVERSAL
REVERSAL() ;EP - GET THE ORIGINAL TRANSACTION
ASKREV ;EP - ASK AGAIN
;Begin new code ;MRS:BAR*1.8*10 D158-3
;PREVENT ALL PAYMENT REVERSALS
W !!,"PAYMENT REVERSALS ARE NO LONGER ALLOWED,"
W !,"PLEASE USE THE 'PAYMENT CREDIT' TRANSACTION TYPE"
D EOP^BARUTL(1)
Q 0 ;End ;MRS:BAR*1.8*10 D158-3
D REVHDR
N ARBILLIN,TRANSDAT,TRANDATE,EXTRDT,TRANTYP,ACCT,RETURN,ARRAY,AMOUNT,BALANCE
N COLDA,ITEMDA,REVSCHED
N CREDIT,DEBIT
N BARCK S BARCK=0 ;BAR*1.8*4 DD 4.1.7.3
S ARBILLIN=$O(^BARTMP($J,"B",BARLIN,""))
;I $G(ARBILLIN)="" W !!,"There are no transactions to reverse!" H 2 Q ;BAR*1.8*4 DD 4.1.7.3
I $G(ARBILLIN)="" D CKREV Q 0 ;BAR*1.8*4 DD 4.1.7.3
I $G(BARPMT)>0 S BARCK=1 ;BAR*1.8*4 DD 4.1.7.3
S BARBAL=0
S TRANSDAT=""
S CNT=0
K BARNOTZ ;FOR NEW CHECK;BAR*1.8*6 DD 4.2.6
F S TRANSDAT=$O(^BARTR(DUZ(2),"AC",ARBILLIN,TRANSDAT)) Q:'TRANSDAT D
.S DEBIT=$$GET1^DIQ(90050.03,TRANSDAT_",",3,"E")
.S CREDIT=$$GET1^DIQ(90050.03,TRANSDAT_",",2,"E")
.S:CREDIT>0 BARCK=1
.Q:+$G(BARAMT)'=-CREDIT
.S TRANTYP=$$GET1^DIQ(90050.03,TRANSDAT_",",101,"E")
.S COLDA=$$GET1^DIQ(90050.03,TRANSDAT_",",14,"I")
.S ITEMDA=$$GET1^DIQ(90050.03,TRANSDAT_",",15,"I")
.S REVSCHED=$$GET1^DIQ(90051.1101,ITEMDA_","_COLDA_",",20,"I")
.Q:TRANTYP'="PAYMENT"
.I '$$EXCHK(ARBILLIN,TRANSDAT) Q ;NEW CHECK; BAR*1.8*6 DD 4.2.6
.S CNT=CNT+1
.S ARRAY(CNT)=TRANSDAT_U_REVSCHED
.W !,CNT,"."
.S EXTRDT=$P(TRANSDAT,".")
.S Y=EXTRDT X ^DD("DD") S EXTRDT=Y
.S ACCT=$$GET1^DIQ(90050.03,TRANSDAT_",",6,"E")
.S COLBAT=$$GET1^DIQ(90050.03,TRANSDAT_",",14,"E")
.S COLITEM=$$GET1^DIQ(90050.03,TRANSDAT_",",15,"E")
.S (BARX,X)=$S($G(CREDIT):-CREDIT,1:$G(DEBIT))
.S X2=2
.S X3=11
.D COMMA^%DTC
.I TRANTYP["PENDING" S X="**"_X_"**"
.S AMOUNT=X
.N X
.I TRANTYP'["PENDING"&(TRANTYP'["GENERAL") D
.. S BARBAL=BARBAL+BARX
. S X=BARBAL,X2=2,X3=11 D COMMA^%DTC
. S BALANCE=X
.W EXTRDT
.W ?25,TRANTYP
.W ?45,AMOUNT
.W ?60,BALANCE
.W !
.W ?10,ACCT
.W ?25,$E(COLBAT,1,20)
.W ?60,COLITEM
I 'BARCK D CKREV Q 0
I $G(BARNOTZ),CNT=0 D Q 0 ;NEW CHECK; BAR*1.8*6 DD 4.2.6
.W !!,"TRANSACTION HAS ALREADY BEEN LINKED TO ANOTHER REVERSAL"
.D EOP^BARUTL(1)
I CNT=0 W !!,"NO TRANSACTIONS MATCH THE REVERSAL AMOUNT ENTERED!" H 2 Q 0
W !!,BARDSH
K DIR
S DIR(0)="NO^1:"_CNT_":0"""
S DIR("A")="Choose One"
D ^DIR
Q:$D(DTOUT)!$D(DUOUT)!(Y="") 0
W !,"You have chosen "_TRANTYP_" dated "_EXTRDT_"."
K DIR
S DIR(0)="YO"
S DIR("B")="Y"
S DIR("A")="Is that correct"
D ^DIR
Q:$D(DTOUT)!$D(DUOUT) 0
G ASKREV:'Y
Q ARRAY(Y)
REVHDR ;EP - REVERSAL HEADER
W @IOF
W !!,"Which Original Payment does this apply to?"
W !
W "TRANS DATE",?25,"TRANS TYPE",?50,"AMOUNT",?65,"BALANCE"
W !,?10,"A/R ACCT",?25,"BATCH",?55,"BATCH ITEM"
W !,BARDSH
Q
CKNEG(LIN) ;EP; CHECK FOR NEGATIVE BALANCE ;BAR*1.8*4 DD 4.1.7.2
Q:'$$IHS^BARUFUT(DUZ(2)) ;IGNORE NON-IHS
N BARDA,BARB
REDO S BARDA=$O(^BARTMP($J,"B",LIN,""))
S BARB=$P(^BARTMP($J,BARDA,LIN),U,5)
I BARB<0 D
.W !!,"THE TRANSACTION(S) YOU ARE ATTEMPTING TO POST WILL PUT THIS BILL INTO A NEGATIVE"
.W !,"BALANCE BY -$"_-BARB," PLEASE CANCEL OR USE 'M' FOR MORE TO EDIT YOUR TRANSACTION(S)"
.W !,"TO PREVENT A NEGATIVE BALANCE"
.D EOP^BARUTL(1)
Q
CKREV ; CHECK FOR PAYMENT PRECEDING REVERSAL ;BAR*1.8*4 DD 4.1.7.3
W !!,"<<YOU ARE ATTEMPTING TO POST A REVERSAL WHEN THERE IS NO PAYMENT ON THE BILL" ;BAR*1.8*4 DD 4.1.7.3
W !,"PLEASE CHECK YOUR TRANSACTION AND TRY AGAIN"
D EOP^BARUTL(1)
Q
EXCHK(BARDA,TX) ; BAR*1.8*6 DD 4.2.6
; ENTERS WITH TRANSACTION DATE/TIME OF ORIGINAL PAYMENT
I BARCOL'=COLDA!(BARITM'=ITEMDA) D Q 0 ;MUST BE IN SAME COLLECTION BATCH/ITEM
.W !!,TX," CANNOT BE LINKED BECAUSE IT IS NOT IN SAME COLLECTION BATCH/ITEM"
.D EOP^BARUTL(1)
I TX<$P($G(^BAR(90052.06,DUZ(2),DUZ(2),15)),U,5) D Q 0 ;MRS:BAR*1.8*10 D158-2
.W !!,TX," CANNOT BE LINKED BECAUSE IT IS BEFORE THE UFMS BOOKING DATE,"
.W !,"USE THE PAYMENT CREDIT TRANSACTION TYPE"
.D EOP^BARUTL(1)
N X,Y,Z ;NOW CHECK IF PREVIOUS REVERSAL
S Z=1
S X=0
F S X=$O(^BARTR(DUZ(2),"AC",BARDA,X)) Q:'X D
.S Y=$P($G(^BARTR(DUZ(2),X,1)),U,10) ;TRANSACTION REVERSAL DATE STAMP
.I Y=TX D
..S Z=0
I Z D ;CHECK IF PAIRED IN THIS SESSION
.S X=0
.F S X=$O(BARTR(BARLIN,X)) Q:'X D
..I $P(BARTR(BARLIN,X),U,5)=TX S Z=0
I 'Z S BARNOTZ=1 ;SET FLAG FOR DISPLAY MESSAGE
Q Z
;*********************************************
BARPST3 ; IHS/SD/LSL - PAYMENT COMMAND PROCESSOR ; 12/29/2008
+1 ;;1.8;IHS ACCOUNTS RECEIVABLE;**3,4,6,7,10,20,21,23,24**;OCT 26, 2005;Build 69
+2 ;** 'Select Command' processor
+3 ; IHS/SD/PKD 1.8*21 HEAT20490 - 3/18/11
+4 ; Prevent Cashier from continuing to post in the same Session
+5 ; if Session t
+6 ;
+7 ;
+8 ; IHS/SD/POTT HEAT76683 07/12 LIMIT COMMAND FORMAT & LENGTH - BAR 1.8*23
+9 ; IHS/SD/POTT 04/13 CONDITIONAL DISPLAY OF TXD AND MESSSAGES - BAR 1.8*23
+10 ; IHS/SD/POTT HEAT148695 01/13/2014 BLOCK INVALID ENTRY (100;200;300 AS COMMANDS) - BAR 1.8*24
+11 ; ********************************************************************
+12 ;
EN ;EP - command processor
+1 KILL DIR,^TEMP($JOB,"BARPOST"),BARTR
+2 SET (BARADJ,BARPMT)=0
+3 SET BARDFLT=""
+4 WRITE !!
+5 ; -------------------------------
EN1 ;
+1 ;K BARCOM,BARTYP,BARCAT,BARATYP,BARAMT,BARLIN
+2 ;BAR*1.8*4
KILL BARCOM,BARTYP,BARCAT,BARATYP,BARAMT,BARLIN,REVERSAL,REVSCHED
+3 SET BARDSP=1
+4 DO HIT1^BARPST2(BARPASS)
+5 ; -------------------------------
EN2 ;
+1 WRITE !!
+2 KILL BARCOM,BARAMT
+3 IF $DATA(BARHLP)<10
DO SETHLP^BARPSTU
+4 ; -------------------------------
ASKLIN ;
+1 IF BARCNT=1
SET (BARLIN,BARDFLT)=1
GOTO ASKCOM1
+2 DO ASKLIN^BARFPST3
+3 IF $GET(BARLIN)["^"
GOTO FINISH
+4 IF $GET(BARLIN)=0
GOTO FINISH
+5 IF BARLIN>0
IF BARLIN<(BARCNT+1)
GOTO ASKCOM1
+6 ;
LNHLP ;
ASKCOM ;EP - select command
+1 KILL BARCOM,BARTYP,BARCAT,BARATYP,BARAMT
+2 SET BARDSP=1
+3 DO HIT1^BARPST2(BARPASS)
+4 WRITE !
+5 ; -------------------------------
ASKCOM1 ;
+1 ;IS SESSION STILL OPEN
IF $$NOTOPEN^BARUFUT(.DUZ,$GET(UFMSESID))
QUIT
+2 ;BAR*1.8*4 SCR56,SCR58
KILL REVERSAL,REVSCHED
+3 WRITE !,"Select Command (Line # "_BARLIN_") : "
+4 ;IHS/SD/TPF BAR*1.8*21 8/3/2011 HEAT 20490
+5 ;-------
+6 ;K DIR
+7 ;S DIR(0)="FAO"
+8 ;S DIR("A")="Select Command (Line # "_BARLIN_") "
+9 ;S DIR("T")=DTIME
+10 ;D ^DIR
+11 ;K DIR
+12 ;S BARCOM=$$UPC^BARUTL(X)
XYZ READ BARCOM:DTIME
+1 SET BARCOM=$$UPC^BARUTL(BARCOM)
+2 ;BAR*1.8*23
SET BARCOM=$EXTRACT(BARCOM,1,10)
0 ;start new code IHS/SD/SDR bar*1.8*4 DD item 4.1.7.1
+1 IF ("P1A2"[BARCOM)
Begin DoDot:1
+2 SET BARBLDA=$ORDER(^BARTMP($JOB,"B",BARLIN,""))
+3 SET BARTPB=$$FIND3PB^BARUTL(DUZ(2),BARBLDA)
+4 KILL DIROUT,DIRUT,DTOUT,DUOUT
+5 KILL DIR,DIE,DIC,X,Y,DA,DR
+6 IF $GET(BARTPB)=""
QUIT
+7 SET BARSTAT=$PIECE($GET(^ABMDBILL($PIECE(BARTPB,","),$PIECE(BARTPB,",",2),0)),U,4)
+8 IF BARSTAT'="X"
QUIT
+9 WRITE !!,"STOP! 3P BILL ",$PIECE($PIECE($GET(^BARBL(DUZ(2),BARBLDA,0)),U),"-")," has been cancelled."
+10 SET DIR(0)="Y"
+11 SET DIR("A")="Are you sure you want to post to this invoice"
+12 SET DIR("B")="N"
+13 DO ^DIR
KILL DIR
End DoDot:1
IF $DATA(DIROUT)!$DATA(DIRUT)!$DATA(DTOUT)!$DATA(DUOUT)!($GET(Y)=0)
GOTO ASKCOM
+14 ;end new code IHS/SD/SDR bar*1.8*4 DD item 4.1.7.1
+15 SET Q=0
+16 ;HEAT#76683 - BAR*1.8*.24
FOR J=1:1
Begin DoDot:1
+17 ;S BARCOM(J)=$E($P(BARCOM,",",J)) ;OLD CODE ;1/13/2014 HEAT148695 - BAR 1.8*24
+18 ;NEW CODE - BAR 1.8*24
SET BARCOM(J)=$PIECE(BARCOM,",",J)
+19 IF $LENGTH(BARCOM(J))
QUIT
+20 KILL BARCOM(J)
+21 SET J=J-1
+22 SET Q=1
QUIT
End DoDot:1
IF Q
QUIT
+23 IF 'J!($LENGTH($GET(BARCOM(1)))=0)
GOTO ASKCOM
+24 IF BARCOM(1)=1
SET BARCOM(1)="P"
WRITE *7,*7,*7
+25 IF BARCOM(1)=2
SET BARCOM(1)="A"
WRITE *7,*7,*7
+26 IF BARCOM(1)=3
SET BARCOM(1)="Q"
WRITE *7,*7,*7
+27 IF '$DATA(BARHLP(BARCOM(1)))
GOTO COMHLP
+28 IF J=1
IF BARCOM(J)="M"
Begin DoDot:1
+29 NEW DA,DIC,BARBLDA,BARACC
+30 SET DA=BARITDA
+31 SET DA(1)=BARCOL
+32 SET DIC="^BARCOL(DUZ(2),DA(1),1,"
+33 SET BARACC=$$GET1^DIQ(DIC,.DA,7,"I")
+34 SET BARBLDA=$ORDER(^BARTMP($JOB,"B",BARLIN,""))
+35 DO EN^BARPST6(BARPAT,BARBLDA,BARACC)
+36 QUIT
End DoDot:1
GOTO ASKCOM
+37 IF J=1
IF BARCOM(J)="T"
Begin DoDot:1
+38 SET Y=$$DSPLY^BARPST4(BARLIN)
+39 DO EOP^BARUTL(1)
End DoDot:1
GOTO ASKCOM
+40 IF J=1
IF BARCOM(J)="H"
DO HISTORY^BARBAD3
GOTO ASKCOM
+41 ; -------------------------------
GOQ ;
+1 ;I J=1,BARCOM(J)="Q" G:BARCNT>1 EN1 G FINISH ;BAR*1.8*4 DD 4.1.7.2
+2 ;BAR*1.8*4 DD 4.1.7.2
IF J=1
IF BARCOM(J)="Q"
Begin DoDot:1
+3 ;BAR*1.8*4 DD 4.1.7.2
DO CKNEG(BARLIN)
End DoDot:1
IF BARCNT>1
GOTO EN1
GOTO FINISH
GOP ;
+1 IF J=1
IF BARCOM(J)="P"
SET BARTYP="P"
GOTO ASKAMT
+2 IF J=1
IF BARCOM(J)="1"
SET BARTYP="P"
GOTO ASKAMT
+3 IF J=1
IF BARCOM(J)="R"
DO ROLL
GOTO ASKCOM
+4 ; enable posting rollback
GOA ;
+1 IF J=1
IF BARCOM(J)="A"
SET BARTYP="A"
GOTO ASKAMT
+2 IF J=1
IF BARCOM(J)="2"
SET BARTYP="A"
GOTO ASKAMT
GOD ;
+1 IF J=1
IF BARCOM(J)="D"
Begin DoDot:1
+2 SET DFN=BARPAT
+3 DO VIEWR^XBLM("START^AGFACE")
End DoDot:1
GOTO ASKCOM
GOB ;
+1 IF J=1
IF BARCOM(J)="B"
Begin DoDot:1
+2 SET BARBLDA=$ORDER(^BARTMP($JOB,"B",BARLIN,""))
+3 DO DIQ^XBLM(90050.01,BARBLDA)
End DoDot:1
GOTO ASKCOM
+4 IF J=1
IF BARCOM(J)="E"
GOTO ^BARPST4
B IF J=2
IF BARCOM(1)="P"
Begin DoDot:1
+1 SET BARAMT=0
SET BARTYP="P"
+2 SET X=$$AMT^BARPSTU(BARCOM(2))
+3 IF X="^"!(X="?")
WRITE *7," (You must enter a valid number)"
QUIT
+4 SET BARAMT=BARCOM(2)
+5 SET BARCAT=$ORDER(^BAR(90052.01,"B","PAYMENT TYPE",""))
+6 WRITE " ($"_$JUSTIFY(BARAMT,0,2)_" payment applied to Line # "_BARLIN_")"
HANG 2
End DoDot:1
IF 'BARAMT
GOTO ASKCOM
DO SETTMP^BARPST3A(BARTYP,BARAMT,BARLIN,BARCAT,,0)
GOTO ASKCOM
+7 WRITE *7
+8 WRITE " Sorry.. ["_BARHLP(BARCOM(1))_"] not active!"
+9 GOTO ASKCOM
+10 ; *********************************************************************
ASKAMT ;
+1 SET (BARCAT,BARATYP)=""
+2 SET BARASK=$SELECT(BARTYP="P":"Payment ",BARTYP="A":"Adjustment ",1:"")_"Amount: "
+3 ;W !,BARASK R X:DTIME
+4 KILL DIR
+5 SET DIR(0)="FAO"
+6 SET DIR("A")=BARASK
+7 SET DIR("T")=DTIME
+8 DO ^DIR
+9 KILL DIR
+10 ;bar*1.8*20
SET X=$$AMT^BARPSTU(X,-9999999.99,9999999.99)
+11 IF X="^"
GOTO ASKCOM
+12 IF X="?"
WRITE *7," Must be a valid number!"
GOTO ASKAMT
+13 SET BARAMT=X
+14 ;IHS/SD/TPF BAR*1.8*3 UFMS REQUEST FOR REVERSAL RECEIPT
+15 ;ONLY FOR IHS AFFILIATED SITES AND TRIBALS WITH FLAG 'RESTRICT POSTING NEG BAL'
+16 ;bar*1.8*20
IF $$IHS^BARUFUT(DUZ(2))
IF (+BARAMT<0)
IF (BARTYP="P")
Begin DoDot:1
+17 KILL REVERSAL,REVSCHED,REVERS
+18 SET REVERS=$$REVERSAL()
+19 SET REVERSAL=$PIECE(REVERS,U)
+20 SET REVSCHED=$PIECE(REVERS,U,2)
+21 ;BAR*1.8*4 DD 4.1.7.3
SET Y=$GET(Y)
End DoDot:1
IF 'REVERSAL!$DATA(DTOUT)!$DATA(DUOUT)!(Y="")
GOTO ASKCOM
+22 ;END IHS/SD/TPF BAR*1.8*3, BAR*1.8*4
+23 ;ONLY ALLOW ZERO DOLLAR PAYMENTS ON NONPAYMENT BATCHES; BAR*1.8*4 DD4.1.5.6
+24 ;
+25 ;MRS:BAR*1.8*7 IM??
IF $$IHS^BARUFUT(DUZ(2))
IF (+BARAMT'=0)
IF (BARTYP="P")
IF $PIECE(BARCOL(0),U,28)["NONP"
Begin DoDot:1
+26 WRITE !!,"You can not post a payment of anything other than $0 if the TDN is NONPAYMENT"
+27 DO EOP^BARUTL(1)
End DoDot:1
GOTO ASKCOM
+28 ;
+29 IF BARTYP="P"
Begin DoDot:1
+30 SET BARCAT=$ORDER(^BAR(90052.01,"B","PAYMENT TYPE",""))
End DoDot:1
GOTO S1
+31 ;
+32 ;** adjustment category/type dialog
+33 SET DIC=90052.01
+34 SET DIC(0)="AEMNQZ"
+35 SET DIC("A")="Adjustment Category: "
+36 SET DIC("S")="I "",3,4,13,14,15,16,20,21,22,""[("",""_Y_"","")"
+37 KILL DD,DO
+38 DO ^DIC
+39 KILL DIC
+40 IF +Y<0
WRITE *7
KILL BARAMT
WRITE !!
GOTO ASKAMT
+41 SET BARCAT=+Y
+42 ;grouper
IF BARCAT=16
SET BARAMT=-BARAMT
+43 SET BARX=0
SET BARJ=0
+44 KILL BARATYP
+45 FOR
SET BARX=$ORDER(^BARTBL("D",BARCAT,BARX))
IF 'BARX
QUIT
Begin DoDot:1
+46 SET BARJ=BARJ+1
+47 IF BARJ>1
QUIT
+48 SET BARATYP=BARX
End DoDot:1
IF BARJ>1
QUIT
+49 IF BARJ=1
IF $GET(BARATYP)
GOTO S1
+50 SET DIC=90052.02
+51 SET DIC(0)="AEMNQZ"
+52 SET DIC("A")="Adjustment Type: "
+53 SET DIC("S")="I $P(^(0),U,2)=BARCAT"
+54 KILL DD,DO
+55 DO ^DIC
+56 KILL DIC
+57 IF +Y<0
KILL BARAMT
WRITE *7,!!
GOTO ASKAMT
+58 SET BARATYP=+Y
+59 ;--------------------------------
S1 ;
+1 ;BAR*1.8*4 DD 4.1.7.2
DO SETTMP^BARPST3A(BARTYP,BARAMT,BARLIN,BARCAT,BARATYP,0)
+2 ;D SETTMP^BARPST3A(BARTYP,BARAMT,BARLIN,BARCAT,BARATYP) ;BAR*1.8*4 DD 4.1.7.2
+3 GOTO ASKCOM
+4 ; *********************************************************************
COMHLP ;
+1 DO COMHLP^BARPSTU
+2 GOTO ASKCOM1
+3 ; *********************************************************************
FINISH ;
+1 IF '$GET(BARPMT)&('$GET(BARADJ))&('$DATA(BARROLL))&'$DATA(BARTR)
DO CANCEL
QUIT
+2 ; enable posting rollback
FIN ;BAR*1.8*4 DD 4.1.7.2
SET BARQ=$$POST()
+1 IF BARQ="M"
GOTO EN1
+2 IF BARQ="C"
DO CANCEL
QUIT
+3 ;I BARQ="P" D POSTTX^BARPSTU,EN^BARROLL Q ;BAR*1.8*4 DD 4.1.7.2
+4 IF BARQ="P"
DO POSTTX^BARPSTU
+5 ;IHS/SD/TPF BAR*1.8*21 8/3/2011 HEAT20490
+6 ;IS SESSION STILL OPEN
IF $$NOTOPEN^BARUFUT(.DUZ,$GET(UFMSESID))
DO CANCEL
QUIT
+7 ;BAR*1.8*4 DD 4.1.7.2
IF $GET(BARSTOP)=1
GOTO FIN
+8 DO EN^BARROLL
+9 ;BAR*1.8*4 DD 4.1.7.2
KILL ^BARTMP($JOB)
+10 QUIT
+11 ;--------------------------------
POST() ;
P1 ;
+1 DO HIT1^BARPST2(BARPASS)
+2 DO EOP^BARUTL(2)
PDIR ;
+1 KILL DIR
+2 SET DIR(0)="SAO^P:POST TO A/R;M:MORE;C:CANCEL"
+3 SET DIR("A")="Select Action (P/M/C): "
+4 DO ^DIR
+5 KILL DIR
+6 IF $DATA(DUOUT)!(Y="")
WRITE *7
GOTO PDIR
+7 QUIT Y
+8 ; *********************************************************************
ROLL ;EP - tag a bill for rollback to 3P
+1 ; enable posting rollback
+2 NEW BARBLDA
+3 SET BARBLDA=$ORDER(^BARTMP($JOB,"B",BARLIN,""))
+4 SET BARROLL(BARBLDA)=""
+5 KILL DIC,DIE
+6 SET DIE="^BARBL(DUZ(2),"
+7 SET DA=BARBLDA
+8 SET DR="214///@"
+9 DO ^DIE
+10 KILL DIC,DIE,X,Y,DR
+11 KILL DIR
+12 SET DIR("A")="TAGGED for Rolling. Enter RETURN to continue."
+13 DO EOP^BARUTL(0)
ROLLE QUIT
+1 ; *********************************************************************
CANCEL ;
+1 ;B "S+"
+2 KILL ^BARTMP($JOB)
+3 KILL BARPMT,BARADJ,BARTR,BARROLL
+4 QUIT
+5 ;IHS/SD/TPF BAR*1.8*3 UFMS LATE REQUEST FOR RECEIPT REVERSAL
REVERSAL() ;EP - GET THE ORIGINAL TRANSACTION
ASKREV ;EP - ASK AGAIN
+1 ;Begin new code ;MRS:BAR*1.8*10 D158-3
+2 ;PREVENT ALL PAYMENT REVERSALS
+3 WRITE !!,"PAYMENT REVERSALS ARE NO LONGER ALLOWED,"
+4 WRITE !,"PLEASE USE THE 'PAYMENT CREDIT' TRANSACTION TYPE"
+5 DO EOP^BARUTL(1)
+6 ;End ;MRS:BAR*1.8*10 D158-3
QUIT 0
+7 DO REVHDR
+8 NEW ARBILLIN,TRANSDAT,TRANDATE,EXTRDT,TRANTYP,ACCT,RETURN,ARRAY,AMOUNT,BALANCE
+9 NEW COLDA,ITEMDA,REVSCHED
+10 NEW CREDIT,DEBIT
+11 ;BAR*1.8*4 DD 4.1.7.3
NEW BARCK
SET BARCK=0
+12 SET ARBILLIN=$ORDER(^BARTMP($JOB,"B",BARLIN,""))
+13 ;I $G(ARBILLIN)="" W !!,"There are no transactions to reverse!" H 2 Q ;BAR*1.8*4 DD 4.1.7.3
+14 ;BAR*1.8*4 DD 4.1.7.3
IF $GET(ARBILLIN)=""
DO CKREV
QUIT 0
+15 ;BAR*1.8*4 DD 4.1.7.3
IF $GET(BARPMT)>0
SET BARCK=1
+16 SET BARBAL=0
+17 SET TRANSDAT=""
+18 SET CNT=0
+19 ;FOR NEW CHECK;BAR*1.8*6 DD 4.2.6
KILL BARNOTZ
+20 FOR
SET TRANSDAT=$ORDER(^BARTR(DUZ(2),"AC",ARBILLIN,TRANSDAT))
IF 'TRANSDAT
QUIT
Begin DoDot:1
+21 SET DEBIT=$$GET1^DIQ(90050.03,TRANSDAT_",",3,"E")
+22 SET CREDIT=$$GET1^DIQ(90050.03,TRANSDAT_",",2,"E")
+23 IF CREDIT>0
SET BARCK=1
+24 IF +$GET(BARAMT)'=-CREDIT
QUIT
+25 SET TRANTYP=$$GET1^DIQ(90050.03,TRANSDAT_",",101,"E")
+26 SET COLDA=$$GET1^DIQ(90050.03,TRANSDAT_",",14,"I")
+27 SET ITEMDA=$$GET1^DIQ(90050.03,TRANSDAT_",",15,"I")
+28 SET REVSCHED=$$GET1^DIQ(90051.1101,ITEMDA_","_COLDA_",",20,"I")
+29 IF TRANTYP'="PAYMENT"
QUIT
+30 ;NEW CHECK; BAR*1.8*6 DD 4.2.6
IF '$$EXCHK(ARBILLIN,TRANSDAT)
QUIT
+31 SET CNT=CNT+1
+32 SET ARRAY(CNT)=TRANSDAT_U_REVSCHED
+33 WRITE !,CNT,"."
+34 SET EXTRDT=$PIECE(TRANSDAT,".")
+35 SET Y=EXTRDT
XECUTE ^DD("DD")
SET EXTRDT=Y
+36 SET ACCT=$$GET1^DIQ(90050.03,TRANSDAT_",",6,"E")
+37 SET COLBAT=$$GET1^DIQ(90050.03,TRANSDAT_",",14,"E")
+38 SET COLITEM=$$GET1^DIQ(90050.03,TRANSDAT_",",15,"E")
+39 SET (BARX,X)=$SELECT($GET(CREDIT):-CREDIT,1:$GET(DEBIT))
+40 SET X2=2
+41 SET X3=11
+42 DO COMMA^%DTC
+43 IF TRANTYP["PENDING"
SET X="**"_X_"**"
+44 SET AMOUNT=X
+45 NEW X
+46 IF TRANTYP'["PENDING"&(TRANTYP'["GENERAL")
Begin DoDot:2
+47 SET BARBAL=BARBAL+BARX
End DoDot:2
+48 SET X=BARBAL
SET X2=2
SET X3=11
DO COMMA^%DTC
+49 SET BALANCE=X
+50 WRITE EXTRDT
+51 WRITE ?25,TRANTYP
+52 WRITE ?45,AMOUNT
+53 WRITE ?60,BALANCE
+54 WRITE !
+55 WRITE ?10,ACCT
+56 WRITE ?25,$EXTRACT(COLBAT,1,20)
+57 WRITE ?60,COLITEM
End DoDot:1
+58 IF 'BARCK
DO CKREV
QUIT 0
+59 ;NEW CHECK; BAR*1.8*6 DD 4.2.6
IF $GET(BARNOTZ)
IF CNT=0
Begin DoDot:1
+60 WRITE !!,"TRANSACTION HAS ALREADY BEEN LINKED TO ANOTHER REVERSAL"
+61 DO EOP^BARUTL(1)
End DoDot:1
QUIT 0
+62 IF CNT=0
WRITE !!,"NO TRANSACTIONS MATCH THE REVERSAL AMOUNT ENTERED!"
HANG 2
QUIT 0
+63 WRITE !!,BARDSH
+64 KILL DIR
+65 SET DIR(0)="NO^1:"_CNT_":0"""
+66 SET DIR("A")="Choose One"
+67 DO ^DIR
+68 IF $DATA(DTOUT)!$DATA(DUOUT)!(Y="")
QUIT 0
+69 WRITE !,"You have chosen "_TRANTYP_" dated "_EXTRDT_"."
+70 KILL DIR
+71 SET DIR(0)="YO"
+72 SET DIR("B")="Y"
+73 SET DIR("A")="Is that correct"
+74 DO ^DIR
+75 IF $DATA(DTOUT)!$DATA(DUOUT)
QUIT 0
+76 IF 'Y
GOTO ASKREV
+77 QUIT ARRAY(Y)
REVHDR ;EP - REVERSAL HEADER
+1 WRITE @IOF
+2 WRITE !!,"Which Original Payment does this apply to?"
+3 WRITE !
+4 WRITE "TRANS DATE",?25,"TRANS TYPE",?50,"AMOUNT",?65,"BALANCE"
+5 WRITE !,?10,"A/R ACCT",?25,"BATCH",?55,"BATCH ITEM"
+6 WRITE !,BARDSH
+7 QUIT
CKNEG(LIN) ;EP; CHECK FOR NEGATIVE BALANCE ;BAR*1.8*4 DD 4.1.7.2
+1 ;IGNORE NON-IHS
IF '$$IHS^BARUFUT(DUZ(2))
QUIT
+2 NEW BARDA,BARB
REDO SET BARDA=$ORDER(^BARTMP($JOB,"B",LIN,""))
+1 SET BARB=$PIECE(^BARTMP($JOB,BARDA,LIN),U,5)
+2 IF BARB<0
Begin DoDot:1
+3 WRITE !!,"THE TRANSACTION(S) YOU ARE ATTEMPTING TO POST WILL PUT THIS BILL INTO A NEGATIVE"
+4 WRITE !,"BALANCE BY -$"_-BARB," PLEASE CANCEL OR USE 'M' FOR MORE TO EDIT YOUR TRANSACTION(S)"
+5 WRITE !,"TO PREVENT A NEGATIVE BALANCE"
+6 DO EOP^BARUTL(1)
End DoDot:1
+7 QUIT
CKREV ; CHECK FOR PAYMENT PRECEDING REVERSAL ;BAR*1.8*4 DD 4.1.7.3
+1 ;BAR*1.8*4 DD 4.1.7.3
WRITE !!,"<<YOU ARE ATTEMPTING TO POST A REVERSAL WHEN THERE IS NO PAYMENT ON THE BILL"
+2 WRITE !,"PLEASE CHECK YOUR TRANSACTION AND TRY AGAIN"
+3 DO EOP^BARUTL(1)
+4 QUIT
EXCHK(BARDA,TX) ; BAR*1.8*6 DD 4.2.6
+1 ; ENTERS WITH TRANSACTION DATE/TIME OF ORIGINAL PAYMENT
+2 ;MUST BE IN SAME COLLECTION BATCH/ITEM
IF BARCOL'=COLDA!(BARITM'=ITEMDA)
Begin DoDot:1
+3 WRITE !!,TX," CANNOT BE LINKED BECAUSE IT IS NOT IN SAME COLLECTION BATCH/ITEM"
+4 DO EOP^BARUTL(1)
End DoDot:1
QUIT 0
+5 ;MRS:BAR*1.8*10 D158-2
IF TX<$PIECE($GET(^BAR(90052.06,DUZ(2),DUZ(2),15)),U,5)
Begin DoDot:1
+6 WRITE !!,TX," CANNOT BE LINKED BECAUSE IT IS BEFORE THE UFMS BOOKING DATE,"
+7 WRITE !,"USE THE PAYMENT CREDIT TRANSACTION TYPE"
+8 DO EOP^BARUTL(1)
End DoDot:1
QUIT 0
+9 ;NOW CHECK IF PREVIOUS REVERSAL
NEW X,Y,Z
+10 SET Z=1
+11 SET X=0
+12 FOR
SET X=$ORDER(^BARTR(DUZ(2),"AC",BARDA,X))
IF 'X
QUIT
Begin DoDot:1
+13 ;TRANSACTION REVERSAL DATE STAMP
SET Y=$PIECE($GET(^BARTR(DUZ(2),X,1)),U,10)
+14 IF Y=TX
Begin DoDot:2
+15 SET Z=0
End DoDot:2
End DoDot:1
+16 ;CHECK IF PAIRED IN THIS SESSION
IF Z
Begin DoDot:1
+17 SET X=0
+18 FOR
SET X=$ORDER(BARTR(BARLIN,X))
IF 'X
QUIT
Begin DoDot:2
+19 IF $PIECE(BARTR(BARLIN,X),U,5)=TX
SET Z=0
End DoDot:2
End DoDot:1
+20 ;SET FLAG FOR DISPLAY MESSAGE
IF 'Z
SET BARNOTZ=1
+21 QUIT Z
+22 ;*********************************************