BPSRPT0 ;BHAM ISC/BEE - ECME REPORTS ;14-FEB-05
 ;;1.0;E CLAIMS MGMT ENGINE;**1,5,7,10,11,19,20,23,24,28**;JUN 2004;Build 22
 ;;Per VA Directive 6402, this routine should not be modified.
 ;
 Q
 ;
 ; Front End for ECME Reports
 ; 
 ; Input variable: BPRTYPE -> 1 = Payable Claims
 ;                          2 = Rejected Claims
 ;                          3 = Claims Submitted, Not Yet Released
 ;                          4 = Reversed Claims
 ;                          5 = Recent Transactions
 ;                          6 = Totals By Date
 ;                          7 = Closed Claims
 ;                          8 = Spending Account Report
 ;                          9 = ECME RXs with Non-Billable Status
 ;                         10 = Duplicate Claims Report
 ;                          
 ; Passed variables:
 ;  The following local variables are set in BPSPRT0 and are passed throughout
 ;  the BPSRPT* routines. They are used during the looping/filtering of transactions
 ;  and when creating the reports.
 ;  These local variable are not passed as parameters but assumed to be defined.
 ; 
 ;    BPRTYPE -  report number (1-10) 
 ;      1 = Payable Claims, 2 = Rejected Claims, 3 = Claims Submitted, Not Yet Released, 
 ;      4 = Reversed Claims, 5 = Recent Transactions, 6 = Totals By Date,
 ;      7 = Closed Claims, 8 = Spending Account Report, 9 = ECME RXs with Non-Billable Status,
 ;      10 = Duplicate Claims
 ;    BPRPTNAM - report name 
 ;      1-PAYABLE CLAIMS, 2-REJECTED CLAIMS, 3-SUBMIT,NOT RELEASED CLAIMS,
 ;      4-REVERSED CLAIMS, 5-RECENT TRANSACTIONS, 6-TOTALS, 7-CLOSED CLAIMS,
 ;      8-SPENDING ACCOUNT REPORT, 9-RXS WITH NON-BILLABLE STATUS,
 ;      10-DUPLICATE CLAIMS REPORT
 ;    BPSLC - all lower case letters (used to convert from lower to upper)
 ;    BPSUC - all upper case letters (used to convert from lower to upper)
 ;    BPPHARM - Pharmacy Divisions or ALL
 ;      BPPHARM=0 - ALL
 ;        if Pharmacy Divisions was selected, returns BPPHARM variable and an array
 ;      BPPHARM=1
 ;      BPPHARM(ptr) for each selection - Pointer to BPS PHARMACIES 
 ;    BPSUMDET - 1=Display Summary  or 0=Detail Format 
 ;    BPINS - allow selection of Insurance or ALL, returns BPINS variable and BPARR array
 ;      0="^" Exit
 ;      1=if ALL - BPARR(1.11)="A",BPARR(2.04)="",BPARR("INS")=""
 ;      1=if INSURANCE
 ;        BPARR(1.11)="I",
 ;        BPARR(2.04)=";1;ptr;"   if multiple entries - BPARR(2.04)=";ptr;ptr;."
 ;        BPARR("INS")=";1;ptr;"  if multiple entries - BPARR("INS")=";ptr;ptr;."
 ;      ptr - Pointer to the INSURANCE file
 ;    BPINSINF - BPINSINF=0 - if ALL Insurances was selected above
 ;      BPINSINF=BPARR("INS") 
 ;    BPMWC - Fill location C-CMOP, W-WINDOW, M-MAIL
 ;      BPMWC=A-ALL, ^-Exit
 ;      BPMWC=(C,W,M)
 ;       if multiple entries - BPMWC=(a comma delimited string of users selection, e.g. "C,M")
 ;    BPRTBCK - Fill Type - 2-RealTime Fills, 3-Backbills, 4-PRO Option, 5-Resubmission
 ;      BPRTBCK=1-ALL,^-exit
 ;      BPRTBCK=(2,3,4,5)
 ;       if multiple entries - BPRTBCK=(a comma delimited string of users selection, e.g. "3,5")
 ;    BPQSTDRG - Drug-2 or Drug Class-3 or All-1 or Exit-^
 ;      BPQSTDRG=(1,2,3,^)
 ;    BPDRUG - select Drug - ptr=Pointer to the DRUG file #50
 ;      BPDRUG= ptr - if multiple entries - BPDRUG="ptr,ptr,."
 ;    BPDRGCL - select Drug - ptr= Pointer to the DRUG CLASS file #50.5
 ;      BPDRGCL= ptr - if multiple entries - BPDRGCL= ptr,ptr,.
 ;    BPBEGDT - Date Range
 ;      BPBEGDT=^-Exit
 ;      BPBEGDT= beginning date ^ ending date
 ;      BPBEGDT=$P(BPBEGDT,U) - beginning date
 ;      BPENDDT=$P(BPBEGDT,U,2) - ending date
 ;    BPRLNRL - 2-Released, 3-Not Released or 1-All
 ;      BPRLNRL=(1,2,3,^) ^=exit
 ;    BPQSTRC - select Reject Code-1 or All-0
 ;      BPQSTRC=(0,1,^)
 ;    BPREJCD - if Reject Code=1 was selected above
 ;      BPREJCD=ptr - if multiple entries - BPREJCD=ptr,ptr,.
 ;       ptr=Pointer to Reject Code in #9002313.93
 ;    BPAUTREV - AutoReversed-1 or All-0
 ;      BPAUTREV=(0,1,^)
 ;    BPACREJ - Accepted-2, Rejected-1 or All-0
 ;      BPACREJ=(0,1,2,^)
 ;    BPQSTCR - select Close Claim Reason-1 or All-0
 ;      BPQSTCR=(0,1,^)
 ;    BPCCRSN - if Specific Close Claim Reason=1 1 was selected above
 ;      BPCCRSN=ptr - if multiple entries - BPCCRSN=ptr,ptr  ptr=Pointer to file #356.8
 ;    BPELIG - Eligibility V-Veteran, T-Tricare, C-Champva or 0-All
 ;      BPELIG=(V,T,C,0,^)
 ;    BPELIG1 - multiple Eligibilities or All-0 
 ;      BPELIG1=(0,^)
 ;      BPELIG1=(V,T,C)   V-Veteran, T-Tricare, C-Champva
 ;       if multiple entries BPELIG1=(a comma delimited string of users selection, e.g. "C,T")
 ; BPDUP - Dup Claims S-Duplicate of Approved, D-Duplicate of Paid, Q-Duplicate of Capture or 0-All
 ; BPDUP=(S,D,Q,0,^)
 ;    BPOPCL - Open-2, Closed-1 or All-0
 ;      BPOPCL=(0,1,2,^)
 ;    BPQSTPR - select Prescriber-1 or All-0
 ;      BPQSTPR=(0,1,^)
 ;    BPRESC - if Prescribers=1 was selected above
 ;      BPRESC=ptr - if multiple entries - BPRESC=ptr,ptr  ptr=Pointer to file #200
 ;    BPQSTPAT - select Patients-1 or All-0
 ;      BPQSTPAT=(0,1,^)
 ;    BPPAT - if Patients=1 was selected above
 ;      BPPAT=ptr - if multiple entries - BPPAT=ptr,ptr  ptr=Pointer to file #2
 ;    BPBILL - Range of Billed Amount-1 or All-0
 ;      BPBILL=(0,1,^) 
 ;    BPMIN - if BPBILL=1 enter minimum billed amount
 ;      BPMIN=amount entered, default is 0
 ;    BPMAX - if BPBILL=1 enter maximum billed amount
 ;      BPMAX=amount entered, default is 999999
 ;    BPALRC - All-A or Most Recent-R (Non-Billable Status report only, BPRTYPE=9)
 ;      BPALRC=(A,R,^)
 ;    BPNBSTS - Non-Billable Status (Non-Billable Status report only, BPRTYPE=9)
 ;      BPNBSTS=(0-All,1-certain Non-billable status,^)
 ;       if BPNBSTS=1 there is a BPNBSTS array for each status selected
 ;      BPNBSTS(ptr)=status  - for each status selected
 ;       ptr=Pointer to file #366.17 - status=non-billable reason from file #366.17 field #.01
 ;    BPEXCEL - Excel capture-detail only, if BPSUMDET=0 (detail format)
 ;      BPEXCEL=(0-No, 1-Yes, ^)
 ;    BPQ - device variable - I POP S BPQ=1 otherwise BPQ=0
 ;
 ; The following local variables are not set in BPSRPT0 however they are used in several
 ; BPSRPT* routines.  They are not passed as parameters but assumed to be defined.
 ;    BPBLINE - blank line indicator, 1-print blank line
 ;    BPGRPLAN - insurance plan name
 ;    BPSDATA - tells whether data has been displayed to the screen (0-No,1-Yes)
 ;                          
