Novak Djokovic has reached the second week of the Australian Open for the first time in three years after seeing off Daniil Medvedev in four sets.