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

BQIGPRA5.m

Go to the documentation of this file.
BQIGPRA5 ;VNGT/HS/ALA-GPRA Aggregate Call ; 24 Oct 2005  1:11 PM
 ;;2.7;ICARE MANAGEMENT SYSTEM;**1**;Dec 19, 2017;Build 12
 ;
 Q
 ;
AGG(DATA,DIV,COMM) ; EP -- BQI GET GPRA AGG TOTAL
 NEW UID,II,BQI,TDATA
 S DIV=$G(DIV,""),COMM=$G(COMM,"")
 S II=0,BQI=0
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 I DIV="",COMM="" S TDATA=$NA(^XTMP("BQIGPTOT")),DATA=$NA(^TMP("BQIGTOT",UID))
 I DIV="",COMM'="" S TDATA=$NA(^XTMP("BQIGPCOM",COMM)),DATA=$NA(^TMP("BQIGTOT",UID))
 I DIV'="" S TDATA=$NA(^XTMP("BQIGPDIV",DIV)),DATA=$NA(^TMP("BQIGTOT",UID))
 K @DATA
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIGPRA D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 I $G(@TDATA@(II))="" D
 . S @DATA@(BQI)="T00025REPORT_PERIOD^I00010TOTAL_PATIENTS^T00030CATEGORY^T00030CLIN_GROUP^I00010MEAS_IEN^"
 . S @DATA@(BQI)=@DATA@(BQI)_"T00010NATIONAL_CURRENT^T00010YEAR_CURRENT^T00040INDICATOR^I00010NUMERATOR^I00010DENOMINATOR^"
 . S @DATA@(BQI)=@DATA@(BQI)_"N00010PERCENT^T00001EXCEPTION^T00030HP_GOAL_2020"_$C(30)
 . S BQI=BQI+1
 F  S II=$O(@TDATA@(II)) Q:'II  S @DATA@(BQI)=@TDATA@(II),BQI=BQI+1
 ;
DONE ;
 S BQI=BQI+1,@DATA@(BQI)=$C(31)
 Q
 ;
COML(DATA,FAKE) ;EP - BQI GET GPRA COMM LIST
 NEW UID,II,BQI,TDATA
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIGPC",UID)) K @DATA
 S TDATA=$NA(^XTMP("BQIGPCOM"))
 S II=0,BQI=0,HDR="I00010IEN^T00050COMMUNITY"
 S @DATA@(II)=HDR_$C(30)
 F  S BQI=$O(@TDATA@(BQI)) Q:'BQI  D
 . S II=II+1,@DATA@(II)=BQI_U_$P(^AUTTCOM(BQI,0),U,1)_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
