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

BKMVQCR6.m

Go to the documentation of this file.
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