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

BQIIPRVG.m

Go to the documentation of this file.
BQIIPRVG ;VNGT/HS/ALA-IPC Revenue Generated ; 04 May 2011  10:59 AM
 ;;2.4;ICARE MANAGEMENT SYSTEM;;Apr 01, 2015;Build 41
 ;
 ;
EN(BQDATE) ;EP
 NEW BQMON,BQDTE,BEGDT,ENDT,EDAY,ID,PROV,BQTOTV,BQTOTP,FAC
 NEW FC,TVIS,TPD,CL,QFL,CRST
 S QFL=0
 S CRST=$P($G(^BQI(90508,1,11)),U,2) S:CRST="" CRST=1
 S CRST="0"_CRST
 ;
 I $G(BQDATE)'="" D
 . S BEGDT=$E(BQDATE,1,5)_"01",CYR=$E(BQDATE,1,3),BQMON=$E(BQDATE,4,5)
 . I $L(BQMON)=1 S BQMON="0"_BQMON
 . S EDAY="31^"_($$LEAP^XLFDT2(CYR)+28)_"^31^30^31^30^31^31^30^31^30^31"
 . S ENDT=$E(BQDATE,1,5)_$P(EDAY,U,+BQMON)
 ;
 I $G(BQDATE)="" D  Q:QFL
 . I $E(DT,6,7)'=CRST S QFL=1 Q
 . S BQMON=$E(DT,4,5)-1,CYR=$E(DT,1,3),PYR=CYR-1
 . I $L(BQMON)=1 S BQMON="0"_BQMON
 . S BQDTE=$P($T(BQM+BQMON),";;",2)
 . S BEGDT=@($P(BQDTE,U,2))_$P(BQDTE,U,1)_"01"
 . S EDAY="31^"_($$LEAP^XLFDT2(CYR)+28)_"^31^30^31^30^31^31^30^31^30^31"
 . S ENDT=@($P(BQDTE,U,2))_$P(BQDTE,U,1)_$P(EDAY,U,+$P(BQDTE,U,1))
 . S BQDATE=$S(BQMON="01":PYR,1:CYR)_BQMON_"00"
 ;
 S ID="IPC_REVG"
 ;
 S PROV="",BQTOTV=0,BQTOTP=0
 F  S PROV=$O(^AUPNPAT("AK",PROV)) Q:PROV=""  D
 . I $P(^VA(200,PROV,0),U,13)'="" Q
 . D PRV(PROV)
 . D STORP^BQIIPUTL(PROV,ID,BQDATE,TVIS,TPD)
 ;
 S FAC=$$HME^BQIGPUTL()
 D STORF^BQIIPUTL(FAC,ID,BQDATE,BQTOTV,BQTOTP)
 Q
 ; Set over all for facility
 NEW DA,DIC,FAC,DLAYGO,MSRN
 S FAC=$P(^BQI(90508,1,0),U,1)
 I '$D(^BQIFAC(FAC,30,0)) S ^BQIFAC(FAC,30,0)="^90505.63^^"
 S DA(1)=FAC,DIC(0)="LMNZ",DLAYGO=90505.63,X=ID,DIC="^BQIFAC("_DA(1)_",30,"
 D ^DIC I Y=-1 K DO,DD D FILE^DICN
 S MSRN=+Y
 I '$D(^BQIFAC(FAC,30,MSRN,1,0)) S ^BQIFAC(FAC,30,MSRN,1,0)="^90505.631D^^"
 S DA(2)=FAC,DA(1)=MSRN,DIC(0)="LMNZ",DLAYGO=90505.631,X=BQDATE
 S DIC="^BQIFAC("_DA(2)_",30,"_DA(1)_",1,"
 D ^DIC I Y=-1 K DO,DD D FILE^DICN
 S DA=+Y
 S $P(^BQIFAC(FAC,30,MSRN,1,DA,0),U,2,3)=BQTOTP_U_BQTOTV
 ;
 K BARP,BAR,BARQ,BARY,BQTOTV,BQTOTP
 Q
 ;
PRV(PROV) ;EP
 I $T(COMPUTE^BARDRST)="" D  Q
 . S TVIS=0,BQTOTV=BQTOTV+TVIS
 . S TPD=0,BQTOTP=BQTOTP+TPD
 K BARP,BAR,BARQ,BARY
 S BARP("RTN")="BARDRST"
 S BAR("LOC")="VISIT"
 S BAR("LVL")=3
 S BAR("OPT")="STA"
 S BAR("PAY")=""
 S BAR("RTYP")=0
 S BAR("STATUS")=0
 S BARQ("NS")="BAR"
 S BARQ("RC")="COMPUTE^BARDRST"
 S BARQ("RP")="PRT^BQIIPRVG"
 S BARQ("RX")="POUT^BARRUTL"
 S BARY("DT")="V"
 S BARY("DT",1)=BEGDT
 S BARY("DT",2)=ENDT
 S BARY("PRV")=PROV
 S BARY("SORT")="C"
 D COMPUTE^BARDRST
 S FC=1
 S TVIS=0,TPD=0
 F  S FC=$O(BAR(FC)) Q:'FC  D
 . S CL=""
 . F  S CL=$O(BAR(FC,CL)) Q:CL=""  D
 .. S TVIS=TVIS+$P(BAR(FC,CL),U,1),BQTOTV=BQTOTV+TVIS
 .. S TPD=TPD+$P(BAR(FC,CL),U,4),BQTOTP=BQTOTP+TPD
 K BARP,BAR,BARQ,BARY
 Q
 ;
PRT ;
 Q
 ;
STORP ; Store for provider
 NEW DA,DIC,MSRN,DLAYGO,X
 I '$D(^BQIPROV(PROV,30,0)) S ^BQIPROV(PROV,30,0)="^90505.43^^"
 S DA(1)=PROV,DIC(0)="LMNZ",DLAYGO=90505.43,X=ID,DIC="^BQIPROV("_DA(1)_",30,"
 D ^DIC I Y=-1 K DO,DD D FILE^DICN
 S MSRN=+Y
 I '$D(^BQIPROV(PROV,30,MSRN,1,0)) S ^BQIPROV(PROV,30,MSRN,1,0)="^90505.431D^^"
 S DA(2)=PROV,DA(1)=MSRN,DIC(0)="LMNZ",DLAYGO=90505.431,X=BQDATE
 S DIC="^BQIPROV("_DA(2)_",30,"_DA(1)_",1,"
 D ^DIC I Y=-1 K DO,DD D FILE^DICN
 S DA=+Y
 S $P(^BQIPROV(PROV,30,MSRN,1,DA,0),U,2,3)=TPD_U_TVIS
 K TVIS,TPD
 Q
 ;
BQM ;
 ;;09^PYR
 ;;10^PYR
 ;;11^PYR
 ;;12^PYR
 ;;01^CYR
 ;;02^CYR
 ;;03^CYR
 ;;04^CYR
 ;;05^CYR
 ;;06^CYR
 ;;07^CYR
 ;;08^CYR