COMP ;EP - Compile the CRS Aggregate for entire database
 NEW UID,II,PLID,DFN,TOTP,BQIIND,BQICAT,MDESC,TWTEN,NCURR,NUM,DEN
 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 EXCEPT,GOAL,HDR,DIV,BQDV,DATA,DDATA,DDDATA,TDATA,VDATA,UDATA,IPC
 S DFN=0,II=0
 ;S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S UID=$J
 S DATA=$NA(^XTMP("BQIGPTOT")),TDATA=$NA(^TMP("BQIGTOT",UID))
 S DDATA=$NA(^XTMP("BQIGPDIV")),VDATA=$NA(^TMP("BQIGDIV",UID))
 S DDDATA=$NA(^XTMP("BQIGPCOM")),UDATA=$NA(^TMP("BQIGPCOM",UID))
 K @DATA,@TDATA,@DDATA,@VDATA,@DDDATA,@UDATA
 S @DATA@(II)=$$FMADD^XLFDT(DT,2)_U_$$DT^XLFDT()_U_"CRS Aggregate"
 S @DDATA@(II)=$$FMADD^XLFDT(DT,2)_U_$$DT^XLFDT()_U_"CRS Aggregate by Division"
 S @DDDATA@(II)=$$FMADD^XLFDT(DT,2)_U_$$DT^XLFDT()_U_"CRS Aggregate by Community"
 S II=II+1
 ;
 S @DATA@(II)="T00025REPORT_PERIOD^I00010TOTAL_PATIENTS^T00030CATEGORY^T00030CLIN_GROUP^I00010MEAS_IEN^"
 S @DATA@(II)=@DATA@(II)_"T00010NATIONAL_CURRENT^T00010YEAR_CURRENT^T00040INDICATOR^I00010NUMERATOR^I00010DENOMINATOR^"
 S @DATA@(II)=@DATA@(II)_"N00010PERCENT^T00001EXCEPTION^T00030HP_GOAL_2020"_$C(30)
 S HDR=@DATA@(II)
 ;
 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,TOTP=0
 F  S DFN=$O(^BQIPAT(DFN)) Q:'DFN  D RPT(.VER)
 ;
 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)
 ;
 K @TDATA
 ;
 S DIV=""
 F  S DIV=$O(@VDATA@(DIV)) Q:DIV=""  D
 . S TOTP=0,DFN=""
 . F  S DFN=$O(@VDATA@("TOTP",DIV,DFN)) Q:DFN=""  S TOTP=TOTP+1
 . K @VDATA@("TOTP",DIV)
 . S CAT="",II=1,@VDATA@(DIV,II)=HDR
 . F  S CAT=$O(@VDATA@(DIV,CAT)) Q:CAT=""  D
 .. S CLIN=""
 .. F  S CLIN=$O(@VDATA@(DIV,CAT,CLIN)) Q:CLIN=""  D
 ... S TIT=""
 ... F  S TIT=$O(@VDATA@(DIV,CAT,CLIN,TIT)) Q:TIT=""  D
 .... S BQIEN=""
 .... F  S BQIEN=$O(@VDATA@(DIV,CAT,CLIN,TIT,BQIEN)) Q:BQIEN=""  D
 ..... S GDATA=@VDATA@(DIV,CAT,CLIN,TIT,BQIEN)
 ..... S GNUM=$G(@VDATA@(DIV,CAT,CLIN,TIT,BQIEN,"NUM"))
 ..... S GDEN=$G(@VDATA@(DIV,CAT,CLIN,TIT,BQIEN,"DEN"))
 ..... D DDEF(GDATA,GNUM,GDEN,DIV)
 ;
 K @VDATA
 ;
 S COMM=""
 F  S COMM=$O(@UDATA@(COMM)) Q:COMM=""  D
 . S TOTP=0,DFN=""
 . F  S DFN=$O(@UDATA@("TOTP",COMM,DFN)) Q:DFN=""  S TOTP=TOTP+1
 . K @UDATA@("TOTP",COMM)
 . S CAT="",II=1,@UDATA@(COMM,II)=HDR
 . F  S CAT=$O(@UDATA@(COMM,CAT)) Q:CAT=""  D
 .. S CLIN=""
 .. F  S CLIN=$O(@UDATA@(COMM,CAT,CLIN)) Q:CLIN=""  D
 ... S TIT=""
 ... F  S TIT=$O(@UDATA@(COMM,CAT,CLIN,TIT)) Q:TIT=""  D
 .... S BQIEN=""
 .... F  S BQIEN=$O(@UDATA@(COMM,CAT,CLIN,TIT,BQIEN)) Q:BQIEN=""  D
 ..... S GDATA=@UDATA@(COMM,CAT,CLIN,TIT,BQIEN)
 ..... S GNUM=$G(@UDATA@(COMM,CAT,CLIN,TIT,BQIEN,"NUM"))
 ..... S GDEN=$G(@UDATA@(COMM,CAT,CLIN,TIT,BQIEN,"DEN"))
 ..... D DDDEF(GDATA,GNUM,GDEN,COMM)
 Q
 ;
DEF(GDATA,GNUM,GDEN) ;EP
 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 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 EXCEPT=$S(NAFLG=1:"Y",1:"N")
 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_EXCEPT_U_GOAL_$C(30)
 Q
 ;
DDEF(GDATA,GNUM,GDEN,GDIV) ;
 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 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 EXCEPT=$S(NAFLG=1:"Y",1:"N")
 S II=II+1,@DDATA@(GDIV,II)=RPERIOD_U_TOTP_U_BQICAT_U_BQICLN_U_BQMEAS_U_NCURR_U_YCURR_U_MDESC_U_NUM_U_DEN_U_PER_U_EXCEPT_U_GOAL_$C(30)
 Q
 ;
