def try_get_department(department_or_code):
try:<EOL><INDENT>value = take_first_department_code(department_or_code)<EOL><DEDENT>except AssertionError:<EOL><INDENT>value = department_or_code<EOL><DEDENT>if value in DEPARTMENT_MAPPING:<EOL><INDENT>value = DEPARTMENT_MAPPING[value]<EOL><DEDENT>return value<EOL>
Try to take the first department code, or fall back to string as passed