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

RCDPEFA3.m

Go to the documentation of this file.
  1. RCDPEFA3 ;AITC/CJE - 1ST PARTY AUTO DECREASE VS MANUAL DECREASE REPORT;Jun 06, 2014@19:11:19 ; 7/3/19 8:41am
  1. ;;4.5;Accounts Receivable;**345,349**;Mar 20, 1995;Build 44
  1. ;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. EN ; Entry point for Manual vs Auto-Decrease Adjustment Report [RCDPE FIRST PARTY MANUAL VS AUTO]
  1. N INPUT,RCVAUTD
  1. S INPUT=$$STADIV^RCDPEFA2(.RCVAUTD) ; Division filter
  1. Q:'INPUT
  1. S $P(INPUT,U,2)=$$DETSUM^RCDPEFA2 ; Display detailed or summary report
  1. Q:$P(INPUT,U,2)=0 ; '^' or timeout
  1. S $P(INPUT,U,3)="F"
  1. I $P(INPUT,U,2)="D" D ; Select Sort Criteria
  1. . S $P(INPUT,U,3)=$$SORTORD^RCDPEFA2("C")
  1. Q:$P(INPUT,U,3)=0 ; '^' or timeout
  1. W !!,"Include first party bills where the latest decrease falls within the following"
  1. W !,"date range",!
  1. S $P(INPUT,U,4)=$$DTRNG^RCDPEFA2 ; Select Date Range for Report
  1. Q:'$P(INPUT,U,4) ; '^' or timeout
  1. S $P(INPUT,U,4)=$P($P(INPUT,U,4),"|",2,3)
  1. S $P(INPUT,U,5)=$$ASKLM^RCDPEARL ; Ask to Display in Listman Template
  1. Q:$P(INPUT,U,5)<0 ; '^' or timeout
  1. I $P(INPUT,U,5)=1 D Q ; Compile data and call listman to display
  1. . D LMOUT^RCDPEFA4(INPUT,.RCVAUTD,.IO)
  1. I $P(INPUT,U,2)="D" D ;
  1. . S $P(INPUT,U,6)=$$DISPTY^RCDPEFA2 ; Select Display Type
  1. Q:$P(INPUT,U,6)=-1 ; '^' or timeout
  1. D:$P(INPUT,U,6)=1 INFO^RCDPEM6 ; Display capture information for Excel
  1. Q:'$$DEVICE^RCDPEFA2(.IO) ; Ask output device
  1. ;
  1. ; Compile and Display Report data (queued) - not allowed for EXCEL
  1. I $P(INPUT,U,5)'=1,$D(IO("Q")) D Q
  1. . N ZTDESC,ZTQUEUED,ZTRTN,ZTSAVE,ZTSK
  1. . S ZTRTN="REPORT^RCDPEFA3(INPUT,.RCVAUTD,.IO)"
  1. . S ZTDESC="EDI LOCKBOX FIRST PARTY AUTO-DECREASE REPORT"
  1. . S ZTSAVE("RC*")="",ZTSAVE("INPUT")="",ZTSAVE("IO*")=""
  1. . D ^%ZTLOAD
  1. . W !!,$S($G(ZTSK):"Task number "_ZTSK_" has been queued.",1:"Unable to queue this job.")
  1. . K IO("Q") D HOME^%ZIS
  1. D REPORT(INPUT,.RCVAUTD,.IO) ; Create report
  1. ;
  1. K ^TMP("RCDPEFADP3",$J),^TMP("RCDPE_ADP3",$J) ; Clear ^TMP global
  1. Q
  1. ;
  1. REPORT(INPUTS,RCVAUTD,IO) ; Compile and print report
  1. ; Input: INPUTS - A1^A2^A3^...^An Where:
  1. ; A1 - 1 - All divisions selected, 2 - Selected divisions
  1. ; A2 - D - Detail Report, S - Summary Report
  1. ; A3 - F - sort First to Last, L - sort Last to First
  1. ; A4 - B1|B2
  1. ; B1 - Decrease Transaction Date Entered Start
  1. ; B2 - Decrease Transaction Date Entered End
  1. ; A5 - 1 - Output to List Manager, else 0
  1. ; A6 - 1 - Output to Excel, else 0
  1. ; RCVAUTD - Array of selected Divisions, Only passed if A1=2
  1. ; IO - Output Device
  1. N RCTOTAL,XX,ZTREQ
  1. U:$P(INPUTS,"^",5)'=1 IO ; PRCA*4.5*349 Added check to skip if in listman mode
  1. K ^TMP("RCDPEFADP3",$J),^TMP("RCDPE_ADP3",$J)
  1. D COMPILE(INPUTS,.RCVAUTD) ; Scan AR TRANSACTION file for entries in date range
  1. D DISP(INPUTS) ; Display Report
  1. D ^%ZISC ; Close device
  1. Q
  1. ;
  1. COMPILE(INPUTS,RCVAUTD) ; Compile Report Data
  1. N BEG,DAIEN,END,EXCEL,RC430IEN,RCAMT,RCBILL,RCBILL3,RCCOPAY,RCDT
  1. N RCSITE,RCSORT,RCTR,RCTRAND,RCUSER,STNAM,STNUM,TRANDA,X,XX
  1. ;
  1. S XX=$P(INPUTS,U,4) ; Auto-Post Date range
  1. S BEG=$$FMADD^XLFDT($P(XX,"|",1),-1)
  1. S END=$P(XX,"|",2) ; Auto-Post End Date
  1. S RCTR=0 ; Record counter
  1. S EXCEL=$P(INPUTS,U,6) ; 1 output to Excel, 0 otherwise
  1. S RCSORT=$P(INPUTS,U,2) ; Sort Type
  1. ;
  1. ; Scan index for auto-posted claim lines within the ERA
  1. ; and Save claim line detail to ^TMP global
  1. ; Get IEN of 'DECREASE ADJUSTMENT' fron #430.3
  1. S DAIEN=$O(^PRCA(430.3,"B","DECREASE ADJUSTMENT",""))
  1. ;
  1. ; Scan AR Transaction date index for days
  1. S RCTRAND=BEG
  1. F S RCTRAND=$O(^PRCA(433,"AT",DAIEN,RCTRAND)) Q:'RCTRAND!(RCTRAND>END) D
  1. . ;
  1. . ; Scan AR transactions
  1. . S TRANDA=""
  1. . F S TRANDA=$O(^PRCA(433,"AT",DAIEN,RCTRAND,TRANDA)) Q:'TRANDA D
  1. . . S RC430IEN=$$GET1^DIQ(433,TRANDA_",",.03,"I") ; Get AR ACCOUNT
  1. . . Q:'RC430IEN
  1. . . S RCSITE=$$GET1^DIQ(430,RC430IEN_",",12,"I") ; Get SITE ien
  1. . . Q:'RCSITE
  1. . . ;
  1. . . ; Ignore transaction if not a selected Division
  1. . . I $P(INPUTS,U,1)=2,'$D(RCVAUTD(RCSITE)) Q
  1. . . S RCBILL=$$GET1^DIQ(433,TRANDA_",",.03,"I") ; Copay Claim #
  1. . . ; Make sure this is first party - DEBTOR is a patient
  1. . . Q:$$GET1^DIQ(340,$$GET1^DIQ(430,RC430IEN_",",9,"I")_",",.01,"I")'["DPT"
  1. . . I $D(^TMP("RCDPEFADP3",$J,"BILL",RCBILL)) Q ; Bill already stored
  1. . . ; Check that the last decrease falls in the date range, if so store the results
  1. . . D CHKBILL(RCBILL,BEG,END,.RCTR)
  1. ;
  1. Q
  1. ;
  1. CHKBILL(RCBILL,BEG,END,RCTR) ; Check date of last decrease transaction, store if inside date range.
  1. ; Input: RCBILL - Internal entry number to file 430.
  1. ; BEG - Beginning date range -1 day, FileMan format
  1. ; END - Ending date range, FileMan format
  1. ; RCTR - Record counter passed by reference
  1. ;
  1. N RCAMT,RCBILL3,RCCOPAY,RCDTI,RCPROC,RCTLIS,RCTOT,RCUSER,RELEASE,STNUM,STNAME,TRANDA,X,Y
  1. S (TRANDA,RCDTI)=""
  1. F X="A","M","T" S RCTOT(X)=0
  1. F S TRANDA=$O(^PRCA(433,"C",RCBILL,TRANDA)) Q:'TRANDA D ;
  1. . I $$GET1^DIQ(433,TRANDA_",",12,"E")'="DECREASE ADJUSTMENT" Q ;
  1. . S X=$$GET1^DIQ(433,TRANDA_",",11,"I")
  1. . I X>RCDTI S RCDTI=X
  1. . S RCTLIS(TRANDA)=""
  1. ;
  1. ; Is last decrease inside selected date range? If not quit.
  1. I RCDTI'>BEG!(RCDTI>END) Q
  1. ;
  1. S RCBILL3=" "
  1. D DIV^RCDPEFA1(RCBILL,.STNUM,.STNAM) ; Station name/number
  1. S X=$$GET1^DIQ(430,RCBILL_",",.01,"E")
  1. S XX=$O(^IB("ABIL",X,0)) ; IEN in file #350
  1. I $$GET1^DIQ(350,XX_",",.05,"E")'="BILLED" Q ; Ignore decrease for charges that were cancelled etc.
  1. S RCCOPAY=$$GET1^DIQ(350,XX_",",.07,"E") ; Copay Amount
  1. S RCPROC=$$GET1^DIQ(430,RCBILL_",",97,"E") ; Processed by
  1. S RELEASE=$S(RCPROC="POSTMASTER":1,1:0) ; Auto-release from hold if bill processed by postmaster
  1. ;
  1. ; Get all decrease transactions for this bill;
  1. S TRANDA=""
  1. F S TRANDA=$O(RCTLIS(TRANDA)) Q:'TRANDA D ;
  1. . S RCUSER=$$GET1^DIQ(433,TRANDA_",",42,"E") ; Get user
  1. . S Y=$$GET1^DIQ(433,TRANDA_",",94,"E")
  1. . I RCBILL3=" ",Y'="" S RCBILL3=Y
  1. . S X=$S(RCUSER="POSTMASTER"&(Y'=" "):"A",1:"M")
  1. . S RCAMT=$$GET1^DIQ(433,TRANDA_",",15,"E") ; Transaction amount
  1. . S RCTOT(X)=$G(RCTOT(X))+RCAMT ; Running total of manual or auto decrease
  1. . S RCTOT("T")=$G(RCTOT("T"))+RCAMT ; Running total decrease for this bill
  1. . ;
  1. ;
  1. D SAVE(RCBILL,RCBILL3,RCDTI,RCCOPAY,RELEASE,.RCTOT,.RCTR)
  1. S ^TMP("RCDPEFADP3",$J,"BILL",RCBILL)=""
  1. Q
  1. ;
  1. SAVE(RCBILL,RCBILL3,RCDTI,RCCOPAY,RELEASE,RCTOT,RCTR) ; Put data into ^TMP
  1. ; Input: RCBILL - Copay Claim #
  1. ; RCBILL3 - 3rd Party Claim #
  1. ; RCDTI - Auto-decrease date (internal)
  1. ; RCCOPAY - Copay Amount
  1. ; RELEASE - 1 charge was auto-released from hold, 0 otherwise
  1. ; RCTOT - Decrease totals in an array passed by reference
  1. ; RCTOT("A") - Auto-decrease total
  1. ; RCTOT("M") - Manual decrease total
  1. ; RCTOT("T") - Total decrease
  1. ; Output: DTOTAL() - RCTR - Record Counter passed by reference
  1. ; ^TMP("RCDPEFADP3",$J,A1,A2,A3) = B1^B2^B3^...^Bn Where:
  1. ; A1 - "EXCEL" if report to excel, fileman date if not
  1. ; A2 - Excel Line Counter if to excel, Claim # if sort by claim,
  1. ; A3 - Record Counter
  1. ; B1 - External Station Name
  1. ; B2 - External Station Number
  1. ; B3 - Copay Bill Number
  1. ; B4 - 3rd Party Bill Number
  1. ; B5 - Auto-Decrease Date
  1. ; B6 - Copay Amount
  1. ; B7 - Auto-Decrease Amount
  1. ; B8 - Manual Decrease Amount
  1. ; B9 - Total decrease Amount
  1. ; B10 - Auto-release from hold flag
  1. ;
  1. N A1,A2,XX,CNT,RCDT,RCTOTAL
  1. S RCTR=RCTR+1
  1. ;
  1. S RCDT=$$FMTE^XLFDT(RCDTI,"2SZ") ; Transaction date External
  1. ; If EXCEL sorting is done in EXCEL
  1. I EXCEL=1 D
  1. . S A1="EXCEL",A2=$G(^TMP("RCDPEFADP3",$J,A1))+1
  1. . S ^TMP("RCDPEFADP3",$J,A1)=A2
  1. ;
  1. ; Otherwise sort by DATE and Bill Number
  1. I 'EXCEL D
  1. . S A1=RCDTI
  1. . S A2=RCBILL
  1. ;
  1. ; Update ^TMP gif claim level adjustments found for this claim
  1. S XX=STNAM_U_STNUM_U_$$GET1^DIQ(430,RCBILL_",",.01,"E")
  1. S XX=XX_U_RCBILL3_U_RCDT_U_RCCOPAY_U_RCTOT("A")_U_RCTOT("M")_U_RCTOT("T")_U_RELEASE
  1. S ^TMP("RCDPEFADP3",$J,"DATA",A1,A2,RCTR)=XX ; Claim Information
  1. ;
  1. ; Update totals for date
  1. S RCTOTAL=$G(^TMP("RCDPEFADP3",$J,"TOTALS",RCDTI))
  1. S ^TMP("RCDPEFADP3",$J,"TOTALS",RCDTI)=$$TOTAL(RCTOTAL,RCCOPAY,RELEASE,.RCTOT)
  1. ;
  1. ; Update totals for date range
  1. S RCTOTAL=$G(^TMP("RCDPEFADP3",$J,"TOTALS"))
  1. S ^TMP("RCDPEFADP3",$J,"TOTALS")=$$TOTAL(RCTOTAL,RCCOPAY,RELEASE,.RCTOT)
  1. ;
  1. Q
  1. ;
  1. TOTAL(RCTOTAL,RCCOPAY,RELEASE,RCTOT) ; Increment daily or overall totals
  1. ; Input : RCTOTAL - old total
  1. ; : RCCOPAY - COPAY amount
  1. ; : RELEASE - Flag 0, 1 if bill was created by auto-releasing a charge from hold
  1. ; : RCTOTAL - Array passed by reference of manual, auto and total decreases for this bill
  1. S $P(RCTOTAL,U,1)=$P(RCTOTAL,U,1)+RCCOPAY
  1. S $P(RCTOTAL,U,2)=$P(RCTOTAL,U,2)+RCTOT("A")
  1. S $P(RCTOTAL,U,3)=$P(RCTOTAL,U,3)+RCTOT("M")
  1. S $P(RCTOTAL,U,4)=$P(RCTOTAL,U,4)+RCTOT("T")
  1. S $P(RCTOTAL,U,5)=$P(RCTOTAL,U,5)+$S(RELEASE:1,1:0) ; # of bills created by auto-release from hold
  1. S $P(RCTOTAL,U,6)=$P(RCTOTAL,U,6)+1 ; Total number of bills
  1. Q RCTOTAL
  1. ;
  1. DISP(INPUTS) ; Format the display for screen/printer or MS Excel
  1. ; Input: INPUTS - See REPORT for details
  1. ; ^TMP("RCDPEFADP",$J) - See SAVE for description
  1. N A1,A2,A3,DATA,EXCEL,GTOTAL,HDRINFO,LMAN,LCNT,MODE,PAGE,RCRDNUM,STOP,X,Y,DISP
  1. U:$P(INPUTS,"^",5)'=1 IO ; PRCA*4.5*349 Added check to skip if in listman mode
  1. S EXCEL=$P(INPUTS,U,6),LMAN=$P(INPUTS,U,5),DISP=$P(INPUTS,U,2)
  1. ;
  1. ; Header information
  1. S XX=$P(INPUTS,U,4) ; Auto-Post Date range
  1. S HDRINFO("START")=$$FMTE^XLFDT($P(XX,"|",1),"2SZ")
  1. S HDRINFO("END")=$$FMTE^XLFDT($P(XX,"|",2),"2SZ")
  1. S HDRINFO("RUNDATE")=$$FMTE^XLFDT($$NOW^XLFDT,"2SZ")
  1. S HDRINFO("SORT")="Sorted By: Claim"
  1. S XX=$S($P(INPUTS,U,3)="L":"Last to First",1:"First to Last")
  1. S HDRINFO("SORT")=HDRINFO("SORT")_" - "_XX
  1. S HDRINFO("DISP")="Display: "_$S(DISP="S":"Summary",1:"Detail")
  1. ;
  1. ; Format Division filter
  1. S XX=$P(INPUTS,U,1) ; XX=1 - All Divisions, 2- selected
  1. S HDRINFO("DIVISIONS")=$S(XX=2:$$LINE(.RCVAUTD),1:"ALL")
  1. ;
  1. S A1="",PAGE=0,STOP=0,LCNT=1
  1. I 'LMAN,DISP="S" D HDR(EXCEL,.HDRINFO,.PAGE)
  1. S MODE=$S($P(INPUTS,U,3)="L":-1,1:1) ; Mode for $ORDER
  1. F D Q:(A1="")!STOP
  1. . S A1=$O(^TMP("RCDPEFADP3",$J,"DATA",A1))
  1. . Q:A1=""
  1. . I 'LMAN,DISP="D" D Q:STOP ; Display Header
  1. . . I PAGE D ASK^RCDPEFA1(.STOP,0) Q:STOP ; Output to screen, quit if user wants to
  1. . . D HDR(EXCEL,.HDRINFO,.PAGE)
  1. . S A2=""
  1. . F D Q:(A2="")!STOP
  1. . . S A2=$O(^TMP("RCDPEFADP3",$J,"DATA",A1,A2),MODE)
  1. . . I 'EXCEL,A2="" D TOTALD(LMAN,.HDRINFO,.PAGE,.STOP,A1,.LCNT)
  1. . . Q:A2=""
  1. . . Q:DISP="S" ; Skip printing details if summary report
  1. . . S A3=0
  1. . . F D Q:'A3!STOP
  1. . . . S A3=$O(^TMP("RCDPEFADP3",$J,"DATA",A1,A2,A3))
  1. . . . Q:'A3
  1. . . . S DATA=^TMP("RCDPEFADP3",$J,"DATA",A1,A2,A3) ; Auto-Decreased Claim
  1. . . . I EXCEL W !,DATA Q ; Output to Excel
  1. . . . I 'LMAN,$Y>(IOSL-4) D Q:STOP ; End of page
  1. . . . . D ASK^RCDPEFA1(.STOP,0)
  1. . . . . Q:STOP
  1. . . . . D HDR(EXCEL,.HDRINFO,.PAGE)
  1. . . . S Y=$P(DATA,U,3) ; 1st Party Bill
  1. . . . S $E(Y,13)=$P(DATA,U,4) ; 3rd Party Bill
  1. . . . S $E(Y,26)=$P(DATA,U,5) ; Decrease Date
  1. . . . S $E(Y,34)=$J($P(DATA,U,6),7,2) ; Copay AMOUNT
  1. . . . S $E(Y,43)=$J($P(DATA,U,7),7,2) ; Auto-Decrease Amount
  1. . . . S $E(Y,54)=$J($P(DATA,U,8),7,2) ; Manual Decrease Amount
  1. . . . S $E(Y,66)=$J($P(DATA,U,9),7,2) ; Total Decrease Amount
  1. . . . S $E(Y,80)=$S($P(DATA,U,10):"*",1:" ") ; Auto-release flag
  1. . . . I LMAN D
  1. . . . . S ^TMP("RCDPE_ADP3",$J,LCNT)=Y,LCNT=LCNT+1
  1. . . . E D
  1. . . . . W !,Y
  1. ;
  1. ; Grand totals
  1. S GTOTAL=$P($G(^TMP("RCDPEFADP3",$J,"TOTALS")),"^",6)
  1. I GTOTAL D
  1. . I 'STOP,'EXCEL D ; Print grand total if not Excel
  1. . . D TOTALG(LMAN,.HDRINFO,.PAGE,.STOP,.LCNT)
  1. . I 'EXCEL,'LMAN D ; Report finished
  1. . . W !,$$ENDORPRT^RCDPEARL,!
  1. . . D:'LMAN ASK^RCDPEFA1(.STOP,1)
  1. ;
  1. ; Null Report
  1. I 'GTOTAL,'LMAN D
  1. . I PAGE=0 D HDR(EXCEL,.HDRINFO,.PAGE)
  1. . W !!,?26,"*** No Records to Print ***",!
  1. . W !,$$ENDORPRT^RCDPEARL
  1. . S:'$D(ZTQUEUED) X=$$ASKSTOP^RCDPELAR
  1. ;
  1. ; List manager
  1. I LMAN D
  1. . S:LCNT=1 ^TMP("RCDPE_ADP3",$J,LCNT)=$J("",26)_"*** No Records to Print ***",LCNT=LCNT+1
  1. . S ^TMP("RCDPE_ADP3",$J,LCNT)=" ",LCNT=LCNT+1
  1. . S ^TMP("RCDPE_ADP3",$J,LCNT)=$$ENDORPRT^RCDPEARL
  1. ; Close device
  1. I '$D(ZTQUEUED) D ^%ZISC
  1. I $D(ZTQUEUED) S ZTREQ="@"
  1. Q
  1. ;
  1. LINE(DIV) ; List selected stations
  1. ; Input: DIV() - Array of selected divisions
  1. ; Returns: Comma delimited list of selected divisions
  1. N LINE,P,SUB
  1. S LINE="",SUB="",P=0
  1. F S SUB=$O(DIV(SUB)) Q:'SUB S P=P+1,$P(LINE,", ",P)=$G(DIV(SUB))
  1. Q LINE
  1. ;
  1. TOTALG(LMAN,HDRINFO,PAGE,STOP,LCNT) ;
  1. ; Input: LMAN - 1 if output to Listman, 0 otherwise
  1. ; HDRINFO - Array of header info
  1. ; PAGE - Current Page Number
  1. ; LCNT - Current line count (only passedif LMAN=1)
  1. ; Output: PAGE - Updated Page Number (if new header is displayed)
  1. ; LCNT - Updated line count (only passedif LMAN=1)
  1. N DATA,LN1,LN2
  1. S DATA=^TMP("RCDPEFADP3",$J,"TOTALS")
  1. S LN1=$$TOTALS("**** Totals for Date Range:",DATA)
  1. S LN2=$$PERCENTS(" Percent for Date Range:",DATA)
  1. ;
  1. I LMAN D Q
  1. . S ^TMP("RCDPE_ADP3",$J,LCNT)="",LCNT=LCNT+1
  1. . S ^TMP("RCDPE_ADP3",$J,LCNT)=LN1,LCNT=LCNT+1
  1. . S ^TMP("RCDPE_ADP3",$J,LCNT)=LN2,LCNT=LCNT+1
  1. ;
  1. I $Y>(IOSL-6) D
  1. . D ASK^RCDPEADP(.STOP,0)
  1. . Q:STOP
  1. . D HDR(EXCEL,.HDRINFO,.PAGE)
  1. Q:STOP
  1. W !!,LN1
  1. W !,LN2,!
  1. Q
  1. ;
  1. TOTALD(LMAN,HDRINFO,PAGE,STOP,DAY,LCNT) ; Totals for a single day
  1. ; Input: LMAN - 1 if output to List Template, 0 otherwise
  1. ; HDRINFO - Array of header information
  1. ; PAGE - Page Number
  1. ; DAY - FileMan date to display totals for
  1. ; LCNT - Current line count (only passedif LMAN=1)
  1. ; Output: PAGE - Updated Page Number (if a new header is displayed)
  1. ; STOP - 1 if user indiacted to stop
  1. ; LCNT - Updated line count (only passedif LMAN=1)
  1. N DAMT,DCNT,LN1,LN2,RCCOPAY,RCDT,Y
  1. S RCDT=$$FMTE^XLFDT(DAY,"2Z")
  1. S DATA=^TMP("RCDPEFADP3",$J,"TOTALS",DAY)
  1. S LN1=$$TOTALS(" **Totals for Date "_RCDT_":",DATA)
  1. S LN2=$$PERCENTS(" Percent for Date "_RCDT_":",DATA)
  1. ;
  1. I LMAN D Q
  1. . S ^TMP("RCDPE_ADP3",$J,LCNT)="",LCNT=LCNT+1
  1. . S ^TMP("RCDPE_ADP3",$J,LCNT)=LN1,LCNT=LCNT+1
  1. . S ^TMP("RCDPE_ADP3",$J,LCNT)=LN2,LCNT=LCNT+1
  1. . S ^TMP("RCDPE_ADP3",$J,LCNT)="",LCNT=LCNT+1
  1. ;
  1. I $Y>(IOSL-4) D
  1. . D ASK^RCDPEADP(.STOP,0)
  1. . Q:STOP
  1. . D HDR(EXCEL,.HDRINFO,.PAGE)
  1. Q:STOP
  1. W !!,LN1
  1. W !,LN2
  1. Q
  1. ;
  1. TOTALS(LABLE,DATA) ; Build Daily or Grand Total string
  1. ; Input: LABLE - Text to prepend to totals line
  1. ; DATA - Delimited totals data
  1. ; Returns: Line of text for output to report
  1. N Y
  1. S Y=LABLE
  1. S $E(Y,34)=$J($P(DATA,U,1),7,2) ; Copay AMOUNT
  1. S $E(Y,43)=$J($P(DATA,U,2),7,2) ; Auto-Decrease Amount
  1. S $E(Y,54)=$J($P(DATA,U,3),7,2) ; Manual Decrease Amount
  1. S $E(Y,66)=$J($P(DATA,U,4),7,2) ; Total Decrease Amount
  1. S $E(Y,76)=$J($P(DATA,U,5),5) ; Auto-release count
  1. Q Y
  1. ;
  1. PERCENTS(LABLE,DATA) ; Build Daily or Grand Total percentage line
  1. ; Input: LABLE - Text to prepend to totals line
  1. ; DATA - Delimited totals data
  1. ; Returns: Line of text for output to report
  1. N RCCOPAY,LN,Y
  1. S LN=LABLE
  1. S RCCOPAY=$P(DATA,U,1)
  1. S Y=$S(RCCOPAY>0:$P(DATA,U,2)/RCCOPAY*100,1:"")
  1. S $E(LN,44)=$$FMT(Y,2)
  1. S Y=$S(RCCOPAY>0:$P(DATA,U,3)/RCCOPAY*100,1:"")_"%"
  1. S $E(LN,55)=$$FMT(Y,2)
  1. S Y=$S(RCCOPAY>0:$P(DATA,U,4)/RCCOPAY*100,1:"")_"%"
  1. S $E(LN,67)=$$FMT(Y,2)
  1. S Y=$S($P(DATA,U,6):$P(DATA,U,5)/$P(DATA,U,6)*100,1:"")
  1. S $E(LN,77)=$$FMT(Y,0,4)
  1. Q LN
  1. ;
  1. FMT(VALUE,PLACES,JUST) ; Format a % value for output
  1. ; Input: VALUE - Value to be formated
  1. ; PLACES - Number of decimal places for number
  1. ; JUST - Length in which to $JUSTIFY (optional defaults to 7)
  1. ; Returns: Formated value
  1. N RETURN
  1. S RETURN=""
  1. I $G(JUST)="" S JUST=7
  1. I VALUE'="" D ;
  1. . I VALUE=0!(VALUE=100) S RETURN=$FN(VALUE,"",0)
  1. . E S RETURN=$FN(VALUE,"",PLACES)
  1. . S RETURN=RETURN_"%"
  1. Q $J(RETURN,JUST)
  1. ;
  1. HDR(EXCEL,HDRINFO,PAGE,NOLINE) ; Print the report header
  1. ; Input: EXCEL - 1 if output to Excel, 0 otherwise
  1. ; HDRINFO() - Array of Header information
  1. ; PAGE - Current Page Number
  1. ; NOLINE - 1 to not display Claim line header
  1. ; Optional, defaults to 0
  1. ; Output: PAGE - Updated Page Number (if EXCEL=0)
  1. N DIV,MSG,SUB,XX,Y,Z0,Z1
  1. S:'$D(NOLINE) NOLINE=0
  1. I EXCEL D Q
  1. . W !,"STATION^STATION NUMBER^COPAY BILL #^3RD PARTY BILL #^DATE^COPAY AMOUNT^AUTO-DECREASE AMOUNT^"
  1. . W "MANUAL DECREASE AMOUNT^TOTAL DECREASE AMOUNT^AUTO RELEASE HOLD"
  1. ;
  1. S PAGE=PAGE+1
  1. W @IOF
  1. S MSG(1)="First Party COPAY Manual vs Auto-Decrease Report"
  1. S MSG(1)=$J("",(80-$L(MSG(1))\2))_MSG(1)
  1. S MSG(1)=MSG(1)_" Page: "_PAGE
  1. S MSG(2)=" Run Date: "_HDRINFO("RUNDATE")
  1. S Z0="Divisions: "_HDRINFO("DIVISIONS")
  1. S MSG(3)=$S($L(Z0)<75:$J("",75-$L(Z0)\2),1:"")_Z0
  1. S XX=" (Date of Latest Decrease)"
  1. S MSG(4)=" Date Range: "_HDRINFO("START")_" - "_HDRINFO("END")_XX
  1. S MSG(5)=" "_HDRINFO("SORT")_" "_HDRINFO("DISP")
  1. I $G(DISP)="D" S MSG(6)=" 3rd Party Copay Auto-Decr Man Decr Total Decr Rel"
  1. E S MSG(6)=" Copay Auto-Decr Man Decr Total Decr Rel"
  1. I 'NOLINE D
  1. . I $G(DISP)="D" S MSG(7)="COPAY Bill # Bill# Date Amt Amt Amt Amt Hold"
  1. . E S MSG(7)=" Amt Amt Amt Amt Hold"
  1. . S MSG(8)=$TR($J("",80)," ","-")
  1. D EN^DDIOL(.MSG)
  1. Q
  1. ;