DDDEF(GDATA,GNUM,GDEN,GCOMM) ;
 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 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 EXCEPT=$S(NAFLG=1:"Y",1:"N")
 S II=II+1,@DDDATA@(GCOMM,II)=RPERIOD_U_TOTP_U_BQICAT_U_BQICLN_U_BQMEAS_U_NCURR_U_YCURR_U_MDESC_U_NUM_U_DEN_U_PER_U_EXCEPT_U_GOAL_$C(30)
 Q
 ;
RPT(VER) ;  Get the CRS Clinical Performance information
 NEW BQIND,BQMEAS,VALUE,NUM,DEN,MSIEN,TITLE,CAT,CLIN,BMEAS,BQIYR,FDT,TDT,RPERIOD,SUM
 NEW BQDV,BQCOMM
 S BQIND=0
 I $O(^BQIPAT(DFN,30,BQIND))'="" S TOTP=TOTP+1
 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 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")
 . I '$D(@TDATA@(CAT,CLIN,TITLE,MSIEN)) D INIT(VER,MSIEN)
 . 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 BQDV=0
 . F  S BQDV=$O(^AUPNPAT(DFN,41,BQDV)) Q:'BQDV  D
 .. I $P($G(^AUPNPAT(DFN,41,BQDV,0)),U,3)'="" Q
 .. I '$D(^BQI(90508,1,25,"B",BQDV)) Q
 .. S @VDATA@(BQDV,CAT,CLIN,TITLE,MSIEN,"NUM")=$G(@VDATA@(BQDV,CAT,CLIN,TITLE,MSIEN,"NUM"))+NUM
 .. S @VDATA@(BQDV,CAT,CLIN,TITLE,MSIEN,"DEN")=$G(@VDATA@(BQDV,CAT,CLIN,TITLE,MSIEN,"DEN"))+DEN
 .. S @VDATA@("TOTP",BQDV,DFN)=""
 .. S $P(@VDATA@(BQDV,CAT,CLIN,TITLE,MSIEN),U,8)=RPERIOD S:RPERIOD'="" TPERIOD=RPERIOD
 . S BQCOMM=$P($G(^AUPNPAT(DFN,11)),U,17) I BQCOMM="" Q
 . S @UDATA@(BQCOMM,CAT,CLIN,TITLE,MSIEN,"NUM")=$G(@UDATA@(BQCOMM,CAT,CLIN,TITLE,MSIEN,"NUM"))+NUM
 . S @UDATA@(BQCOMM,CAT,CLIN,TITLE,MSIEN,"DEN")=$G(@UDATA@(BQCOMM,CAT,CLIN,TITLE,MSIEN,"DEN"))+DEN
 . S @UDATA@("TOTP",BQCOMM,DFN)=""
 . S $P(@UDATA@(BQCOMM,CAT,CLIN,TITLE,MSIEN),U,8)=RPERIOD S:RPERIOD'="" TPERIOD=RPERIOD
 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="",IPC=""
 ;
 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
 S DIV=""
 F  S DIV=$O(^BQI(90508,1,25,"B",DIV)) Q:DIV=""  S @VDATA@(DIV,CAT,CLIN,TITLE,MSIEN)=CAT_U_CLIN_U_MSIEN_U_TITLE_U_NCURR_U_YCURR_U_RPERIOD_U_VALUE_U_NAFLG_U_GOAL
 NEW COMM,DFN,CIEN
 S COMM=""
 F  S COMM=$O(^AUPNPAT("AC",COMM)) Q:COMM=""  D
 . S DFN=""
 . F  S DFN=$O(^AUPNPAT("AC",COMM,DFN)) Q:DFN=""  D
 .. S CIEN=$P($G(^AUPNPAT(DFN,11)),"^",17) I CIEN="" Q
 .. S @UDATA@(CIEN,CAT,CLIN,TITLE,MSIEN)=CAT_U_CLIN_U_MSIEN_U_TITLE_U_NCURR_U_YCURR_U_RPERIOD_U_VALUE_U_NAFLG_U_GOAL
 Q