IBJDF51 ;ALB/RB - CHAMPVA/TRICARE FOLLOW-UP REPORT (COMPILE);15-APR-00 ;;2.0;INTEGRATED BILLING;**123,185,240,356**;21-MAR-94 ;;Per VHA Directive 2004-038, this routine should not be modified. ; ST ; - Tasked entry point. K IB,^TMP("IBJDF5",$J) S IBQ=0 ; ; - Set selected categories for report. I IBSEL[1 S IBCAT(31)=1 I IBSEL[2 S IBCAT(19)=2 I IBSEL[3 S IBCAT(30)=3 I IBSEL[4 S IBCAT(32)=4 I IBSEL[5 S IBCAT(29)=5 I IBSEL[6 S IBCAT(28)=6 ; ; Initialize the Summary Information S IBCAT="" F S IBCAT=$O(IBCAT(IBCAT)) Q:IBCAT="" D . S IBDIV=0 . I IBSD,IBCAT'=31 D Q . . F S IBDIV=$O(VAUTD(IBDIV)) Q:IBDIV="" D INIT^IBJDF53 . D INIT^IBJDF53 ; ; - Print the header line for the Excel spreadsheet I $G(IBEXCEL) D PHDL ; ; - Find data required for the report. S IBA=0 F S IBA=$O(^PRCA(430,"AC",16,IBA)) Q:'IBA D Q:IBQ . I IBA#100=0 D Q:IBQ . . S IBQ=$$STOP^IBOUTL("CHAMPVA/Tricare Follow-Up Report") . S IBAR=$G(^PRCA(430,IBA,0)) Q:'IBAR . I $P($G(^DGCR(399,IBA,0)),U,13)=7 Q ; Cancelled claim. . S IBCAT=+$P(IBAR,U,2) Q:'$D(IBCAT(IBCAT)) ; Invalid AR category. . S IBCAT1=IBCAT(IBCAT) . ; . ; - Get division, if necessary. . I IBCAT1=1 S IBDIV=0 ; CHAMPVA/Tricare Patient . ; . I IBCAT1'=1 D ; Others . . I 'IBSD S IBDIV=0 Q . . S IBDIV=$$DIV(IBA) . ; . I IBSD,IBDIV,'VAUTD Q:'$D(VAUTD(IBDIV)) ; Not a selected division. . ; . ; - Determine whether AR has corresponding IB action or claim and . ; whether action/claim is inpatient, outpatient, or RX refill. . S IBAC=$$CLMACT^IBJD(IBA,IBCAT) Q:IBAC=""!(+IBAC=3) . I +IBAC=1 D . . S X=$P($G(^IB($P(IBAC,U,2),0)),U,3) . . S X=$P($G(^IBE(350.1,X,0)),U) . . S IBTYP=$S(X["RX":3,X["OPT":2,1:1) . I +IBAC'=1 D . . S IBTYP=$S($P($G(^DGCR(399,IBA,0)),U,5)>2:2,1:1) . . I $D(^IBA(362.4,"C",IBA)) S IBTYP=3 . ; . I IBSEL1'[IBTYP,IBSEL1'[4 Q . ; . I IBRPT="D" S IBPT=$$PAT(IBA) Q:IBPT="" ; Get patient info. . ; . I '$G(IBEXCEL) D EN^IBJDF53 Q:IBRPT="S" ; Get stats for summary. . ; . ; - Get insurance info. . S (IBI,IBIN)=0 . I $G(^DGCR(399,IBA,"MP")) D I 'IBI Q . . S IBI=+$G(^DGCR(399,IBA,"MP")) I 'IBI S IBIN="*** UNKNOWN ***" Q . . S IBIN=$P($G(^DIC(36,IBI,0)),U)_"@@"_IBI . ; . ; - Check the receivable age, if necessary. . I IBSMN D Q:IBARDIBSMX) . . S IBARD=+$$ACT^IBJDF2(IBA) S:IBARD IBARD=$$FMDIFF^XLFDT(DT,IBARD) . ; . ; - Check the minimum balance amount, if necessary. . S IBBA=0 F X=1:1:5 S IBBA=IBBA+$P($G(^PRCA(430,IBA,7)),U,X) . I IBSAM,IBBA0 DIV=0 Q DIV SID(DFN,INS) ; - Find the subscriber ID for a bill (if any). ; Input: DFN=Pointer to the patient in file #2 ; INS=Pointer to the patient's primary carrier in file #36 ; Output: Subscriber ID no. or null N X,Y,Z S Y="" G:'$G(DFN)!('$G(INS)) SIDQ S Z=0 F S Z=$O(^DPT(DFN,.312,Z)) Q:'Z S X=$G(^(Z,0)) D Q:Y]"" .I +X=INS S Y=$E($P(X,U,2),1,16) ; SIDQ Q Y ; PHDL ; - Print the header line for the Excel spreadsheet N X S X="Patient^VA Empl.?^Age^SSN^Prim.Ins.Carrier^Other Ins.Carrier^" S X=X_"Dt Bill prep.^Bill From Dt^Bill To Dt^Subsc.ID^Bill #^" S X=X_"Orig.Amt^Curr.Bal.^Cat.^Bill Type^Lst Comm.Dt^Days Lst Comm.^" S X=X_"Division" W !,X Q ; OTH(DFN,INS,DS) ; - Find a patient's other valid insurance carrier (if any). ; Input: DFN=Pointer to the patient in file #2 ; INS=Pointer to the patient's primary carrier in file #36 ; DS=Date of service for validity check ; Output: Valid insurance carrier (first 15 chars.) or null N X,X1,Y,Z S Y="" G:'$G(DFN)!('$G(INS))!('$G(DS)) OTHQ S Z=0 F S Z=$O(^DPT(DFN,.312,Z)) Q:'Z S X=$G(^(Z,0)) D:X Q:Y]"" .I +X=INS Q .S X1=$G(^DIC(36,+X,0)) Q:X1="" .I $P(X1,U,2)'="N",$$CHK^IBCNS1(X,DS) S Y=$E($P(X1,U),1,15) ; OTHQ Q Y ; COM ; - Get bill comments. S DAT=0,IBA1=$S(IBSH1="M":999999999,1:0) F S IBA1=$S(IBSH1="M":$O(^PRCA(433,"C",IBA,IBA1),-1),1:$O(^PRCA(433,"C",IBA,IBA1))) Q:'IBA1 D I IBSH1="M",DAT Q .S IBC=$G(^PRCA(433,IBA1,1)) Q:'IBC .I $G(IBSH2),$$FMDIFF^XLFDT(DT,+IBC)