PXRRPCE5 ;HIN/MjK - Clinic Specific Caseload Demographics ;6/7/96
;;1.0;PCE PATIENT CARE ENCOUNTER;;Aug 12, 1996
BP ;_._._._._._._._._._._._._.Blood Pressure_._._._._._._._._._._._._._.
S PXRRDFN=0 F S PXRRDFN=$O(^TMP($J,PXRRCLIN,"CLINIC PATIENTS",PXRRDFN)) Q:'PXRRDFN I $D(^GMR(120.5,"C",PXRRDFN)) S PXRRBIEN=0 F S PXRRBIEN=$O(^GMR(120.5,"C",PXRRDFN,PXRRBIEN)) Q:'PXRRBIEN D
. Q:$P(^GMR(120.5,PXRRBIEN,0),U)'>PXRRSXMO
. Q:$P(^GMR(120.5,PXRRBIEN,0),U)'<DT
. Q:$P(^GMR(120.5,PXRRBIEN,0),U,3)'=1 ;Blood pressures only
. I $P(^GMR(120.5,PXRRBIEN,0),U,8) S X=$P(^(0),U,8),Y=$P(X,"/"),Z=$P(X,"/",2) D
.. ;X = blood pressure ;Y = systolic bp ;Z = diastolic bp
.. I Y>159!(Z>90) S ^TMP($J,"HIBP",PXRRCLIN,PXRRDFN)=Y_"/"_Z_U_$G(^GMR(120.5,PXRRBIEN,0))
S (PXRRBPT,PXRRDFN)=0 F S PXRRDFN=$O(^TMP($J,"HIBP",PXRRCLIN,PXRRDFN)) Q:'PXRRDFN S PXRRBPT=PXRRBPT+1
PERCNT1 ;_._._._._._._._._._.Calculate % Pats by DXS_._._._._._._._._._.
F PXRR="PXRRDM","PXRRHTN","PXRRCAD","PXRRHLIP","PXRRHTDM","PXRRHLIP" S Y=@PXRR S PXRR(PXRR)=$S('Y:0,1:(Y/PXRRVPAT)*100)
PERCNT2 ;_._._._._._._.Percentages for Preventive Medicine Data_._._._._._._.
I PXRRTPAT S PXRR("SMOKE")=(PXRRSMYR/PXRRTPAT)*100 S PXRR("MAMGRM")=$S(+PXRRF50:(PXRRMMYR/PXRRF50)*100,1:"N/A")
I +PXRR("MAMGRM") S PXRR("MAMGRM")=$J(PXRR("MAMGRM"),2,1)
S PXRRHBA1=$S(+PXRRHBA1:$J(PXRRHBA1,2,1),1:PXRRHBA1),PXRRLDL=$S(+PXRRLDL:$J(PXRRLDL,2,1),1:PXRRLDL)
TOTS S ^TMP($J,"CLINIC TOTALS",PXRRCLIN)=PXRRTVS_U_PXRRSESS_U_PXRRAG_U_PXRRCAD_U_$J(PXRR("PXRRCAD"),2,1)_U_PXRRDM_U_$J(PXRR("PXRRDM"),2,1)_U_PXRRHTN_U_$J(PXRR("PXRRHTN"),2,1)_U_PXRRHTDM_U_$J(PXRR("PXRRHTDM"),2,1)_U_PXRRHBA1
S X=PXRRCDSM_U_PXRRLDL_U_PXRRNOLD_U_$J($G(PXRR("PXRRSXUN")),2,1)_U_$J($G(PXRR("PXRRSXER")),2,1)_U_$J($G(PXRR("PXRRSXHP")),2,1)_U_PXRRSMYR_U_PXRRMMYR_U_PXRRUTVS_U_$J($G(PXRR("SMOKE")),2,1)
S Y=$G(PXRR("MAMGRM"))_U_$J(PXRRHLIP,2,1)_U_$J($G(PXRR("PXRRHLIP")),2,1)_U_PXRRRTVS_U_$J(PXRRPTSS,2,1)_U_PXRRMPAT_U_PXRRFPAT_U_PXRRHBG7_U_PXRRGL_U_PXRRCHOL_U_PXRRCDSX_U_$J(PXRR("PXRRPSUT"),2,1)_U_$J(PXRR("PXRRCOST"),4,2)
S Z=PXRRBPT_U_PXRRF50
S ^TMP($J,"CLINIC TOTALS",PXRRCLIN)=^TMP($J,"CLINIC TOTALS",PXRRCLIN)_U_X_U_Y_U_Z
Q
MEAN ;_._._._._._.Calculate Mean Against Selected Clinics_._._._._._._.
S (X,Y)=0 F S X=$O(^TMP($J,"CLINIC TOTALS",X)) Q:'X S Y=Y+1
S PXRRCNUM=Y
F I=5,7,9,11,12,13,14,16,17,18,21,22,23,25,30,31,32,33,34,35,36 S ^TMP($J,"MEAN",I)=0,PXRRCLIN=0 F S PXRRCLIN=$O(^TMP($J,"CLINIC TOTALS",PXRRCLIN)) Q:'PXRRCLIN D
. I I=12!(I=14) S Z=$P(^TMP($J,"CLINIC TOTALS",PXRRCLIN),U,I),^TMP($J,"MEAN",I)=^TMP($J,"MEAN",I)+$S('Z&(PXRRCNUM-1):^TMP($J,"MEAN",I)/(PXRRCNUM-1),1:Z) Q
. S Z=$P(^TMP($J,"CLINIC TOTALS",PXRRCLIN),U,I),^TMP($J,"MEAN",I)=^TMP($J,"MEAN",I)+Z
F I=35 S ^TMP($J,"MEAN",I)=^TMP($J,"MEAN",I)/PXRRCNUM,^TMP($J,"MEAN",I)=$S(+^TMP($J,"MEAN",I):$J(^TMP($J,"MEAN",I),4,2),1:"N/A")
F I=12,14 S ^TMP($J,"MEAN",I)=^TMP($J,"MEAN",I)/PXRRCNUM,^TMP($J,"MEAN",I)=$S(+^TMP($J,"MEAN",I):$J(^TMP($J,"MEAN",I),2,1),1:"N/A")
F I=5,7,9,11,13,16,17,18,21,22,23,25,30,31,32,33,34,36 S ^TMP($J,"MEAN",I)=$J((^TMP($J,"MEAN",I)/PXRRCNUM),2,1)
Q
INITVAR S (PXRRCAD,PXRRSESS,PXRRAG,PXRRAGE,PXRRTVS,PXRRSXUN,PXRRVPAT,PXRRQPAT,PXRRTPAT,PXRRMPAT,PXRRPSUT,PXRRCOST)=0
S X1=PXRREDT,X2=-180 D C^%DTC S PXRRSXMO=X,X1=PXRREDT,X2=-365 D C^%DTC S PXRRYR=X
Q
PXRRPCE5 ;HIN/MjK - Clinic Specific Caseload Demographics ;6/7/96
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;;Aug 12, 1996
BP ;_._._._._._._._._._._._._.Blood Pressure_._._._._._._._._._._._._._.
+1 SET PXRRDFN=0
FOR
SET PXRRDFN=$ORDER(^TMP($JOB,PXRRCLIN,"CLINIC PATIENTS",PXRRDFN))
IF 'PXRRDFN
QUIT
IF $DATA(^GMR(120.5,"C",PXRRDFN))
SET PXRRBIEN=0
FOR
SET PXRRBIEN=$ORDER(^GMR(120.5,"C",PXRRDFN,PXRRBIEN))
IF 'PXRRBIEN
QUIT
Begin DoDot:1
+2 IF $PIECE(^GMR(120.5,PXRRBIEN,0),U)'>PXRRSXMO
QUIT
+3 IF $PIECE(^GMR(120.5,PXRRBIEN,0),U)'<DT
QUIT
+4 ;Blood pressures only
IF $PIECE(^GMR(120.5,PXRRBIEN,0),U,3)'=1
QUIT
+5 IF $PIECE(^GMR(120.5,PXRRBIEN,0),U,8)
SET X=$PIECE(^(0),U,8)
SET Y=$PIECE(X,"/")
SET Z=$PIECE(X,"/",2)
Begin DoDot:2
+6 ;X = blood pressure ;Y = systolic bp ;Z = diastolic bp
+7 IF Y>159!(Z>90)
SET ^TMP($JOB,"HIBP",PXRRCLIN,PXRRDFN)=Y_"/"_Z_U_$GET(^GMR(120.5,PXRRBIEN,0))
End DoDot:2
End DoDot:1
+8 SET (PXRRBPT,PXRRDFN)=0
FOR
SET PXRRDFN=$ORDER(^TMP($JOB,"HIBP",PXRRCLIN,PXRRDFN))
IF 'PXRRDFN
QUIT
SET PXRRBPT=PXRRBPT+1
PERCNT1 ;_._._._._._._._._._.Calculate % Pats by DXS_._._._._._._._._._.
+1 FOR PXRR="PXRRDM","PXRRHTN","PXRRCAD","PXRRHLIP","PXRRHTDM","PXRRHLIP"
SET Y=@PXRR
SET PXRR(PXRR)=$SELECT('Y:0,1:(Y/PXRRVPAT)*100)
PERCNT2 ;_._._._._._._.Percentages for Preventive Medicine Data_._._._._._._.
+1 IF PXRRTPAT
SET PXRR("SMOKE")=(PXRRSMYR/PXRRTPAT)*100
SET PXRR("MAMGRM")=$SELECT(+PXRRF50:(PXRRMMYR/PXRRF50)*100,1:"N/A")
+2 IF +PXRR("MAMGRM")
SET PXRR("MAMGRM")=$JUSTIFY(PXRR("MAMGRM"),2,1)
+3 SET PXRRHBA1=$SELECT(+PXRRHBA1:$JUSTIFY(PXRRHBA1,2,1),1:PXRRHBA1)
SET PXRRLDL=$SELECT(+PXRRLDL:$JUSTIFY(PXRRLDL,2,1),1:PXRRLDL)
TOTS SET ^TMP($JOB,"CLINIC TOTALS",PXRRCLIN)=PXRRTVS_U_PXRRSESS_U_PXRRAG_U_PXRRCAD_U_$JUSTIFY(PXRR("PXRRCAD"),2,1)_U_PXRRDM_U_$JUSTIFY(PXRR("PXRRDM"),2,1)_U_PXRRHTN_U_$JUSTIFY(PXRR("PXRRHTN"),2,1)_U_PXRRHTDM_U_$JUSTIFY(PXRR("PXRRHTDM"),2,1)_U_PXRRHB
A1
+1 SET X=PXRRCDSM_U_PXRRLDL_U_PXRRNOLD_U_$JUSTIFY($GET(PXRR("PXRRSXUN")),2,1)_U_$JUSTIFY($GET(PXRR("PXRRSXER")),2,1)_U_$JUSTIFY($GET(PXRR("PXRRSXHP")),2,1)_U_PXRRSMYR_U_PXRRMMYR_U_PXRRUTVS_U_$JUSTIFY($GET(PXRR("SMOKE")),2,1)
+2 SET Y=$GET(PXRR("MAMGRM"))_U_$JUSTIFY(PXRRHLIP,2,1)_U_$JUSTIFY($GET(PXRR("PXRRHLIP")),2,1)_U_PXRRRTVS_U_$JUSTIFY(PXRRPTSS,2,1)_U_PXRRMPAT_U_PXRRFPAT_U_PXRRHBG7_U_PXRRGL_U_PXRRCHOL_U_PXRRCDSX_U_$JUSTIFY(PXRR("PXRRPSUT"),2,1)_U_...
... $JUSTIFY(PXRR("PXRRCOST"),4,2)
+3 SET Z=PXRRBPT_U_PXRRF50
+4 SET ^TMP($JOB,"CLINIC TOTALS",PXRRCLIN)=^TMP($JOB,"CLINIC TOTALS",PXRRCLIN)_U_X_U_Y_U_Z
+5 QUIT
MEAN ;_._._._._._.Calculate Mean Against Selected Clinics_._._._._._._.
+1 SET (X,Y)=0
FOR
SET X=$ORDER(^TMP($JOB,"CLINIC TOTALS",X))
IF 'X
QUIT
SET Y=Y+1
+2 SET PXRRCNUM=Y
+3 FOR I=5,7,9,11,12,13,14,16,17,18,21,22,23,25,30,31,32,33,34,35,36
SET ^TMP($JOB,"MEAN",I)=0
SET PXRRCLIN=0
FOR
SET PXRRCLIN=$ORDER(^TMP($JOB,"CLINIC TOTALS",PXRRCLIN))
IF 'PXRRCLIN
QUIT
Begin DoDot:1
+4 IF I=12!(I=14)
SET Z=$PIECE(^TMP($JOB,"CLINIC TOTALS",PXRRCLIN),U,I)
SET ^TMP($JOB,"MEAN",I)=^TMP($JOB,"MEAN",I)+$SELECT('Z&(PXRRCNUM-1):^TMP($JOB,"MEAN",I)/(PXRRCNUM-1),1:Z)
QUIT
+5 SET Z=$PIECE(^TMP($JOB,"CLINIC TOTALS",PXRRCLIN),U,I)
SET ^TMP($JOB,"MEAN",I)=^TMP($JOB,"MEAN",I)+Z
End DoDot:1
+6 FOR I=35
SET ^TMP($JOB,"MEAN",I)=^TMP($JOB,"MEAN",I)/PXRRCNUM
SET ^TMP($JOB,"MEAN",I)=$SELECT(+^TMP($JOB,"MEAN",I):$JUSTIFY(^TMP($JOB,"MEAN",I),4,2),1:"N/A")
+7 FOR I=12,14
SET ^TMP($JOB,"MEAN",I)=^TMP($JOB,"MEAN",I)/PXRRCNUM
SET ^TMP($JOB,"MEAN",I)=$SELECT(+^TMP($JOB,"MEAN",I):$JUSTIFY(^TMP($JOB,"MEAN",I),2,1),1:"N/A")
+8 FOR I=5,7,9,11,13,16,17,18,21,22,23,25,30,31,32,33,34,36
SET ^TMP($JOB,"MEAN",I)=$JUSTIFY((^TMP($JOB,"MEAN",I)/PXRRCNUM),2,1)
+9 QUIT
INITVAR SET (PXRRCAD,PXRRSESS,PXRRAG,PXRRAGE,PXRRTVS,PXRRSXUN,PXRRVPAT,PXRRQPAT,PXRRTPAT,PXRRMPAT,PXRRPSUT,PXRRCOST)=0
+1 SET X1=PXRREDT
SET X2=-180
DO C^%DTC
SET PXRRSXMO=X
SET X1=PXRREDT
SET X2=-365
DO C^%DTC
SET PXRRYR=X
+2 QUIT