-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add startDate and endDate to OCKOutcomeValue #719
base: main
Are you sure you want to change the base?
Conversation
* feat: date acesses for created date to end date to task outcomes * endDate documentation update * Updated OCKOutcomeValue startDate and endDate documentation to HealthKit documentation. * Added 2.0 to 3.0 CoreData mapping and adjusted OCKOutcomeValue members * nits * Test added for Outcome Value * CareKitStore3.0 mapping update * Succesful migration from CareKitStore 2.1 to CareKitStore 3.0. * Add file to Package.swift * add files to Xcode project * fix coredata in project * nits * fix absolute path for coredata * deleted files --------- Co-authored-by: Corey Baker <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This CareKitStore only adds two new attributes to OCKCDOutcomeValue, startDate and endDate, to CareKitStore 2.1. Nothing else has changed from the 2.1 store
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same custom migration policy from CareKitStore 2.0 to CareKitStore 2.1 updated to migrate CKS 2.0 to CKS 3.0. The only change that occurred was updating the schema version to 3.0.0
.
|
||
// Update the schema version to 3.0 | ||
if key == "schemaVersion" { | ||
dInstance.setValue("3.0.0", forKey: key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated schema version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mapping is one-to-one for CKS 2.1 to CKS 3.0. I need to hardcode the schemaVersion to 3.0.0
since $source.schemaVersion would not be correct, and I do not want to introduce a new custom migration policy for one change.
Changes occurred to:
- OCKCDOutcomeToOCKCDOutcome
- OCKCDCarePlanToOCKCDCarePlan
- OCKCDTaskToOCKCDTask
- OCKCDContactToOCKCDContact
- OCKCDPatientToOCKCDPatient
@@ -35,6 +35,8 @@ class OCKCDOutcomeValue: NSManagedObject { | |||
@NSManaged var kind: String? // blood sugar, body weight, etc. | |||
@NSManaged var units: String? | |||
@NSManaged var createdDate: Date | |||
@NSManaged var startDate: Date? | |||
@NSManaged var endDate: Date? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added startDate and endDate
doubleValue, | ||
units: event.task.healthKitLinkage.unit.unitString | ||
) | ||
|
||
outcomeValue.startDate = sample.dateInterval.start | ||
outcomeValue.endDate = sample.dateInterval.end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we add the sample's startDate and endDate to its OCKOutcomeValue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These files were added to test migration from CareKitStore2.1 to CareKitStore3.0 (used in testMigrationFrom2_1to3_0
)
@@ -48,14 +48,15 @@ class TestCoreDataSchemaMigrations: XCTestCase { | |||
/// Tasks: 3 | |||
/// Outcomes: 3 | |||
/// OutcomeValues: 3 | |||
func testMigrationFrom2_0to2_1() throws { | |||
func testMigrationFrom2_0to3_0() throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed testMigrationFrom2_0to2_1 because we are not using CareKitStore 2.1. Created new tests for the previous stores to check if their migration was successfull.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example of how this updated OCKOutcomeValue allows developers to store/retrieve their own dates for these values
@@ -129,6 +130,8 @@ class TestHealthKitPassthroughStoreEvents: XCTestCase { | |||
case heartRateTask.id: | |||
XCTAssertEqual(outcomeValues.count, 2) | |||
XCTAssertEqual(outcomeValues.first?.doubleValue, 70) | |||
XCTAssertEqual(outcomeValues.first?.startDate, heartRateStart) | |||
XCTAssertEqual(outcomeValues.first?.endDate, heartRateEnd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test to check if the sample's startDate and endDate were successfully saved in their OCKOutcomeValue
|
||
/// The value's end date. | ||
public var endDate: Date? | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added startDate and endDate to OCKOutcomeValue
Currently, when querying
OCKHealthKitTask
from the CareStore, the captured dates of samples are not accessible by developers from their respectiveOCKOutcomeValues
. Adding this information to OCKOutcomeValue will allow developers to differentiate when samples were taken to provide insights into trends over time. The current problem is thecreatedDate
can only be accessed on anOCKOutcomeValue
which for a HealthKit sample is incorrect because thecreatedDate
is the date the sample was queried from HealthKit (see here) as opposed to the actual start/end dates of the HealthKit sample. At @netreconlab, we plan on creating graphs to display user's health data over time and with the newly added startDate and endDate to OCKOutcomeValue, we can provide this functionality.These are the proposed changes to CareKit:
@gavirawson-apple please let me know if you want me to make any additional updates
Collaborators: @cbaker6