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

BQIIPSNG.m

Go to the documentation of this file.
BQIIPSNG ;GDIT/HS/ALA-Update a Single Provider ; 06 Dec 2012  1:18 PM
 ;;2.7;ICARE MANAGEMENT SYSTEM;;Dec 19, 2017;Build 23
 ;
EN(BQIPROV,BQDATE,CRIPC) ;EP - Monthly
 ; Get current IPC
 S CRIPC=$G(CRIPC,"")
 I CRIPC="" S CRIPC=$P($G(^BQI(90508,1,11)),U,1)
 S CRN=$O(^BQI(90508,1,22,"B",CRIPC,"")) I CRN="" Q
 ; Calculate the IPC measures
 S MSN=0
 F  S MSN=$O(^BQI(90508,1,22,CRN,1,MSN)) Q:'MSN  D
 . S IDATA=^BQI(90508,1,22,CRN,1,MSN,0)
 . S CODE=$P(IDATA,U,1),TYP=$P(IDATA,U,2)
 . ; If inactive, quit
 . I $P(IDATA,U,7)=1 Q
 . ; If type is non calculable
 . I TYP="N" D NCLC Q
 . ; If type is RPMS
 . I TYP="R" Q
 . ; If type is CRS
 . I TYP="G" D CRS Q
 . I TYP="M" D MU
 ;
 ; Update the Goal Set
 NEW TPRN,PRV,TPRD,GPRN,GPRD,DEN,FAC,YEAR
 S YEAR=$$GET1^DIQ(90508,1_",",2,"E")
 S TPRN=$O(^BQIPROV(BQIPROV,30,"B","IPC_TOTP",""))
 I TPRN="" D TOTP
 I TPRN'="" S TPRD=$O(^BQIPROV(BQIPROV,30,TPRN,1,"B",BQDATE,""))
 I $G(TPRD)="" D
 . D TOTP
 . S TPRN=$O(^BQIPROV(BQIPROV,30,"B","IPC_TOTP",""))
 . I TPRN'="" S TPRD=$O(^BQIPROV(BQIPROV,30,TPRN,1,"B",BQDATE,""))
 S GPRN=$O(^BQIPROV(BQIPROV,30,"B",YEAR_"_2452",""))
 I GPRN'="" S GPRD=$O(^BQIPROV(BQIPROV,30,GPRN,1,"B",BQDATE,""))
 I TPRN'="",TPRD'="" S DEN=$P(^BQIPROV(BQIPROV,30,TPRN,1,TPRD,0),U,2)
 I GPRN'="",GPRD'="" S $P(^BQIPROV(BQIPROV,30,GPRN,1,GPRD,0),U,2)=DEN
 S $P(^BQIPROV(BQIPROV,2),U,3)=$$NOW^XLFDT()
 ;
 ; Update the MU bundles
 NEW MPRN,IPRN,IPRD,DEN,NUM,MCOD,MPRD,MBUN
 S MPRN=$O(^BQIPROV(BQIPROV,30,"B","IPC_WGT",""))
 I MPRN'="" S MPRD=$O(^BQIPROV(BQIPROV,30,MPRN,1,"B",BQDATE,""))
 K MBUN
 F MCOD="MU_8","MU_6","MU_7" D
 . S IPRN=$O(^BQIPROV(BQIPROV,30,"B",MCOD,"")) I IPRN="" Q
 . S IPRD=$O(^BQIPROV(BQIPROV,30,IPRN,1,"B",BQDATE,"")) I IPRD="" Q
 . S DEN=$P(^BQIPROV(BQIPROV,30,IPRN,1,IPRD,0),U,2),NUM=$P(^(0),U,3)
 . S MBUN(+DEN)=+NUM
 S DEN=$O(MBUN(""))
 S:DEN="" NUM="" S:DEN'="" NUM=MBUN(DEN)
 I MPRN'="",MPRD'="" D
 . S $P(^BQIPROV(BQIPROV,30,MPRN,1,MPRD,0),U,2)=DEN,$P(^BQIPROV(BQIPROV,30,MPRN,1,MPRD,0),U,3)=NUM
 Q
 ;
