OCKCarePlanStore Class Reference

Inherits from NSObject
Declared in OCKCarePlanStore.h

An instance of the OCKCarePlanStore class represents a care plan database. It stores activities and events.

An activity can be added to, or removed from, a store. Once an activity has been added to a store, only the endDate can be changed by using the setEndDate:forActivity:completion: method. Update the state of an event after the user has responded to it.

You can query the store in the following ways: - Get all the activities in the store. - Get all the activities of a given type (intervention or assessment) in the store. - Get the activity for a given identifier. - Get activities for a given group identifier - Get the events of a type (intervention or assessment) for a given date. - Get the events for a given activity for a given date. - Enumerate all the events for a given activity for a range of dates - Enumerate the completion status for a given type (intervention or assessment) for a range of dates.

– initWithPersistenceDirectoryURL:identifier:patient:

The initializer requires an identifier and a local directory URL. The directory in the URL must exist, otherwise this initializer raises an exception.

- (instancetype)initWithPersistenceDirectoryURL:(NSURL *)URL identifier:(NSString *)identifier patient:(nullable OCKPatient *)patient

Parameters

URL

The directory for the store to save its database file.

identifier

A unqiue identifier for the store.

patient

The patient associated with the store.

Return Value

An instance of the store.

Declared In

OCKCarePlanStore.h

– initWithPersistenceDirectoryURL:

The initializer requires a local directory URL. The directory in the URL must exist, otherwise this initializer raises an exception.

- (instancetype)initWithPersistenceDirectoryURL:(NSURL *)URL

Parameters

URL

The directory for the store to save its database file.

Return Value

An instance of the store.

Declared In

OCKCarePlanStore.h

  identifier

A unique identifier for the store at the directory url.

@property (nonatomic, copy, readonly) NSString *identifier

Declared In

OCKCarePlanStore.h

  directoryURL

The persistence directory url for the store to save its database file.

@property (nonatomic, copy, readonly) NSURL *directoryURL

Declared In

OCKCarePlanStore.h

  patient

The patient object associated with this care plan store.

@property (nonatomic, copy, readonly, nullable) OCKPatient *patient

Declared In

OCKCarePlanStore.h

  delegate

You can use the delegate to subscribe to notifications of changes to the store.

@property (nonatomic, weak, nullable) id<OCKCarePlanStoreDelegate> delegate

Declared In

OCKCarePlanStore.h

  watchDelegate

You can use the watch delegate to subscribe a watch app to notifications of changes to the store.

@property (nonatomic, weak, nullable) id<OCKCarePlanStoreDelegate> watchDelegate

Declared In

OCKCarePlanStore.h

  cloudBridgeDelegate

The cloud bridge delegate is used to support the Medable, IBM Watson, or CloudMine cloud bridge.

@property (nonatomic, weak, nullable) id<OCKCarePlanStoreDelegate> cloudBridgeDelegate

Discussion

Developers should not use this delegate. Use delegate property instead.

Declared In

OCKCarePlanStore.h

– addActivity:completion:

Add an activity to this store.

- (void)addActivity:(OCKCarePlanActivity *)activity completion:(void ( ^ ) ( BOOL success , NSError *_Nullable error ))completion

Parameters

activity

Activity object to be added.

completion

Completion block to return operation result.

Discussion

The identifiers for activities in the store should be unique. An activity with a duplicate identifier cannot be added.

Declared In

OCKCarePlanStore.h

– activitiesWithCompletion:

Get all activities in the store.

- (void)activitiesWithCompletion:(void ( ^ ) ( BOOL success , NSArray<OCKCarePlanActivity*> *activities , NSError *_Nullable error ))completion

Parameters

completion

A completion block that returns the result of the operation and a list of activities.

Declared In

OCKCarePlanStore.h

– activitiesWithType:completion:

Get all activities with specified type from this store.

- (void)activitiesWithType:(OCKCarePlanActivityType)type completion:(void ( ^ ) ( BOOL success , NSArray<OCKCarePlanActivity*> *activities , NSError *_Nullable error ))completion

Parameters

type

Activity type used to filter the activity list.

completion

A completion block that returns the result of the operation and a list of activities.

Declared In

OCKCarePlanStore.h

– activityForIdentifier:completion:

Gets the activity associated with the provided identifier.

- (void)activityForIdentifier:(NSString *)identifier completion:(void ( ^ ) ( BOOL success , OCKCarePlanActivity *_Nullable activity , NSError *_Nullable error ))completion

Parameters

identifier

An activity identifier.

completion

A completion block that returns the result of the operation and an activity (if the activity is in the store).

Declared In

OCKCarePlanStore.h

– activitiesWithGroupIdentifier:completion:

Gets the activities associated with the specified group identifier.

- (void)activitiesWithGroupIdentifier:(NSString *)groupIdentifier completion:(void ( ^ ) ( BOOL success , NSArray<OCKCarePlanActivity*> *activities , NSError *_Nullable error ))completion

Parameters

groupIdentifier