EN(BPRTYPE) ;
 N %,BPACREJ,BPAUTREV,BPBEGDT,BPCCRSN,BPDRGCL,BPDRUG,BPENDDT,BPEXCEL,BPNOW,BPPHARM,BPINSINF,BPMWC,BPQ,BPQSTDRG
 N BPREJCD,BPRLNRL,BPRPTNAM,BPRTBCK,BPSCR,BPSUMDET,BPINS,BPARR,BPELIG,BPDUP,BPOPCL
 N BPNBSTS,BPALRC,BPELIG1,BPRESC,BPPAT,BPQSTPAT,BPBILL,BPMIN,BPMAX,BPSLC,BPSUC,BPSCOMMENT
 N BPQSTCR,BPQSTPR,BPQSTRC,CODE,POS,STAT,X,Y
 ;
 ;Verify that a valid report has been requested
 I ",1,2,3,4,5,6,7,8,9,10,"'[(","_$G(BPRTYPE)_",") W "<Invalid Menu Definition - Report Undefined>" H 3 Q
 S BPRPTNAM=$P("PAYABLE CLAIMS^REJECTED CLAIMS^SUBMIT,NOT RELEASED CLAIMS^REVERSED CLAIMS^RECENT TRANSACTIONS^TOTALS^CLOSED CLAIMS^SPENDING ACCOUNT REPORT^RXS WITH NON-BILLABLE STATUS^DUPLICATE CLAIMS","^",BPRTYPE)
 ;
 ;Needed to convert lower case entries to upper case
 S BPSLC="abcdefghijklmnopqrstuvwxyz"
 S BPSUC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 ;
 ;Get current Date/Time
 D NOW^%DTC S Y=% D DD^%DT S BPNOW=Y
 ;
DIV ;
 ;Prompt for ECME Pharmacy Division(s) (No Default)
 ;Sets up BPPHARM variable and array, BPPHARM =0 ALL or BPPHARM=1,BPPHARM(ptr) for list
 S X=$$SELPHARM^BPSRPT3() G:(X="^")&($G(BPPHARM)="") EXIT G:(X="^")&(BPPHARM=1) DIV
 ;
 ;Prompt to Display Summary or Detail Format (Default to Detail)
 ;Returns 1 for Summary, 0 for Detail
 S BPSUMDET=$$SELSMDET^BPSRPT3(2) I BPSUMDET="^" G EXIT
 ;
