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

PRCAFN.m

Go to the documentation of this file.
  1. PRCAFN ;WASH-ISC@ALTOONA,PA/RGY-Functions to return AR data ;4/3/95 8:24 AM
  1. V ;;4.5;Accounts Receivable;**2,48,120,144**;Mar 20, 1995
  1. ;;Per VHA Directive 10-93-142, this routine should not be modified.
  1. ;
  1. ;Note: These functions are only valid for non-patient and non-
  1. ;means test patient bills. The category type of the bill
  1. ;must not be a PATIENT or MEANS TEST PATIENT type for these
  1. ;functions to work. (Except for the PST, PUR, and CATN functions).
  1. ;
  1. ;Note: All functions return a -1 if unable to determine
  1. ;
  1. BN(Y) ;Input: Internal Bill #
  1. ;Return: Action number or -1
  1. D CHK I Y>0 S Y=$S('$D(Y)#2:-1,Y="":-1,1:$P($G(^PRCA(430,Y,0)),"^")) S:Y="" Y=-1
  1. Q Y
  1. ;
  1. CAT(Y) ;Input: Internal Bill #
  1. ;Return: Category #^Category name^Category Type or -1
  1. ;
  1. D CHK I Y>0 S Y=$S('$D(Y)#2:-1,Y="":-1,1:$G(^PRCA(430.2,+$P($G(^PRCA(430,Y,0)),"^",2),0))) S:Y="" Y=-1 S:Y'=-1 Y=$P(Y,"^",7)_"^"_$P(Y,"^")_"^"_$P(Y,"^",6)
  1. Q Y
  1. CATN(Y) ;Input: Category Internal Number (430.2)
  1. ;Return: Category #^Category name^Category Type or -1
  1. S Y=$S('$D(Y)#2:-1,1:$G(^PRCA(430.2,+Y,0))) S:Y="" Y=-1 S:Y'=-1 Y=$P(Y,"^",7)_"^"_$P(Y,"^")_"^"_$P(Y,"^",6)
  1. Q Y
  1. ;
  1. TPR(Y) ;Input: Internal Bill #
  1. ;Return: Total paid principal or -1
  1. D CHK I Y>0 S Y=$S('$D(Y)#2:-1,Y="":-1,1:+$P($G(^PRCA(430,Y,7)),"^",7))
  1. Q Y
  1. ;
  1. ORI(Y) ;Input: Internal Bill #
  1. ;Return: Original amount or -1
  1. D CHK I Y>0 S Y=$S('$D(Y)#2:-1,Y="":-1,$G(^PRCA(430,Y,0))="":-1,1:+$P(^(0),"^",3))
  1. Q Y
  1. ;
  1. STA(Y) ;Input: Internal Bill #
  1. ;Return: Status #^Status name or -1
  1. D CHK I Y'=-1 S Y=$S('$D(Y)#2:-1,Y="":-1,1:$G(^PRCA(430.3,+$P($G(^PRCA(430,Y,0)),"^",8),0))) S:Y="" Y=-1 S:Y'=-1 Y=$P(Y,"^",3)_"^"_$P(Y,"^")
  1. Q Y
  1. ;
  1. ;
  1. CLO(BILLDA) ; input: internal bill #
  1. ; return: date the bill was closed
  1. ; -1 for patient or means test
  1. ; -2 if bill not closed
  1. ;
  1. N DATE,STAT,TYPE
  1. ; if type of bill category is for patient or means test quit -1
  1. S TYPE=$P($G(^PRCA(430.2,+$P($G(^PRCA(430,BILLDA,0)),"^",2),0)),"^",6)
  1. I TYPE="P"!(TYPE="C") Q -1
  1. ;
  1. ; do not look at bills never activated
  1. ;I '$P($P($G(^PRCA(430,BILLDA,6)),"^",21),".") Q -2
  1. ;
  1. ; bill not closed
  1. S STAT=$P($G(^PRCA(430,BILLDA,0)),"^",8)
  1. I STAT'=22,STAT'=23,STAT'=26,STAT'=39,STAT'=48,STAT'=49 Q -2
  1. ;
  1. S DATE=$P($G(^PRCA(430,BILLDA,0)),"^",14)
  1. Q DATE
  1. ;
  1. ;
  1. PST(Y) ;
  1. Q $$PST^RCAMFN01($G(Y))
  1. CHK ;
  1. S Y=$S('$D(Y)#2:-1,",C,P,"[(","_$P($G(^PRCA(430.2,+$P($G(^PRCA(430,+Y,0)),"^",2),0)),"^",6)_","):-1,1:Y)
  1. Q
  1. PUR(Y) ;Input: Internal Bill #
  1. ;Return: Date Bill can be purged (FM format) or
  1. ;Return: -1 Do Not Purge
  1. ;Return: -2 Purge but no Date, does not exist or Archived
  1. NEW BN0,X,Z,LST
  1. I $G(Y)="" S Y=-1 G PURQ
  1. S BN0=$G(^PRCA(430,Y,0)) I BN0']"" S Y=-2 G PURQ
  1. I "^220^102^110^104^112^107^113^240^230^205^"[("^"_$P($G(^PRCA(430.3,+$P(BN0,"^",8),0)),"^",3)_"^") S Y=-1 G PURQ
  1. I $P($G(^PRCA(430.3,+$P(BN0,"^",8),0)),"^",3)=115 S Y=-2 G PURQ
  1. S Z=0 F X=0:0 S X=$O(^PRCA(433,"C",Y,X)) Q:'X S Z=$S(+$P($G(^PRCA(433,X,1)),"^",9):$P(^(1),"^",9),1:+$G(^PRCA(433,X,1)))
  1. I Z S LST(9999999-Z)=""
  1. S Z=$G(^PRCA(430,Y,6)) F X=3:-1:1 I $P(Z,"^",X) S LST(9999999-$P(Z,"^",X))="" Q
  1. S LST(9999999-$P(BN0,U,10))=""
  1. S Z=9999999-$O(LST(0)) S:'Z Z=-2
  1. S Y=Z
  1. PURQ Q $P(Y,".")
  1. RETN(Y) ;Input: Internal Bill #
  1. ;Return: 1 if bill was returned to IB, 0 if bill was not returned to IB
  1. Q ",220,"[(","_$P($G(^PRCA(430.3,+$P($G(^PRCA(430,+Y,0)),"^",8),0)),"^",3)_",")
  1. BAL(DEBT) ;Input: IEN of file 340 or Varable ptr value of debtor
  1. NEW STAT,X,Y,TOTAL,BILL,BAT,TRAN
  1. S TOTAL="-"
  1. I $G(DEBT)'?1N.N,$G(DEBT)'?1N.N1";".A1"(" G Q8
  1. I DEBT?1N.N1";".E S DEBT=$$DEBT^RCEVUTL(DEBT) ;+$O(^RCD(340,"B",DEBT,0))
  1. I $G(^RCD(340,DEBT,0))="" G Q8
  1. S TOTAL=0
  1. F STAT=$O(^PRCA(430.3,"AC",102,0)),$O(^PRCA(430.3,"AC",107,0)),$O(^PRCA(430.3,"AC",112,0)) F BILL=0:0 S BILL=$O(^PRCA(430,"AS",DEBT,STAT,BILL)) Q:'BILL D:$G(^PRCA(430,BILL,0))]""
  1. .S X=$G(^PRCA(430,BILL,7)),Y=$P(X,"^")+$P(X,"^",2)+$P(X,"^",3)+$P(X,"^",4)+$P(X,"^",5)
  1. .I $P(^PRCA(430,BILL,0),"^",2)=$O(^PRCA(430.2,"AC",33,0)) S Y=-Y
  1. .S TOTAL=TOTAL+$S($P(^PRCA(430,BILL,0),"^",2)=$O(^PRCA(430.2,"AC",33,0))&(STAT'=$O(^PRCA(430.3,"AC",112,0))):0,1:Y)
  1. .Q
  1. S DEBT=$P(^RCD(340,DEBT,0),"^")
  1. F BAT=0:0 S BAT=$O(^RCY(344,"AC",DEBT,BAT)) Q:'BAT F TRAN=0:0 S TRAN=$O(^RCY(344,"AC",DEBT,BAT,TRAN)) Q:'TRAN I $G(^RCY(344,BAT,1,TRAN,0))]"",$P(^(0),"^",5)="" S TOTAL=TOTAL-$P(^(0),"^",4)
  1. Q8 Q TOTAL
  1. ;
  1. BN1(Y) ;Input: Internal Bill #
  1. ;Return: Action number or -1
  1. S Y=$S('$D(Y)#2:-1,Y="":-1,1:$P($G(^PRCA(430,Y,0)),"^")) S:Y="" Y=-1
  1. Q Y