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

BQIIPPRG.m

Go to the documentation of this file.
BQIIPPRG ;VNGT/HS/ALA-RPMS Program ; 13 Sep 2011  5:27 PM
 ;;2.3;ICARE MANAGEMENT SYSTEM;;Apr 18, 2012;Build 59
 ;
 ;
ERUR(BQDATE) ;EP
 NEW BQDTE,BQMON,EDAY,ENDT,CYR,PYR,ID,FAC,BQITOTV,BQITOTR,BD,VISIT
 NEW DFN,VD,X,Y,BQA,DPCP,CLN,QFL,BEGDT,BQITOTP,FC,PRV,CRST
 NEW CLNC,FTOTF,FTOTP
 S QFL=0
 S CRST=$P($G(^BQI(90508,1,11)),U,2) S:CRST="" CRST=1
 S CRST="0"_CRST
 ;
 I $G(BQDATE)'="" D
 . S BEGDT=$E(BQDATE,1,5)_"01",CYR=$E(BQDATE,1,3),BQMON=$E(BQDATE,4,5)
 . I $L(BQMON)=1 S BQMON="0"_BQMON
 . S EDAY="31^"_($$LEAP^XLFDT2(CYR)+28)_"^31^30^31^30^31^31^30^31^30^31"
 . S ENDT=$E(BQDATE,1,5)_$P(EDAY,U,+BQMON)
 ;
 I $G(BQDATE)="" D  Q:QFL
 . I $E(DT,6,7)'=CRST S QFL=1 Q
 . S BQMON=$E(DT,4,5)-1,CYR=$E(DT,1,3),PYR=CYR-1
 . S BQDTE=$P($T(BQM+BQMON),";;",2)
 . I $L(BQMON)=1 S BQMON="0"_BQMON
 . S BEGDT=@($P(BQDTE,U,2))_$P(BQDTE,U,1)_"01"
 . S EDAY="31^"_($$LEAP^XLFDT2(CYR)+28)_"^31^30^31^30^31^31^30^31^30^31"
 . S ENDT=@($P(BQDTE,U,2))_$P(BQDTE,U,1)_$P(EDAY,U,+$P(BQDTE,U,1))
 . S BQDATE=$S(BQMON="01":PYR,1:CYR)_BQMON_"00"
 ;
 S ID="IPC_ERUR"
 S FAC=$$HME^BQIGPUTL()
 ;
 ; BQITOTP(primary provider ien,DFN))=# of patients with visits to this provider
 S BQITOTV=0,BQITOTR=0
 S PRV=""
 F  S PRV=$O(^AUPNPAT("AK",PRV)) Q:PRV=""  D
 . S BQITOTP(PRV)=0
 . S PIEN="" F  S PIEN=$O(^AUPNPAT("AK",PRV,PIEN)) Q:PIEN=""  D
 .. I '$$HRN^BQIUL1(PIEN) Q
 .. S BQITOTP(PRV)=$G(BQITOTP(PRV))+1
 ;
 S BD=BEGDT_".9999"
 F  S BD=$O(^AUPNVSIT("B",BD)) Q:BD=""!(BD\1>ENDT)  D
 . S VISIT=""
 . F  S VISIT=$O(^AUPNVSIT("B",BD,VISIT)) Q:VISIT=""  D
 .. I $G(^AUPNVSIT(VISIT,0))="" Q
 .. I $P(^AUPNVSIT(VISIT,0),U,11) Q
 .. ; skip E:EVENT (HISTORICAL);D:DAILY HOSP DATA;X:ANCILLARY PACKAGE DAILY visits
 .. Q:"EDX"[$P(^AUPNVSIT(VISIT,0),U,7)
 .. ; location of visit not facility
 .. S FC=$P(^AUPNVSIT(VISIT,0),U,6) Q:'FC
 .. Q:FC'=FAC
 .. S CLN=$P(^AUPNVSIT(VISIT,0),U,8)
 .. I CLN="" Q
 .. S CLNC=$$PTR^BQIUL2(9000010,.08,CLN,1)
 .. I CLNC'=80,CLNC'=30 Q
 .. ; if no diagnoses
 .. Q:'$D(^AUPNVPOV("AD",VISIT))
 .. S DFN=$P(^AUPNVSIT(VISIT,0),U,5) I DFN="" Q
 .. I $G(^AUPNPAT(DFN,0))="" Q
 .. I $G(^DPT(DFN,0))="" Q
 .. ; If no HRN for this facility
 .. I $G(^AUPNPAT(DFN,41,FAC,0))="" Q
 .. S VD=$P(^AUPNVSIT(VISIT,0),U,1)\1
 .. ; HRN is inactive
 .. S X=$S($P($G(^AUPNPAT(DFN,41,FAC,0)),U,3)="":1,$P($G(^AUPNPAT(DFN,41,FAC,0)),U,3)>VD:1,1:0)
 .. I 'X Q
 .. ; patient is deceased
 .. I $P($G(^DPT(DFN,.35)),U,1)'="" Q
 .. ; If no DPCP
 .. S DPCP=$P(^AUPNPAT(DFN,0),U,14) I DPCP="" Q
 .. S BQITOTP(DPCP,DFN)=$G(BQITOTP(DPCP,DFN))+1
 ;
 S DPCP="",FTOTP=0,FTOTF=0
 F  S DPCP=$O(BQITOTP(DPCP)) Q:DPCP=""  D
 . S DFN="",TOTP=0
 . F  S DFN=$O(BQITOTP(DPCP,DFN)) Q:DFN=""  S TOTP=TOTP+1
 . D STORP^BQIIPUTL(DPCP,ID,BQDATE,BQITOTP(DPCP),TOTP)
 . S FTOTP=FTOTP+TOTP
 . S FTOTF=FTOTF+BQITOTP(DPCP)
 D STORF^BQIIPUTL(FAC,ID,BQDATE,FTOTF,FTOTP)
 Q
 ;
TOT(BQDATE) ;EP - Total patients in microsystem
 NEW BQMON,BQDTE,BEGDT,ENDT,EDAY,ID,PROV,BQTOTV,BQTOTP,FAC
 NEW FC,TVIS,TPD,CL,QFL,CRST
 S QFL=0
 S CRST=$P($G(^BQI(90508,1,11)),U,2) S:CRST="" CRST=1
 S CRST="0"_CRST
 ;
 I $G(BQDATE)'="" D
 . S BEGDT=$E(BQDATE,1,5)_"01",CYR=$E(BQDATE,1,3),BQMON=$E(BQDATE,4,5)
 . I $L(BQMON)=1 S BQMON="0"_BQMON
 . S EDAY="31^"_($$LEAP^XLFDT2(CYR)+28)_"^31^30^31^30^31^31^30^31^30^31"
 . S ENDT=$E(BQDATE,1,5)_$P(EDAY,U,+BQMON)
 ;
 I $G(BQDATE)="" D  Q:QFL
 . I $E(DT,6,7)'=CRST S QFL=1 Q
 . S BQMON=$E(DT,4,5)-1,CYR=$E(DT,1,3),PYR=CYR-1
 . I $L(BQMON)=1 S BQMON="0"_BQMON
 . S BQDTE=$P($T(BQM+BQMON),";;",2)
 . S BEGDT=@($P(BQDTE,U,2))_$P(BQDTE,U,1)_"01"
 . S EDAY="31^"_($$LEAP^XLFDT2(CYR)+28)_"^31^30^31^30^31^31^30^31^30^31"
 . S ENDT=@($P(BQDTE,U,2))_$P(BQDTE,U,1)_$P(EDAY,U,+$P(BQDTE,U,1))
 . S BQDATE=$S(BQMON="01":PYR,1:CYR)_BQMON_"00"
 ;
 S ID="IPC_TOTP"
 S FAC=$$HME^BQIGPUTL()
 ;
 S PROV="",BQTOTP=0
 F  S PROV=$O(^AUPNPAT("AK",PROV)) Q:PROV=""  D
 . S BQITOTP(PROV)=0
 . S PIEN="" F  S PIEN=$O(^AUPNPAT("AK",PROV,PIEN)) Q:PIEN=""  D
 .. I '$$HRN^BQIUL1(PIEN) Q
 .. S BQITOTP(PROV)=$G(BQITOTP(PROV))+1
 S DPCP="",FTOTP=0,FTOTF=0
 F  S DPCP=$O(BQITOTP(DPCP)) Q:DPCP=""  D
 . D STORP^BQIIPUTL(DPCP,ID,BQDATE,BQITOTP(DPCP),0)
 . S FTOTF=FTOTF+BQITOTP(DPCP)
 D STORF^BQIIPUTL(FAC,ID,BQDATE,FTOTF,FTOTP)
 Q
 ;
BQM ;
 ;;12^PYR
 ;;01^CYR
 ;;02^CYR
 ;;03^CYR
 ;;04^CYR
 ;;05^CYR
 ;;06^CYR
 ;;07^CYR
 ;;08^CYR
 ;;09^CYR
 ;;10^CYR
 ;;11^CYR