INSUR ;
 ;Prompt to allow selection of Multiple Insurances or All (Default to ALL)
 ;See description for $$INSURSEL^BPSSCRCU
 S BPINS=$$INSURSEL^BPSSCRCU(.BPARR,DUZ) I BPINS<1 G EXIT
 S BPINSINF=$S(BPARR(1.11)="I":BPARR("INS"),1:0)
 ;If "I" Specific Insurance(s) was selected and the user didn't select
 ;an Insurance re-prompt for Specific Insurance(s) or All
 I BPINSINF=";" G INSUR
 ;
 ;Prompt to Display (C)MOP or (M)ail or (W)indow or (A)LL (Default to ALL)
 ;Returns (A-ALL,M-Mail,W-Window,C-CMOP)
 I (",5,6,8,")[BPRTYPE S BPMWC=$$SELMWC^BPSRPT3("A") I BPMWC="^" G EXIT
 I (",1,2,3,4,7,9,")[BPRTYPE S BPMWC=$$SELMWC1^BPSRPT3("A") I BPMWC="^" G EXIT
 I BPRTYPE=10 S BPMWC="A"   ;DEFAULT TO ALL, do not prompt for report 10
 ;
 ;Prompt to Display (R)ealTime Fills or (B)ackbills or (P)RO Option or Re(S)ubmission or (A)LL (Default to ALL)
 ;Returns (1-ALL,2-RealTime Fills,3-Backbills,4-PRO Option,5-Resubmission)
 S BPRTBCK=1
 I (",5,6,8,")[BPRTYPE S BPRTBCK=$$SELRTBCK^BPSRPT3(1) I BPRTBCK="^" G EXIT
 I (",1,2,3,4,7,")[BPRTYPE S BPRTBCK=$$SELRBPS^BPSRPT3() I BPRTBCK="^" G EXIT
 I BPRTYPE=10 S BPMWC="A"   ;DEFAULT TO ALL, do not prompt for report 10
 ;
DGDGCL ;
 ;Prompt to Display Specific (D)rug or Drug (C)lass or (A)ll (Default to ALL)
 ;Returns (1-ALL,2-Drug,3-Drug Class)
 I BPRTYPE'=10 S BPQSTDRG=$$SELDRGAL^BPSRPT3(1) I BPQSTDRG="^" Q
 I BPRTYPE=10 S BPQSTDRG=1 ;DEFAULT TO 1-ALL, do not prompt for report 10
 ;
 ;Prompt to Select Drug (No Default)
 S BPDRUG=0 I BPQSTDRG=2 D  G:BPDRUG="^" EXIT G:BPDRUG=0 DGDGCL
 . I (",5,6,8,")[BPRTYPE S BPDRUG=$$SELDRG^BPSRPT3()
 . I (",1,2,3,4,7,9,")[BPRTYPE S BPDRUG=$$SELDRG1^BPSRPT3A()
 ;
 ;Prompt to Select Drug Class (No Default)
 S BPDRGCL=0 I BPQSTDRG=3 D  G:BPDRGCL="^" EXIT G:BPDRGCL=0 DGDGCL
 . I (",5,6,8,")[BPRTYPE S BPDRGCL=$$SELDRGCL^BPSRPT3()
 . I (",1,2,3,4,7,9,")[BPRTYPE S BPDRGCL=$$SELDC^BPSRPT3A()
 ;
 ;Report Specific Prompts
 ;
 ;Prompt to select Date Range
 ;Returns (Start Date^End Date)
 S BPBEGDT=$$SELDATE^BPSRPT3(BPRTYPE) D  I BPBEGDT="^" G EXIT
 .I BPBEGDT="^" Q
 .S BPENDDT=$P(BPBEGDT,U,2)
 .S BPBEGDT=$P(BPBEGDT,U)
 ;
 ;Prompt to Include (R)ELEASED or (N)OT RELEASED or (A)LL (Default to RELEASED)
 ;Returns (1-ALL,2-RELEASED,3-NOT RELEASED)
 S BPRLNRL=$S(BPRTYPE=3:3,1:1) I (",1,2,4,6,7,8,9,10,")[(","_BPRTYPE_",") S BPRLNRL=$$SELRLNRL^BPSRPT4($S(BPRTYPE=9!(BPRTYPE=10):1,1:2)) I BPRLNRL="^" G EXIT
 ;
REJCD ;
 ;Prompt to Include (S)pecific Reject Code or (A)LL (Default to ALL)
 ;Returns (0-All,1-Reject Code,^=exit)
 S BPQSTRC=0 I (",2,")[BPRTYPE S BPQSTRC=$$SELRC^BPSRPT4(0) I BPQSTRC="^" G EXIT
 ;
 ;If Specific Reject Code was selected, prompt for one or more Reject Codes
 ;Returns: BPREJCD=a string of reject code ien's separated by a comma (file #9002313.93)
 S BPREJCD=0
 I BPQSTRC=1 S BPREJCD=$$SELREJCD^BPSRPT4() G:BPREJCD=0 REJCD G:BPREJCD="^" EXIT
 ;
 ;Prompt to Include Auto(R)eversed or (A)LL (Default to ALL)
 ;Returns (0-All,1-AutoReversed)
 S BPAUTREV=0 I (",4,")[BPRTYPE S BPAUTREV=$$SELAUREV^BPSRPT4(0) I BPAUTREV="^" G EXIT
 ;
 ;Prompt to Include A(C)cepted or (R)ejected or (A)LL (Default to REJECTED)
 ;Returns (0-All,1-Rejected,2-Accepted)
 S BPACREJ=0 I (",4,")[BPRTYPE S BPACREJ=$$SELACREJ^BPSRPT4(1) I BPACREJ="^" G EXIT
 ;
CCR ;
 ;Prompt to Include (S)pecific Close Claim Reason or (A)ll (Default to All)
 ;Returns (0-All,1-Close Claim Reason,^=exit)
 S BPQSTCR=0 I (",7,")[BPRTYPE S BPQSTCR=$$SELCCR^BPSRPT4(0) I BPQSTCR="^" G EXIT
 ;
 ;If Specific Close Claim Reason was selected, prompt for one or more Close Claim Reasons
 ;Returns: BPCCRSN=a string of close claim reason ien's separated by a comma
 S BPCCRSN=0
 I BPQSTCR=1 S BPCCRSN=$$SELCCRSN^BPSRPT4() G:BPCCRSN=0 CCR I BPCCRSN="^" G EXIT
 ;
 ;;Prompt for Eligibility Indicator for payable, rejected, reversed and closed claims report
 ;;Returns (V=VETERAN,T=TRICARE,C=CHAMPVA,0=All)
 ;;S BPELIG=0 I (",1,4,7,")[BPRTYPE S BPELIG=$$SELELIG^BPSRPT3(1) I BPELIG="^" G EXIT
 ;
 ;Prompt for All or Most Recent (Non-Billable Status Report only)
 ;Returns A - All, R - Most Recent
 S BPALRC=0 I (",9,")[BPRTYPE S BPALRC=$$SELALRC^BPSRPT3() I BPALRC="^" G EXIT
 ;
 ;Prompt for one, multiple or (A)ll Eligibility Indicator
 ;Returns (0-All, 1-selection)
 ; If 1, BPARR("ELIG",xx) is set for each eligibility selected - xx="V", "T" or "C"
 S BPELIG1=0 I (",1,2,3,4,7,9,10,")[(","_BPRTYPE_",") S BPELIG1=$$SELELIG1^BPSRPT3() I BPELIG1="^" G EXIT
 ;
 ;Prompt to Display S - DUPLICATE OF APPROVED, D - DUPLICATE OF PAID, Q - DUPLICATE OF CAPTURE, A - ALL
 ;Returns 0-ALL,^-quit, or selection separated by comma's
 I BPRTYPE=10 S BPDUP=$$SELDUP^BPSRPT3A() I BPDUP="^" G EXIT
 ;
 ;Prompt for Open/Closed/All claims
 ;Returns (1=Closed,2=Open,0=All)
 S BPOPCL=0 I (",2,")[BPRTYPE S BPOPCL=$$SELOPCL^BPSRPT3(2) I BPOPCL="^" G EXIT
 ;
PRESCR ;
 ;Prompt to select SPECIFIC PRESCRIBER(S) or (A)ll Prescribers
 ;Returns: (0=ALL,1=Prescriber,^=exit)
 S BPQSTPR=0 I (",2,")[BPRTYPE S BPQSTPR=$$SELPR^BPSRPT3A() I BPQSTPR="^" G EXIT
 ;
 ;If Specific Prescriber was selected, prompt for one or more prescribers
 ;Returns: BPRESC=a string of prescriber ien's separated by a comma
 S BPRESC=0
 I BPQSTPR=1 S BPRESC=$$SELPRESC^BPSRPT3A() G:BPRESC=0 PRESCR I BPRESC="^" G EXIT
 ;
PATIENT ;    
 ;Prompt to select (P)atients or (A)LL Patients
 ;Returns: (0=ALL,1=Patient,^=exit)
 S BPQSTPAT=0 I (",1,2,3,4,7,9,10,")[(","_BPRTYPE_",") S BPQSTPAT=$$SELPA^BPSRPT3A() I BPQSTPAT="^" G EXIT
 ;
 ;If (P)atients was selected, prompt for one or more patients
 ;Returns: BPPAT=a string of patient ien's separated by a comma
 S BPPAT=0
 I BPQSTPAT=1 S BPPAT=$$SELPAT^BPSRPT3A() G:BPPAT="^" EXIT G:BPPAT=0 PATIENT
 ;
 ;Prompt to select(R)ange for Billed Amount or (A)LL
 ;Returns: (0=ALL,1=Range,^=exit)
 S BPBILL=0 I (",1,2,3,4,9,10,")[(","_BPRTYPE_",") S BPBILL=$$SELBAMT^BPSRPT3A() I BPBILL="^" G EXIT
 ;If Range of Billed Amount was selected prompt for Minimum and Maximum
 ;Returns: BPMIN=minimum amount entered, BPMAX=maximum amount entered
 S (BPMIN,BPMAX)=0
 I BPBILL=1 W !,"Range for the Billed Amount" D  I (BPMIN="^")!(BPMAX="^") G EXIT
 . S BPMIN=$$SELBMIN^BPSRPT3A() I BPMIN="^" Q
 . S BPMAX=$$SELBMAX^BPSRPT3A()
 ;
 ;Prompt for Non-Billable Status (Non-Billable Status Report only)
 ;Sets up BPNBSTS variable and array, BPNBSTS=0 ALL or BPNBSTS=1,BPNBSTS(xx) for list
 S BPNBSTS=0 I (",9,")[BPRTYPE S BPNBSTS=$$SELNBSTS^BPSRPT3() I BPNBSTS="^" G EXIT
 ;
 ;Prompt for Excel Capture (Detail Only)
 S BPEXCEL=0 I 'BPSUMDET S BPEXCEL=$$SELEXCEL^BPSRPT4() I BPEXCEL="^" G EXIT
 ;
 ;Prompt for the Device
 I 'BPEXCEL D
 .W !!,"WARNING - THIS REPORT REQUIRES THAT A DEVICE WITH 132 COLUMN WIDTH BE USED."
 .W !,"IT WILL NOT DISPLAY CORRECTLY USING 80 COLUMN WIDTH DEVICES",!
 S BPQ=0 D DEVICE(BPRPTNAM) Q:BPQ
 ;
 ;Compile and Run the Report
 D RUN(BPEXCEL,BPRPTNAM,BPSUMDET)
 I 'BPQ D PAUSE2^BPSRPT1
 ;
EXIT Q
 ;
 ;Compile and Run the Report
 ;
RUN(BPEXCEL,BPRPTNAM,BPSUMDET) N BPPAGE,BPTMP
 S BPTMP=$NA(^TMP($J,"BPSRPT"))
 K @BPTMP
 S BPPAGE=0
 W:BPSCR&'BPEXCEL !,"Please wait...",!
 ;
 ;Compile the report
 Q:$$COLLECT^BPSRPT1(BPTMP)=-1
 U IO
 ;
 ;Display the report
 D REPORT^BPSRPT5(BPTMP,BPEXCEL,BPSCR,BPRPTNAM,BPSUMDET,BPPAGE)
 I 'BPSCR W !,@IOF
 K @BPTMP
 I $D(ZTQUEUED) S ZTREQ="@" Q
 D ^%ZISC
 Q
 ;
 ;Prompt For the Device
 ;
 ; Returns Device variables and BPSCR
 ;
DEVICE(BPRPTNAM) N %ZIS,ZTSK,ZTRTN,ZTIO,ZTDESC,ZTSAVE,POP
 S %ZIS="QM"
 D ^%ZIS
 I POP S BPQ=1
 ;
 ;Check for exit
 I $G(BPQ) G XDEV
 ;
 S BPSCR=$S($E($G(IOST),1,2)="C-":1,1:0)
 I $D(IO("Q")) D  S BPQ=1
 . S ZTRTN="RUN^BPSRPT0(BPEXCEL,BPRPTNAM,BPSUMDET)"
 . S ZTIO=ION
 . S ZTSAVE("*")=""
 . S ZTDESC="BPS REPORT: "_BPRPTNAM
 . D ^%ZTLOAD
 . W !,$S($D(ZTSK):"REQUEST QUEUED TASK="_ZTSK,1:"REQUEST CANCELLED")
 . D HOME^%ZIS
 U IO
XDEV Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HBPSRPT0   15949     printed  Sep 23, 2025@19:28:52                                                                                                                                                                                                    Page 2
BPSRPT0   ;BHAM ISC/BEE - ECME REPORTS ;14-FEB-05
 +1       ;;1.0;E CLAIMS MGMT ENGINE;**1,5,7,10,11,19,20,23,24,28**;JUN 2004;Build 22
 +2       ;;Per VA Directive 6402, this routine should not be modified.
 +3       ;
 +4        QUIT 
 +5       ;
 +6       ; Front End for ECME Reports
 +7       ; 
 +8       ; Input variable: BPRTYPE -> 1 = Payable Claims
 +9       ;                          2 = Rejected Claims
 +10      ;                          3 = Claims Submitted, Not Yet Released
 +11      ;                          4 = Reversed Claims
 +12      ;                          5 = Recent Transactions
 +13      ;                          6 = Totals By Date
 +14      ;                          7 = Closed Claims
 +15      ;                          8 = Spending Account Report
 +16      ;                          9 = ECME RXs with Non-Billable Status
 +17      ;                         10 = Duplicate Claims Report
 +18      ;                          
 +19      ; Passed variables:
 +20      ;  The following local variables are set in BPSPRT0 and are passed throughout
 +21      ;  the BPSRPT* routines. They are used during the looping/filtering of transactions
 +22      ;  and when creating the reports.
 +23      ;  These local variable are not passed as parameters but assumed to be defined.
 +24      ; 
 +25      ;    BPRTYPE -  report number (1-10) 
 +26      ;      1 = Payable Claims, 2 = Rejected Claims, 3 = Claims Submitted, Not Yet Released, 
 +27      ;      4 = Reversed Claims, 5 = Recent Transactions, 6 = Totals By Date,
 +28      ;      7 = Closed Claims, 8 = Spending Account Report, 9 = ECME RXs with Non-Billable Status,
 +29      ;      10 = Duplicate Claims
 +30      ;    BPRPTNAM - report name 
 +31      ;      1-PAYABLE CLAIMS, 2-REJECTED CLAIMS, 3-SUBMIT,NOT RELEASED CLAIMS,
 +32      ;      4-REVERSED CLAIMS, 5-RECENT TRANSACTIONS, 6-TOTALS, 7-CLOSED CLAIMS,
 +33      ;      8-SPENDING ACCOUNT REPORT, 9-RXS WITH NON-BILLABLE STATUS,
 +34      ;      10-DUPLICATE CLAIMS REPORT
 +35      ;    BPSLC - all lower case letters (used to convert from lower to upper)
 +36      ;    BPSUC - all upper case letters (used to convert from lower to upper)
 +37      ;    BPPHARM - Pharmacy Divisions or ALL
 +38      ;      BPPHARM=0 - ALL
 +39      ;        if Pharmacy Divisions was selected, returns BPPHARM variable and an array
 +40      ;      BPPHARM=1
 +41      ;      BPPHARM(ptr) for each selection - Pointer to BPS PHARMACIES 
 +42      ;    BPSUMDET - 1=Display Summary  or 0=Detail Format 
 +43      ;    BPINS - allow selection of Insurance or ALL, returns BPINS variable and BPARR array
 +44      ;      0="^" Exit
 +45      ;      1=if ALL - BPARR(1.11)="A",BPARR(2.04)="",BPARR("INS")=""
 +46      ;      1=if INSURANCE
 +47      ;        BPARR(1.11)="I",
 +48      ;        BPARR(2.04)=";1;ptr;"   if multiple entries - BPARR(2.04)=";ptr;ptr;."
 +49      ;        BPARR("INS")=";1;ptr;"  if multiple entries - BPARR("INS")=";ptr;ptr;."
 +50      ;      ptr - Pointer to the INSURANCE file
 +51      ;    BPINSINF - BPINSINF=0 - if ALL Insurances was selected above
 +52      ;      BPINSINF=BPARR("INS") 
 +53      ;    BPMWC - Fill location C-CMOP, W-WINDOW, M-MAIL
 +54      ;      BPMWC=A-ALL, ^-Exit
 +55      ;      BPMWC=(C,W,M)
 +56      ;       if multiple entries - BPMWC=(a comma delimited string of users selection, e.g. "C,M")
 +57      ;    BPRTBCK - Fill Type - 2-RealTime Fills, 3-Backbills, 4-PRO Option, 5-Resubmission
 +58      ;      BPRTBCK=1-ALL,^-exit
 +59      ;      BPRTBCK=(2,3,4,5)
 +60      ;       if multiple entries - BPRTBCK=(a comma delimited string of users selection, e.g. "3,5")
 +61      ;    BPQSTDRG - Drug-2 or Drug Class-3 or All-1 or Exit-^
 +62      ;      BPQSTDRG=(1,2,3,^)
 +63      ;    BPDRUG - select Drug - ptr=Pointer to the DRUG file #50
 +64      ;      BPDRUG= ptr - if multiple entries - BPDRUG="ptr,ptr,."
 +65      ;    BPDRGCL - select Drug - ptr= Pointer to the DRUG CLASS file #50.5
 +66      ;      BPDRGCL= ptr - if multiple entries - BPDRGCL= ptr,ptr,.
 +67      ;    BPBEGDT - Date Range
 +68      ;      BPBEGDT=^-Exit
 +69      ;      BPBEGDT= beginning date ^ ending date
 +70      ;      BPBEGDT=$P(BPBEGDT,U) - beginning date
 +71      ;      BPENDDT=$P(BPBEGDT,U,2) - ending date
 +72      ;    BPRLNRL - 2-Released, 3-Not Released or 1-All
 +73      ;      BPRLNRL=(1,2,3,^) ^=exit
 +74      ;    BPQSTRC - select Reject Code-1 or All-0
 +75      ;      BPQSTRC=(0,1,^)
 +76      ;    BPREJCD - if Reject Code=1 was selected above
 +77      ;      BPREJCD=ptr - if multiple entries - BPREJCD=ptr,ptr,.
 +78      ;       ptr=Pointer to Reject Code in #9002313.93
 +79      ;    BPAUTREV - AutoReversed-1 or All-0
 +80      ;      BPAUTREV=(0,1,^)
 +81      ;    BPACREJ - Accepted-2, Rejected-1 or All-0
 +82      ;      BPACREJ=(0,1,2,^)
 +83      ;    BPQSTCR - select Close Claim Reason-1 or All-0
 +84      ;      BPQSTCR=(0,1,^)
 +85      ;    BPCCRSN - if Specific Close Claim Reason=1 1 was selected above
 +86      ;      BPCCRSN=ptr - if multiple entries - BPCCRSN=ptr,ptr  ptr=Pointer to file #356.8
 +87      ;    BPELIG - Eligibility V-Veteran, T-Tricare, C-Champva or 0-All
 +88      ;      BPELIG=(V,T,C,0,^)
 +89      ;    BPELIG1 - multiple Eligibilities or All-0 
 +90      ;      BPELIG1=(0,^)
 +91      ;      BPELIG1=(V,T,C)   V-Veteran, T-Tricare, C-Champva
 +92      ;       if multiple entries BPELIG1=(a comma delimited string of users selection, e.g. "C,T")
 +93      ; BPDUP - Dup Claims S-Duplicate of Approved, D-Duplicate of Paid, Q-Duplicate of Capture or 0-All
 +94      ; BPDUP=(S,D,Q,0,^)
 +95      ;    BPOPCL - Open-2, Closed-1 or All-0
 +96      ;      BPOPCL=(0,1,2,^)
 +97      ;    BPQSTPR - select Prescriber-1 or All-0
 +98      ;      BPQSTPR=(0,1,^)
 +99      ;    BPRESC - if Prescribers=1 was selected above
 +100     ;      BPRESC=ptr - if multiple entries - BPRESC=ptr,ptr  ptr=Pointer to file #200
 +101     ;    BPQSTPAT - select Patients-1 or All-0
 +102     ;      BPQSTPAT=(0,1,^)
 +103     ;    BPPAT - if Patients=1 was selected above
 +104     ;      BPPAT=ptr - if multiple entries - BPPAT=ptr,ptr  ptr=Pointer to file #2
 +105     ;    BPBILL - Range of Billed Amount-1 or All-0
 +106     ;      BPBILL=(0,1,^) 
 +107     ;    BPMIN - if BPBILL=1 enter minimum billed amount
 +108     ;      BPMIN=amount entered, default is 0
 +109     ;    BPMAX - if BPBILL=1 enter maximum billed amount
 +110     ;      BPMAX=amount entered, default is 999999
 +111     ;    BPALRC - All-A or Most Recent-R (Non-Billable Status report only, BPRTYPE=9)
 +112     ;      BPALRC=(A,R,^)
 +113     ;    BPNBSTS - Non-Billable Status (Non-Billable Status report only, BPRTYPE=9)
 +114     ;      BPNBSTS=(0-All,1-certain Non-billable status,^)
 +115     ;       if BPNBSTS=1 there is a BPNBSTS array for each status selected
 +116     ;      BPNBSTS(ptr)=status  - for each status selected
 +117     ;       ptr=Pointer to file #366.17 - status=non-billable reason from file #366.17 field #.01
 +118     ;    BPEXCEL - Excel capture-detail only, if BPSUMDET=0 (detail format)
 +119     ;      BPEXCEL=(0-No, 1-Yes, ^)
 +120     ;    BPQ - device variable - I POP S BPQ=1 otherwise BPQ=0
 +121     ;
 +122     ; The following local variables are not set in BPSRPT0 however they are used in several
 +123     ; BPSRPT* routines.  They are not passed as parameters but assumed to be defined.
 +124     ;    BPBLINE - blank line indicator, 1-print blank line
 +125     ;    BPGRPLAN - insurance plan name
 +126     ;    BPSDATA - tells whether data has been displayed to the screen (0-No,1-Yes)
 +127     ;                          
EN(BPRTYPE) ;
 +1        NEW %,BPACREJ,BPAUTREV,BPBEGDT,BPCCRSN,BPDRGCL,BPDRUG,BPENDDT,BPEXCEL,BPNOW,BPPHARM,BPINSINF,BPMWC,BPQ,BPQSTDRG
 +2        NEW BPREJCD,BPRLNRL,BPRPTNAM,BPRTBCK,BPSCR,BPSUMDET,BPINS,BPARR,BPELIG,BPDUP,BPOPCL
 +3        NEW BPNBSTS,BPALRC,BPELIG1,BPRESC,BPPAT,BPQSTPAT,BPBILL,BPMIN,BPMAX,BPSLC,BPSUC,BPSCOMMENT
 +4        NEW BPQSTCR,BPQSTPR,BPQSTRC,CODE,POS,STAT,X,Y
 +5       ;
 +6       ;Verify that a valid report has been requested
 +7        IF ",1,2,3,4,5,6,7,8,9,10,"'[(","_$GET(BPRTYPE)_",")
               WRITE "<Invalid Menu Definition - Report Undefined>"
               HANG 3
               QUIT 
 +8        SET BPRPTNAM=$PIECE("PAYABLE CLAIMS^REJECTED CLAIMS^SUBMIT,NOT RELEASED CLAIMS^REVERSED CLAIMS^RECENT TRANSACTIONS^TOTALS^CLOSED CLAIMS^SPENDING ACCOUNT REPORT^RXS WITH NON-BILLABLE STATUS^DUPLICATE CLAIMS","^",BPRTYPE)
 +9       ;
 +10      ;Needed to convert lower case entries to upper case
 +11       SET BPSLC="abcdefghijklmnopqrstuvwxyz"
 +12       SET BPSUC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 +13      ;
 +14      ;Get current Date/Time
 +15       DO NOW^%DTC
           SET Y=%
           DO DD^%DT
           SET BPNOW=Y
 +16      ;
DIV       ;
 +1       ;Prompt for ECME Pharmacy Division(s) (No Default)
 +2       ;Sets up BPPHARM variable and array, BPPHARM =0 ALL or BPPHARM=1,BPPHARM(ptr) for list
 +3        SET X=$$SELPHARM^BPSRPT3()
           if (X="^")&($GET(BPPHARM)="")
               GOTO EXIT
           if (X="^")&(BPPHARM=1)
               GOTO DIV
 +4       ;
 +5       ;Prompt to Display Summary or Detail Format (Default to Detail)
 +6       ;Returns 1 for Summary, 0 for Detail
 +7        SET BPSUMDET=$$SELSMDET^BPSRPT3(2)
           IF BPSUMDET="^"
               GOTO EXIT
 +8       ;
INSUR     ;
 +1       ;Prompt to allow selection of Multiple Insurances or All (Default to ALL)
 +2       ;See description for $$INSURSEL^BPSSCRCU
 +3        SET BPINS=$$INSURSEL^BPSSCRCU(.BPARR,DUZ)
           IF BPINS<1
               GOTO EXIT
 +4        SET BPINSINF=$SELECT(BPARR(1.11)="I":BPARR("INS"),1:0)
 +5       ;If "I" Specific Insurance(s) was selected and the user didn't select
 +6       ;an Insurance re-prompt for Specific Insurance(s) or All
 +7        IF BPINSINF=";"
               GOTO INSUR
 +8       ;
 +9       ;Prompt to Display (C)MOP or (M)ail or (W)indow or (A)LL (Default to ALL)
 +10      ;Returns (A-ALL,M-Mail,W-Window,C-CMOP)
 +11       IF (",5,6,8,")[BPRTYPE
               SET BPMWC=$$SELMWC^BPSRPT3("A")
               IF BPMWC="^"
                   GOTO EXIT
 +12       IF (",1,2,3,4,7,9,")[BPRTYPE
               SET BPMWC=$$SELMWC1^BPSRPT3("A")
               IF BPMWC="^"
                   GOTO EXIT
 +13      ;DEFAULT TO ALL, do not prompt for report 10
           IF BPRTYPE=10
               SET BPMWC="A"
 +14      ;
 +15      ;Prompt to Display (R)ealTime Fills or (B)ackbills or (P)RO Option or Re(S)ubmission or (A)LL (Default to ALL)
 +16      ;Returns (1-ALL,2-RealTime Fills,3-Backbills,4-PRO Option,5-Resubmission)
 +17       SET BPRTBCK=1
 +18       IF (",5,6,8,")[BPRTYPE
               SET BPRTBCK=$$SELRTBCK^BPSRPT3(1)
               IF BPRTBCK="^"
                   GOTO EXIT
 +19       IF (",1,2,3,4,7,")[BPRTYPE
               SET BPRTBCK=$$SELRBPS^BPSRPT3()
               IF BPRTBCK="^"
                   GOTO EXIT
 +20      ;DEFAULT TO ALL, do not prompt for report 10
           IF BPRTYPE=10
               SET BPMWC="A"
 +21      ;
DGDGCL    ;
 +1       ;Prompt to Display Specific (D)rug or Drug (C)lass or (A)ll (Default to ALL)
 +2       ;Returns (1-ALL,2-Drug,3-Drug Class)
 +3        IF BPRTYPE'=10
               SET BPQSTDRG=$$SELDRGAL^BPSRPT3(1)
               IF BPQSTDRG="^"
                   QUIT 
 +4       ;DEFAULT TO 1-ALL, do not prompt for report 10
           IF BPRTYPE=10
               SET BPQSTDRG=1
 +5       ;
 +6       ;Prompt to Select Drug (No Default)
 +7        SET BPDRUG=0
           IF BPQSTDRG=2
               Begin DoDot:1
 +8                IF (",5,6,8,")[BPRTYPE
                       SET BPDRUG=$$SELDRG^BPSRPT3()
 +9                IF (",1,2,3,4,7,9,")[BPRTYPE
                       SET BPDRUG=$$SELDRG1^BPSRPT3A()
               End DoDot:1
               if BPDRUG="^"
                   GOTO EXIT
               if BPDRUG=0
                   GOTO DGDGCL
 +10      ;
 +11      ;Prompt to Select Drug Class (No Default)
 +12       SET BPDRGCL=0
           IF BPQSTDRG=3
               Begin DoDot:1
 +13               IF (",5,6,8,")[BPRTYPE
                       SET BPDRGCL=$$SELDRGCL^BPSRPT3()
 +14               IF (",1,2,3,4,7,9,")[BPRTYPE
                       SET BPDRGCL=$$SELDC^BPSRPT3A()
               End DoDot:1
               if BPDRGCL="^"
                   GOTO EXIT
               if BPDRGCL=0
                   GOTO DGDGCL
 +15      ;
 +16      ;Report Specific Prompts
 +17      ;
 +18      ;Prompt to select Date Range
 +19      ;Returns (Start Date^End Date)
 +20       SET BPBEGDT=$$SELDATE^BPSRPT3(BPRTYPE)
           Begin DoDot:1
 +21           IF BPBEGDT="^"
                   QUIT 
 +22           SET BPENDDT=$PIECE(BPBEGDT,U,2)
 +23           SET BPBEGDT=$PIECE(BPBEGDT,U)
           End DoDot:1
           IF BPBEGDT="^"
               GOTO EXIT
 +24      ;
 +25      ;Prompt to Include (R)ELEASED or (N)OT RELEASED or (A)LL (Default to RELEASED)
 +26      ;Returns (1-ALL,2-RELEASED,3-NOT RELEASED)
 +27       SET BPRLNRL=$SELECT(BPRTYPE=3:3,1:1)
           IF (",1,2,4,6,7,8,9,10,")[(","_BPRTYPE_",")
               SET BPRLNRL=$$SELRLNRL^BPSRPT4($SELECT(BPRTYPE=9!(BPRTYPE=10):1,1:2))
               IF BPRLNRL="^"
                   GOTO EXIT
 +28      ;
REJCD     ;
 +1       ;Prompt to Include (S)pecific Reject Code or (A)LL (Default to ALL)
 +2       ;Returns (0-All,1-Reject Code,^=exit)
 +3        SET BPQSTRC=0
           IF (",2,")[BPRTYPE
               SET BPQSTRC=$$SELRC^BPSRPT4(0)
               IF BPQSTRC="^"
                   GOTO EXIT
 +4       ;
 +5       ;If Specific Reject Code was selected, prompt for one or more Reject Codes
 +6       ;Returns: BPREJCD=a string of reject code ien's separated by a comma (file #9002313.93)
 +7        SET BPREJCD=0
 +8        IF BPQSTRC=1
               SET BPREJCD=$$SELREJCD^BPSRPT4()
               if BPREJCD=0
                   GOTO REJCD
               if BPREJCD="^"
                   GOTO EXIT
 +9       ;
 +10      ;Prompt to Include Auto(R)eversed or (A)LL (Default to ALL)
 +11      ;Returns (0-All,1-AutoReversed)
 +12       SET BPAUTREV=0
           IF (",4,")[BPRTYPE
               SET BPAUTREV=$$SELAUREV^BPSRPT4(0)
               IF BPAUTREV="^"
                   GOTO EXIT
 +13      ;
 +14      ;Prompt to Include A(C)cepted or (R)ejected or (A)LL (Default to REJECTED)
 +15      ;Returns (0-All,1-Rejected,2-Accepted)
 +16       SET BPACREJ=0
           IF (",4,")[BPRTYPE
               SET BPACREJ=$$SELACREJ^BPSRPT4(1)
               IF BPACREJ="^"
                   GOTO EXIT
 +17      ;
CCR       ;
 +1       ;Prompt to Include (S)pecific Close Claim Reason or (A)ll (Default to All)
 +2       ;Returns (0-All,1-Close Claim Reason,^=exit)
 +3        SET BPQSTCR=0
           IF (",7,")[BPRTYPE
               SET BPQSTCR=$$SELCCR^BPSRPT4(0)
               IF BPQSTCR="^"
                   GOTO EXIT
 +4       ;
 +5       ;If Specific Close Claim Reason was selected, prompt for one or more Close Claim Reasons
 +6       ;Returns: BPCCRSN=a string of close claim reason ien's separated by a comma
 +7        SET BPCCRSN=0
 +8        IF BPQSTCR=1
               SET BPCCRSN=$$SELCCRSN^BPSRPT4()
               if BPCCRSN=0
                   GOTO CCR
               IF BPCCRSN="^"
                   GOTO EXIT
 +9       ;
 +10      ;;Prompt for Eligibility Indicator for payable, rejected, reversed and closed claims report
 +11      ;;Returns (V=VETERAN,T=TRICARE,C=CHAMPVA,0=All)
 +12      ;;S BPELIG=0 I (",1,4,7,")[BPRTYPE S BPELIG=$$SELELIG^BPSRPT3(1) I BPELIG="^" G EXIT
 +13      ;
 +14      ;Prompt for All or Most Recent (Non-Billable Status Report only)
 +15      ;Returns A - All, R - Most Recent
 +16       SET BPALRC=0
           IF (",9,")[BPRTYPE
               SET BPALRC=$$SELALRC^BPSRPT3()
               IF BPALRC="^"
                   GOTO EXIT
 +17      ;
 +18      ;Prompt for one, multiple or (A)ll Eligibility Indicator
 +19      ;Returns (0-All, 1-selection)
 +20      ; If 1, BPARR("ELIG",xx) is set for each eligibility selected - xx="V", "T" or "C"
 +21       SET BPELIG1=0
           IF (",1,2,3,4,7,9,10,")[(","_BPRTYPE_",")
               SET BPELIG1=$$SELELIG1^BPSRPT3()
               IF BPELIG1="^"
                   GOTO EXIT
 +22      ;
 +23      ;Prompt to Display S - DUPLICATE OF APPROVED, D - DUPLICATE OF PAID, Q - DUPLICATE OF CAPTURE, A - ALL
 +24      ;Returns 0-ALL,^-quit, or selection separated by comma's
 +25       IF BPRTYPE=10
               SET BPDUP=$$SELDUP^BPSRPT3A()
               IF BPDUP="^"
                   GOTO EXIT
 +26      ;
 +27      ;Prompt for Open/Closed/All claims
 +28      ;Returns (1=Closed,2=Open,0=All)
 +29       SET BPOPCL=0
           IF (",2,")[BPRTYPE
               SET BPOPCL=$$SELOPCL^BPSRPT3(2)
               IF BPOPCL="^"
                   GOTO EXIT
 +30      ;
PRESCR    ;
 +1       ;Prompt to select SPECIFIC PRESCRIBER(S) or (A)ll Prescribers
 +2       ;Returns: (0=ALL,1=Prescriber,^=exit)
 +3        SET BPQSTPR=0
           IF (",2,")[BPRTYPE
               SET BPQSTPR=$$SELPR^BPSRPT3A()
               IF BPQSTPR="^"
                   GOTO EXIT
 +4       ;
 +5       ;If Specific Prescriber was selected, prompt for one or more prescribers
 +6       ;Returns: BPRESC=a string of prescriber ien's separated by a comma
 +7        SET BPRESC=0
 +8        IF BPQSTPR=1
               SET BPRESC=$$SELPRESC^BPSRPT3A()
               if BPRESC=0
                   GOTO PRESCR
               IF BPRESC="^"
                   GOTO EXIT
 +9       ;
PATIENT   ;    
 +1       ;Prompt to select (P)atients or (A)LL Patients
 +2       ;Returns: (0=ALL,1=Patient,^=exit)
 +3        SET BPQSTPAT=0
           IF (",1,2,3,4,7,9,10,")[(","_BPRTYPE_",")
               SET BPQSTPAT=$$SELPA^BPSRPT3A()
               IF BPQSTPAT="^"
                   GOTO EXIT
 +4       ;
 +5       ;If (P)atients was selected, prompt for one or more patients
 +6       ;Returns: BPPAT=a string of patient ien's separated by a comma
 +7        SET BPPAT=0
 +8        IF BPQSTPAT=1
               SET BPPAT=$$SELPAT^BPSRPT3A()
               if BPPAT="^"
                   GOTO EXIT
               if BPPAT=0
                   GOTO PATIENT
 +9       ;
 +10      ;Prompt to select(R)ange for Billed Amount or (A)LL
 +11      ;Returns: (0=ALL,1=Range,^=exit)
 +12       SET BPBILL=0
           IF (",1,2,3,4,9,10,")[(","_BPRTYPE_",")
               SET BPBILL=$$SELBAMT^BPSRPT3A()
               IF BPBILL="^"
                   GOTO EXIT
 +13      ;If Range of Billed Amount was selected prompt for Minimum and Maximum
 +14      ;Returns: BPMIN=minimum amount entered, BPMAX=maximum amount entered
 +15       SET (BPMIN,BPMAX)=0
 +16       IF BPBILL=1
               WRITE !,"Range for the Billed Amount"
               Begin DoDot:1
 +17               SET BPMIN=$$SELBMIN^BPSRPT3A()
                   IF BPMIN="^"
                       QUIT 
 +18               SET BPMAX=$$SELBMAX^BPSRPT3A()
               End DoDot:1
               IF (BPMIN="^")!(BPMAX="^")
                   GOTO EXIT
 +19      ;
 +20      ;Prompt for Non-Billable Status (Non-Billable Status Report only)
 +21      ;Sets up BPNBSTS variable and array, BPNBSTS=0 ALL or BPNBSTS=1,BPNBSTS(xx) for list
 +22       SET BPNBSTS=0
           IF (",9,")[BPRTYPE
               SET BPNBSTS=$$SELNBSTS^BPSRPT3()
               IF BPNBSTS="^"
                   GOTO EXIT
 +23      ;
 +24      ;Prompt for Excel Capture (Detail Only)
 +25       SET BPEXCEL=0
           IF 'BPSUMDET
               SET BPEXCEL=$$SELEXCEL^BPSRPT4()
               IF BPEXCEL="^"
                   GOTO EXIT
 +26      ;
 +27      ;Prompt for the Device
 +28       IF 'BPEXCEL
               Begin DoDot:1
 +29               WRITE !!,"WARNING - THIS REPORT REQUIRES THAT A DEVICE WITH 132 COLUMN WIDTH BE USED."
 +30               WRITE !,"IT WILL NOT DISPLAY CORRECTLY USING 80 COLUMN WIDTH DEVICES",!
               End DoDot:1
 +31       SET BPQ=0
           DO DEVICE(BPRPTNAM)
           if BPQ
               QUIT 
 +32      ;
 +33      ;Compile and Run the Report
 +34       DO RUN(BPEXCEL,BPRPTNAM,BPSUMDET)
 +35       IF 'BPQ
               DO PAUSE2^BPSRPT1
 +36      ;
EXIT       QUIT 
 +1       ;
 +2       ;Compile and Run the Report
 +3       ;
RUN(BPEXCEL,BPRPTNAM,BPSUMDET)  NEW BPPAGE,BPTMP
 +1        SET BPTMP=$NAME(^TMP($JOB,"BPSRPT"))
 +2        KILL @BPTMP
 +3        SET BPPAGE=0
 +4        if BPSCR&'BPEXCEL
               WRITE !,"Please wait...",!
 +5       ;
 +6       ;Compile the report
 +7        if $$COLLECT^BPSRPT1(BPTMP)=-1
               QUIT 
 +8        USE IO
 +9       ;
 +10      ;Display the report
 +11       DO REPORT^BPSRPT5(BPTMP,BPEXCEL,BPSCR,BPRPTNAM,BPSUMDET,BPPAGE)
 +12       IF 'BPSCR
               WRITE !,@IOF
 +13       KILL @BPTMP
 +14       IF $DATA(ZTQUEUED)
               SET ZTREQ="@"
               QUIT 
 +15       DO ^%ZISC
 +16       QUIT 
 +17      ;
 +18      ;Prompt For the Device
 +19      ;
 +20      ; Returns Device variables and BPSCR
 +21      ;
DEVICE(BPRPTNAM)  NEW %ZIS,ZTSK,ZTRTN,ZTIO,ZTDESC,ZTSAVE,POP
 +1        SET %ZIS="QM"
 +2        DO ^%ZIS
 +3        IF POP
               SET BPQ=1
 +4       ;
 +5       ;Check for exit
 +6        IF $GET(BPQ)
               GOTO XDEV
 +7       ;
 +8        SET BPSCR=$SELECT($EXTRACT($GET(IOST),1,2)="C-":1,1:0)
 +9        IF $DATA(IO("Q"))
               Begin DoDot:1
 +10               SET ZTRTN="RUN^BPSRPT0(BPEXCEL,BPRPTNAM,BPSUMDET)"
 +11               SET ZTIO=ION
 +12               SET ZTSAVE("*")=""
 +13               SET ZTDESC="BPS REPORT: "_BPRPTNAM
 +14               DO ^%ZTLOAD
 +15               WRITE !,$SELECT($DATA(ZTSK):"REQUEST QUEUED TASK="_ZTSK,1:"REQUEST CANCELLED")
 +16               DO HOME^%ZIS
               End DoDot:1
               SET BPQ=1
 +17       USE IO
XDEV       QUIT