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

BQIIPPRV.m

Go to the documentation of this file.
BQIIPPRV ;VNGT/HS/ALA-Get Provider Data ; 19 Jul 2011  2:39 PM
 ;;2.7;ICARE MANAGEMENT SYSTEM;**1**;Dec 19, 2017;Build 12
 ;
 ;
EN(DATA,OWNR,PLIEN,CRIPC,PLIST) ;EP - BQI GET IPC PROV DETAIL
 ;Description - Entry point for the panel
 ;Input Parameters
 ;  OWNR  - Owner of panel
 ;  PLIEN - Panel IEN
 ;  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,TNDA,CAT2,CAT
 NEW TAB,MSN,NA,BQIDOD,CNT,DCAT,EXEC,GP,I,ORD,QFL,TAG,STAB,GOAL,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)="T00035PROVIDER^I00010TOTAL_PATIENTS^I00010TOTAL_NDA^"
 S @DATA@(II)=@DATA@(II)_"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 PRV=""
 F  S PRV=$O(@TDATA@(PRV)) Q:PRV=""  D
 . S TOTP=$G(@TDATA@(PRV,"TOTP")),TNDA=0
 . S DFN="" F  S DFN=$O(@TDATA@(PRV,"NDA",DFN)) Q:DFN=""  S TNDA=TNDA+1
 . S ORD=""
 . F  S ORD=$O(@TDATA@(PRV,ORD)) Q:'ORD  D
 .. S MSN=$O(^BQI(90508,1,22,CRN,1,"C",ORD,"")) I MSN="" Q
 .. 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@(PRV,ORD,"NUM"))
 .. S DEN=$G(@TDATA@(PRV,ORD,"DEN"))
 .. S DEC=$G(@TDATA@(PRV,ORD,"DEC"))
 .. I IDATA["Goal Set" S DEN=TOTP
 .. 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," ")_"%"
 .. I PRV'="~" D
 ... S TRM=0
 ... I $P($G(^VA(200,PRV,0)),U,13)'="" S TRM=1
 ... S PROV=PRV_$C(28)_$S(TRM:"*",1:"")_$P($G(^VA(200,PRV,0)),U,1)
 .. I PRV="~" S PROV="{NOT ASSIGNED}"
 .. 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)=PROV_U_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
 S PROV=$P($G(^AUPNPAT(DFN,0)),U,14) S:PROV="" PROV="~"
 I '$$HRN^BQIUL1(DFN) Q
 S @TDATA@(PROV,"TOTP")=$G(@TDATA@(PROV,"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@(PROV,ORD,"DEC")=$G(@TDATA@(PROV,ORD,"DEC"))+1
 .. I TYP="R",$P(IDATA,U,5)="B" D
 ... K XX
 ... I CODE="IPC_OUTC" D
 .... I DFN'="" S VAL=$$OPAT^BQIIPOTC(CRN,DFN)
 ... I CODE["CTRL" D
 .... I DFN'="" S VAL=$$PAT^BQIIPOTC(CRN,DFN,CODE)
 ... I CODE'="IPC_OUTC",CODE'["CTRL" D
 .... D BUN^BQIIPBNL(CRN,MSN,.XX)
 .... I DFN'="" S VAL=$$PAT^BQIIPBNL(DFN,.XX)
 ... I VAL="N/A"!(VAL="NDA") S NUM=0,DEN=0 D STOR(ORD) Q
 ... ;I VAL="N/A" Q
 ... I $P(IDATA,U,5)="B" S CAT=CAT_"_1"
 ... I VAL="NDA" D  Q
 .... S DEN=0,NUM=0 D STOR(ORD)
 .... S @TDATA@(PROV,"NDA",DFN)=1
 ... I VAL="NO" S DEN=1,NUM=0 D STOR(ORD) Q
 ... I VAL="YES" S DEN=1,NUM=1 D STOR(ORD) Q
 .. I TYP'="G" Q
 .. S BQIND=$O(^BQIPAT(DFN,30,"B",CODE,"")) I BQIND="" D  Q
 ... S @TDATA@(PROV,"NDA",DFN)=1
 ... ;S DEN=1,NUM=0 D STOR(ORD)
 ... S 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)
 .. ;
 .. D STOR(ORD)
 Q
 ;
STOR(ORD) ;EP
 S @TDATA@(PROV,ORD,"NUM")=$G(@TDATA@(PROV,ORD,"NUM"))+NUM
 S @TDATA@(PROV,ORD,"DEN")=$G(@TDATA@(PROV,ORD,"DEN"))+DEN
 ;S @TDATA@(PROV,CAT,TITLE,MSN,"NUM")=$G(@TDATA@(PROV,CAT,TITLE,MSN,"NUM"))+NUM
 ;S @TDATA@(PROV,CAT,TITLE,MSN,"DEN")=$G(@TDATA@(PROV,CAT,TITLE,MSN,"DEN"))+DEN
 Q