Question: Creating a conditional differential equation in Maple

I am a new Maple user. I have a system of differential equations and I want Maple to solve the system such that if one of the solutions (dependent variable) is larger than a certain value, one of the differential equation will be described in a different way. I will describe it with an example:

# imagine we have two differential equations:
eqn1 := diff(T(x), x) = x + T(x)/10 + q(x)/2;
eqn2 := diff(q(x), x) = T(x)^2/10 + 3*q(x);
#The solution is given by:
sol := dsolve({eqn1, eqn2, T(0) = 0, q(0) = 0}, {T(x), q(x)}, numeric, method = mebdfi);
odeplot(sol, [x, T(x)], x = 1 .. 3);

#what I want to do is to write a conditional differential equation that depends on the solution T(x) of the system. For exmaple, if the value of T(x) is larger than 4, the solver sould use a different equation to solve the system. Say for example instead of eqn1 it will use something else like: eqn1:=diff(T(x),x)=x+T(x)^2/200+q(x)/300.

#Internally after each iteration, the solver should check the value of the solution T(x), and depending on it it will choose a different differential equation to use in the next step x.

I tried defining the differential equation as piecewise but I was not successful.

Please Wait...