def criterion_mapping(crit):
    """Returns mapping tuple (table, patient, start, end, code, status, value, fields)

       table:    is a table reference for the episode

       patient:  expression for episode patient ID

       start:    expression for episode start date/time

       end:      expression for episode end date/time or NULL

       code:     expression for episode coding or NULL, e.g. 
                 diagnosis code

       status:   expression for episode status or NULL, i.e. 
                 HQMF status string

       negation: expression for episode negation, i.e. negation 
                 rationale or NULL for non-negated/non-negatable

       value:    expression for episode value or NULL, e.g. lab 
                 numeric value

    """
    qds_data_type = crit.data['qds_data_type'].flatten()

    return (qds_data_type, 
            'patient_id', 
            'start_dt', 
            'end_dt', 
            'code', 
            'status', 
            'negation', 
            'value')