carekit-apple / CareKit

CareKit is an open source software framework for creating apps that help people better understand and manage their health.
https://www.researchandcare.org
Other
2.4k stars 443 forks source link

OCKPatient restricted to 1 patient or an initial set of patients #438

Open cbaker6 opened 4 years ago

cbaker6 commented 4 years ago

When using CareKit for a provider facing app, OCKStore will need to have multiple patients. Currently, OCKStore.validateNumberOfPatients() prevents this after the initial add of 1 or a set of patients. Is possible to remove this?

I can submit a PR if supporting multiple patients sounds reasonable and won't cause issues in the data store.

cbaker6 commented 4 years ago

Thinking more about what @erik-apple mentioned

... probably needs to be paired together with some other considerations, like updating the OCKDailyTasksPageViewController to make sure it show the tasks for 1 specific patient.

A PR for this seems much larger than I originally anticipated. In CareKit's current form, it seems supporting 1 patient allows for the assumption that all entities created in a CareKitStore belongs to the respective patient. In this manner, you don't have to worry about things like ACLs (I don't remember seeing anything related to ACLs in the CareKitStore, but for 1 patient ACLs also don't seem needed). My initial thoughts are ACLs can be handled in 1 of 2 ways:

  1. Add ACL support to all entities
  2. Leave ACLs to the vendors using OCKRemoteSynchronizable, meaning they should only allow pullRevisions or pushRevisions for entities a particular user has access to. This seems okay in my opinion as most remotes should have some notion of ACL already because they are handling user login etc..

The other item that seems important is fetching entities, essentially all fetches are able to fetch anything from the CareKitStore. If support for multiple patients are added, it seems something similar to @NSManaged var patient: OCKCDPatient? in OCKCDCarePlan could be added to the rest of the OCKCD... (except for OCKCDPatient) and all queries should add the ability to fetch by OCKPatient.uuid or OCKPatient.id (I'm thinking OCKPatient.id fetches may be used more for these types of scenarios). This will probably change up the initializers of all of the OCKStructs also as they will probably all need to accept OCKPatient as an argument.