Skip to content

Commit

Permalink
Specific Upload Error Handling (#51)
Browse files Browse the repository at this point in the history
# Specific Upload Error Handling

## ♻️ Current situation & Problem
Previously, uploads of `HKQuantityTypeIdentifierPhysicalEffort` were
throwing errors before the other samples could be uploaded.


## ⚙️ Release Notes 
Now that there is separation of concerns between computing properties of
ECGs and uploading them, valid samples will still be successfully
uploaded, even if other samples throw
`HealthKitOnFHIR.HealthKitOnFHIRError.notSupported`.


## 📚 Documentation
Next steps will involve adding new support for some samples to
HealthKitOnFHIR and updating the documentation of [supported quantity
sample
types](https://swiftpackageindex.com/stanfordbdhg/healthkitonfhir/0.2.5/documentation/healthkitonfhir/supportedhkquantitytypes).


## ✅ Testing
Uploaded requests can be viewed in the Mock Web Service tab while
debugging.


### Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
MatthewTurk247 authored Feb 27, 2024
1 parent d75ecce commit 2e271bb
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions PAWS/PAWSStandard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,21 @@ actor PAWSStandard: Standard, EnvironmentAccessible, HealthKitConstraint, Onboar
do {
try await upload(sample: electrocardiogram)

supplementalMetrics.append(contentsOf: try await electrocardiogram.precedingPulseRates)
supplementalMetrics.append(contentsOf: try await electrocardiogram.precedingPhysicalEffort)
supplementalMetrics.append(contentsOf: try await electrocardiogram.precedingStepCount)
supplementalMetrics.append(contentsOf: try await electrocardiogram.precedingActiveEnergy)
supplementalMetrics.append(contentsOf: (try? await electrocardiogram.precedingPulseRates) ?? [])
supplementalMetrics.append(contentsOf: (try? await electrocardiogram.precedingPhysicalEffort) ?? [])
supplementalMetrics.append(contentsOf: (try? await electrocardiogram.precedingStepCount) ?? [])
supplementalMetrics.append(contentsOf: (try? await electrocardiogram.precedingActiveEnergy) ?? [])

if let precedingVo2Max = try await electrocardiogram.precedingVo2Max {
if let precedingVo2Max = try? await electrocardiogram.precedingVo2Max {
supplementalMetrics.append(precedingVo2Max)
}

for supplementalMetric in supplementalMetrics {
try await upload(sample: supplementalMetric)
do {
try await upload(sample: supplementalMetric)
} catch {
logger.log("Could not upload \(supplementalMetric.sampleType): \(error)")
}
}
} catch {
logger.log("Could not access HealthKit sample: \(error)")
Expand Down

0 comments on commit 2e271bb

Please sign in to comment.