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

IBCNOR2.m

Go to the documentation of this file.
  1. IBCNOR2 ;AITC/TAZ - IBCN BUFFER DAILY REPORT ;15-AUG-2023
  1. ;;2.0;INTEGRATED BILLING;**771,778,794**;21-MAR-94;Build 9
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ;IB*794/DTG corrected date in line two from 16-SEP-09 to 21-MAR-94
  1. ;
  1. ; Variables:
  1. ; IBCNSPC("IBOUT") = "R" for Report format or "E" for Excel format
  1. ; IBCNSPC("TYPE") = report type: "S" - summary, "D" - detailed
  1. ;
  1. Q
  1. ;
  1. DBR ; Send Daily Buffer Report Email
  1. N LOCALTIME,CURRTIME,MTIME,MSG,MGRP
  1. N ZTRTN,ZTDESC,ZTDTH,ZTIO,ZTUCI,ZTCPU,ZTPRI,ZTSAVE,ZTKIL,ZTSYNC,ZTSK
  1. ;
  1. I $$GET1^DIQ(350.9,"1,",54.02,"E")="" G DBRX ;No email address to receive the report.
  1. ;
  1. S LOCALTIME=$$GET1^DIQ(350.9,"1,",51.03,"I")
  1. I 'LOCALTIME G DBRX ; MM message time is not defined
  1. ;
  1. S CURRTIME=$P($H,",",2) ; current $H time
  1. S MTIME=DT_"."_LOCALTIME ; build a FileMan date/time
  1. S MTIME=$$FMTH^XLFDT(MTIME) ; convert to $H format
  1. S MTIME=$P(MTIME,",",2) ; $H time of MM message
  1. ;
  1. ; If the current time is after the MailMan message time, then schedule the message for tomorrow at that time.
  1. ; Otherwise, schedule it for later today.
  1. S ZTDTH=$S(CURRTIME>MTIME:$H+1,1:+$H)_","_MTIME
  1. ;
  1. ; Set up the other TaskManager variables
  1. S ZTRTN="EMAIL^IBCNOR2"
  1. S ZTDESC="Daily Buffer Report Message"
  1. S ZTIO=""
  1. D ^%ZTLOAD ; Call TaskManager
  1. ;
  1. DBRX ; Exit
  1. Q
  1. ;
  1. EMAIL ;Email a summary version of the report to a select email group
  1. N EMAIL,IBOUT,MSG,SITE,TYPE,XMSUBJ,XMTO
  1. S EMAIL=$$GET1^DIQ(350.9,"1,",54.02,"E") I EMAIL="" G EMAILX
  1. K ^TMP($J,"IBCNOR2")
  1. S IBOUT="R",TYPE="S"
  1. ;
  1. D SNAPSHOT I $G(ZTSTOP) G PROCESSX
  1. ;
  1. D PRINT
  1. ;
  1. S SITE=$$SITE^VASITE
  1. S XMSUBJ=$P(SITE,U,2)_" (#"_$P(SITE,U,3)_") Daily Buffer Report"
  1. S XMTO(EMAIL)=""
  1. D MSG^IBCNEUT5(,XMSUBJ,"MSG(",,.XMTO) ; Send a MailMan Message
  1. ;
  1. EMAILX ; Exit
  1. Q
  1. ;
  1. EN ; entry point
  1. N IBCNSPC,STOP,TYPE
  1. ;
  1. S STOP=0
  1. W @IOF
  1. W !,"This report displays data from the Process Insurance Buffer option, otherwise"
  1. W !,"known as ""the Buffer"". It is real time data that is constantly changing;"
  1. W !,"therefore, the numbers and dates reflected in this report are never the same"
  1. W !,"minute to minute, hour by hour, or day by day. This report output is only"
  1. W !,"accurate to the exact date and time it is produced. The Insurance Company"
  1. W !,"section of this report is based on free text fields and may not be reflective"
  1. W !,"of actual category counts due to spelling errors in the free text Insurance"
  1. W !,"Company field."
  1. ;
  1. ; Report Type - Summary or Detailed
  1. TYPE ;Type of Report
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
  1. W !
  1. S DIR(0)="SA^S:Summary;D:Detailed"
  1. S DIR("A")="Run a (S)ummary or (D)etailed Report: "
  1. S DIR("B")="Summary"
  1. D ^DIR
  1. I $D(DIRUT)!$D(DIRUT)!$D(DTOUT)!$D(DUOUT) G EXIT
  1. S (TYPE,IBCNSPC("TYPE"))=Y
  1. ;
  1. IBOUT ;
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
  1. W !
  1. S DIR(0)="SA^E:Excel;R:Report"
  1. S DIR("A")="(E)xcel Format or (R)eport Format: "
  1. S DIR("B")="Report"
  1. D ^DIR
  1. I $D(DIRUT)!$D(DIRUT)!$D(DTOUT)!$D(DUOUT) G EXIT
  1. S IBCNSPC("IBOUT")=Y
  1. I Y="E" D
  1. . W !!,"For CSV output, turn logging or capture on now. To avoid undesired wrapping"
  1. . W !,"of the data saved to the file, please enter "_$S(TYPE="S":"0;132;99999",1:"0;80;99999")_" at the ""DEVICE:"""
  1. . W !,"prompt.",!
  1. ;
  1. ; Select the output device
  1. DEVICE ; Device Handler and possible TaskManager calls
  1. ;
  1. ; Output params:
  1. ; STOP = Flag to stop routine
  1. ;
  1. ; Init vars
  1. N POP,ZTDESC,ZTRTN,ZTSAVE
  1. ;
  1. S ZTRTN="PROCESS^IBCNOR2(.IBCNSPC)"
  1. S ZTDESC="IBCN Daily Buffer Report"
  1. S ZTSAVE("IBCNSPC(")=""
  1. D EN^XUTMDEVQ(ZTRTN,ZTDESC,.ZTSAVE,"QM",1)
  1. ;
  1. EXIT ;
  1. Q
  1. ;
  1. PROCESS(IBCNSPC) ;
  1. ; Entry point called from EN^XUTMDEVQ in either direct or queued mode.
  1. ; Input params:
  1. ; IBCNSPC = Array passed by ref of the report params
  1. ;
  1. ; Init scratch globals
  1. N CRT,DATE,IBOUT,TYPE,ZTQUEUED,ZTREQ,ZTSTOP
  1. K ^TMP($J,"IBCNOR2")
  1. S IBOUT=$G(IBCNSPC("IBOUT"))
  1. S TYPE=$G(IBCNSPC("TYPE"))
  1. I IOST["C-" S CRT=1
  1. ;
  1. D SNAPSHOT I $G(ZTSTOP) G PROCESSX
  1. ;
  1. ;
  1. I TYPE="D" D I $G(ZTSTOP) G PROCESSX
  1. . D INIT I $G(ZTSTOP) Q
  1. . D COMPILE I $G(ZTSTOP) Q
  1. ;
  1. D PRINT
  1. ;
  1. PROCESSX ; exit
  1. ; Kill scratch globals
  1. K ^TMP($J,"IBCNOR2")
  1. ;
  1. ; Purge task record
  1. I $D(ZTQUEUED) S ZTREQ="@"
  1. Q
  1. ;
  1. SNAPSHOT ;Grab a snapshot of the data right now.
  1. N BACKLOG,BCNT,CNT,DATE,IEN,OLDEST,WBACKLOG,WCNT
  1. S BACKLOG=$$BACKLOG(DT,0)
  1. S WBACKLOG=$$BACKLOG($$FMADD^XLFDT(DT,-7),1)
  1. S DATE="",(BCNT,CNT,WCNT)=0,CRT=+$G(CRT)
  1. I CRT W !,"Building Snapshot..."
  1. F S DATE=$O(^IBA(355.33,"AEST","E",DATE)) Q:'DATE D
  1. . ;I CNT<1 S ^TMP($J,"IBCNOR2","SUM","OLDEST DATE")=DATE ;IB*778/DTG moved to avoid bad records.
  1. . ;
  1. . S IEN=""
  1. . F S IEN=$O(^IBA(355.33,"AEST","E",DATE,IEN)) Q:'IEN D
  1. .. ;
  1. .. I '$D(^IBA(355.33,IEN,0)) Q ; IB*778/DTG if node 0 for IEN not there, go back
  1. .. I CNT<1 S ^TMP($J,"IBCNOR2","SUM","OLDEST DATE")=DATE ;IB*778
  1. .. ;
  1. .. N IBARY,IBY,IENS,DFN
  1. .. S IENS=IEN_",",CNT=CNT+1 I CRT,'(CNT#100) W "."
  1. .. I DATE<BACKLOG S BCNT=BCNT+1
  1. .. I DATE<WBACKLOG S WCNT=WCNT+1
  1. .. D GETS^DIQ(355.33,IENS,".01;.03;.04;20.01;60.01","EI","IBARY")
  1. .. M ^TMP($J,"IBCNOR2","DATA")=IBARY(355.33)
  1. .. S DFN=IBARY(355.33,IENS,60.01,"I")
  1. .. S IBY="" D FLAGS^IBCNBLL(DFN,.IBY)
  1. .. S ^TMP($J,"IBCNOR2","DATA",IENS,"FLAGS")=$TR(IBY," ")
  1. S ^TMP($J,"IBCNOR2","SUM","TOTAL ENTRIES")=CNT
  1. S ^TMP($J,"IBCNOR2","SUM","BACKLOG")=BCNT
  1. S ^TMP($J,"IBCNOR2","SUM","WBACKLOG")=WCNT
  1. ;
  1. ; IB*778/DTG change for oldest date check
  1. ; S OLDEST=$G(^TMP($J,"IBCNOR2","SUM","OLDEST DATE")) S ^TMP($J,"IBCNOR2","SUM","AGE")=$S(OLDEST:$$FMDIFF^XLFDT(DT,OLDEST),1:0)
  1. S OLDEST=$S(CNT<1:"",1:$G(^TMP($J,"IBCNOR2","SUM","OLDEST DATE")))
  1. S ^TMP($J,"IBCNOR2","SUM","AGE")=$S(OLDEST:$$FMDIFF^XLFDT(DT,OLDEST),1:0)
  1. ;
  1. Q
  1. ;
  1. BACKLOG(DATE,WED) ;Calculate Backlog Date to T-6 business days so that T-7 inclusive shows on the report.
  1. N BACKLOG,DOW
  1. S DOW=$E($$DOW^XLFDT(DATE),1,2)
  1. I DOW="Su" S BACKLOG=$$FMADD^XLFDT(DATE,$S(WED:+4,1:-10)) G BACKLOGX
  1. I DOW="Mo" S BACKLOG=$$FMADD^XLFDT(DATE,$S(WED:+3,1:-10)) G BACKLOGX
  1. I DOW="Tu" S BACKLOG=$$FMADD^XLFDT(DATE,$S(WED:+2,1:-8)) G BACKLOGX
  1. I DOW="We" S BACKLOG=$$FMADD^XLFDT(DATE,$S(WED:+1,1:-8)) G BACKLOGX
  1. I DOW="Th" S BACKLOG=$$FMADD^XLFDT(DATE,$S(WED:-0,1:-8)) G BACKLOGX
  1. I DOW="Fr" S BACKLOG=$$FMADD^XLFDT(DATE,$S(WED:-1,1:-8)) G BACKLOGX
  1. I DOW="Sa" S BACKLOG=$$FMADD^XLFDT(DATE,$S(WED:-2,1:-9)) G BACKLOGX
  1. BACKLOGX ;Exit Backlog Date calculation
  1. Q BACKLOG
  1. ;
  1. INIT ;Initialize the ^TMP global
  1. ;Initialize the Report Global Array
  1. N CAT,CATS,LINE,PCE
  1. F LINE=1:1 S CATS=$P($T(CATNDT+LINE),";;",2) Q:CATS="" D
  1. . F PCE=1:1 S CAT=$P(CATS,U,PCE) Q:CAT="" D
  1. .. S ^TMP($J,"IBCNOR2","DET",CAT)=0
  1. F LINE=1:1 S CATS=$P($T(CATWDT+LINE),";;",2) Q:CATS="" D
  1. . F PCE=1:1 S CAT=$P(CATS,U,PCE) Q:CAT="" D
  1. .. S ^TMP($J,"IBCNOR2","DET",CAT)=0
  1. .. S ^TMP($J,"IBCNOR2","DET",CAT,"DATE")=""
  1. .. I CAT'="MEDICARE" Q
  1. F LINE=1:1 S CATS=$P($T(TOTALS+LINE),";;",2) Q:CATS="" D
  1. . F PCE=1:1 S CAT=$P(CATS,U,PCE) Q:CAT="" D
  1. .. S ^TMP($J,"IBCNOR2","TOT",CAT)=0
  1. ;
  1. INITX ;Exit
  1. Q
  1. ;
  1. COMPILE ; Compile the report
  1. N CNT,IEN,INSCO,TOT
  1. S (CNT,IEN)=0
  1. I CRT W !,"Compiling Data..."
  1. F CNT=1:1 S IEN=$O(^TMP($J,"IBCNOR2","DATA",IEN)) Q:'IEN D
  1. . I CRT,'(CNT#100) W "."
  1. . N ARRAY
  1. . M ARRAY=^TMP($J,"IBCNOR2","DATA",IEN)
  1. . D UPDATE("TOT","MCCF vs. non-MCCF")
  1. . S INSCO=$$UP^XLFSTR($G(ARRAY(20.01,"E")))
  1. . D ;Process Insurance Company
  1. .. D UPDATE("TOT","Insurance Company Category")
  1. .. I INSCO["TRICARE" D UPDATE("DET","TRICARE"),UPDATE("DET","Non-MCCF") Q
  1. .. I INSCO["CHAMPVA" D UPDATE("DET","CHAMPVA"),UPDATE("DET","Non-MCCF") Q
  1. .. D UPDATE("DET","MCCF")
  1. .. I INSCO["MEDICARE" D Q
  1. ... D UPDATE("DET","MEDICARE")
  1. ... I INSCO="MEDICARE PART D (WNR)" D UPDATE("DET","MEDICARE PART D (WNR)")
  1. .. I INSCO="NO INSURANCE" D UPDATE("DET","NO INSURANCE") Q
  1. .. I INSCO="PATIENT REFUSED" D UPDATE("DET","PATIENT REFUSED") Q
  1. .. I INSCO="CMS MBI ONLY" D UPDATE("DET","CMS MBI ONLY") Q
  1. .. D UPDATE("DET","ALL OTHER")
  1. . D ;Process Patient Status
  1. .. D UPDATE("TOT","Patient Status")
  1. .. N FLAG,FLAGS,POS
  1. .. S FLAGS=$G(ARRAY("FLAGS"))
  1. .. I FLAGS="" D UPDATE("DET","blank")
  1. .. F POS=1:1:$L(FLAGS) S FLAG=$E(FLAGS,POS) D
  1. ... I FLAG="i" D UPDATE("DET","i ACTIVE INSURANCE") Q
  1. ... I FLAG="I" D UPDATE("DET","I INPATIENT") Q
  1. ... I FLAG="E" D UPDATE("DET","E DECEASED") Q
  1. ... I FLAG="Y" D UPDATE("DET","Y COPAY REQUIRED") Q
  1. ... I FLAG="H" D UPDATE("DET","H CHARGES ON HOLD") Q
  1. . D ;Process Source of Informtion
  1. .. D UPDATE("TOT","Source of Information")
  1. .. N SOI
  1. .. S SOI=$G(ARRAY(.03,"E"))
  1. .. I '$D(^TMP($J,"IBCNOR2","SOI",SOI)) D
  1. ... S ^TMP($J,"IBCNOR2","SOI",SOI)=0
  1. ... S ^TMP($J,"IBCNOR2","SOI",SOI,"DATE")=""
  1. .. D UPDATE("SOI",SOI) Q
  1. ;
  1. COMPILEX ; Exit Compile
  1. Q
  1. ;
  1. UPDATE(LVL,NODE) ;Increase a node
  1. N TOT
  1. I LVL="" G UPDATEX
  1. I NODE="" G UPDATEX
  1. S TOT=^TMP($J,"IBCNOR2",LVL,NODE)+1,^TMP($J,"IBCNOR2",LVL,NODE)=TOT
  1. D OLDDATE(LVL,NODE,ARRAY(.01,"I"))
  1. UPDATEX ;Exit
  1. Q
  1. ;
  1. OLDDATE(LVL,NODE,DATE) ; Calculate the oldest date for the categories tracked.
  1. N GDATE
  1. I '$D(^TMP($J,"IBCNOR2",LVL,NODE,"DATE")) G OLDDATEX ;Not calculating
  1. S GDATE=^TMP($J,"IBCNOR2",LVL,NODE,"DATE")
  1. I 'GDATE S GDATE=DATE
  1. I GDATE,(DATE<GDATE) S GDATE=DATE
  1. S ^TMP($J,"IBCNOR2",LVL,NODE,"DATE")=GDATE
  1. ;
  1. OLDDATEX ; Exit oldest date calculation
  1. Q
  1. ;
  1. PRINT ; Print the report
  1. N CRT,EORMSG,IBPGC,IBPXT,MAXCNT,PL,SLINE,SOI,TSTAMP
  1. S EORMSG="*****END OF REPORT*****"
  1. S TSTAMP=$$FMTE^XLFDT($$NOW^XLFDT,1) ; time of report
  1. S PL=IOSL-6,(CRT,IBPGC,IBPXT)=0
  1. S:IOST["C-" PL=IOSL-3,CRT=1
  1. S $P(SLINE,"=",14)="",$P(LINE,"=",79)="",TAB=$S(IBOUT="E":"^",1:"?"_53)
  1. D HDR I IBPXT G PRINTX
  1. I IBOUT="E",TYPE="S" D G PRINTX
  1. . S DLINE="OLDEST DATE^AGE OF OLDEST^TOTAL NUMBER OF ENTRIES^*TOTAL T-7 BACKLOG^TOTAL WEDNESDAY BACKLOG" D WRTLNX
  1. . S DATA=$G(^TMP($J,"IBCNOR2","SUM","OLDEST DATE")) S DLINE=$S(DATA:$$FMTDT(DATA),1:"")
  1. . S DATA=$FN(^TMP($J,"IBCNOR2","SUM","AGE"),",") S DLINE=DLINE_U_DATA
  1. . S DATA=$FN(^TMP($J,"IBCNOR2","SUM","TOTAL ENTRIES"),",") S DLINE=DLINE_U_DATA
  1. . S DATA=$FN(^TMP($J,"IBCNOR2","SUM","BACKLOG"),",") S DLINE=DLINE_U_DATA
  1. . S DATA=$FN(^TMP($J,"IBCNOR2","SUM","WBACKLOG"),",") S DLINE=DLINE_U_DATA
  1. . D WRTLNX
  1. D WRTLN("Oldest Date","OLDEST DATE","D","SUM") I IBPXT G PRINTX
  1. D WRTLN("Age of Oldest","AGE","N","SUM") I IBPXT G PRINTX
  1. D WRTLN("Total Number of Entries","TOTAL ENTRIES","N","SUM") I IBPXT G PRINTX
  1. D WRTLN("*Total T-7 Backlog","BACKLOG","N","SUM") I IBPXT G PRINTX
  1. D WRTLN("Total Wednesday Backlog","WBACKLOG","N","SUM") I IBPXT G PRINTX
  1. I TYPE="S" G PRINTX
  1. D WRTLN("Total MCCF vs. non-MCCF","MCCF vs. non-MCCF","N","TOT") I IBPXT G PRINTX
  1. D WRTLN(" MCCF","MCCF","N","DET") I IBPXT G PRINTX
  1. D WRTLN(" Non-MCCF","Non-MCCF","N","DET") I IBPXT G PRINTX
  1. D WRTLN("Total Number of Entries by Insurance Company Category","Insurance Company Category","N","TOT") I IBPXT G PRINTX
  1. D WRTLN(" TRICARE","TRICARE","N","DET") I IBPXT G PRINTX
  1. D WRTLN(" CHAMPVA","CHAMPVA","N","DET") I IBPXT G PRINTX
  1. D WRTLN(" MEDICARE","MEDICARE","N","DET") I IBPXT G PRINTX
  1. D WRTLN(" MEDICARE PART D (WNR)","MEDICARE PART D (WNR)","N","DET") I IBPXT G PRINTX
  1. D WRTLN(" CMS MBI ONLY","CMS MBI ONLY","N","DET") I IBPXT G PRINTX
  1. D WRTLN(" NO INSURANCE","NO INSURANCE","N","DET") I IBPXT G PRINTX
  1. D WRTLN(" PATIENT REFUSED","PATIENT REFUSED","N","DET") I IBPXT G PRINTX
  1. D WRTLN(" All OTHER","ALL OTHER","N","DET") I IBPXT G PRINTX
  1. D WRTLN("Total Number of Entries by Patient Status","Patient Status","N","TOT") I IBPXT G PRINTX
  1. D WRTLN(" i ACTIVE INSURANCE","i ACTIVE INSURANCE","N","DET") I IBPXT G PRINTX
  1. D WRTLN(" I INPATIENT","I INPATIENT","N","DET") I IBPXT G PRINTX
  1. D WRTLN(" E DECEASED","E DECEASED","N","DET") I IBPXT G PRINTX
  1. D WRTLN(" Y CO-PAY REQUIRED","Y COPAY REQUIRED","N","DET") I IBPXT G PRINTX
  1. D WRTLN(" H CHARGES ON HOLD","H CHARGES ON HOLD","N","DET") I IBPXT G PRINTX
  1. D WRTLN(" blank","blank","N","DET") I IBPXT G PRINTX
  1. D WRTLN("Total Number of Entries by Source of Information","Source of Information","N","TOT") I IBPXT G PRINTX
  1. S SOI=""
  1. F S SOI=$O(^TMP($J,"IBCNOR2","SOI",SOI)) Q:SOI="" D I IBPXT Q
  1. . D WRTLN(" "_SOI,SOI,"N","SOI")
  1. ;
  1. PRINTX ; Exit Print
  1. I 'IBPXT D EOP(1)
  1. Q
  1. ;
  1. FMTDT(DATE) ;Format the date
  1. I $L(DATE) S DATE=$TR($$FMTE^XLFDT(DATE,"5FD")," ","0")
  1. FMTDTX ;Exit
  1. Q DATE
  1. ;
  1. WRTLN(TITLE,NODE,DTYPE,LEVEL) ;Write the line
  1. N DATA,DATE,DLINE,NUM,TAB,TAB1
  1. S TAB=$S(TITLE["PART D":35,LEVEL="TOT":55,1:30)
  1. S TAB1=$S(TITLE["PART D":50,1:45)
  1. I $Y+1>PL,IBOUT="R",'$D(EMAIL) D HDR I $G(ZTSTOP)!IBPXT Q
  1. I LEVEL="DET" D G WRTLNX
  1. . S DATA=$G(^TMP($J,"IBCNOR2","DET",NODE))
  1. . S DATA=$FN(+DATA,",") I IBOUT="R" S DATA=$$RJ^XLFSTR(DATA,7)
  1. . S DLINE=TITLE
  1. . I IBOUT="E" S DLINE=DLINE_"^"_DATA
  1. . I IBOUT="R" S $E(DLINE,TAB)=DATA
  1. . S DATA=$G(^TMP($J,"IBCNOR2","DET",NODE,"DATE"))
  1. . I DATA]"" D
  1. .. S DATA=$$FMTDT(DATA)
  1. .. I IBOUT="E" D Q
  1. ... D WRTLNX
  1. ... S DLINE=TITLE_" OLDEST^"_DATA
  1. .. S $E(DLINE,TAB1)=DATA
  1. I LEVEL="SOI" D G WRTLNX
  1. . S DATA=$G(^TMP($J,"IBCNOR2","SOI",NODE))
  1. . S DATA=$FN(+DATA,",") I IBOUT="R" S DATA=$$RJ^XLFSTR(DATA,7)
  1. . S DLINE=TITLE
  1. . I IBOUT="E" S DLINE=DLINE_"^"_DATA
  1. . I IBOUT="R" S $E(DLINE,TAB)=DATA
  1. . S DATA=$G(^TMP($J,"IBCNOR2","SOI",NODE,"DATE"))
  1. . I DATA]"" D
  1. .. S DATA=$$FMTDT(DATA)
  1. .. I IBOUT="E" D Q
  1. ... D WRTLNX
  1. ... S DLINE=TITLE_" OLDEST^"_DATA
  1. .. S $E(DLINE,TAB1)=DATA
  1. I LEVEL="SUM" D G WRTLNX
  1. . S DATA=$G(^TMP($J,"IBCNOR2","SUM",NODE))
  1. . I DTYPE="D" S DATA=$$FMTDT(DATA)
  1. . I DTYPE="N" S DATA=$FN(+DATA,",") I IBOUT="R" S DATA=$$RJ^XLFSTR(DATA,7)
  1. . S DLINE=TITLE
  1. . I IBOUT="E" S DLINE=DLINE_"^"_DATA
  1. . I IBOUT="R" S $E(DLINE,TAB)=DATA
  1. I LEVEL="TOT" D G WRTLNX
  1. . S DLINE="" D WRTLNX
  1. . S DATA=$G(^TMP($J,"IBCNOR2","TOT",NODE))
  1. . I NODE="Patient Status" S DATA="N/A"
  1. . I NODE'="Patient Status" S DATA=$FN(+DATA,",")
  1. . I IBOUT="R" S DATA=$$RJ^XLFSTR(DATA,7)
  1. . S DLINE=TITLE
  1. . I IBOUT="E" S DLINE=DLINE_"^"_DATA
  1. . I IBOUT="R" S $E(DLINE,TAB)=DATA
  1. . D WRTLNX
  1. . S DLINE=$S(IBOUT="R":" ",1:"")_SLINE
  1. WRTLNX ;Exit
  1. I $D(EMAIL) S CNT=$G(MSG)+1,MSG=CNT,MSG(CNT)=DLINE Q
  1. W !,DLINE
  1. Q
  1. ;
  1. HDR ;Print Header
  1. N STRING,TAB
  1. I $D(ZTQUEUED),$$S^%ZTLOAD() S (ZTSTOP,IBPXT)=1 G HDRX
  1. I CRT,(IBPGC>0),'$D(ZTQUEUED) D EOP(0) I IBPXT G HDRX
  1. S IBPGC=IBPGC+1
  1. I '$D(EMAIL) W @IOF
  1. S STRING=TSTAMP I IBOUT="R" S STRING=STRING_" Page: "_IBPGC
  1. S TAB=$S(IBOUT="E":24,1:80-($L(STRING)+3))
  1. S DLINE="Daily Buffer Report",$E(DLINE,TAB)=STRING D WRTLNX
  1. S DLINE=$S(TYPE="S":"Summary",1:"Detail") D WRTLNX
  1. S DLINE="*Entries > 7 weekdays, where T=1 if weekday. Otherwise, T= previous Friday." D WRTLNX
  1. I IBOUT="E" G HDRX
  1. S DLINE=LINE D WRTLNX
  1. S DLINE="" D WRTLNX
  1. ;
  1. HDRX ; Header Exit
  1. Q
  1. ;
  1. EOP(END) ; display "end of page" message and set exit flag
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,LIN
  1. I END D
  1. . S DLINE="" D WRTLNX
  1. . S DLINE="*****END OF REPORT*****" D WRTLNX
  1. I 'CRT!$D(EMAIL) G EOPQ
  1. I PL<51 F LIN=1:1:(PL-$Y)-1 W !
  1. W !
  1. S DIR(0)="E" D ^DIR K DIR
  1. I $D(DTOUT)!$D(DUOUT) S IBPXT=1
  1. EOPQ ;
  1. Q
  1. ;
  1. CATNDT ; Report categories with no oldest date
  1. ;;MCCF^Non-MCCF^i ACTIVE INSURANCE^I INPATIENT^E DECEASED^Y COPAY REQUIRED^
  1. ;;H CHARGES ON HOLD^blank^
  1. ;;
  1. CATWDT ; Report categories with oldest date
  1. ;;TRICARE^CHAMPVA^MEDICARE^MEDICARE PART D (WNR)^CMS MBI ONLY^NO INSURANCE^
  1. ;;PATIENT REFUSED^ALL OTHER^
  1. ;;
  1. TOTALS ;Category Totals
  1. ;;MCCF vs. non-MCCF^Insurance Company Category^Patient Status^Source of Information^
  1. ;;