RCDMCR5A ;HAF/ASF - First Party Charge IB Cancellation Reconciliation Report - Input/output; Apr 9, 2019@21:06
 ;;4.5;Accounts Receivable;**347,361**;Mar 20, 1995;Build 6
 ;;Per VA Directive 6402, this routine should not be modified.
 ;
 ;This routine is being implemented for the AR Cross-Referencing Project
 ;
 ;This report will assist users in reviewing first party charges receiving
 ;Integrated Billing (IB) cancellation for potential refund activities or charge
 ;cancellation accuracy, and to identify and monitor cancellation activity
 ;productivity so veteran customers can receive refunds due to them for
 ;retroactive eligibility exemptions.  The report provides data for first party
 ;charges receiving IB cancellation for a user defined bill cancellation 
 ;date range.
MAIN ; Initial Interactive Processing
 N STOPIT,EXCEL,CANDATE,CANBEGDT,CANENDDT,BILLPAYS,RCSCR
 W !!,"*** Print the First Party Charge IB Cancellation Reconciliation Report ***",!
 S STOPIT=0 ; quit flag
 ;Prompt user for Date Range for Bill Cancellation date range
 S CANDATE=$$DATE2^RCDMCUT2("    Enter the Bill Cancellation Date Range: ")
 ;Quit is user up arrowed or timed out
 Q:CANDATE'>0
 S CANBEGDT=$P(CANDATE,U,2),CANENDDT=$P(CANDATE,U,3)
 ; Prompt user for Bills with Payments
 S BILLPAYS=$$BILLPAYS^RCDMCUT2
 Q:BILLPAYS="^"
 ; Prompt user if report will be Excel Delimited format:
 S EXCEL=$$EXCEL
 ;Quit if user up arrowed or timed out
 Q:EXCEL="^"
 D:EXCEL>0 EXMSG
 D:EXCEL'>0
 . W !!,"This report is designed to be uploaded to an Excel spreadsheet format"
 . W !,"but you have chosen non-Excel format.  Therefore, it is recommended that you"
 . W !,"adjust your screen display size and terminal settings to at least 150 characters"
  .W !,"wide to accommodate the screen output."
 ; Logic from DEVICE^RCDMCUT2 copied here
 N %ZIS,ZTRTN,ZTIO,ZTSAVE,ZTDESK,ZTSK,POP,ZTDESC
 S %ZIS="QM"
 W ! D ^%ZIS
 I POP Q
 S RCSCR=$S($E($G(IOST),1,2)="C-":1,1:0)
 ;
 I $D(IO("Q")) D  S STOPIT=1
 . S ZTRTN="RUN^RCDMCR5A"
 . S ZTIO=ION
 . S ZTSAVE("RCSCR")=""
 . S ZTSAVE("CANBEGDT")=""
 . S ZTSAVE("CANENDDT")=""
 . S ZTSAVE("BILLPAYS")=""
 . S ZTSAVE("EXCEL")=""
 . S ZTDESC="DMC 0-40 Percent SC Change Reconciliation Report Process"
 . D ^%ZTLOAD
 . W !!,$S($D(ZTSK):"Request Queued.  TASK = "_ZTSK,1:"REQUEST CANCELLED")
 . D HOME^%ZIS
 ;
 Q:STOPIT>0!($D(ZTQUEUED))
 D RUN^RCDMCR5A
 I 'STOPIT D PAUSE2^RCDMCUT2
 Q
 ; Currently, Taskman schedulable option is not being planned for this report
 ; If this is going to change later on, QUERPT^RCDMCR3A would be a good example
 ; of how to do such an option
QUERPT ; Initial Taskman Scheduled Queued processing
 Q
 ;
RUN ;Get data and Print it out
 ;If queued ensure you delete it from the TASKS file
 I $D(ZTQUEUED) S ZTREQ="@"
 N RCPAGE
 S STOPIT=0
 K ^TMP($J,"RCDMCR5B")
 S RCPAGE=0
 ; Collect the data in ^TMP
 D COLLECT^RCDMCR5B(.STOPIT,CANBEGDT,CANENDDT,BILLPAYS)
 Q:$G(STOPIT)>0
 U IO
 ; Print Report using data in ^TMP
 D REPORT
 I 'RCSCR W !,@IOF
 D ^%ZISC
 K ^TMP($J,"RCDMCR5B")
 K EXCEL,RCSCR
 Q
 ;
