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

BQIIPPNL.m

Go to the documentation of this file.
BQIIPPNL ;GDIT/HS/ALA-Panel Aggregate ; 09 Sep 2011  12:17 PM
 ;;2.7;ICARE MANAGEMENT SYSTEM;;Dec 19, 2017;Build 23
 ;
 ;
EN(DATA,OWNR,PLIEN,CRIPC,PLIST) ;EP - BQI GET IPC PROV AGG
 ;Description - Entry point for the panel
 ;Input Parameters
 ;  OWNR  - Owner of panel
 ;  PLIEN - Panel IEN
 ;  CRIPC = IPC Version
 ;  PLIST - List of DFNs (optional) 
 NEW UID,II,TDATA,XX,BQIND,BQMEAS,CAT,CODE,DEC,DEN,DFN,IDATA,MET,MSIEN
 NEW NDA,NO,NUM,PROV,PRV,TITLE,TOTP,TYP,VAL,VALUE,XX,YES,GOAL,TNDA,CAT2
 NEW STAB,MSN,NA,TAB,BQIDOD,CNT,DCAT,EXEC,GP,I,ORD,QFL,TAG,CRN
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIIPPRV",UID)) K @DATA
 S TDATA=$NA(^TMP("BQIPRVIP",UID)) K @TDATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIIPPRV D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 ;  get the current IPC definition
 S CRIPC=$G(CRIPC,"")
 I CRIPC="" S CRIPC=$P($G(^BQI(90508,1,11)),U,1)
 S CRN=$O(^BQI(90508,1,22,"B",CRIPC,"")) I CRN="" Q
 S @DATA@(II)="I00010TOTAL_PATIENTS^I00010TOTAL_NDA^T00030CATEGORY^T00030CAT2^T00060TITLE^T00030ID^"
 S @DATA@(II)=@DATA@(II)_"I00010NUMERATOR^I00010DENOMINATOR^I00010DECEASED^T00005PERCENT_MET^T00005PERCENT_GOAL"_$C(30)
 ;
 ; If a list of DFNs, process them instead of entire panel
 I $D(PLIST)>0 D  G DONE
 . I $D(PLIST)>1 D
 .. S LIST="",BN=""
 .. F  S BN=$O(PLIST(BN)) Q:BN=""  S LIST=LIST_PLIST(BN)
 .. K PLIST S PLIST=LIST
 . F BQI=1:1 S DFN=$P(PLIST,$C(28),BQI) Q:DFN=""  D
 .. I $P($G(^BQICARE(OWNR,1,PLIEN,40,DFN,0)),"^",2)="R" Q
 .. D RPT(DFN)
 ;
 S DFN=0
 I $O(^BQICARE(OWNR,1,PLIEN,40,DFN))="" G DONE
 ;
 F  S DFN=$O(^BQICARE(OWNR,1,PLIEN,40,DFN)) Q:'DFN  D
 . I $P($G(^BQICARE(OWNR,1,PLIEN,40,DFN,0)),"^",2)="R" Q
 . D RPT(DFN)
 ;
 S TOTP=$G(@TDATA@("TOTP")),TNDA=0
 S DFN="" F  S DFN=$O(@TDATA@("NDA",DFN)) Q:DFN=""  S TNDA=$G(TNDA)+1
 S ORD=""
 F  S ORD=$O(@TDATA@(ORD)) Q:ORD=""  D
 . S MSN=$O(^BQI(90508,1,22,CRN,1,"C",ORD,"")) Q:MSN=""
 . S IDATA=^BQI(90508,1,22,CRN,1,MSN,0)
 . I $P(IDATA,U,7)=1 Q
 . NEW DA,IENS
 . S DA(2)=1,DA(1)=CRN,DA=MSN,IENS=$$IENS^DILF(.DA)
 . S CAT=$$GET1^DIQ(90508.221,IENS,.03,"E")
 . S CAT2=$$GET1^DIQ(90508.221,IENS,.11,"E")
 . I CRIPC="IPC4/IPC5" D
 .. S CAT=$$GET1^DIQ(90508.221,IENS,.03,"E")
 .. I CAT="" D
 ... S RIEN=$O(^BQI(90506.1,"B",CODE,""))
 ... S CAT=$$GET1^DIQ(90506.1,RIEN_",",3.02,"E")
 .. S CAT2=$$GET1^DIQ(90508.221,IENS,.11,"E")
 . I CRIPC="IPCMH" D
 .. S CAT1=$$GET1^DIQ(90508.221,IENS,.03,"E")
 .. S ICAT=$$GET1^DIQ(90508.221,IENS,.03,"I")
 .. S CAT2=$$GET1^DIQ(90508.221,IENS,.11,"E")
 .. I CAT2="" S CAT2=$$GET1^DIQ(90506.8,ICAT_",",.04,"E")
 .. S CAT=CAT2,CAT2=CAT1
 . S TAB=$$GET1^DIQ(90508.221,IENS,.13,"I")
 . S STAB=$$GET1^DIQ(90508.221,IENS,.14,"I")
 . I TAB="A" Q
 . S CODE=$P(IDATA,U,1),TITLE=$P(IDATA,U,4),GOAL=$P(IDATA,U,12)
 . S NUM=$G(@TDATA@(ORD,"NUM"))
 . S DEN=$G(@TDATA@(ORD,"DEN"))
 . S DEC=$G(@TDATA@(ORD,"DEC"))
 . ;S NDA=$G(@TDATA@(ORD,"NDA"))
 . ;I $P(IDATA,U,5)'="B" S DEN=DEN+NDA
 . I $P(IDATA,U,5)'="B" S DEN=DEN
 . I +DEN=0 S MET="0%"
 . I +DEN'=0,+NUM=0 S MET="0%"
 . I +NUM'=0 S MET=$J((NUM/DEN)*100,3,0),MET=$$TRIM^BQIUL1(MET," ")_"%"
 . S DCAT=CAT
 . I DCAT["_1" S DCAT=$P(CAT,"_1",1)
 . I DCAT["_2" S DCAT=$P(CAT,"_2",1)
 . S II=II+1,@DATA@(II)=TOTP_U_$G(TNDA)_U_DCAT_U_CAT2_U_TITLE_U_CODE_U_NUM_U_DEN_U_DEC_U_MET_U_GOAL_$C(30)
 ; 
DONE ;
 S II=II+1,@DATA@(II)=$C(31)
 K @TDATA
 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(DFN) ;  Get the CRS Clinical Performance information
 I '$$HRN^BQIUL1(DFN) Q
 S PROV=$P($G(^AUPNPAT(DFN,0)),U,14)
 S @TDATA@("TOTP")=$G(@TDATA@("TOTP"))+1
 S ORD=""
 F  S ORD=$O(^BQI(90508,1,22,CRN,1,"C",ORD)) Q:ORD=""  D
 . S MSN=""
 . F  S MSN=$O(^BQI(90508,1,22,CRN,1,"C",ORD,MSN)) Q:MSN=""  D
 .. S IDATA=^BQI(90508,1,22,CRN,1,MSN,0)
 .. S CODE=$P(IDATA,U,1),TYP=$P(IDATA,U,2),TITLE=$P(IDATA,U,4)
 .. ; If inactive, quit
 .. I $P(IDATA,U,7)=1 Q
 .. NEW DA,IENS
 .. S DA(2)=1,DA(1)=CRN,DA=MSN,IENS=$$IENS^DILF(.DA)
 .. S CAT=$$GET1^DIQ(90508.221,IENS,.03,"E")
 .. S MSIEN=$O(^BQI(90506.1,"B",CODE,""))
 .. I CAT="",MSIEN'="" S CAT=$$GET1^DIQ(90506.1,MSIEN_",",3.03,"E")
 .. I CAT="" S CAT="~"
 .. I $P(IDATA,U,5)'="B" S CAT=CAT_"_2"
 .. S BQIDOD=$$GET1^DIQ(2,DFN_",",.351,"I")
 .. I $G(BQIDOD)'="" D  Q
 ... I CAT'["_" S CAT=CAT_"_1"
 ... S @TDATA@(ORD,"DEC")=$G(@TDATA@(ORD,"DEC"))+1
 .. I TYP="R",$P(IDATA,U,5)="B" D
 ... K XX
 ... I CODE="IPC_OUTC" D  Q
 .... I DFN'="" S VAL=$$OPAT^BQIIPOTC(CRN,DFN)
 .... D CK
 ... I CODE["CTRL" D  Q
 .... I DFN'="" S VAL=$$PAT^BQIIPOTC(CRN,DFN,CODE)
 .... D CK
 ... D  Q
 .... D BUN^BQIIPBNL(CRN,MSN,.XX)
 .... I DFN'="" S VAL=$$PAT^BQIIPBNL(DFN,.XX)
 .... D CK
 .. I TYP'="G" Q
 .. S BQIND=$O(^BQIPAT(DFN,30,"B",CODE,"")) I BQIND="" D  Q
 ... S @TDATA@("NDA",DFN)=1
 ... S NDA=1,DEN=0,NUM=0 D STOR(ORD)
 .. 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),NDA=0
 .. ;
 .. D STOR(ORD)
 Q
 ;
STOR(ORD) ;EP
 S @TDATA@(ORD,"NUM")=$G(@TDATA@(ORD,"NUM"))+$G(NUM)
 S @TDATA@(ORD,"DEN")=$G(@TDATA@(ORD,"DEN"))+$G(DEN)
 S @TDATA@(ORD,"NDA")=$G(@TDATA@(ORD,"NDA"))+$G(NDA)
 Q
 ;
CK ;Check and store
 I VAL="N/A" S DEN=0,NUM=0 D STOR(ORD) Q
 S CAT=CAT_"_1"
 I VAL="NDA" S DEN=0,NUM=0 D STOR(ORD) Q
 ;I VAL="NDA" Q
 I VAL="NO" S DEN=1,NUM=0 D STOR(ORD) Q
 I VAL="YES" S DEN=1,NUM=1 D STOR(ORD) Q
 Q