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

BQIMUDCQ.m

Go to the documentation of this file.
BQIMUDCQ ;GDIT/HS/ALA-MU Clin Qual by Division ; 21 Nov 2012  3:56 PM
 ;;2.3;ICARE MANAGEMENT SYSTEM;**3,4**;Apr 18, 2012;Build 66
 ;
PROV(DATA,TMFRAME,PERIOD,PROV,CNT,DIV) ;EP -- BQI MU GET PROV CQM
 NEW UID,II,HDR,C1,C2,C3,C4,NAME,HEAD,HX,PEC,SORT,QFL,PCT,CT,DDATA,CPER,PPER
 NEW BJ,BQCDAR,BQDTM,BQPDAR,CRDT,CURDT,CYR,ID,MSN,NYR,PRDT,PYR,QQF
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIMUPCQM",UID))
 K @DATA
 S DIV=$G(DIV,"")
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIMUDCQ D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 D GTM^BQIMUTIM
 ;
 S HDR="T00050PROVIDER^T00035HIDE_PROV_SORT^T00030HIDE_CURR_PERIOD^T00030HIDE_PREV_PERIOD^"
 S HX=0,PEC=5
 F  S HX=$O(^BGPMUIND(90596.11,HX)) Q:'HX  D
 . S MSN=$P(^BGPMUIND(90596.11,HX,0),U,1)
 . I $G(^BGPMUIND(90595.11,MSN,0))="" Q
 . I $P(^BGPMUIND(90595.11,MSN,0),U,4)'="H" D
 .. S HDR=HDR_"T00005"_$P(^BGPMUIND(90596.11,HX,0),U,4)_"_CURR^T00005"_$P(^BGPMUIND(90596.11,HX,0),U,4)_"_PREV^"
 .. S HEAD($P(^BGPMUIND(90596.11,HX,0),U,4))=PEC,PEC=PEC+2
 S @DATA@(II)=HDR_"T00020HIDE_LAST_PROV"_$C(30)
 S (C1,C2,C3,C4,CT,PCT)=0
 S PROV=$G(PROV,"")
 I PROV="" S PROV=+PROV
 I PROV'="" D
 . S C1=+$P(PROV,":",2),C2=+$P(PROV,":",3),C3=+$P(PROV,":",4),C4=+$P(PROV,":",5),CT=+$P(PROV,":",6)
 . S PROV=$P(PROV,":",1)
 S CNT=$G(CNT,0),QFL=0,QQF=0
 I CT=0 D
 . I '$D(^BQIPROV(DUZ)) Q
 . I '$D(^BQI(90508,1,14,"B",DUZ)) Q
 . I $G(DIV)'="",'$D(^VA(200,DUZ,2,"B",DIV)) Q
 . I $D(^BQIPROV(DUZ)) D PFND(DUZ) D
 .. I QQF S QQF=0 Q
 .. S @DATA@(II)=@DATA@(II)_U_PROV_":"_C1_":"_C2_":"_C3_":"_C4_":"_CT_$C(30)
 .. F BJ=3:1:$L(@DATA@(II),U) I $P(@DATA@(II),U,BJ)="" S $P(@DATA@(II),U,BJ)="NDA"
 ;
 F  S PROV=$O(^BQIPROV(PROV)) Q:'PROV  D  Q:QFL
 . I PROV=DUZ Q
 . I '$D(^BQI(90508,1,14,"B",PROV)) Q
 . I $G(DIV)'="",'$D(^VA(200,PROV,2,"B",DIV)) Q
 . I PROV'=DUZ D PFND(PROV) D
 .. I QQF S QQF=0 Q
 .. S @DATA@(II)=@DATA@(II)_U_PROV_":"_C1_":"_C2_":"_C3_":"_C4_":"_CT_$C(30)
 .. F BJ=3:1:$L(@DATA@(II),U) I $P(@DATA@(II),U,BJ)="" S $P(@DATA@(II),U,BJ)="NDA"
 .. I CNT'=0,PCT=CNT S QFL=1
DONE ;
 S II=II+1,@DATA@(II)=$C(31)
 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
 ;