REPORT ;Print report
 N RUNDATE,NAME,SSN,BILLNO,IBIEN,SKIP
 ;
 S RUNDATE=$$FMTE^XLFDT($$NOW^XLFDT,"9MP")
 D HDR
 I +$D(^TMP($J,"RCDMCR5B"))'>0 W !,"No data meets the criteria." Q
 K SKIP
 S NAME=""
 F  S NAME=$O(^TMP($J,"RCDMCR5B","DETAIL",NAME)) Q:NAME']""  D  Q:STOPIT
 . S SSN=""
 . F  S SSN=$O(^TMP($J,"RCDMCR5B","DETAIL",NAME,SSN)) Q:SSN']""  D  Q:STOPIT
 . . S BILLNO=""
 . . F  S BILLNO=$O(^TMP($J,"RCDMCR5B","DETAIL",NAME,SSN,BILLNO)) Q:BILLNO']""  D  Q:STOPIT
 . . . S IBIEN=""
 . . . F  S IBIEN=$O(^TMP($J,"RCDMCR5B","DETAIL",NAME,SSN,BILLNO,IBIEN)) Q:IBIEN']""  D  Q:STOPIT
 . . . . N NODE,CHGAMT,SERVDT,RXDT,RXNUM,RXNAM,CANCDT,CANCREAS,CANCUSER,APPR,RSC
 . . . . ; S ^TMP($J,"RCDMCR5B","DETAIL",NAME,SSN,BILLNO,IBIEN)=SERVDT_U_RXDT_U_CHGAMT_U_RXNUM_U_RXNAM_U_CANCDT_U_CANCREAS_U_CANCUSER
 . . . . S NODE=$G(^TMP($J,"RCDMCR5B","DETAIL",NAME,SSN,BILLNO,IBIEN))
 . . . . S SERVDT=$P(NODE,U,1)
 . . . . S RXDT=$P(NODE,U,2)
 . . . . S CHGAMT=$P(NODE,U,3)
 . . . . S RXNUM=$P(NODE,U,4)
 . . . . S RXNAM=$P(NODE,U,5)
 . . . . S CANCDT=$P(NODE,U,6)
 . . . . S CANCREAS=$P(NODE,U,7)
 . . . . S CANCUSER=$P(NODE,U,8)
 . . . . S APPR=$P(NODE,U,9)
 . . . . S RSC=$P(NODE,U,10) ;S ZZ=$G(ZZ)_", "_RSC
 . . . . I EXCEL'>0 D WRLINE Q
 . . . . I EXCEL>0 D WRLINE2 Q
 Q
 ;
WRLINE ; Write the data formated report line
 ;If Multiple Bills for Vet only print Name & SSN for 1st record on page
 ;
 ; Columns are - position, width, spacing (offset header by)
 ; Veteran Name - 0, 13, 1 (offset 1)
 ; SSN - 14, 10, 1 (offset 3)
 ; Bill Number - 25, 11, 1 (offset 1)
 ; Charge/Amount - 37, 11, 1 (offset 3,3)
 ; Appropriation Fund Number - 49, 6, 1 (offset 1)
 ; Revenue Source Code - 56, 5, 1 (offset 1) 
 ; Medical/Care Date - 62, 8, 1 (offset 1, 0)
 ; RXFillDT - 72, 9, 1 (offset 0)
 ; RX # - 82, 9, 1 (offset 3)
 ; RX Name - 92, 14, 1 (offset 3)
 ; IBCXLDT - 107, 7, 1 (offset 0)
 ; IB Cancellation/Reason - 115, 16, 1 (Offset 0, 6)
 ; Cancelled By - 132, 14 (offset 1)
 D CHKP() Q:STOPIT
 ; Disable Skips for now per direction of customer with :0
 W !
 I (NAME_SSN)'=$G(SKIP(1)) D
 . W $E(NAME,1,13) ; Veteran Name
 . W ?14,SSN ; SSN
 . S:0 SKIP(1)=NAME_SSN
 W ?25,BILLNO ; Bill Number
 W ?37,$J("$"_$FN(CHGAMT,",",2),11)
 W ?49,APPR
 W ?56,RSC
 W:SERVDT>0 ?62,$$STRIP^XLFSTR($$FMTE^XLFDT(SERVDT,"8D")," ")
 W:RXDT>0 ?72,$$STRIP^XLFSTR($$FMTE^XLFDT(RXDT,"8D")," ") ; Med Fill Date
 W ?82,RXNUM ; RX # 
 W ?92,$E(RXNAM,1,14) ; RX Name
 W ?107,$$STRIP^XLFSTR($$FMTE^XLFDT(CANCDT,"8D")," ")
 W ?115,$E(CANCREAS,1,16)
 W ?132,$E(CANCUSER,1,14)
 Q
 ;
