Additional items should be added before idMapping

Previously additional fields were added to the documents after that had
all been created. We want to use an additional field as part of creating
the _id so it need to be available to the build_document function. This
commit pushes the additionalFields down into this function.