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

BQI27POS.m

Go to the documentation of this file.
BQI27POS ;GDIT/HCD/ALA-Version 2.7 PostInstall ; 20 Jun 2017  11:39 AM
 ;;2.7;ICARE MANAGEMENT SYSTEM;;Dec 19, 2017;Build 23
 ;
 ;
EN ;EP
 NEW DA,DIK
 ; Delete Data Dictionary fields
 F DA=.02,.03,.04,.05,.06,.07,.08,.09,1.01,1.02,1.03,1.04,1.05,1.06,1.07,1.08,2.01,2.02 S DIK="^DD(90505.4,",DA(1)=90505.4 D ^DIK
 ;
 F DA=.02,.03,.04,.05,.06,.07,.08,.09,1.01,1.02,1.03,1.04,1.05,1.06,1.07,1.08,2.01,3.01 S DIK="^DD(90505.6,",DA(1)=90505.6 D ^DIK
 ;
 ;Reindex BQIPROV and BQIFAC
 S DIK="^BQIPROV(" D IXALL^DIK
 S DIK="^BQIFAC(" D IXALL^DIK
 ;
 ; Change current IPC to IPC4/IPC5,update Executables
 NEW DA,IENS
 S DA(1)=1,DA=2,IENS=$$IENS^DILF(.DA)
 S BQIUP(90508.022,IENS,.01)="IPC4/IPC5"
 S BQIUP(90508,"1,",11)="IPC4/IPC5"
 D FILE^DIE("","BQIUP","ERROR")
 S ^BQI(90508,1,22,2,1,2,1)="D EN^BQIIPCCP($G(BQDATE),$G(BQFROM),$G(BQTHRU))"
 S ^BQI(90508,1,22,2,1,3,1)="D EN^BQIIPEMP($G(BQDATE),$G(BQFROM),$G(BQTHRU))"
 S ^BQI(90508,1,22,2,1,4,1)="D EN^BQIIPBNL(CRN,MSN,$G(BQDATE),CODE,$G(BQFROM),$G(BQTHRU))"
 S ^BQI(90508,1,22,2,1,5,1)="D EN^BQIIPBNL(CRN,MSN,$G(BQDATE),CODE,$G(BQFROM),$G(BQTHRU))"
 S ^BQI(90508,1,22,2,1,51,1)="D EN^BQIIPBNL(CRN,MSN,$G(BQDATE),CODE,$G(BQFROM),$G(BQTHRU))"
 S ^BQI(90508,1,22,2,1,56,1)="D EN^BQIIPBNL(CRN,MSN,$G(BQDATE),CODE,$G(BQFROM),$G(BQTHRU))"
 S ^BQI(90508,1,22,2,1,59,1)="D EN^BQIIPBNL(CRN,MSN,$G(BQDATE),CODE,$G(BQFROM),$G(BQTHRU))"
 ;
 ; Set BTPWRPC and BUSARPC into BQIRPC
 NEW IEN,DA,X,DIC,Y
 S DA(1)=$$FIND1^DIC(19,"","B","BQIRPC","","","ERROR"),DIC="^DIC(19,"_DA(1)_",10,",DIC(0)="LMNZ"
 I $G(^DIC(19,DA(1),10,0))="" S ^DIC(19,DA(1),10,0)="^19.01IP^^"
 S X="BTPWRPC"
 D ^DIC I +Y<1 K DO,DD D FILE^DICN
 NEW IEN,DA,X,DIC,Y
 S DA(1)=$$FIND1^DIC(19,"","B","BQIRPC","","","ERROR"),DIC="^DIC(19,"_DA(1)_",10,",DIC(0)="LMNZ"
 I $G(^DIC(19,DA(1),10,0))="" S ^DIC(19,DA(1),10,0)="^19.01IP^^"
 S X="BUSARPC"
 D ^DIC I +Y<1 K DO,DD D FILE^DICN
 ;
 ;Add new IPC Medical Home
 D ^BQIIPCHM
 ;Set the version number
 NEW DA
 S DA=$O(^BQI(90508,0))
 S BQIUPD(90508,DA_",",.08)="2.7.0.5"
 S BQIUPD(90508,DA_",",.09)="2.7.0.5"
 D FILE^DIE("","BQIUPD","ERROR")
 K BQIUPD
 ;
