source: FOIAVistA/trunk/r/INTEGRATED_BILLING-IB-PRQ--IBD--IBQ--PRQS/IBJDF11.m@ 1203

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

initial load of FOIAVistA 6/30/08 version

File size: 5.4 KB
Line 
1IBJDF11 ;ALB/CPM - THIRD PARTY FOLLOW-UP REPORT (COMPILE) ; 09-JAN-97
2 ;;2.0;INTEGRATED BILLING;**69,80,118,128,204,205,227**;21-MAR-94
3 ;
4DQ ; - Tasked entry point.
5 K ^TMP("IBJDF1",$J) S IBQ=0
6 ;
7 ; - Collect divisions when running the job for all divisions.
8 I IBSD,VAUTD S J=0 F S J=$O(^DG(40.8,J)) Q:'J S VAUTD(J)=""
9 ;
10 ; - Find data required for the report.
11 S IBA=0 F S IBA=$O(^PRCA(430,"AC",16,IBA)) Q:'IBA D Q:IBQ
12 .;
13 .I IBA#100=0 S IBQ=$$STOP^IBOUTL("Third Party Follow-Up Report") Q:IBQ
14 .;
15 .S IBAR=$G(^PRCA(430,IBA,0))
16 .I $P(IBAR,U,2)'=9 Q ; Not an RI bill.
17 .I '$D(^DGCR(399,IBA,0)) Q ; No corresponding claim to this AR.
18 .;
19 .; - Determine whether bill is inpatient, outpatient, or RX refill.
20 .S IBTYP=$P($G(^DGCR(399,IBA,0)),U,5),IBTYP=$S(IBTYP>2:2,1:1)
21 .S:$D(^IBA(362.4,"C",IBA)) IBTYP=3 I IBSEL'[IBTYP,IBSEL'[4 Q
22 .;
23 .; - Check the receivable age, if necessary.
24 .I IBSMN S:"Aa"[IBSDATE IBARD=$$ACT^IBJDF2(IBA) S:"Dd"[IBSDATE IBARD=$$DATE1^IBJDF2(IBA) Q:'IBARD S:IBARD IBARD=$$FMDIFF^XLFDT(DT,IBARD) I IBARD<IBSMN!(IBARD>IBSMX) Q
25 .;
26 .; - Check the minimum dollar amount, if necessary.
27 .S IBWBA=+$G(^PRCA(430,IBA,7)) I IBSAM,IBWBA<IBSAM Q
28 .;
29 .; - Get division, if necessary.
30 .I 'IBSD S IBDIV=0
31 .E S IBDIV=$$DIV^IBJDF2(IBA) I 'IBDIV S IBDIV=+$$PRIM^VASITE()
32 .I IBSD,'VAUTD Q:'$D(VAUTD(IBDIV)) ; Not a selected division.
33 .;
34 .; - Exclude receivables referred to Regional Counsel, if necessary.
35 .S IBWRC=$G(^PRCA(430,IBA,6)) I 'IBSRC,$P(IBWRC,U,4) Q
36 .S IBWRC=$S('$P(IBWRC,U,4):"",$P(IBWRC,U,22):$P(IBWRC,U,22),1:$P(IBWRC,U,4))
37 .;
38 .; - Get the insurance carrier and exclude claim, if necessary.
39 .S IBWIN=$$INS(IBA) I IBWIN="" Q
40 .;
41 .; - Get the claim patient and exclude claim, if necessary.
42 .S IBWPT=$$PAT(IBA) I IBWPT="" Q
43 .;
44 .; - Get remaining claim information.
45 .S IBWDP=$P(IBAR,U,10),IBWBN=$P(IBAR,U)
46 .S IBBU=$G(^DGCR(399,IBA,"U")),IBWFR=+IBBU,IBWTO=$P(IBBU,U,2)
47 .S IBWSC=$$OTH($P(IBWPT,U,5),$P(IBWIN,"@@",2),IBWFR),IBWOR=$P(IBAR,U,3)
48 .S IBWSI=$P($G(^DPT(+$P(IBWPT,U,5),.312,+$P($G(^DGCR(399,IBA,"MP")),U,2),0)),U,2)
49 .;
50 .; - Set up main report index.
51 .F X=IBTYP,4 I IBSEL[X D
52 ..S ^TMP("IBJDF1",$J,IBDIV,X,IBWIN,$P(IBWPT,U)_"@@"_$P(IBWPT,U,5),IBWDP_"@@"_IBWBN)=$P(IBWPT,U,2)_" ("_$P(IBWPT,U,4)_")"_U_$P(IBWPT,U,3)_U_IBWSC_U_IBWFR_U_IBWTO_U_IBWOR_U_IBWBA_"~"_IBWRC_U_IBWSI
53 .;
54 .; - Add bill comment history, if necessary.
55 .I IBSH D
56 ..S X=0 F S X=$O(^PRCA(433,"C",IBA,X)) Q:'X D
57 ...S Y=$G(^PRCA(433,X,1))
58 ...I $P(Y,U,2)'=35,$P(Y,U,2)'=45 Q ; Not a decrease/comment transact.
59 ...S DAT=$S(Y:+Y\1,1:+$P(Y,U,9)\1)
60 ...;
61 ...; - Append brief and transaction comments.
62 ...K COM,COM1 S COM(0)=DAT,X1=0
63 ...S COM1(1)=$P($G(^PRCA(433,X,5)),U,2),COM1(2)=$E($P($G(^(8)),U,6),1,70)
64 ...S COM(1)=COM1(1)_$S(COM1(1)]""&(COM1(2)]""):"|",1:"")_COM1(2)
65 ...I COM(1)]"" S COM(1)="**"_COM(1)_"**",X1=1
66 ...;
67 ...; - Get main comments.
68 ...S X2=0 F S X2=$O(^PRCA(433,X,7,X2)) Q:'X2 S COM($S(X1:X2+1,1:X2))=^(X2,0)
69 ...;
70 ...S X1="" F S X1=$O(COM(X1)) Q:X1="" F X2=IBTYP,4 I IBSEL[X2 D
71 ....S ^TMP("IBJDF1",$J,IBDIV,X2,IBWIN,$P(IBWPT,U)_"@@"_$P(IBWPT,U,5),IBWDP_"@@"_IBWBN,X,X1)=COM(X1)
72 ;
73 I 'IBQ D EN^IBJDF12 ; Print the report.
74 ;
75ENQ K ^TMP("IBJDF1",$J)
76 I $D(ZTQUEUED) S ZTREQ="@" G ENQ1
77 ;
78 D ^%ZISC
79ENQ1 K IBA,IBAR,IBARD,IBBU,IBDIV,IBQ,IBIO,IBWRC,IBWPT,IBWDP,IBWIN,IBWBN
80 K IBTYP,IBWSC,IBWSI,IBWFR,IBWTO,IBWOR,IBWBA,COM,COM1,DAT,VAUTD
81 K X,X1,X2,Y,Z
82 Q
83 ;
84INS(X) ; - Find the Insurance company and decide to include the claim.
85 ; Input: X=Pointer to the claim/AR in file #399/#430
86 ; plus all variable input in IBS*
87 ; Output: Y=Insurance Company name and pointer to file #36
88 ;
89 N Y,Z,Z1 S Y=""
90 I '$G(X) G INSQ
91 S Z=+$G(^DGCR(399,X,"MP")),Z1=$P($G(^DIC(36,Z,0)),U)
92 I $G(IBSI) G INSQ:'$D(IBSI(Z)),INSC
93 I IBSIF'="@",'Z G INSQ
94 I $D(IBSIA) G:IBSIA="ALL"&('Z) INSQ G:IBSIA="NULL"&(Z) INSQ
95 I Z1="" S Z1="UNKNOWN" G INSC
96 I $G(IBSIA)="ALL" G INSC
97 I IBSIF="@",IBSIL="zzzzz" G INSC
98 I IBSIF]Z1!(Z1]IBSIL) G INSQ
99 ;
100INSC S Y=Z1_"@@"_Z
101INSQ Q Y
102 ;
103PAT(X) ; - Find the claim patient and decide to include the claim.
104 ; Input: X=Pointer to the claim/AR in file #399/#430
105 ; plus all variable input in IBS*
106 ; Output: Y=1^2^3^4^5, where
107 ; 1 => sort key (name or last four)
108 ; 2 => patient name
109 ; 3 => patient ssn
110 ; 4 => patient age
111 ; 5 => patient pointer to file #2
112 ;
113 N AGE,DFN,DOB,KEY,Y,Z S Y=""
114 I '$G(X) G PATQ
115 S DFN=+$P($G(^DGCR(399,X,0)),U,2),Z=$G(^DPT(DFN,0))
116 S KEY=$S(IBSN="N":$P(Z,U),1:$E($P(Z,U,9),6,9))
117 ;
118 I IBSNF'="@",'DFN G PATQ
119 I $D(IBSNA) G:IBSNA="ALL"&('DFN) PATQ G:IBSNA="NULL"&(DFN) PATQ
120 I KEY="" S Y="UNK^UNK^UNK^UNK^UNK" G PATQ
121 I $G(IBSNA)="ALL" G PATC
122 I IBSNF="@",IBSNL="zzzzz" G PATC
123 I IBSNF]KEY!(KEY]IBSNL) G PATQ
124 ;
125PATC ; - Find all patient data.
126 S DOB=$P(Z,U,3)
127 S AGE=$S('DOB:"UNK",1:$E(DT,1,3)-$E(DOB,1,3)-($E(DT,4,7)<$E(DOB,4,7)))
128 S Y=KEY_U_$E($P(Z,U),1,17)_U_$P(Z,U,9)_U_AGE_U_DFN
129PATQ Q Y
130 ;
131OTH(DFN,INS,DS) ; - Find a patient's other valid insurance carrier (if any).
132 ; Input: DFN=Pointer to the patient in file #2
133 ; INS=Pointer to the patient's primary carrier in file #36
134 ; DS=Date of service for validity check
135 ; Output: Valid insurance carrier (1st 13 chars.) or null
136 ;
137 N Y S Y="" I '$G(DFN)!('$G(DS)) G OTHQ
138 S Z=0 F S Z=$O(^DPT(DFN,.312,Z)) Q:'Z S X=$G(^(Z,0)) D:X Q:Y]""
139 .I $G(INS),+X=INS Q
140 .S X1=$G(^DIC(36,+X,0)) I X1="" Q
141 .I $P(X1,U,2)'="N",$$CHK^IBCNS1(X,DS) S Y=$E($P(X1,U),1,13)
142 ;
143OTHQ Q Y
Note: See TracBrowser for help on using the repository browser.