from typing import Mapping
from typing import Any


def sex(document: dict) -> str:
    """
    Given a *document*, parses the sex name and returns its matching sex
    identifier.
    """
    sex_name = document.get("AssignedSex")

    sex_map: Mapping[Any, str] = {
        1: "male",
        2: "female"
    }

    return sex_map.get(sex_name, "other")