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

PRCAP377.m

Go to the documentation of this file.
  1. PRCAP377 ;EDE/YMG - PRCA*4.5*377 POST INSTALL; 12/04/20
  1. ;;4.5;Accounts Receivable;**377**;Mar 20, 1995;Build 45
  1. ;Per VA Directive 6402, this routine should not be modified.
  1. Q
  1. ;
  1. EN ; entry point
  1. D BMES^XPDUTL(" >> Start of the Post-Installation routine for PRCA*4.5*377")
  1. ; Add 2 new entries to the Transaction Type file
  1. D UPD4303
  1. ; Initialize the Repayment Plan Process field in the Transaction Type File
  1. D ADDRPP
  1. ; convert repayment plans in file 430 to entries in file 340.5
  1. D CONVERT
  1. D BMES^XPDUTL(" >> End of the Post-Installation routine for PRCA*4.5*377")
  1. Q
  1. ;
  1. CONVERT ; convert repayment plans in file 430 to entries in file 340.5
  1. N AMNT,BILL,CAT,CNT,DEBTOR,FDA,FDAIEN,IENS,N0,N4,N15,NEWTOT,NUMPMNT,RCRPIEN,REFDMC,REFTOP,RPPCNT,RPPID,STARTDT,TOTAL,Z
  1. D MES^XPDUTL("Converting existing repayment plans...")
  1. K ^TMP("PRCAP377",$J)
  1. S (CNT,RPPCNT)=0
  1. ; loop through AR bills with ACTIVE status
  1. S BILL=0 F S BILL=$O(^PRCA(430,"AC",16,BILL)) Q:BILL="" D
  1. .S N0=^PRCA(430,BILL,0),CAT=+$P(N0,U,2) I CAT'>0 Q
  1. .S TOTAL=$$BALANCE^RCRPRPU(BILL) I TOTAL'>0 Q ; skip if total balance is 0
  1. .S N4=$G(^PRCA(430,BILL,4)) I N4="" Q ; skip if node 4 in file 430 is blank - no repayment plan
  1. .I +$P(N4,U,5)>0 Q ; skip if 430/45 is populated - this entry has been converted already
  1. .S N15=$G(^PRCA(430,BILL,15))
  1. .I +$P(N15,U)>0,$P(N15,U,3)="" Q ; skip if bill was referred to TSCP and was not recalled
  1. .S DEBTOR=+$P($G(^PRCA(430,BILL,0)),U,9) ; file 340 ien
  1. .I '$$GET1^DIQ(430.2,CAT_",",1.06,"I") D Q ; skip if not eligible for RPP and add to exception report
  1. ..S ^TMP("PRCAP377",$J,"CAT",DEBTOR,BILL)=CAT ; AR category - ien in file 430.2
  1. ..Q
  1. .S RCRPIEN=+$O(^RCRP(340.5,"E",DEBTOR,""))
  1. .S AMNT=+$P(N4,U,3) I 'AMNT Q
  1. .S CNT=CNT+1 I '$D(ZTQUEUED) W:CNT#500=0 "."
  1. .S STARTDT=$$GETSTART^RCRPU(DT)
  1. .I 'RCRPIEN D
  1. ..; no entry in 340.5, create new plan
  1. ..S Z="000000"_($P($G(^RCRP(340.5,0)),U,3)+1)
  1. ..S RPPID=$$GETID^RCRPU(DEBTOR)_$E(Z,$L(Z)-5,$L(Z))
  1. ..S FDA(340.5,"+1,",.01)=RPPID ; RPP ID
  1. ..S FDA(340.5,"+1,",.02)=DEBTOR ; ptr to file 340
  1. ..S FDA(340.5,"+1,",.03)=DT ; creation date
  1. ..S FDA(340.5,"+1,",.04)=STARTDT ; start date
  1. ..S FDA(340.5,"+1,",.06)=AMNT ; amount per month (from 430/43)
  1. ..S FDA(340.5,"+1,",.07)=2 ; status (set to "current")
  1. ..S FDA(340.5,"+1,",.08)=DT ; status date
  1. ..S FDA(340.5,"+1,",.09)=0 ; # of forbearances
  1. ..D UPDATE^DIE("","FDA","FDAIEN")
  1. ..S RCRPIEN=FDAIEN(1) K FDAIEN I 'RCRPIEN Q
  1. ..D NEWAUDT(RCRPIEN) ; update sub-file 340.54
  1. ..D UPDDBTR^RCRPU(RCRPIEN,DEBTOR) ; update debtor file (340)
  1. ..S RPPCNT=RPPCNT+1
  1. ..S ^TMP("PRCAP377",$J,"CNV",RCRPIEN)=RPPID_U_DEBTOR
  1. ..Q
  1. .; skip bills with monthly amount that differs from the rest of repayment plan, add them to exception report
  1. .I AMNT'=$P(^RCRP(340.5,RCRPIEN,0),U,6) D Q
  1. ..I '$D(^TMP("PRCAP377",$J,"AMNT")) S ^TMP("PRCAP377",$J,"AMNT")=$P(^RCRP(340.5,RCRPIEN,0),U,6) ; monthly amount in repayment plan
  1. ..S ^TMP("PRCAP377",$J,"AMNT",DEBTOR,BILL)=AMNT ; monthly amount for this bill
  1. ..Q
  1. .; if bill was referred to TOP or DMC, add it to TOP/DMC report
  1. .S REFDMC=+$P($G(^PRCA(430,BILL,12)),U)
  1. .S REFTOP=+$P($G(^PRCA(430,BILL,14)),U)
  1. .I REFTOP!REFDMC S ^TMP("PRCAP377",$J,"REF",DEBTOR,RCRPIEN,BILL)=$S(REFTOP:"TOP",1:"DMC")
  1. .;
  1. .D UPDBILL^RCRPU(RCRPIEN,BILL) ; update sub-file 340.56
  1. .; update fields 430/41 and 430/45
  1. .S IENS=BILL_","
  1. .S FDA(430,IENS,41)=DT
  1. .S FDA(430,IENS,45)=RCRPIEN
  1. .D FILE^DIE("","FDA")
  1. .; add new transaction to file 433
  1. .D TRAN^RCRPU(BILL,TOTAL,67)
  1. .; update field 340.5/.11 (plan amount owed)
  1. .S FDA(340.5,RCRPIEN_",",.11)=TOTAL+$P(^RCRP(340.5,RCRPIEN,0),U,11) D FILE^DIE("","FDA")
  1. .; update schedule (sub-file 340.52)
  1. .I AMNT D
  1. ..S NEWTOT=$P(^RCRP(340.5,RCRPIEN,0),U,11)
  1. ..S NUMPMNT=NEWTOT\AMNT I NEWTOT#AMNT S NUMPMNT=NUMPMNT+1 ; # of payments (amount owed / amount per month, rounded up)
  1. ..D UPDSCHED(RCRPIEN,+$P(^RCRP(340.5,RCRPIEN,0),U,5),NUMPMNT,$S('$D(^RCRP(340.5,RCRPIEN,2)):STARTDT,1:""))
  1. ..; update # of payments
  1. ..S FDA(340.5,RCRPIEN_",",.05)=NUMPMNT D FILE^DIE("","FDA")
  1. ..Q
  1. .Q
  1. D MES^XPDUTL(" Done.")
  1. D MSG(CNT,RPPCNT),MSG1,MSG2
  1. K ^TMP("PRCAP377",$J)
  1. Q
  1. ;
  1. UPDSCHED(RCIEN,RCORLN,RCNEWLN,RCSTDT) ; Update RPP schedule.
  1. ;
  1. ; RCRPIEN - IEN of the Repayment Plan being adjusted
  1. ; RCORLN - Original Term Length of the payments
  1. ; RCNEWLN - New Term Length
  1. ; RCSTDT - Plan start date (required for initial schedule, optional for adjustments)
  1. ;
  1. N DA,DIK,RCFLG,RCLP,RCLP1,RCPD,RCSUB
  1. ;
  1. S RCSTDT=$G(RCSTDT)
  1. S RCFLG=0
  1. ; Find the last date by looking for the last entry and grabbing the first piece.
  1. I RCSTDT="" S RCSTDT=$P($G(^RCRP(340.5,RCIEN,2,RCORLN,0)),U,1),RCFLG=1
  1. ; Clear RPP Temp array
  1. K ^TMP("RCRPP",$J)
  1. ;find all of the payments paid, stop on the first unpaid.
  1. S RCLP=0 F S RCLP=$O(^RCRP(340.5,RCIEN,2,RCLP)) Q:'RCLP S RCPD=$P($G(^RCRP(340.5,RCIEN,2,RCLP,0)),U,2) Q:'RCPD
  1. ; Count the new remaining payment out.
  1. S RCLP1=RCLP+RCNEWLN-1 ;first missing payment + new length of payment - 1 for the first missing payment)
  1. ; remove the remaining payments from schedule
  1. F S RCLP1=$O(^RCRP(340.5,RCIEN,2,RCLP1)) Q:'RCLP1 D
  1. .S DA(1)=RCIEN,DA=RCLP1,DIK="^RCRP(340.5,"_DA(1)_",2,"
  1. .D ^DIK K DA,DIK
  1. .Q
  1. ; add new payments to schedule.
  1. D BLDPLN^RCRPU(RCSTDT,(RCNEWLN-RCORLN),RCFLG)
  1. ; Add the new months to the Schedule
  1. ; Update the Schedule Node
  1. S RCSUB=0 F S RCSUB=$O(^TMP("RCRPP",$J,"PLAN",RCSUB)) Q:'RCSUB D UPDSCHED^RCRPU(RCIEN,RCSUB)
  1. ; Clear temp array
  1. K ^TMP("RCRPP",$J)
  1. ;
  1. Q
  1. ;
  1. NEWAUDT(RCRPIEN) ; create new entry in sub-file 340.54
  1. ;
  1. ; RCRPIEN - file 340.5 ien
  1. ;
  1. N FDA,IENS
  1. S IENS="+1,"_RCRPIEN_","
  1. S FDA(340.54,IENS,.01)=DT ; date of change
  1. S FDA(340.54,IENS,1)="N" ; type of change = "NEW"
  1. S FDA(340.54,IENS,2)=.5 ; who changed = POSTMASTER
  1. S FDA(340.54,IENS,3)="N" ; comment = "NEW PLAN"
  1. D UPDATE^DIE("","FDA")
  1. Q
  1. ;
  1. MSG(BILCNT,RPPCNT) ; send Mailman notification for # of bills converted
  1. ;
  1. ; BILCNT - number of converted bills
  1. ; RPPCNT - number of repayment plans created
  1. ;
  1. N BAL,CNT,DEBTOR,DIFROM,IENS,RPIEN,RPPID,SSN,STAT,XMDUZ,XMMG,XMSUB,XMTEXT,XMY,Z
  1. D MES^XPDUTL("Sending conversion message...")
  1. S CNT=1,^TMP("PRCAP377",$J,"MSG",CNT)="Conversion of existing repayment plans has been completed"
  1. S CNT=CNT+1,^TMP("PRCAP377",$J,"MSG",CNT)="Total number of repayment plans created: "_RPPCNT
  1. S CNT=CNT+1,^TMP("PRCAP377",$J,"MSG",CNT)="Total number of bills converted: "_BILCNT
  1. S CNT=CNT+1,^TMP("PRCAP377",$J,"MSG",CNT)=""
  1. ;
  1. I RPPCNT>0 D
  1. .S CNT=CNT+1,^TMP("PRCAP377",$J,"MSG",CNT)="The following repayment plans have been created:"
  1. .S CNT=CNT+1,^TMP("PRCAP377",$J,"MSG",CNT)=""
  1. .S CNT=CNT+1,^TMP("PRCAP377",$J,"MSG",CNT)="Repayment Plan ID Debtor SSN Status Balance"
  1. .S CNT=CNT+1,^TMP("PRCAP377",$J,"MSG",CNT)="-------------------------------------------------------------------------------"
  1. .S RPIEN="" F S RPIEN=$O(^TMP("PRCAP377",$J,"CNV",RPIEN)) Q:RPIEN="" D
  1. ..S Z=$G(^TMP("PRCAP377",$J,"CNV",RPIEN)),RPPID=$P(Z,U),DEBTOR=$P(Z,U,2)
  1. ..S IENS=RPIEN_",",STAT=$$GET1^DIQ(340.5,IENS,.07),BAL=$$GET1^DIQ(340.5,IENS,.11)
  1. ..S Z=$$SSN^RCFN01(DEBTOR),SSN=$E(Z,$L(Z)-3,$L(Z)) I SSN'>0 S SSN=" N/A" ; last 4 of ssn
  1. ..S CNT=CNT+1
  1. ..S ^TMP("PRCAP377",$J,"MSG",CNT)=RPPID_" "_$$LJ^XLFSTR($$NAM^RCFN01(DEBTOR),"30T")_" "_SSN_" "_STAT_" $"_$FN(BAL,"",2)
  1. ..Q
  1. .Q
  1. S XMSUB="PRCA*4.5*377 AR REPAYMENT PLAN CONVERSION",XMDUZ="AR PACKAGE"
  1. S XMY("G.RC REPAY PLANS")="",XMTEXT="^TMP(""PRCAP377"","_$J_",""MSG"","
  1. D ^XMD
  1. I $G(XMMG) D MES^XPDUTL(XMMG)
  1. K ^TMP("PRCAP377",$J,"MSG")
  1. D MES^XPDUTL(" Done.")
  1. Q
  1. ;
  1. MSG1 ; send Mailman notification for exception report
  1. N BILL,CNT,DEBTOR,DIFROM,XMDUZ,XMMG,XMSUB,XMTEXT,XMY
  1. I '$D(^TMP("PRCAP377",$J,"AMNT")),'$D(^TMP("PRCAP377",$J,"CAT")) Q ; nothing to send - bail out
  1. D MES^XPDUTL("Sending exceptions report message...")
  1. S CNT=1,^TMP("PRCAP377",$J,"MSG",CNT)="The following exceptions were encountered during the conversion:"
  1. S CNT=CNT+1,^TMP("PRCAP377",$J,"MSG",CNT)=""
  1. I $D(^TMP("PRCAP377",$J,"AMNT")) D
  1. .S CNT=CNT+1,^TMP("PRCAP377",$J,"MSG",CNT)="Bills not added to converted plan. Repay amount associated"
  1. .S CNT=CNT+1,^TMP("PRCAP377",$J,"MSG",CNT)="with individual bill differs from plan. Please review."
  1. .S CNT=CNT+1,^TMP("PRCAP377",$J,"MSG",CNT)=""
  1. .S DEBTOR="" F S DEBTOR=$O(^TMP("PRCAP377",$J,"AMNT",DEBTOR)) Q:DEBTOR="" D
  1. ..S BILL="" F S BILL=$O(^TMP("PRCAP377",$J,"AMNT",DEBTOR,BILL)) Q:BILL="" D
  1. ...S CNT=CNT+1
  1. ...S ^TMP("PRCAP377",$J,"MSG",CNT)=$$LJ^XLFSTR($$NAM^RCFN01(DEBTOR),"30T")_" "_$$LJ^XLFSTR($$GET1^DIQ(430,BILL_",",.01),"15T")_" $"_$FN(^TMP("PRCAP377",$J,"AMNT",DEBTOR,BILL),"",2)
  1. ...Q
  1. ..Q
  1. .S CNT=CNT+1,^TMP("PRCAP377",$J,"MSG",CNT)=""
  1. .Q
  1. I $D(^TMP("PRCAP377",$J,"CAT")) D
  1. .S CNT=CNT+1,^TMP("PRCAP377",$J,"MSG",CNT)="Bills with AR categories not eligible for conversion"
  1. .S CNT=CNT+1,^TMP("PRCAP377",$J,"MSG",CNT)=""
  1. .S DEBTOR="" F S DEBTOR=$O(^TMP("PRCAP377",$J,"CAT",DEBTOR)) Q:DEBTOR="" D
  1. ..S BILL="" F S BILL=$O(^TMP("PRCAP377",$J,"CAT",DEBTOR,BILL)) Q:BILL="" D
  1. ...S CNT=CNT+1
  1. ...S ^TMP("PRCAP377",$J,"MSG",CNT)=$$LJ^XLFSTR($$NAM^RCFN01(DEBTOR),"30T")_" "_$$LJ^XLFSTR($$GET1^DIQ(430,BILL_",",.01),"15T")_" "_$$LJ^XLFSTR($$GET1^DIQ(430.2,^TMP("PRCAP377",$J,"CAT",DEBTOR,BILL)_",",.01),"15T")
  1. ...Q
  1. ..Q
  1. .Q
  1. S XMSUB="PRCA*4.5*377 AR REPAYMENT PLAN CONVERSION EXCEPTIONS",XMDUZ="AR PACKAGE"
  1. S XMY("G.RC REPAY PLANS")="",XMTEXT="^TMP(""PRCAP377"","_$J_",""MSG"","
  1. D ^XMD
  1. I $G(XMMG) D MES^XPDUTL(XMMG)
  1. K ^TMP("PRCAP377",$J,"MSG")
  1. D MES^XPDUTL(" Done.")
  1. Q
  1. ;
  1. MSG2 ; send Mailman notification for TOP/DMC report
  1. N BILL,CNT,DEBTOR,DIFROM,RCRPIEN,REF,XMDUZ,XMMG,XMSUB,XMTEXT,XMY
  1. I '$D(^TMP("PRCAP377",$J,"REF")) Q ; nothing to send - bail out
  1. D MES^XPDUTL("Sending TOP/DMC referrals report message...")
  1. S CNT=1,^TMP("PRCAP377",$J,"MSG",CNT)="The following bills are referred to TOP /DMC:"
  1. S CNT=CNT+1,^TMP("PRCAP377",$J,"MSG",CNT)=""
  1. S DEBTOR="" F S DEBTOR=$O(^TMP("PRCAP377",$J,"REF",DEBTOR)) Q:DEBTOR="" D
  1. .S RCRPIEN="" F S RCRPIEN=$O(^TMP("PRCAP377",$J,"REF",DEBTOR,RCRPIEN)) Q:RCRPIEN="" D
  1. ..S BILL="" F S BILL=$O(^TMP("PRCAP377",$J,"REF",DEBTOR,RCRPIEN,BILL)) Q:BILL="" D
  1. ...S REF=^TMP("PRCAP377",$J,"REF",DEBTOR,RCRPIEN,BILL)
  1. ...S CNT=CNT+1
  1. ...S ^TMP("PRCAP377",$J,"MSG",CNT)=$$LJ^XLFSTR($$NAM^RCFN01(DEBTOR),"30T")_" "_$$LJ^XLFSTR($$GET1^DIQ(340.5,RCRPIEN_",",.01),"20T")
  1. ...S ^TMP("PRCAP377",$J,"MSG",CNT)=^TMP("PRCAP377",$J,"MSG",CNT)_" "_$$LJ^XLFSTR($$GET1^DIQ(430,BILL_",",.01),"15T")_" "_REF
  1. ...Q
  1. ..Q
  1. .Q
  1. S XMSUB="PRCA*4.5*377 AR REPAYMENT PLAN BILLS REFERRED TO TOP/DMC",XMDUZ="AR PACKAGE"
  1. S XMY("G.RC REPAY PLANS")="",XMTEXT="^TMP(""PRCAP377"","_$J_",""MSG"","
  1. D ^XMD
  1. I $G(XMMG) D MES^XPDUTL(XMMG)
  1. K ^TMP("PRCAP377",$J,"MSG")
  1. D MES^XPDUTL(" Done.")
  1. Q
  1. ;
  1. UPD4303 ; Update the Transaction Type file (#430.3) with 3 new Transaction types.
  1. N LOOP,RCIEN,RCDATA,RCCNNM
  1. N X,Y,DIE,DA,DR,DTOUT,EXDATA,RCDATAB,DIK
  1. ;
  1. ; Grab all of the entries to update
  1. D MES^XPDUTL(" -> Adding new Transaction Types into the ACCOUNTS RECEIVABLE TRANS.TYPE file (430.3).")
  1. S Y=-1
  1. F LOOP=1:1 S RCDATA=$T(TRDAT+LOOP) Q:$P(RCDATA,";",3)="END" D
  1. . S DR=""
  1. . ;Extract the new ACTION TYPE to be added.
  1. . ;Store in array for adding to the file (#350.1).
  1. . Q:RCDATA="" ;go to next entry if Category is not to be updated.
  1. . ;
  1. . S RCCNNM=$P(RCDATA,";",3)
  1. . S RCIEN=$O(^PRCA(430.3,"B",RCCNNM,""))
  1. . Q:RCIEN>0
  1. . ; File the update along with inactivate the ACTION TYPE
  1. . S DLAYGO=430.3,DIC="^PRCA(430.3,",DIC(0)="L",X=RCCNNM
  1. . I '+RCIEN D FILE^DICN S RCIEN=+Y K DIC,DINUM,DLAYGO
  1. . S DR="1////"_$P(RCDATA,";",4) ; ABBREVIATION
  1. . S DR=DR_";2////"_$P(RCDATA,";",5) ; STATUS NUMBER
  1. . S DR=DR_";3////"_$P(RCDATA,";",6) ; CALM CODE
  1. . S DR=DR_";5////"_$P(RCDATA,";",8) ; CBO EXTRACT FLAG
  1. . ;
  1. . S DIE="^PRCA(430.3,",DA=RCIEN
  1. . D ^DIE
  1. . K DR,DA,DIE
  1. . ;re-index new entry here
  1. . S DA=RCIEN,DIK="^PRCA(430.3,"
  1. . D IX^DIK
  1. . K DR,DA,DIK
  1. Q
  1. ;
  1. TRDAT ; Fee Service to inactivate
  1. ;;EDIT REPAYMENT PLAN;EZ;67;0;;0
  1. ;;CLOSE REPAYMENT PLAN;RZ;68;0;;0
  1. ;;RPP TERMINATED;RT;69;0;;0
  1. ;;END
  1. Q
  1. ;
  1. ADDRPP ; Update the Transaction Type file (#430.3) with data for the new Repayment Plan field.
  1. N LOOP,RCIEN,RCDATA,RCCNNM
  1. N X,Y,DIE,DA,DR,DTOUT,EXDATA,RCDATAB,DIK
  1. ;
  1. ; Grab all of the entries to update
  1. D MES^XPDUTL(" -> Updating entries in the ACCOUNTS RECEIVABLE TRANS.TYPE file (430.3). to populate the REPAYMENT PLAN PROCESS field.")
  1. S Y=-1
  1. F LOOP=1:1 S RCDATA=$T(RPPDAT+LOOP) Q:$P(RCDATA,";",3)="END" D
  1. . S DR=""
  1. . ;Extract the new ACTION TYPE to be added.
  1. . ;Store in array for adding to the file (#350.1).
  1. . Q:RCDATA="" ;go to next entry if Category is not to be updated.
  1. . ;
  1. . S RCCNNM=$P(RCDATA,";",3)
  1. . S RCIEN=$O(^PRCA(430.3,"B",RCCNNM,""))
  1. . ; File the update along with inactivate the ACTION TYPE
  1. . S DLAYGO=430.3,DIC="^PRCA(430.3,",DIC(0)="L",X=RCCNNM
  1. . I '+RCIEN D FILE^DICN S RCIEN=+Y K DIC,DINUM,DLAYGO
  1. . S DR="6////"_$P(RCDATA,";",4) ; ABBREVIATION
  1. . ;
  1. . S DIE="^PRCA(430.3,",DA=RCIEN
  1. . D ^DIE
  1. . ;re-index new entry here
  1. . S DA=RCIEN,DIK="^PRCA(430.3," D IX^DIK
  1. . K DR
  1. Q
  1. ;
  1. RPPDAT ; Transaction Types to update
  1. ;;INCREASE ADJUSTMENT;I
  1. ;;PAYMENT (IN PART);P
  1. ;;CASH COLLECTION BY RC/DOJ;P
  1. ;;TERM.BY FIS.OFFICER;D
  1. ;;TERM.BY COMPROMISE;D
  1. ;;WAIVED IN FULL;D
  1. ;;WAIVED IN PART;D
  1. ;;ADMIN.COST CHARGE;I
  1. ;;INTEREST/ADM. CHARGE;I
  1. ;;EXEMPT INT/ADM. COST;D
  1. ;;WRITE-OFF;D
  1. ;;MARSHAL/COURT COST;I
  1. ;;TERM.BY RC/DOJ;D
  1. ;;PAYMENT (IN FULL);P
  1. ;;DECREASE ADJUSTMENT;D
  1. ;;CHARGE SUSPENDED;D
  1. ;;RE-ESTABLISH;I
  1. ;;END
  1. Q