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

BQIGPRA.m

Go to the documentation of this file.
BQIGPRA ;PRXM/HC/ALA-GPRA Aggregate Call ; 24 Oct 2005  1:11 PM
 ;;2.7;ICARE MANAGEMENT SYSTEM;**1**;Dec 19, 2017;Build 12
 ;
 Q
 ;
AGG(DATA,OWNR,PLIEN) ; EP -- BQI GET GPRA AGGREGATE
 NEW UID,II,PLID,DFN,TOTP,BQIIND,BQICAT,MDESC,TWTEN,NCURR,NUM,DEN,GOAL
 NEW TITLE,ORDER,CAT,BQIYR,FDT,TDT,RPERIOD,BQIMEASF,BQIND,BQMEAS,BQIEN
 NEW SUM,PER,VALUE,X,TDATA,YCURR,CLIN,BQICLN,MSIEN,PIND,YEAR,BQIY,BQIH
 NEW BQIINDF,BQIINDG,BQIMEASG,NAFLG,TPERIOD,BMEAS,GDATA,GNUM,GDEN,TIT
 NEW IPC,BQCODE
 S DFN=0,II=0,PLID=$$PLID^BQIUG1(OWNR,PLIEN)
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIGPAGG",UID)),TDATA=$NA(^TMP("BQIGAGG",UID))
 K @DATA,@TDATA
 ;
 ;S @DATA@(II)="T00025REPORT_PERIOD^I00010TOTAL_PATIENTS^T00030CATEGORY^T00030CLIN_GROUP^I00010MEAS_IEN^T000202010 GOAL^T00010NATIONAL_CURRENT^T00010YEAR_CURRENT^T00040INDICATOR^I00010NUMERATOR^I00010DENOMINATOR^N00010PERCENT"_$C(30)
 S @DATA@(II)="T00025REPORT_PERIOD^I00010TOTAL_PATIENTS^T00030CATEGORY^T00030CLIN_GROUP^I00010MEAS_IEN^T00010NATIONAL_CURRENT^T00010YEAR_CURRENT^T00040INDICATOR^"
 S @DATA@(II)=@DATA@(II)_"I00010NUMERATOR^I00010DENOMINATOR^N00010PERCENT^T00030HP_GOAL_2020"_$C(30)
 ;
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIGPRA D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 S YEAR=$$GET1^DIQ(90508,1_",",2,"E")
 S BQIY=$$LKP^BQIGPUTL(YEAR)
 D GFN^BQIGPUTL(BQIH,BQIY)
 S BQIINDG=$$ROOT^DILFD(BQIINDF,"",1)
 S BQIMEASG=$$ROOT^DILFD(BQIMEASF,"",1)
 S VER=$$VERSION^XPDUTL("BGP")
 ;
 S MSIEN=""
 F  S MSIEN=$O(^BQI(90506.1,"AC","G",MSIEN)) Q:MSIEN=""  D
 . I $P(^BQI(90506.1,MSIEN,0),U,10)=1 Q
 . D INIT(.VER,.MSIEN)
 ;
 S DFN=0
 F  S DFN=$O(^BQICARE(OWNR,1,PLIEN,40,DFN)) Q:'DFN  D RPT(.VER)
 ;
 NEW DA,IENS
 S DA(1)=OWNR,DA=PLIEN,IENS=$$IENS^DILF(.DA)
 S TOTP=$$GET1^DIQ(90505.01,IENS,.1,"E")
 ;
 S CAT=""
 F  S CAT=$O(@TDATA@(CAT)) Q:CAT=""  D
 . S CLIN=""
 . F  S CLIN=$O(@TDATA@(CAT,CLIN)) Q:CLIN=""  D
 .. S TIT=""
 .. F  S TIT=$O(@TDATA@(CAT,CLIN,TIT)) Q:TIT=""  D
 ... S BQIEN=""
 ... F  S BQIEN=$O(@TDATA@(CAT,CLIN,TIT,BQIEN)) Q:BQIEN=""  D
 .... S GDATA=@TDATA@(CAT,CLIN,TIT,BQIEN)
 .... S GNUM=$G(@TDATA@(CAT,CLIN,TIT,BQIEN,"NUM"))
 .... S GDEN=$G(@TDATA@(CAT,CLIN,TIT,BQIEN,"DEN"))
 .... D DEF(GDATA,GNUM,GDEN)
 ;
DONE S II=II+1,@DATA@(II)=$C(31)
 K @TDATA
 Q
 ;
DEF(GDATA,GNUM,GDEN) ;
 S BQICAT=$P(GDATA,"^",1)
 S BQICLN=$P(GDATA,"^",2)
 S BQMEAS=$P(GDATA,"^",3)
 S MDESC=$P(GDATA,"^",4)
 ;S TWTEN=$P(GDATA,"^",5)
 S NCURR=$P(GDATA,"^",5)
 S YCURR=$P(GDATA,"^",6)
 S RPERIOD=$P(GDATA,"^",7) S:RPERIOD="" RPERIOD=$G(TPERIOD)
 S VALUE=$P(GDATA,"^",8)
 S NAFLG=$P(GDATA,"^",9)
 S GOAL=$P(GDATA,"^",10)
 ;
 S NUM=+$G(GNUM)
 S DEN=+$G(GDEN)
 I DEN=0 S PER=-1
 I NUM=0,DEN'=0 S PER=0
 ;I NUM=0,DEN=0 S PER=0
 I NUM=0,DEN=0 S PER=-1
 I NAFLG=1,PER=0 S PER=-1
 I NUM'=0,DEN'=0 S PER=(NUM/DEN)*100,PER=$J(PER,3,1)
 I NAFLG=1 S DEN="-"
 S II=II+1,@DATA@(II)=RPERIOD_U_TOTP_U_BQICAT_U_BQICLN_U_BQMEAS_U_NCURR_U_YCURR_U_MDESC_U_NUM_U_DEN_U_PER_U_GOAL_$C(30)
 Q
 ;