WRLINE2 ; Write the Excel report line
 W !
 W $$EXOUT^RCDMCR4A(NAME),U
 W $$EXOUT^RCDMCR4A(SSN),U
 W BILLNO,U
 W "$",$FN(CHGAMT,",",2),U
 W APPR,U
 W RSC,U
 W $$FMTE^XLFDT(SERVDT,"9D")
 W U
 I RXDT W $$FMTE^XLFDT(RXDT,"9D")
 W U
 W RXNUM,U
 W RXNAM,U
 W $$FMTE^XLFDT(CANCDT,"9D"),U
 W CANCREAS,U
 W $$EXOUT^RCDMCR4A(CANCUSER)
 Q
 ;
CHKP(FOOTER) ;Check for End of Page
 ;INPUT:
 ;  FOOTER - Footer value. Optional. Default to 4 if nothing passed
 I $G(FOOTER)'>0 S FOOTER=4
 I $Y>(IOSL-FOOTER) D:RCSCR PAUSE^RCDMCUT2 Q:STOPIT  D HDR
 Q
 ;
HDR ;Print Report Header
 ;RUNDATE - Current Date in human readable format
 I EXCEL>0 D  Q
 . ;ASF 8/10/19
 . W !,"Veteran Name",U,"SSN",U,"Bill Number",U,"Charge Amount",U,"APPR",U,"RSC",U,"Medical Care Date",U,"RXFillDT",U
 . W "RX #",U,"RX Name",U,"IBCXLDT",U,"IB Cancellation Reason",U,"Cancelled By"
 S RCPAGE=RCPAGE+1 K SKIP
 W @IOF,"First Party Charge IB Cancellation Reconciliation Report  -- Run Date: ",RUNDATE," --"
 W ?140,"Page "_RCPAGE
 W !?6,"Cancellation Dates from ",$$FMTE^XLFDT(CANBEGDT,"9D")," to ",$$FMTE^XLFDT(CANENDDT,"9D")
 W !
 ;Print to screen or printer
 W !,?42,"Charge",?63,"Medical",?115,"IB Cancellation"
 W !," Veteran Name",?17,"SSN",?25,"Bill Number",?42,"Amount",?50,"APPR",?56,"RSC",?62,"Care Date",?72,"RXFillDT",?84,"RX #",?95,"RX Name",?107,"IBCXLDT",?120,"Reason",?132,"Cancelled By"
 D ULINE^RCDMCUT2("=",$G(IOM))
 Q
EXCEL() ; - Returns whether to capture data for Excel report.
 ;INPUT:
 ;  None
 ; Output:
 ;   Returns 1 - YES (capture data) / 0 - NO (DO NOT capture data) /
 ;           "^" - Exit report
 ;
 N EXCEL,X,Y,DIR,DIRUT,DTOUT,DUOUT,DIROUT
 ;
 S EXCEL=0
 S DIR(0)="Y",DIR("B")="YES",DIR("T")=DTIME W !
 S DIR("A")="Do you want to capture report data for an Excel document"
 S DIR("?")="^D HEXC^RCDMCUT2"
 D ^DIR
 S:$D(DIRUT)!$D(DTOUT)!$D(DUOUT)!$D(DIROUT) EXCEL="^"
 S:$G(Y)>0 EXCEL=1
 ;
 Q EXCEL
