Indivo Framework (iOS)
An iOS framework for Apps connecting to Indivo server
 All Classes Functions Variables Properties Pages
Instance Methods | Class Methods | Properties | List of all members
IndivoDocument Class Reference

An IndivoDocument represents a document tied to a record. More...

#import <IndivoDocument.h>

Inherits IndivoAbstractDocument.

Inherited by IndivoAggregateReport, IndivoAllergy, IndivoAllergyExclusion, IndivoAppDocument, IndivoDemographics, IndivoEncounter, IndivoEquipment, IndivoFill, IndivoImmunization, IndivoLabResult, IndivoMedication, IndivoPrincipal, IndivoProblem, IndivoProcedure, IndivoSimpleClinicalNote, and IndivoVitalSigns.

Instance Methods

(void) - archive:forReason:callback:
 Archive (or unarchive) a document for the given reason. More...
 
(NSString *) - basePostPath
 The base path, e.g. More...
 
(id) - cachedObjectOfType:
 Retrieves the object for a given type from cache. More...
 
(BOOL) - cacheObject:asType:error:
 Caches the object for a given type. More...
 
(NSString *) - documentPath
 The path to this document, i.e. More...
 
(void) - fetchMetaDocumentWithCallback:
 Fetches the meta document for this document. More...
 
(void) - fetchStatusHistoryWithCallback:
 Fetch the document's version history. More...
 
(void) - fetchVersionsWithCallback:
 Fetch the document's version history. More...
 
(BOOL) - hasStatus:
 
(id) - initFromNode:forRecord:withMeta:
 The designated initializer. More...
 
(BOOL) - isLatest
 
(void) - pull:
 
(void) - push:
 This method puts a new document on the server. More...
 
(void) - replace:
 This method updates the receiver's version on the server with new data from the receiver's properties. More...
 
(void) - setLabel:callback:
 Label a document. More...
 
(void) - updateWithMeta:
 This method updates our udid, type and status from the given meta document. More...
 
(void) - void:forReason:callback:
 Void (or unvoid) a document for a given reason. More...
 
- Instance Methods inherited from IndivoAbstractDocument
(NSString *) - documentXML
 Returns an XML representation of the receiver, like "xml" does, but adds namespace information. More...
 
(NSString *) - flatDocumentXML
 Returns the Indivo 2.0 flat XML format for a document. More...
 
(NSString *) - flatXML
 Returns the Indivo 2.0 flat XML format. More...
 
(id) - initFromNode:forRecord:
 The designated initializer, initializes an instance from an XML node. More...
 
- Instance Methods inherited from INServerObject
(void) - forceNotOnServer
 This is provided for subclasses, the fact that onServer is readonly but settable by this and markOnServer underlines the fact that you should only change this property when you know what you're doing. More...
 
(void) - get:callback:
 Shortcut for GETting data. More...
 
(void) - get:parameters:callback:
 Shortcut for GETting data with parameters. More...
 
(id) - initFromNode:withServer:
 The designated initializer. More...
 
(BOOL) - is:
 Shortcut method to test if the document has the given ID. More...
 
(void) - markOnServer
 Sets onServer to YES for the receiver. More...
 
(void) - performMethod:withBody:orParameters:httpMethod:callback:
 The basic method to perform REST methods on the server with App credentials. More...
 
(void) - post:body:callback:
 Shortcut for POSTing body data. More...
 
(void) - post:parameters:callback:
 Shortcut for POSTing parameters. More...
 
(void) - put:body:callback:
 Shortcut for PUTting data. More...
 

Class Methods

(id) + cachedObjectOfType:forId:
 Retrieves the cached object of a given type for a given document udid. More...
 
(BOOL) + cacheObject:asType:forId:error:
 Stores an object of a given type for the document of the given udid. More...
 
(Class) + documentClassForType:
 Returns the class for a previously registered type, or "IndivoDocument" if the type has not been registered. More...
 
(NSString *) + fetchReportPathForRecord:
 The base path to get reports for documents of this class. More...
 
(void) + registerDocumentClass:
 Our IndivoDocument subclasses call this in their +load method. More...
 
(NSString *) + reportType
 This name is used to construct the report path for this kind of document. More...
 
- Class Methods inherited from IndivoAbstractDocument
(Class) + classForProperty:
 Returns the class of a property from the property map dictionary. More...
 
(NSString *) + nameSpace
 
(id) + newWithRecord:
 To get a new instance that must be pushed to the server. More...
 
(NSDictionary *) + propertyClassMapper
 The automatically generated IndivoDocument subclasses return a dictionary with property->class mappings. More...
 
(BOOL) + useFlatXMLFormat
 Implementing this to have some flexibility about the XML format to use on the road to Indivo 2.0, default implementation returns YES. More...
 

Properties

IndivoPrincipalcreator
 The creator of the document. More...
 
INDocumentStatus documentStatus
 This document's status. More...
 
BOOL fetched
 YES if the document has been fetched from the server. More...
 
NSString * label
 This document's label. More...
 
NSString * uuidLatest
 The udid of the latest document of the receiver. More...
 
NSString * uuidOriginal
 The udid of the original document, if the receiver replaced a document. More...
 
NSString * uuidReplaces
 The udid of the replaced document, if the receiver replaced a document. More...
 
- Properties inherited from IndivoAbstractDocument
IndivoCreated * created
 
NSString * nameSpace
 The namespace. More...
 
IndivoRecordrecord
 The owning record. If you change this on documents fetched from the server, you will get errors. More...
 
IndivoSuppressed * suppressed
 
