BKMVQCR9 ;PRXM/HC/BWF - BKMV Quality of Care Report; [ 1/19/2005 7:16 PM ]
;;2.1;HIV MANAGEMENT SYSTEM;;Feb 07, 2011
; Quality of Care Audit Report
Q
ARVCALC ; EP - ARV Calculation
N ARVTOT,DFN,PTOTAL,CNT1,CNT2,CNT3,VSTDT,TEST,CNTM02,CNTM03,CNTM05
S PTOTAL=$G(^TMP("BKMVQCR",$J,"HIVTOT1"))
S ARVTOT=0,DFN=0,(CNT1,CNT2,CNT3)=0
F S DFN=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN)) Q:'DFN D
.S VSTDT="",CNTM02=0,CNTM03=0,CNTM05=0
.F S VSTDT=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"ARVM02",VSTDT)) Q:VSTDT="" D
..S TEST=""
..F S TEST=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"ARVM02",VSTDT,TEST)) Q:TEST="" S CNTM02=CNTM02+1
.F S VSTDT=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"ARVM03",VSTDT)) Q:VSTDT="" D
..S TEST=""
..F S TEST=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"ARVM03",VSTDT,TEST)) Q:TEST="" S CNTM03=CNTM03+1
.F S VSTDT=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"ARVM05",VSTDT)) Q:VSTDT="" D
..S TEST=""
..F S TEST=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"ARVM05",VSTDT,TEST)) Q:TEST="" S CNTM05=CNTM05+1
.I CNTM02+CNTM03+CNTM05=0 Q
.S ARVTOT=ARVTOT+1
.I CNTM02+CNTM03+CNTM05=1 S CNT2=CNT2+1 Q
.; 3 different criteria will classify medications as HAART
.I CNTM03>2 S CNT1=CNT1+1 Q
.I CNTM05>1,CNTM03>0 S CNT1=CNT1+1 Q
.I CNTM03>1,CNTM02+CNTM05>0 S CNT1=CNT1+1 Q
.S CNT3=CNT3+1
I ARVTOT=0 Q
S ^TMP("BKMVQCR",$J,"ARVT","TOTAL","CNT")=ARVTOT
S ^TMP("BKMVQCR",$J,"ARVT","TOTAL","PERC")=ARVTOT/PTOTAL*100
S ^TMP("BKMVQCR",$J,"ARVT","HAART","CNT")=CNT1
S ^TMP("BKMVQCR",$J,"ARVT","HAART","PERC")=CNT1/ARVTOT*100
S ^TMP("BKMVQCR",$J,"ARVT","MONO","CNT")=CNT2
S ^TMP("BKMVQCR",$J,"ARVT","MONO","PERC")=CNT2/ARVTOT*100
S ^TMP("BKMVQCR",$J,"ARVT","OTHER","CNT")=CNT3
S ^TMP("BKMVQCR",$J,"ARVT","OTHER","PERC")=CNT3/ARVTOT*100
Q
PCP ; EP - PCP Calculation
N PCPTOT,CD4TOT
S CD4TOT=$G(^TMP("BKMVQCR",$J,"CD4T","BET50/200 ANY","CNT"))
I CD4TOT<1 Q
S PCPTOT=$G(^TMP("BKMVQCR",$J,"HIVCHK","PCPPTCNT"))
S ^TMP("BKMVQCR",$J,"PCPT","TOTAL","CNT")=PCPTOT
S ^TMP("BKMVQCR",$J,"PCPT","TOTAL","PERC")=PCPTOT/CD4TOT*100
Q
MAC ; EP - MAC Calculation
N MACTOT,CD4TOT
S CD4TOT=$G(^TMP("BKMVQCR",$J,"CD4T","LT50 ANY","CNT"))
I CD4TOT<1 Q
S MACTOT=$G(^TMP("BKMVQCR",$J,"HIVCHK","MACPTCNT"))
S ^TMP("BKMVQCR",$J,"MACT","TOTAL","CNT")=MACTOT
S ^TMP("BKMVQCR",$J,"MACT","TOTAL","PERC")=MACTOT/CD4TOT*100
Q
TOBCALC ; EP - Tobacco use Calculation
N DFN,CNT1,CNT2,CNT3,CNT4,PTOTAL,TOBTOT
S PTOTAL=$G(^TMP("BKMVQCR",$J,"HIVTOT1"))
I PTOTAL=0 Q
S TOBTOT=$G(^TMP("BKMVQCR",$J,"HIVCHK","TOBTOT"))
I TOBTOT<1 Q
S DFN=0,(CNT1,CNT2,CNT3,CNT4)=0
F S DFN=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN)) Q:'DFN D
.I '$D(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"TOB")) Q ; Only sub-total those who have been screened
.I $D(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"TOBUSER")) S CNT1=CNT1+1 D Q ; Current Tobacco User
..;Only count tobacco counseling on current tobacco users
..I $D(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"TOBED")) S CNT2=CNT2+1
..Q
.I $D(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"TOBNONUSER")) S CNT3=CNT3+1 Q ; Non-Current Tobacco User
.S CNT4=CNT4+1 ; Screened, but not documented as to Current or Non-Current Tobacco User
S ^TMP("BKMVQCR",$J,"TOBT","SCREEN","CNT")=TOBTOT
S ^TMP("BKMVQCR",$J,"TOBT","SCREEN","PERC")=TOBTOT/PTOTAL*100
S ^TMP("BKMVQCR",$J,"TOBT","USER","CNT")=CNT1
S ^TMP("BKMVQCR",$J,"TOBT","USER","PERC")=CNT1/TOBTOT*100
S ^TMP("BKMVQCR",$J,"TOBT","ED","CNT")=CNT2
S ^TMP("BKMVQCR",$J,"TOBT","ED","PERC")=CNT2/TOBTOT*100
S ^TMP("BKMVQCR",$J,"TOBT","NON","CNT")=CNT3
S ^TMP("BKMVQCR",$J,"TOBT","NON","PERC")=CNT3/TOBTOT*100
S ^TMP("BKMVQCR",$J,"TOBT","UNK","CNT")=CNT4
S ^TMP("BKMVQCR",$J,"TOBT","UNK","PERC")=CNT4/TOBTOT*100
Q
SUBCALC ; EP - Substance abuse Calculation
N DFN,PTOTAL,CNT1,CNT2,CNT3,CNT4
S PTOTAL=$G(^TMP("BKMVQCR",$J,"HIVTOT1"))
I PTOTAL=0 Q
S DFN=0,CNT1=0,CNT2=0
F S DFN=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN)) Q:'DFN D
. I $D(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"SUBS01")) S CNT1=CNT1+1
I CNT1<1 Q
S DFN=0
F S DFN=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN)) Q:'DFN D
. I $D(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"SUBS01CURR")) S CNT2=CNT2+1
; No info on how to calculate 'Not Current', or 'IV'. Assume 0 for now.
S CNT3=0,CNT4=0
S ^TMP("BKMVQCR",$J,"SUBST","TOTAL","CNT")=CNT1
S ^TMP("BKMVQCR",$J,"SUBST","TOTAL","PERC")=CNT1/PTOTAL*100
S ^TMP("BKMVQCR",$J,"SUBST","CURRENT","CNT")=CNT2
S ^TMP("BKMVQCR",$J,"SUBST","CURRENT","PERC")=CNT2/CNT1*100
; Can't calculate yet.
;S ^TMP("BKMVQCR",$J,"SUBST","IV","CNT")=CNT3
;S ^TMP("BKMVQCR",$J,"SUBST","IV","PERC")=CNT3/CNT2*100
;S ^TMP("BKMVQCR",$J,"SUBST","NOT","CNT")=CNT4
;S ^TMP("BKMVQCR",$J,"SUBST","NOT","PERC")=CNT4/CNT1*100
S ^TMP("BKMVQCR",$J,"SUBST","UNK","CNT")=CNT1-(CNT2+CNT4)
S ^TMP("BKMVQCR",$J,"SUBST","UNK","PERC")=CNT1-(CNT2+CNT4)/CNT1*100
Q
BKMVQCR9 ;PRXM/HC/BWF - BKMV Quality of Care Report; [ 1/19/2005 7:16 PM ]
+1 ;;2.1;HIV MANAGEMENT SYSTEM;;Feb 07, 2011
+2 ; Quality of Care Audit Report
+3 QUIT
ARVCALC ; EP - ARV Calculation
+1 NEW ARVTOT,DFN,PTOTAL,CNT1,CNT2,CNT3,VSTDT,TEST,CNTM02,CNTM03,CNTM05
+2 SET PTOTAL=$GET(^TMP("BKMVQCR",$JOB,"HIVTOT1"))
+3 SET ARVTOT=0
SET DFN=0
SET (CNT1,CNT2,CNT3)=0
+4 FOR
SET DFN=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN))
IF 'DFN
QUIT
Begin DoDot:1
+5 SET VSTDT=""
SET CNTM02=0
SET CNTM03=0
SET CNTM05=0
+6 FOR
SET VSTDT=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"ARVM02",VSTDT))
IF VSTDT=""
QUIT
Begin DoDot:2
+7 SET TEST=""
+8 FOR
SET TEST=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"ARVM02",VSTDT,TEST))
IF TEST=""
QUIT
SET CNTM02=CNTM02+1
End DoDot:2
+9 FOR
SET VSTDT=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"ARVM03",VSTDT))
IF VSTDT=""
QUIT
Begin DoDot:2
+10 SET TEST=""
+11 FOR
SET TEST=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"ARVM03",VSTDT,TEST))
IF TEST=""
QUIT
SET CNTM03=CNTM03+1
End DoDot:2
+12 FOR
SET VSTDT=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"ARVM05",VSTDT))
IF VSTDT=""
QUIT
Begin DoDot:2
+13 SET TEST=""
+14 FOR
SET TEST=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"ARVM05",VSTDT,TEST))
IF TEST=""
QUIT
SET CNTM05=CNTM05+1
End DoDot:2
+15 IF CNTM02+CNTM03+CNTM05=0
QUIT
+16 SET ARVTOT=ARVTOT+1
+17 IF CNTM02+CNTM03+CNTM05=1
SET CNT2=CNT2+1
QUIT
+18 ; 3 different criteria will classify medications as HAART
+19 IF CNTM03>2
SET CNT1=CNT1+1
QUIT
+20 IF CNTM05>1
IF CNTM03>0
SET CNT1=CNT1+1
QUIT
+21 IF CNTM03>1
IF CNTM02+CNTM05>0
SET CNT1=CNT1+1
QUIT
+22 SET CNT3=CNT3+1
End DoDot:1
+23 IF ARVTOT=0
QUIT
+24 SET ^TMP("BKMVQCR",$JOB,"ARVT","TOTAL","CNT")=ARVTOT
+25 SET ^TMP("BKMVQCR",$JOB,"ARVT","TOTAL","PERC")=ARVTOT/PTOTAL*100
+26 SET ^TMP("BKMVQCR",$JOB,"ARVT","HAART","CNT")=CNT1
+27 SET ^TMP("BKMVQCR",$JOB,"ARVT","HAART","PERC")=CNT1/ARVTOT*100
+28 SET ^TMP("BKMVQCR",$JOB,"ARVT","MONO","CNT")=CNT2
+29 SET ^TMP("BKMVQCR",$JOB,"ARVT","MONO","PERC")=CNT2/ARVTOT*100
+30 SET ^TMP("BKMVQCR",$JOB,"ARVT","OTHER","CNT")=CNT3
+31 SET ^TMP("BKMVQCR",$JOB,"ARVT","OTHER","PERC")=CNT3/ARVTOT*100
+32 QUIT
PCP ; EP - PCP Calculation
+1 NEW PCPTOT,CD4TOT
+2 SET CD4TOT=$GET(^TMP("BKMVQCR",$JOB,"CD4T","BET50/200 ANY","CNT"))
+3 IF CD4TOT<1
QUIT
+4 SET PCPTOT=$GET(^TMP("BKMVQCR",$JOB,"HIVCHK","PCPPTCNT"))
+5 SET ^TMP("BKMVQCR",$JOB,"PCPT","TOTAL","CNT")=PCPTOT
+6 SET ^TMP("BKMVQCR",$JOB,"PCPT","TOTAL","PERC")=PCPTOT/CD4TOT*100
+7 QUIT
MAC ; EP - MAC Calculation
+1 NEW MACTOT,CD4TOT
+2 SET CD4TOT=$GET(^TMP("BKMVQCR",$JOB,"CD4T","LT50 ANY","CNT"))
+3 IF CD4TOT<1
QUIT
+4 SET MACTOT=$GET(^TMP("BKMVQCR",$JOB,"HIVCHK","MACPTCNT"))
+5 SET ^TMP("BKMVQCR",$JOB,"MACT","TOTAL","CNT")=MACTOT
+6 SET ^TMP("BKMVQCR",$JOB,"MACT","TOTAL","PERC")=MACTOT/CD4TOT*100
+7 QUIT
TOBCALC ; EP - Tobacco use Calculation
+1 NEW DFN,CNT1,CNT2,CNT3,CNT4,PTOTAL,TOBTOT
+2 SET PTOTAL=$GET(^TMP("BKMVQCR",$JOB,"HIVTOT1"))
+3 IF PTOTAL=0
QUIT
+4 SET TOBTOT=$GET(^TMP("BKMVQCR",$JOB,"HIVCHK","TOBTOT"))
+5 IF TOBTOT<1
QUIT
+6 SET DFN=0
SET (CNT1,CNT2,CNT3,CNT4)=0
+7 FOR
SET DFN=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN))
IF 'DFN
QUIT
Begin DoDot:1
+8 ; Only sub-total those who have been screened
IF '$DATA(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"TOB"))
QUIT
+9 ; Current Tobacco User
IF $DATA(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"TOBUSER"))
SET CNT1=CNT1+1
Begin DoDot:2
+10 ;Only count tobacco counseling on current tobacco users
+11 IF $DATA(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"TOBED"))
SET CNT2=CNT2+1
+12 QUIT
End DoDot:2
QUIT
+13 ; Non-Current Tobacco User
IF $DATA(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"TOBNONUSER"))
SET CNT3=CNT3+1
QUIT
+14 ; Screened, but not documented as to Current or Non-Current Tobacco User
SET CNT4=CNT4+1
End DoDot:1
+15 SET ^TMP("BKMVQCR",$JOB,"TOBT","SCREEN","CNT")=TOBTOT
+16 SET ^TMP("BKMVQCR",$JOB,"TOBT","SCREEN","PERC")=TOBTOT/PTOTAL*100
+17 SET ^TMP("BKMVQCR",$JOB,"TOBT","USER","CNT")=CNT1
+18 SET ^TMP("BKMVQCR",$JOB,"TOBT","USER","PERC")=CNT1/TOBTOT*100
+19 SET ^TMP("BKMVQCR",$JOB,"TOBT","ED","CNT")=CNT2
+20 SET ^TMP("BKMVQCR",$JOB,"TOBT","ED","PERC")=CNT2/TOBTOT*100
+21 SET ^TMP("BKMVQCR",$JOB,"TOBT","NON","CNT")=CNT3
+22 SET ^TMP("BKMVQCR",$JOB,"TOBT","NON","PERC")=CNT3/TOBTOT*100
+23 SET ^TMP("BKMVQCR",$JOB,"TOBT","UNK","CNT")=CNT4
+24 SET ^TMP("BKMVQCR",$JOB,"TOBT","UNK","PERC")=CNT4/TOBTOT*100
+25 QUIT
SUBCALC ; EP - Substance abuse Calculation
+1 NEW DFN,PTOTAL,CNT1,CNT2,CNT3,CNT4
+2 SET PTOTAL=$GET(^TMP("BKMVQCR",$JOB,"HIVTOT1"))
+3 IF PTOTAL=0
QUIT
+4 SET DFN=0
SET CNT1=0
SET CNT2=0
+5 FOR
SET DFN=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN))
IF 'DFN
QUIT
Begin DoDot:1
+6 IF $DATA(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"SUBS01"))
SET CNT1=CNT1+1
End DoDot:1
+7 IF CNT1<1
QUIT
+8 SET DFN=0
+9 FOR
SET DFN=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN))
IF 'DFN
QUIT
Begin DoDot:1
+10 IF $DATA(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"SUBS01CURR"))
SET CNT2=CNT2+1
End DoDot:1
+11 ; No info on how to calculate 'Not Current', or 'IV'. Assume 0 for now.
+12 SET CNT3=0
SET CNT4=0
+13 SET ^TMP("BKMVQCR",$JOB,"SUBST","TOTAL","CNT")=CNT1
+14 SET ^TMP("BKMVQCR",$JOB,"SUBST","TOTAL","PERC")=CNT1/PTOTAL*100
+15 SET ^TMP("BKMVQCR",$JOB,"SUBST","CURRENT","CNT")=CNT2
+16 SET ^TMP("BKMVQCR",$JOB,"SUBST","CURRENT","PERC")=CNT2/CNT1*100
+17 ; Can't calculate yet.
+18 ;S ^TMP("BKMVQCR",$J,"SUBST","IV","CNT")=CNT3
+19 ;S ^TMP("BKMVQCR",$J,"SUBST","IV","PERC")=CNT3/CNT2*100
+20 ;S ^TMP("BKMVQCR",$J,"SUBST","NOT","CNT")=CNT4
+21 ;S ^TMP("BKMVQCR",$J,"SUBST","NOT","PERC")=CNT4/CNT1*100
+22 SET ^TMP("BKMVQCR",$JOB,"SUBST","UNK","CNT")=CNT1-(CNT2+CNT4)
+23 SET ^TMP("BKMVQCR",$JOB,"SUBST","UNK","PERC")=CNT1-(CNT2+CNT4)/CNT1*100
+24 QUIT