Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ACHSAJ

ACHSAJ.m

Go to the documentation of this file.
ACHSAJ ; IHS/ITSC/PMF - ADJUST A PAID DOCUMENT (1/2) ;      [ 12/11/2003  1:09 PM ]
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;**1,5,14,19**;JUN 11, 2001
 ;;ACHS*3.1*1; Correct typo
 ;;ACHS*3.1*5 12/06/2002; set ACHSDOC0 in THIS routine, instead of
 ;                        depending on it being passed in
 ; ACHS*3.1*14 7/25/2008 IHS/OIT/FCJ Added ability to neg adj 3rd party payment
 ;
 I $D(^ACHS(9,DUZ(2),"FY",ACHSCFY,"W",+ACHSFYWK(DUZ(2),ACHSCFY),0)),$P($G(^ACHS(9,DUZ(2),"FY",ACHSCFY,"W",+ACHSFYWK(DUZ(2),ACHSCFY),0)),U,2)=DT D  Q
 . W !!,*7,"  The Register Has Been CLOSED -- An adjustment cannot be done at this time!",!
 . D ENDC^ACHSAJ1
 . Q
 ;
A3 ; Select document, check for paid status.
 D ^ACHSUD
 ;
 I '$D(ACHSDIEN) D ENDC^ACHSAJ1 Q
 ;
 I '$D(^ACHSF(DUZ(2),"D",ACHSDIEN,"PA")) W !!,*7,?10,"NOT A PAID DOCUMENT -- ONLY PAID DOCUMENTS CAN BE ADJUSTED" G A3
 S ACHSTIEN=1,ACHSIPA=0,ACHS3RDS=""
 K ACHSSIG
 ;
 D INIT^ACHSRP2  ;INITIALIZE DOCUMENT VARIABLES
 D ^ACHSAV       ;DOCUMENT DISPLAY
 S ACHSADJ=""
 D A0A^ACHSUSC   ;DISPLAY DOCUMENT CANCEL/SUPPLEMENT INFO
 ;
A4 ;
 I '$D(ACHSDIEN) D ENDC^ACHSAJ1 Q
 ;
 I '$$LOCK^ACHS("^ACHSF(DUZ(2),""D"",ACHSDIEN)","+") W !,"LOCK FAILED AT A4+2^ACHSAJ" D K^ACHSAJ1 Q
 ;
 ;THIS ENTRY CALLED BY ACHSEOB3 THREE DIFFERENT TIMES TO PROCESS
 ;ADJUSTMENT AMOUNTS - 
 ;1)FIRST IF THERE ARE PAYMENT AMOUNTS
 ;I.E. I $D(^ACHSF(DUZ(2),"D",ACHSDIEN,"PA")) DO THIS
 ;2)
