source: WorldVistAEHR/trunk/r/ACCOUNTS_RECEIVABLE-PRCA-PRY-RC/RCDMBWLA.m@ 1582

Last change on this file since 1582 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 4.5 KB
RevLine 
[613]1RCDMBWLA ;WISC/RFJ-diagnostic measures workload report (build it) (Cont.) ;1 Jan 01
2 ;;4.5;Accounts Receivable;**167,171**;Mar 20, 1995
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 Q
5 ;
6RECTYP ; screen on receivable type
7 I ($P(RCDATA2,"^",8)'="")&($P(RCDATA2,"^",8)'=5) D
8 . S RCIFSTAT=RCIFSTAT_"I RCRECTYP="_$P(RCDATA2,"^",8)_" "
9 . S RCIFDESC=RCIFDESC_"[RECEIVABLE TYPE equals "_$S($P(RCDATA2,"^",8)=1:"INPATIENT",$P(RCDATA2,"^",8)=2:"OUTPATIENT",$P(RCDATA2,"^",8)=3:"PROSTHETICS",$P(RCDATA2,"^",8)=4:"PHARMACY REFILL",$P(RCDATA2,"^",8)=5:"ALL RECEIVABLES")_"]"
10 Q
11 ;
12 ;
13BUILDIF ; build if statement by clerk
14 S ^TMP("RCDMBWLR",$J,RCCLERK,RCASSIGN,"IF")=RCIFSTAT
15 S ^TMP("RCDMBWLR",$J,RCCLERK,RCASSIGN,"DESC")=RCIFDESC
16 Q
17 ;
18 ;
19PAYDAYS(RCBILLDA) ; return number of days since last payment
20 N DATA1,DAYS,RCDATE,RCTRANDA
21 ; loop all transactions in reverse order until you find last payment
22 S RCDATE=0
23 S RCTRANDA=99999999999 F S RCTRANDA=$O(^PRCA(433,"C",RCBILLDA,RCTRANDA),-1) Q:'RCTRANDA D I RCDATE Q
24 . S DATA1=$G(^PRCA(433,RCTRANDA,1))
25 . ; not a payment transaction
26 . I $P(DATA1,"^",2)'=2,$P(DATA1,"^",2)'=34 Q
27 . ; get the transaction date
28 . S RCDATE=+$P($P(DATA1,"^",9),".")
29 ;
30 ; if payment not found, use date bill activated
31 ; if there is a problem with AR and the bill does not have an
32 ; activation date, use default 1/1/1990
33 I 'RCDATE S RCDATE=+$P($P($G(^PRCA(430,RCBILLDA,6)),"^",21),".") I 'RCDATE S RCDATE=2900101
34 ;
35 ; calculate the number of days from today
36 S DAYS=$$FMDIFF^XLFDT(DT,RCDATE)
37 Q DAYS
38 ;
39 ;
40TRANDAYS(RCBILLDA) ; return number of days since last transaction
41 N DAYS,RCDATE,RCTRANDA
42 ; get the last transaction date
43 S RCTRANDA=+$O(^PRCA(433,"C",RCBILLDA,999999999999),-1)
44 ; get the transaction date
45 S RCDATE=+$P($P($G(^PRCA(433,RCTRANDA,1)),"^",9),".")
46 ;
47 ; if transaction not found, use date bill activated
48 ; if there is a problem with AR and the bill does not have an
49 ; activation date, use default 1/1/1990
50 I 'RCDATE S RCDATE=+$P($P($G(^PRCA(430,RCBILLDA,6)),"^",21),".") I 'RCDATE S RCDATE=2900101
51 ;
52 ; calculate the number of days from today
53 S DAYS=$$FMDIFF^XLFDT(DT,RCDATE)
54 Q DAYS
55 ;
56PTNAM(RCBILLDA) ; return patient name if third party
57 S (RCPTNAM,RCSSN)=""
58 N IBFOTP,IBBCAT,IBZ
59 S IBBCAT=$P(RCDATA0,"^",2) Q:'IBBCAT "^"
60 S IBFOTP=$$CATTYP^IBJD1(IBBCAT)
61 I IBFOTP="T" D
62 . I '$D(^DGCR(399,RCBILLDA,0)) Q
63 . S IBZ=^DGCR(399,RCBILLDA,0),DFN=+$P(IBZ,"^",2)
64 . D DEM^VADPT S RCPTNAM=VADM(1),RCSSN=+VADM(2)
65 Q (RCPTNAM_"^"_RCSSN)
66 ;
67LOOP ; loop all active bills and put them into the assignment list
68 N RCPTNAM,RCSSN,RCX,RCRECTYP,RCY,RCCLDAT0
69 S RCBILLDA=0 F S RCBILLDA=$O(^PRCA(430,"AC",16,RCBILLDA)) Q:'RCBILLDA D
70 . ; get the data from the bill file
71 . S RCDATA0=$G(^PRCA(430,RCBILLDA,0)) I RCDATA0="" Q
72 . S RCDATA6=$G(^PRCA(430,RCBILLDA,6)) S RCRC=$P(RCDATA6,"^",4)
73 . S RCDATA7=$G(^PRCA(430,RCBILLDA,7))
74 . S RCBALANC=$P(RCDATA7,"^")+$P(RCDATA7,"^",2)+$P(RCDATA7,"^",3)+$P(RCDATA7,"^",4)+$P(RCDATA7,"^",5)
75 . ; get the data for the debtor
76 . K RCDPDATA
77 . D DIQ340^RCDPAPLM(+$P(RCDATA0,"^",9),.01)
78 . S RCNAME=$G(RCDPDATA(340,+$P(RCDATA0,"^",9),.01,"E")) I RCNAME="" S RCNAME=" "
79 . S RCDEBT=$G(RCDPDATA(340,+$P(RCDATA0,"^",9),.01,"I"))
80 . ; get the patient name and SSN if third party bill
81 . S RCY=$$PTNAM^RCDMBWLA(RCBILLDA)
82 . S RCPTNAM=$P(RCY,"^"),RCSSN=$P(RCY,"^",2)
83 . ; get the ssn-first party
84 . I $G(RCDPDATA(340,+$P(RCDATA0,"^",9),.01,"I"))["DPT" S RCSSN=$P($G(^DPT(+$G(RCDPDATA(340,+$P(RCDATA0,"^",9),.01,"I")),0)),"^",9)
85 . S RCSSN=$E($E(RCSSN,6,9)_" ",1,4)
86 . ; test for date of death
87 . S RCFDEATH=0
88 . I $G(RCDPDATA(340,+$P(RCDATA0,"^",9),.01,"I"))["DPT(",$G(^DPT(+$G(RCDPDATA(340,+$P(RCDATA0,"^",9),.01,"I")),.35)) S RCFDEATH=1
89 . ; get the receivable type
90 . S RCCLDAT0=$G(^DGCR(399,RCBILLDA,0))
91 . S RCX=$$BTYP^IBCOIVM1(RCBILLDA,RCCLDAT0)
92 . S RCRECTYP=$S(RCX="I":1,RCX="O":2,RCX="P":3,RCX="R":4,1:"")
93 . ;
94 . ; loop assignments and see if they should appear on the clerks list
95 . S RCCLERK=0 F S RCCLERK=$O(^TMP("RCDMBWLR",$J,RCCLERK)) Q:'RCCLERK D
96 . . S RCASSIGN=0 F S RCASSIGN=$O(^TMP("RCDMBWLR",$J,RCCLERK,RCASSIGN)) Q:'RCASSIGN D
97 . . . S RCIFSTAT=^TMP("RCDMBWLR",$J,RCCLERK,RCASSIGN,"IF")
98 . . . X RCIFSTAT
99 . . . I $T D
100 . . . . I $D(^TMP($J,RCCLERK,RCBILLDA)) Q
101 . . . . S RCDEBTDA=+$P(RCDATA0,"^",9)
102 . . . . S ^TMP("RCDMBWLR",$J,RCCLERK,RCASSIGN,"IF",$E(RCNAME,1,30),RCDEBTDA,RCBILLDA)=RCSSN_"^"_RCFDEATH_"^"_RCBALANC_"^"_RCPTNAM
103 . . . . S ^TMP($J,RCCLERK,RCBILLDA)=""
104 Q
105 ;
Note: See TracBrowser for help on using the repository browser.