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

RCTCSPRS.m

Go to the documentation of this file.
RCTCSPRS ;ALBANY/BDB - CROSS-SERVICING (RECONCILIATION SERVER);02/19/14 3:21 PM
 ;;4.5;Accounts Receivable;**301,315,336**;Mar 20, 1995;Build 45
 ;;Per VA Directive 6402, this routine should not be modified.
 ;
 ;Program to process reconciliation server messages from AITC
 ;
 ;PRCA*4.5*336 Use a different work file ^XTMP('RCTCSPRSW') to avoid
 ;             any contention with weekly CS batch run RCTCSPD.
 ;             Also, the clearing of the CS flag for debtor when
 ;             no longer having any CS bills has been REMOVED.
 ;
READ ;READS MESSAGE INTO TEMPORARY GLOBAL
 N FDT,RDNODE S FDT=0
 K ^XTMP("RCTCSPDW",$J)      ;PRCA*4.5*336 
 ;New report for claims returned from treasury PRCA*4.5*315
 S ^XTMP("RCTCSP5 - "_DT,0)=$$FMADD^XLFDT(DT,57)_"^"_DT_"^"_"Treasury Cross-Servicing IAI Report"  ; Maintain this entry for 57 days
 S RDNODE=$NA(^XTMP("RCTCSP5 - "_DT))
 ;
 S XMA=0
READ1 X XMREC I $D(XMER) G:XMER<0 READQ
 I $E(XMRG,1)="H" S FDT=$E(XMRG,2,9)
 S ^XTMP("RCTCSPRS",$J,"READ",FDT,XMPOS)=XMRG
 G READ1
 ;