- Properties inherited from INServerObject
BOOL onServer
 Indicates whether this document lives on the server. More...
 
IndivoServerserver
 Our beloved server. More...
 
NSString * uuid
 This object's udid. More...
 

Additional Inherited Members

- Protected Attributes inherited from INObject
NSString * _nodeName
 

Detailed Description

An IndivoDocument represents a document tied to a record.

It's the superclass to all the specific document types we provide (IndivoMedication, IndivoAllergy and so on) and if you implement your own type, you should consider using this as the base class.

Method Documentation

- (void) archive: (BOOL)  flag
forReason: (NSString *)  aReason
callback: (INCancelErrorBlock)  callback 

Archive (or unarchive) a document for the given reason.

You must supply a reason, Indivo server will issue a 400 if there is no reason

Parameters
flagYES to archive, NO to re-activate
aReasonThe reason for the status change, should not be nil if you want the call to succeed
callbackAn INCancelErrorBlock callback
- (NSString *) basePostPath

The base path, e.g.

"/records/{record id}/documents/" for documents. POSTing XML to this path should result in creation of a new object of this class (given it doesn't fail on the server)

- (id) cachedObjectOfType: (NSString *)  aType

Retrieves the object for a given type from cache.

+ (id) cachedObjectOfType: (NSString *)  aType
forId: (NSString *)  aUdid 

Retrieves the cached object of a given type for a given document udid.

Todo:
load from disk
- (BOOL) cacheObject: (id)  anObject
asType: (NSString *)  aType
error: (__autoreleasing NSError **)  error 

Caches the object for a given type.

+ (BOOL) cacheObject: (id)  anObject
asType: (NSString *)  aType
forId: (NSString *)  aUdid
error: (__autoreleasing NSError **)  error 

Stores an object of a given type for the document of the given udid.

Todo:
cache to disk
+ (Class) documentClassForType: (NSString *)  aType

Returns the class for a previously registered type, or "IndivoDocument" if the type has not been registered.

- (NSString *) documentPath

The path to this document, i.e.

the path I can GET to receive this document instance

- (void) fetchMetaDocumentWithCallback: (INSuccessRetvalueBlock)  callback

Fetches the meta document for this document.

+ (NSString *) fetchReportPathForRecord: (IndivoRecord *)  aRecord

The base path to get reports for documents of this class.

- (void) fetchStatusHistoryWithCallback: (INSuccessRetvalueBlock)  callback

Fetch the document's version history.

Upon success, the userInfo dictionary will contain an array of INDocumentStatusNode objects for the INResponesArrayKey key.

Parameters
callbackAn INCancelErrorBlock callback
- (void) fetchVersionsWithCallback: (INSuccessRetvalueBlock)  callback

Fetch the document's version history.

Upon success, the userInfo dictionary will contain an array of IndivoMetaDocument objects for the INResponesArrayKey key.

Parameters
callbackAn INCancelErrorBlock callback
- (BOOL) hasStatus: (INDocumentStatus)  aStatus
Returns
YES if the receiver's status matches the supplied status, which can be an OR-ed list of status
- (id) initFromNode: (INXMLNode *)  aNode
forRecord: (IndivoRecord *)  aRecord
withMeta: (IndivoMetaDocument *)  aMetaDocument 

The designated initializer.

- (BOOL) isLatest
Returns
YES if this document has not (yet) been replaced by a newer version
- (void) pull: (INCancelErrorBlock)  callback
- (void) push: (INCancelErrorBlock)  callback

This method puts a new document on the server.

Attention
If you have assigned a udid yourself already, this udid will change. Use "replace:" to update a modified document on the server.
+ (void) registerDocumentClass: (Class)  aClass

Our IndivoDocument subclasses call this in their +load method.

Since we are auto-generating the classes from a template, this method is potentially also called by non-IndivoDocument-subclasses, which is why we check for subclass status here instead.

- (void) replace: (INCancelErrorBlock)  callback

This method updates the receiver's version on the server with new data from the receiver's properties.

If the document does not yet exist, this method automatically calls "push:" to create the document.

+ (NSString *) reportType

This name is used to construct the report path for this kind of document.

For example, "IndivoMedication" will return "medications" from this method, so the path will be "/records/<record-id>/medications/".

- (void) setLabel: (NSString *)  aLabel
callback: (INCancelErrorBlock)  callback 

Label a document.

- (void) updateWithMeta: (IndivoMetaDocument *)  aMetaDoc

This method updates our udid, type and status from the given meta document.

Todo:
There is more information in the meta doc, either store the whole meta doc or store the data in the instance.
- (void) void: (BOOL)  flag
forReason: (NSString *)  aReason
callback: (INCancelErrorBlock)  callback 

Void (or unvoid) a document for a given reason.

Parameters
flagYES to void, NO to re-activate
aReasonThe reason for the status change, should not be nil if you want the call to succeed
callbackAn INCancelErrorBlock callback

Property Documentation

- (IndivoPrincipal*) creator
readnonatomicstrong

The creator of the document.

- (INDocumentStatus) documentStatus
readnonatomicassign

This document's status.

- (BOOL) fetched
readnonatomicassign

YES if the document has been fetched from the server.

- (NSString*) label
readnonatomiccopy

This document's label.

- (NSString*) uuidLatest
readnonatomiccopy

The udid of the latest document of the receiver.

- (NSString*) uuidOriginal
readnonatomiccopy

The udid of the original document, if the receiver replaced a document.

- (NSString*) uuidReplaces
readnonatomiccopy

The udid of the replaced document, if the receiver replaced a document.


The documentation for this class was generated from the following files: