Logging symptoms associated with a medication
At a glance
| Item | Summary |
|---|---|
| Purpose | Fetch medications and dose events from the HealthKit store, and create symptom samples to associate with them. |
| App architecture | A Swift sample with the source-visible chain MedsSymptomsLoggingApp → TabsView → HealthStore → DoseEventProvider → HealthKit / HealthKitUI APIs. |
| Main patterns | Central store, Binding-based state propagation, Actor-isolated state |
| Project style | 23 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries. |
Project structure
Source bundle/
└── MedsSymptomsLoggingApp/
├── MedsSymptomsLoggingApp.swift
├── Views/
│ ├── Charts/
│ │ ├── MedicationChartsView+ChartsView.swift
│ │ ├── MedicationChartsView.swift
│ │ └── MedicationChartsView+MedicationSelectorView.swift
│ ├── TabsView.swift
│ └── HealthKitAuthorizationGatedView.swift
├── Models/
│ ├── AnnotatedMedicationConceptModel.swift
│ ├── DoseEventModel.swift
│ ├── Stores/
│ │ └── HealthStore.swift
│ └── SymptomModel.swift
└── Data Sources/
├── DoseEventProvider.swift
└── MedicationProvider.swift
Structure observations
- Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
- Primary languages: Swift.
- The verified tree contains 4 project/configuration file(s) and 27 source declaration(s).
Overall architecture
flowchart LR
N1["MedsSymptomsLoggingApp"]
N2["TabsView"]
N3["HealthStore"]
N4["DoseEventProvider"]
N5["HealthKit / HealthKitUI APIs"]
N1 --> N2
N2 --> N3
N3 --> N4
N4 --> N5
Reference code
MedsSymptomsLoggingApp/MedsSymptomsLoggingApp.swift:11 — architecture anchor
@main
struct MedsSymptomsLoggingApp: App {
// ...
}Interpretation
The arrows summarize the source-visible entry, role-named types or folders, and framework direction; when nodes come from structural folders, the sequence is a high-level interpretation rather than proof that every adjacent node calls the next. Ownership is claimed only where the next section cites a stored property or assignment. The diagram is intentionally limited to the dominant path into HealthKit.
Ownership and state
classDiagram
MedsSymptomsLoggingApp *-- Bool : triggerMedicationsAuthorization
MedsSymptomsLoggingApp *-- Bool : healthDataAuthorized
ChartsView o-- DateConfiguration : dateConfiguration
ChartsView *-- Array : chartSeries
Ownership evidence
MedsSymptomsLoggingApp/MedsSymptomsLoggingApp.swift:15 — stored dependency or nearest verified ownership anchor
@main
struct MedsSymptomsLoggingApp: App {
// ...
@State var triggerMedicationsAuthorization: Bool = false
// ...
}| Owner | Object or state | Relationship | Mutation authority |
|---|---|---|---|
MedsSymptomsLoggingApp |
Bool (triggerMedicationsAuthorization) |
owns wrapper-managed state | App/module collaborators |
MedsSymptomsLoggingApp |
Bool (healthDataAuthorized) |
owns wrapper-managed state | App/module collaborators |
ChartsView |
DateConfiguration (dateConfiguration) |
borrows mutable state | The upstream binding owner is authoritative |
ChartsView |
Array (chartSeries) |
owns value state | Initialized by the owner; the binding is immutable |
Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.
Class and protocol design
MedsSymptomsLoggingApp/MedsSymptomsLoggingApp.swift:12 — representative type boundary
struct MedsSymptomsLoggingApp: App {
// ...
}| Type | Responsibility | Depends on or conforms to |
|---|---|---|
MedsSymptomsLoggingApp |
Application entry and top-level composition | App |
ChartsView |
User-interface presentation and input forwarding | View |
DateIntervalPaginationView |
User-interface presentation and input forwarding | View |
DoseEventModel |
Feature data or observable state | Sendable, Identifiable, Equatable, Hashable |
HealthStore |
Centralized state or persistence access | Sendable |
SymptomModel |
Feature data or observable state | Sendable, Identifiable, Hashable |
MedicationChartsView |
User-interface presentation and input forwarding | View |
TabsView |
User-interface presentation and input forwarding | View |
DoseEventProvider |
Supplies a capability or framework resource | Sendable |
MedicationProvider |
Supplies a capability or framework resource | Concrete collaborators/imported frameworks |
No local protocol conformance is claimed as protocol-oriented design; external framework conformances are listed only as dependencies.
Access control
| Symbol | Access | Verified effect | Likely rationale |
|---|---|---|---|
doseEvents (MedsSymptomsLoggingApp/Data Sources/DoseEventProvider.swift:19) |
private(set) |
Read access follows the declaration; writes remain in the private scope. | Inference: allow observation while reserving invariant-changing writes for the owner. |
updatedDoseSampleCollection (MedsSymptomsLoggingApp/Data Sources/DoseEventProvider.swift:21) |
private(set) |
Read access follows the declaration; writes remain in the private scope. | Inference: allow observation while reserving invariant-changing writes for the owner. |
handleResultForLastLoggedDose (MedsSymptomsLoggingApp/Data Sources/DoseEventProvider.swift:146) |
private |
Use is restricted to the lexical declaration and same-file extensions allowed by Swift. | Inference: hide an implementation step that is not part of the collaboration surface. |
handleResult (MedsSymptomsLoggingApp/Data Sources/DoseEventProvider.swift:171) |
private |
Use is restricted to the lexical declaration and same-file extensions allowed by Swift. | Inference: hide an implementation step that is not part of the collaboration surface. |
Reference code
MedsSymptomsLoggingApp/Data Sources/DoseEventProvider.swift:19 — representative boundary
private(set) var doseEvents: [DoseEventModel] = []
private(set) var updatedDoseSampleCollection = [HKMedicationDoseEvent]()
/// Creates a data source for providing `HKMedicationDoseEvent` samples for a provided `HKMedicationConcept`.
init(healthStore: HKHealthStore,
annotatedMedicationConcept: AnnotatedMedicationConcept) {
// ...
}Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.
Logic ownership and placement
| Logic | Owning type or file | Placement rationale |
|---|---|---|
| Application entry and top-level composition | MedsSymptomsLoggingApp |
The source’s App suffix makes this role explicit. |
| Feature data or observable state | DoseEventModel, SymptomModel |
The source’s Model suffix makes this role explicit. |
| Supplies a capability or framework resource | DoseEventProvider, MedicationProvider |
The source’s Provider suffix makes this role explicit. |
| Centralized state or persistence access | HealthStore |
The source’s Store suffix makes this role explicit. |
| User-interface presentation and input forwarding | ArchivedMedicationView, ChartsView, DateIntervalPaginationView, DoseEventView |
The source’s View suffix makes this role explicit. |
Design patterns
| Pattern | Source evidence | Purpose or tradeoff |
|---|---|---|
| Central store | MedsSymptomsLoggingApp/Models/Stores/HealthStore.swift:11 |
A store-named type centralizes feature state or persistence. |
| Binding-based state propagation | MedsSymptomsLoggingApp/Views/Charts/MedicationChartsView+ChartsView.swift:16 |
A binding exposes controlled read/write access while the upstream owner remains authoritative. |
| Actor-isolated state | MedsSymptomsLoggingApp/Data Sources/DoseEventProvider.swift:11 |
Actor annotations make the concurrency ownership boundary explicit. |
Naming conventions
- Types: App: MedsSymptomsLoggingApp; Model: DoseEventModel, SymptomModel; Provider: DoseEventProvider, MedicationProvider; Store: HealthStore; View: ArchivedMedicationView, ChartsView, DateIntervalPaginationView, DoseEventView, HealthKitAuthorizationGatedView.
- Protocols: no local protocol declaration in the scanned source.
- Methods:
chartPoints,chartPoint,decrement,increment,todayView,calendarChartsView. - Files:
MedsSymptomsLoggingApp/MedsSymptomsLoggingApp.swift,MedsSymptomsLoggingApp/Models/DoseEventModel.swift,MedsSymptomsLoggingApp/Models/Stores/HealthStore.swift,MedsSymptomsLoggingApp/Models/SymptomModel.swift,MedsSymptomsLoggingApp/Views/Charts/MedicationChartsView.swift,MedsSymptomsLoggingApp/Views/TabsView.swift.
Architecture takeaways
MedsSymptomsLoggingAppis the main source-visible entry or composition anchor for this sample.- Framework work reaches SwiftUI, HealthKit, Charts, HealthKitUI through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
- Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
- Access-control conclusions separate verified language visibility from the likely design rationale.
- The source does not justify labeling the design protocol-oriented.
Source map
| Source file | Relevant symbols |
|---|---|
MedsSymptomsLoggingApp/MedsSymptomsLoggingApp.swift |
MedsSymptomsLoggingApp |
MedsSymptomsLoggingApp/Views/Charts/MedicationChartsView+ChartsView.swift |
ChartsView, ChartSeries, ChartPoint, DateIntervalPaginationView |
MedsSymptomsLoggingApp/Models/AnnotatedMedicationConceptModel.swift |
AnnotatedMedicationConcept |
MedsSymptomsLoggingApp/Models/DoseEventModel.swift |
DoseEventModel |
MedsSymptomsLoggingApp/Models/Stores/HealthStore.swift |
HealthStore |
MedsSymptomsLoggingApp/Models/SymptomModel.swift |
SymptomModel |
MedsSymptomsLoggingApp/Views/Charts/MedicationChartsView.swift |
MedicationChartsView, DateConfiguration |
MedsSymptomsLoggingApp/Views/TabsView.swift |
TabsView, TabKind |
MedsSymptomsLoggingApp/Data Sources/DoseEventProvider.swift |
DoseEventProvider |
MedsSymptomsLoggingApp/Data Sources/MedicationProvider.swift |
MedicationProvider |