Repository navigation
Expand file tree
/
Copy pathTable
More file actions
138 lines (111 loc) · 4.67 KB
/
Copy pathTable
File metadata and controls
138 lines (111 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import matplotlib.ticker as mtick
import numpy as np
# 1. Load the Data
# Make sure to update the filename to match your local file
file_name = "KI_Copy of Reach Rates by Outreach Program_2025 (1).xlsx - Blinded Preventitive Programs -.csv"
df = pd.read_csv(file_name)
# 2. Define Categorization Logic
def categorize_program(name):
name = str(name).lower()
if 'depression' in name:
return 'Depression Screening'
elif 'diabetes' in name:
return 'Diabetes Care'
elif 'cancer' in name or 'colon' in name:
return 'Cancer Screening'
elif 'well child' in name:
return 'Well Child Visit'
elif 'flu' in name:
return 'Flu Vaccine'
elif 'hypertension' in name:
return 'Hypertension'
elif 'medication adherence' in name:
return 'Medication Adherence'
elif 'annual' in name or 'wellness' in name:
return 'Annual Wellness'
elif 'primary care' in name:
return 'Primary Care'
elif 'care gaps' in name:
return 'General Care Gaps'
else:
return 'Other'
# 3. Process the Data
df['Program Category'] = df['Outreach Program Full Name'].apply(categorize_program)
# Calculate absolute numbers based on rates
df['Completed Count'] = (df['Patients Outreached To'] * df['% Completed']).round().astype(int)
df['Medically Reached Count'] = (df['Patients Outreached To'] * df['% Medically Reached']).round().astype(int)
# Group by category and sum up the counts
grouped_counts = df.groupby('Program Category').agg({
'Patients Outreached To': 'sum',
'Completed Count': 'sum',
'Medically Reached Count': 'sum'
}).reset_index()
# Calculate weighted rates for plotting/labels
grouped_counts['Weighted % Completed'] = grouped_counts['Completed Count'] / grouped_counts['Patients Outreached To']
grouped_counts['Weighted % Medically Reached'] = grouped_counts['Medically Reached Count'] / grouped_counts['Patients Outreached To']
# --- Graph 1: Scale of Impact (Volume Bar Chart) ---
# Sort by Volume for the bar chart
plot_data_bar = grouped_counts.sort_values('Completed Count', ascending=True)
plt.figure(figsize=(14, 8))
# Use a "Success Green" color
bars = plt.barh(plot_data_bar['Program Category'], plot_data_bar['Completed Count'], color='#00A36C')
# Add text labels to the bars
for bar, rate in zip(bars, plot_data_bar['Weighted % Completed']):
width = bar.get_width()
label_y = bar.get_y() + bar.get_height() / 2
# Label format: "17,106 Gaps Closed (22.3%)"
label_text = f"{int(width):,} Gaps Closed ({rate:.1%})"
plt.text(width + 500, label_y, label_text,
va='center', fontweight='bold', fontsize=12, color='black')
plt.xlabel('Number of Patients (Care Gaps Closed)', fontsize=12)
plt.title('Real World Impact: Total Care Gaps Closed by Program Category\n(Focus on Volume of Success)',
fontsize=16, fontweight='bold', loc='left')
plt.xlim(0, max(plot_data_bar['Completed Count']) * 1.3) # Add space for labels
# Styling
sns.despine(left=True, bottom=True)
plt.grid(axis='x', linestyle='--', alpha=0.5)
plt.tight_layout()
# Save or Show
plt.savefig('cipher_impact_volume.png', dpi=300)
plt.show()
# --- Graph 2: Program Landscape (Bubble Chart) ---
plt.figure(figsize=(12, 8))
# Sort by volume so smaller bubbles are plotted on top if they overlap
bubble_data = grouped_counts.sort_values('Patients Outreached To', ascending=False)
# Define bubble sizes (scaled down for readability)
sizes = bubble_data['Patients Outreached To'] / 20
# Create Scatter Plot
plt.scatter(
x=bubble_data['Weighted % Completed'],
y=bubble_data['Weighted % Medically Reached'],
s=sizes,
alpha=0.6,
c='#0072B2',
edgecolors='white',
linewidth=2
)
# Add labels to bubbles
for i, row in bubble_data.iterrows():
plt.annotate(
row['Program Category'],
(row['Weighted % Completed'], row['Weighted % Medically Reached']),
xytext=(0, 0), textcoords='offset points',
ha='center', va='center', fontsize=9, fontweight='bold'
)
plt.title('Program Landscape: Efficiency (Completion) vs. Engagement (Reach)\n(Bubble Size = Total Patient Volume)',
fontsize=16, fontweight='bold')
plt.xlabel('Completion Rate (%)', fontsize=12)
plt.ylabel('Medically Reached Rate (%)', fontsize=12)
# Format axes as percentages
plt.gca().xaxis.set_major_formatter(mtick.PercentFormatter(1.0))
plt.gca().yaxis.set_major_formatter(mtick.PercentFormatter(1.0))
# Add diagonal reference line
plt.plot([0, 1], [0, 1], 'k--', alpha=0.2, label='Reference: 100% Conversion')
sns.despine()
plt.tight_layout()
# Save or Show
plt.savefig('cipher_efficiency_landscape.png', dpi=300)
plt.show()