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

BARDMBS.m

Go to the documentation of this file.
BARDMBS ; IHS/OIT/FCJ - DEBT MANAGEMENT BILL SEARCH ; 26 May 2011  8:41 AM
 ;;1.8;IHS ACCOUNTS RECEIVABLE;**22,23,24**;OCT 26, 2005;Build 69
 ;New routine 5-12-2011 for Debt Letter Management
 ;
 ;Search the A/R Bill file for overdue bills and
 ;and queue letters for overdue bills.
 ;IHS/SD/POT JULY 2013 FIXED BAREND IN DATE "AG" LOOP - BAR*1.8*.23
 ;IHS/SD/POT HEAT152452 2/10/2014 CHK IF PAR/SAT FILE CORECTLY SET UP - BAR*1.8*.24
ST ;
 ;
 D PAR^BARDMU
 G:$G(BARQ) XIT ;P.OTT HEAT152452 2/10/2014 - BAR*1.8*.24
 D VAR
 I $G(BARRPT)'="C" D PARCHK
 G:$G(BARQ) XIT
 I IOST["C-",'$D(IO("S")) W !!,"Searching for overdue bills..."
 ;S BARPSDI-EFF DT,BARDRDT-RUN DATE
 ;start new code bar*1.8*22 SDR
 S X1=BARDRDT
 S X2=-(BARPCD(1)-1)
 D C^%DTC
 S BARDRDT=X
 K X,X1,X2
 ;end new code bar*1.8*22 SDR
 S BARDRDT=$S(BARDRDT<1:BARPSDI,1:BARDRDT)   ;OR EFFECTIVE DATE OR THE LAST TIME RAN, UPDATING INS LIST WILL RESET RUN DATE
 ;start old code bar*1.8*22 SDR
 ;F  S BARDADT=$O(^BARBL(DUZ(2),"AG",BARDADT)) Q:BARDADT=""  D
 ;.Q:BARDADT'<BARDMDT
 ;end old code start new code bar*1.8*22 SDR
 F  S BARDRDT=$O(^BARBL(DUZ(2),"AG",BARDRDT)) Q:BARDRDT=""!(BARDRDT\1>BARDADT)  D  ;- BAR*1.8*.23
 .Q:BARDRDT'<BARDADT
 .;end new code bar*1.8*22 SDR
 .D CHKBIL
 ;I IOST["C-",'$D(IO("S")) W !!,"Number of NEW overdue bills found: ",CNT  ;bar*1.8*22 SDR
 I IOST["C-",'$D(IO("S")) W !!,"Number of NEW overdue bills found: ",BARCNT  ;bar*1.8*22 SDR
 S DIE="^BAR(90052.06,"_BARPIEN_",",DA=DUZ(2)
 S DR="1807///"_DT
 D ^DIE
XIT ;
 ;K BARDADT,BARDMDT,CNT,SUBCNT,DIR,DIE,DR,DA  ;bar*1.8*22 SDR
 K BARDADT,BARDMDT,BARCNT,BARSBCNT,DIR,DIE,DR,DA  ;bar*1.8*22 SDR
 Q
 ;
VAR ;
 ;W $$EN^BARVDF("IOF")  ;bar*1.8*22 SDR
 I IOST["C-",'$D(IO("S")) W $$EN^BARVDF("IOF")  ;bar*1.8*22 SDR
 ;S CNT=0  ;bar*1.8*22 SDR
 S BARCNT=0  ;bar*1.8*22 SDR
 ;S SUBCNT=0  ;bar*1.8*22 SDR
 S BARSBCNT=0  ;bar*1.8*22 SDR
 K DIR
 ;
 ;CALCULATES LETTER 1 PRINT DATE
 S X1=DT
 S X2=-(BARPCD(1)-1)
 D C^%DTC
 S (BARDADT,BARDMDT)=X
 K X,X1,X2
 ;
 ;SET UP ARRAY FOR INS TYPE
 ;start old code bar*1.8*22 SDR
 ;S L=0 
 ;F  S L=$O(^BAR(90052.06,BARPIEN,DUZ(2),19,L)) Q:L'?1N.N  D
 ;.S L1=$P(^BAR(90052.06,BARPIEN,DUZ(2),19,L,0),U)
 ;.S L2=$P($G(^BAR(90053.03,L1,0)),U,2)
 ;.I L2'="" S BARDINS(L2)=""
 ;end old code start new code
 S BARL=0
 F  S BARL=$O(^BAR(90052.06,BARPIEN,DUZ(2),19,BARL)) Q:BARL'?1N.N  D
 .S BARL1=$P(^BAR(90052.06,BARPIEN,DUZ(2),19,BARL,0),U)
 .S BARL2=$$GET1^DIQ(90053.03,BARL1,".01","E")
 .I BARL2'="" S BARDINS(BARL2)=""
 ;end new code
 Q
 ;
PARCHK ;CHECK FOR REQUIRED PARAMETERS
 S BARQ=0
 S BARPAR1=^BAR(90052.06,BARPIEN,DUZ(2),18)
 ;start old code bar*1.8*22 SDR
 ;F L=1:1:4 I (BARPCD(L)="")!(BARPCL(L)="") S BARQ=1 D ERRMSG Q
 ;F L=1,13,14 I $P(BARPAR,U,L)="" S BARQ=1 D ERRMSG Q
 ;F L=1,3,4,5,6,8 I $P(BARPAR1,U,L)="" S BARQ=1 D ERRMSG Q
 ;end old code start new code
 F BARL=1:1:4 I (BARPCD(BARL)="")!(BARPCL(BARL)="") S BARQ=1 D ERRMSG Q
 F BARL=1,13,14 I $P(BARPAR,U,BARL)="" S BARQ=1 D ERRMSG Q
 F BARL=1,3,4,5,6,8 I $P(BARPAR1,U,BARL)="" S BARQ=1 D ERRMSG Q
 ;end new code
 Q
ERRMSG ;
 W !?5,"All of the Required parameters are not set up. You will need to set",!,"these up to continue.",!
 D RTRN^BARDMU
 Q
 ; 
CHKBIL ;
 ;CHECKS FOR BILL AMOUNT > 0
 S BARBIEN=0
 ;F  S BARBIEN=$O(^BARBL(DUZ(2),"AG",BARDADT,BARBIEN)) Q:BARBIEN=""  D  ;bar*1.8*22 SDR
 F  S BARBIEN=$O(^BARBL(DUZ(2),"AG",BARDRDT,BARBIEN)) Q:BARBIEN=""  D  ;bar*1.8*22 SDR
 .;S SUBCNT=SUBCNT+1  ;bar*1.8*22 SDR
 .S BARSBCNT=BARSBCNT+1  ;bar*1.8*22 SDR
 .;I IOST["C-",'$D(IO("S")),SUBCNT#1000 W "."  ;bar*1.8*22 SDR
 .I IOST["C-",'$D(IO("S")),BARSBCNT#1000 W "."  ;bar*1.8*22 SDR
 .;CHECK IF BILL ALREADY IN BARDM
 .Q:$D(^BARDM(DUZ(2),"B",BARBIEN))
 .;CHECKS FOR BILL AMOUNT > 0
 .Q:$P(^BARBL(DUZ(2),BARBIEN,0),U,15)'>0
 .;CHECKS FOR ACCOUNT AND INSURER TYPE
 .; BARDAC=0  ;ACCT POINTER
 .S BARDAC=$P(^BARBL(DUZ(2),BARBIEN,0),U,3)
 .;TEST ACCOUNT FOR TSI TRANSMISSION
 .;I $D(^BAR(90052.06,BARPIEN,DUZ(2),13,"B",BARDAC)) S R=$O(^BAR(90052.06,BARPIEN,DUZ(2),13,"B",BARDAC,0)) Q:$P(^BAR(90052.06,BARPIEN,DUZ(2),13,R,0),U,2)=0  ;bar*1.8*22 SDR
 .I $D(^BAR(90052.06,BARPIEN,DUZ(2),13,"B",BARDAC)) S BARR=$O(^BAR(90052.06,BARPIEN,DUZ(2),13,"B",BARDAC,0)) Q:$P(^BAR(90052.06,BARPIEN,DUZ(2),13,BARR,0),U,2)=0  ;bar*1.8*22 SDR
 .Q:$P(^BARAC(DUZ(2),BARDAC,0),U,7)="N"
 .I $P(^BARAC(DUZ(2),BARDAC,0),U,7)="Y" D ADD Q   ;TEST ACCT=YES
 .;TEST INSURANCE TYPE
 .D INSTYP^BARDMU
 .I BARDITY'="",$D(BARDINS(BARDITY)) D ADD Q
 Q
 ;
ADD ;ADD BILL TO A/R DEBT MAN
 K DD,DO,DINUM
 S (DIE,DIC)="^BARDM("_DUZ(2)_",",DIC(0)="L",X=BARBIEN
 D FILE^DICN
 S:+Y>0 BARDIEN=+Y
 I +Y<0 W !,"ERROR ADDING BILL NUMBER: ",$P(^BARBL(DUZ(2),BARBIEN,0),U) Q
 S DR=".02///A"
 D ^DIE
 ;ADD SUB ENTRY STATUS
 S DA(1)=BARDIEN
 S DIC="^BARDM("_DUZ(2)_","_BARDIEN_",50,",DIC(0)="L",X=DT
 S DIC("P")=$P(^DD(90053.05,50,0),U,2)
 D FILE^DICN
 S:+Y>0 DA=+Y
 I +Y<0 W !,"ERROR ADDING STATUS COMMENTS ENTRY " Q
 S DIE=DIC
 S DR=".02///"_DUZ_";.03///A"
 D ^DIE
 ;ADD LETTER TO SUB-RECORD
 S DA(1)=BARDIEN
 S DIC="^BARDM("_DUZ(2)_","_BARDIEN_",100,",DIC(0)="L",X="CYCLE 1"
 S DIC("P")=$P(^DD(90053.05,100,0),U,2)
 D FILE^DICN
 S:+Y>0 DA=+Y
 I +Y<0 W !,"ERROR ADDING CYCLE ENTRY TO DEBT BILL: ",$P(^BARBL(DUZ(2),BARBIL,0),U) Q
 S DIE=DIC
 S DR=".02///"_BARPCL(1)_";.03///Q"_";.06///"_$P(^BARBL(DUZ(2),BARBIEN,0),U,15)
 D ^DIE
 ;Q WRITE ERROR MESSAGE
 ;S CNT=CNT+1  ;bar*1.8*22 SDR
 S BARCNT=BARCNT+1  ;bar*1.8*22 SDR
 K DIC,DIE,DR,DA
 Q
 ;