BKMVQCR6 ;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
CD4CALC ; EP - CD4 calculation
N CD4TOT,DFN,CNT1,CNT2,CNT3,CNT4,CNT5,CNT6,FOUND,FOUND1,FOUND2,VSTDT,TEST,CD4CNT,PTOTAL
S PTOTAL=$G(^TMP("BKMVQCR",$J,"HIVTOT1"))
S CD4TOT=$G(^TMP("BKMVQCR",$J,"HIVCHK","CD4PTCNT"))
I CD4TOT=""!(CD4TOT=0) Q
S DFN=0,(CNT1,CNT2,CNT3,CNT4,CNT5,CNT6)=0
F S DFN=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN)) Q:'DFN D
.I '$D(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"CD4ABS")),'$D(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"CD4ALL")) Q
.S VSTDT="",(FOUND,FOUND1,FOUND2)=0
.F S VSTDT=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"CD4ABS",VSTDT),-1) Q:VSTDT=""!(FOUND&FOUND1&FOUND2) D
..S TEST=""
..F S TEST=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"CD4ABS",VSTDT,TEST),-1) Q:TEST=""!(FOUND&FOUND1&FOUND2) D
...S CD4CNT=$P($G(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"CD4ABS",VSTDT,TEST)),U)
...I CD4CNT'?1N.E Q
...;S FOUND=1
...I CD4CNT<50,'FOUND1 S:'FOUND CNT1=CNT1+1,FOUND=1 S FOUND1=1 Q
...I CD4CNT<200,'FOUND2 S:'FOUND CNT2=CNT2+1,FOUND=1 S FOUND2=1 Q
...S:'FOUND CNT3=CNT3+1
...S FOUND=1
.I 'FOUND S CNT4=CNT4+1 Q ; Includes patients with no ABS test but with an ALL test.
.I FOUND1 S CNT5=CNT5+1
.I FOUND2 S CNT6=CNT6+1
S ^TMP("BKMVQCR",$J,"CD4T","TOTAL","CNT")=CD4TOT
S ^TMP("BKMVQCR",$J,"CD4T","TOTAL","PERC")=CD4TOT/PTOTAL*100
S ^TMP("BKMVQCR",$J,"CD4T","LT50","PERC")=CNT1/CD4TOT*100
S ^TMP("BKMVQCR",$J,"CD4T","LT50","CNT")=CNT1
S ^TMP("BKMVQCR",$J,"CD4T","BET50/200","PERC")=CNT2/CD4TOT*100
S ^TMP("BKMVQCR",$J,"CD4T","BET50/200","CNT")=CNT2
S ^TMP("BKMVQCR",$J,"CD4T","GTE200","PERC")=CNT3/CD4TOT*100
S ^TMP("BKMVQCR",$J,"CD4T","GTE200","CNT")=CNT3
S ^TMP("BKMVQCR",$J,"CD4T","UND","PERC")=CNT4/CD4TOT*100
S ^TMP("BKMVQCR",$J,"CD4T","UND","CNT")=CNT4
S ^TMP("BKMVQCR",$J,"CD4T","LT50 ANY","CNT")=CNT5
S ^TMP("BKMVQCR",$J,"CD4T","BET50/200 ANY","CNT")=CNT6
Q
VRLLDC ; EP - Viral Load Calculation
N VRLTOT,DFN,CNT1,CNT2,CNT3,VSTDT,TEST,VRLRES,FOUND,PTOTAL
S PTOTAL=$G(^TMP("BKMVQCR",$J,"HIVTOT1"))
S VRLTOT=$G(^TMP("BKMVQCR",$J,"HIVCHK","VRLPTCNT"))
I VRLTOT=""!(VRLTOT=0) Q
S DFN=0,(CNT1,CNT2,CNT3)=0
F S DFN=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN)) Q:'DFN D
.I '$D(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"VRL")) Q
.S VSTDT="",FOUND=0
.F S VSTDT=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"VRL",VSTDT),-1) Q:VSTDT=""!FOUND D
..S TEST=""
..F S TEST=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"VRL",VSTDT,TEST),-1) Q:TEST=""!FOUND D
...S VRLRES=$P($G(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"VRL",VSTDT,TEST)),U)
...I VRLRES'?1N.E Q
...S FOUND=1
...I VRLRES<100000 S CNT1=CNT1+1 Q
...S CNT2=CNT2+1
.I 'FOUND S CNT3=CNT3+1
S ^TMP("BKMVQCR",$J,"VRLT","TOTAL","CNT")=VRLTOT
S ^TMP("BKMVQCR",$J,"VRLT","TOTAL","PERC")=VRLTOT/PTOTAL*100
S ^TMP("BKMVQCR",$J,"VRLT","LT100K","CNT")=CNT1
S ^TMP("BKMVQCR",$J,"VRLT","LT100K","PERC")=CNT1/VRLTOT*100
S ^TMP("BKMVQCR",$J,"VRLT","GTE100K","CNT")=CNT2
S ^TMP("BKMVQCR",$J,"VRLT","GTE100K","PERC")=CNT2/VRLTOT*100
S ^TMP("BKMVQCR",$J,"VRLT","UNK","CNT")=CNT3
S ^TMP("BKMVQCR",$J,"VRLT","UNK","PERC")=CNT3/VRLTOT*100
Q
RPRCALC ; EP - Rapid Plasma Reagin (and FTA-ABS) Calculation
N TOTALRPR,DFN,CNT1,CNT2,CNT3,CNT4,CNT5,VSTDT,TEST,RPRRES,PTOTAL,REFVSTDT,DFNSTAT
S PTOTAL=$G(^TMP("BKMVQCR",$J,"HIVTOT1"))
S TOTALRPR=$G(^TMP("BKMVQCR",$J,"HIVCHK","RPRPTCNT"))
I +TOTALRPR=0 Q
S DFN=0,(CNT1,CNT2,CNT3,CNT4,CNT5)=0
F S DFN=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN)) Q:'DFN D
.I '$D(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"RPRREF")),'$D(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"RPR")) Q
.S VSTDT="",FOUND=0,DFNSTAT=0
.F S VSTDT=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"RPR",VSTDT),-1) Q:VSTDT="" D Q:FOUND
..S TEST=""
..F S TEST=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"RPR",VSTDT,TEST),-1) Q:TEST="" D Q:FOUND
...S RPRRES=$P($G(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"RPR",VSTDT,TEST)),U)
...I $$POSITIVE^BKMVF32(RPRRES) S DFNSTAT=1,FOUND=1 Q
...I $$NEGATIVE^BKMVF32(RPRRES) S DFNSTAT=2,FOUND=1 Q
.S REFVSTDT=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"RPRREF",""),-1)
.D
..I REFVSTDT'="",REFVSTDT>VSTDT D Q
...S TEST=$O(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"RPRREF",REFVSTDT,""),-1)
...S RPRRES=$P($G(^TMP("BKMVQCR",$J,"HIVCHK",DFN,"RPRREF",REFVSTDT,TEST)),U)
...I $P(RPRRES,"^")="NOT MEDICALLY INDICATED" S CNT5=CNT5+1 Q
...S CNT4=CNT4+1
..I DFNSTAT=1 S CNT1=CNT1+1 Q
..I DFNSTAT=2 S CNT2=CNT2+1 Q
..S CNT3=CNT3+1
S ^TMP("BKMVQCR",$J,"RPRT","TOTAL","CNT")=TOTALRPR
S ^TMP("BKMVQCR",$J,"RPRT","TOTAL","PERC")=TOTALRPR/PTOTAL*100
S ^TMP("BKMVQCR",$J,"RPRT","REAC","CNT")=CNT1
S ^TMP("BKMVQCR",$J,"RPRT","REAC","PERC")=CNT1/TOTALRPR*100
S ^TMP("BKMVQCR",$J,"RPRT","NONREAC","CNT")=CNT2
S ^TMP("BKMVQCR",$J,"RPRT","NONREAC","PERC")=CNT2/TOTALRPR*100
S ^TMP("BKMVQCR",$J,"RPRT","UND","CNT")=CNT3
S ^TMP("BKMVQCR",$J,"RPRT","UND","PERC")=CNT3/TOTALRPR*100
S ^TMP("BKMVQCR",$J,"RPRT","REF","CNT")=CNT4
S ^TMP("BKMVQCR",$J,"RPRT","REF","PERC")=CNT4/TOTALRPR*100
S ^TMP("BKMVQCR",$J,"RPRT","REFNMI","CNT")=CNT5
S ^TMP("BKMVQCR",$J,"RPRT","REFNMI","PERC")=CNT5/TOTALRPR*100
Q
BKMVQCR6 ;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
CD4CALC ; EP - CD4 calculation
+1 NEW CD4TOT,DFN,CNT1,CNT2,CNT3,CNT4,CNT5,CNT6,FOUND,FOUND1,FOUND2,VSTDT,TEST,CD4CNT,PTOTAL
+2 SET PTOTAL=$GET(^TMP("BKMVQCR",$JOB,"HIVTOT1"))
+3 SET CD4TOT=$GET(^TMP("BKMVQCR",$JOB,"HIVCHK","CD4PTCNT"))
+4 IF CD4TOT=""!(CD4TOT=0)
QUIT
+5 SET DFN=0
SET (CNT1,CNT2,CNT3,CNT4,CNT5,CNT6)=0
+6 FOR
SET DFN=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN))
IF 'DFN
QUIT
Begin DoDot:1
+7 IF '$DATA(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"CD4ABS"))
IF '$DATA(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"CD4ALL"))
QUIT
+8 SET VSTDT=""
SET (FOUND,FOUND1,FOUND2)=0
+9 FOR
SET VSTDT=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"CD4ABS",VSTDT),-1)
IF VSTDT=""!(FOUND&FOUND1&FOUND2)
QUIT
Begin DoDot:2
+10 SET TEST=""
+11 FOR
SET TEST=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"CD4ABS",VSTDT,TEST),-1)
IF TEST=""!(FOUND&FOUND1&FOUND2)
QUIT
Begin DoDot:3
+12 SET CD4CNT=$PIECE($GET(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"CD4ABS",VSTDT,TEST)),U)
+13 IF CD4CNT'?1N.E
QUIT
+14 ;S FOUND=1
+15 IF CD4CNT<50
IF 'FOUND1
IF 'FOUND
SET CNT1=CNT1+1
SET FOUND=1
SET FOUND1=1
QUIT
+16 IF CD4CNT<200
IF 'FOUND2
IF 'FOUND
SET CNT2=CNT2+1
SET FOUND=1
SET FOUND2=1
QUIT
+17 IF 'FOUND
SET CNT3=CNT3+1
+18 SET FOUND=1
End DoDot:3
End DoDot:2
+19 ; Includes patients with no ABS test but with an ALL test.
IF 'FOUND
SET CNT4=CNT4+1
QUIT
+20 IF FOUND1
SET CNT5=CNT5+1
+21 IF FOUND2
SET CNT6=CNT6+1
End DoDot:1
+22 SET ^TMP("BKMVQCR",$JOB,"CD4T","TOTAL","CNT")=CD4TOT
+23 SET ^TMP("BKMVQCR",$JOB,"CD4T","TOTAL","PERC")=CD4TOT/PTOTAL*100
+24 SET ^TMP("BKMVQCR",$JOB,"CD4T","LT50","PERC")=CNT1/CD4TOT*100
+25 SET ^TMP("BKMVQCR",$JOB,"CD4T","LT50","CNT")=CNT1
+26 SET ^TMP("BKMVQCR",$JOB,"CD4T","BET50/200","PERC")=CNT2/CD4TOT*100
+27 SET ^TMP("BKMVQCR",$JOB,"CD4T","BET50/200","CNT")=CNT2
+28 SET ^TMP("BKMVQCR",$JOB,"CD4T","GTE200","PERC")=CNT3/CD4TOT*100
+29 SET ^TMP("BKMVQCR",$JOB,"CD4T","GTE200","CNT")=CNT3
+30 SET ^TMP("BKMVQCR",$JOB,"CD4T","UND","PERC")=CNT4/CD4TOT*100
+31 SET ^TMP("BKMVQCR",$JOB,"CD4T","UND","CNT")=CNT4
+32 SET ^TMP("BKMVQCR",$JOB,"CD4T","LT50 ANY","CNT")=CNT5
+33 SET ^TMP("BKMVQCR",$JOB,"CD4T","BET50/200 ANY","CNT")=CNT6
+34 QUIT
VRLLDC ; EP - Viral Load Calculation
+1 NEW VRLTOT,DFN,CNT1,CNT2,CNT3,VSTDT,TEST,VRLRES,FOUND,PTOTAL
+2 SET PTOTAL=$GET(^TMP("BKMVQCR",$JOB,"HIVTOT1"))
+3 SET VRLTOT=$GET(^TMP("BKMVQCR",$JOB,"HIVCHK","VRLPTCNT"))
+4 IF VRLTOT=""!(VRLTOT=0)
QUIT
+5 SET DFN=0
SET (CNT1,CNT2,CNT3)=0
+6 FOR
SET DFN=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN))
IF 'DFN
QUIT
Begin DoDot:1
+7 IF '$DATA(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"VRL"))
QUIT
+8 SET VSTDT=""
SET FOUND=0
+9 FOR
SET VSTDT=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"VRL",VSTDT),-1)
IF VSTDT=""!FOUND
QUIT
Begin DoDot:2
+10 SET TEST=""
+11 FOR
SET TEST=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"VRL",VSTDT,TEST),-1)
IF TEST=""!FOUND
QUIT
Begin DoDot:3
+12 SET VRLRES=$PIECE($GET(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"VRL",VSTDT,TEST)),U)
+13 IF VRLRES'?1N.E
QUIT
+14 SET FOUND=1
+15 IF VRLRES<100000
SET CNT1=CNT1+1
QUIT
+16 SET CNT2=CNT2+1
End DoDot:3
End DoDot:2
+17 IF 'FOUND
SET CNT3=CNT3+1
End DoDot:1
+18 SET ^TMP("BKMVQCR",$JOB,"VRLT","TOTAL","CNT")=VRLTOT
+19 SET ^TMP("BKMVQCR",$JOB,"VRLT","TOTAL","PERC")=VRLTOT/PTOTAL*100
+20 SET ^TMP("BKMVQCR",$JOB,"VRLT","LT100K","CNT")=CNT1
+21 SET ^TMP("BKMVQCR",$JOB,"VRLT","LT100K","PERC")=CNT1/VRLTOT*100
+22 SET ^TMP("BKMVQCR",$JOB,"VRLT","GTE100K","CNT")=CNT2
+23 SET ^TMP("BKMVQCR",$JOB,"VRLT","GTE100K","PERC")=CNT2/VRLTOT*100
+24 SET ^TMP("BKMVQCR",$JOB,"VRLT","UNK","CNT")=CNT3
+25 SET ^TMP("BKMVQCR",$JOB,"VRLT","UNK","PERC")=CNT3/VRLTOT*100
+26 QUIT
RPRCALC ; EP - Rapid Plasma Reagin (and FTA-ABS) Calculation
+1 NEW TOTALRPR,DFN,CNT1,CNT2,CNT3,CNT4,CNT5,VSTDT,TEST,RPRRES,PTOTAL,REFVSTDT,DFNSTAT
+2 SET PTOTAL=$GET(^TMP("BKMVQCR",$JOB,"HIVTOT1"))
+3 SET TOTALRPR=$GET(^TMP("BKMVQCR",$JOB,"HIVCHK","RPRPTCNT"))
+4 IF +TOTALRPR=0
QUIT
+5 SET DFN=0
SET (CNT1,CNT2,CNT3,CNT4,CNT5)=0
+6 FOR
SET DFN=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN))
IF 'DFN
QUIT
Begin DoDot:1
+7 IF '$DATA(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"RPRREF"))
IF '$DATA(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"RPR"))
QUIT
+8 SET VSTDT=""
SET FOUND=0
SET DFNSTAT=0
+9 FOR
SET VSTDT=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"RPR",VSTDT),-1)
IF VSTDT=""
QUIT
Begin DoDot:2
+10 SET TEST=""
+11 FOR
SET TEST=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"RPR",VSTDT,TEST),-1)
IF TEST=""
QUIT
Begin DoDot:3
+12 SET RPRRES=$PIECE($GET(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"RPR",VSTDT,TEST)),U)
+13 IF $$POSITIVE^BKMVF32(RPRRES)
SET DFNSTAT=1
SET FOUND=1
QUIT
+14 IF $$NEGATIVE^BKMVF32(RPRRES)
SET DFNSTAT=2
SET FOUND=1
QUIT
End DoDot:3
IF FOUND
QUIT
End DoDot:2
IF FOUND
QUIT
+15 SET REFVSTDT=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"RPRREF",""),-1)
+16 Begin DoDot:2
+17 IF REFVSTDT'=""
IF REFVSTDT>VSTDT
Begin DoDot:3
+18 SET TEST=$ORDER(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"RPRREF",REFVSTDT,""),-1)
+19 SET RPRRES=$PIECE($GET(^TMP("BKMVQCR",$JOB,"HIVCHK",DFN,"RPRREF",REFVSTDT,TEST)),U)
+20 IF $PIECE(RPRRES,"^")="NOT MEDICALLY INDICATED"
SET CNT5=CNT5+1
QUIT
+21 SET CNT4=CNT4+1
End DoDot:3
QUIT
+22 IF DFNSTAT=1
SET CNT1=CNT1+1
QUIT
+23 IF DFNSTAT=2
SET CNT2=CNT2+1
QUIT
+24 SET CNT3=CNT3+1
End DoDot:2
End DoDot:1
+25 SET ^TMP("BKMVQCR",$JOB,"RPRT","TOTAL","CNT")=TOTALRPR
+26 SET ^TMP("BKMVQCR",$JOB,"RPRT","TOTAL","PERC")=TOTALRPR/PTOTAL*100
+27 SET ^TMP("BKMVQCR",$JOB,"RPRT","REAC","CNT")=CNT1
+28 SET ^TMP("BKMVQCR",$JOB,"RPRT","REAC","PERC")=CNT1/TOTALRPR*100
+29 SET ^TMP("BKMVQCR",$JOB,"RPRT","NONREAC","CNT")=CNT2
+30 SET ^TMP("BKMVQCR",$JOB,"RPRT","NONREAC","PERC")=CNT2/TOTALRPR*100
+31 SET ^TMP("BKMVQCR",$JOB,"RPRT","UND","CNT")=CNT3
+32 SET ^TMP("BKMVQCR",$JOB,"RPRT","UND","PERC")=CNT3/TOTALRPR*100
+33 SET ^TMP("BKMVQCR",$JOB,"RPRT","REF","CNT")=CNT4
+34 SET ^TMP("BKMVQCR",$JOB,"RPRT","REF","PERC")=CNT4/TOTALRPR*100
+35 SET ^TMP("BKMVQCR",$JOB,"RPRT","REFNMI","CNT")=CNT5
+36 SET ^TMP("BKMVQCR",$JOB,"RPRT","REFNMI","PERC")=CNT5/TOTALRPR*100
+37 QUIT