Create a document, or update one in place.
This function serves document_create() and document_create_or_update(), which encompasses record- and/or app-specific documents.
The external_id is expected to be already adjusted.
Arguments:
request: The incoming Django HttpRequest object.
Record instance refers to the document’s record.
PHA instance refers to the application to which the document pertains.
if available. The identifier should already have been prepared using prepare_external_id().
or versioning) an existing document, this Document instance references the old document to be overwritten.
Returns:
document, ready for return over the wire on success.
document failed validation during the creation process.
Raises:
violate a database unique constraint (i.e., duplicate external id).
Warning
If an IntegrityError is raised, it will invalidate the current database transaction. Calling functions should handle this case and rollback the current transaction.
Create an Indivo Document.
This is the lowest-level creation function called for all record- and/or app-specific documents.
The PHA argument, if non-null, indicates app-specificity only. By this point, the external_id should be fully formed.
If status is specified, then it is used, otherwise it is not specified and the model’s default value is used (i.e. active).
This function creates a new model instance, processing the document if necessary, and storing it in the database (or in the file system, if the document is binary).
Arguments:
instance that is responsible for creating the document.
content: The raw content (XML or binary) of the document to be created.
PHA instance refers to the application to which the document pertains.
Record instance refers to the document’s record.
or versioning) an existing document, this Document instance references the old document to be overwritten.
if available. The identifier should already have been prepared using prepare_external_id().
application/xml.
status: The initial status of the new document. active by default.
Returns:
Document, on success. If the document was updated in place, and no new document was created, the old document is returned.
Raises:
ValueError: if the document doesn’t validate.
violate a database unique constraint (i.e., duplicate external id).
Warning
If an IntegrityError is raised, it will invalidate the current database transaction. Calling functions should handle this case and rollback the current transaction.
Set the ‘related documents’-related fields on a document for rendering.
This is computed at load-time before each rendering of document. It is not pre-computed or stored in the DB.
returns: None
Fetch a document from the DB.
EITHER document_id OR external_id must be provided (exclusive or). If a document doesn’t exist matching all passed arguments, this call returns None.
Arguments:
Record instance refers to the document’s record.
Carenet instance refers to the carenet containing the document.
Warning
Carenet membership is NOT checked in this function. That security must be checked elsewhere.
document_id: the internal identifier for the document, if available.
Note
One of external_id or document_id MUST be passed to this function, or it cannot retrieve a unique document.
PHA instance refers to the application to which the document pertains.
identifier should already have been prepared using prepare_external_id().
Note
One of external_id or document_id MUST be passed to this function, or it cannot retrieve a unique document.
Returns:
Document, on success.
None, if a document satisfying all passed arguments could not be found.
Get the raw content of a document, ready to be sent over the wire.
Arguments:
Document instance to render.
Returns:
document on success.
Lowlevel document rendering to response data.
Arguments:
Document objects to be rendered.
Record that every document in docs belongs to.
PHA that docs are scoped to.
This can be passed in to avoid recomputing the size of docs if that might be expensive (i.e., a QuerySet which would require an extra DB call).
format_type: The format to render into. Options are xml.
Returns:
documents (which might be empty).
Set the ‘latest version’-related fields on a document for rendering.
This is computed at load-time before each rendering of document. It is not pre-computed or stored in the DB.
returns: None
Create an app-specific Indivo document.
Calls into document_create_or_update().
Create or Overwrite an app-specific Indivo document.
Calls into document_create_or_update().
Create an app-specific Indivo document with an associated external id.
Calls into document_create_or_update().
List app-specific documents.
Calls into document_list().
Retrive an app-specific document.
Calls into document().
Retrieve a document, record- and/or app-specific.
Arguments:
request: the incoming Django HttpRequest object.
document_id: the internal identifier of the document to retrieve.
Record instance refers to the document’s record.
PHA instance refers to the application to which the document pertains.
Returns:
on success.
Raises:
Create a record-specific Indivo Document.
Calls into __local_document_create().
Create a record-specific Indivo Document with an associated external id.
Calls into __local_document_create().
Create or Overwrite an app-specific or record-app-specific document, possibly with an associated external id.
Prepares the external id, loads the existing document to overwrite, then calls into __local_document_create().
List Indivo documents.
Arguments:
request: The incoming Django HttpRequest object. request.GET may contain:
- type: The Indivo document schema type on which to filter the resut set. As
of 2010-08-16, type is no longer part of the URL, it’s only in the GET query parameters.
arguments. See marsloader() or API Query Interface.
Record instance refers to the record to filter on.
PHA instance refers to the app to filter on.
Returns:
documents (which might be empty), on success.
Raises:
correspond to an existing Indivo schema.
Create a record-app-specific Indivo document.
Calls into document_create_or_update().
Create or Overwrite a record-app-specific Indivo document with an associated external id.
Calls into document_create_or_update().
List record-app-specific documents.
Calls into document_list().
Retrieve a record-app-specific document.
Calls into document().
List record-specific documents.
Calls into document_list().
Retrieve a record-specific document.
Calls into document().
Delete a document.
ARGUMENTS:
RETURNS:
RAISES:
Delete an app-specific document.
No restrictions, since this storage is managed by the app.
Calls into _document_delete().
Delete all documents associated with a record.
ARGUMENTS:
RETURNS:
Delete a record-app-specific document.
No restrictions, since this storage is managed by the app.
Calls into _document_delete().
Set a document’s label.
ARGUMENTS:
request: The incoming Django HttpRequest object. request.POST must consist of a raw string containing the new label to assign.
record: The Record that the document is scoped to, if applicable.
document_id: The internal identifier of the document to re-label.
Note
One of external_id or document_id MUST be passed to this function, or it cannot retrieve a unique document.
external_id: The external identifier of the document to re-label.
Note
One of external_id or document_id MUST be passed to this function, or it cannot retrieve a unique document.
pha: The PHA object that the document is scoped to. Also serves to scope external_id, if present and app_specific is True.
app_specific: Whether or not the document is app-specific. The mere presence of the pha argument isn’t enough to satisfy this question, as pha might have been passed in only to scope an external id for a non-app-specific document.
RETURNS:
RAISES:
Set the label of an app-specific document.
Calls into _document_label().
Set the label of a record-app-specific document.
Calls into _document_label().
Set the label of a record-specific document.
Calls into _document_label().
Set the label of a record-specific document, specified by external id.
Calls into _document_label().
Fetch the metadata of a single document.
Metadata includes:
ARGUMENTS:
record: The Record that the document is scoped to, if applicable.
carenet: The Carenet that the document is shared into, if applicable.
document: The document to get metadata for, if it has been prefetched.
Note
One of external_id or document MUST be passed to this function, or it cannot retrieve a unique document.
pha: The PHA object that the document is scoped to. Also serves to scope external_id, if present and app_specific is True.
external_id: The external identifier of the document to re-label.
Note
One of external_id or document MUST be passed to this function, or it cannot retrieve a unique document.
app_specific: Whether or not the document is app-specific. The mere presence of the pha argument isn’t enough to satisfy this question, as pha might have been passed in only to scope an external id for a non-app-specific document.
RETURNS:
RAISES:
Fetch the metadata of an app-specific document.
Calls into _document_meta().
Fetch the metadata of an app-specific document identified by external id.
Calls into _document_meta().
Fetch the metadata of a record-specific document via a carenet.
Calls into _document_meta().
Fetch the metadata of a record-app-specific document.
Calls into _document_meta().
Fetch the metadata of a record-app-specific document identified by external id.
Calls into _document_meta().
Fetch the metadata of a record-specific document.
Calls into _document_meta().
Fetch the metadata of a record-specific document identified by external id.
Calls into _document_meta().
Set metadata fields on a document. NOT IMPLEMENTED.
Create a document and relate it to an existing document.
ARGUMENTS:
RETURNS:
RAISES:
Create a document and relate it to an existing document.
Calls into _document_create_by_rel().
Create a document, assign it an external id, and relate it to an existing document.
Calls into _document_create_by_rel().
Create a new relationship between two existing documents.
ARGUMENTS:
RETURNS:
RAISES:
Get all documents related to the passed document_id by a relation of the passed relation-type.
Includes relationships to other versions of document_id. Paging operators are NOT IMPLEMENTED.
ARGUMENTS:
request: The incoming Django HttpRequest object.
record: The Record that the document is scoped to.
document_id: The internal document identifier for the source document.
rel: The relationship type to filter related documents by (as a string).
limit, offset, status, order_by: Standard paging and filtering arguments. See marsloader() or API Query Interface.
Note
Paging operators are not implemented for this call currently. Passing them into the function will have no effect on output.
pha: The PHA object that the source document is scoped to, if applicable.
RETURNS:
RAISES:
Set the status of a record-specific document.
ARGUMENTS:
RETURNS:
RAISES:
List all changes to a document’s status over time.
ARGUMENTS:
RETURNS:
RAISES:
Create a new version of a record-specific document.
ARGUMENTS:
RETURNS:
RAISES:
Create a new version of a record-specific document.
Calls into _document_version().
Create a new version of a record-specific document and assign it an external id.
Calls into _document_version().
Retrieve the versions of a document.
ARGUMENTS:
RETURNS:
RAISES:
Read a special document.
Calls into get_special_doc().
Fetch a special document from either a record or a carenet.
ARGUMENTS:
record: The Record from which to fetch the special document.
Note
Either record or carenet must be non-empty.
carenet: The Carenet from which to fetch the special document.
Note
Either record or carenet must be non-empty.
special_document: The type of special document to fetch. Options are demographics or contact.
RETURNS:
RAISES:
Read a special document from a record.
Calls into _read_special_document().
Read a special document from a carenet.
Calls into _read_special_document().
Create or update a special document on a record.
ARGUMENTS:
RETURNS:
Set a record to point to a different existing special_document.
Also updates the label of record to the full_name in the new contact document.
ARGUMENTS:
RETURNS:
Unimplemented.
Unimplemented.