Calculate right leg drive integrator
An ecg is an instrumentation amplifier. The right leg drive amplifies the common mode noise (mains hum) and injects it into the patient body, so that it can be rejected by the instrumentation amplifier more easily.

I'm not sure if the 30K resistors play any role in setting the gain. If the midpoint of the 30K is considered ground, then the 12K has to be outside the feedback loop (otherwise it does not make sense). The attenuation did not change much from using a single 15K to ground (and the 12k inside the feedback loop). I checked this by doing a bode plot in LTspice. Attenuation is about 38dB till 10Hz and decreases to about 3dB at 1.5KHz (6dB at 1KHz for the 15K). Based on this it may be better to have the 12k inside the feedback loop, but it does not seem to make a big difference.