Using the shift theorem, we can easily calculate the z-transform of a digital filter's difference equation. Given the following second-order difference equation,
y[n] = b0 x[n] + b1 x[n-1] + b2 x[n-2] - a1 y[n-1] - a2 y[n-2],
the z-transform can immediately be written (assuming the system is linear)
Y(z) = b0 X(z) + b1 z-1 X(z) + b2 z-2 X(z) - a1 z-1 Y(z) - a2 z-2 Y(z).