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

BPSOPR3.m

Go to the documentation of this file.
BPSOPR3 ;ALB/PHH - OPECC Productivity Report Print ;9/21/2015
 ;;1.0;E CLAIMS MGMT ENGINE;**20**;JUN 2004;Build 27
 ;;Per VA Directive 6402, this routine should not be modified.
 ;
 Q
 ;
PRINT ; Entry point for printing the report
 N BPSPG,BPSHDR,BPSIDX,BPSQUIT,DIR,DIRUT,DUOUT,DTOUT
 ;
 S BPSPG=1
 ;
 I 'BPEXCEL D
 .D HDRINIT(.BPSHDR)
 .D HDR(.BPSHDR,BPSPG)
 ;
 ; User chose to export the report to Excel
 I BPEXCEL D
 .W !,"DIVISION^USER^CURRENT STATUS^#TRANS IN DT RANGE^#TRANS TOTAL^ELIG^RX#^REF^ECME#^COB^DOS^TRANS DATE^PAID AMT"
 ;
 S (BPSIDX,BPSQUIT)=0
 F  S BPSIDX=$O(@BPGLTMP@("REPORT",BPSIDX)) Q:'BPSIDX!(BPSQUIT)  D
 .W !,@BPGLTMP@("REPORT",BPSIDX)
 .Q:BPEXCEL
 .I $Y>(IOSL-3) D
 ..I $E(IOST,1,2)="C-" D
 ...W !
 ...S DIR(0)="E"
 ...D ^DIR
 ...K DIR
 ...I $D(DIRUT)!($D(DUOUT)) S BPSQUIT=1 K DIRUT,DTOUT,DUOUT
 ..Q:BPSQUIT
 ..S BPSPG=BPSPG+1
 ..D HDR(.BPSHDR,BPSPG)
 ;
 I 'BPEXCEL W !!?5,"*** End of Report ***"
 W !
 I '$D(ZTQUEUED) U 0 S DIR(0)="E" D ^DIR K DIR U IO
 Q
 ;
HDR(BPSHDR,BPSPG) ; Print header
 N BPSOHDR1,BPSTMP,X
 ;
 S (BPSOHDR1,BPSTMP)=BPSHDR(1)
 D ADDCHAR(.BPSTMP," ",3-$L(BPSPG))
 S BPSTMP=BPSTMP_BPSPG
 S BPSHDR(1)=BPSTMP
 ;
 W @IOF
 F X=1:1:9 W !,BPSHDR(X)
 ;
 S BPSHDR(1)=BPSOHDR1
 Q
 ;
HDRINIT(BPSHDR) ; Setup header
 N BPSRPTNM,BPSDTTM,HDR1,HDR2,X,BPSDIVNM,HDR3,HDR4,BPSUSRNM,HDR6,HDR7
 ;
 S BPSRPTNM="OPECC PRODUCTIVITY "_$S(BPSUMDET=1:"SUMMARY ",1:"DETAIL ")_"REPORT"
 S BPSDTTM=$$HTE^XLFDT($H)
 S HDR1=BPSRPTNM
 D ADDCHAR(.HDR1," ",$S(BPSUMDET=1:53,1:54))
 S HDR1=HDR1_"Print Date: "_BPSDTTM
 D ADDCHAR(.HDR1," ",121-$L(HDR1))
 S HDR1=HDR1_"Page:"
 S BPSHDR(1)=HDR1
 ;
 S HDR2="DIVISION(S): "
 I BPPHARM=0 S HDR2=HDR2_"ALL"
 I BPPHARM=1 D
 .S X=0
 .F  S X=$O(BPPHARM(X)) Q:'X  S BPSDIVNM($P(BPPHARM(X),U,2))=""
 .S X=""
 .F  S X=$O(BPSDIVNM(X)) Q:X=""  D
 ..S HDR2=HDR2_X_", "
 .S HDR2=$E(HDR2,1,$L(HDR2)-2)
 S BPSHDR(2)=$E(HDR2,1,129)
 ;
 S HDR3="ELIGIBILITY: "
 I BPELIG=0 S HDR3=HDR3_"ALL"
 I BPELIG=1 D
 .S X=""
 .F  S X=$O(BPELIG(X)) Q:X=""  D
 ..S HDR3=HDR3_$S(X="V":"VETERAN",X="T":"TRICARE",X="C":"CHAMPVA",1:"")_", "
 .S HDR3=$E(HDR3,1,$L(HDR3)-2)
 S BPSHDR(3)=HDR3
 ;
 S HDR4="USERS: "
 I BPUSER=0 S HDR4=HDR4_"ALL"
 I BPUSER=1 D
 .S X=0
 .F  S X=$O(BPUSER(X)) Q:'X  S BPSUSRNM($P(BPUSER(X),U,2))=""
 .S X=""
 .F  S X=$O(BPSUSRNM(X)) Q:X=""  D
 ..S HDR4=HDR4_X_", "
 .S HDR4=$E(HDR4,1,$L(HDR4)-2)
 S BPSHDR(4)=$E(HDR4,1,129)
 ;
 S BPSHDR(5)="ALL PRESCRIPTIONS BY TRANSACTION DATE: From "_$$FMTE^XLFDT(BPBEGDT,2)_" through "_$$FMTE^XLFDT(BPENDDT\1,2)
 ;
 S HDR6=""
 D ADDCHAR(.HDR6,"=",129)
 S BPSHDR(6)=HDR6
 ;
 S HDR7=""
 D ADDCHAR(.HDR7," ",17)
 S HDR7=HDR7_"CURRENT           # TRANSACTIONS"
 S BPSHDR(7)=HDR7
 ;
 S BPSHDR(8)="USER             STATUS            DT RANGE  TOTAL    ELIG RX#         REF/ECME#       COB    DOS      TRANS DATE       PAID AMT"
 ;
 S BPSHDR(9)=HDR6
 Q
 ;
