def METHOD_NAME(prescriptions, practices, dates):
    """
    Accepts an iterable of prescriptions plus mappings of pratice codes and
    date strings to their respective row/column offsets. Yields tuples of the
    form:
        bnf_code, items_matrix, quantity_matrix, actual_cost_matrix, net_cost_matrix
    Where the matrices contain the prescribed values for that presentation for
    every practice and date.
    """
    max_row = max(practices.values())
    max_col = max(dates.values())
    shape = (max_row + 1, max_col + 1)
    grouped_by_bnf_code = groupby(prescriptions, lambda row: row[0])
    for bnf_code, row_group in grouped_by_bnf_code:
        items_matrix = sparse_matrix(shape, integer=True)
        quantity_matrix = sparse_matrix(shape, integer=False)
        actual_cost_matrix = sparse_matrix(shape, integer=True)
        net_cost_matrix = sparse_matrix(shape, integer=True)
        for _, practice, date, items, quantity, actual_cost, net_cost in row_group:
            practice_offset = practices[practice]
            date_offset = dates[date]
            items_matrix[practice_offset, date_offset] = items
            quantity_matrix[practice_offset, date_offset] = quantity
            actual_cost_matrix[practice_offset, date_offset] = actual_cost
            net_cost_matrix[practice_offset, date_offset] = net_cost
        yield MatrixRow(
            bnf_code,
            finalise_matrix(items_matrix),
            finalise_matrix(quantity_matrix),
            finalise_matrix(actual_cost_matrix),
            finalise_matrix(net_cost_matrix),
        )