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

BQIMUDFC.m

Go to the documentation of this file.
BQIMUDFC ;GDIT/HS/ALA-Facility by Division ; 26 Nov 2012  11:07 AM
 ;;2.3;ICARE MANAGEMENT SYSTEM;**3,4**;Apr 18, 2012;Build 66
 ;
PERF(DATA,REPORT,TMFRAME,PERIOD,DIV) ;EP -- BQI MU PERF BY DIVISION
 NEW BQCDAR,BQPDAR,CDATA,CDEN,CEXC,CNUM,CPER,CQN,CRDT,CURDT,CURR,HDR,HEAD,HX,ID,IDN,II,PDATA
 NEW PDEN,PEC,PEXC,PNUM,PPER,PQN,PRDT,PREV,PRVR,SORT,PGLOB
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIMUPRPF",UID))
 K @DATA
 S II=0,SORT=""
 S DIV=$G(DIV,""),REPORT=$G(REPORT,"")
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIMUPRV D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 D GTM^BQIMUTIM
 ;
 S HDR="T00050FACILITY^T00030HIDE_CURR_PERIOD^T00030HIDE_PREV_PERIOD^"
 S PGLOB=$$PRFPGL^BQIMUTAB(REPORT)
 S HX=0,PEC=4
 F  S HX=$O(@PGLOB@(HX)) Q:'HX  I $P(@PGLOB@(HX,0),U,2)="E" D
 . I $P(@PGLOB@(HX,0),U,6)'="R" Q
 . S HDR=HDR_"T00005"_$P(@PGLOB@(HX,0),U,1)_"_CURR^T00005"_$P(@PGLOB@(HX,0),U,1)_"_PREV^"
 . S HEAD($P(@PGLOB@(HX,0),U,1))=PEC,PEC=PEC+2
 S @DATA@(II)=$$TKO^BQIUL1(HDR,"^")_$C(30)
 ;
 I $G(DIV)'="" D RPF
 I $G(DIV)="" S DIV=0 D
 . F  S DIV=$O(^BQIFAC(DIV)) Q:'DIV  D RPF
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
CQM(DATA,TMFRAME,PERIOD,DIV) ;EP -- BQI MU CQM BY DIVISION
 NEW BQCDAR,BQPDAR,CDATA,CDEN,CEXC,CNUM,CPER,CQN,CRDT,CURDT,CURR,HDR,HEAD,HX,ID,IDN,II,PDATA
 NEW PDEN,PEC,PEXC,PNUM,PPER,PQN,PRDT,PREV,PRVR,SORT,MSN
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIMUFCQM",UID))
 K @DATA
 S DIV=$G(DIV,"")
 S II=0,SORT=""
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIMUDFC D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 D GTM^BQIMUTIM
 S HDR="T00050FACILITY^T00030HIDE_CURR_PERIOD^T00030HIDE_PREV_PERIOD^"
 S HX=0,PEC=4
 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)=$$TKO^BQIUL1(HDR,"^")_$C(30)
 ;
 I $G(DIV)'="" D RCQ
 I $G(DIV)="" S DIV=0 D
 . F  S DIV=$O(^BQIFAC(DIV)) Q:'DIV  D RCQ
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
RCQ ;
 S PRVR=DIV_$C(28)_$P(^DIC(4,DIV,0),U,1)
 S II=II+1,@DATA@(II)=PRVR_U_CPER_U_PPER_U
 K BQCURR,BQPREV
 S CRDT=""
 F  S CRDT=$O(BQCDAR(CRDT)) Q:CRDT=""  D
 . S CQN=$O(^BQIFAC(DIV,80,"B",CRDT,""))
 . D CAGG
 ;
 S PRDT=""
 F  S PRDT=$O(BQPDAR(PRDT)) Q:PRDT=""  D
 . S PQN=$O(^BQIFAC(DIV,80,"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
 S @DATA@(II)=@DATA@(II)_$C(30)
 K BQCURR,BQPREV
 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
 ;
CAGG ; Aggregate
 NEW ID
 S ID=""
 F  S ID=$O(HEAD(ID)) Q:ID=""  D
 . S BQCURR(ID)=$S(CQN="":"NDA",'$D(^BQIFAC(DIV,80,CQN,1)):"NDA",1:"N/A")
 ;
 I CQN="" Q
 S IDN=0
 F  S IDN=$O(^BQIFAC(DIV,80,CQN,1,IDN)) Q:'IDN  D
 . S (CDEN,CNUM,CEXC,CURR)=""
 . S CDATA=^BQIFAC(DIV,80,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(^BQIFAC(DIV,80,PQN,1)):"NDA",1:"N/A")
 ;
 I PQN="" Q
 S IDN=0
 F  S IDN=$O(^BQIFAC(DIV,80,PQN,1,IDN)) Q:'IDN  D
 . S (PDEN,PNUM,PEXC,PREV)=""
 . S PDATA=^BQIFAC(DIV,80,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
 ;
RPF ;
 S PRVR=DIV_$C(28)_$P(^DIC(4,DIV,0),U,1)
 S II=II+1,@DATA@(II)=PRVR_U_CPER_U_PPER_U
 K BQCURR,BQPREV
 S CRDT=""
 F  S CRDT=$O(BQCDAR(CRDT)) Q:CRDT=""  D
 . S CQN=$O(^BQIFAC(DIV,70,"B",CRDT,""))
 . D CPAGG
 ;
 S PRDT=""
 F  S PRDT=$O(BQPDAR(PRDT)) Q:PRDT=""  D
 . S PQN=$O(^BQIFAC(DIV,70,"B",PRDT,""))
 . D PPAGG
 ;
 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)
 . S 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
 S @DATA@(II)=@DATA@(II)_$C(30)
 K BQCURR,BQPREV
 Q
 ;
CPAGG ; Aggregate performance
 NEW ID
 S ID=""
 F  S ID=$O(HEAD(ID)) Q:ID=""  D
 . S BQCURR(ID)=$S(CQN="":"NDA",'$D(^BQIFAC(DIV,70,CQN,1)):"NDA",1:"N/A")
 ;
 I CQN="" Q
 S IDN=0
 F  S IDN=$O(^BQIFAC(DIV,70,CQN,1,IDN)) Q:'IDN  D
 . S (CDEN,CNUM,CEXC,CURR)=""
 . S CDATA=^BQIFAC(DIV,70,CQN,1,IDN,0)
 . S CEXC=$G(^BQIFAC(DIV,70,CQN,1,IDN,1))
 . S CDEN=$P(CDATA,U,2),CNUM=$P(CDATA,U,3)
 . S ID=$P(CDATA,U,1)
 . I CDEN="",CEXC'="" S $P(BQICURR(ID),U,3)=CEXC Q
 . 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
 Q
 ;
PPAGG ;
 NEW ID
 S ID=""
 F  S ID=$O(HEAD(ID)) Q:ID=""  D
 . S BQPREV(ID)=$S(PQN="":"NDA",'$D(^BQIFAC(DIV,70,PQN,1)):"NDA",1:"N/A")
 ;
 I PQN="" Q
 S IDN=0
 F  S IDN=$O(^BQIFAC(DIV,70,PQN,1,IDN)) Q:'IDN  D
 . S (PDEN,PNUM,PEXC,PREV)=""
 . S PDATA=^BQIFAC(DIV,70,PQN,1,IDN,0)
 . S PEXC=$G(^BQIFAC(DIV,70,PQN,1,IDN,1))
 . S PDEN=$P(PDATA,U,2),PNUM=$P(PDATA,U,3)
 . S ID=$P(PDATA,U,1)
 . I PDEN="",PEXC'="" S $P(BQIPREV(ID),U,3)=PEXC
 . 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
 Q