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

BQIIPWKL.m

Go to the documentation of this file.
BQIIPWKL ;GDIT/HCSD/ALA-Update Weekly ; 18 Sep 2017  9:04 AM
 ;;2.7;ICARE MANAGEMENT SYSTEM;**1**;Dec 19, 2017;Build 12
 ;
 ;
EN ;EP - IPC calculations
 ; 
 NEW BQMON,CYR,PYR,YR,TMFRAME,CRIPC,CRN,MSN,IDATA,CODE,TYP,BARDUZ2
 NEW BCODE,BCT,BEGDT,BN,BQDTE,CD,CNT,DEN,DFN,EDAY,ENDT,EXEC,FAC,IEN
 NEW NUM,PCT,PDEN,PNUM,PRV,QFL,TDEN,TNUM,TP,XX,Y,CRST,BQDA,PROW
 NEW CDOW,BQFROM,BQTHRU
 ;
 S QFL=0
 ;
 ; Get current IPC
 S CRIPC=$P($G(^BQI(90508,1,11)),U,1)
 ;I CRIPC'="IPCMH" Q
 S CRIPC="IPCMH"
 S CRN=$O(^BQI(90508,1,22,"B",CRIPC,"")) I CRN="" G CHK
 ;
 ; Set the WEEKLY Date Range
 S CDOW=$$DOW^XLFDT(DT,1) I CDOW'=0 G CHK
 S BQFROM=$$FMADD^XLFDT(DT,-7),BQTHRU=DT,WEEK=1
 ;
BEG ;  Set the DATE/TIME STARTED field
 NEW DA
 S DA=$O(^BQI(90508,0)) I 'DA G CHK
 S BQIUPD(90508,DA_",",8.04)=$$NOW^XLFDT()
 S BQIUPD(90508,DA_",",8.06)=1
 D FILE^DIE("","BQIUPD","ERROR")
 K BQIUPD
 ;
 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
 . ; If type is RPMS
 . I TYP="R" D  Q
 .. S EXEC=$G(^BQI(90508,1,22,CRN,1,MSN,1)) I EXEC="" Q
 .. X EXEC
 . ;
 . S BQIPROV="",FDEN=0,FNUM=0
 . F  S BQIPROV=$O(^AUPNPAT("AK",BQIPROV)) Q:BQIPROV=""  D
 .. I $P(^VA(200,BQIPROV,0),U,13)'="" Q
 .. S TDEN=0,TNUM=0
 .. S BDFN="" F  S BDFN=$O(^AUPNPAT("AK",BQIPROV,BDFN)) Q:BDFN=""  D
 ... S PN=$O(^BQIPAT(BDFN,30,"B",CODE,"")) I PN="" Q
 ... S NUM=$P(^BQIPAT(BDFN,30,PN,0),"^",3),DEN=$P(^(0),"^",4)
 ... S TDEN=TDEN+DEN,TNUM=TNUM+NUM,FDEN=FDEN+DEN,FNUM=FNUM+NUM
 .. I $G(DEBUG)=1 W !,BQIPROV,"|",CODE,"|",TNUM,"|",TDEN
 .. D STORPW^BQIIPUTL(BQIPROV,CODE,BQFROM,BQTHRU,TDEN,TNUM)
 . S FAC=$$HME^BQIGPUTL()
 . I $G(DEBUG)=1 W !!,FAC,"|",CODE,"|",FNUM,"|",FDEN,!!
 . D STORFW^BQIIPUTL(FAC,CODE,BQFROM,BQTHRU,FDEN,FNUM)
 ;
TEM ;EP - Process teams
 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
 . ; 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 PN=$O(^BQIPROV(TMM,30,"B",CODE,"")) I PN="" Q
 ... S WKN=$O(^BQIPROV(TMM,30,PN,2,"AC",BQTHRU,"")) I WKN="" Q
 ... S NUM=$P(^BQIPROV(TMM,30,PN,2,WKN,0),"^",3),DEN=$P(^(0),"^",2)
 ... S PDEN=PDEN+DEN,PNUM=PNUM+NUM
 .. I $G(DEBUG)=1 W !,TMN,"|",CODE,"|",PNUM,"|",PDEN
 .. D STORTW^BQIIPUTL(TEAM,CODE,BQFROM,BQTHRU,PDEN,PNUM)
 ;
FIN ;EP - Set the DATE/TIME FLAG ENDED field
 NEW DA
 S DA=$$SPM^BQIGPUTL()
 S BQIUPD(90508,DA_",",8.05)=$$NOW^XLFDT()
 S BQIUPD(90508,DA_",",8.06)="@"
 S BQIUPD(90508,"1,",11.06)="@"
 D FILE^DIE("","BQIUPD","ERROR")
 K BQIUPD
 K WEEK
 Q
 ;
CHK ; EP - quit and delete task
 S BQIUPD(90508,"1,",11.06)="@"
 D FILE^DIE("","BQIUPD","ERROR")
 K BQIUPD
 Q