EXMSG ;message if sending to excel
 W !!,"This report may take a while to run. It is recommended that you Queue it."
 W !,"To capture as an Excel format, it is recommended that you queue this"
 W !,"report to a spool device with margins of 256 and page length of 99999"
 W !,"(e.g. spoolname;256;99999). This should help avoid wrapping problems."
 W !
 W !,"Another method would be to set up your terminal to capture the detail"
 W !,"report data. On some terminals, this can be done by clicking on the"
 W !,"'Tools' menu above, then click on 'Capture Incoming Data' to save to"
 W !,"Desktop.  To avoid undesired wrapping of the data saved to the file,"
 W !,"please enter '0;256;99999' at the 'DEVICE:' prompt."
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRCDMCR5A   8407     printed  Sep 23, 2025@19:19:38                                                                                                                                                                                                    Page 2
RCDMCR5A  ;HAF/ASF - First Party Charge IB Cancellation Reconciliation Report - Input/output; Apr 9, 2019@21:06
 +1       ;;4.5;Accounts Receivable;**347,361**;Mar 20, 1995;Build 6
 +2       ;;Per VA Directive 6402, this routine should not be modified.
 +3       ;
 +4       ;This routine is being implemented for the AR Cross-Referencing Project
 +5       ;
 +6       ;This report will assist users in reviewing first party charges receiving
 +7       ;Integrated Billing (IB) cancellation for potential refund activities or charge
 +8       ;cancellation accuracy, and to identify and monitor cancellation activity
 +9       ;productivity so veteran customers can receive refunds due to them for
 +10      ;retroactive eligibility exemptions.  The report provides data for first party
 +11      ;charges receiving IB cancellation for a user defined bill cancellation 
 +12      ;date range.
MAIN      ; Initial Interactive Processing
 +1        NEW STOPIT,EXCEL,CANDATE,CANBEGDT,CANENDDT,BILLPAYS,RCSCR
 +2        WRITE !!,"*** Print the First Party Charge IB Cancellation Reconciliation Report ***",!
 +3       ; quit flag
           SET STOPIT=0
 +4       ;Prompt user for Date Range for Bill Cancellation date range
 +5        SET CANDATE=$$DATE2^RCDMCUT2("    Enter the Bill Cancellation Date Range: ")
 +6       ;Quit is user up arrowed or timed out
 +7        if CANDATE'>0
               QUIT 
 +8        SET CANBEGDT=$PIECE(CANDATE,U,2)
           SET CANENDDT=$PIECE(CANDATE,U,3)
 +9       ; Prompt user for Bills with Payments
 +10       SET BILLPAYS=$$BILLPAYS^RCDMCUT2
 +11       if BILLPAYS="^"
               QUIT 
 +12      ; Prompt user if report will be Excel Delimited format:
 +13       SET EXCEL=$$EXCEL
 +14      ;Quit if user up arrowed or timed out
 +15       if EXCEL="^"
               QUIT 
 +16       if EXCEL>0
               DO EXMSG
 +17       if EXCEL'>0
               Begin DoDot:1
 +18               WRITE !!,"This report is designed to be uploaded to an Excel spreadsheet format"
 +19               WRITE !,"but you have chosen non-Excel format.  Therefore, it is recommended that you"
 +20               WRITE !,"adjust your screen display size and terminal settings to at least 150 characters"
 +21               WRITE !,"wide to accommodate the screen output."
               End DoDot:1
 +22      ; Logic from DEVICE^RCDMCUT2 copied here
 +23       NEW %ZIS,ZTRTN,ZTIO,ZTSAVE,ZTDESK,ZTSK,POP,ZTDESC
 +24       SET %ZIS="QM"
 +25       WRITE !
           DO ^%ZIS
 +26       IF POP
               QUIT 
 +27       SET RCSCR=$SELECT($EXTRACT($GET(IOST),1,2)="C-":1,1:0)
 +28      ;
 +29       IF $DATA(IO("Q"))
               Begin DoDot:1
 +30               SET ZTRTN="RUN^RCDMCR5A"
 +31               SET ZTIO=ION
 +32               SET ZTSAVE("RCSCR")=""
 +33               SET ZTSAVE("CANBEGDT")=""
 +34               SET ZTSAVE("CANENDDT")=""
 +35               SET ZTSAVE("BILLPAYS")=""
 +36               SET ZTSAVE("EXCEL")=""
 +37               SET ZTDESC="DMC 0-40 Percent SC Change Reconciliation Report Process"
 +38               DO ^%ZTLOAD
 +39               WRITE !!,$SELECT($DATA(ZTSK):"Request Queued.  TASK = "_ZTSK,1:"REQUEST CANCELLED")
 +40               DO HOME^%ZIS
               End DoDot:1
               SET STOPIT=1
 +41      ;
 +42       if STOPIT>0!($DATA(ZTQUEUED))
               QUIT 
 +43       DO RUN^RCDMCR5A
 +44       IF 'STOPIT
               DO PAUSE2^RCDMCUT2
 +45       QUIT 
 +46      ; Currently, Taskman schedulable option is not being planned for this report
 +47      ; If this is going to change later on, QUERPT^RCDMCR3A would be a good example
 +48      ; of how to do such an option
