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

BARDYSV1.m

Go to the documentation of this file.
BARDYSV1 ; IHS/SD/TPF - DAYS IN A/R REPORT CALLS ; 
 ;;1.8;IHS ACCOUNTS RECEIVABLE;**1,16,23,28**;OCT 26,2005;Build 92
 ;IHS/SD/POT-1.8*23-FEB 2013 CHANGED PTR TO INSURER TYPE
 ;IHS/SD/POT-1.8*23-APR 2013 RESOLVED NIL VALUES OF INSTYP AND ACTINS
 ;IHS/SD/SDR-1.8*28-Updated p23 documentation
 ;IHS/SD/SDR-1.8*28-HEAT224215 - Added code to look thru DUZ(2)s in 3P Bill file for visit IEN.  Changed couple FM calls to be straight code.
 ;  Lookups were failing due to multiple DUZ(2)s.  Captured detail in "DET" subscript for detail report.  Added code to populate last
 ;  pymt all the time; was only populated if multiple pymts were made.
 Q
 ;GET TOTAL DAYS NEEDED TO APPROVE A BILL
 ;AS WELL AS NEEDED TO EXPORT
 ;TPBDAYS(VISITIEN,VSITADMT,DAYSAPP,DAYSEXP,BILLNUM,AMTBILLD) ;EP -TOTAL DAYS FOR BILL
TPBDAYS(VISITIEN,VSITADMT) ;EP -TOTAL DAYS FOR BILL
 Q:'VISITIEN 0
 N TPBEXP,TPBAPPRO,TEMPAYS,BAMOUNT,BILL3P,TEMPAYS,TPBNOEXP
 S TPBNOEXP=0
 ;start new bar*1.8*28 HEAT224215
 S BILLNUM=0
 S ABMDUZ(2)=0
 F  S ABMDUZ(2)=$O(^ABMDBILL(ABMDUZ(2))) Q:'ABMDUZ(2)  D TPBDAYS2
 Q
