Diffusion across an interface and conservation of mass.
I am reading a physiology book chapter (Mathematical Physiology, by Keener --Respiration chapter) about the gas exchange between capillaries and alveoli. It seems that this gas exchange can be modeled after some simple physical relationships. Since I am not usually studying physics, I do not fully understand some concepts that the author uses to derive a conservation law and I would appreciate any help.
I do admit, however, that this question may be off-topic since it could be a mathematical lapsus rather than a physics question.
Preliminaries
First, the author indicates that if a gas with partial pressure $P_g$ is in contact with a liquid, the steady-state concentration $U$ of gas is given by: $$ U = \sigma P_s $$
where $\sigma$ is the solubility of the gas in the liquid. I assume that this is a particular version of Henry's Law.
Then, it explains if there is a difference between the partial pressure of the gas ($P_g$) and the partial pressure on the fluid ($\frac{U}{\sigma}$), then there should be some flux between the gas and the fluid and the simplest model would be to assume that this flux is linearly proportional to the pressure difference: $$ q = D_s \left(P_g - \frac{U}{\sigma}\right) $$
Problem
The author then considers a segment of a capillary (a cylindrical tube) of length $L$, constant cross-sectional area $A$ and perimeter $p$, that is in contact with a gas with partial pressure $P_g$. 453
The fluid moves through the tube with a velocity $v(x)$. Finally, they say that since mass is conserved: $$ \frac{d}{dt} \left( A \int_{0}^{L} U(x,t) dt \right) = v(0)AU(0,t) - v(L)AU(L,t) + p \int_{0}^{L} q(x,t) dx $$
Question
How is the relationship below derived?
I understand that $A \int_{0}^{L} U(x,t) dt$ is in fact the total amount of the dissolved gas in the tube at a given time. I also understand how $\int_{0}^{L} q(x,t) dx$ represents the total flux of gas across the whole capillary wall. However, I fail to see what the two first elements of the right-hand represent and why is the left-side derived with respect to $t$. 453