def validate_medication_time()

in lambda/src/medication_diary_bot.py [0:0]


def validate_medication_time(intent_name, session_attributes, slot_details, slots):
    time_slot_val = slots.get(SLOT_MED_TIME, None)
    time_of_day_slot_val = slots.get(SLOT_MED_TIME_OF_DAY, None)
    time_val_resolutions = slot_details.get(SLOT_MED_TIME, {}).get('resolutions', []) if slot_details.get(
        SLOT_MED_TIME, {}) else []
    time_detail = parse_time_input(time_slot_val, time_of_day_slot_val,
                                   time_val_alts=[res['value'] for res in time_val_resolutions])
    slots[SLOT_MED_TIME] = time_detail.time_str
    slots[SLOT_MED_TIME_OF_DAY] = time_detail.time_of_day
    if time_detail.finished:
        return helper.delegate(session_attributes, slots)
    else:
        if time_detail.time_str is not None:
            return helper.elicit_slot(session_attributes, intent_name, slots, SLOT_MED_TIME_OF_DAY,
                                      f'<speak>Do you mean '
                                      f'<say-as interpret-as="time" >{time_detail.time_str}</say-as> '
                                      f'AM, or PM?</speak>',
                                      message_type='SSML')
        elif time_detail.time_of_day:
            return helper.elicit_slot(session_attributes, intent_name, slots, SLOT_MED_TIME,
                                      f'<speak>Can you tell the exact time in the '
                                      f'{time_detail.time_of_day}?</speak>',
                                      message_type='SSML')
        else:
            return helper.elicit_slot(session_attributes, intent_name, slots, SLOT_MED_TIME,
                                      '<speak>What time did you take your medication?</speak>',
                                      message_type='SSML')