Spaces:
Sleeping
Sleeping
File size: 7,029 Bytes
46922d7 |
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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
import streamlit as st
def set_custom_css():
"""Set custom CSS for better styling"""
custom_css = """
<style>
.main {
background-color: #f5f7f9;
}
.stTabs [data-baseweb="tab-list"] {
gap: 8px;
}
.stTabs [data-baseweb="tab"] {
height: 50px;
white-space: pre-wrap;
background-color: #f0f2f6;
border-radius: 5px 5px 0px 0px;
padding-left: 20px;
padding-right: 20px;
}
.stTabs [aria-selected="true"] {
background-color: #4e8cff;
color: white;
}
.css-1kyxreq {
justify-content: center;
}
.big-font {
font-size:20px !important;
font-weight: bold;
}
.medium-font {
font-size:16px !important;
}
.highlight {
background-color: #f0f7ff;
padding: 15px;
border-radius: 5px;
border-left: 5px solid #4e8cff;
}
.card {
background-color: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
margin-bottom: 20px;
}
.metric-card {
background-color: white;
padding: 15px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
text-align: center;
}
.metric-value {
font-size: 24px;
font-weight: bold;
color: #0068c9;
}
.metric-label {
font-size: 14px;
color: #555;
}
hr {
margin-top: 30px;
margin-bottom: 30px;
}
</style>
"""
st.markdown(custom_css, unsafe_allow_html=True)
def metric_card(label, value, description=None, color="#0068c9"):
"""Create a custom styled metric card"""
html = f"""
<div class="metric-card">
<div class="metric-label">{label}</div>
<div class="metric-value" style="color: {color};">{value}</div>
{f'<div class="metric-description">{description}</div>' if description else ''}
</div>
"""
return st.markdown(html, unsafe_allow_html=True)
def create_sidebar(brand="XenoGlip (DPP-4 Inhibitor)"):
"""Create a sidebar with controls"""
with st.sidebar:
st.title("PhysicianTwin™")
st.markdown("### Digital Twin Parameters")
# Brand selection
selected_brand = st.selectbox("Select Brand", [brand])
# Therapeutic Area
therapeutic_area = st.selectbox("Therapeutic Area", ["Type 2 Diabetes"])
# Physician segment selection
physician_segments = st.multiselect(
"Physician Segments",
["Primary Care", "Endocrinology", "Cardiology"],
default=["Primary Care", "Endocrinology"]
)
# Time period
time_period = st.select_slider(
"Time Period",
options=["Current Quarter", "6 Months", "1 Year", "2 Years"],
value="6 Months"
)
# Payer mix
st.markdown("### Payer Mix")
commercial = st.slider("Commercial", 0, 100, 65, 5)
medicare = st.slider("Medicare", 0, 100, 25, 5)
medicaid = st.slider("Medicaid", 0, 100, 10, 5)
# Ensure total is 100%
total = commercial + medicare + medicaid
if total != 100:
st.warning(f"Payer mix totals {total}%. Please adjust to total 100%.")
st.markdown("---")
st.markdown("### Analysis Options")
analysis_depth = st.select_slider(
"Analysis Depth",
options=["Basic", "Standard", "Comprehensive"],
value="Standard"
)
confidence_display = st.checkbox("Show Confidence Intervals", value=True)
st.markdown("---")
st.markdown("*Powered by Anthropic Claude*")
return {
"brand": selected_brand,
"therapeutic_area": therapeutic_area,
"physician_segments": physician_segments,
"time_period": time_period,
"payer_mix": {
"commercial": commercial,
"medicare": medicare,
"medicaid": medicaid
},
"analysis_depth": analysis_depth,
"confidence_display": confidence_display
}
def create_tabs():
"""Create tabs for different analyses"""
return st.tabs([
"📊 Market Overview",
"👥 Physician Segments",
"💬 Message Testing",
"🔮 Predictive Scenarios",
"🤖 Interactive Twin"
])
def header_section(brand, therapeutic_area):
"""Create the header section of the app"""
st.title("PhysicianTwin™ Digital Simulation")
st.markdown(f"### Brand: {brand} | Therapeutic Area: {therapeutic_area}")
def patient_profile_card(profile_data):
"""Create a patient profile card"""
html = f"""
<div class="card">
<h3>Patient Profile</h3>
<div class="patient-details">
<p><strong>Age:</strong> {profile_data['age']}</p>
<p><strong>Gender:</strong> {profile_data['gender']}</p>
<p><strong>BMI:</strong> {profile_data['bmi']}</p>
<p><strong>A1C:</strong> {profile_data['a1c']}%</p>
<p><strong>Comorbidities:</strong> {profile_data['comorbidities']}</p>
<p><strong>Current Medications:</strong> {profile_data['medications']}</p>
</div>
</div>
"""
return st.markdown(html, unsafe_allow_html=True)
def create_expandable_sections(sections_data):
"""Create expandable sections with content"""
for title, content in sections_data.items():
with st.expander(title):
st.markdown(content)
def loading_spinner(message="Processing data..."):
"""Create a loading spinner with a message"""
with st.spinner(message):
import time
time.sleep(2) # Simulate processing time
def confidence_indicator(score, label="Confidence", description=None):
"""Create a confidence indicator with a score"""
color = "#5cb85c" if score >= 0.7 else "#f0ad4e" if score >= 0.5 else "#d9534f"
return metric_card(label, f"{score:.0%}", description, color)
def create_metric_row(metrics):
"""Create a row of metrics"""
cols = st.columns(len(metrics))
for i, (label, value, delta) in enumerate(metrics):
with cols[i]:
st.metric(label=label, value=value, delta=delta)
def kpi_dashboard(kpis):
"""Create a KPI dashboard section"""
st.markdown("## Key Performance Indicators")
# Create metrics in rows of 3
metrics = []
for label, value, delta in kpis:
metrics.append((label, value, delta))
if len(metrics) == 3:
create_metric_row(metrics)
metrics = []
# Add any remaining metrics
if metrics:
create_metric_row(metrics) |