def filter_tornado_keys_patient_data_kvp(all_patient_data, 
    study_key, query_key, query_val):
    """
    Does a simple kvp filter against the patient data from a study  using the
    data structure loaded by patient_data_etl.load_all_metadata.

    returns a list of tornado_sample_keys
    """

    cohort_sample_keys = list()
    study_data = all_patient_data[study_key]
    for tornado_sample_key in study_data['patients']:
        patient_data = study_data['patients'][tornado_sample_key]
        if patient_data[query_key] == query_val:
            cohort_sample_keys.append(tornado_sample_key)
    return cohort_sample_keys