def METHOD_NAME(submission: Submission) -> str:
    """
    Given a submission instance, check if an appointment needs to be booked.
    This flow is aborted when:
    * The form is not marked as appointment form, which flags the 'new-style'
      appointments.
    * There is no related :class:`Appointment` instance - this is an unexpected error.
      It could be caused by an existing form being changed into an appointment form with
      old data.
    """
    if not submission.form.is_appointment:
        raise NoAppointmentForm("Not an appointment form")
    try:
        appointment = submission.appointment
    except Appointment.DoesNotExist:
        logevent.appointment_register_skip(submission)
        raise AppointmentRegistrationFailed(
            "No registration attempted - there is no appointment data available."
        )
    assert isinstance(appointment, Appointment)
    # Delete the previous appointment info if there is one since a new one will be
    # created anyway.
    AppointmentInfo.objects.filter(submission=submission).delete()
    try:
        appointment_id = book(appointment)
    except AppointmentCreateFailed as e:
        logger.error("Appointment creation failed", exc_info=e)
        # This is displayed to the end-user!
        error_information = _(
            "A technical error occurred while we tried to book your appointment. "
            "Please verify if all the data is correct or try again later."
        )
        appointment_info = AppointmentInfo.objects.create(
            status=AppointmentDetailsStatus.failed,
            error_information=error_information,
            submission=submission,
        )
        plugin = _get_plugin(appointment)
        logevent.appointment_register_failure(appointment_info, plugin, e)
        raise AppointmentRegistrationFailed("Unable to create appointment") from e
    cancel_previous_submission_appointment(submission)
    return appointment_id