def discard_inserted_documents(error_documents, original_documents):
    """Discard any documents that have already been inserted which are violating index constraints
       such documents will have an error code of 11000 for a DuplicateKey error
       from https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.yml#L467

       Parameters:
           error_documents (List[Dict]): list of documents that failed to insert in original transaction
           original_documents (List[Dict]): list of documents from original transaction that failed
           error_code (Int): error status code to filter on

       Returns:
           List[Dict]: list of documents with matching error code entries removed
    """
    # doc['op'] returns the actual document from the previous transaction
    errors = list(doc['op'] for doc in error_documents if doc['code'] == 11000)
    return list(doc for doc in original_documents if doc not in errors)