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

BARUFRPT.m

Go to the documentation of this file.
BARUFRPT ; IHS/SD/TPF - UFMS DS,NS, TRANSACTION REPORTS ;12/15/2008
 ;;1.8;IHS ACCOUNTS RECEIVABLE;**3,4,6,7,10,20,23**;OCT 26, 2005
 Q
 ;THIS ROUTINE IS CALLED BY
 ;BAR UFMS 'NOT SENT' REPORT
 ;AND BAR UFMS DELAYED SEND REPORT
 ;
NOTSENT(XREF) ;EP - XREF=1 "NS" PRINT NOT SENT, XREF=2 "DS" PRINT DELAYED SEND
 N TRDATE,LINE,NOW,DELDATE,DEBIT,CREDIT,BILL,BLLIEN,ENTRYBY,TPBIEN,TRANTYP,ADJCAT
 N REASON  ;BAR*1.8*4 SCR56,58 PER MEETING OF 11/14/2007
 S:$G(XREF)="" XREF=1
 S:XREF=1 XREF="NS"  ;[BAR UFMS 'NOT SENT' REPORT
 S:XREF=2 XREF="DS"  ;[BAR UFMS DELAYED SEND REPORT
 ;
ASKFROM ;EP - ASK FROM DATE
 K %DT
 S %DT="AET"
 S %DT("A")="Enter beginning transaction date: "
 W !
 D ^%DT
 Q:X=""!(X[U)
 I Y<0 W !,"INVALID DATE. TRY AGAIN!" H 2 G ASKFROM
 S BARFROM=Y
ASKTO ;EP - ASK TO DATE
 K %DT
 S %DT="AET"
 S %DT("A")="Enter ending transaction date: "
 W !
 D ^%DT
 G:X=""!(X[U) ASKFROM
 I Y<0 W !,"INVALID DATE. TRY AGAIN!" H 2 G ASKTO
 S BARTO=Y
 I BARTO<BARFROM W !!,"END DATE MUST BE GREATER THAN BEGINING DATE" H 2 G ASKFROM
 ;
ASKDEV ;EP - ASK DEVICE 
 S %ZIS="MQ"
 W !
 D ^%ZIS
 Q:POP
 I $D(IO("Q")) D QUE Q
 U IO
 D PRINT
 D ^%ZISC
 Q
QUE ; EP - QUE 'NOT SENT' OR 'DELAY SEND' REPORT
 S ZTRTN="PRINT^BARUFRPT"
 S ZTDESC=$S(XREF="NS":"NOT SENT ",1:"DELAYED SEND ")_"TRANSACTION REPORT"
 S ZTSAVE("XREF")=""
 S ZTSAVE("BARTO")=""
 S ZTSAVE("BARFROM")=""
 D ^%ZTLOAD
 I $D(ZTSK)[0 W !!?5,"Report Cancelled!"
 E  W !!?5,"Report task #: ",$G(ZTSK)
 D HOME^%ZIS
 Q
PRINT ;EP - ENTRY POINT FOR REPORT
 K BAR("CNT")  ;IHS/SD/SDR 1/25/08
 K BAR("AMT")  ;IHS/SD/SDR 1/25/08
 S $P(LINE,"-",81)=""
 D NOW^%DTC
 S Y=% X ^DD("DD") S NOW=Y
 S NOW=Y
 D NOTHDR(NOW)
 D NOTDET
 S ESC=0
 S BARTO=BARTO_"."_999999  ;IM??? FOUND DURING PATCH 4 TESTING
 S TRDATE=BARFROM-.000001
 F  S TRDATE=$O(^BARSESS(DUZ(2),XREF,TRDATE)) Q:'TRDATE!(ESC)!(TRDATE>BARTO)  D
 .S SESSID=$O(^BARSESS(DUZ(2),XREF,TRDATE,""))
 .S UDUZ=$O(^BARSESS(DUZ(2),XREF,TRDATE,SESSID,""))
 .S APPLYTO=$$GET1^DIQ(90057.110102,TRDATE_","_SESSID_","_UDUZ_",",.05)
 .I XREF="DS" D
 ..S BARFILE=$$GET1^DIQ(90057.110102,TRDATE_","_SESSID_","_UDUZ_",",.08,"E")
 ..;IHS_AR_RPMS_RCV_398_113510_20070702_1430
 ..S DELDATE=$P(BARFILE,"_",7)
 ..S DELDATE=$E(DELDATE,5,6)_"/"_$E(DELDATE,7,8)_"/"_$E(DELDATE,1,4)
 ..S DELTIME=$P($P(BARFILE,"_",8),".")
 ..S DELTIME=$E(DELTIME,1,2)_":"_$E(DELTIME,3,4)
 .S CREDIT=$$GET1^DIQ(90050.03,TRDATE_",",2)
 .S DEBIT=$$GET1^DIQ(90050.03,TRDATE_",",3)
 .S BILL=$$GET1^DIQ(90050.03,TRDATE_",",4)
 .S BLLIEN=$$GET1^DIQ(90050.03,TRDATE_",",4,"I")
 .S ENTRYBY=$$GET1^DIQ(90050.03,TRDATE_",",13,"E")
 .S TPBIEN=$$GET1^DIQ(90050.01,BLLIEN_",",17,"I")
 .S TRANTYP=$$GET1^DIQ(90050.03,TRDATE_",",101,"E")
 .S ADJCAT=$$GET1^DIQ(90050.03,TRDATE_",",102,"E")
 .S REASON=$$GET1^DIQ(90057.110102,TRDATE_","_SESSID_","_UDUZ_",",.09,"E")  ;BAR*1.8*4 SCR56,58 PER MEETING OF 11/14/2007
 .S CREDEB=$$GET1^DIQ(90050.03,TRDATE_",",3.5)
 .S:REASON="" REASON="NOT STATED"   ;MRS:BAR*1.8*6 IM29956
 .S BAR("CNT",REASON)=+$G(BAR("CNT",REASON))+1  ;cnt reasons IHS/SD/SDR 1/25/08
 .S BAR("AMT",REASON)=+$G(BAR("AMT",REASON))+CREDEB  ;cnt amt for reason IHS/SD/SDR 1/25/08
 .W !!,BILL
 .S Y=TRDATE X ^DD("DD") S EXDATE=Y
 .W ?18,EXDATE
 .W ?40,APPLYTO
 .W ?60,REASON  ; IHS/SD/PKD BAR*1.8*20 Tab further 12/21/10
 .W !?10,ENTRYBY
 .W ?30,$J(CREDIT,10,2)
 .W ?40,$J(DEBIT,10,2)
 .W ?52,$E(TRANTYP,1,15)
 .W ?70,$E(ADJCAT,1,10)
 .I XREF="DS" D
 ..W !!?10,"SENT ON "_DELDATE_" AT "_DELTIME
 ..W !?10,"IN FILE "_BARFILE
 .I $Y>(IOSL-4) W ! D:$D(IO("S")) NOTHDR(NOW),NOTDET Q:$D(IO("S"))  K DIR S DIR(0)="E" D:'$D(ZTQUEUED)&(IO=IO(0)) ^DIR S ESC=X=U Q:ESC  D NOTHDR(NOW),NOTDET
 ;start new IHS/SD/SDR 1/25/08
 S REASON=""
 W !!,"Count of entries in Not Sent bucket:"
 F  S REASON=$O(BAR("CNT",REASON)) Q:REASON=""  D
 . W !?5,"Error Code# ",REASON," had ",$P($G(BAR("CNT",REASON)),U)," entries for ",$J($G(BAR("AMT",REASON)),".",2)  ;MRS:BAR*1.8*7
 I '$D(ZTQUEUED)&(IO=IO(0)) D
 . K DIR
 . S DIR(0)="E"
 . W !
 . D ^DIR
 W @IOF
 Q:ESC!$D(IO("S"))
 I '$D(ZTQUEUED)&(IO=IO(0)) D
 .K DIR
 .S DIR(0)="E"
 .W !
 .D ^DIR
 Q
 ;
NOTDET ;EP -
 W !!?3,"A/R BILL"
 W ?18,"TRAN. DATE"
 W ?40,"APPLY TO"
 W ?52,"REASON NOT SENT"  ;BAR*1.8*4 SCR56,58 PER MEETING OF 11/14/2007
 W !?10,"ENTRY BY"
 W ?35,"CREDIT"
 W ?45,"DEBIT"
 W ?52,"TRANTYPE"
 W ?70,"ADJCAT"
 W !,LINE
 Q
 ;
NOTHDR(DATE) ;EP -
 W @IOF
 ;W !,$$CJ^XLFSTR("TRANSACTIONS "_$S(XREF="NS":"NOT SENT",1:"SENT BUT DELAYED")_" BECAUSE THE 3P BILL "_$S(XREF="NS":"HAS",1:"HAD")_" NOT BEEN SENT",IOM)
 W !,$$CJ^XLFSTR("TRANSACTIONS "_$S(XREF="NS":"NOT SENT",1:"SENT BUT DELAYED"),IOM)
 W !,$$CJ^XLFSTR("REPORT DATE: "_DATE,IOM)
 W !,$$CJ^XLFSTR("PRINTED BY : "_$P($G(^VA(200,DUZ,0)),U),IOM)
 W !
 Q
 ;
TRANSRPT ; EP - REPORT OF TRANS SENT TO IE SORTED BY ?
 N ARTRAN,UDUZ,SESSID,LINE,DASH,LINE2
 S $P(DASH,"-",81)=""
ASKFR ;EP - ASK FROM DATE
 K DIR
 S DIR(0)="DO^::EXT"
 S DIR("A")="From Transaction Date"
 D ^DIR
 Q:$D(DTOUT)!$D(DUOUT)!$D(DIROUT)!(Y="")
 S FROM=Y
 S Y=FROM X ^DD("DD") S EXFROM=Y
ASKENDY ;EP - ASK TO DATE
 K DIR
 S DIR(0)="DO^::EXT"
 S DIR("A")="To Transaction Date"
 D ^DIR
 G:$D(DTOUT)!$D(DUOUT)!$D(DIROUT)!(Y="") ASKFR
 S TO=Y
 I TO<FROM W !,"BEGIN DATE CAN NOT BE GREATER THAN END DATE!" H 3 G ASKFR
 S Y=TO X ^DD("DD") S EXTO=Y
 D NOW^%DTC
 S Y=% X ^DD("DD") S NOW=Y
 S NOW=Y
 S ESC=0
 D TRANHDR(NOW)
 D TRANDET
 S UDUZ=0
 F  S UDUZ=$O(^BARSESS(DUZ(2),UDUZ)) Q:'UDUZ!(ESC)  D
 .W !,$E($P($G(^VA(200,UDUZ,0)),U),1,15)
 .S SESSID=0
 .F LINE=1:1 S SESSID=$O(^BARSESS(DUZ(2),UDUZ,11,SESSID)) Q:'SESSID!(ESC)  D
 ..S Y=SESSID X ^DD("DD") S EXSESSID=Y
 ..W:LINE'=1 !
 ..W ?18,EXSESSID
 ..S ARTRAN=FROM-.000001
 ..F LINE2=1:1 S ARTRAN=$O(^BARSESS(DUZ(2),UDUZ,11,SESSID,2,ARTRAN)) Q:'ARTRAN!(ARTRAN>TO)!(ESC)  D
 ...W:LINE2'=1 !
 ...W ?40,ARTRAN
 ...W:LINE2'=1&('$O(^BARSESS(DUZ(2),UDUZ,11,SESSID,2,ARTRAN))) !
 ...I $Y>(IOSL-4) W ! K DIR S DIR(0)="E" D:'$D(ZTQUEUED)&(IO=IO(0)&'$D(IO("S"))) ^DIR S ESC=X=U Q:ESC  D TRANHDR(NOW),TRANDET
 Q:ESC!$D(IO("S"))
 I '$D(ZTQUEUED) D
 .K DIR
 .S DIR(0)="E"
 .W !
 .D ^DIR
 Q
TRANHDR(DATE) ;EP -
 W @IOF
 W !,$$CJ^XLFSTR("TRANSACTION REPORT",IOM)
 W !,$$CJ^XLFSTR("REPORT DATE: "_DATE,IOM)
 W !,$$CJ^XLFSTR("PRINTED BY : "_$P($G(^VA(200,DUZ,0)),U),IOM)
 W !,$$CJ^XLFSTR("DATE RANGE FROM : "_EXFROM_" TO "_EXTO,IOM)
 Q
TRANDET ;EP -
 W !!!,"CASHIER"
 W ?18,"SESSION ID"
 W ?40,"TRANSACTION DATE/TIME"
 W !,DASH
 Q
 ;
BATCH ;EP - BATCH REPORT
 N START,END,EXSTART,EXEND,DASH
 S $P(DASH,"-",81)=""
ASKSTART ;EP -
 N LIMIT
 S LIMIT=$$GETDISLM^BARUFUT1("I")
 K DIR
 S DIR(0)="DO^::EXT"
 S DIR("?",1)="Enter a beginning date range for listing files."
 S DIR("?",2)="A file can be identified by the date/time the session or sessions"
 S DIR("?",3)="were sent or transmitted. Since several sessions can be sent"
 S DIR("?",4)="at the same time they are grouped by the transmission date/time"
 S DIR("?",5)="This date/time can identify the file, e.g. 3071001.120101"
 S DIR("A")="Select beginning export file date"
 W !!
 D ^DIR
 Q:$D(DIRUT)!$D(DUOUT)!$D(DTOUT)!(Y="")
 S START=Y
ASKEND ;EP -
 K DIR
 S DIR(0)="DO^::EXT"
 S DIR("A")="Select ending export file date"
 W !!
 D ^DIR
 G:$D(DIRUT)!$D(DUOUT)!$D(DTOUT)!(Y=0) ASKSTART
 S END=Y
 ;
 I END<START W !,"End date cannot become before the Beginning Date" H 2 G ASKSTART
 ;
ASKTYP ;EP -
 K DIR
 S DIR(0)="S^SS:FILE TOTALS BY SESSION;SC:FILE TOTALS BY CASHIER;SF:FILE TOTALS"
 S DIR(0)=DIR(0)_";D:DETAIL;F:FILE DATE & FILE NAMES"
 S DIR(0)=DIR(0)_";G:GRAND TOTAL ALL FILES BY TRANSMISSION DATE"
 S DIR("B")="GRAND TOTAL ALL FILES BY TRANSMISSION DATE"
 D ^DIR
 G:$D(DIRUT)!$D(DTOUT)!$D(DUOUT)!(Y="") ASKEND
 D ASKDEV^BARUFRP1(START,END,Y)
 I '$G(ESC) D
 .K DIR
 .S DIR(0)="E"
 .D ^DIR
 D ^BARBAN
 G BATCH
 Q
 ;
BATHDR(DATE,RPTTYP) ;EP -
 S PAGE=$G(PAGE)+1
 W @IOF
 S X=$S(RPTTYP="D":"DETAIL",RPTTYP="G":"GRAND TOTAL ALL FILES",RPTTYP="SS":"FILE TOTALS BY SESSION",RPTTYP="SC":"FILE TOTALS BY CASHIER",RPTTYP="SF":"FILE TOTALS",1:"")_" REPORT"
 I RPTTYP="F" S X="FILE DATES & FILE NAME REPORT"
 S X=$J("",IOM-$L(X)\2-$X)_X
 W !,X
 W ?70,"PAGE ",PAGE
 W !,$$CJ^XLFSTR("REPORT DATE: "_DATE,IOM)
 W !,$$CJ^XLFSTR("PRINTED BY : "_$P($G(^VA(200,DUZ,0)),U),IOM)
 W !,$$CJ^XLFSTR("DATE RANGE FROM : "_EXSTART_" TO "_EXEND,IOM)
 I PAGE>1 W !,DASH Q  ;ONLY PRINT LIST ONCE ;MRS:BAR*1.8*10 H1087
 ;start new BARLOC
 I RPTTYP="G" D
 .;N BARST,BARHEND,UDUZ,BARSESID,BARREC,IENS,BARFILEN  ;MRS:BAR*1.8*10 H1197
 .N BARST,BARHEND,UDUZ,BARSESID,BARREC,IENS,BARFILEN,BARSESXM  ;PKD:BAR*1.8*20 H13149
 .K BARFLST  ;IHS/SD/SDR 8/8/08
 .S BARHEND=$S(END'[("."):END_".999999",1:END)
 .S BARST=START-.000001
 .F  S BARST=$O(^BARSESS(DUZ(2),"F",BARST)) Q:'BARST!(ESC)!(BARST>BARHEND)  D
 ..S UDUZ=""
 ..F  S UDUZ=$O(^BARSESS(DUZ(2),"F",BARST,UDUZ)) Q:'UDUZ!(ESC)  D
 ...S BARSESID=""
 ...F  S BARSESID=$O(^BARSESS(DUZ(2),"F",BARST,UDUZ,BARSESID)) Q:'BARSESID!(ESC)  D
 ....S BARREC=0
 ....F  S BARREC=$O(^BARSESS(DUZ(2),UDUZ,11,BARSESID,21,BARREC)) Q:'BARREC!(ESC)  D
 .....S IENS=BARREC_","_BARSESID_","_UDUZ_","
 ..... ; IHS/SD/PKD 11/26/10 1.8*20 HEAT 13149
 ..... ; Exclude Date on Header if EXPORT date.time is outside range 
 .....S BARSESXM=$$GET1^DIQ(90057.210101,IENS,.01,"I")
 .....S BARFILEN=$$GET1^DIQ(90057.210101,IENS,.02,"E")
 .....Q:BARFILEN=""!(BARSESXM>BARHEND)!(BARSESXM<START)
 .....; End H13149
 .....S BARFLST(BARFILEN)=""
 .S BARFILEN=""
 .;Begin modifications ;MRS:BAR*1.8*10 H1197
 .;F  S BARFILEN=$O(BARFLST(BARFILEN)) Q:BARFILEN=""  W !,$$CJ^XLFSTR("FILE: "_BARFILEN,IOM)
 .F  S BARFILEN=$O(BARFLST(BARFILEN)) Q:BARFILEN=""  D  Q:$G(ESC)
 ..W !,$$CJ^XLFSTR("FILE: "_BARFILEN,IOM)
 ..I $Y>(IOSL-4) D EOP^BARUTL(1) S ESC=$G(DIRUT)=U W @IOF
 ;end new BARLOC;MRS:BAR*1.8*10 H1197
 W !,DASH
 Q
BATDET(BATCH) ;EP - 
 W !?3,"A/R BILL"
 W ?25,"TRANSACTION DATE/TIME"
 W !?10,"CASHIER"
 W ?35,"CREDIT - DEBIT"
 W ?52,"TRAN TYPE"
 W ?70,"ADJ CAT"
 W !,DASH
 W:$G(BATCH)'="" !,"BATCH: ",BATCH
 Q
SUMINIT ;EP - SUMMARY INITIALIZE COUNTERS
 N BARCAT,BARALLC,BARTYP  ;MRS:BAR*1.8*10 IM30577
 F BARCAT="ADJ","AAA PAYMENT","ZZZ REFUND","RRR RCODE","AAZERO","ADJZERO" D
 .F BARALLC="MEDICARE","MEDICAID","PRIVATE INSURANCE","OTHER","VETERAN" D  ;P.OTT
 ..F BARTYP="ALL","NS","TR","DS","ZP","ZA" D
 ...S TOTALS(BARCAT,BARALLC,BARTYP,"CNT")=0
 ...S TOTALS(BARCAT,BARALLC,BARTYP)=0
 Q
 ;
COUNT(TOTALS) ;EP - INCREMENT COUNTERS
 I TRANTYP="PAYMENT",(AMT=0) S CAT="AAZERO" D TOT(CAT,AMT,.TOTALS)
 I TRANTYP="PAYMENT" S CAT="AAA "_TRANTYP D TOT(CAT,AMT,.TOTALS) Q
 I TRANTYP="REFUND" S CAT="ZZZ "_TRANTYP D TOT(CAT,AMT,.TOTALS) Q
 I TRANTYP["ADJUST",(AMT=0) S CAT="ADJZERO" D TOT(CAT,AMT,.TOTALS)
 I TRANTYP="" S CAT="ADJ" D TOT(CAT,AMT,.TOTALS) Q
 I TRANTYP="REMARK CODE" S CAT="RRR RCODE" D TOT(CAT,AMT,.TOTALS) Q
 S CAT="ADJ" D TOT(CAT,AMT,.TOTALS) Q
 Q
 ;
TOT(CAT,AMT,TOTALS) ;
 D TOT^BARUFRP3  ;split due to routine size
 Q
 ;
LIST(TOTALS) ;EP - DISPLAY CALCULATED TOTALS
 N CATEGORY,ADJCAT,ADJCNT,ADJAMT
 S (CATEGORY,SUBHDR)=""
 ;start new BARLOC
 D SETVAR^BARUFRP3  ;set up vars for printing
 F  S CATEGORY=$O(TOTALS(CATEGORY)) Q:CATEGORY=""  D
 .I $P(CATEGORY," ")'=SUBHDR D
 ..W !!?2,"Cashiering Function"
 ..W !,?3,"- "_$S($P(CATEGORY," ")="AAA":"Payments",$P(CATEGORY," ")="ZZZ":"Refunds",$P(CATEGORY," ")="RRR":"Remark Codes",CATEGORY="AAZERO":"Zero Pay",CATEGORY="ADJZERO":"Zero Adjustments",1:"Adjustments")
 .S BARALLC=""
 .F  S BARALLC=$O(TOTALS(CATEGORY,BARALLC)) Q:BARALLC=""  D
 ..I $P(CATEGORY," ",2)="PAYMENT" D
 ...S BARAPCNT=BARAPCNT+TOTALS(CATEGORY,BARALLC,"ALL","CNT")
 ...S BARAPAMT=BARAPAMT+TOTALS(CATEGORY,BARALLC,"ALL")
 ...I $G(TOTALS(CATEGORY,BARALLC,"DS","CNT"))'="" D
 ....S BARDPCNT=BARDPCNT+TOTALS(CATEGORY,BARALLC,"DS","CNT")
 ....S BARDPAMT=BARDPAMT+TOTALS(CATEGORY,BARALLC,"DS")
 ...I $G(TOTALS(CATEGORY,BARALLC,"NS","CNT"))'="" D
 ....S BARNPCNT=BARNPCNT+TOTALS(CATEGORY,BARALLC,"NS","CNT")
 ....S BARNPAMT=BARNPAMT+TOTALS(CATEGORY,BARALLC,"NS")
 ...I $G(TOTALS(CATEGORY,BARALLC,"TR","CNT"))'="" D
 ....S BARTPCNT=BARTPCNT+TOTALS(CATEGORY,BARALLC,"TR","CNT")
 ....S BARTPAMT=BARTPAMT+TOTALS(CATEGORY,BARALLC,"TR")
 ..I CATEGORY="AAZERO" D
 ...I $G(TOTALS(CATEGORY,BARALLC,"ZP","CNT"))'="" D
 ....S BARZPCNT=BARZPCNT+TOTALS(CATEGORY,BARALLC,"ZP","CNT")
 ....S BARZPAMT=BARZPAMT+TOTALS(CATEGORY,BARALLC,"ZP")
 ..I CATEGORY="ADJZERO" D
 ...I $G(TOTALS(CATEGORY,BARALLC,"ZA","CNT"))'="" D
 ....S BARZACNT=BARZACNT+TOTALS(CATEGORY,BARALLC,"ZA","CNT")
 ....S BARZAAMT=BARZAAMT+TOTALS(CATEGORY,BARALLC,"ZA")
 ..I $P(CATEGORY," ")="ADJ" D
 ...S ADJACNT=ADJACNT+TOTALS(CATEGORY,BARALLC,"ALL","CNT")
 ...S ADJAAMT=ADJAAMT+TOTALS(CATEGORY,BARALLC,"ALL")
 ...I $G(TOTALS(CATEGORY,BARALLC,"NS","CNT"))'="" D
 ....S ADJNCNT=ADJNCNT+TOTALS(CATEGORY,BARALLC,"NS","CNT")
 ....S ADJNAMT=ADJNAMT+TOTALS(CATEGORY,BARALLC,"NS")
 ...I $G(TOTALS(CATEGORY,BARALLC,"TR","CNT"))'="" D
 ....S ADJTCNT=ADJTCNT+TOTALS(CATEGORY,BARALLC,"TR","CNT")
 ....S ADJTAMT=ADJTAMT+TOTALS(CATEGORY,BARALLC,"TR")
 ..I $P(CATEGORY," ",2)="REFUND" D
 ...S REFACNT=REFACNT+TOTALS(CATEGORY,BARALLC,"ALL","CNT")
 ...S REFAAMT=REFAAMT+TOTALS(CATEGORY,BARALLC,"ALL")
 ...I $G(TOTALS(CATEGORY,BARALLC,"NS","CNT"))'="" D
 ....S REFNCNT=REFNCNT+TOTALS(CATEGORY,BARALLC,"NS","CNT")
 ....S REFNAMT=REFNAMT+TOTALS(CATEGORY,BARALLC,"NS")
 ...I $G(TOTALS(CATEGORY,BARALLC,"TR","CNT"))'="" D
 ....S REFTCNT=REFTCNT+TOTALS(CATEGORY,BARALLC,"TR","CNT")
 ....S REFTAMT=REFTAMT+TOTALS(CATEGORY,BARALLC,"TR")
 ..I $P(CATEGORY," ",2)="RCODE" D
 ...S BARRCCNT=BARRCCNT+TOTALS(CATEGORY,BARALLC,"ALL","CNT")
 ...S BARRCAMT=BARRCAMT+TOTALS(CATEGORY,BARALLC,"ALL")
 ...I $G(TOTALS(CATEGORY,BARALLC,"NS","CNT"))'="" D
 ....S BARCNCNT=BARCNCNT+TOTALS(CATEGORY,BARALLC,"NS","CNT")
 ....S BARCNAMT=BARCNAMT+TOTALS(CATEGORY,BARALLC,"NS")
 ...I $G(TOTALS(CATEGORY,BARALLC,"TR","CNT"))'="" D
 ....S BARCTCNT=BARCTCNT+TOTALS(CATEGORY,BARALLC,"TR","CNT")
 ....S BARCTAMT=BARCTAMT+TOTALS(CATEGORY,BARALLC,"TR")
 ..S SUBHDR=$P(CATEGORY," ")
 ..D WRITEDET^BARUFRP3
 .D WRITETOT^BARUFRP3
 W !?46,"TOTALS SENT: ",$J(BARTPCNT+ADJTCNT-BARZPCNT,6),?66,"$"_$J((BARTPAMT-ADJTAMT-REFTAMT),10,2)
 W !
 Q