A4A ;EP - Automatic adjustment.
 S ACHSX=+$$DOC^ACHS(0,14)  ;GET FISCAL YEAR DIGIT
 D FYCVT^ACHSFU             ;COMPUTE FISCAL YEAR
 S ACHSACFY=ACHSY,ACHSACWK=+ACHSFYWK(DUZ(2),ACHSACFY)
 ;
 ;ACHS*3.1*5 12/06/2002 pmf  make sure that ACHSDOC0 has the
 ;data from the CURRENT document.  We BETTER have ACHSDIEN set
 ;by now, but I'm being careful with the $G
 I $G(ACHSDIEN)'="" S ACHSDOC0=$G(^ACHSF(DUZ(2),"D",ACHSDIEN,0))  ;  ACHS*3.1*5 12/06/2002
 ;
 ;
 S X=1   ;SKIP INITIAL TRANSACTION ASSUMES FIRST IS I='INITIAL'
 F  S X=$O(^ACHSF(DUZ(2),"D",ACHSDIEN,"T",X)) Q:+X=0  D
 .;IF 'TRANSACTION TYPE' EQUALS P=PAYMENT GET 'DATE OF SERVICE'
 .;THIS WILL GET ONLY THE FIRST PAYMENT ENTRY.
 .;IF THERE IS NO PAYMENT ENTRY THEN DATE OF SERVICE WILL BE UNDEFINED
 .;OR THE LAST ONE FOUND. ALSO ACHSTIEN IS SET TO X WHEN DATE OF SERVICE
 .;IS NOT DEFINED
 .I $P($G(^ACHSF(DUZ(2),"D",ACHSDIEN,"T",X,0)),U,2)="P" S ACHSSVDT=$P($G(^ACHSF(DUZ(2),"D",ACHSDIEN,"T",X,0)),U,10) Q:ACHSSVDT>0  S ACHSTIEN=X
 ;
 ;
 ;
 D CKB^ACHSUUP              ;CHECK BALANCE
 I $D(ACHSISAO),$D(ACHSCNC) D  Q
 .S ACHSERRE=13             ;REGISTERS OUT OF BALANCE
 .S ACHSEDAT="" D ^ACHSEOBG D K^ACHSAJ1 S ACHSERRA=1 Q
 ;
 I $D(ACHSCNC) D END^ACHSAJ1 Q
 ;
 S (ACHSTADJ,ACHSNADJ)=0
 ;
 ;GET PAYMENT AMOUNT NODE
 S ACHSAPA=$G(^ACHSF(DUZ(2),"D",ACHSDIEN,"PA"))
 I ACHSAPA="" D  Q
 .S ACHSERRE=12   ;ZERO DOCUMENT AMOUNT
 .S ACHSEDAT=$G(S),ACHSERRA=1 D ^ACHSEOBG D K^ACHSAJ1 Q
 ;
 ;
 S ACHS3PA=$P(ACHSAPA,U,5)    ;PAYMENT AMOUNT THIRD PARTY
 S ACHSAPA=$P(ACHSAPA,U)      ;TOTAL PAYMENT AMOUNT
 ;
 ;IF THERE IS DATA IN ADJUSTMENT NODE REPLACE INFO FROM
 ;PA NODE WITH INFO FROM ZA NODE??????
 I $D(^ACHSF(DUZ(2),"D",ACHSDIEN,"ZA")) D
 .;ADJUSTED PAYMENT AMT
 .S ACHSAPA=$P($G(^ACHSF(DUZ(2),"D",ACHSDIEN,"ZA")),U)
 .;TOTAL ADJUSTMENT AMT
 .S ACHSTADJ=$P($G(^ACHSF(DUZ(2),"D",ACHSDIEN,"ZA")),U,2)
 .;NUMBER OF ADJUSTMENTS
 .S ACHSNADJ=$P($G(^ACHSF(DUZ(2),"D",ACHSDIEN,"ZA")),U,3)
 .;ADJUSTED THIRD PARTY PAYMENT AMT
 .S ACHS3PA=$P($G(^ACHSF(DUZ(2),"D",ACHSDIEN,"ZA")),U,4)
 ;
 I $D(ACHSISAO),$D(^ACHSF(DUZ(2),"D",ACHSDIEN,"EB1",ACHSPDAT)) S ACHSERRE=29,ACHSEDAT="" D ^ACHSEOBG
B2 ;
 I $D(ACHSISAO),$D(ACHSIPA) S Y=ACHSIPA,ACHSSIGN=1 S:$E(Y)="-" ACHSSIGN=-1,Y=$E(Y,2,99) G B3
 I $D(ACHSISAO) S ACHSERRE=28,ACHSEDAT=ACHSIPA,ACHSERRA=1 D ^ACHSEOBG,K^ACHSAJ1 Q
B2Z ;
 W !!,"Amount Of pay Adjustment: "
 S ACHSSIGN=1
 D READ^ACHSFU             ;USER INPUT DOLLAR AMOUNT
 I $D(DTOUT)!($D(DUOUT)) D ENDC^ACHSAJ1 Q
 ;
 I Y?1"?".E W !,"  Enter Payment Adjustment Amount (e.g. + or -  150.00)." G B2
 ;ACHS*3.1*14 7/25/2008 IHS/OIT/FCJ CHNGED NXT LINE TO ALLOW 0 ON ADJ IN ORDER TO ADJ 3RD PARTY PAY AMT
 ;I Y=""!(+Y=0) W *7,"   NO AMOUNT ENTERED",!! D ENDC^ACHSAJ1 Q
 I Y="" W *7,"   NO AMOUNT ENTERED",!! D ENDC^ACHSAJ1 Q
 ;
 S ACHSADAM=Y              ;ADJUSTMENT AMOUNT
 ;
 ;pmf  06/19/01  first, strip out the dollar sign, if there is one.
 S ACHSADAM=$TR(ACHSADAM,"$")
 S:$E(ACHSADAM)="+" ACHSADAM=$E(ACHSADAM,2,99)
 S:$E(ACHSADAM)="-" ACHSSIGN=-1,ACHSADAM=$E(ACHSADAM,2,99)
 ;pmf 06/19/01  remove next line.  this is now handle better above
 ;S:ACHSADAM?1"$".E ACHSADAM=$E(ACHSADAM,2,99)
 ;
 F I=1:1 S F=$F(ACHSADAM,",") Q:'F  S ACHSADAM=$E(ACHSADAM,1,F-2)_$E(ACHSADAM,F,99)
 I '(ACHSADAM?1N.N1"."2N!(ACHSADAM?1N.N))!($L(ACHSADAM)>10) W *7,"  ??" G A4