GLS ;Update glossary
 NEW GN,GNM,GSN,BQIUPD
 S GN=0
 F  S GN=$O(^BQI(90509.9,GN)) Q:'GN  D
 . S GNM=$P(^BQI(90509.9,GN,0),U,1)
 . S GSN=$O(^BQI(90508.2,"B",GNM,"")) Q:GSN=""
 . S BQIUPD(90508.2,GSN_",",1)="@"
 . D FILE^DIE("","BQIUPD","ERROR")
 . M ^BQI(90508.2,GSN,1)=^BQI(90509.9,GN,1)
 ;
JBW ; Job off weekly data for the past week
 NEW ZTDTH,ZTDESC,ZTRTN,ZTIO,ZTSAVE,BQIUPD
 S ZTDTH=$$FMADD^XLFDT($$NOW^XLFDT(),,,3)
 S ZTDESC="IPC Weekly Compile",ZTRTN="WEEK^BQI27POS",ZTIO=""
 D ^%ZTLOAD
 S BQIUPD(90508,"1,",11.06)=ZTSK
 D FILE^DIE("","BQIUPD","ERROR")
 Q
 ;
WEEK ;EP - Set up the most recent past week of data
 S CRIPC="IPCMH"
 S CRN=$O(^BQI(90508,1,22,"B",CRIPC,"")) I CRN="" Q
 ;
 ; Set the WEEKLY Date Range for the previous week
 S CDOW=$$DOW^XLFDT(DT,1) I CDOW'=0 D
 . S DFL=0
 . F I=1:1 Q:DFL  D  Q:DFL
 .. S WDATE=$$FMADD^XLFDT(DT,-I),CDOW=$$DOW^XLFDT(WDATE,1)
 .. I CDOW=0 S BQTHRU=WDATE,BQFROM=$$FMADD^XLFDT(WDATE,-7),DFL=1
 ;
 I $D(^BQITEAM("AC",BQTHRU)) Q
 ;
 S WEEK=1
 S MSN=0 F  S MSN=$O(^BQI(90508,1,22,CRN,1,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)
 . ; If inactive, quit
 . I $P(IDATA,U,7)=1 Q
 . I CODE="IPC_CCPR"!(CODE="IPC_PEMP")!(CODE="IPC_CCTM") Q
 . S PRV="",TDEN=0,TNUM=0
 . F  S PRV=$O(^AUPNPAT("AK",PRV)) Q:PRV=""  D
 .. I $P(^VA(200,PRV,0),U,13)'="" Q
 .. S DFN="",PDEN=0,PNUM=0
 .. F  S DFN=$O(^AUPNPAT("AK",PRV,DFN)) Q:DFN=""  D
 ... S IPRN=$O(^BQIPAT(DFN,30,"B",CODE,"")) I IPRN="" Q
 ... S DEN=$P(^BQIPAT(DFN,30,IPRN,0),U,4),NUM=$P(^(0),U,3)
 ... S PNUM=PNUM+NUM,PDEN=PDEN+DEN,TDEN=TDEN+DEN,TNUM=TNUM+NUM
 .. I $G(DEBUG)=1 W !,PRV,"|",CODE,"|",PDEN,"|",PNUM
 .. D STORPW^BQIIPUTL(PRV,CODE,BQFROM,BQTHRU,PDEN,PNUM)
 . S FAC=$$HME^BQIGPUTL()
 . D STORFW^BQIIPUTL(FAC,CODE,BQFROM,BQTHRU,TDEN,TNUM)
 ;
 S MSN=0
 F  S MSN=$O(^BQI(90508,1,22,CRN,1,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)
 . ; If inactive, quit
 . I $P(IDATA,U,7)=1 Q
 . I CODE="IPC_CCPR"!(CODE="IPC_PEMP") Q
 . I CODE="IPC_CCTM" S WEEK=1 D EN^BQIIPCCT($G(BQDATE),$G(BQFROM),$G(BQTHRU)) Q
 . ; Update the team
 . NEW TMN,TEAM,TMM,OK,TDEN,TNUM,IPRN,IPRD,DEN,NUM
 . S TMN=0
 . F  S TMN=$O(^BSDPCT(TMN)) Q:'TMN  D
 .. S TEAM=$P(^BSDPCT(TMN,0),"^",1)
 .. S TMM="",PDEN=0,PNUM=0
 .. F  S TMM=$O(^BSDPCT(TMN,1,"B",TMM)) Q:TMM=""  D
 ... S DFN="" F  S DFN=$O(^AUPNPAT("AK",TMM,DFN)) Q:DFN=""  D
 .... I $P(IDATA,"^",5)="B" D  Q
 ..... S VALUE=$$PT^BQIIPBNL(DFN,CRN,MSN)
 ..... I VALUE="YES" S PDEN=PDEN+1,PNUM=PNUM+1 Q
 ..... I VALUE="NO" S PDEN=PDEN+1,PNUM=PNUM+0 Q
 .... S IPRN=$O(^BQIPAT(DFN,30,"B",CODE,"")) I IPRN="" Q
 .... S DEN=$P(^BQIPAT(DFN,30,IPRN,0),U,4),NUM=$P(^(0),U,3)
 .... S PDEN=PDEN+DEN,PNUM=PNUM+NUM
 .. I $G(DEBUG)=1 W !,TEAM,"|",CODE,"|",PNUM,"|",PDEN
 .. D STORTW^BQIIPUTL(TEAM,CODE,BQFROM,BQTHRU,PDEN,PNUM)
 K WEEK
 ;
MON ;Monthy update
 S BQDATE=$O(^BQI(90508,1,22,2,3,"B",""),-1)
 F CRN=2,3 D
 . S MSN=0 F  S MSN=$O(^BQI(90508,1,22,CRN,1,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)
 .. ; If inactive, quit
 .. I $P(IDATA,U,7)=1 Q
 .. I CODE="IPC_CCPR"!(CODE="IPC_PEMP")!(CODE="IPC_CCTM") Q
 .. S PRV="",TDEN=0,TNUM=0
 .. F  S PRV=$O(^AUPNPAT("AK",PRV)) Q:PRV=""  D
 ... I $P(^VA(200,PRV,0),U,13)'="" Q
 ... S DFN="",PDEN=0,PNUM=0
 ... F  S DFN=$O(^AUPNPAT("AK",PRV,DFN)) Q:DFN=""  D
 .... S IPRN=$O(^BQIPAT(DFN,30,"B",CODE,"")) I IPRN="" Q
 .... S DEN=$P(^BQIPAT(DFN,30,IPRN,0),U,4),NUM=$P(^(0),U,3)
 .... S PNUM=PNUM+NUM,PDEN=PDEN+DEN,TDEN=TDEN+DEN,TNUM=TNUM+NUM
 ... I $G(DEBUG)=1 W !,PRV,"|",CODE,"|",PDEN,"|",PNUM
 ... D STORP^BQIIPUTL(PRV,CODE,BQDATE,PDEN,PNUM)
 .. S FAC=$$HME^BQIGPUTL()
 .. D STORF^BQIIPUTL(FAC,CODE,BQDATE,TDEN,TNUM)
 . ;
 . S MSN=0
 . F  S MSN=$O(^BQI(90508,1,22,CRN,1,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)
 .. ; If inactive, quit
 .. I $P(IDATA,U,7)=1 Q
 .. I CODE="IPC_CCPR"!(CODE="IPC_PEMP")!(CODE="IPC_CCTM") Q
 .. NEW TMN,TEAM,TMM,OK,TDEN,TNUM,IPRN,IPRD,DEN,NUM
 .. S TMN=0
 .. F  S TMN=$O(^BSDPCT(TMN)) Q:'TMN  D
 ... ; Check inactivation date
 ... I $P(^BSDPCT(TMN,0),"^",3)'="" Q
 ... S TEAM=$P(^BSDPCT(TMN,0),"^",1)
 ... ; Check if the team members has at least one member with patients assigned to them
 ... S OK=0
 ... S TMM="" F  S TMM=$O(^BSDPCT(TMN,1,"B",TMM)) Q:TMM=""  I $O(^AUPNPAT("AK",TMM,""))'="" S OK=1
 ... I 'OK Q
 ... S TDEN=0,TNUM=0
 ... S TMM="" F  S TMM=$O(^BSDPCT(TMN,1,"B",TMM)) Q:TMM=""  I $O(^AUPNPAT("AK",TMM,""))'="" D
 .... I $P(^VA(200,TMM,0),U,13)'="" Q
 .... S IPRN=$O(^BQIPROV(TMM,30,"B",CODE,"")) I IPRN="" Q
 .... S IPRD=$O(^BQIPROV(TMM,30,IPRN,1,"B",BQDATE,"")) I IPRD="" Q
 .... S DEN=$P(^BQIPROV(TMM,30,IPRN,1,IPRD,0),U,2),NUM=$P(^(0),U,3)
 .... S TNUM=TNUM+NUM,TDEN=TDEN+DEN
 ... I $G(DEBUG)=1 W !,TEAM,"|",CODE,"|",BQDATE,"|",TNUM_"/"_TDEN
 ... D STORT^BQIIPUTL(TEAM,CODE,BQDATE,TDEN,TNUM)
 Q