NAM ;EP
 S C1=C1+1 S:C1=27 C2=C2+1,C1=1 S:C2=27 C3=C3+1,C2=1,C1=1 S:C3=27 C4=C4+1,C3=1,C2=1,C1=1 S NAME="PROVIDER "_$S(C4>0:$C(C4+64),1:"")_$S(C3>0:$C(C3+64),1:"")_$S(C2>0:$C(C2+64),1:"")_$S(C1>0:$C(C1+64),1:"")
 Q
 ;
PFND(PRV) ; Find data
 NEW DATE,FAC,MN,MDATA,PRVR,CFROM,CTHRU,PFROM,PTHRU,IDN,CDEN,CNUM,CEXC,PDEN
 NEW PNUM,PEXC,CURR,PREV,SORT,USN,TYPE,DDATA,CQN,PQN,PDATA,CDATA
 ;
 S CT=CT+1,PCT=PCT+1
 I DUZ=PRV S PRVR=PRV_$C(28)_$P($G(^VA(200,PRV,0)),U,1),SORT=1_"_"_$P($G(^VA(200,PRV,0)),U,1)
 I '$D(^XUSEC("BQIZMUMGR",DUZ)),'$D(^XUSEC("BQIZMGR",DUZ)) D
 . I DUZ'=PRV D NAM S PRVR=PRV_$C(28)_NAME,SORT=2_"_"_NAME
 I $D(^XUSEC("BQIZMUMGR",DUZ))!($D(^XUSEC("BQIZMGR",DUZ))) D
 . I DUZ'=PRV S PRVR=PRV_$C(28)_$P($G(^VA(200,PRV,0)),U,1),SORT=1_"_"_$P($G(^VA(200,PRV,0)),U,1)
 S DDATA=$G(^BQIPROV(PRV,1))
 ;
 S II=II+1,@DATA@(II)=PRVR_U_SORT_U_CPER_U_PPER_U
 ;
 K BQCURR,BQPREV
 S CRDT=""
 F  S CRDT=$O(BQCDAR(CRDT)) Q:CRDT=""  D
 . S CQN=$O(^BQIPROV(PRV,50,"B",CRDT,""))
 . D CAGG
 ;
 S PRDT=""
 F  S PRDT=$O(BQPDAR(PRDT)) Q:PRDT=""  D
 . S PQN=$O(^BQIPROV(PRV,50,"B",PRDT,""))
 . D PAGG
 ;
 S HX=""
 F  S HX=$O(HEAD(HX)) Q:HX=""  D
 . S ID=HX,PEC=$G(HEAD(ID)) I PEC="" Q
 . S CDEN=$P($G(BQCURR(ID)),U,1),CNUM=$P($G(BQCURR(ID)),U,2),CEXC=$P($G(BQCURR(ID)),U,3)
 . I +CNUM=0 S CURR="0%"
 . I +CDEN'=0,+CNUM'=0 S CURR=(CNUM/CDEN)*100,CURR=$J(CURR,3,0)_"%",CURR=$$TRIM^BQIUL1(CURR," ")
 . I CDEN="",CNUM="",CEXC'="" S CURR="Excluded"
 . I CDEN="",CNUM="",CEXC="" S CURR=""
 . S PDEN=$P($G(BQPREV(ID)),U,1),PNUM=$P($G(BQPREV(ID)),U,2),PEXC=$P($G(BQPREV(ID)),U,3)
 . I +PNUM=0 S PREV="0%"
 . I +PDEN'=0,+PNUM'=0 S PREV=$J((PNUM/PDEN)*100,3,0)_"%",PREV=$$TRIM^BQIUL1(PREV," ")
 . I PDEN="",PNUM="",PEXC'="" S PREV="Excluded"
 . I PDEN="",PNUM="",PEXC="" S PREV=""
 . S $P(@DATA@(II),U,PEC)=CURR
 . S $P(@DATA@(II),U,PEC+1)=PREV
 K BQCURR,BQPREV
 ;
 Q
 ;
