Edje09 February 2016

Saving "data sessions" with CoreData

I'm writing an app to keep track of patients to see during a shift. Right now, I've got an app with a list that you can add patients to, each represented by a different NSManagedObject, and each of these objects has a name, room number, and several aspects of their care that need to be dealt with (exam, labs, imaging, etc, each has a state of "to be done", "in process", or "done"). With CoreData, I'm able to save the state of eat of the aspects of care and the specific patient data and reload it each time the app starts. However, the next step is integrating a "shift", where the user can start his or her shift with an empty list and add only those patients seen on that shift. When the shift ends, they can save that list so they can load it later and see who they saw on that specific shift, but can also start a new shift with a totally separate list. Is there any way to save these shifts lists independently so they can be brought up separately later?

Answers


Tom Harrington February 2016

It sounds like you want to create a new Shift entity in your data model, with a relationship to your current patient entity. Shift would have a relationship called patients that led to the patient entity. It would be a to-many relationship since each shift has multiple patients. The patient entity would have an inverse relationship called either shift or shifts, depending on whether each patient instance can belong to just one or to multiple shifts.

Later on you could look up existing instances of Shift or create new instances.

Post Status

Asked in February 2016
Viewed 2,060 times
Voted 5
Answered 1 times

Search




Leave an answer