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

BARDMAN2.m

Go to the documentation of this file.
  1. BARDMAN2 ; IHS/SD/LSL - A/R Debt Collection Process (2) ;08/20/2008
  1. ;;1.8;IHS ACCOUNTS RECEIVABLE;**7**;OCT 26, 2005
  1. ;
  1. ; IHS/SD/LSL - 04/08/2004 - V1.8
  1. ; Routine created. Moved (modified) from BBMDC2
  1. ; Callable entry points from BARDMAN that will find bills
  1. ; needing to be sent to Transworld for Stop/Start Collection.
  1. ; This routine calls one of four entry points to BARDMAN3 that
  1. ; build a temporary global of the necessary data.
  1. ; MODIFIED XTMP FILE NAME TO TMP TO MEET SAC REQUIREMENTS;MRS:BAR*1.8*7 IM29892
  1. ; ********************************************************************
  1. ;
  1. ; Verify the following 2 entries exist in ZISH SEND PARAMETERS file or
  1. ; the creation and sending of files won't work.
  1. ;
  1. ; 1. BAR DCM F (foreground)
  1. ; 2. BAR DCM B (background or queued)
  1. ;
  1. ; ********************************************************************
  1. Q
  1. ;
  1. FINDSTOP ; EP
  1. ; Loop log and create stops for bills with a changed balance in this DUZ(2)
  1. ; code of 1 - bill is adjusted to 0 - stop collection service
  1. ; code of 5 = bill is paid in full - stop collection service
  1. ; code of A = an adjustment has been made to the previous service
  1. S BARSYMB=0
  1. S BARTCNT=0
  1. S BARL=0
  1. S BARSSELF=0 ; Initialize self pay stop counter
  1. S BARSINS=0 ; Initialize insurer stop counter
  1. ;
  1. ; Loop Active log entries
  1. F S BARL=$O(^BARDEBT("AD",1,BARL)) Q:'+BARL D ACTLOG
  1. S ^TMP($J,"BAR-STOPS-CNT")=BARTCNT
  1. Q
  1. ; ********************************************************************
  1. ;
  1. ACTLOG ;
  1. ; For each active log entry do the following...
  1. S BARSYMB=BARSYMB+1
  1. S:BARSYMB>10 BARSYMB=1
  1. W:'$D(BARQUIET) $C(32+BARSYMB),$C(8)
  1. Q:($P($G(^BARDEBT(BARL,0)),U,8)'=DUZ(2)) ; log entry not this fac
  1. Q:($P($G(^BARDEBT(BARL,0)),U,2)="") ; No bill # this log ent
  1. S BARLDT=$P($G(^BARDEBT(BARL,0)),U) ; Log date
  1. S X1=DT
  1. S X2=-160 ; Changed from 100 per Sandra Lahi 4/13/04
  1. D C^%DTC
  1. S BARCHKDT=X
  1. ;
  1. ; Log entry 100 days old, mark inactive, don't send stop
  1. I +BARLDT,BARLDT<BARCHKDT D INACTREC Q
  1. S BARLBAL=$P($G(^BARDEBT(BARL,0)),U,3) ; Bill Balance on log
  1. S BARBL=$P(^BARDEBT(BARL,0),U,2) ; IEN A/R Bill File
  1. S BARBAL=$P($G(^BARBL(DUZ(2),BARBL,0)),U,15) ; Bill Bal AR bill
  1. Q:+BARLBAL=+BARBAL ; Balances same, no stop
  1. I BARBAL>0 S BARACT="A"
  1. E S BARACT=$$GETTX(BARBL)
  1. S BARBLNM=$$GET1^DIQ(90050.01,BARBL,.01)
  1. S BARBLNM=$TR(BARBLNM,"-","") ; Don;t send - in bill name
  1. S:BARBAL<0 BARBAL=0 ; Don't send negative
  1. S BARX=$P(BARBAL,".")_"."_$P(BARBAL,".",2)_"00"
  1. S BARBAL=$P(BARX,".")_$E($P(BARX,".",2),1,2)
  1. I $P($G(^BARDEBT(BARL,0)),U,6)="S",$L(BARSNUM) D Q
  1. . D SSELFILE^BARDMAN3 ; Build self pay stops global
  1. . S BARTCNT=BARTCNT+1
  1. I $P($G(^BARDEBT(BARL,0)),U,6)="I",$L(BARINUM) D Q
  1. . D SINSFILE^BARDMAN3 ; Build insurer stops global
  1. . S BARTCNT=BARTCNT+1
  1. Q
  1. ; ********************************************************************
  1. ;
  1. INACTREC ;
  1. K DIE,DA,DR
  1. S DIE="^BARDEBT("
  1. S DA=BARL
  1. S DR=".05////^S X=0"
  1. D ^DIE
  1. Q
  1. ; ********************************************************************
  1. ;
  1. GETTX(BARBL) ; EP
  1. ;
  1. ;** this function is only called if the current balance is 0
  1. ;** find last transaction - determine if it is a payment
  1. ; if last tx is a payment, pass the action code 5 (paid in full)
  1. ; if last tx is an adj., pass the action code 1 (cancel)
  1. ;
  1. N BARPMT
  1. S BARTR=$O(^BARTR(DUZ(2),"AC",BARBL,""),-1)
  1. I '+BARTR Q 1
  1. S BARPMT=$$GET1^DIQ(90050.03,BARTR,3.6)
  1. Q $S(+BARPMT:5,1:1)
  1. ; ********************************************************************
  1. ; ********************************************************************
  1. ;
  1. FINDSTRT ; EP
  1. ; search A/R Bill file for this DUZ(2) for matches to extract to data file
  1. S X1=DT
  1. S X2=-365
  1. D C^%DTC
  1. S BARYRCHK=X ; Date 1 yr ago
  1. S BARTCNT=0
  1. S BARSYMB=0
  1. S BARTSELF=0 ; Initialize self pay start counter
  1. S BARTSINS=0 ; Initialize insurer start counter
  1. S BARIRCHD=0 ; Max ins transaction reached
  1. S BARSRCHD=0 ; Max self pay transaction reached
  1. S BARDT=BARSTART-.5
  1. S BAREND=BAREND_".9999999"
  1. ;
  1. ; Loop 3P Approval Date x-ref of AR bill for approval dates within
  1. ; selected range.
  1. F S BARDT=$O(^BARBL(DUZ(2),"AG",BARDT)) Q:'+BARDT!(BARDT>BAREND) D LOOP
  1. S ^TMP($J,"BAR-STARTS-CNT")=BARTCNT
  1. Q
  1. ; ********************************************************************
  1. ;
  1. LOOP ;
  1. ; For each valid 3P approval date do...
  1. S BARBL=0
  1. F S BARBL=$O(^BARBL(DUZ(2),"AG",BARDT,BARBL)) Q:'+BARBL D BILL
  1. Q
  1. ; ********************************************************************
  1. ;
  1. BILL ;
  1. S BARSYMB=BARSYMB+1
  1. S:BARSYMB>10 BARSYMB=1
  1. W:'$D(BARQUIET) $C(32+BARSYMB),$C(8)
  1. ;
  1. ; Check balance on greater than limit
  1. S BARBAL=$$GET1^DIQ(90050.01,BARBL,15)
  1. Q:(BARBAL<BARAMT)
  1. ;
  1. ; Check DOS after earliest DOS allowed
  1. S BARDOS=$$GET1^DIQ(90050.01,BARBL,102,"I") ; DOS Begin of AR bill
  1. I $G(BAREDOS),BARDOS<BAREDOS Q
  1. ;
  1. ; Check A/R Bill already sent for collection
  1. S BARL=$O(^BARDEBT("C",BARBL,0))
  1. I +BARL D Q:(BARLOC=DUZ(2)) ; AR bill IEN in log
  1. . S BARLOC=$P($G(^BARDEBT(BARL,0)),U,8)
  1. ;
  1. ; Check to see if A/R Account on bill is restricted
  1. S BARAC=$$GET1^DIQ(90050.01,BARBL,"3","I")
  1. Q:'+BARAC ; No AR Account on bill
  1. S BARACTP=$$GET1^DIQ(90050.02,BARAC,1)
  1. K BARNOGO
  1. I BARACTP=9999999.18 D Q:$D(BARNOGO)
  1. . I $D(^BAR(90052.06,DUZ(2),DUZ(2),13,"B",BARAC)) D
  1. . . S BAR13IEN=$O(^BAR(90052.06,DUZ(2),DUZ(2),13,"B",BARAC,""))
  1. . . S BARESTRT=$P($G(^BAR(90052.06,DUZ(2),DUZ(2),13,BAR13IEN,0)),U,2)
  1. . . S:BARESTRT=1 BARNOGO=1
  1. . I (BARICUR>BARIMAX!(BARICUR=BARIMAX)) S BARNOGO=1
  1. S BARCAT=""
  1. ;
  1. ; Check if AR Account, TSI Account Number
  1. I BARACTP=9999999.18,$L(BARINUM) S BARCAT="I"
  1. ;
  1. ; Check if Self Pay, age less 1 yr, TSI Self Pay Number
  1. I BARACTP=9000001 D
  1. . Q:BARSNUM=""
  1. . Q:BARSCUR>BARSMAX
  1. . Q:BARSCUR=BARSMAX
  1. . Q:(BARDT<BARYRCHK)
  1. . S BARCAT="S"
  1. Q:BARCAT=""
  1. S BARBLNMD=$$GET1^DIQ(90050.01,BARBL,.01) ;bill number - w/dashes
  1. S BARBLNM=$TR(BARBLNMD,"-","") ;bill number - strip dashes
  1. S BARX=$P(BARBAL,".")_"."_$P(BARBAL,".",2)_"00"
  1. S BARBAL=$P(BARX,".")_$E($P(BARX,".",2),1,2)
  1. I BARCAT="I" D Q:+BARIRCHD
  1. . S BARICUR=BARICUR+1
  1. . I BARICUR>BARIMAX S BARIRCHD=BARICUR Q
  1. . D TINSFILE^BARDMAN3 ; Build Insurer Starts global
  1. I BARCAT="S" D Q:+BARSRCHD
  1. . S BARSCUR=BARSCUR+1
  1. . I BARSCUR>BARSMAX S BARSRCHD=BARSCUR Q
  1. . D TSELFILE^BARDMAN3 ; Build Self Pay Starts global
  1. S BARTCNT=BARTCNT+1
  1. Q
  1. ; ********************************************************************
  1. ;
  1. SEND ; EP
  1. ; Using XBGSAVE, create local files from the 4 globals and send them
  1. ; to the ITSC Server.
  1. D NOW^%DTC
  1. S BARTM=$E($P(%,".",2),1,4)
  1. S BARJDT=$$JDT^XBFUNC(DT)
  1. ;
  1. I $D(^BARSSELF) D
  1. . S (XBFN,BARSSFN)="bar-stop-self-"_BARSNUM_"-"_BARTM_"-"_BARJDT_".dat"
  1. . S XBGL="BARSSELF("
  1. . D SENDFILE
  1. . I XBFLG=0 D
  1. . . W:'$D(BARQUIET) !!,"File ",BARSSFN," sent. Updating LOG with Self Pay Stops"
  1. . . D LOGSSELF^BARDMAN4
  1. . I +XBFLG,'$D(BARQUIET) D
  1. . . W !!,"Creation/Send of file ",BARSSFN," was unsuccessful."
  1. . . W !,XBFLG(1)
  1. . D:$D(BARQUIET) PAZ^BARRUTL
  1. ;
  1. I $D(^BARSTOPS) D
  1. . S (XBFN,BARSIFN)="bar-stop-ins-"_BARINUM_"-"_BARTM_"-"_BARJDT_".dat"
  1. . S XBGL="BARSTOPS("
  1. . D SENDFILE
  1. . I XBFLG=0 D
  1. . . W:'$D(BARQUIET) !!,"File ",BARSIFN," sent. Updating LOG with Insurer Stops"
  1. . . D LOGSTOP^BARDMAN4
  1. . I +XBFLG,'$D(BARQUIET) D
  1. . . W !!,"Creation/Send of file ",BARSIFN," was unsuccessful."
  1. . . W !,XBFLG(1)
  1. . D:'$D(BARQUIET) PAZ^BARRUTL
  1. ;
  1. I $D(^BARTSELF) D
  1. . S (XBFN,BARTSFN)="bar-start-self-"_BARSNUM_"-"_BARTM_"-"_BARJDT_".dat"
  1. . S XBGL="BARTSELF("
  1. . D SENDFILE
  1. . I XBFLG=0 D
  1. . . W:'$D(BARQUIET) !!,"File ",BARTSFN," sent. Updating LOG with Self Pay Starts"
  1. . . D LOGTSELF^BARDMAN4
  1. . I +XBFLG,'$D(BARQUIET) D
  1. . . W !!,"Creation/Send of file ",BARTSFN," was unsuccessful."
  1. . . W !,XBFLG(1)
  1. . D:'$D(BARQUIET) PAZ^BARRUTL
  1. ;
  1. I $D(^BARSTART) D
  1. . S (XBFN,BARTIFN)="bar-start-ins-"_BARINUM_"-"_BARTM_"-"_BARJDT_".dat"
  1. . S XBGL="BARSTART("
  1. . D SENDFILE
  1. . I XBFLG=0 D
  1. . . W:'$D(BARQUIET) !!,"File ",BARTIFN," sent. Updating LOG with Insurer Starts"
  1. . . D LOGSTART^BARDMAN4
  1. . I +XBFLG,'$D(BARQUIET) D
  1. . . W !!,"Creation/Send of file ",BARTIFN," was unsuccessful."
  1. . . W !,XBFLG(1)
  1. . D:'$D(BARQUIET) PAZ^BARRUTL
  1. Q
  1. ; ********************************************************************
  1. ;
  1. SENDFILE ; EP
  1. ; Create self pay stops and send file to ITSC Server
  1. S XBQSHO=""
  1. S XBF=$J ; Beginning 1st level numeric subscript
  1. S XBE=$J ; Ending 1st level numeric subscript
  1. S XBFLT=1 ; indicates flat file
  1. S XBMED="F" ; Flag indicates file as media
  1. S XBCON=1 ; Q if non-cononic
  1. S XBS1="BAR DCM F" ; ZISH SEND PARAMETERS entry
  1. I $D(ZTQUEUED) S XBS1="BAR DCM B"
  1. S XBQ="N"
  1. ;S BARITSC=$P($G(^BAR(90052.06,DUZ(2),DUZ(2),10)),U,9,11)
  1. S XBUF=$P($G(^BAR(90052.06,DUZ(2),DUZ(2),10)),U,7) ; Local directory for file creation
  1. ;S BARUNAM=$P(BARITSC,U,2) ; Username of system receiving file
  1. ;S BARUPASS=$P(BARITSC,U,3) ; Password of system receiving file
  1. ;S XBQTO=$P(BARITSC,U) ; System id to receive file
  1. ; Include username and password in system id
  1. ;S XBQTO="-l """_BARUNAM_":"_BARUPASS_""" "_XBQTO
  1. ;I XBUF=""!(BARUNAM="")!(BARUPASS="")!(XBQTO="") D Q
  1. I XBUF="" D Q
  1. . S XBFLG=-1
  1. . S XBFLG(1)="Missing local directory. Please check Debt Collection Parameters"
  1. I IO=IO(0) W !!
  1. D ^XBGSAVE
  1. Q