CAGG ; Aggregate
 NEW ID
 S ID=""
 F  S ID=$O(HEAD(ID)) Q:ID=""  D
 . S BQCURR(ID)=$S(CQN="":"NDA",'$D(^BQIPROV(PRV,50,CQN,1)):"NDA",1:"N/A")
 ;
 I CQN="" Q
 S IDN=0
 F  S IDN=$O(^BQIPROV(PRV,50,CQN,1,IDN)) Q:'IDN  D
 . S (CDEN,CNUM,CEXC,CURR)=""
 . S CDATA=^BQIPROV(PRV,50,CQN,1,IDN,0)
 . S CDEN=$P(CDATA,U,2),CNUM=$P(CDATA,U,3),CEXC=$P(CDATA,U,4)
 . S ID=$P(CDATA,U,1)
 . S $P(BQCURR(ID),U,1)=$P($G(BQCURR(ID)),U,1)+CDEN
 . S $P(BQCURR(ID),U,2)=$P($G(BQCURR(ID)),U,2)+CNUM
 . S $P(BQCURR(ID),U,3)=$P($G(BQCURR(ID)),U,3)+CEXC
 Q
 ;
PAGG ; Aggregate
 NEW ID
 S ID=""
 F  S ID=$O(HEAD(ID)) Q:ID=""  D
 . S BQPREV(ID)=$S(PQN="":"NDA",'$D(^BQIPROV(PRV,50,PQN,1)):"NDA",1:"N/A")
 ;
 I PQN="" Q
 S IDN=0
 F  S IDN=$O(^BQIPROV(PRV,50,PQN,1,IDN)) Q:'IDN  D
 . S (PDEN,PNUM,PEXC,PREV)=""
 . S PDATA=^BQIPROV(PRV,50,PQN,1,IDN,0)
 . S PDEN=$P(PDATA,U,2),PNUM=$P(PDATA,U,3),PEXC=$P(PDATA,U,4)
 . S ID=$P(PDATA,U,1)
 . S $P(BQPREV(ID),U,1)=$P($G(BQPREV(ID)),U,1)+PDEN
 . S $P(BQPREV(ID),U,2)=$P($G(BQPREV(ID)),U,2)+PNUM
 . S $P(BQPREV(ID),U,3)=$P($G(BQPREV(ID)),U,3)+PEXC
 Q
 ;
HOV(DATA,TMFRAME,PERIOD,PROV,CNT,DIV) ;EP -- BQI MU GET PROV CQM HOVER
 NEW UID,II,HDR,C1,C2,C3,C4,NAME,HEAD,HX,PEC,SORT,QFL,PCT,CT,DDATA,CPER,PPER
 NEW BJ,BQCDAR,BQDTM,BQPDAR,CRDT,CURDT,CYR,ID,MSN,NYR,PRDT,PYR,QQF
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIMUDCQH",UID))
 K @DATA
 S DIV=$G(DIV,"")
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIMUPRV D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 D GTM^BQIMUTIM
 S HDR="T00050PROVIDER^T00035HIDE_PROV_SORT^T00030HIDE_CURR_PERIOD^T00030HIDE_PREV_PERIOD^"
 S HX=0,PEC=5
 F  S HX=$O(^BGPMUIND(90596.11,HX)) Q:'HX  D
 . S MSN=$P(^BGPMUIND(90596.11,HX,0),U,1)
 . I $G(^BGPMUIND(90595.11,MSN,0))="" Q
 . I $P(^BGPMUIND(90595.11,MSN,0),U,4)'="H" D
 .. S HDR=HDR_"T00005"_$P(^BGPMUIND(90596.11,HX,0),U,4)_"_CURR^T00005"_$P(^BGPMUIND(90596.11,HX,0),U,4)_"_PREV^"
 .. ;S HDR=HDR_"T00005CURR_"_$P(^BGPMUIND(90595.11,HX,0),U,1)_"^T00005PREV"_$P(^BGPMUIND(90595.11,HX,0),U,1)_"^"
 .. S HEAD($P(^BGPMUIND(90596.11,HX,0),U,4))=PEC,PEC=PEC+2
 S @DATA@(II)=HDR_"T00020HIDE_LAST_PROV"_$C(30)
 S (C1,C2,C3,C4,CT,PCT)=0
 S PROV=$G(PROV,"")
 I PROV="" S PROV=+PROV
 I PROV'="" D
 . S C1=+$P(PROV,":",2),C2=+$P(PROV,":",3),C3=+$P(PROV,":",4),C4=+$P(PROV,":",5),CT=+$P(PROV,":",6)
 . S PROV=$P(PROV,":",1)
 S CNT=$G(CNT,0),QFL=0,QQF=0
 I CT=0 D
 . I '$D(^BQIPROV(DUZ)) Q
 . I '$D(^BQI(90508,1,14,"B",DUZ)) Q
 . I $G(DIV)'="",'$D(^VA(200,DUZ,2,"B",DIV)) Q
 . I $D(^BQIPROV(DUZ)) D FND(DUZ) D
 .. I QQF S QQF=0 Q
 .. S @DATA@(II)=@DATA@(II)_U_PROV_":"_C1_":"_C2_":"_C3_":"_C4_":"_CT_$C(30)
 .. F BJ=3:1:$L(@DATA@(II),U) I $P(@DATA@(II),U,BJ)="" S $P(@DATA@(II),U,BJ)="No Data Available"
 ;
 F  S PROV=$O(^BQIPROV(PROV)) Q:'PROV  D  Q:QFL
 . I PROV=DUZ Q
 . I '$D(^BQI(90508,1,14,"B",PROV)) Q
 . I $G(DIV)'="",'$D(^VA(200,PROV,2,"B",DIV)) Q
 . I PROV'=DUZ D FND(PROV) D
 .. I QQF S QQF=0 Q
 .. S @DATA@(II)=@DATA@(II)_U_PROV_":"_C1_":"_C2_":"_C3_":"_C4_":"_CT_$C(30)
 .. F BJ=3:1:$L(@DATA@(II),U) I $P(@DATA@(II),U,BJ)="" S $P(@DATA@(II),U,BJ)="No Data Available"
 .. I CNT'=0,PCT=CNT S QFL=1
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
FND(PRV) ; Find data
 NEW DATE,FAC,MN,MDATA,PRVR,CFROM,CTHRU,PFROM,PTHRU,IDN,CDEN,CNUM,CEXC,PDEN
 NEW PNUM,PEXC,CURR,PREV,SORT,USN,TYPE,CQN,PQN
 S CT=CT+1,PCT=PCT+1
 I DUZ=PRV S PRVR=PRV,SORT=""
 I '$D(^XUSEC("BQIZMUMGR",DUZ)),'$D(^XUSEC("BQIZMGR",DUZ)) D
 . I DUZ'=PRV D NAM S PRVR=PRV,SORT=""
 I $D(^XUSEC("BQIZMUMGR",DUZ))!($D(^XUSEC("BQIZMGR",DUZ))) D
 . I DUZ'=PRV S PRVR=PRV,SORT=""
 S II=II+1,@DATA@(II)=PRVR_U_SORT_U_CPER_U_PPER_U
 ;
 K BQCURR,BQPREV
 S CRDT=""
 F  S CRDT=$O(BQCDAR(CRDT)) Q:CRDT=""  D
 . S CQN=$O(^BQIPROV(PRV,50,"B",CRDT,""))
 . D CAGG
 ;
 S PRDT=""
 F  S PRDT=$O(BQPDAR(PRDT)) Q:PRDT=""  D
 . S PQN=$O(^BQIPROV(PRV,50,"B",PRDT,""))
 . D PAGG
 ;
 K BQCURR,BQPREV
 S CRDT=""
 F  S CRDT=$O(BQCDAR(CRDT)) Q:CRDT=""  D
 . S CQN=$O(^BQIPROV(PRV,50,"B",CRDT,""))
 . D CAGG
 ;
 S PRDT=""
 F  S PRDT=$O(BQPDAR(PRDT)) Q:PRDT=""  D
 . S PQN=$O(^BQIPROV(PRV,50,"B",PRDT,""))
 . D PAGG
 ;
 S HX=""
 F  S HX=$O(HEAD(HX)) Q:HX=""  D
 . S ID=HX,PEC=$G(HEAD(ID)) I PEC="" Q
 . S CDEN=$P($G(BQCURR(ID)),U,1),CNUM=$P($G(BQCURR(ID)),U,2),CEXC=$P($G(BQCURR(ID)),U,3)
 . I +CNUM=0 S CURR="Not Applicable"
 . I +CDEN'=0 S CURR="Numerator: "_+CNUM_" Denominator: "_CDEN
 . I CDEN="",CNUM="",CEXC'="" S CURR="Excluded"
 . I CDEN="",CNUM="",CEXC="" S CURR="Not Applicable"
 . S PDEN=$P($G(BQPREV(ID)),U,1),PNUM=$P($G(BQPREV(ID)),U,2),PEXC=$P($G(BQPREV(ID)),U,3)
 . I +PNUM=0 S PREV="Not Applicable"
 . I +PDEN'=0 S PREV="Numerator: "_+PNUM_" Denominator: "_PDEN
 . I PDEN="",PNUM="",PEXC'="" S PREV=PEXC
 . I PDEN="",PNUM="",PEXC="" S PREV="Not Applicable"
 . S $P(@DATA@(II),U,PEC)=CURR
 . S $P(@DATA@(II),U,PEC+1)=PREV
 K BQCURR,BQPREV
 Q
 ;
CQM ;EP - Update BQIFAC for CQ data already processed
 NEW PRV
 S PRV=0
 F  S PRV=$O(^BQIPROV(PRV)) Q:'PRV  D
 . S DN=0
 . F  S DN=$O(^BQIPROV(PRV,50,DN)) Q:'DN  D
 .. S MN=0
 .. F  S MN=$O(^BQIPROV(PRV,50,DN,1,MN)) Q:'MN  D
 ... S BQDATE=$P(^BQIPROV(PRV,50,DN,0),"^",1)
 ... S MDATA=^BQIPROV(PRV,50,DN,1,MN,0)
 ... S ID=$P(MDATA,"^",1),CDEN=$P(MDATA,"^",2),CNUM=$P(MDATA,"^",3),CEXC=$P(MDATA,"^",4)
 ... S DV=0
 ... F  S DV=$O(^VA(200,PRV,2,DV)) Q:'DV  D
 .... I $G(^BQIFAC(DV,0))="" S ^BQIFAC(DV,0)=DV,^BQIFAC("B",DV,DV)=""
 .... S FAC=DV D UPD
 .... S VN=$O(^BQIFAC(DV,80,BQTMN,1,"B",ID,"")) I VN="" S VN=MN,^BQIFAC(DV,80,BQTMN,1,0)="^90505.681^"_VN_U_VN
 .... I $G(^BQIFAC(DV,80,BQTMN,1,VN,0))="" S ^BQIFAC(DV,80,BQTMN,1,VN,0)=ID,^BQIFAC(DV,80,BQTMN,1,"B",ID,VN)=""
 .... S $P(^BQIFAC(DV,80,BQTMN,1,VN,0),U,2)=$P($G(^BQIFAC(DV,80,BQTMN,1,VN,0)),U,2)+$G(CDEN)
 .... S $P(^BQIFAC(DV,80,BQTMN,1,VN,0),U,3)=$P($G(^BQIFAC(DV,80,BQTMN,1,VN,0)),U,3)+$G(CNUM)
 .... S $P(^BQIFAC(DV,80,BQTMN,1,VN,0),U,3)=$P($G(^BQIFAC(DV,80,BQTMN,1,VN,0)),U,4)+$G(CEXC)
 Q
 ;
UPD ;EP
 I $G(^BQIFAC(FAC,80,0))="" S ^BQIFAC(FAC,80,0)="^90505.68D^^"
 ;
 NEW DA,X,IENS,Y,DIC,DLAYGO
 S DA(1)=FAC,DIC="^BQIFAC("_DA(1)_",80,",X=BQDATE,DIC(0)="LNZ",DLAYGO=90505.68,DIC("P")=DLAYGO
 D ^DIC
 S DA=+Y I DA=-1 Q
 S BQTMN=DA
 Q