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

BQIRMAGG.m

Go to the documentation of this file.
BQIRMAGG ;PRXM/HC/ALA-Reminders Aggregate ; 16 Mar 2007  4:11 PM
 ;;2.2;ICARE MANAGEMENT SYSTEM;;Jul 28, 2011;Build 37
 ;
 Q
 ;
EN(DATA,OWNR,PLIEN) ;EP -- BQI GET REMINDERS AGGREGATE
 ;Description - Entry point for the panel
 NEW UID,II,DFN,AGGREG,REM,PRCUR,PROVR,RCAT,RCLIN,REMNM,RMCODE,NREMNM
 NEW RIEN,GRDT
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIRMAGG",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIRMAGG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="I00010MEAS_IEN^T00030CATEGORY^T00030CLIN_GROUP^T00050REMINDER^T00015CODE^I00010PATS_ELIGIBLE^I00010PAT_CURRENT^N00010PER_CURRENT^I00010PAT_OVERDUE^N00010PER_OVERDUE"_$C(30)
 S DFN=0,GRDT=$$DATE^BQIUL1("T-30")
 F  S DFN=$O(^BQICARE(OWNR,1,PLIEN,40,DFN)) Q:'DFN  D RPT
 ;
 S REMNM=""
 F  S REMNM=$O(AGGREG(REMNM)) Q:REMNM=""  D
 . S RMCODE=""
 . F  S RMCODE=$O(AGGREG(REMNM,RMCODE)) Q:RMCODE=""  D
 .. ;S PRCUR=$J(($P(AGGREG(REMNM,RMCODE),U,2)/$P(AGGREG(REMNM,RMCODE),U,1))*100,3,1)_"%"
 .. S PRCUR=$J(($P(AGGREG(REMNM,RMCODE),U,2)/$P(AGGREG(REMNM,RMCODE),U,1))*100,3,1)
 .. ;S PROVR=$J(($P(AGGREG(REMNM,RMCODE),U,3)/$P(AGGREG(REMNM,RMCODE),U,1))*100,3,1)_"%"
 .. S PROVR=$J(($P(AGGREG(REMNM,RMCODE),U,3)/$P(AGGREG(REMNM,RMCODE),U,1))*100,3,1)
 .. S RIEN=$$FIND1^DIC(90506.1,"","X",RMCODE,"B","","ERROR")
 .. ;S RCAT=$$GET1^DIQ(90506.1,RIEN_",",2.03,"E")
 .. ;S RCLIN=$$GET1^DIQ(90506.1,RIEN_",",2.05,"E")
 .. S RCAT=$$GET1^DIQ(90506.1,RIEN_",",3.03,"E")
 .. S RCLIN=$$GET1^DIQ(90506.1,RIEN_",",3.02,"E")
 .. I REMNM'?.U S NREMNM=REMNM
 .. I REMNM?.UP S NREMNM=$$LOWER^VALM1(REMNM)
 .. I NREMNM="Breast Mri" S NREMNM="Breast MRI"
 .. S II=II+1,@DATA@(II)=RIEN_U_RCAT_U_RCLIN_U_NREMNM_U_RMCODE_U_$P(AGGREG(REMNM,RMCODE),U,1)_U_$P(AGGREG(REMNM,RMCODE),U,2)_U_PRCUR_U_$P(AGGREG(REMNM,RMCODE),U,3)_U_PROVR_$C(30)
 ;
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
 ;
RPT ;
 ;  If patient is 'removed', don't include
 I $P($G(^BQICARE(OWNR,1,PLIEN,40,DFN,0)),"^",2)="R" Q
 ;
 NEW RDATA,RIEN,DUE,LAST,CT,PELIG,PCUR,POVR,REM,REMNM,RMCODE,DIEN
 S RIEN=0
 F  S RIEN=$O(^BQIPAT(DFN,40,RIEN)) Q:'RIEN  D
 . S RDATA=^BQIPAT(DFN,40,RIEN,0)
 . S CT=0,PELIG=0,PCUR=0,POVR=0
 . S RMCODE=$P(RDATA,U,1)
 . S DIEN=$O(^BQI(90506.1,"B",RMCODE,"")) Q:DIEN=""
 . ; If it's inactive reminder, quit
 . I $P(^BQI(90506.1,DIEN,0),U,10)=1 Q
 . ; If it's a register reminder, quit
 . ;I $$GET1^DIQ(90506.1,DIEN_",",2.03,"E")="CARE MANAGEMENT" Q
 . I $$GET1^DIQ(90506.1,DIEN_",",3.03,"E")="CARE MANAGEMENT" Q
 . S REMNM=$P(^BQI(90506.1,DIEN,0),U,3)
 . ; NDA patients have no data so CT should be 0
 . F I=2:1:4 S:$P(RDATA,U,I)'="" CT=CT+1
 . I CT=0 Q
 . ; EHR reminders return a N/A
 . I $P(RDATA,U,3)="N/A" Q
 . S PELIG=PELIG+1
 . I CT'=0 D
 .. S DUE=$P(RDATA,U,4),LAST=$P(RDATA,U,2)
 .. I LAST="",DUE="" Q
 .. ;I LAST'="",DUE'="" D
 .. I DUE'="" D
 ... I DUE<GRDT S POVR=POVR+1 Q
 ... ;E  S PCUR=PCUR+1
 ... I DUE>DT S PCUR=PCUR+1
 .. ;I LAST'="",DUE="",LAST<GRDT S POVR=POVR+1
 . S $P(AGGREG(REMNM,RMCODE),U,1)=$P($G(AGGREG(REMNM,RMCODE)),U,1)+PELIG
 . S $P(AGGREG(REMNM,RMCODE),U,2)=$P($G(AGGREG(REMNM,RMCODE)),U,2)+PCUR
 . S $P(AGGREG(REMNM,RMCODE),U,3)=$P($G(AGGREG(REMNM,RMCODE)),U,3)+POVR
 Q