READQ K XMA,XMER,XMREC,XMPOS,XMRG
 N TYPE,VALC,VFASTCD,VSTTN,VSITE,LN,REC,REC1,REC2
 S VALC="36001200"
 S VFASTCD="36"
 S VSTTN="DM1D "
 S VSITE=$E($$SITE^RCMSITE(),1,3)
 S LN=0
 F  S LN=$O(^XTMP("RCTCSPRS",$J,"READ",FDT,LN)) Q:LN=""  S REC1=$G(^(LN)),LN=LN+1,REC2=$G(^(LN)),REC=$E(REC1,1,225)_$E(REC2,1,225) D
 .S TYPE=$E(REC,1,2)
 .I TYPE["H" D HDR Q
 .I TYPE="A1" D A1 Q
 .I TYPE="C1" Q
 .I TYPE="R1" D R1 Q
 .I TYPE="R2" D R2 Q
 .I TYPE["Z" K TYPE Q
 .Q
 ;
TRDT ;sends mailman message to user for returned debts
 Q:'$D(^XTMP("RCTCSPDW",$J,"TRDTRDB"))
 S XMDUZ="AR PACKAGE",XMY("G.TCSP")=""
 N TCT1,TDEB1,TDEB10,TBIL1,TSP1,FST1,TBCNT,TTXT1
 S XMSUB="CS QUALIFIED/RETURNED DEBTS "_$E(DT,4,5)_"/"_$E(DT,6,7)_"/"_$E(DT,2,3)
 S ^XTMP("RCTCSPDW",$J,"TRDT",1)="The following Debtors and Debts were Returned by Reconciliation."
 S ^XTMP("RCTCSPDW",$J,"TRDT",2)=""
 S ^XTMP("RCTCSPDW",$J,"TRDT",3)="Name                                     Bill #    Returned Date   Closed Date"
 S ^XTMP("RCTCSPDW",$J,"TRDT",4)="----                                     ------    -------- ----   ------ ----"
 S TCT1=5,TSP1=0,TDEB1="",TBCNT=0
 F  S TDEB1=$O(^XTMP("RCTCSPDW",$J,"TRDTRDB",TDEB1)) Q:TDEB1=""  D
 .S FST1=1,TBIL1=""
 .I FST1,TCT1'=5 S ^XTMP("RCTCSPDW",$J,"TRDT",TCT1)="",TCT1=TCT1+1,TSP1=TSP1+1
 .F  S TBIL1=$O(^XTMP("RCTCSPDW",$J,"TRDTRDB",TDEB1,TBIL1)) Q:TBIL1=""  S TBCNT=TBCNT+1 D
 ..S TDEB10=$S(FST1:TDEB1,1:""),TTXT1=""
 ..F  S TTXT1=$O(^XTMP("RCTCSPDW",$J,"TRDTRDB",TDEB1,TBIL1,TTXT1)) Q:TTXT1=""  S ^XTMP("RCTCSPDW",$J,"TRDT",TCT1)=^XTMP("RCTCSPDW",$J,"TRDTRDB",TDEB1,TBIL1,TTXT1) S TCT1=TCT1+1
 ..S TCT1=TCT1+1,FST1=0
 S ^XTMP("RCTCSPDW",$J,"TRDT",TCT1)="Total records: "_TBCNT
 S XMTEXT="^XTMP(""RCTCSPDW"","_$J_",""TRDT"","
 D ^XMD K XMDUZ,XMSUB,XMTEXT,XMY
 K ^XTMP("RCTCSPDW",$J,"TRDT")
TRDTQ Q
 ;
HDR ; header record
 S TFASTCD=$E(REC,10,11),TALC=$E(REC,12,19) ;repeated on r1 AND r2
 Q
 ;
A1 ;active debt record
 N TFASTCD,TALC,TSTTN,TDBTID,TSITE,BILL,B0,DEBTOR
 S TFASTCD=$E(REC,3,4),TALC=$E(REC,5,12),TSTTN=$E(REC,13,17),TDBTID=$E(REC,18,47),TRDT=$E(REC,58,65)
 I TFASTCD'=VFASTCD D NPMSG("FASTCD",TFASTCD,VFASTCD) Q
 I TALC'=VALC D NPMSG("ALC",TALC,VALC) Q
 I TSTTN'=VSTTN D NPMSG("STATION",TSTTN,VSTTN)
 S TSITE=$E(TDBTID,1,3) I TSITE'=VSITE D NPMSG("SITE",TSITE,VSITE) Q
 S BILL=+$E(TDBTID,12,30)  ;BILL = IEN
 S B0=$G(^PRCA(430,BILL,0))
 S DEBTOR=+$P(B0,U,9)
 ;PRCA*4.5*315  set data for IAI report (^RCTCSP5)
 I DEBTOR,BILL S @RDNODE@(DEBTOR,BILL)=""   ;set to debtor then bill IEN for sorting the IAI report
 Q
 ;
R1 ;returned debt record
 N TFASTCD,TALC,TSTTN,TDBTID,TRDT,TSITE,BILLNO,BILL,B0,B4,B6,B7,B9,B14,B15,B16,DEBTOR,RJND
 S TFASTCD=$E(REC,3,4),TALC=$E(REC,5,12),TSTTN=$E(REC,13,17),TDBTID=$E(REC,18,47),TRDT=$E(REC,58,65)
 I TFASTCD'=VFASTCD D NPMSG("FASTCD",TFASTCD,VFASTCD) Q
 I TALC'=VALC D NPMSG("ALC",TALC,VALC) Q
 I TSTTN'=VSTTN D NPMSG("STATION",TSTTN,VSTTN)
 S TSITE=$E(TDBTID,1,3) I TSITE'=VSITE D NPMSG("SITE",TSITE,VSITE) Q
 S BILLNO=$E(TDBTID,4,10),BILL=+$E(TDBTID,11,30)  ;BILL = IEN
 S B0=$G(^PRCA(430,BILL,0)),B4=$G(^(4)),B6=$G(^(6)),B7=$G(^(7)),B9=$G(^(9)),B14=$G(^(14)),B15=$G(^(15)),B16=$G(^(16))
 S DEBTOR=$P(B0,U,9)
 ;set comment transaction in 433
 D CSPRTR^RCTCSPD5  ;PRCA*4.5*315
 ;
 S RJND=0 F  S RJND=$O(^PRCA(430,BILL,18,RJND)) Q:'RJND  D
 .N DAT
 .S DAT=+$G(^PRCA(430,BILL,18,RJND,0))
 .I DAT K ^PRCA(430,"AB",DAT,BILL)
 K ^PRCA(430,BILL,15),^(16),^(17),^(18),^(19),^(20)
 I +TRDT D
 .N DNM,DA,DIE,DR
 .I $D(^XTMP("RCTCSPDW",$J,"TRDTRDB",DEBTOR,BILL,1)) S $E(^XTMP("RCTCSPDW",$J,"TRDTRDB",DEBTOR,BILL,1),52,63)=$$DTT2E(TRDT) Q
 .S DNM=$E($$NAMEFF(+^RCD(340,DEBTOR,0)),1,30),DNM=$$LJSF(DNM,30)
 .S ^XTMP("RCTCSPDW",$J,"TRDTRDB",DEBTOR,BILL,1)=$$LJSF(DNM,30)_"           "_$$LJSF(BILLNO,7)_"   "_$$DTT2E(TRDT)
 .S EFFDT=$$HL7TFM^XLFDT(TRDT),REASON="O",COMMENT="BY RECONCILIATION"
 .S $P(^PRCA(430,BILL,15),U,7,10)="1^"_EFFDT_U_REASON_U_$G(COMMENT)
 .S DIE="^PRCA(430,",DA=BILL
 .S DR="301////"_EFFDT ;Returned date
 .S DR=DR_";310////"_$P(B16,U,9)
 .S DR=DR_";311////"_$P(B16,U,10)
 .S DR=DR_";312////"_$P(B15,U,3)
 .D ^DIE
 K ^PRCA(430,"TCSP",BILL) ;set the bill to not sent to cross-servicing
 Q
 ;
R2 ;returned debtor record
 N TFASTCD,TALC,TSTTN,TDBTID,TSITE,TFDA,TDBTORID,TRRSNCD,TCMPIND,TCMPAMT,TCLSDT,TBNKDT,TDTHDT,TDISDT,RJND
 S TFASTCD=$E(REC,3,4),TALC=$E(REC,5,12),TSTTN=$E(REC,13,17),TDBTID=$E(REC,18,47),TDBTORID=$E(REC,48,62),TRRSNCD=$E(REC,261,262)
 S TCMPIND=$E(REC,263,263),TCMPAMT=$E(REC,264,277),TCLSDT=$E(REC,278,285),TBNKDT=$E(REC,286,293),TDTHDT=$E(REC,294,301),TDISDT=$E(REC,302,309)
 I TFASTCD'=VFASTCD D NPMSG("FASTCD",TFASTCD,VFASTCD) Q
 I TALC'=VALC D NPMSG("ALC",TALC,VALC) Q
 I TSTTN'=VSTTN D NPMSG("STATION",TSTTN,VSTTN)
 S TSITE=$E(TDBTID,1,3) I TSITE'=VSITE D NPMSG("SITE",TSITE,VSITE) Q
 S BILLNO=$E(TDBTID,4,10),BILL=+$E(TDBTID,11,30)
 S B0=$G(^PRCA(430,BILL,0))
 S TRRSNCD=$$CLRBLNK(TRRSNCD)
 S DEBTOR=$P(B0,U,9)
 S RJND=0 F  S RJND=$O(^PRCA(430,BILL,18,RJND)) Q:'RJND  D
 .N DAT
 .S DAT=+$G(^PRCA(430,BILL,18,RJND,0))
 .I DAT K ^PRCA(430,"AB",DAT,BILL)
 K ^PRCA(430,BILL,15),^(16),^(17),^(18),^(19),^(20)
 I TRRSNCD]"" D
 .N DNM,EFFDT,REASON,COMMENT
 .I $D(^XTMP("RCTCSPDW",$J,"TRDTRDB",DEBTOR,BILL,1)) S $E(^XTMP("RCTCSPDW",$J,"TRDTRDB",DEBTOR,BILL,1),68,79)=$S($G(TCLSDT)]"":$$DTT2E(TCLSDT),1:"")
 .I '$D(^XTMP("RCTCSPDW",$J,"TRDTRDB",DEBTOR,BILL,1)) D
 ..S DNM=$E($$NAMEFF(+^RCD(340,DEBTOR,0)),1,30),DNM=$$LJSF(DNM,30),^XTMP("RCTCSPDW",$J,"TRDTRDB",DEBTOR,BILL,1)=DNM_"           "_$$LJSF(BILLNO,7)_"                   "_$S($G(TCLSDT)]"":$$DTT2E(TCLSDT),1:"")
 .S DIC="^PRCA(430.5,",DIC(0)="Z",X=TRRSNCD D ^DIC K DIC I +Y>0 D
 ..S ^XTMP("RCTCSPDW",$J,"TRDTRDB",DEBTOR,BILL,2)="     "_$P(Y(0),U,2)
 ..S $P(^PRCA(430,BILL,30),U,2)=+Y
 I TCMPIND="Y" D
 .S ^XTMP("RCTCSPDW",$J,"TRDTRDB",DEBTOR,BILL,3)="     COMPROMISE, PLEASE WRITE THIS BILL OFF BY THE MANUAL PROCESS."
 .S $P(^PRCA(430,BILL,30),U,3)=TCMPIND
 .I +TCMPAMT D
 ..S ^XTMP("RCTCSPDW",$J,"TRDTRDB",DEBTOR,BILL,4)="     COMPROMISED AMOUNT (NOT COLLECTED):"_$J(TCMPAMT/100,9,2)
 ..S $P(^PRCA(430,BILL,30),U,4)=TCMPAMT/100
 I +TBNKDT D
 .S ^XTMP("RCTCSPDW",$J,"TRDTRDB",DEBTOR,BILL,5)="     BANKRUPTCY DATE: "_$$DTT2E(TBNKDT)
 .S $P(^PRCA(430,BILL,30),U,6)=$$HL7TFM^XLFDT(TBNKDT)
 I +TDTHDT D
 .S ^XTMP("RCTCSPDW",$J,"TRDTRDB",DEBTOR,BILL,6)="     DATE OF DEATH:  "_$$DTT2E(TDTHDT)
 .S $P(^PRCA(430,BILL,30),U,7)=$$HL7TFM^XLFDT(TDTHDT)
 I +TDISDT D
 .S ^XTMP("RCTCSPDW",$J,"TRDTRDB",DEBTOR,BILL,7)="     DATE OF DISSOLUTION:  "_$$DTT2E(TDISDT)
 .S $P(^PRCA(430,BILL,30),U,8)=$$HL7TFM^XLFDT(TDISDT)
 I +TCLSDT D
 .S EFFDT=$$HL7TFM^XLFDT(TCLSDT),REASON="O",COMMENT="BY RECONCILIATION"
 .S $P(^PRCA(430,BILL,15),U,7,10)="1^"_EFFDT_U_REASON_U_$G(COMMENT)
 .S $P(^PRCA(430,BILL,30),U,5)=$$HL7TFM^XLFDT(TCLSDT)
 K ^PRCA(430,"TCSP",BILL) ;set the bill to not sent to cross-servicing
 S ^XTMP("RCTCSPDW",$J,"TRDTRDB",DEBTOR,BILL,8)=""
 Q
 ;