RPT(VER) ;  Get the CRS Clinical Performance information
 ;  If patient is 'removed', don't include
 I $P($G(^BQICARE(OWNR,1,PLIEN,40,DFN,0)),"^",2)="R" Q
 ;
 S BQIND=0
 F  S BQIND=$O(^BQIPAT(DFN,30,BQIND)) Q:'BQIND  D
 . S BQMEAS=$P(^BQIPAT(DFN,30,BQIND,0),U,1),VALUE=$P(^(0),U,2),NUM=$P(^(0),U,3),DEN=$P(^(0),U,4)
 . S MSIEN=$O(^BQI(90506.1,"B",BQMEAS,"")) I MSIEN="" Q
 . I $P(^BQI(90506.1,MSIEN,0),U,10)=1 Q
 . S TITLE=$P(^BQI(90506.1,MSIEN,0),U,3)
 . S CAT=$$GET1^DIQ(90506.1,MSIEN_",",3.03,"E")
 . S CLIN=$$GET1^DIQ(90506.1,MSIEN_",",3.02,"E")
 . S BQCODE=BQMEAS,BMEAS=$P(BQMEAS,"_",2)
 . ;
 . S BQIYR=$P($G(^BQIPAT(DFN,0)),U,2)
 . S FDT=$P($G(^BQIPAT(DFN,0)),U,3),TDT=$P($G(^BQIPAT(DFN,0)),U,4)
 . S RPERIOD=$$FMTE^XLFDT(FDT,1)_"-"_$$FMTE^XLFDT(TDT,1)
 . ;
 . S SUM=$$GET1^DIQ(BQIMEASF,BMEAS_",",1706,"I")
 . S IPC=$$GET1^DIQ(BQIMEASF,BMEAS_",",1707,"I")
 . I IPC=1,$$CIPC^BQIIPCUT(BQCODE) D
 .. S CAT="IPC",CLIN=$$CLIN^BQIIPCUT(BQCODE)
 .. I CLIN="" S CLIN=$$GET1^DIQ(90506.1,MSIEN_",",3.02,"E")
 . S @TDATA@(CAT,CLIN,TITLE,MSIEN,"NUM")=$G(@TDATA@(CAT,CLIN,TITLE,MSIEN,"NUM"))+NUM
 . S @TDATA@(CAT,CLIN,TITLE,MSIEN,"DEN")=$G(@TDATA@(CAT,CLIN,TITLE,MSIEN,"DEN"))+DEN
 . S $P(@TDATA@(CAT,CLIN,TITLE,MSIEN),U,8)=RPERIOD S:RPERIOD'="" TPERIOD=RPERIOD
 . S $P(@TDATA@(CAT,CLIN,TITLE,MSIEN),U,9)=VALUE
 . K IPC
 Q
 ;
ERR ;
 D ^%ZTER
 NEW Y,ERRDTM
 S Y=$$NOW^XLFDT() X ^DD("DD") S ERRDTM=Y
 S BMXSEC="Recording that an error occurred at "_ERRDTM
 I $D(II),$D(DATA) S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
INIT(VER,MSIEN) ; Initialize array
 S BQMEAS=$P(^BQI(90506.1,MSIEN,0),U,1),TITLE=$P(^(0),U,3)
 S BQCODE=BQMEAS,BQMEAS=$P(BQMEAS,"_",2)
 ;
 S ORDER=TITLE
 S NAFLG=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1704,"I")
 S NAFLG=$S(NAFLG="Y":1,1:0)
 S SUM=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1706,"I")
 S IPC=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1707,"I")
 ;
 S TWTEN=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1403,"E")
 I TWTEN="" S TWTEN=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1503,"E")
 S NCURR=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1402,"E")
 I NCURR="" S NCURR=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1502,"E")
 S NCURR=$$STRIP^XLFSTR(NCURR," @#&!")
 S YCURR=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1408,"E")
 I YCURR="" S YCURR=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1508,"E")
 ;
 S GOAL=""
 I $$VERSION^XPDUTL("BGP")>11 D
 . S GOAL=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1403,"E")
 . I GOAL="" S GOAL=$$GET1^DIQ(BQIMEASF,BQMEAS_",",1903,"E")
 ;
 S CAT=$$GET1^DIQ(90506.1,MSIEN_",",3.03,"E")
 S CLIN=$$GET1^DIQ(90506.1,MSIEN_",",3.02,"E")
 I IPC=1,$$CIPC^BQIIPCUT(BQCODE) D
 . S CAT="IPC",CLIN=$$CLIN^BQIIPCUT(BQCODE)
 . I CLIN="" S CLIN=$$GET1^DIQ(90506.1,MSIEN_",",3.02,"E")
 ;
 S RPERIOD="",VALUE=""
 ;
 S @TDATA@(CAT,CLIN,TITLE,MSIEN)=CAT_U_CLIN_U_MSIEN_U_TITLE_U_NCURR_U_YCURR_U_RPERIOD_U_VALUE_U_NAFLG_U_GOAL
 Q