B3 ;
 D OBLM^ACHSFU     ;CHECK OBLIGATION LIMIT FOR THIS TYPE OF DOCUMENT
 G:$D(DUOUT)!($D(DTOUT)) B2
 ;
 I $D(ACHSISAO),$D(ACHSERRE) S ACHSERRA=1,ACHSEDAT="" D ^ACHSEOBG,K^ACHSAJ1 Q
C ;
 S ACHSADAM=$G(ACHSADAM)
 I ACHSADAM="" S ACHSADAM=$G(Y)
 ;
 ;4/30/02  pmf  just above, we make sure that we have a value
 ;for the adjustment amount.  However, it is possible that ACHSADAM
 ;was floating around from a previous iteration and is set wrong.
 ;therefore, let's do one more line for auto EOBR processing
 ;if ACHSISAO exists, we are doing that, and the amount is in Y
 I $D(ACHSISAO) S ACHSADAM=Y
 ;
 ;
 S (S,X)=ACHSSIGN*ACHSADAM,X2="2$",X3=0
 D COMMA^%DTC
 W:'$D(ACHSISAO) "   (",X,")"
 S (ACHSESDO,ACHSAMT)=S
 S ACHS("CHK")=1,ACHSUFLG=""
 ;
 D SBAENT^ACHSUUP          ;UPDATE CURRENT ADVICE OF ALLOWANCE
 ;
 K ACHSUFLG
 I S>0 G C0
 ;I -1*S>$P($G(^ACHSF(DUZ(2),"D",ACHSDIEN,"PA")),U) D NEGADJ
 ;G:'$D(ACHSISAO) B2
 ;Q
 ;ACHS*3.1*19 IHS.OIT.FCJ MODIFIED NEXT LINE TO TEST FOR ADJ PAYMENTS
 ;I -1*S>$P(^ACHSF(DUZ(2),"D",ACHSDIEN,"PA"),U) W:'$D(ACHSISAO) *7,!!,"NEG ADJ CANNOT BE > PAYMENT AMT" G:'$D(ACHSISAO) B2 I $D(ACHSISAO) S ACHSERRE=25,ACHSEDAT=S,ACHSERRA=1 D ^ACHSEOBG D K^ACHSAJ1 Q
 I $D(^ACHSF(DUZ(2),"D",ACHSDIEN,"ZA")) S ACHSTP=$P(^("ZA"),U)
 E  S ACHSTP=$P(^ACHSF(DUZ(2),"D",ACHSDIEN,"PA"),U)
 I -1*S>ACHSTP W:'$D(ACHSISAO) *7,!!,"NEG ADJ CANNOT BE > PAYMENT AMT" G:'$D(ACHSISAO) B2 I $D(ACHSISAO) S ACHSERRE=25,ACHSEDAT=S,ACHSERRA=1 D ^ACHSEOBG D K^ACHSAJ1 Q
 G C0
 ;
NEGADJ ;
 W:'$D(ACHSISAO) *7,!!,"NEG ADJ CANNOT BE > PAYMENT AMT"
 I $D(ACHSISAO) D
 .S ACHSERRE=25       ;NEG ADJ > PAY AMOUNT;E
 .S ACHSEDAT=S
 .S ACHSERRA=1
 .D ^ACHSEOBG         ;PLACE ERROR IN ERROR GLOBAL 
 .D K^ACHSAJ1
 Q
 ;
C0 ;
 I $D(ACHSISAO) G C1
 S Y=$$DIR^XBDIR("D^::E","Enter Date Document Paid","","","","",2)
 G B2:$D(DUOUT)
 I $D(DTOUT) D ENDC^ACHSAJ1 Q
 S ACHSEOBD=Y,ACHSPDAT=ACHSEOBD
C01 ;
 W !!
 S ACHSJERR=0
 ;
 ;IF 'DOCUMENT DESTINATION' IS IHS THEN get a sequence number
 I $$DOC^ACHS(0,17)="I" S ACHSPSQN=$G(^ACHSF(DUZ(2),"SEQN"))+1,^ACHSF(DUZ(2),"SEQN")=ACHSPSQN G C02
 ;
 S Y=$$DIR^XBDIR("N","Enter Sequence Number From EOBR","","","","",2)
 G C0:$D(DUOUT)
 I $D(DTOUT) D ENDC^ACHSAJ1 Q
 S ACHSPSQN=Y