QUERPT    ; Initial Taskman Scheduled Queued processing
 +1        QUIT 
 +2       ;
RUN       ;Get data and Print it out
 +1       ;If queued ensure you delete it from the TASKS file
 +2        IF $DATA(ZTQUEUED)
               SET ZTREQ="@"
 +3        NEW RCPAGE
 +4        SET STOPIT=0
 +5        KILL ^TMP($JOB,"RCDMCR5B")
 +6        SET RCPAGE=0
 +7       ; Collect the data in ^TMP
 +8        DO COLLECT^RCDMCR5B(.STOPIT,CANBEGDT,CANENDDT,BILLPAYS)
 +9        if $GET(STOPIT)>0
               QUIT 
 +10       USE IO
 +11      ; Print Report using data in ^TMP
 +12       DO REPORT
 +13       IF 'RCSCR
               WRITE !,@IOF
 +14       DO ^%ZISC
 +15       KILL ^TMP($JOB,"RCDMCR5B")
 +16       KILL EXCEL,RCSCR
 +17       QUIT 
 +18      ;
REPORT    ;Print report
 +1        NEW RUNDATE,NAME,SSN,BILLNO,IBIEN,SKIP
 +2       ;
 +3        SET RUNDATE=$$FMTE^XLFDT($$NOW^XLFDT,"9MP")
 +4        DO HDR
 +5        IF +$DATA(^TMP($JOB,"RCDMCR5B"))'>0
               WRITE !,"No data meets the criteria."
               QUIT 
 +6        KILL SKIP
 +7        SET NAME=""
 +8        FOR 
               SET NAME=$ORDER(^TMP($JOB,"RCDMCR5B","DETAIL",NAME))
               if NAME']""
                   QUIT 
               Begin DoDot:1
 +9                SET SSN=""
 +10               FOR 
                       SET SSN=$ORDER(^TMP($JOB,"RCDMCR5B","DETAIL",NAME,SSN))
                       if SSN']""
                           QUIT 
                       Begin DoDot:2
 +11                       SET BILLNO=""
 +12                       FOR 
                               SET BILLNO=$ORDER(^TMP($JOB,"RCDMCR5B","DETAIL",NAME,SSN,BILLNO))
                               if BILLNO']""
                                   QUIT 
                               Begin DoDot:3
 +13                               SET IBIEN=""
 +14                               FOR 
                                       SET IBIEN=$ORDER(^TMP($JOB,"RCDMCR5B","DETAIL",NAME,SSN,BILLNO,IBIEN))
                                       if IBIEN']""
                                           QUIT 
                                       Begin DoDot:4
 +15                                       NEW NODE,CHGAMT,SERVDT,RXDT,RXNUM,RXNAM,CANCDT,CANCREAS,CANCUSER,APPR,RSC
 +16      ; S ^TMP($J,"RCDMCR5B","DETAIL",NAME,SSN,BILLNO,IBIEN)=SERVDT_U_RXDT_U_CHGAMT_U_RXNUM_U_RXNAM_U_CANCDT_U_CANCREAS_U_CANCUSER
 +17                                       SET NODE=$GET(^TMP($JOB,"RCDMCR5B","DETAIL",NAME,SSN,BILLNO,IBIEN))
 +18                                       SET SERVDT=$PIECE(NODE,U,1)
 +19                                       SET RXDT=$PIECE(NODE,U,2)
 +20                                       SET CHGAMT=$PIECE(NODE,U,3)
 +21                                       SET RXNUM=$PIECE(NODE,U,4)
 +22                                       SET RXNAM=$PIECE(NODE,U,5)
 +23                                       SET CANCDT=$PIECE(NODE,U,6)
 +24                                       SET CANCREAS=$PIECE(NODE,U,7)
 +25                                       SET CANCUSER=$PIECE(NODE,U,8)
 +26                                       SET APPR=$PIECE(NODE,U,9)
 +27      ;S ZZ=$G(ZZ)_", "_RSC
                                           SET RSC=$PIECE(NODE,U,10)
 +28                                       IF EXCEL'>0
                                               DO WRLINE
                                               QUIT 
 +29                                       IF EXCEL>0
                                               DO WRLINE2
                                               QUIT 
                                       End DoDot:4
                                       if STOPIT
                                           QUIT 
                               End DoDot:3
                               if STOPIT
                                   QUIT 
                       End DoDot:2
                       if STOPIT
                           QUIT 
               End DoDot:1
               if STOPIT
                   QUIT 
 +30       QUIT 
 +31      ;
