Feature: Endocrinologist Visit Report (PDF Export)#671
Open
greyghost99 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✨ Feature: Endocrinologist Visit Report (PDF Export)
Summary
This PR adds a PDF report generator to LoopFollow that produces a professional, clinic-ready endocrinologist visit report directly from Nightscout data — no third-party services, no external dependencies, and no internet connection required beyond the existing Nightscout connection.
The report is inspired by the LoopInsights report format and designed to give endocrinologists a clean summary of a patient's AID performance over any chosen period.
Motivation
Patients using DIY AID systems (Loop, Trio, iAPS) often arrive at endo appointments without structured data summaries. Apps like Dexcom Clarity and Tidepool produce reports but don't have visibility into Loop/Trio-specific data. LoopFollow already fetches and displays all the relevant data — this feature simply packages it into a shareable PDF that patients can AirDrop, email, or print before their visit.
What's New
Report Contents (all sections are individually toggleable)
Report Options
Auto-Fill from Nightscout
A "Auto-Fill from Nightscout" button in the Therapy Settings section calls
/api/v1/profile/current.jsonusing the existingNightscoutUtilsinfrastructure and pre-fills CR, ISF, basal rate schedule, and target glucose — no manual re-entry needed.Files Changed
Files Added
LoopFollow/Stats/EndoReportGenerator.swift— Core PDF rendering engine using PDFKit + CoreGraphics. ContainsEndoReportConfig,EndoReportGenerator, per-page layout, all chart drawing, and the daily breakdown row renderer. No external dependencies.LoopFollow/Stats/EndoReportView.swift— SwiftUI sheet UI for configuring and generating the report. ContainsEndoReportView,NightscoutProfileFetcher,ShareSheet, andColor/UIColorhex extensions. All settings are persisted via@AppStorage.Files Modified
LoopFollow/Stats/AggregatedStatsView.swift— Added@State private var showEndoReport = false, a toolbar button (doc.richtexticon) next to the existing Refresh button, and a.sheetpresentation ofEndoReportView.Technical Notes
AGPCalculator,TIRCalculator,GRICalculator,SimpleStatsViewModel, andStatsDataServiceare used directly. No data is re-fetched.NightscoutUtils.executeRequestwith.profileevent type. Includes a lenient three-layer decoder that handles missing fields gracefully across Nightscout variants (Trio, Loop, standard).DispatchQueueand dispatches UI updates back to main.@AppStorage.Testing
Tested on iPhone simulator (iOS 26.5) with real Nightscout data. Verified:
Date range presets tested:
Screenshots
Report Configuration UI
Generated PDF
Page 1 — Summary Dashboard
Page 2 — Daily Glucose Breakdown
Checklist
@AppStorageStorage.shared,dateTimeUtils)NightscoutUtilsinfrastructure