NCLC ; No calculation possible
 Q
 ;
CRS ; Get values from BQIPAT
 S PRV=BQIPROV,TDEN=0,TNUM=0
 S DFN="",PDEN=0,PNUM=0
 F  S DFN=$O(^AUPNPAT("AK",PRV,DFN)) Q:DFN=""  D
 . I '$$HRN^BQIUL1(DFN) Q
 . S IEN=$O(^BQIPAT(DFN,30,"B",CODE,"")) I IEN="" Q
 . S PNUM=PNUM+$P(^BQIPAT(DFN,30,IEN,0),U,3)
 . S PDEN=PDEN+$P(^BQIPAT(DFN,30,IEN,0),U,4)
 D STORP^BQIIPUTL(PRV,CODE,BQDATE,PDEN,PNUM)
 Q
 ;
MU ; Get values for MU measures
 S PRV=BQIPROV,TDEN=0,TNUM=0
 NEW BGPBEN,BGPRTYPE,BGP0RPTH,BGPMUT,BGPMUYF,BGPBD,BGPED,BGPTP,BGPINDT
 NEW BQTDT,BQTMN,BQIGREF,DFN,CDEN,CNUM,CEXC,NUM,BQTN,MUIND,MUI
 S PDEN=0,PNUM=0
 ; Current
 S BGPBEN=3
 S BGPRTYPE=4,BGP0RPTH="A",BGPMUT="P",BGPMUYF=90595.11
 S (BGPBD,BGPED,BGPTP,BGPINDT)=""
 S BGPBD=BEGDT,BGPED=ENDT
 S BGPPBD="",BGPPED=""
 ; Baseline
 S BGPBBD=BGPPBD,BGPBED=BGPPED
 S BQIGREF=$NA(^TMP("BQICQM",$J)) K @BQIGREF
 S MUIND=$P($G(^BGPMUIND(90596.11,$P(CODE,"_",2),0)),U,1) I MUIND="" Q
 S BGPIND(MUIND)="",BGPPROV=PRV,MUI=$P(CODE,"_",2)
 D BQI^BGPMUEPD(.BQIGREF,BGPPROV)
 K CDEN,CNUM,CEXC,NUM
 S DFN=""
 F  S DFN=$O(@BQIGREF@(BGPPROV,DFN)) Q:DFN=""  D
 . S CDEN=$P($G(@BQIGREF@(BGPPROV,DFN,"C",MUI)),U,1)
 . S NUM=$P($G(@BQIGREF@(BGPPROV,DFN,"C",MUI)),U,2)
 . I NUM>1,$$FMTE^BQIUL1(NUM)'?.N S NUM=1
 . S CNUM=NUM
 . S CEXC=$P($G(@BQIGREF@(BGPPROV,DFN,"C",MUI)),U,3)
 . S PDEN=PDEN+$G(CDEN),PNUM=PNUM+$G(CNUM)
 D STORP^BQIIPUTL(PRV,CODE,BQDATE,PDEN,PNUM)
 K BQIND
 Q
 ;
TOTP ;
 NEW BQITOTP
 S BQITOTP=0
 S PIEN="" F  S PIEN=$O(^AUPNPAT("AK",BQIPROV,PIEN)) Q:PIEN=""  D
 . ;I '$$HRN^BQIUL1(PIEN) Q
 . S BQITOTP=BQITOTP+1
 D STORP^BQIIPUTL(BQIPROV,"IPC_TOTP",BQDATE,BQITOTP,0)
 Q
 ;
