Skip to content

Add customizable endocrinology PDF reporting to LoopFollow#660

Open
greyghost99 wants to merge 7 commits into
loopandlearn:devfrom
type1ghost:feat/pdf-export
Open

Add customizable endocrinology PDF reporting to LoopFollow#660
greyghost99 wants to merge 7 commits into
loopandlearn:devfrom
type1ghost:feat/pdf-export

Conversation

@greyghost99
Copy link
Copy Markdown

@greyghost99 greyghost99 commented May 23, 2026

Add Endo PDF Export for Provider-Friendly Diabetes Reporting

Overview

This PR introduces an Endo PDF Export feature to LoopFollow, allowing users to generate a provider-friendly report for endocrinology appointments using diabetes data already available in the app and associated Nightscout data.

The goal is to reduce friction during appointment prep and improve how diabetes management data is communicated to providers without relying on screenshots, manual notes, or multiple external exports.

What this adds

This implementation introduces a dedicated endocrinology reporting workflow including:

  • PDF export generation for endo visits
  • EndoReportView for report previewing
  • EndoReportGenerator for report rendering and formatting
  • Integration with statistics / aggregated data views
  • Multi-page reporting with expanded daily breakdowns
  • Provider-readable formatting focused on insulin usage, glucose trends, and therapy settings

Included features

Reporting & Layout

  • Newest-to-oldest day ordering for easier review of recent therapy
  • Multi-page daily breakdowns (all days included, no 7-day cap)
  • Daily breakdown include/exclude toggle
  • AGP layout overlap fix on page 1
  • Header spacing improvements (Loop Follow formatting cleanup)
  • Report accent color picker for personalization/readability

Daily Insulin Analysis

  • Per-day insulin summaries including:

    • total insulin
    • bolus insulin
    • basal insulin
    • bolus/basal ratio
  • SMBs displayed separately in daily charts for clearer AID behavior visibility

  • Daily therapy summaries for longitudinal review

Diabetes Metrics & Units

  • mg/dL ↔ mmol/L toggle support

  • Date range presets:

    • 3 days
    • 7 days
    • 14 days
    • 30 days
    • 90 days

Therapy & Clinical Context

Optional provider-facing metadata fields stored locally using UserDefaults:

  • insulin type
  • diagnosis date
  • AID system (Trio, Loop, or custom/other)
  • pump device
  • CGM device

Additional therapy configuration fields:

  • carb ratio (CR)
  • insulin sensitivity factor (ISF)
  • basal rates
  • target glucose settings

Nutrition / Treatment Data

  • Fat and protein entries included when logged through Nightscout treatments
  • Expanded contextual therapy reporting for meal-related dosing patterns

Why

Many users currently rely on screenshots, manual notes, or external tools to communicate therapy history during endocrinology appointments.

This feature aims to:

  • Improve appointment preparation
  • Provide a cleaner provider-facing summary
  • Reduce manual work for users
  • Surface meaningful insulin and glucose trends in a reportable format
  • Make LoopFollow more useful as a diabetes management companion outside real-time monitoring

Files introduced / updated

New files:

  • EndoReportView.swift
  • EndoReportGenerator.swift

Updated:

  • AggregatedStatsView.swift
  • project configuration / Xcode integration files

Screenshots

Screenshot 2026-05-23 at 21 22 14 Screenshot 2026-05-23 at 21 22 24 Screenshot 2026-05-23 at 21 22 35 Screenshot 2026-05-23 at 21 22

EndoReport_1779594925.pdf

Testing

  • Built and tested locally in Xcode
  • Verified report generation flow
  • Verified multi-page report rendering
  • Confirmed integration into statistics workflow
  • Confirmed project builds after Xcode updates and integration

Future Improvements

Potential follow-up improvements may include:

  • richer AGP visualizations
  • additional provider-facing analytics
  • export presets/templates
  • optional branding/layout customization
  • expanded therapy insight summaries

@greyghost99 greyghost99 changed the title Add Endo PDF export to LoopFollow Add customizable endocrinology PDF reporting to LoopFollow May 24, 2026
@greyghost99
Copy link
Copy Markdown
Author

Build currently broken, will push out update within a day or so

@bjorkert
Copy link
Copy Markdown
Member

Thanks for the PR, looking forward to test it in more detail.

One concern with the daily insulin breakdown: I'd suggest dropping bolus insulin, basal insulin, and the bolus/basal ratio.

With AID systems these numbers vary heavily depending on delivery method (SMBs, UAM, temp basals, etc.) and don't carry meaningful signal for an endo, if anything they tend to invite questions that lead the conversation in the wrong direction.

Total insulin + total scheduled basal is enough context for a clinical review. The endo can see how much insulin was delivered and how it compares to the programmed baseline, if the endo is interested in a ratio, that is the ratio to look at. At least this is my opinion and experience.

@greyghost99
Copy link
Copy Markdown
Author

@bjorkert

Thanks for the thoughtful feedback — that makes a lot of sense, especially in the context of AID systems.

I agree that bolus insulin, basal insulin, and bolus/basal ratio can become noisy or misleading with SMBs, UAM, temp basals, and dynamic insulin delivery, and I can see how that may steer discussion away from more clinically useful signals during an endo visit.

I’ve updated the report accordingly and removed the daily bolus insulin, basal insulin, and bolus/basal ratio breakdowns. The daily section now focuses on total insulin delivered + total scheduled basal, which provides clearer context against programmed therapy settings and feels more aligned with provider review.

Really appreciate the perspective here — this was helpful feedback and I think the report is better for it.

@greyghost99
Copy link
Copy Markdown
Author

@bjorkert

Thanks again for taking the time to review the PR and for the thoughtful feedback — I really appreciate it.

I’ve addressed the changes discussed, and I’m looking forward to hearing your thoughts after you’ve had more time to test it. Any additional feedback, ideas, or improvements are always appreciated!

@greyghost99
Copy link
Copy Markdown
Author

@bjorkert

I’m fairly happy with the PR in its current state and feel like it’s in a good place right now, but I’m definitely open to improvements. As you continue testing, any additional feedback, suggestions, or ideas for refinement would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants