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

FBAAIAR2.m

Go to the documentation of this file.
  1. FBAAIAR2 ;ALB/FA - Fee IPAC Vendor DoD Invoice Inquiry Report Print ;1/16/2014
  1. ;;3.5;FEE BASIS;**123**;JAN 30, 1995;Build 51
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ; Scratch global built by FBAAIAR.
  1. ; Type - 'O'utpatient,'I'npatient,Inpatient 'A'ncillary, 'P'harmacy
  1. ; XX - Unique identifier to allow for multiple Outpatient/Ancillary payments on the
  1. ; same invoice. 0 for Inpatient or Pharmacy
  1. ; ^TMP("FBAAIAR1",$J, Vendor Name,Type,VistA Invoice#) = A1^A2^A3^...^A5 Where:
  1. ; A1 - Type of Record (Cancelled, Void, Reject, Purge, "", or some combination)
  1. ; A2 - Date Paid (Fileman format)
  1. ; A3 - Total amount claimed
  1. ; A4 - Total amount paid
  1. ; A5 - Total adjustment amount
  1. ; ^TMP("FBAAIAR1",$J,Vendor Name) = A1^A2^...^A4 Where:
  1. ; A1 - Total amount claimed for DoD Invoice Vendor
  1. ; A2 - Total amount paid for DoD Invoice Vendor
  1. ; A3 - Total adjustment amount DoD Invoice Vendor
  1. ; A4 - Total number of invoices for the DoD Invoice Vendor
  1. ; ^TMP("FBAAIAR1",$J,Vendor Name, Type) = A1^A2^...^A4 Where:
  1. ; A1 - Total amount claimed for DoD Invoice Vendor by type
  1. ; A2 - Total amount paid for DoD Invoice Vendor by type
  1. ; A3 - Total adjustment amount DoD Invoice Vendor by type
  1. ; A4 - Total number of invoices for the DoD Invoice Vendor by type
  1. ;
  1. ;-----------------------------------------------------------------------------
  1. ; Entry Points
  1. ; PRINT - DoD Invoice Inquiry Report - PRINT report
  1. ;-----------------------------------------------------------------------------
  1. ;
  1. Q
  1. ;
  1. PRINT(FBDODINV,FBFORMAT) ;EP
  1. ; Entry point for printing the report
  1. ; Input: FBDODINV - Selected DoD Invoice number
  1. ; FBFORMAT - 1 - CSV format, 0 otherwise
  1. ; ZTQUEUE - Defined if report was queued
  1. ; undefined otherwise
  1. ; ZSTOP - Defined and 1 if compilation was stopped
  1. ; 0 or undefined otherwise
  1. ; ^TMP("FBAAIAR1",$J) - Described in full above
  1. ; Output: Report is printed
  1. ; Called From: COMPILE@FBAAIAR1
  1. ;
  1. N CRT,DIR,DIROUT,DIRUT,DTOUT,DUOUT,INVDOD,FBIASTOP,IDATA,ITYPE,INVNUM
  1. N LVNAME,PAGE,SEPLINE,VNAME,X,XX,Y
  1. S LVNAME="",VNAME=""
  1. S CRT=$S(IOST["C-":1,1:0) ; 1 - Print to Screen, 0 - Otherwise
  1. S:FBFORMAT IOSL=999999 ; Long screen length for Excel output
  1. S PAGE=0,FBIASTOP=0,$P(SEPLINE,"-",81)=""
  1. I '$D(^TMP("FBAAIAR1",$J)) D Q ; No data was compiled
  1. . D HDR(FBDODINV,VNAME,CRT,.PAGE,.FBIASTOP)
  1. . W !!?5,"No data found for this report."
  1. . I CRT,'$D(ZTQUEUED) D
  1. . . S DIR(0)="E"
  1. . . D ^DIR
  1. ;
  1. I $G(ZTSTOP) D Q ; Compilation was halted
  1. . D HDR(FBDODINV,VNAME,CRT,.PAGE,.FBIASTOP)
  1. . W !!?5,"This report was halted during compilation by TaskManager Request."
  1. . I CRT,'$D(ZTQUEUED) D
  1. . . S DIR(0)="E"
  1. . . D ^DIR
  1. ;
  1. ; Gather headers for excel spreadsheet
  1. D:FBFORMAT HDR(FBDODINV,"",CRT,.PAGE,.FBIASTOP)
  1. Q:FBIASTOP
  1. ;
  1. S VNAME=""
  1. F D Q:(VNAME="")!(FBIASTOP)
  1. . S VNAME=$O(^TMP("FBAAIAR1",$J,VNAME))
  1. . Q:VNAME=""
  1. . S LVNAME=VNAME
  1. . ;
  1. . ; Display header if not in CSV format
  1. . D:'FBFORMAT HDR(FBDODINV,VNAME,CRT,.PAGE,.FBIASTOP)
  1. . S ITYPE=""
  1. . F D Q:(ITYPE="")!(FBIASTOP)
  1. . . S ITYPE=$O(^TMP("FBAAIAR1",$J,VNAME,ITYPE))
  1. . . Q:(ITYPE="")!FBIASTOP
  1. . . S INVNUM=""
  1. . . F D Q:(INVNUM="")!(FBIASTOP)
  1. . . . S INVNUM=$O(^TMP("FBAAIAR1",$J,VNAME,ITYPE,INVNUM))
  1. . . . Q:(INVNUM="")!FBIASTOP
  1. . . . S XX=""
  1. . . . F D Q:(XX="")!(FBIASTOP)
  1. . . . . S XX=$O(^TMP("FBAAIAR1",$J,VNAME,ITYPE,INVNUM,XX))
  1. . . . . Q:XX=""
  1. . . . . S IDATA=$G(^TMP("FBAAIAR1",$J,VNAME,ITYPE,INVNUM,XX))
  1. . . . . ;
  1. . . . . ; Excel output - Print a CSV format record
  1. . . . . I FBFORMAT D EXCELN(ITYPE,INVNUM,IDATA) Q
  1. . . . . ;
  1. . . . . I $Y+4>IOSL,'FBFORMAT D Q:FBIASTOP ; Page break check
  1. . . . . . D HDR(FBDODINV,VNAME,CRT,.PAGE,.FBIASTOP)
  1. . . . . W !,$$LJ^XLFSTR(INVNUM,22) ; VistA Invoice#
  1. . . . . W ?25,$$RJ^XLFSTR(ITYPE,4) ; Record Type
  1. . . . . W ?32,$P(IDATA,U,1) ; C/V/R
  1. . . . . W ?40,$$LJ^XLFSTR($$FMTE^XLFDT($P(IDATA,U,2),"2DZ"),10) ; Paid Date
  1. . . . . W ?50,$$RJ^XLFSTR("$"_$FN($P(IDATA,U,3),"",0),8) ; Amount Claimed
  1. . . . . W ?60,$$RJ^XLFSTR("$"_$FN($P(IDATA,U,4),"",0),8) ; Amount Paid
  1. . . . . W ?70,$$RJ^XLFSTR("$"_$FN($P(IDATA,U,5),"",0),8) ; Adjustment Amount
  1. . . ;
  1. . . Q:FBIASTOP
  1. . . D:'FBFORMAT TYPETOT(FBDODINV,VNAME,FBFORMAT,ITYPE,.PAGE,.FBIASTOP) ; Totals by record type
  1. . ;
  1. . Q:FBIASTOP
  1. . D:'FBFORMAT VTOT(FBDODINV,VNAME,FBFORMAT,.PAGE,.FBIASTOP) ; Totals by DoD Invoice
  1. Q:FBIASTOP
  1. ;
  1. I $Y+1>IOSL,'FBFORMAT D Q:FBIASTOP ; Page break check
  1. . D HDR(FBDODINV,LVNAME,CRT,.PAGE,.FBIASTOP)
  1. W !!?5,"*** End of Report ***"
  1. ;
  1. I CRT,'$D(ZTQUEUED) D
  1. . S DIR(0)="E"
  1. . D ^DIR
  1. Q
  1. ;
  1. VTOT(FBDODINV,VNAME,FBFORMAT,PAGE,FBIASTOP) ; Print the totals by Dod Invoice Vendor
  1. ; Input: FBDODINV - DoD Invoice report was compiled for
  1. ; VNAME - Name of the
  1. ; FBFORMAT - 0 - CSV format (for Excel), 0 otherwise
  1. ; PAGE - Current page number
  1. ; FBIASTOP - Stop flag
  1. ; ^TMP("FBAAIAR1",$J) - Compiled report data
  1. ; Output: FBIASTOP - 1 - user stopped printing, 0 otherwise
  1. ; DoD Invoice Type Totals are printed
  1. ; Called From: PRINT
  1. N IDATA
  1. I $Y+5>IOSL,'FBFORMAT D Q:FBIASTOP ; Page break check
  1. . D HDR(FBDODINV,VNAME,CRT,.PAGE,.FBIASTOP)
  1. S IDATA=^TMP("FBAAIAR1",$J,VNAME) ; DoD Invoice Type Totals
  1. W !?1,"$Totals for Vendor: ",VNAME
  1. W !,"---------",?50,"-------- -------- --------"
  1. W !,"# ",$$RJ^XLFSTR($P(IDATA,U,4),7) ; Total Number of Invoices
  1. W ?50,$$RJ^XLFSTR("$"_$FN($P(IDATA,U,1),"",0),8) ; Total Amount Claimed
  1. W ?60,$$RJ^XLFSTR("$"_$FN($P(IDATA,U,2),"",0),8) ; Total Amount Paid
  1. W ?70,$$RJ^XLFSTR("$"_$FN($P(IDATA,U,3),"",0),8) ; Total Adjustment Amount
  1. Q
  1. ;
  1. TYPETOT(FBDODINV,VNAME,FBFORMAT,ITYPE,PAGE,FBIASTOP) ; Print the totals by Invoice type
  1. ; Input: FBDODINV - DoD Invoice report was compiled for
  1. ; VNAME - Name of the
  1. ; FBFORMAT - 0 - CSV format (for Excel), 0 otherwise
  1. ; ITYPE - Invoice Type to print totals for
  1. ; PAGE - Current page number
  1. ; IASTOP - Stop flag
  1. ; ^TMP($J,"FBAAIAR1") - Compiled report data
  1. ; Output: IASTOP - 1 - user stopped printing, 0 otherwise
  1. ; Invoice Type Totals are printed
  1. ; Called From: PRINT
  1. N ETYPE,IDATA
  1. I $Y+5>IOSL,'FBFORMAT D Q:FBIASTOP ; Page break check
  1. . D HDR(FBDODINV,CRT,.PAGE,.FBIASTOP)
  1. S ETYPE=$S(ITYPE="ANC":"Inpatient Ancillary",ITYPE="INP":"Inpatient",ITYPE="OUT":"Outpatient",1:"Pharmacy")
  1. S IDATA=^TMP("FBAAIAR1",$J,VNAME,ITYPE) ; Invoice Type Totals
  1. W !?1,"$Totals for DoD Invoice # by Type: ",ETYPE
  1. W !?25,"---- ",?50,"-------- -------- --------"
  1. W !?20,"Tot# ",$$RJ^XLFSTR($P(IDATA,U,4),4) ; Total Number of Invoices by Type
  1. W ?50,$$RJ^XLFSTR("$"_$FN($P(IDATA,U,1),"",0),8) ; Total Amount Claimed
  1. W ?60,$$RJ^XLFSTR("$"_$FN($P(IDATA,U,2),"",0),8) ; Total Amount Paid
  1. W ?70,$$RJ^XLFSTR("$"_$FN($P(IDATA,U,3),"",0),8) ; Total Adjustment Amount
  1. W !
  1. Q
  1. ;
  1. EXCELN(ITYPE,INVNUM,DATA) ; Output one Excel line
  1. ; Input: ITYPE - Invoice record type
  1. ; INVNUM - VistA Invoice number
  1. ; DATA - Invoice data
  1. ; Output: One line of invoice data is output in excel format
  1. ; Called From: PRINT
  1. N FBZ
  1. S FBZ=$$CSV("",INVNUM) ; VistA Invoice Number
  1. S FBZ=$$CSV(FBZ,ITYPE) ; Invoice Record Type
  1. S FBZ=$$CSV(FBZ,$P(DATA,U,1)) ; C/V/R
  1. S FBZ=$$CSV(FBZ,$$FMTE^XLFDT($P(DATA,U,2),"2DZ")) ; Date Paid
  1. S FBZ=$$CSV(FBZ,$FN($P(DATA,U,3),"",0)) ; Amount Claimed
  1. S FBZ=$$CSV(FBZ,$FN($P(DATA,U,4),"",0)) ; Amount Paid
  1. S FBZ=$$CSV(FBZ,$FN($P(DATA,U,5),"",0)) ; Adjustment Amount
  1. W !,FBZ
  1. Q
  1. ;
  1. HDR(FBDODINV,VNAME,CRT,PAGE,IASTOP) ; Print the Report Header
  1. ; Input: FBDODINV - DoD Invoice Number
  1. ; VNAME - Name of the Vendor associated with the DoD Invoice
  1. ; CRT - 1 - Print to screen, 0 otherwise
  1. ; PAGE - Current page count
  1. ; IASTOP - Stop flag
  1. ; ZTQUEUED - Defined if report was queued
  1. ; undefined otherwise
  1. ; Output: PAGE - Updated page count
  1. ; IASTOP - 1 - user stopped printing, 0 otherwise
  1. ; ZSTOP - Defined and 1 if a task manager stop was received
  1. ; 0 or undefined otherwise
  1. ;
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,VENID,X,Y,Z
  1. ;
  1. ; Do an end of page reader call if page# exists and device is the screen
  1. I PAGE,CRT D Q:FBIASTOP
  1. . S DIR(0)="E"
  1. . D ^DIR K DIR
  1. . S:'Y FBIASTOP=1
  1. ;
  1. ; If screen output or page# exists, do a form feed and left margin reset
  1. I PAGE!CRT D
  1. . W @IOF,$C(13)
  1. ;
  1. S PAGE=PAGE+1 ; Increment Page #
  1. ;
  1. ; For Excel CSV format, display the column headers only
  1. I FBFORMAT D EXCELHD Q
  1. ;
  1. ; Display the report headers
  1. W ?20,"IPAC Vendor DoD Invoice Inquiry Report"
  1. W !,?1,"For DoD Invoice # ",FBDODINV
  1. W ?48,$$FMTE^XLFDT($$NOW^XLFDT),?71,"Page: ",PAGE
  1. W !,?1,"For Vendor: ",VNAME
  1. ;
  1. ; Display the column headers
  1. W !?42,"Date",?52,"Amount",?63,"Amount",?72,"Amount"
  1. W !,"Invoice #",?25,"Type",?31,"C/V/R",?42,"Paid",?52,"Claimed",?63,"Paid",?72,"Adjusted"
  1. W !,SEPLINE
  1. ;
  1. ; Check for a TaskManager stop request
  1. I $D(ZTQUEUED),$$S^%ZTLOAD() D Q
  1. . S (ZTSTOP,FBIASTOP)=1
  1. . W !!!?5,"*** Report Halted by TaskManager Request ***"
  1. Q
  1. ;
  1. EXCELHD ; Print an Excel CSV header record
  1. ; (only 1 Excel CSV header should print for the entire report)
  1. ; Input: None
  1. ; Output: Header line printed for CSV format (excel)
  1. ; Called From:
  1. N FBH
  1. S FBH=$$CSV("","VistA Invoice#")
  1. S FBH=$$CSV(FBH,"Type")
  1. S FBH=$$CSV(FBH,"C/V/R")
  1. S FBH=$$CSV(FBH,"Date Paid")
  1. S FBH=$$CSV(FBH,"Amount Claimed")
  1. S FBH=$$CSV(FBH,"Amount Paid")
  1. S FBH=$$CSV(FBH,"Adjustment Amount")
  1. W FBH
  1. Q
  1. ;
  1. CSV(STRING,DATA) ; Build the Excel data string for CSV format
  1. ; Input: STRING - Current string being built or ""
  1. ; DATA - New data to be added to the string
  1. ; Returns: STRING - Updated string with DATA added
  1. ; Called From: EXCELHD,EXCELN
  1. S DATA=$C(34)_$TR(DATA,$C(34),$C(39))_$C(34)
  1. S STRING=$S(STRING="":DATA,1:STRING_","_DATA)
  1. Q STRING
  1. ;