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