Example #1
0
def __local_document_create(request, record, pha, external_id, existing_doc):
  """
  This function only serves document_create and document_create_or_update
  The pha argument is null for medical data, non-null for app-specific
  The external_id is expected to be already adjusted
  """
  try:
    doc = _document_create(record              = record, 
                          creator             = request.principal,
                          pha                 = pha, 
                          content             = request.raw_post_data, 
                          external_id         = external_id,
                          replaces_document   = existing_doc,
                          mime_type           = utils.get_content_type(request))
  except ValueError, e:
    return HttpResponseBadRequest("the document submitted is malformed:" + str(e))
Example #2
0
def __local_document_create(request, record, pha, external_id, existing_doc):
    """
  This function only serves document_create and document_create_or_update
  The pha argument is null for medical data, non-null for app-specific
  The external_id is expected to be already adjusted
  """
    try:
        doc = _document_create(record=record,
                               creator=request.principal,
                               pha=pha,
                               content=request.raw_post_data,
                               external_id=external_id,
                               replaces_document=existing_doc,
                               mime_type=utils.get_content_type(request))
    except ValueError, e:
        return HttpResponseBadRequest("the document submitted is malformed:" +
                                      str(e))
Example #3
0
def __local_document_create(request, record, pha, external_id, existing_doc):
    """ Create a document, or update one in place.

    This function serves 
    :py:meth:`~indivo.views.documents.document.document_create` and 
    :py:meth:`~indivo.views.documents.document.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*: if the document is record-specific, this
        :py:class:`~indivo.models.records_and_documents.Record`
        instance refers to the document's record.

    * *pha*: if the document is application-specific, this
        :py:class:`~indivo.models.apps.PHA` instance refers to the 
        application to which the document pertains.  

    * *external_id*: the external identifier to assing to the new document, 
        if available. The identifier should already have been prepared using
        :py:meth:`~indivo.models.records_and_documents.Document.prepare_external_id`.

    * *existing_doc*: If the new document will overwrite (via in-place update
        or versioning) an existing document, this 
        :py:class:`~indivo.models.records_and_documents.Document`
        instance references the old document to be overwritten.

    **Returns:**

    * An HttpResponse object whose body is a string of XML describing the created 
        document, ready for return over the wire on success.

    * An instance of :py:class:`django.http.HttpResponseBadRequest` if the new
        document failed validation during the creation process.

    **Raises:**
    
    * :py:exc:`django.db.IntegrityError`: if the arguments to this function
        violate a database unique constraint (i.e., duplicate external id).

        .. warning::

             If an :py:exc:`IntegrityError` is raised, it will invalidate the 
             current database transaction. Calling functions should handle this
             case and rollback the current transaction.

    """

    try:
        doc = _document_create(record=record,
                               creator=request.principal,
                               pha=pha,
                               content=request.raw_post_data,
                               external_id=external_id,
                               replaces_document=existing_doc,
                               mime_type=utils.get_content_type(request))
    except ValueError, e:
        return HttpResponseBadRequest("the document submitted is malformed:" +
                                      str(e))
Example #4
0
def __local_document_create(request, record, pha, external_id, existing_doc):
    """ Create a document, or update one in place.

    This function serves 
    :py:meth:`~indivo.views.documents.document.document_create` and 
    :py:meth:`~indivo.views.documents.document.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*: if the document is record-specific, this
        :py:class:`~indivo.models.records_and_documents.Record`
        instance refers to the document's record.

    * *pha*: if the document is application-specific, this
        :py:class:`~indivo.models.apps.PHA` instance refers to the 
        application to which the document pertains.  

    * *external_id*: the external identifier to assing to the new document, 
        if available. The identifier should already have been prepared using
        :py:meth:`~indivo.models.records_and_documents.Document.prepare_external_id`.

    * *existing_doc*: If the new document will overwrite (via in-place update
        or versioning) an existing document, this 
        :py:class:`~indivo.models.records_and_documents.Document`
        instance references the old document to be overwritten.

    **Returns:**

    * An HttpResponse object whose body is a string of XML describing the created 
        document, ready for return over the wire on success.

    * An instance of :py:class:`django.http.HttpResponseBadRequest` if the new
        document failed validation during the creation process.

    **Raises:**
    
    * :py:exc:`django.db.IntegrityError`: if the arguments to this function
        violate a database unique constraint (i.e., duplicate external id).

        .. warning::

             If an :py:exc:`IntegrityError` is raised, it will invalidate the 
             current database transaction. Calling functions should handle this
             case and rollback the current transaction.

    """

    try:
        doc = _document_create(
            record=record,
            creator=request.principal,
            pha=pha,
            content=request.raw_post_data,
            external_id=external_id,
            replaces_document=existing_doc,
            mime_type=utils.get_content_type(request),
        )
    except ValueError, e:
        return HttpResponseBadRequest("the document submitted is malformed:" + str(e))