MEAS(CRN,MSN,PROV,TEAM,BQDATE,BQFROM,BQTHRU) ;EP - Update a Measure
 I $G(BQDATE)'="" S WEEK=""
 I $G(BQFROM)'="" S WEEK=1
 S DEBUG=1
 S IDATA=^BQI(90508,1,22,CRN,1,MSN,0)
 S CODE=$P(IDATA,U,1),TYP=$P(IDATA,U,2)
 ; If inactive, quit
 I $P(IDATA,U,7)=1 Q
 ; If type is non calculable
 I TYP="N" Q
 ; If type is RPMS
 I TYP="R" D  Q
 . S EXEC=$G(^BQI(90508,1,22,CRN,1,MSN,1)) I EXEC="" Q
 . X EXEC
 . K DEBUG
 ; If type is CRS
 I TYP="G" D  Q
 . I $G(PROV)'=""!($G(FAC)'="") D  Q
 .. S BQIPROV="",FDEN=0,FNUM=0
 .. F  S BQIPROV=$O(^AUPNPAT("AK",BQIPROV)) Q:BQIPROV=""  D
 ... I $P(^VA(200,BQIPROV,0),U,13)'="" Q
 ... S TDEN=0,TNUM=0
 ... S BDFN="" F  S BDFN=$O(^AUPNPAT("AK",BQIPROV,BDFN)) Q:BDFN=""  D
 .... S PN=$O(^BQIPAT(BDFN,30,"B",CODE,"")) I PN="" Q
 .... S NUM=$P(^BQIPAT(BDFN,30,PN,0),"^",3),DEN=$P(^(0),"^",4)
 .... S TDEN=TDEN+DEN,TNUM=TNUM+NUM,FDEN=FDEN+DEN,FNUM=FNUM+NUM
 ... W !,BQIPROV,"|",CODE,"|",TNUM,"|",TDEN
 ... ;I WEEK'=1 D STORP^BQIIPUTL(BQIPROV,CODE,BQDATE,TDEN,TNUM)
 ... ;I WEEK=1 D STORPW^BQIIPUTL(BQIPROV,CODE,BQFROM,BQTHRU,TDEN,TNUM)
 .. I $G(FAC)'="" D
 ... S FAC=$$HME^BQIGPUTL()
 ... W !!,FAC,"|",CODE,"|",FNUM,"|",FDEN,!!
 ... ;I WEEK'=1 D STORF^BQIIPUTL(FAC,CODE,BQDATE,FDEN,FNUM)
 ... ;I WEEK=1 D STORFW^BQIIPUTL(FAC,CODE,BQFROM,BQTHRU,FDEN,FNUM)
 . I $G(TEAM)'="" D
 .. I TEAM'?.N S TMN=$O(^BSDPCT("B",TEAM,"")) I TMN="" Q
 .. I TEAM?.N S TMN=TEAM,TEAM=$P(^BSDPCT(TMN,0),"^",1)
 .. S TMM="",PDEN=0,PNUM=0 F  S TMM=$O(^BSDPCT(TMN,1,"B",TMM)) Q:TMM=""  D
 ... S DFN="" I $O(^AUPNPAT("AK",TMM,DFN))="" Q
 ... F  S DFN=$O(^AUPNPAT("AK",TMM,DFN)) Q:DFN=""  D
 .... S PN=$O(^BQIPAT(DFN,30,"B",CODE,"")) I PN="" Q
 .... S NUM=$P(^BQIPAT(DFN,30,PN,0),"^",3),DEN=$P(^(0),"^",4)
 .... S PDEN=PDEN+DEN,PNUM=PNUM+NUM
 .. W !,TMN,"|",CODE,"|",PNUM,"|",PDEN
 .. ;I WEEK'=1 D STORT^BQIIPUTL(TEAM,CODE,BQDATE,PDEN,PNUM)
 .. ;I WEEK=1 D STORTW^BQIIPUTL(TEAM,CODE,BQFROM,BQTHRU,PDEN,PNUM)
 Q