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

BQIIPBNL.m

Go to the documentation of this file.
BQIIPBNL ;VNGT/HS/ALA-IPC Bundle Logic ; 24 Jun 2011  11:53 AM
 ;;2.7;ICARE MANAGEMENT SYSTEM;;Dec 19, 2017;Build 23
 ;
 ;
EN(CRSN,BNIEN,BQDATE,CODE,BQFROM,BQTHRU) ;EP - do the bundle for monthly update
 ; Input
 ;   CRSN  - Current IPC IEN
 ;   BNIEN - Bundle IEN
 ;   CODE  - Code name
 ;   BQI(90508,1,22,CRN,1,MSN,1
 ;
 NEW TDEN,TNUM,CNT,CD,BQIDOD,NA,YES,NO,NDA
 S BQDATE=$G(BQDATE,""),BQFROM=$G(BQFROM,""),BQTHRU=$G(BQTHRU,"")
 S TDEN=0,TNUM=0,CNT=0
 K XX
 D BUN(CRSN,BNIEN,.XX)
 S CD="" F  S CD=$O(XX(CD)) Q:CD=""  S CNT=CNT+1
 ;
 S PRV=""
 F  S PRV=$O(^AUPNPAT("AK",PRV)) Q:PRV=""  D
 . I $P(^VA(200,PRV,0),U,13)'="" Q
 . S DFN="",PCT=0,TP=0
 . F  S DFN=$O(^AUPNPAT("AK",PRV,DFN)) Q:DFN=""  D
 .. ;B:PRV=2911
 .. I '$$HRN^BQIUL1(DFN) Q
 .. S VAL=$$PAT(DFN,.XX)
 .. I VAL="N/A"!(VAL="{D}") Q
 .. S TP=TP+1
 .. I VAL="YES" S PCT=PCT+1
 .. Q
 .. S CD="",BCT=0,NA=0,YES=0,NO=0,NDA=0
 .. F  S CD=$O(XX(CD)) Q:CD=""  D
 ... S IEN=$O(^BQIPAT(DFN,30,"B",CD,"")) I IEN="" S NDA=NDA+1 Q
 ... S BQIDOD=$$GET1^DIQ(2,DFN_",",.351,"I")
 ... I BQIDOD'="" Q
 ... S NUM=$P(^BQIPAT(DFN,30,IEN,0),U,3)
 ... S DEN=$P(^BQIPAT(DFN,30,IEN,0),U,4)
 ... S TP=TP+1
 ... I NUM="",DEN="" S BCT=BCT+1,NA=NA+1 Q
 ... I DEN'="",NUM="" S NO=NO+1 Q
 ... I DEN'="",NUM'="" S BCT=BCT+1,YES=YES+1
 .. I NDA S NA=NA+1
 .. I 'NO S PCT=PCT+1
 .. Q
 .. S PCT=$S(BCT=CNT:PCT+1,1:PCT)
 . I '$G(WEEK) D STORP^BQIIPUTL(PRV,CODE,BQDATE,TP,PCT)
 . I $G(WEEK)=1 D STORPW^BQIIPUTL(PRV,CODE,BQFROM,BQTHRU,TP,PCT)
 . I $G(DEBUG)=1 W !,PRV,"|",CODE,"|",PCT,"/",TP
 . S TDEN=TDEN+TP,TNUM=TNUM+PCT
 S FAC=$$HME^BQIGPUTL()
 I '$G(WEEK) D STORF^BQIIPUTL(FAC,CODE,BQDATE,TDEN,TNUM)
 I $G(WEEK)=1 D STORFW^BQIIPUTL(FAC,CODE,BQFROM,BQTHRU,TDEN,TNUM)
 I $G(DEBUG)=1 W !,FAC,"|",CODE,"|",TNUM,"/",TDEN
 Q
 ;
BUN(CRSN,BNIEN,XX) ;EP - Get values for bundle
 NEW BN,BCODE
 S BN=0
 F  S BN=$O(^BQI(90508,1,22,CRSN,1,BNIEN,2,BN)) Q:'BN  D
 . S BCODE=$P(^BQI(90508,1,22,CRSN,1,BNIEN,2,BN,0),U,1)
 . S XX(BCODE)=""
 Q
 ;
PAT(DFN,XX) ;EP - See if patient meets bundle criteria
 NEW BCT,PCT,CNT,CD,IEN,NUM,DEN,BQIDOD,NA,YES,NO,NDA
 S BCT=0,PCT=0,CNT=0,NA=0,YES=0,NO=0,NDA=0
 S BQIDOD=$$GET1^DIQ(2,DFN_",",.351,"I")
 I BQIDOD'="" Q "{D}"
 S CD="" F  S CD=$O(XX(CD)) Q:CD=""  S CNT=CNT+1
 F  S CD=$O(XX(CD)) Q:CD=""  D
 . I $P(CD,"_",1)="MU" S NA=NA+1 Q
 . S IEN=$O(^BQIPAT(DFN,30,"B",CD,"")) I IEN="" S NDA=NDA+1 Q
 . S NUM=$P(^BQIPAT(DFN,30,IEN,0),U,3)
 . S DEN=$P(^BQIPAT(DFN,30,IEN,0),U,4)
 . I NUM="",DEN="" S BCT=BCT+1,NA=NA+1 Q
 . I DEN'="",NUM="" S NO=NO+1 Q
 . I DEN'="",NUM'="" S BCT=BCT+1,YES=YES+1
 I NDA Q "N/A"
 I NA=CNT Q "N/A"
 I YES=CNT Q "YES"
 I 'NO Q "YES"
 Q "NO"
 ;
PT(DFN,IPCN,CDN) ;EP
 D BUN(IPCN,CDN,.XX)
 S VAL=$$PAT(DFN,.XX)
 Q VAL