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

RCRJRCOC.m

Go to the documentation of this file.
  1. RCRJRCOC ;WISC/RFJ/BGJ-count current receivables ; 11/2/10 10:53am
  1. ;;4.5;Accounts Receivable;**156,170,182,203,220,138,239,272,273,334,335,338**;Mar 20, 1995;Build 69
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ; IA 4385 for call to $$MRATYPE^IBCEMU2
  1. Q
  1. ;
  1. ;
  1. CURRENT(RCBILLDA,RCVALUE) ; count current bills balance
  1. ; rcvalue = prin ^ int ^ admin ^ mf ^ cc
  1. ;
  1. N %,RCFUND,RCRSC,RCTOHSIF,RCTOMCCF,SGL,TYPE,MRATYPE,ARACTDT,CATEGORY,RCRHITYP,RCCATNM
  1. ;
  1. ; calculate the rsc for the bill. the rsc is only used for
  1. ; mccf bills
  1. S RCRSC=""
  1. ;PRCA*4.5*338 - Modified the code to only recalculate RSCs if none currently calculated.
  1. S RCRSC=$$GET1^DIQ(430,BILLDA_",",255)
  1. S:RCRSC="" RCRSC=$$GET1^DIQ(430,BILLDA_",",255.1)
  1. I $$ACCK^PRCAACC(RCBILLDA) S:RCRSC="" RCRSC=$$CALCRSC^RCXFMSUR(RCBILLDA)
  1. ;
  1. ; calculate the amount that goes to mccf and hsif
  1. D MCCFHSIF(RCBILLDA,RCVALUE,RCRSC,DATEEND+1)
  1. ;
  1. ; store the data for the ndb, if a 0 is returned by the function,
  1. ; then the bill has already been counted as a current receivable,quit
  1. I '$$NDBSTORE(RCBILLDA,RCVALUE,1) Q
  1. ;
  1. ; store results for FMS SV document for accrued bills only
  1. ; do not include prepayments (26)
  1. I $$ACCK^PRCAACC(RCBILLDA),$P($G(^PRCA(430,RCBILLDA,0)),"^",2)'=26 D
  1. . ; get the bills fund and category
  1. . ;PRCA*4.5*338 Calculate fund only if it is not stored in the bill
  1. . S RCFUND=$$GET1^DIQ(430,BILLDA_",",203)
  1. . I RCFUND="" S RCFUND=$$GETFUNDB^RCXFMSUF(BILLDA,1)
  1. . ;end PRCA*4.5*338
  1. . S RCFUND=$$ADJFUND^RCRJRCO(RCFUND) ; may remove the line after 10/1/03
  1. . S CATEGORY=+$P($G(^PRCA(430,RCBILLDA,0)),"^",2),RCCATNM=$$GET1^DIQ(430.2,CATEGORY_",",.01) ; retrieve CAT name PRCA*4.5*338
  1. . ;
  1. . ; ----- this code is used to set up the SV code sheet -----
  1. . S TYPE=21
  1. . ; special type for tort feasor
  1. . I RCCATNM["TORT" S TYPE="2A" ;Using the category name to look for TORTs - PRCA*4.5*338
  1. . ;
  1. . ; Get ARACTDT=AR Date Active for bill
  1. . S ARACTDT=+$P($P($G(^PRCA(430,RCBILLDA,6)),"^",21),".")
  1. . ; determine Receivable Type: 1=pre-MRA, 2=post-MRA Medicre, 3=post-MRA non-Medicare
  1. . ; DBIA #4385 activated on 31-Mar-2004
  1. . S MRATYPE=$$MRATYPE^IBCEMU2(RCBILLDA,ARACTDT)
  1. . ; set TYPE to 2F for post-MRA Medicare bills or to 2L for
  1. . ; post-MRA non-Medicare bills (for RHI receivables only)
  1. . ; PRCA*4.5*338 moved TYPE set for RHI to function call to ensure Community Care RSCs are captured correctly.
  1. . S RCRHITYP=$$RHITYPE(RCRSC,MRATYPE,RCCATNM) S:+RCRHITYP TYPE=$P(RCRHITYP,U,2)
  1. . ;
  1. . ; store dollars to mccf and hsif
  1. . I RCTOMCCF S ^TMP($J,"RCRJRCOLSV",TYPE,RCFUND,RCRSC)=$G(^TMP($J,"RCRJRCOLSV",TYPE,RCFUND,RCRSC))+RCTOMCCF
  1. . I RCTOHSIF S ^TMP($J,"RCRJRCOLSV",21,5358.1,$S(RCRSC="8BZZ":"8B1Z",1:"8C1Z"))=$G(^TMP($J,"RCRJRCOLSV",21,5358.1,$S(RCRSC="8BZZ":"8B1Z",1:"8C1Z")))+RCTOHSIF
  1. . ;
  1. . ; ----- this code is used to build the user report
  1. . S %=+$P($P($G(^PRCA(430,RCBILLDA,6)),"^",21),".")
  1. . S ^TMP($J,"RCRJRCOLREPORT",%,RCBILLDA)=$P(RCVALUE,"^")_"^"_($P(RCVALUE,"^",2)+$P(RCVALUE,"^",3)+$P(RCVALUE,"^",4)+$P(RCVALUE,"^",5))_"^SV"_TYPE
  1. . I RCTOMCCF D STORE^RCRJRCOU(BILLDA,DATEBEG,DATEEND,ARACTDT,CATEGORY,"SV"_TYPE,RCFUND,RCRSC,RCVALUE)
  1. . I RCTOHSIF D STORE^RCRJRCOU(BILLDA,DATEBEG,DATEEND,ARACTDT,CATEGORY,"SV21","5358.1",$S(RCRSC="8BZZ":"8B1Z",1:"8C1Z"),RCVALUE)
  1. . ;
  1. . ; ----- this code is used to build the OIG extract, piece 3 = GL acct
  1. . S ^TMP($J,"RCRJROIG",RCBILLDA)=$P(RCVALUE,"^")_"^"_($P(RCVALUE,"^",2)+$P(RCVALUE,"^",3)+$P(RCVALUE,"^",4)+$P(RCVALUE,"^",5))_"^"_$S(TYPE="2A":1333,TYPE="2F":"13H1",TYPE="2L":"13N1",1:1311)
  1. . ;
  1. . ; ----- this code is used to set up medicare supplemental SVs
  1. . S %=$G(^PRCA(430,RCBILLDA,13))
  1. . ; medicare contract adjustment field 131 for bills activated in AR during the month the ARDC is running
  1. . I $P(%,"^",1),ARACTDT'<DATEBEG D ;
  1. . . S ^TMP($J,"RCRJRCOLSV",17)=$G(^TMP($J,"RCRJRCOLSV",17))+$P(%,"^",1)
  1. . . S ^TMP($J,"RCRJRCOLSV",17,RCFUND,RCRSC)=$G(^TMP($J,"RCRJRCOLSV",17,RCFUND,RCRSC))+$P(%,"^",1)
  1. . ; medicare unreimbursable medicare expense field 132 for bills activated in AR during the month the ARDC is running
  1. . I $P(%,"^",2),ARACTDT'<DATEBEG D ;
  1. . . S ^TMP($J,"RCRJRCOLSV",18)=$G(^TMP($J,"RCRJRCOLSV",18))+$P(%,"^",2)
  1. . . S ^TMP($J,"RCRJRCOLSV",18,RCFUND,RCRSC)=$G(^TMP($J,"RCRJRCOLSV",18,RCFUND,RCRSC))+$P(%,"^",2)
  1. . ;
  1. . ; ----- this code is used to set up the bad debt report -----
  1. . S SGL=$$BDRSGL^RCRJRBD(CATEGORY,RCFUND,MRATYPE)
  1. . ; store dollars to mccf and hsif. both are sgl 1319 so 1319.1 is
  1. . ; used to put hsif in a subset of 1319
  1. . I RCTOMCCF S ^TMP($J,"RCRJRBD",SGL)=$G(^TMP($J,"RCRJRBD",SGL))+RCTOMCCF
  1. . I RCTOHSIF S ^TMP($J,"RCRJRBD",1319.1)=$G(^TMP($J,"RCRJRBD",1319.1))+RCTOHSIF
  1. ;
  1. ; store the interest, admin, mf, cc on the SV code sheet
  1. ; interest (type P2; fund 1435; rsc 8047)
  1. I $P(RCVALUE,"^",2) S ^TMP($J,"RCRJRCOLSV","P2",1435,8047)=$G(^TMP($J,"RCRJRCOLSV","P2",1435,8047))+$P(RCVALUE,"^",2)
  1. ; admin (type P2; fund 3220; rsc 8046)
  1. I $P(RCVALUE,"^",3) S ^TMP($J,"RCRJRCOLSV","P2",3220,8046)=$G(^TMP($J,"RCRJRCOLSV","P2",3220,8046))+$P(RCVALUE,"^",3)
  1. ; mf + cc (type P2; fund 0869; rsc 8048)
  1. S %=$P(RCVALUE,"^",4)+$P(RCVALUE,"^",5)
  1. I % S ^TMP($J,"RCRJRCOLSV","P2","0869",8048)=$G(^TMP($J,"RCRJRCOLSV","P2","0869",8048))+%
  1. Q
  1. ;
  1. RHITYPE(RCRSC,MRATYPE,RCCATNM) ;
  1. ; Input - RCRSC - Revenue Source Code from a Bill
  1. ; RCMRATYP - Type of MRA as determined by the call to $$MRATYPE^IBCEMU2
  1. ; Output - Is it a RHI Bill (0 - No, 1 - Yes) ^ SV Type to return (2F or 2L) [required if an RHI Bill]
  1. ;
  1. N RCTYPE
  1. S RCTYPE=0
  1. I MRATYPE>1 D
  1. . Q:RCRSC="85CC" ; This specific RSC is a TORT RSC for the CHOICE program
  1. . I $E(RCRSC,1,2)=85!($E(RCRSC,1,2)="8R") S RCTYPE="1^"_$S(MRATYPE=2:"2F",1:"2L") Q
  1. . I RCCATNM["THIRD PARTY" D Q
  1. . . Q:RCCATNM["CHAMPVA" ;Exclude CHAMPVA
  1. . . Q:RCCATNM["TRICARE" ;Exclude TRICARE
  1. . . ;otherwise this is a Community Care Bill, set the SV type
  1. . . S RCTYPE="1^"_$S(MRATYPE=2:"2F",1:"2L")
  1. Q RCTYPE
  1. ;
  1. WRITEOFF(RCBILLDA,RCVALUE,RCRITER2) ; count write offs
  1. ; rcvalue = prin ^ int ^ admin ^ mf ^ cc
  1. ; rcriter2 = write off criteria tracked in ndb
  1. ;
  1. N %,RCFUND,RCRSC,RCTOHSIF,RCTOMCCF,TYPE,MRATYPE,ARACTDT
  1. ;
  1. ; calculate the rsc for the bill. the rsc is only used for
  1. ; mccf bills
  1. S RCRSC=""
  1. ;PRCA*4.5*338 - Modified the code to only recalculate RSCs if none currently calculated.
  1. S RCRSC=$$GET1^DIQ(430,BILLDA_",",255)
  1. S:RCRSC="" RCRSC=$$GET1^DIQ(430,BILLDA_",",255.1)
  1. I $$ACCK^PRCAACC(RCBILLDA) S:RCRSC="" RCRSC=$$CALCRSC^RCXFMSUR(RCBILLDA)
  1. ;
  1. ; calculate the amount that goes to mccf and hsif
  1. D MCCFHSIF(RCBILLDA,RCVALUE,RCRSC,DATEEND+1)
  1. ;
  1. ; store the data for the ndb, if a 0 is returned by the function,
  1. ; then the bill has already been counted as a current receivable,quit
  1. I '$$NDBSTORE(RCBILLDA,RCVALUE,RCRITER2) Q
  1. ;
  1. ; store results for FMS WR document
  1. ; do not include prepayments (26)
  1. I $$ACCK^PRCAACC(RCBILLDA),$P($G(^PRCA(430,RCBILLDA,0)),"^",2)'=26 D
  1. . ; get the bills fund
  1. . ;PRCA*4.5*338 Calculate fund only if it is not stored in the bill
  1. . S RCFUND=$$GET1^DIQ(430,BILLDA_",",203)
  1. . I RCFUND="" S RCFUND=$$GETFUNDB^RCXFMSUF(BILLDA,1)
  1. . ;end PRCA*4.5*338
  1. . S RCFUND=$$ADJFUND^RCRJRCO(RCFUND) ; may remove the line after 10/1/03
  1. . S CATEGORY=+$P($G(^PRCA(430,RCBILLDA,0)),"^",2),RCCATNM=$$GET1^DIQ(430.2,CATEGORY_",",.01) ; retrieve CAT name PRCA*4.5*338
  1. . ;
  1. . S TYPE=37
  1. . ; special type for tort feasor
  1. . I RCCATNM["TORT" S TYPE="39" ;Using the category name to look for TORTs - PRCA*4.5*338
  1. . S ARACTDT=+$P($P($G(^PRCA(430,RCBILLDA,6)),"^",21),".")
  1. . ; DBIA #4385 activated on 31-Mar-2004
  1. . S MRATYPE=$$MRATYPE^IBCEMU2(RCBILLDA,ARACTDT)
  1. . ; for contract adjustments (criter2=22), the type is 38 for pre-
  1. . ; MRA, 4N for post-MRA non-Medicare and 08 for post-MRA Medicare
  1. . I RCRITER2=22 S TYPE=$S(MRATYPE=1:38,MRATYPE=2:"08",1:"4N") ;Aging bucket increase modified in PRCA*4.5*334
  1. . ; store dollars to mccf and hsif
  1. . I RCTOMCCF S ^TMP($J,"RCRJRCOLWR",TYPE,RCFUND,RCRSC)=$G(^TMP($J,"RCRJRCOLWR",TYPE,RCFUND,RCRSC))+RCTOMCCF
  1. . I RCTOHSIF S ^TMP($J,"RCRJRCOLWR",TYPE,5358.1,$S(RCRSC="8BZZ":"8B1Z",1:"8C1Z"))=$G(^TMP($J,"RCRJRCOLWR",TYPE,5358.1,$S(RCRSC="8BZZ":"8B1Z",1:"8C1Z")))+RCTOHSIF
  1. ;
  1. ; store the interest, admin, mf, cc on the WR code sheet
  1. ; interest (type P4; fund 1435; rsc 8047)
  1. I $P(RCVALUE,"^",2) S ^TMP($J,"RCRJRCOLWR","P4",1435,8047)=$G(^TMP($J,"RCRJRCOLWR","P4",1435,8047))+$P(RCVALUE,"^",2)
  1. ; admin (type P4; fund 3220; rsc 8046)
  1. I $P(RCVALUE,"^",3) S ^TMP($J,"RCRJRCOLWR","P4",3220,8046)=$G(^TMP($J,"RCRJRCOLWR","P4",3220,8046))+$P(RCVALUE,"^",3)
  1. ; mf + cc (type P4; fund 0869; rsc 8048)
  1. S %=$P(RCVALUE,"^",4)+$P(RCVALUE,"^",5)
  1. I % S ^TMP($J,"RCRJRCOLWR","P4","0869",8048)=$G(^TMP($J,"RCRJRCOLWR","P4","0869",8048))+%
  1. Q
  1. ;
  1. ;
  1. NDBSTORE(RCBILLDA,RCVALUE,RCRITER2) ; store the data for the NDB
  1. ; returns a 1 if the bill has not been counted
  1. ; returns a 0 if the bill has been counted
  1. N %,CRITERIA
  1. ;
  1. ; this line of code will prevent duplicate counts if a sites cross
  1. ; references in file 430 (actdt and asdt) are duplicated (incorrect)
  1. I RCRITER2<15,$D(^TMP($J,"RCRJRCOL","COUNT",RCBILLDA,RCRITER2)) Q 0 ; Aging bucket increase modified in PRCA*4.5*334
  1. ;
  1. ; get a bills criteria 1,3,4,5
  1. S CRITERIA=$G(^TMP($J,"RCRJRCOL","CRITERIA",RCBILLDA))
  1. I CRITERIA="" S CRITERIA=$$CRITERIA^RCRJRCOL(RCBILLDA),^TMP($J,"RCRJRCOL","CRITERIA",RCBILLDA)=CRITERIA
  1. S $P(CRITERIA,"-",2)=RCRITER2
  1. ;
  1. ; store results for ndb
  1. S %=$G(@DATASTOR)
  1. S $P(%,"^")=$P(%,"^")+1
  1. S $P(%,"^",2)=$P(%,"^",2)+$P(RCVALUE,"^")
  1. S $P(%,"^",3)=$P(%,"^",3)+$P(RCVALUE,"^",2)+$P(RCVALUE,"^",3)+$P(RCVALUE,"^",4)+$P(RCVALUE,"^",5)
  1. S @DATASTOR=%
  1. ;
  1. ; keep a count of current receivables counted
  1. S ^TMP($J,"RCRJRCOL","COUNT",RCBILLDA,RCRITER2)=""
  1. S ^TMP($J,"RCRJRCOL","CRIT2",RCRITER2,RCBILLDA)=""
  1. Q 1
  1. ;
  1. ;
  1. MCCFHSIF(RCBILLDA,RCVALUE,RCRSC,ASOFDATE) ; calculate the amount that goes
  1. ;
  1. ; to mccf and hsif
  1. ;
  1. ; returns RCTOMCCF and RCTOHSIF as the outstanding balance to mccf
  1. ; and the outstanding balance to hsif
  1. N MCCFHSIF
  1. ;
  1. S RCTOMCCF=$P(RCVALUE,"^"),RCTOHSIF=0
  1. ;
  1. I $$NOHSIF^RCRJRCO() Q ; disabled HSIF
  1. ;
  1. ; if revenue source code is not 8BZZ or 8CZZ then it all goes to mccf
  1. I RCRSC="8BZZ"!(RCRSC="8CZZ") D
  1. . ; get the amount for each fund mccf and hsif
  1. . ; this call returns the total amount owed to mccf (piece 1),
  1. . ; total amount owed to hsif (piece 2), total amount paid
  1. . ; to mccf (piece 3), total amount paid to hsif (piece 4).
  1. . ; for outstanding balance you must subtract the payment in
  1. . ; pieces 3 and 4 which are returned as negative amounts.
  1. . S MCCFHSIF=$$BILLFUND^RCBMILLC(RCBILLDA,ASOFDATE)
  1. . S RCTOMCCF=$P(MCCFHSIF,"^",1)+$P(MCCFHSIF,"^",3)
  1. . S RCTOHSIF=$P(MCCFHSIF,"^",2)+$P(MCCFHSIF,"^",4)
  1. Q