WRLINE    ; Write the data formated report line
 +1       ;If Multiple Bills for Vet only print Name & SSN for 1st record on page
 +2       ;
 +3       ; Columns are - position, width, spacing (offset header by)
 +4       ; Veteran Name - 0, 13, 1 (offset 1)
 +5       ; SSN - 14, 10, 1 (offset 3)
 +6       ; Bill Number - 25, 11, 1 (offset 1)
 +7       ; Charge/Amount - 37, 11, 1 (offset 3,3)
 +8       ; Appropriation Fund Number - 49, 6, 1 (offset 1)
 +9       ; Revenue Source Code - 56, 5, 1 (offset 1) 
 +10      ; Medical/Care Date - 62, 8, 1 (offset 1, 0)
 +11      ; RXFillDT - 72, 9, 1 (offset 0)
 +12      ; RX # - 82, 9, 1 (offset 3)
 +13      ; RX Name - 92, 14, 1 (offset 3)
 +14      ; IBCXLDT - 107, 7, 1 (offset 0)
 +15      ; IB Cancellation/Reason - 115, 16, 1 (Offset 0, 6)
 +16      ; Cancelled By - 132, 14 (offset 1)
 +17       DO CHKP()
           if STOPIT
               QUIT 
 +18      ; Disable Skips for now per direction of customer with :0
 +19       WRITE !
 +20       IF (NAME_SSN)'=$GET(SKIP(1))
               Begin DoDot:1
 +21      ; Veteran Name
                   WRITE $EXTRACT(NAME,1,13)
 +22      ; SSN
                   WRITE ?14,SSN
 +23               if 0
                       SET SKIP(1)=NAME_SSN
               End DoDot:1
 +24      ; Bill Number
           WRITE ?25,BILLNO
 +25       WRITE ?37,$JUSTIFY("$"_$FNUMBER(CHGAMT,",",2),11)
 +26       WRITE ?49,APPR
 +27       WRITE ?56,RSC
 +28       if SERVDT>0
               WRITE ?62,$$STRIP^XLFSTR($$FMTE^XLFDT(SERVDT,"8D")," ")
 +29      ; Med Fill Date
           if RXDT>0
               WRITE ?72,$$STRIP^XLFSTR($$FMTE^XLFDT(RXDT,"8D")," ")
 +30      ; RX # 
           WRITE ?82,RXNUM
 +31      ; RX Name
           WRITE ?92,$EXTRACT(RXNAM,1,14)
 +32       WRITE ?107,$$STRIP^XLFSTR($$FMTE^XLFDT(CANCDT,"8D")," ")
 +33       WRITE ?115,$EXTRACT(CANCREAS,1,16)
 +34       WRITE ?132,$EXTRACT(CANCUSER,1,14)
 +35       QUIT 
 +36      ;
WRLINE2   ; Write the Excel report line
 +1        WRITE !
 +2        WRITE $$EXOUT^RCDMCR4A(NAME),U
 +3        WRITE $$EXOUT^RCDMCR4A(SSN),U
 +4        WRITE BILLNO,U
 +5        WRITE "$",$FNUMBER(CHGAMT,",",2),U
 +6        WRITE APPR,U
 +7        WRITE RSC,U
 +8        WRITE $$FMTE^XLFDT(SERVDT,"9D")
 +9        WRITE U
 +10       IF RXDT
               WRITE $$FMTE^XLFDT(RXDT,"9D")
 +11       WRITE U
 +12       WRITE RXNUM,U
 +13       WRITE RXNAM,U
 +14       WRITE $$FMTE^XLFDT(CANCDT,"9D"),U
 +15       WRITE CANCREAS,U
 +16       WRITE $$EXOUT^RCDMCR4A(CANCUSER)
 +17       QUIT 
 +18      ;
