from datetime import datetime


def verify_get_interval_average_input(in_dict):
    """
    Verify the json contains the correct keys and data
    {"patient_id": 1,
    "heart_rate_average_since": "2018-03-09 11:00:36.372339"}
    """
    for key in ("patient_id", "heart_rate_average_since"):
        if key not in in_dict:
            return "Key {} not found".format(key)
        if key == "patient_id":
            try:
                id = int(in_dict[key])
            except ValueError:
                return "Key patient_id is not integer"
        if key == "heart_rate_average_since":
            try:
                timestamp = datetime.strptime(in_dict[key],
                                              '%Y-%m-%d %H:%M:%S.%f')
            except:
                return "Key heart_rate_average_since not " \
                    + "in correct datetime format"
    return True