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

BQIIPCMH.m

Go to the documentation of this file.
BQIIPCMH ;GDIT/HS/ALA-Get IPC Monthly Data Export by Provider ; 11 Oct 2011  4:10 PM
 ;;2.7;ICARE MANAGEMENT SYSTEM;**1**;Dec 19, 2017;Build 12
 ;
 ;
RET(DATA,DATE,PLIST) ;EP -- BQI GET IPC PROV MON EXPORT
 NEW UID,II,HDR,C1,C2,C3,C4,NAME,HEAD,HX,PEC,SORT,QFL,PCT,CT,DDATA,CPER,PPER,TIT,BQMON
 NEW BN,LIST,FAC
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIMUPROV",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIIPCM D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ; If a list of IENs, process them instead of entire panel
 I $D(PLIST)>0 D
 . 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
 ;
 ; Get current IPC
 S CRIPC=$P($G(^BQI(90508,1,11)),U,1)
 I CRIPC="IPCMH" S CRIPC="IPC4/IPC5"
 S CRN=$O(^BQI(90508,1,22,"B",CRIPC,"")) I CRN="" Q
 ;
 K Z
 ;S HDR="T00050PROVIDER^T00050IPC_MEAS^T00030CATEGORY^T00030NUMERATOR^T00030DENOMINATOR"
 S HDR="T00050IPC_MEAS^T00030CATEGORY^T00030NUMERATOR^T00030DENOMINATOR"
 S @DATA@(II)=HDR_$C(30)
 ;
 S (C1,C2,C3,C4,CT,PCT)=0
 ;S PROV=$G(PROV,"")
 F BQI=1:1 S PROV=$P(PLIST,$C(28),BQI) Q:PROV=""  D RTE(PROV)
 ;I PROV'="" D RTE(PROV) G DONE
 ;I PROV="" S PROV=+PROV
 ;F  S PROV=$O(^BQIPROV(PROV)) Q:'PROV  D RTE(PROV)
 ;
 S ID=""
 F  S ID=$O(DDATA(ID)) Q:ID=""  D
 . S FDATA=DDATA(ID)_Z(ID,DATE)_U
 . S FDATA=$$TKO^BQIUL1(FDATA,"^")
 . S II=II+1,@DATA@(II)=FDATA_$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
 ;
RTE(PRV) ;EP
 ;S DDATA=""
 ;S PRVR=PRV_$C(28)_$P($G(^VA(200,PRV,0)),U,1)
 ;S DDATA=PRVR_U
 S CYR=$E(DT,1,3)
 S FAC=$$HME^BQIGPUTL()
 ;
 S ORD=""
 F  S ORD=$O(^BQI(90508,1,22,CRN,1,"C",ORD)) Q:ORD=""  D
 . S IDD=""
 . F  S IDD=$O(^BQI(90508,1,22,CRN,1,"C",ORD,IDD)) Q:IDD=""  D
 .. S ID=$P(^BQI(90508,1,22,CRN,1,IDD,0),U,1),MEAS=$P(^(0),U,4)
 .. I $P(^BQI(90508,1,22,CRN,1,IDD,0),U,7)=1 Q
 .. NEW DA,IENS
 .. S DA(2)=1,DA(1)=CRN,DA=IDD,IENS=$$IENS^DILF(.DA)
 .. S CAT=$$GET1^DIQ(90508.221,IENS,.03,"E")
 .. I CAT="" D
 ... S CODE=ID
 ... S RIEN=$O(^BQI(90506.1,"B",CODE,"")) I RIEN="" Q
 ... S CAT=$$GET1^DIQ(90506.1,RIEN_",",3.02,"E")
 .. S DDATA(ID)=ID_$C(28)_MEAS_U_CAT_U
 .. I ID="IPC_PEMP" D  Q
 ... S IDN=$O(^BQIFAC(FAC,30,"B",ID,"")) I IDN="" D  Q
 .... S $P(Z(ID,DATE),U,1)=$P($G(Z(ID,DATE)),U,1)+0
 .... S $P(Z(ID,DATE),U,2)=$P($G(Z(ID,DATE)),U,2)+0
 ... S MSDN=$O(^BQIFAC(FAC,30,IDN,1,"B",DATE,""))
 ... I MSDN="" S $P(Z(ID,DATE),U,1)=$P($G(Z(ID,DATE)),U,1)+0,$P(Z(ID,DATE),U,2)=$P($G(Z(ID,DATE)),U,2)+0 Q
 ... S DEN=+$P(^BQIFAC(FAC,30,IDN,1,MSDN,0),U,2),NUM=+$P(^BQIFAC(FAC,30,IDN,1,MSDN,0),U,3)
 ... S $P(Z(ID,DATE),U,1)=NUM,$P(Z(ID,DATE),U,2)=DEN
 .. S IDN=$O(^BQIPROV(PRV,30,"B",ID,"")) I IDN="" D  Q
 ... S $P(Z(ID,DATE),U,1)=$P($G(Z(ID,DATE)),U,1)+0
 ... S $P(Z(ID,DATE),U,2)=$P($G(Z(ID,DATE)),U,2)+0
 .. D
 ... S MSDN=$O(^BQIPROV(PRV,30,IDN,1,"B",DATE,""))
 ... I MSDN="" S $P(Z(ID,DATE),U,1)=$P($G(Z(ID,DATE)),U,1)+0,$P(Z(ID,DATE),U,2)=$P($G(Z(ID,DATE)),U,2)+0 Q
 ... S DEN=+$P(^BQIPROV(PRV,30,IDN,1,MSDN,0),U,2),NUM=+$P(^BQIPROV(PRV,30,IDN,1,MSDN,0),U,3)
 ... I ID="IPC_TOTP" D  Q
 .... ;S Z(ID,DATE)="0^"_DEN
 .... S $P(Z(ID,DATE),U,2)=$P($G(Z(ID,DATE)),U,2)+DEN
 ... I ID="IPC_REVG" D  Q
 .... I DEN=0 S $P(Z(ID,DATE),U,1)=$P($G(Z(ID,DATE)),U,1)+0,$P(Z(ID,DATE),U,2)=$P($G(Z(ID,DATE)),U,2)+0 Q
 .... I DEN'=0,NUM=0 S $P(Z(ID,DATE),U,1)=$P($G(Z(ID,DATE)),U,1)+0,$P(Z(ID,DATE),U,2)=$P($G(Z(ID,DATE)),U,2)+DEN Q
 .... I DEN'=0,NUM'=0 S $P(Z(ID,DATE),U,1)=$P($G(Z(ID,DATE)),U,1)+NUM,$P(Z(ID,DATE),U,2)=$P($G(Z(ID,DATE)),U,2)+DEN Q
 ... I DEN=0 S $P(Z(ID,DATE),U,1)=$P($G(Z(ID,DATE)),U,1)+0,$P(Z(ID,DATE),U,2)=$P($G(Z(ID,DATE)),U,2)+0 Q
 ... I DEN'=0,NUM=0 S $P(Z(ID,DATE),U,1)=$P($G(Z(ID,DATE)),U,1)+0,$P(Z(ID,DATE),U,2)=$P($G(Z(ID,DATE)),U,2)+DEN Q
 ... I NUM'=0 S $P(Z(ID,DATE),U,1)=$P($G(Z(ID,DATE)),U,1)+NUM,$P(Z(ID,DATE),U,2)=$P($G(Z(ID,DATE)),U,2)+DEN
 Q