def minimize_document(document):
    """
    Takes a document obtained directly from its json from the portal and strips
    it down to a subset of desired fields. The document @id is prepended to the
    attachment href
    """
    minimized_document = {}
    
    for field in ('document_type', 'urls', 'references'):
        if field in document:
            minimized_document[field] = document[field]
    
    if 'attachment' in document:
        minimized_document['attachment'] = document['@id'] + document['attachment']['href']

    return minimized_document