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

RCRFRPT.m

Go to the documentation of this file.
  1. RCRFRPT ;EDE/YMG - MULTIPLE REFERRAL PROGRAMS REPORT; 11/02/2022
  1. ;;4.5;Accounts Receivable;**412**;Mar 20, 1995;Build 13
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. Q
  1. ;
  1. EN ; entry point
  1. N DAY,POP,ZTDESC,ZTRTN,ZTSAVE,ZTSK,%ZIS
  1. K ^TMP("RCRFRPT",$J)
  1. W !!,"Multiple Referral Programs Report",!
  1. S DAY=$E(DT,6,7)
  1. I (DAY>19)!(DAY<8) D Q
  1. .W !,"WARNING:"
  1. .W !," This report is disabled from the 20th of current month through the 7th of"
  1. .W !," the next month to ensure that the DMC Master File updates have occurred.",!
  1. .D PAUSE^RCRPRPU
  1. .Q
  1. D EXCMSG^RCTCSJR ; Excel display message
  1. ; ask for device
  1. K IOP,IO("Q")
  1. S %ZIS="MQ",%ZIS("B")="",POP=0 D ^%ZIS Q:POP
  1. I $D(IO("Q")) D Q ; queued report
  1. .S ZTDESC="Multiple Referral Programs Report",ZTRTN="COMPILE^RCRFRPT"
  1. .S ZTSAVE("ZTREQ")="@"
  1. .D ^%ZTLOAD,HOME^%ZIS
  1. .I $G(ZTSK) W !!,"Report compilation has started with task# ",ZTSK,".",! D PAUSE^RCRPRPU
  1. .Q
  1. D COMPILE
  1. Q
  1. ;
  1. COMPILE ; compile report
  1. N AAFLG,BILLNO,DBTR,DEATHDT,DEBTOR,DFN,DMCDT,DMCFLG,HBFLG,HRFSFLG,IENS,INCLUDE,LTRDT1,LTRDT2,LTRDT3,N0,N6,PENFLG,PNAME,PREPDT,PTDONE,RCBAL,RCBILL,RCCAT,RCSTAT
  1. N SC,SCFLG,SSN,TCSPDT,TCSPFLG,TOPDT,TOPFLG,VADM,VAEL,VAMB,Z
  1. S DBTR=0 F S DBTR=$O(^RCD(340,"B",DBTR)) Q:'DBTR D
  1. .I $P(DBTR,";",2)'["DPT(" Q ; debtor is not a patient
  1. .S DEBTOR=$O(^RCD(340,"B",DBTR,"")) Q:'DEBTOR
  1. .I $P($G(^RCD(340,DEBTOR,3)),U,10) Q ; DMC site deletion flag is set
  1. .I $P($G(^RCD(340,DEBTOR,6)),U,2) Q ; TOP referral is stopped
  1. .S DFN=$P(DBTR,";") D DEM^VADPT
  1. .S PNAME=VADM(1) ; patient name
  1. .S SSN=$P(VADM(2),U) ; patient SSN
  1. .S DEATHDT=+$P(VADM(6),U) I DEATHDT Q ; date of death
  1. .D MB^VADPT S AAFLG=$P(VAMB(1),U),HBFLG=$P(VAMB(2),U),PENFLG=$P(VAMB(4),U) ; A&A, Housebound, and pension flags
  1. .S SC=0 D ELIG^VADPT S SCFLG=$P(VAEL(3),U) I SCFLG S SC=$P(VAEL(3),U,2) ; service connected %
  1. .S HRFSFLG=$$CHKHRFS^RCHRFSUT(DFN,DT,DT) I HRFSFLG Q ; was there an active HRFS flag for this patient (1/0)
  1. .S PTDONE=0
  1. .S RCBILL=0 F S RCBILL=$O(^PRCA(430,"C",DEBTOR,RCBILL)) Q:'RCBILL D
  1. ..S (DMCFLG,TCSPFLG,TOPFLG)=0
  1. ..S DMCDT=+$G(^PRCA(430,RCBILL,12)) S:DMCDT DMCFLG=1 ; DMC referral date; if 0, then bill is not at DMC
  1. ..S IENS=RCBILL_","
  1. ..S RCSTAT=$$GET1^DIQ(430,IENS,8) I "^ACTIVE^SUSPENDED^CANCELLATION^COLLECTED/CLOSED^"'[(U_RCSTAT_U) Q ; incorect bill status
  1. ..S TOPDT=+$G(^PRCA(430,RCBILL,14)) S:TOPDT TOPFLG=1 ; TOP referral date
  1. ..S TCSPDT=0,Z=$G(^PRCA(430,RCBILL,15)) I '$P(Z,U,2),'$P(Z,U,7) S TCSPDT=+$P(Z,U) ; TCSP referral date, get if neither recall of stop referral flag is set
  1. ..S:TCSPDT TCSPFLG=1
  1. ..S INCLUDE=$S(TOPFLG=TCSPFLG:TOPFLG,1:DMCFLG) ; debt at 2 or more referral programs
  1. ..I AAFLG!HBFLG!PENFLG S INCLUDE=TOPFLG!TCSPFLG ; debt at treasury when debtor has A&A, housebound, or pension
  1. ..I 'INCLUDE Q
  1. ..S N0=^PRCA(430,RCBILL,0),BILLNO=$P(N0,U),PREPDT=+$P(N0,U,10) ; Bill # and Bill Prepared Date
  1. ..S RCBAL=$$BALANCE^RCRPRPU(RCBILL) ; current bill balance
  1. ..S RCCAT=$$GET1^DIQ(430,IENS,2) ; AR category
  1. ..S N6=$G(^PRCA(430,RCBILL,6)),LTRDT1=$P(N6,U),LTRDT2=$P(N6,U,2),LTRDT3=$P(N6,U,3)
  1. ..I 'PTDONE S ^TMP("RCRFRPT",$J,PNAME,DFN)=SSN_U_$S(SCFLG:SC,1:"No")_U_AAFLG_U_PENFLG_U_HBFLG,PTDONE=1
  1. ..S ^TMP("RCRFRPT",$J,PNAME,DFN,BILLNO)=RCCAT_U_RCSTAT_U_RCBAL_U_PREPDT_U_LTRDT1_U_LTRDT2_U_LTRDT3_U_TCSPDT_U_DMCDT_U_TOPDT
  1. ..Q
  1. .Q
  1. D PRINT
  1. K ^TMP("RCRFRPT",$J)
  1. I '$D(ZTQUEUED) D ^%ZISC
  1. Q
  1. ;
  1. PRINT ; print report
  1. N BDATA,BILLNO,DFN,EXTDT,PDATA,PNAME,SC,Z,Z1
  1. U IO
  1. S EXTDT=$$FMTE^XLFDT(DT)
  1. W !,"Multiple Referral Programs Report^",EXTDT
  1. W !!,"This report includes debts at multiple referral programs along with debts at treasury where the veteran has Aid and Attendance, Housebound or Pension benefits."
  1. W !!,"Name^SSN^Bill #^AR Category^Bill Status^Bill Balance^Bill Prepared Date^Letter 1^Letter 2^Letter 3^TCSP Referral Date^DMC Referral Date^TOP Referral Date^SC %^A&A^VA Pension^Housebound Benefits"
  1. I '$D(^TMP("RCRFRPT",$J)) W !!,"No records found." Q
  1. S PNAME="" F S PNAME=$O(^TMP("RCRFRPT",$J,PNAME)) Q:PNAME="" D
  1. .S DFN=0 F S DFN=$O(^TMP("RCRFRPT",$J,PNAME,DFN)) Q:'DFN D
  1. ..S PDATA=^TMP("RCRFRPT",$J,PNAME,DFN)
  1. ..S BILLNO="" F S BILLNO=$O(^TMP("RCRFRPT",$J,PNAME,DFN,BILLNO)) Q:BILLNO="" D
  1. ...S BDATA=^TMP("RCRFRPT",$J,PNAME,DFN,BILLNO)
  1. ...W !,PNAME,U,$P(PDATA,U),U,BILLNO,U,$P(BDATA,U),U,$P(BDATA,U,2),U,$P(BDATA,U,3),U
  1. ...F Z=4:1:10 S Z1=$P(BDATA,U,Z) W $S('Z1:"N/A",1:$$FMTE^XLFDT(Z1,"2DZ")),U
  1. ...S SC=$P(PDATA,U,2) I SC'="No" S SC=SC_"%"
  1. ...W SC,U,$S($P(PDATA,U,3):"Yes",1:"No"),U,$S($P(PDATA,U,4):"Yes",1:"No"),U,$S($P(PDATA,U,5):"Yes",1:"No")
  1. ...Q
  1. ..Q
  1. .Q
  1. Q