Refactor code structure for improved readability and maintainability
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1297,6 +1297,8 @@ class ContextGenerator:
|
||||
|
||||
# Page 9
|
||||
contexts["page_9"] = {
|
||||
"client_name": self.patient_info["name"],
|
||||
"assessment_date": datetime.now().strftime("%B %d %Y"),
|
||||
"fat_max_value": f"{pnoe_metrics['fat_max_value']:.2f}",
|
||||
"fat_max_hr": f"{int(pnoe_metrics['fat_max_hr'])}",
|
||||
"fuel_utilization_chart": graphs.get("fuel_utilization", ""),
|
||||
@@ -1410,10 +1412,16 @@ class ContextGenerator:
|
||||
|
||||
# Pages 14-18 (previously 13-17)
|
||||
for i in range(1, 6):
|
||||
contexts[f"page_{i + 13}"] = {
|
||||
page_num = i + 13
|
||||
contexts[f"page_{page_num}"] = {
|
||||
"patient_name": self.patient_info["name"],
|
||||
"page_number": i + 13,
|
||||
"page_number": page_num,
|
||||
}
|
||||
# Add next_testing_date to page 16
|
||||
if page_num == 16:
|
||||
contexts["page_16"]["next_testing_date"] = self.patient_info.get(
|
||||
"next_testing_date", "Contact us for scheduling"
|
||||
)
|
||||
|
||||
# Page 19 - Glossary with Body Fat Percentage Master Chart (previously page 18)
|
||||
contexts["page_19"] = {
|
||||
|
||||
@@ -1141,15 +1141,20 @@ class GraphGenerator:
|
||||
fig, ax = plt.subplots(figsize=(10, 2.5))
|
||||
|
||||
# Chart data and positions
|
||||
# Use normalized positions (0-100 scale) for uniform bar length
|
||||
categories = ["Very Slow", "Slow", "Average", "Fast", "Very Fast"]
|
||||
positions = [1500, 3000, 4500, 6000, 7500]
|
||||
indicator_pos = rmr_kcal
|
||||
highlight_end = rmr_kcal
|
||||
positions = [10, 30, 50, 70, 90] # Normalized positions on 0-100 scale
|
||||
|
||||
# Main Bar (Background)
|
||||
# Normalize the kcal value to 0-100 scale (assuming range 0-9000 kcal)
|
||||
max_kcal = 9000
|
||||
normalized_value = (rmr_kcal / max_kcal) * 100
|
||||
indicator_pos = normalized_value
|
||||
highlight_end = normalized_value
|
||||
|
||||
# Main Bar (Background) - using 0-100 scale
|
||||
main_bar = FancyBboxPatch(
|
||||
(0, 0.4),
|
||||
9000,
|
||||
100,
|
||||
0.2,
|
||||
boxstyle="round,pad=0,rounding_size=0.1",
|
||||
ec="none",
|
||||
@@ -1168,7 +1173,7 @@ class GraphGenerator:
|
||||
)
|
||||
ax.add_patch(highlight_bar)
|
||||
|
||||
# Text and Labels
|
||||
# Text and Labels (show actual kcal value)
|
||||
ax.text(
|
||||
highlight_end / 2,
|
||||
0.5,
|
||||
@@ -1192,7 +1197,7 @@ class GraphGenerator:
|
||||
|
||||
# Chart Styling
|
||||
ax.set_title("Slow vs Fast Metabolism", fontsize=18, weight="bold", loc="left")
|
||||
ax.set_xlim(0, 9000)
|
||||
ax.set_xlim(0, 100) # Normalized scale for uniformity
|
||||
ax.set_ylim(0, 1)
|
||||
ax.axis("off")
|
||||
|
||||
@@ -1296,6 +1301,7 @@ class GraphGenerator:
|
||||
|
||||
# Chart Styling
|
||||
ax.set_title("Fuel Source", fontsize=18, weight="bold", loc="left")
|
||||
ax.set_xlim(0, 100) # Normalized scale for uniformity
|
||||
ax.set_ylim(0, 1)
|
||||
ax.axis("off")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user