Identifier for a group of activities.

completion

A completion block that returns the result of the operation and a list of activities.

Declared In

OCKCarePlanStore.h

– setEndDate:forActivity:completion:

Update the end date of an activity. Use this method to change the end date of an activity after it has been added to store.

- (void)setEndDate:(NSDateComponents *)endDate forActivity:(OCKCarePlanActivity *)activity completion:(void ( ^ ) ( BOOL success , OCKCarePlanActivity *_Nullable activity , NSError *_Nullable error ))completion

Parameters

endDate

End date for an activity.

activity

Activity object to receive new end date.

completion

A completion block that returns the result of the operation and the activity that was modified.

Declared In

OCKCarePlanStore.h

– removeActivity:completion:

Remove an activity from this store. All the events related to the activity will also be removed.

- (void)removeActivity:(OCKCarePlanActivity *)activity completion:(void ( ^ ) ( BOOL success , NSError *_Nullable error ))completion

Parameters

activity

The activity object to remove.

completion

A completion block that returns the result of the operation.

Declared In

OCKCarePlanStore.h

– eventsOnDate:type:completion:

Get all the OCKCarePlanEvent objects for a given date.

- (void)eventsOnDate:(NSDateComponents *)date type:(OCKCarePlanActivityType)type completion:(void ( ^ ) ( NSArray<NSArray<OCKCarePlanEvent*> *> *eventsGroupedByActivity , NSError *_Nullable error ))completion

Parameters

date

Date to filter events.

type

Activity type to filter events.

completion

A completion block that returns the result of the operation and a list of event objects.

Discussion

@disccussion The returned events are grouped by OCKCarePlanActivity objects.

Declared In

OCKCarePlanStore.h

– eventsForActivity:date:completion:

Obtain events on a given date and belongs to a OCKCarePlanActivity .

- (void)eventsForActivity:(OCKCarePlanActivity *)activity date:(NSDateComponents *)date completion:(void ( ^ ) ( NSArray<OCKCarePlanEvent*> *events , NSError *_Nullable error ))completion

Parameters

activity

Activity to filter events.

date

Date to filter events.

completion

A completion block that returns the result of the operation and a list of event objects.

Declared In

OCKCarePlanStore.h

– updateEvent:withResult:state:completion:

Change the state of an event and optionally attach a result object to it. All events start with OCKCarePlanEventStateInitial.

- (void)updateEvent:(OCKCarePlanEvent *)event withResult:(nullable OCKCarePlanEventResult *)result state:(OCKCarePlanEventState)state completion:(void ( ^ ) ( BOOL success , OCKCarePlanEvent *_Nullable event , NSError *_Nullable error ))completion

Parameters

event

The event object to modify.

result

The result to attach (optional).

state

A new state for the event.

completion

A completion block that returns the result of the operation and the event that was changed.

Declared In

OCKCarePlanStore.h

– dailyCompletionStatusWithType:startDate:endDate:handler:completion:

Get the daily event completion status within a date range. An event with state OCKCarePlanEventStateCompleted is counting towards completed number.

- (void)dailyCompletionStatusWithType:(OCKCarePlanActivityType)type startDate:(NSDateComponents *)startDate endDate:(NSDateComponents *)endDate handler:(void ( ^ ) ( NSDateComponents *date , NSUInteger completedEvents , NSUInteger totalEvents ))handler completion:(void ( ^ ) ( BOOL completed , NSError *_Nullable error ))completion

Parameters

type

Activity type to filter events.

startDate

Start date of the date range.

endDate

End date of the date range.

handler

A completion block that reports completion status for each day.

completion

A completion block that reports the end of the enumeration.

Declared In

OCKCarePlanStore.h

– enumerateEventsOfActivity:startDate:endDate:handler:completion:

Enumerate through all the events associated with an OCKCarePlanActivity object within a specified date range.

- (void)enumerateEventsOfActivity:(OCKCarePlanActivity *)activity startDate:(NSDateComponents *)startDate endDate:(NSDateComponents *)endDate handler:(void ( ^ ) ( OCKCarePlanEvent *_Nullable event , BOOL *stop ))handler completion:(void ( ^ ) ( BOOL completed , NSError *_Nullable error ))completion

Parameters

activity

The activity to which the events belong.

startDate

Start date of the date range.

endDate

End date of the date range.

handler

A completion block that returns each event object.

completion

A completion block that reports the end of the enumeration.

Declared In

OCKCarePlanStore.h

– evaluateAdheranceThresholdForActivity:date:completion:

Check the adherance threshold for an activity on a given day.

- (void)evaluateAdheranceThresholdForActivity:(OCKCarePlanActivity *)activity date:(NSDateComponents *)date completion:(void ( ^ ) ( BOOL success , OCKCarePlanThreshold *_Nullable threshold , NSError *_Nullable error ))completion

Parameters

activity

The activity to check.

date

The date to check.

completion

A completion block that returns the result of the operation and a possible triggered threshold object.

Declared In

OCKCarePlanStore.h