C02 ;
 ;IF ENRTY IN EOBR DATE X-REF THEN THE TRANSACTION HAS BEEN PROCESSED
 I '$D(ACHSISAO),$D(^ACHSF(DUZ(2),"D",ACHSDIEN,"EB1",ACHSPDAT)) D  I $G(ACHSJERR) D ENDC^ACHSAJ1 Q
 . W !!,*7,*7,"A Transaction Has Been Processed For This Document On This Date.",!!?15,$$FMTE^XLFDT(ACHSPDAT),!!
 . S Y=$$DIR^XBDIR("Y","Do You Wish To Continue","N")
 . I ('Y)!$D(DUOUT)!$D(DTOUT) S ACHSJERR=1
 ;
 S ACHSPIND="F"
 ;
 ;IF DOCUMENT DESTINATION IHS
 I $$DOC^ACHS(0,17)="I" G C1
 ;
C03 ; EOBR Services billed.
 D DIR("9002080.02,19^O",$$SET(9002080.02,19,$G(ACHSSV)))
 I $D(DTOUT) D ENDC^ACHSAJ1 Q
 G B2:$D(DUOUT)
 S ACHSSV=Y
 ;
C04 ; EOBR Control Number.
 D DIR("9002080.02,16^O",$G(ACHSCTL))
 I $D(DTOUT) D ENDC^ACHSAJ1 Q
 G C03:$D(DUOUT)
 S ACHSCTL=Y
 ;
C05 ; EOBR Check number.
 D DIR("9002080.02,17^O",$G(ACHSCHK))
 I $D(DTOUT) D ENDC^ACHSAJ1 Q
 G C04:$D(DUOUT)
 S ACHSCHK=Y
 ;
C06 ; EOBR Remittance number.
 D DIR("9002080.02,18^O",$G(ACHSREM))
 I $D(DTOUT) D ENDC^ACHSAJ1 Q
 G C05:$D(DUOUT)
 S ACHSREM=Y
 ;
C07 ; EOBR Oblication type.
 D DIR("9002080.02,20^O",$$SET(9002080.02,20,$G(ACHSOB)))
 I $D(DTOUT) D ENDC^ACHSAJ1 Q
 G C06:$D(DUOUT)
 S ACHSOB=Y
 ;
C1 ; Adjustment to 3rd party payment.
 I $D(ACHSISAO) S Y=$G(ACHS3RDP) G C1A
 ;ACHS*3.1*14 7/25/2008 IHS/OIT/FCJ BY CALLING DIR, IT DID NOT ALLOW FOR A NEG ADJUSTMENT, ADDED LINE W/DIRECT DIR CALL
 ;D DIR("9002080.02,7^0",$G(ACHS3TAJ))
 S DIR("A")="THIRD PARTY PAY AMT",DIR(0)="N^"_-ACHS3PA_":99999:2",DIR("B")=$G(ACHS3TAJ) D ^DIR K DIR
 I $D(DTOUT) D ENDC^ACHSAJ1 Q
 G C07:$D(DUOUT)
 S ACHS3TAJ=Y
C1A ;
 S ACHS3AJ=ACHS3PA+Y,ACHS3TAJ=Y
OK ; Ask for confirmation.
 G D1^ACHSAJ1:$D(ACHSISAO)
 G D1^ACHSAJ1:$$DIR^XBDIR("Y","Is everything correct","NO","","","",2)
 G B2
 ;
DIR(ACHS,ACHS1) ; ( <DIR(0)> , <DIR("B")> )
 W !
 K DIR,DUOUT,DTOUT,DIRUT
 S DIR(0)=ACHS
 I $L($G(ACHS1)) S DIR("B")=ACHS1
 D ^DIR
 K DIR
 Q
 ;
 ;11/29/01  pmf  replace this line   ET(X,Y,Z) ; (File,Field,Internal) Return the external form of a set element. ACHS*3.1*1
SET(X,Y,Z) ; (File,Field,Internal) Return the external form of a set element. ; ACHS*3.1*1
 S %=$P($G(^DD(X,Y,0)),U,3)
 F X=1:1 S Y=$P(%,";",X) Q:Y=""  I $P(Y,":")=Z S Y=$P(Y,":",2) Q
 Q Y
 ;