TPBDAYS2 ;EP
 ;end new bar*1.8*28 HEAT224215
 S BILLIEN=""
 S FIRST=0,LAST=0  ;bar*1.8*28 HEAT224215
 S BATCHIEN=0,BATCHFIN=0  ;bar*1.8*28 HEAT224215
 ;F  S BILLIEN=$O(^ABMDBILL(DUZ(2),"AV",VISITIEN,BILLIEN)) Q:'BILLIEN  D  ;bar*1.8*28 HEAT224215
 F  S BILLIEN=$O(^ABMDBILL(ABMDUZ(2),"AV",VISITIEN,BILLIEN)) Q:'BILLIEN  D  ;bar*1.8*28 HEAT224215
 .;Q:'$$GETPRV(BILLIEN,$G(BARY("PRV")))
 .S PROV=$$GETPRV^BARDYSV8(BILLIEN,$G(BARY("PRV"))) Q:'PROV  ;FIND PROVIDER CHOSEN OR ONLY ATTEND OR RENDERING
 .S PROV=$P($G(PROV,"^UNDEF"),U,2)
 .;
 .;S BILLSTAT=$$GET1^DIQ(9002274.4,BILLIEN_",",.04,"I")  ;bar*1.8*28 HEAT224215
 .S BILLSTAT=$P($G(^ABMDBILL(ABMDUZ(2),BILLIEN,0)),U,4)  ;bar*1.8*28 HEAT224215
 .S:BILLSTAT="" BILLSTAT="UNDEF"
 .;BILL STATUS VALUES
 .;'R'-REVIEWED
 .;'A'-APPROVED
 .;'B'-BILLED
 .;'T'-TRANSFERRED TO FINANCE
 .;'C'-COMPLETED
 .;'P'-PARTIAL PAYMENT
 .;'X'-CANCELLED
 .I BILLSTAT="X" D  Q  ;3P BILL STATUS = CANCELLED
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","CANCELLED 3P BILLS","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","CANCELLED 3P BILLS","MONTHYR",MONTHYR))+1
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","CANCELLED 3P BILLS","MONTHYR",MONTHYR,BILLSTAT)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","CANCELLED 3P BILLS","MONTHYR",MONTHYR,BILLSTAT))+1
 .;IF PROVIDER NOT CHOSEN SORT BY PROVIDER
 .I '$D(BARY("PRV")) D
 ..S SUB4=PROV
 .E  S SUB4="UNCHOSEN"
 .;
 .;S BILL3P=$P($G(^ABMDBILL(DUZ(2),BILLIEN,0)),U)_" "  ;bar*1.8*28 HEAT224215
 .S BILL3P=$P($G(^ABMDBILL(ABMDUZ(2),BILLIEN,0)),U)_" "  ;bar*1.8*28 HEAT224215
 .S BILLAR=$O(^BARBL(DUZ(2),"B",BILL3P))
 .S:BILLAR'="" BLLARIEN=$O(^BARBL(DUZ(2),"B",BILLAR,""))
 .I '$G(BLLARIEN) S NOARIEN("MONTHYR")=$G(NOARIEN("MONTHYR"))+1 S NOARIEN=NOARIEN+1
 .Q:'$G(BLLARIEN)  ;CAN'T FIND CORRESPONDING A/R BILL
 .S ARACCT=$$GET1^DIQ(90050.01,BLLARIEN_",",3)
 .;
 .S BAR=BLLARIEN
 .D BILL^BARRCHK
 .I 'BARP("HIT") D  Q
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","BILLREJT",SUB1,SUB2,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","BILLREJT",SUB1,SUB2,"MONTHYR",MONTHYR))+1
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","BILLREJT","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","BILLREJT","MONTHYR",MONTHYR))+1
 ..S BILLREJT=BILLREJT+1
 .;
 .;S ACTINS=$$GET1^DIQ(9002274.4,BILLIEN_",",.17,"I")  ;bar*1.8*23 IHS/SD/POT
 .;S INSTYP=$$GET1^DIQ(9999999.18,ACTINS_",",.21,"I")  ;bar*1.8*23 IHS/SD/POT
 .;start new bar*1.8*23 IHS/SD/POT
 .;S ACTINS=$$GET1^DIQ(9002274.4,BILLIEN_",",.08,"I")  ;bar*1.8*28 HEAT224215
 .S ACTINS=$P($G(^ABMDBILL(ABMDUZ(2),BILLIEN,0)),U,8)  ;bar*1.8*28 HEAT224215
 .;start old bar*1.8*28 HEAT224215
 .;I ACTINS="" D  Q
 .;.W !,"3PB BILLIEN ",BILLIEN,"  MISSING POINTER TO INSURER FILE 9999999.18 (^AUTNINS) - VARIABLE ACTINS : ",ACTINS
 .;.Q
 .;end old bar*1.8*28 HEAT224215
 .S INSTYP=$$GET1^DIQ(9999999.18,ACTINS_",",.211,"I")
 .S INSTYP=$P($G(^AUTTINTY(INSTYP,0)),U,2)
 .;start old bar*1.8*28 HEAT224215
 .;I INSTYP="" D  Q
 .;.W !,"INSTYP IS MISSING FOR BILLIEN ",BILLIEN,"  ACTINS: ",ACTINS
 .;.Q  ;
 .;end new bar*1.8*23 IHS/SD/POT
 .;end old bar*1.8*28 HEAT224215
 .S ACTINS=INSTYP_U_ACTINS
 .;
 .;IF NOT BILLING ENTITY CHOSEN DO SORT ON WHAT?
 .I '$D(BARY("BI")) D
 ..S SUB3=ACTINS
 .E  S SUB3="UNCHOSEN"
 .;S TPBEXP=$P($$GET1^DIQ(9002274.4,BILLIEN_",",.17,"E"),"@")  ;DATE EXPORTED  ;bar*1.8*28 HEAT224215
 .S TPBEXP=DT  ;bar*1.8*28 IHS/SD/SDR HEAT224215
 .S:$P($G(^ABMDBILL(ABMDUZ(2),BILLIEN,1)),U,7) TPBEXP=$P($G(^ABMDTXST(ABMDUZ(2),$P($G(^ABMDBILL(ABMDUZ(2),BILLIEN,1)),U,7),0)),U)  ;bar*1.8*28 HEAT224215
 .S TPBEXP=$P($$CDT^BARDUTL(TPBEXP),"@")  ;DATE EXPORTED  ;bar*1.8*28 HEAT224215
 .I TPBEXP'="" D
 ..S X=TPBEXP D ^%DT S TPBEXP=Y
 .E  S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","BLLNOEXP","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","BLLNOEXP","MONTHYR",MONTHYR))+1
 .;start old bar*1.8*28 HEAT224215
 .;S TPBAPPRO=$P($$GET1^DIQ(9002274.4,BILLIEN_",",.15,"I"),".")
 .;S BAMOUNT=$$GET1^DIQ(9002274.4,BILLIEN_",",.21)
 .;end old start new bar*1.8*28 HEAT224215
 .S TPBAPPRO=$P($G(^ABMDBILL(ABMDUZ(2),BILLIEN,1)),U,5)  ;date/time approved
 .S BAMOUNT=$P($G(^ABMDBILL(ABMDUZ(2),BILLIEN,2)),U,1)  ;billed amt
 .;end new bar*1.8*28 HEAT224215
 .;
 .S AMTBILLD=AMTBILLD+BAMOUNT
 .S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","AMTBILLD",SUB1,SUB2,SUB3,SUB4,VISITIEN,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","AMTBILLD",SUB1,SUB2,SUB3,SUB4,VISITIEN,"MONTHYR",MONTHYR))+BAMOUNT
 .S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","AMTBILLD","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","AMTBILLD","MONTHYR",MONTHYR))+BAMOUNT
 .;
 .I BILLSTAT'="X" D
 ..S BILLNUM=BILLNUM+1
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","BILLNUM",SUB1,SUB2,SUB3,SUB4,VISITIEN,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","BILLNUM",SUB1,SUB2,SUB3,SUB4,VISITIEN,"MONTHYR",MONTHYR))+1
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","BILLNUM","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","BILLNUM","MONTHYR",MONTHYR))+1
 .;
 .S DAYSAPP=DAYSAPP+$$DAYS(TPBAPPRO,VSITADMT)
 .S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DAYSAPP","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DAYSAPP","MONTHYR",MONTHYR))+$$DAYS(TPBAPPRO,VSITADMT)
 .S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DAYSAPP",SUB1,SUB2,SUB3,SUB4,VISITIEN,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DAYSAPP",SUB1,SUB2,SUB3,SUB4,VISITIEN,"MONTHYR",MONTHYR))+$$DAYS(TPBAPPRO,VSITADMT)
 .;
 .S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DAYSEXP",SUB1,SUB2,SUB3,SUB4,VISITIEN,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DAYSEXP",SUB1,SUB2,SUB3,SUB4,VISITIEN,"MONTHYR",MONTHYR))+$$DAYS(TPBEXP,VSITADMT)
 .S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DAYSEXP","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DAYSEXP","MONTHYR",MONTHYR))+$$DAYS(TPBEXP,VSITADMT)
 .;
 .;S BILL3P=$P($G(^ABMDBILL(DUZ(2),BILLIEN,0)),U)  ;bar*1.8*28 HEAT224215
 .S BILL3P=$P($G(^ABMDBILL(ABMDUZ(2),BILLIEN,0)),U)  ;bar*1.8*28 HEAT224215
 .;S BILL3P=$$GET1^DIQ(9002274.4,BILLIEN_",",.01,"I")  ;bar*1.8*28 HEAT224215
 .;
 .S TEMPAYS=$$FIRLSTPY^BARDYSV8(BILL3P)  ;returns FIRST_U_LAST_U_BATCHFIN
 .;
 .;at this point there should be:
 .; BATCHFIN from collection batch from first pymt on first bill, when batch was finalized
 .; FIRST from first pymt on first bill
 .; LAST from last pymt on last bill
 .;
 .;start old bar*1.8*28 HEAT224215
 .;S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","EARLYPAY",SUB1,SUB2,SUB3,SUB4,VISITIEN,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","EARLYPAY",SUB1,SUB2,SUB3,SUB4,VISITIEN,"MONTHYR",MONTHYR))+$$DAYS($P(TEMPAYS,U),VSITADMT)
 .;S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","EARLYPAY","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","EARLYPAY","MONTHYR",MONTHYR))+$$DAYS($P(TEMPAYS,U),VSITADMT)
 .;S TEMPAYS1=$S(+$P(TEMPAYS,U):$P(TEMPAYS,U),1:"UNDEF")
 .;S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","EARLYPAY DATES","MONTHYR",MONTHYR,TEMPAYS1,$S(+$P(TEMPAYS,U,2):$P(TEMPAYS,U,2),1:"UNDEF"),$S(+$P(TEMPAYS,U,3):$P(TEMPAYS,U,3),1:"UNDEF"))=$$DAYS($P(TEMPAYS,U),VSITADMT)
 .;S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","LASTPAY",SUB1,SUB2,SUB3,SUB4,VISITIEN,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","LASTPAY",SUB1,SUB2,SUB3,SUB4,VISITIEN,"MONTHYR",MONTHYR))+$$DAYS($P(TEMPAYS,U,2),VSITADMT)
 .;S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","LASTPAY","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","LASTPAY","MONTHYR",MONTHYR))+$$DAYS($P(TEMPAYS,U,2),VSITADMT)
 .;end old start new bar*1.8*28 HEAT224215
 .;
 .S BARTREC=$S(BILLNUM>1:"~",1:U)_BILL3P_";"_TPBAPPRO_";"_$$DAYS(TPBAPPRO,VSITADMT)_";"_TPBEXP_";"_$$DAYS(TPBEXP,VSITADMT)_";"_$P(TEMPAYS,U,3)_";"_$$DAYS($P(TEMPAYS,U,3),VSITADMT)_";"_$P(TEMPAYS,U)_";"  ;detail rec
 .S BARTREC=BARTREC_$$DAYS($P(TEMPAYS,U),VSITADMT)_";"_$P(TEMPAYS,U,2)_";"_$$DAYS($P(TEMPAYS,U,2),VSITADMT)_";"_PROV_";"_BAMOUNT  ;detail rec
 .S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DET",VISITIEN)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DET",VISITIEN))_BARTREC  ;detail rec
 .;
 .I +$G(TEMPAYS)'=0  D
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","TOT FIRST PAYMENT MADE","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","TOT FIRST PAYMENT MADE","MONTHYR",MONTHYR))+1
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DYSTOPAY",SUB1,SUB2,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DYSTOPAY",SUB1,SUB2,"MONTHYR",MONTHYR))+$$DAYS(BATCHFIN,VSITADMT)  ;avg to pymt
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DYSTOPAY","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DYSTOPAY","MONTHYR",MONTHYR))+$$DAYS(BATCHFIN,VSITADMT)  ;avg to pymt
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DYSTOPAY DATES","MONTHYR",MONTHYR,$S(+BATCHFIN:BATCHFIN,1:"UNDEF"),$S(+VSITADMT:VSITADMT,1:"UNDEF"),$$DAYS(BATCHFIN,VSITADMT))=""
 ..S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","TOT LAST PAYMENT MADE","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","TOT LAST PAYMENT MADE","MONTHYR",MONTHYR))+1
 ..;
 .S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","EARLYPAY",SUB1,SUB2,SUB3,SUB4,VISITIEN,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","EARLYPAY",SUB1,SUB2,SUB3,SUB4,VISITIEN,"MONTHYR",MONTHYR))+$$DAYS($P(TEMPAYS,U),VSITADMT)
 .S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","EARLYPAY","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","EARLYPAY","MONTHYR",MONTHYR))+$$DAYS($P(TEMPAYS,U),VSITADMT)
 .S TEMPAYS1=$S(+$P(TEMPAYS,U):$P(TEMPAYS,U),1:"UNDEF")
 .S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","EARLYPAY DATES","MONTHYR",MONTHYR,TEMPAYS1,$S(+$P(TEMPAYS,U,2):$P(TEMPAYS,U,2),1:"UNDEF"),$S(+$P(TEMPAYS,U,3):$P(TEMPAYS,U,3),1:"UNDEF"))=$$DAYS($P(TEMPAYS,U),VSITADMT)
 .;
 .S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","LASTPAY",SUB1,SUB2,SUB3,SUB4,VISITIEN,"MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","LASTPAY",SUB1,SUB2,SUB3,SUB4,VISITIEN,"MONTHYR",MONTHYR))+$$DAYS($P(TEMPAYS,U,2),VSITADMT)
 .S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","LASTPAY","MONTHYR",MONTHYR)=$G(^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","LASTPAY","MONTHYR",MONTHYR))+$$DAYS($P(TEMPAYS,U,2),VSITADMT)
 .;end new bar*1.8*28 HEAT224215
 Q
 ;RETURN DIFF BETWEEN TWO DATES - see glossary item 2 page 19
DAYS(X1,X2) ;EP
 N DATE1,DATE2
 S:X1="" X1=DT
 S:X2="" X2=DT
 S DATE1=X1
 S DATE2=X2
 N AVG
 D ^%DTC
 S DIFF=$G(X)
 S ^XTMP("BARDYSVS",$J,"DAYS TO COL VISIT","DIFF BETWEEN TWO DATES",DATE1,DATE2,$S(DIFF'="":DIFF,1:"UNDEF"))=""
 Q:'DIFF 0
 Q DIFF