ADDCHAR(BPSTXSTR,BPSCHAR,BPSCNT) ; Add characters to string
 N X
 Q:BPSCNT<1
 F X=1:1:BPSCNT S BPSTXSTR=BPSTXSTR_BPSCHAR
 Q
 ;
PROCESS(BP57) ; Process each Entry
 N BPSCOB,BPRX,BPREF,BPSRXFC,BPSTRTYP,BPSDIV,BPSTATUS,BPSECME,BPSDOS
 N BPSTRDT,BPSEC,BPSUSER,BPSPAMT,BPSRXFCI,BPSPRVST,BPSPRVAM,BPSPRVUT,BPSRJFND
 ;
 ; Get COB
 S BPSCOB=$S($P($G(^BPSTL(BP57,0)),U,14):$P(^BPSTL(BP57,0),U,14),1:$E($P($P($G(^BPSTL(BP57,0)),U),".",2),5,5))
 ;
 ; Get RX#
 S BPRX=+$P($G(^BPSTL(BP57,1)),U,11)
 ;
 ; Get REF - FILL NUMBER field #9 in 9002313.57
 S BPREF=+$P($G(^BPSTL(BP57,1)),U)
 ;
 ; Unique ID for RX#-Fill#-COB to separate display line/counters
 S BPSRXFC=BPRX_"-"_BPREF_"-"_BPSCOB
 ;
 ; Get Transaction Type
 S BPSTRTYP=$P($G(^BPSTL(BP57,0)),U,15)
 ; Skip eligibility verification transactions
 I BPSTRTYP="E" Q
 ;
 ; Limit report to the following RX ACTION field #1201 values
 I '$F(".BB.ERES.ERWV.ERNB.EREV.P2.P2S.","."_$P($G(^BPSTL(BP57,12)),U,1)_".") Q
 ;
 ; Check for correct BPS Pharmacy (DIVISION)
 S BPSDIV=+$P($G(^BPSTL(BP57,1)),U,7)
 I BPPHARM=1,'$D(BPPHARM(BPSDIV)) Q
 S BPSDIV=$$GET1^DIQ(9002313.56,BPSDIV,.01)
 I BPSDIV="" Q
 ;
 ; Get Status
 S BPSTATUS=$P($P($$STATUS^BPSOSRX(BPRX,BPREF,0,,BPSCOB),U),"E ",2)
 ;
 ; Get ECME
 S BPSECME=$$ECMENUM^BPSOPR2(BP57)
 ;
 ; Get Date of Service
 S BPSDOS=$$DATTIM^BPSRPT1(+$P($G(^BPSTL(BP57,12)),U,2))
 ;
 ; Get Trans Date
 S BPSTRDT=$P($G(^BPSTL(BP57,0)),U,8)
 I BPSTRDT="" Q
 ;
 ; Check for Eligibility Code
 S BPSEC=$P($G(^BPSTL(BP57,9)),U,4)
 I BPSEC="" Q
 I BPELIG=1,'$D(BPELIG(BPSEC)) Q
 ;
 ; Update general RXFC info
 S $P(@BPGLTMP@("DATA",BPSRXFC,BPSDIV),"^")=+$P($G(@BPGLTMP@("DATA",BPSRXFC,BPSDIV)),"^")+1
 I BPSTATUS'="" S $P(@BPGLTMP@("DATA",BPSRXFC,BPSDIV),"^",3)=BPSTATUS
 ;
 ; Get User
 S BPSUSER=+$P($G(^BPSTL(BP57,0)),U,10)
 I BPUSER=1,'$D(BPUSER(BPSUSER)),'$D(@BPGLTMP@("DATA",BPSRXFC,BPSDIV)) Q
 S BPSUSER=$$GET1^DIQ(200,BPSUSER,.01)
 I BPSUSER="" Q
 ;
 ; Get Paid Amount
 S BPSPAMT=$P($G(@BPGLTMP@("DATA",BPSRXFC,BPSDIV)),"^",4),BPSRXFCI=""
 I BPSPAMT="" D
 .S BPSRXFCI=$$GETRXFCI^BPSOPR2(BPSDIV,BPRX,BPREF,BPSCOB)
 .S $P(@BPGLTMP@("DATA",BPSRXFC,BPSDIV),"^",2)=$P(BPSRXFCI,"^",3)
 .S $P(@BPGLTMP@("DATA",BPSRXFC,BPSDIV),"^",4)=$S($P(BPSRXFCI,"^")="":0,1:$P(BPSRXFCI,"^"))
 .S $P(@BPGLTMP@("DATA",BPSRXFC,BPSDIV),"^",6)=$P(BPSRXFCI,"^",2)
 .I $P(BPSRXFCI,"^",4)="N",$P($G(@BPGLTMP@("DATA",BPSRXFC,BPSDIV)),"^",3)="" S $P(@BPGLTMP@("DATA",BPSRXFC,BPSDIV),"^",3)="NON-BILLABLE"
 .S BPSPAMT=$P(BPSRXFCI,"^")
 I BPSPAMT=0 S BPSPAMT=""
 ;
 ; Set variables for Non-Billable entries
 I BPSTATUS="",$P($G(@BPGLTMP@("DATA",BPSRXFC,BPSDIV)),"^",3)="NON-BILLABLE" S BPSTRTYP="N"
 I BPSTRTYP="N" S (BPSECME,BPSDOS,BPSPAMT)="",BPSTATUS="NON-BILLABLE"
 ;
 ; Update RXFC info for specific division/user
 I BPUSER=0!(BPUSER=1&($D(BPUSER(+$P($G(^BPSTL(BP57,0)),U,10))))) D
 .S BPSPRVST=$P($G(@BPGLTMP@("DATA",BPSRXFC,BPSDIV,BPSUSER)),"^")
 .S BPSPRVAM=+$P($G(@BPGLTMP@("DATA",BPSRXFC,BPSDIV,BPSUSER)),"^",6)
 .S BPSPRVUT=+$P($G(@BPGLTMP@("DATA",BPSRXFC,BPSDIV,BPSUSER)),"^",13)+1
 .S @BPGLTMP@("DATA",BPSRXFC,BPSDIV,BPSUSER)=BPSTATUS_"^"_BPSEC_"^"_$$GET1^DIQ(52,BPRX,.01)_"^"_BPREF_"^"_BPSDOS_"^"_BPSPAMT_"^"_BPSECME_"^"_BPSCOB_"^"_BPSDIV_"^"_BPSUSER_"^"_BPSTRDT_"^"_BP57
 .S $P(@BPGLTMP@("DATA",BPSRXFC,BPSDIV,BPSUSER),"^",13)=BPSPRVUT
 .S $P(@BPGLTMP@("USRTOT",BPSDIV,BPSUSER),"^",4)=+$P($G(@BPGLTMP@("USRTOT",BPSDIV,BPSUSER)),"^",4)+1
 .S $P(@BPGLTMP@("USRTOT",BPSDIV,BPSUSER),"^")=+$P($G(@BPGLTMP@("USRTOT",BPSDIV,BPSUSER)),"^")-(+BPSPRVAM)+(+BPSPAMT)
 .;
 .; Update count totals for Rejects found
 .I BPSTATUS["PAYABLE"!(BPSTATUS["NON-BILLABLE") D
 ..S BPSRJFND=$P(@BPGLTMP@("DATA",BPSRXFC,BPSDIV),"^",5)
 ..I BPSRJFND="" D
 ...S BPSRJFND=$$CALCREJ^BPSOPR2(BPSDIV,BPSUSER,BPRX,BPREF,BPSCOB)
 ...S $P(@BPGLTMP@("DATA",BPSRXFC,BPSDIV),"^",5)=BPSRJFND
 ..I BPSTATUS["PAYABLE" D
 ...Q:BPSPRVST["PAYABLE"
 ...I BPSRJFND D  Q
 ....S $P(@BPGLTMP@("USRTOT",BPSDIV,BPSUSER),"^",3)=+($P(@BPGLTMP@("USRTOT",BPSDIV,BPSUSER),"^",3))+1
 ...S $P(@BPGLTMP@("USRTOT",BPSDIV,BPSUSER),"^",2)=+($P(@BPGLTMP@("USRTOT",BPSDIV,BPSUSER),"^",2))+1
 ..I BPSTATUS["NON-BILLABLE",BPSPRVST["PAYABLE" D
 ...I BPSRJFND D  Q
 ....S $P(@BPGLTMP@("USRTOT",BPSDIV,BPSUSER),"^",3)=+($P(@BPGLTMP@("USRTOT",BPSDIV,BPSUSER),"^",3))-1
 ...S $P(@BPGLTMP@("USRTOT",BPSDIV,BPSUSER),"^",2)=+($P(@BPGLTMP@("USRTOT",BPSDIV,BPSUSER),"^",2))-1
 Q
 ;