NPMSG(FLD,TCD,VCD) ;error not processed
 Q
 ;
LJSF(X,Y) ;left justified space filled
 S X=$E(X,1,Y)
 S X=X_$$BLANK(Y-$L(X))
 Q X
 ;
BLANK(X) ;returns 'x' blank spaces
 N BLANK
 S BLANK="",$P(BLANK," ",X+1)=""
 Q BLANK
 ;
CLRBLNK(X) ;clear blanks
 S X=$TR(X," ","")
 Q X
 ;
NAMEFF(DFN) ;returns name for document and name in file
 N FN,LN,MN,NM,DOCNM,VA,VADM
 S NM=""
 D DEM^VADPT
 I $D(VADM) S NM=VADM(1)
 S LN=$TR($P(NM,",")," .'-"),MN=$P($P(NM,",",2)," ",2)
 I ($E(MN,1,2)="SR")!($E(MN,1,2)="JR")!(MN?2.3"I")!(MN?0.1"I"1"V"1.3"I") S MN=""
 S FN=$P($P(NM,",",2)," ")
 S DOCNM=LN_" "_FN_" "_MN
 Q DOCNM
 ;
DTT2E(TDT) ;date treasury to external format
 Q $$UPPER^VALM1($$FMTE^XLFDT($$HL7TFM^XLFDT(TDT)))