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

FBAAPAR.m

Go to the documentation of this file.
  1. FBAAPAR ;WOIFO/SAB - PAYMENT AGING REPORT ;11/7/2012
  1. ;;3.5;FEE BASIS;**132**;JAN 30, 1995;Build 17
  1. ;;Per VHA Directive 2004-038, this routine should not be modified.
  1. ; ICRs
  1. ; #10090 ^DIC(4,
  1. ; #2056 $$GET1^DIQ
  1. ; #10026 DIR
  1. ; #10003 DD^%DT
  1. ; #10000 NOW^%DTC
  1. ; #4398 FIRST^VAUTOMA
  1. ; #10103 $$FMADD^XLFDT, $$FMDIFF^XLFDT, $$FMTE^XLFDT
  1. ; #2171 $$STA^XUAF4
  1. ; #10086 %ZIS, HOME^%ZIS
  1. ; #10089 %ZISC
  1. ; #10063 %ZTLOAD, $$S^%ZTLOAD
  1. ;
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,FBDT1,FBDT2,FBPSV,FBX,%ZIS,POP,X,Y
  1. ;
  1. ; user prompts
  1. ;
  1. ; ask one/many/all primary service failities
  1. W !!
  1. S DIC="^DIC(4,"
  1. S VAUTSTR="Primary Service Facility",VAUTNI=2,VAUTVB="FBPSV"
  1. D FIRST^VAUTOMA K DIC I Y=-1 G EXIT
  1. ;
  1. ; ask end date
  1. S DIR(0)="D^:"_DT_":EX"
  1. S DIR("A")="Report payments finalized on or before"
  1. ; default end date is last day of month at least 30 days ago
  1. S FBX=$$FMADD^XLFDT($E(DT,1,5)_"01",-1) ; last date of prior month
  1. I $$FMDIFF^XLFDT(DT,FBX)<30 S FBX=$$FMADD^XLFDT($E(FBX,1,5)_"01",-1)
  1. S DIR("B")=$$FMTE^XLFDT(FBX)
  1. D ^DIR K DIR G:$D(DIRUT) EXIT
  1. S FBDT2=Y
  1. ;
  1. ; ask start date
  1. S DIR(0)="D^:"_FBDT2_":EX"
  1. S DIR("A")="Earliest finalized date to report"
  1. ; default start date is first day of selected month
  1. S DIR("B")=$$FMTE^XLFDT($E(FBDT2,1,5)_"01")
  1. D ^DIR K DIR G:$D(DIRUT) EXIT
  1. S FBDT1=Y
  1. ;
  1. ; ask device
  1. S %ZIS="Q" D ^%ZIS G:POP EXIT
  1. I $D(IO("Q")) D G EXIT
  1. . N ZTRTN,ZTDESC,ZTDTH,ZTIO,ZTUCI,ZTCPU,ZTPRI,ZTSAVE,ZTKIL,ZTSYNC,ZTSK
  1. . S ZTRTN="QEN^FBAAPAR",ZTDESC="Fee Basis Payment Aging Report"
  1. . F FBX="FBDT*","FBPSV","FBPSV(" S ZTSAVE(FBX)=""
  1. . D ^%ZTLOAD,HOME^%ZIS
  1. ;
  1. QEN ; queued entry
  1. U IO
  1. ;
  1. GATHER ; collect and sort data
  1. K ^TMP($J)
  1. ; init counters
  1. K FBC F X="B2","B3","B5","B9" F Y="F","P" S FBC(X,Y)=0
  1. ;
  1. ;
  1. ; batch type B2
  1. ; loop thru batch file by date finalized for specified period
  1. ; because DATE FINALIZED field is not being populated
  1. S FBDT=FBDT1-.0001
  1. F S FBDT=$O(^FBAA(161.7,"AF",FBDT)) Q:FBDT>FBDT2!(FBDT="") D
  1. . ; loop thru batch
  1. . S FBN=0 F S FBN=$O(^FBAA(161.7,"AF",FBDT,FBN)) Q:'FBN D
  1. . . ; loop thru payments for batch
  1. . . S FBJ=0 F S FBJ=$O(^FBAAC("AD",FBN,FBJ)) Q:'FBJ D
  1. . . . S FBK=0 F S FBK=$O(^FBAAC("AD",FBN,FBJ,FBK)) Q:'FBK D
  1. . . . . S FBY0=$G(^FBAAC(FBJ,3,FBK,0))
  1. . . . . ;
  1. . . . . ; dont't check primary service facility since it is not
  1. . . . . ; stored with payment, associated auth. is not known, and
  1. . . . . ; station in batch file is not necessarily the same
  1. . . . . ;
  1. . . . . S FBC("B2","F")=FBC("B2","F")+1 ; incr finalized count
  1. . . . . ;
  1. . . . . ; check if payment meets criterion for pending
  1. . . . . Q:$P(FBY0,U,7)'="" ; check number
  1. . . . . Q:$P(FBY0,U,6)'="" ; date paid
  1. . . . . Q:$P(FBY0,U,8)'="" ; cancel date
  1. . . . . Q:$P($G(^FBAAC(FBJ,3,FBK,"FBREJ")),U)'="" ; reject status
  1. . . . . ; travel payment cannot be void
  1. . . . . ;
  1. . . . . ; save payment in list
  1. . . . . S ^TMP($J,"B2",FBDT,FBJ,FBK)=""
  1. . . . . S FBC("B2","P")=FBC("B2","P")+1 ; incr pending payment count
  1. ;
  1. ; batch type B3
  1. ; loop thru DATE FINALIZED x-ref
  1. S FBDT=FBDT1-.0001
  1. F S FBDT=$O(^FBAAC("AK",FBDT)) Q:FBDT>FBDT2!(FBDT="") D
  1. . S FBJ=0 F S FBJ=$O(^FBAAC("AK",FBDT,FBJ)) Q:'FBJ D
  1. . . S FBK=0 F S FBK=$O(^FBAAC("AK",FBDT,FBJ,FBK)) Q:'FBK D
  1. . . . S FBL=0 F S FBL=$O(^FBAAC("AK",FBDT,FBJ,FBK,FBL)) Q:'FBL D
  1. . . . . S FBM=0 F S FBM=$O(^FBAAC("AK",FBDT,FBJ,FBK,FBL,FBM)) Q:'FBM D
  1. . . . . . S FBY0=$G(^FBAAC(FBJ,1,FBK,1,FBL,1,FBM,0))
  1. . . . . . S FBY2=$G(^FBAAC(FBJ,1,FBK,1,FBL,1,FBM,2))
  1. . . . . . ;
  1. . . . . . ; skip if not selected primary service facility
  1. . . . . . I 'FBPSV,$P(FBY0,U,12),'$D(FBPSV($P(FBY0,U,12))) Q
  1. . . . . . ;
  1. . . . . . S FBC("B3","F")=FBC("B3","F")+1 ; incr finalized count
  1. . . . . . ;
  1. . . . . . ; check if payment meets criterion for pending
  1. . . . . . Q:$P(FBY2,U,3)'="" ; check number
  1. . . . . . Q:$P(FBY0,U,14)'="" ; date paid
  1. . . . . . Q:$P(FBY2,U,4)'="" ; cancellation date
  1. . . . . . Q:$P($G(^FBAAC(FBJ,1,FBK,1,FBL,1,FBM,"FBREJ")),U)'="" ; rej.
  1. . . . . . Q:$P(FBY0,U,21)'="" ; void
  1. . . . . . ;
  1. . . . . . ; save payment in list
  1. . . . . . S ^TMP($J,"B3",FBDT,FBJ,FBK,FBL,FBM)=""
  1. . . . . . S FBC("B3","P")=FBC("B3","P")+1 ; incr pending payment count
  1. ;
  1. ; batch type B5
  1. ; loop thru batch file by date finalized for specified period
  1. ; because DATE FINALIZED field does not exist
  1. S FBDT=FBDT1-.0001
  1. F S FBDT=$O(^FBAA(161.7,"AF",FBDT)) Q:FBDT>FBDT2!(FBDT="") D
  1. . ; loop thru batch
  1. . S FBN=0 F S FBN=$O(^FBAA(161.7,"AF",FBDT,FBN)) Q:'FBN D
  1. . . ; loop thru payments for batch
  1. . . S FBJ=0 F S FBJ=$O(^FBAA(162.1,"AE",FBN,FBJ)) Q:'FBJ D
  1. . . . S FBK=0 F S FBK=$O(^FBAA(162.1,"AE",FBN,FBJ,FBK)) Q:'FBK D
  1. . . . . S FBY2=$G(^FBAA(162.1,FBJ,"RX",FBK,2))
  1. . . . . ;
  1. . . . . ; skip if not selected primary service facility
  1. . . . . I 'FBPSV,$P(FBY2,U,5),'$D(FBPSV($P(FBY2,U,5))) Q
  1. . . . . ;
  1. . . . . S FBC("B5","F")=FBC("B5","F")+1 ; incr finalzied count
  1. . . . . ;
  1. . . . . ; check if payment meets criterion as pending
  1. . . . . Q:$P(FBY2,U,10)'="" ; check number
  1. . . . . Q:$P(FBY2,U,8)'="" ; date paid
  1. . . . . Q:$P(FBY2,U,11)'="" ; cancel date
  1. . . . . Q:$P(FBY2,U,3)'="" ; void
  1. . . . . Q:$P($G(^FBAA(162.1,FBJ,"RX",FBK,"FBREJ")),U)'="" ; reject
  1. . . . . ;
  1. . . . . ; save payment in list
  1. . . . . S ^TMP($J,"B5",FBDT,FBJ,FBK)=""
  1. . . . . S FBC("B5","P")=FBC("B5","P")+1 ; incr pending payment count
  1. ;
  1. ; batch type B9
  1. ; loop thru DATE FINALIZED x-ref
  1. S FBDT=FBDT1-.0001
  1. F S FBDT=$O(^FBAAI("AD",FBDT)) Q:FBDT>FBDT2!(FBDT="") D
  1. . S FBJ=0 F S FBJ=$O(^FBAAI("AD",FBDT,FBJ)) Q:'FBJ D
  1. . . S FBY0=$G(^FBAAI(FBJ,0))
  1. . . S FBY2=$G(^FBAAI(FBJ,2))
  1. . . ;
  1. . . ; skip if not selected primary service facility
  1. . . I 'FBPSV,$P(FBY0,U,20),'$D(FBPSV($P(FBY0,U,20))) Q
  1. . . ;
  1. . . S FBC("B9","F")=FBC("B9","F")+1 ; incr finalized count
  1. . . ;
  1. . . ; check if payment meets criterion
  1. . . Q:$P(FBY2,U,4)'="" ; check number
  1. . . Q:$P(FBY2,U,1)'="" ; date paid
  1. . . Q:$P(FBY2,U,5)'="" ; cancellation date
  1. . . Q:$P($G(^FBAAI(FBJ,"FBREJ")),U)'="" ; reject status
  1. . . Q:$P(FBY0,U,14)'="" ; void
  1. . . ;
  1. . . ; save payment in list
  1. . . S ^TMP($J,"B9",FBDT,FBJ)=""
  1. . . S FBC("B9","P")=FBC("B9","P")+1 ; incr pending payment count
  1. ;
  1. PRINT ; report data
  1. S (FBQUIT,FBPG)=0 D NOW^%DTC S Y=% D DD^%DT S FBDTR=Y
  1. K FBDL
  1. S FBDL="",$P(FBDL,"-",80)=""
  1. ;
  1. ; build page header text for selection criteria
  1. K FBHDT
  1. S FBHDT(1)=" Payments finalized from "
  1. S FBHDT(1)=FBHDT(1)_$$FMTE^XLFDT(FBDT1)_" to "_$$FMTE^XLFDT(FBDT2)
  1. S FBHDT(2)=" for "_$S(FBPSV:"all ",1:"")_"primary service facilities"_$S(FBPSV:"",1:": ")
  1. I 'FBPSV D
  1. . ; load facility numbers into header lines
  1. . S FBK=2
  1. . S FBJ=0 F S FBJ=$O(FBPSV(FBJ)) Q:'FBJ D
  1. . . S FBX=$$STA^XUAF4(FBJ)_" "
  1. . . I $L(FBHDT(FBK))+$L(FBX)>78 S FBK=FBK+1,FBHDT(FBK)=" "
  1. . . S FBHDT(FBK)=FBHDT(FBK)_FBX
  1. S Q="",$P(Q,"=",80)="="
  1. S (FBAAOUT,FBINTOT)=0
  1. ;
  1. ; loop thru ^TMP global by batch type
  1. S FBTYPE="" F S FBTYPE=$O(^TMP($J,FBTYPE)) Q:FBTYPE="" D Q:FBQUIT
  1. . ; print header
  1. . D HD
  1. . ; add header for batch type
  1. . D:FBTYPE="B2" HEDP^FBAACCB0
  1. . D:FBTYPE="B3" HED^FBAACCB
  1. . D:FBTYPE="B5" HED^FBAACCB
  1. . D:FBTYPE="B9" HEDC^FBAACCB1
  1. . ;
  1. . ; loop thru date finalized
  1. . S FBDT="" F S FBDT=$O(^TMP($J,FBTYPE,FBDT)) Q:FBDT="" D Q:FBQUIT
  1. . . ; process payments
  1. . . D:FBTYPE="B2" PROCB2
  1. . . D:FBTYPE="B3" PROCB3
  1. . . D:FBTYPE="B5" PROCB5
  1. . . D:FBTYPE="B9" PROCB9
  1. ;
  1. I FBQUIT W !!,"REPORT STOPPED AT USER REQUEST"
  1. E D ; report footer
  1. . I $Y+5>IOSL D HD Q:FBQUIT
  1. . W !,FBDL
  1. . W !,"Type",?30,"Total Finalized",?50,"Pending Payment"
  1. . F FBTYPE="B2","B3","B5","B9" D
  1. . . W !," "
  1. . . W:FBTYPE="B2" "Travel"
  1. . . W:FBTYPE="B3" "Outpatient/Ancillary"
  1. . . W:FBTYPE="B5" "Pharmacy"
  1. . . W:FBTYPE="B9" "Inpatient"
  1. . . W ?30,$J(FBC(FBTYPE,"F"),10)
  1. . . W ?50,$J(FBC(FBTYPE,"P"),10)
  1. ;
  1. I 'FBQUIT,$E(IOST,1,2)="C-" S DIR(0)="E" D ^DIR K DIR
  1. D ^%ZISC
  1. ;
  1. EXIT ;
  1. I $D(ZTQUEUED) S ZTREQ="@"
  1. K ^TMP($J)
  1. K FBC,FBDA,FBDL,FBDT,FBDT1,FBDT2,FBDTR,FBEV,FBHDT,FBJ,FBK,FBL,FBM,FBN
  1. K FBPG,FBSTALL,FBSTN,FBQUIT,FBY0,FBY2
  1. D Q^FBAACCB0
  1. K DIC,DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
  1. Q
  1. ;
  1. HD ; page header
  1. N FBI
  1. I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1,FBQUIT=1 Q
  1. I $E(IOST,1,2)="C-",FBPG S DIR(0)="E" D ^DIR K DIR I 'Y S FBQUIT=1 Q
  1. I $E(IOST,1,2)="C-"!FBPG W @IOF
  1. S FBPG=FBPG+1
  1. W !,"Fee Basis Payment Aging Report",?49,FBDTR,?72,"page ",FBPG
  1. S FBI=0 F S FBI=$O(FBHDT(FBI)) Q:'FBI W !,FBHDT(FBI)
  1. W !
  1. Q
  1. ;
  1. PROCB2 ;
  1. N J,K,Y
  1. ; loop thru payments
  1. S FBJ=0 F S FBJ=$O(^TMP($J,FBTYPE,FBDT,FBJ)) Q:'FBJ D Q:FBQUIT
  1. . S FBK=0 F S FBK=$O(^TMP($J,FBTYPE,FBDT,FBJ,FBK)) Q:'FBK D Q:FBQUIT
  1. . . I $Y+7>IOSL D HD Q:FBQUIT D HEDP^FBAACCB0
  1. . . S J=FBJ,K=FBK,Y(0)=^FBAAC(J,3,K,0)
  1. . . D SETT^FBAACCB0 I FBAAOUT S FBQUIT=1
  1. Q
  1. ;
  1. PROCB3 ;
  1. N B,J,K,L,M
  1. ; loop thru payments
  1. S FBJ=0 F S FBJ=$O(^TMP($J,FBTYPE,FBDT,FBJ)) Q:'FBJ D Q:FBQUIT
  1. . S FBK=0 F S FBK=$O(^TMP($J,FBTYPE,FBDT,FBJ,FBK)) Q:'FBK D Q:FBQUIT
  1. . . S FBL=0
  1. . . F S FBL=$O(^TMP($J,FBTYPE,FBDT,FBJ,FBK,FBL)) Q:'FBL D Q:FBQUIT
  1. . . . S FBM=0
  1. . . . F S FBM=$O(^TMP($J,FBTYPE,FBDT,FBJ,FBK,FBL,FBM)) Q:'FBM D Q:FBQUIT
  1. . . . . I $Y+8>IOSL D HD Q:FBQUIT D HED^FBAACCB
  1. . . . . S J=FBJ,K=FBK,L=FBL,M=FBM
  1. . . . . S Y(0)=^FBAAC(J,1,K,1,L,1,M,0),B=$P(Y(0),U,8)
  1. . . . . D SET^FBAACCB I FBAAOUT S FBQUIT=1
  1. Q
  1. ;
  1. PROCB5 ;
  1. N A,B,B2,Z
  1. ; loop thru payments
  1. S FBJ=0 F S FBJ=$O(^TMP($J,FBTYPE,FBDT,FBJ)) Q:'FBJ D Q:FBQUIT
  1. . S FBK=0 F S FBK=$O(^TMP($J,FBTYPE,FBDT,FBJ,FBK)) Q:'FBK D Q:FBQUIT
  1. . . I $Y+7>IOSL D HD Q:FBQUIT D HED^FBAACCB
  1. . . S A=FBJ,B2=FBK,Z(0)=^FBAA(162.1,A,"RX",B2,0),B=$P(Z(0),U,17)
  1. . . D SETV^FBAACCB0,MORE^FBAACCB1 I FBAAOUT S FBQUIT=1
  1. Q
  1. ;
  1. PROCB9 ;
  1. N A,B,B2,Z
  1. ; loop thru payments
  1. S FBJ=0 F S FBJ=$O(^TMP($J,FBTYPE,FBDT,FBJ)) Q:'FBJ D Q:FBQUIT
  1. . I $Y+7>IOSL D HD Q:FBQUIT D HEDC^FBAACCB1
  1. . S I=FBJ,Z(0)=^FBAAI(I,0),B=$P(Z(0),U,17)
  1. . D CMORE^FBAACCB1 I FBAAOUT S FBQUIT=1
  1. Q
  1. ;
  1. ;FBAAPAR