CHKP(FOOTER) ;Check for End of Page
 +1       ;INPUT:
 +2       ;  FOOTER - Footer value. Optional. Default to 4 if nothing passed
 +3        IF $GET(FOOTER)'>0
               SET FOOTER=4
 +4        IF $Y>(IOSL-FOOTER)
               if RCSCR
                   DO PAUSE^RCDMCUT2
               if STOPIT
                   QUIT 
               DO HDR
 +5        QUIT 
 +6       ;
HDR       ;Print Report Header
 +1       ;RUNDATE - Current Date in human readable format
 +2        IF EXCEL>0
               Begin DoDot:1
 +3       ;ASF 8/10/19
 +4                WRITE !,"Veteran Name",U,"SSN",U,"Bill Number",U,"Charge Amount",U,"APPR",U,"RSC",U,"Medical Care Date",U,"RXFillDT",U
 +5                WRITE "RX #",U,"RX Name",U,"IBCXLDT",U,"IB Cancellation Reason",U,"Cancelled By"
               End DoDot:1
               QUIT 
 +6        SET RCPAGE=RCPAGE+1
           KILL SKIP
 +7        WRITE @IOF,"First Party Charge IB Cancellation Reconciliation Report  -- Run Date: ",RUNDATE," --"
 +8        WRITE ?140,"Page "_RCPAGE
 +9        WRITE !?6,"Cancellation Dates from ",$$FMTE^XLFDT(CANBEGDT,"9D")," to ",$$FMTE^XLFDT(CANENDDT,"9D")
 +10       WRITE !
 +11      ;Print to screen or printer
 +12       WRITE !,?42,"Charge",?63,"Medical",?115,"IB Cancellation"
 +13       WRITE !," Veteran Name",?17,"SSN",?25,"Bill Number",?42,"Amount",?50,"APPR",?56,"RSC",?62,"Care Date",?72,"RXFillDT",?84,"RX #",?95,"RX Name",?107,"IBCXLDT",?120,"Reason",?132,"Cancelled By"
 +14       DO ULINE^RCDMCUT2("=",$GET(IOM))
 +15       QUIT 
EXCEL()   ; - Returns whether to capture data for Excel report.
 +1       ;INPUT:
 +2       ;  None
 +3       ; Output:
 +4       ;   Returns 1 - YES (capture data) / 0 - NO (DO NOT capture data) /
 +5       ;           "^" - Exit report
 +6       ;
 +7        NEW EXCEL,X,Y,DIR,DIRUT,DTOUT,DUOUT,DIROUT
 +8       ;
 +9        SET EXCEL=0
 +10       SET DIR(0)="Y"
           SET DIR("B")="YES"
           SET DIR("T")=DTIME
           WRITE !
 +11       SET DIR("A")="Do you want to capture report data for an Excel document"
 +12       SET DIR("?")="^D HEXC^RCDMCUT2"
 +13       DO ^DIR
 +14       if $DATA(DIRUT)!$DATA(DTOUT)!$DATA(DUOUT)!$DATA(DIROUT)
               SET EXCEL="^"
 +15       if $GET(Y)>0
               SET EXCEL=1
 +16      ;
 +17       QUIT EXCEL
EXMSG     ;message if sending to excel
 +1        WRITE !!,"This report may take a while to run. It is recommended that you Queue it."
 +2        WRITE !,"To capture as an Excel format, it is recommended that you queue this"
 +3        WRITE !,"report to a spool device with margins of 256 and page length of 99999"
 +4        WRITE !,"(e.g. spoolname;256;99999). This should help avoid wrapping problems."
 +5        WRITE !
 +6        WRITE !,"Another method would be to set up your terminal to capture the detail"
 +7        WRITE !,"report data. On some terminals, this can be done by clicking on the"
 +8        WRITE !,"'Tools' menu above, then click on 'Capture Incoming Data' to save to"
 +9        WRITE !,"Desktop.  To avoid undesired wrapping of the data saved to the file,"
 +10       WRITE !,"please enter '0;256;99999' at the 'DEVICE:' prompt."