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

RCKATRPT.m

Go to the documentation of this file.
  1. RCKATRPT ;ALB/MAF-KATRINA FINANCIAL STATEMENT REPORT ;12/1/05 4:14 PM
  1. V ;;4.5;Accounts Receivable;**242,246**;Mar 20, 1995
  1. ;
  1. EN1 ;
  1. N RCTYPE,X,%,DUOUT,DTOUT,DIR,RCDATE,Y
  1. S DIR("A")="(S)UMMARY OR (D)ETAIL?: ",DIR(0)="SBA^S:SUMMARY TOTALS ONLY;D:DETAILS AND SUMMARY"
  1. S DIR("B")="S" D ^DIR K DIR
  1. I $D(DTOUT)!$D(DUOUT)!(Y="") G RPTQ
  1. S RCTYPE=Y
  1. D NOW^%DTC
  1. S RCDATE=DT
  1. ; Ask device
  1. N ZTRTN,ZTSK,ZTSAVE,ZTDESC,%ZIS,POP
  1. S %ZIS="QM" D ^%ZIS G:POP RPTQ
  1. I $D(IO("Q")) D G RPTQ
  1. . S ZTRTN="EN^RCKATRPT",ZTSAVE("RCTYPE")="",ZTSAVE("RCDATE")="",ZTDESC="KATRINA REPORT"
  1. . D ^%ZTLOAD
  1. . W !!,$S($D(ZTSK):"Your task number "_ZTSK_" has been queued.",1:"Unavailable")
  1. . K ZTSK,IO("Q") D HOME^%ZIS
  1. U IO
  1. D EN^RCKATRPT
  1. RPTQ Q
  1. EN ;
  1. N BBAL,DEB,RCDFN,X,SITE,Y,%,%H,%I,RCSITE,DFN,BN,RCDCL,RCDL,RCPAG,STAT,TOTAMT,TOTVET,BAL,DATA,INT,RCTOT,AC,OP,PRE,ADM,PB,RCFLAG,X1,X2
  1. K ^XTMP("RCKATRPT")
  1. D NOW^%DTC S X1=DT,X2=30 D C^%DTC
  1. S ^XTMP("RCKATRPT",0)=DT_"^"_X_"^Katrina Detailed Report"
  1. S (DEB,TOTAMT,TOTVET)=0
  1. K ^TMP("RCDEBTOR",$J),^TMP("RCTOT",$J),^TMP("DEBTOR",$J),^TMP("RCSITE",$J),^TMP("RCDFN",$J),^TMP("RCBBL",$J)
  1. F S DEB=$O(^RCD(340,"AB","DPT(",DEB)) Q:DEB="" D
  1. . I $L(+$$SSN^RCFN01(DEB))<5 Q
  1. . ;Check for Emergency Response Indicator (ERI) Flag.
  1. . ;N RCDFN S RCDFN=$P($G(^RCD(340,DEB,0)),"^",1) I $$EMERES^PRCAUTL(+RCDFN)']"" Q
  1. . N RCDFN S RCDFN=$P($G(^RCD(340,DEB,0)),"^",1) I $$EMGRES^DGUTL(+RCDFN)']"" Q
  1. . S BBAL=0 D BBAL ;get bill bal
  1. D PRINT
  1. K ^TMP("RCDEBTOR",$J),^TMP("RCTOT",$J),^TMP("DEBTOR",$J),^TMP("RCSITE",$J),^TMP("RCDFN",$J),^TMP("RCBBL",$J)
  1. Q
  1. BBAL ;get bills balances return array
  1. G:'DEB BBALQ
  1. S AC=+$O(^PRCA(430.3,"AC",102,0)),OP=+$O(^PRCA(430.3,"AC",112,0))
  1. F STAT=AC,OP F BN=0:0 S BN=$O(^PRCA(430,"AS",DEB,STAT,BN)) Q:'BN D
  1. .I '$D(^TMP("RCBBL",$J,DEB)) S (BBAL,PB,INT,ADM)=0 S ^TMP("RCBBL",$J,DEB)=""
  1. .S BAL=$G(^PRCA(430,BN,7))
  1. .S SITE=$S($P($G(^PRCA(430,BN,0)),"^",12):$P($G(^PRCA(430,BN,0)),"^",12),1:"SITE UNKNOWN")
  1. .I '$D(^TMP("DEBTOR",$J,SITE,DEB)) S TOTVET=TOTVET+1
  1. .S PB=PB+$P(BAL,"^",1),INT=INT+$P(BAL,"^",2),ADM=ADM+$P(BAL,"^",3)
  1. .S BBAL=$P(BAL,"^",1)+$P(BAL,"^",2)+$P(BAL,"^",3)
  1. .S ^TMP("DEBTOR",$J,SITE,DEB,+RCDFN,BN)=$P(BAL,"^",1)_"^"_$P(BAL,"^",2)_"^"_$P(BAL,"^",3)_"^"_BBAL
  1. .S ^TMP("RCDEBTOR",$J,SITE,DEB,+RCDFN)=PB_"^"_INT_"^"_ADM_"^"_(PB+INT+ADM)
  1. .S RCTOT=$G(^TMP("RCTOT",$J,SITE)),$P(^TMP("RCTOT",$J,SITE),"^",1)=$P(RCTOT,"^",1)+$P(BAL,"^",1),$P(^TMP("RCTOT",$J,SITE),"^",2)=$P(RCTOT,"^",2)+$P(BAL,"^",2)
  1. .S $P(^TMP("RCTOT",$J,SITE),"^",3)=$P(RCTOT,"^",3)+$P(BAL,"^",3),$P(^TMP("RCTOT",$J,SITE),"^",4)=$P(RCTOT,"^",4)+BBAL
  1. .Q
  1. BBALQ Q
  1. PRINT ;PRINT THE REPORT
  1. S $P(RCDCL,"=",81)="",(SITE,RCPAG)=0
  1. D HEAD
  1. I '$D(^TMP("RCDEBTOR",$J)) W !!,"No data meets this criteria" Q
  1. I RCTYPE="D" D
  1. .S RCFLAG=0 F S SITE=$O(^TMP("DEBTOR",$J,SITE)) Q:SITE=""!(RCFLAG) S DEB=0 F S DEB=$O(^TMP("DEBTOR",$J,SITE,DEB)) Q:DEB=""!(RCFLAG) D
  1. ..S DFN=0 F S DFN=$O(^TMP("DEBTOR",$J,SITE,DEB,DFN)) Q:DFN=""!(RCFLAG) S BN=0 F S BN=$O(^TMP("DEBTOR",$J,SITE,DEB,DFN,BN)) Q:BN=""!(RCFLAG) D:$Y+5>IOSL RET Q:RCFLAG D PRDATA
  1. ..Q
  1. .Q
  1. I RCTYPE="D" Q:RCFLAG S RCTYPE="S" S RCPAG=0 D RET Q:RCFLAG
  1. I RCTYPE="S" D
  1. .F S SITE=$O(^TMP("RCTOT",$J,SITE)) Q:SITE="" D PRDATA
  1. .Q
  1. Q
  1. RET ;
  1. F X=$Y:1:(IOSL-3) W !
  1. I IOST'?1"C-".E D Q
  1. .I RCTYPE="D" K ^TMP("RCSITE",$J,SITE),^TMP("RCDFN",$J,DFN)
  1. .D HEAD
  1. N DIR,DUOUT,DTOUT
  1. S DIR(0)="EA",DIR("A")="Enter <RET> to continue or ^ to quit " D ^DIR
  1. I $D(DTOUT)!$D(DUOUT) S RCFLAG=1 Q:RCFLAG
  1. I RCTYPE="D" K ^TMP("RCSITE",$J,SITE),^TMP("RCDFN",$J,DFN)
  1. N Y S RCPAG=RCPAG+1
  1. W @IOF,"Financial"_$S(RCTYPE="S":" Summary ",1:" Detailed ")_"Statement for Hurricane Katrina ",?53 S Y=RCDATE D DD^%DT W Y," ",$J("PAGE: "_RCPAG,12),!
  1. I RCTYPE="S" D
  1. .W !,"SITE",?25,"#AFFECTED VETS",?48,"TOTAL AMT.",?65,"AVG. AMOUNT/VET"
  1. I RCTYPE="D" D
  1. .W !,"BILL #",?17,"PRINC. BAL",?41,"INT.",?56,"ADM.",?75,"TOTAL"
  1. W !,RCDCL
  1. Q
  1. PRDATA ;WRITE THE DATA
  1. ;W !
  1. I RCTYPE="S" D
  1. .S TOTAMT=$P($G(^TMP("RCTOT",$J,SITE)),"^",4)
  1. .W !,$P($$SITE^VASITE(),"^",2),?20,$J(TOTVET,18),?40,$J("$"_TOTAMT,18),?60,$J("$"_$P(TOTAMT/TOTVET,".",1)_"."_$E($P(TOTAMT/TOTVET,".",2),1,2),18)
  1. .S ^XTMP("RCKATRPT",SITE,"TOTGRAND")=TOTVET_"^"_TOTAMT_"^"_$P(TOTAMT/TOTVET,".",1)_"."_$E($P(TOTAMT/TOTVET,".",2),1,2)
  1. I RCTYPE="D" D
  1. .N DATA
  1. .S DATA=$G(^TMP("DEBTOR",$J,SITE,DEB,DFN,BN))
  1. . I '$D(^TMP("RCSITE",$J,SITE)) W !,?35,$P($$SITE^VASITE(),"^",2),! S ^TMP("RCSITE",$J,SITE)=""
  1. . I '$D(^TMP("RCDFN",$J,DFN)) W !,DEB_":"_$P($G(^DPT(DFN,0)),"^",1) S ^TMP("RCDFN",$J,DFN)=""
  1. . W !,$P($G(^PRCA(430,BN,0)),"^",1),?12,$S($P($G(DATA),"^",1):$J("$"_$P(DATA,"^",1),15),1:$J("$0",15)),?30,$S($P($G(DATA),"^",2):$J("$"_$P(DATA,"^",2),15),1:$J("$0",15))
  1. .W ?45,$S($P($G(DATA),"^",3):$J("$"_$P(DATA,"^",3),15),1:$J("$0",15)),?65,$S($P($G(DATA),"^",4):$J("$"_$P(DATA,"^",4),15),1:$J("$0",15))
  1. .S ^TMP("RCSITE",$J,SITE)="",^TMP("RCDFN",$J,DFN)=""
  1. .I '$O(^TMP("DEBTOR",$J,SITE,DEB,DFN,BN)) D
  1. ..I $Y+5>IOSL D RET Q:RCFLAG W !,?35,$P($$SITE^VASITE(),"^",2),!!,DEB_":"_$P($G(^DPT(DFN,0)),"^",1),! S ^TMP("RCSITE",$J,SITE)="",^TMP("RCDFN",$J,DFN)=""
  1. ..N X
  1. ..S X=$G(^TMP("RCDEBTOR",$J,SITE,DEB,DFN))
  1. ..S $P(RCDL,"-",65)="" W !,"------",?16,RCDL
  1. ..W !,"TOTAL: ",?12,$J("$"_$P(X,"^",1),15),?30,$J("$"_$P(X,"^",2),15),?45,$J("$"_$P(X,"^",3),15),?65,$J("$"_$P(X,"^",4),15),!
  1. ..S ^XTMP("RCKATRPT",SITE,DEB,DFN,"TOT")=DEB_"^"_"^"_X
  1. .S ^XTMP("RCKATRPT",SITE,DEB,DFN,BN)=DEB_"^"_BN_"^"_DATA
  1. .Q
  1. Q