What you are looking for nowadays goes by the name of the Rumin complex, and is defined on any contact manifold, although there is, of course, a vast generalization of this that sometimes goes by the name of 'the variational bicomplex' and sometimes by the name 'characteristic cohomology'. Here is a brief description that is suited for the question you asked:
On $M = \mathbb{R}^3$ with coordinates $x,y_0,y_1$, consider the differential ideal $\mathcal{I}\subset\Omega^\ast(M)$ generated by the $1$-form $\omega = dy_0 - y_1\ dx$, i.e., the set of linear combinations of all multiples of $\omega$ and $d\omega$. Note that $\mathcal{I}$ is a homogeneous ideal and equals $\Omega^\ast(M)$ in degrees 2 and 3. Because $\mathcal{I}$ is closed under exterior derivative, it forms a sub-complex of $\bigl(\Omega^\ast(M),d\bigr)$, and so there is a graded quotient complex, call it $\bigl(\mathcal{Q},\bar d\bigr)$, that vanishes in degrees above $1$. Note that $\mathcal{Q}^0 = \Omega^0(M)= C^\infty(M)$, since $\mathcal{I}$ vanishes in degree $0$.
Now, say that an element $\phi \in \mathcal{Q}^1$ is exact if $\phi = \bar d f$ for some $f\in \mathcal{Q}^0 = \Omega^0(M)= C^\infty(M)$. Unfortunately, the complex $\bigl(\mathcal{Q},\bar d\bigr)$ is not locally exact in positive degree, as $\bigl(\Omega^\ast(M),d\bigr)$ is. In fact, $\bar d \phi =0$ for all $\phi\in\mathcal{Q}^1$, so that is not a text for exactness.
Let me pause just a moment to explain how this fits into your question. Your equation $P(x)y'' + Q(x)y' +R(x)y = 0$ is encoded as the element $\phi = P(x) dy_1 + (Q(x)y_1 + R(x) y_0) dx$ (which is the same as the element $P(x) dy_1 + Q(x)dy_0 + R(x) y_0 dx$ in $\mathcal{Q}^1$), and you are asking when there is a function $f(x,y_0,y_1)$ such that $\phi = \bar d f$. (You should verify that $f = P(x) y_1 + (Q(x)-P'(x))y_0$ works when your equation is satisfied and that, otherwise, nothing does.)
Now, how can we test for exactness? This is where the Rumin complex (aka the variational bicomplex, etc.) comes in. It turns out that there is a way to embed the operator $\bar d:\mathcal{Q}^0\to\mathcal{Q}^1$ into a complex that provides a fine resolution of the constant sheaf, the same way that the exterior derivative does for the full complex of exterior differential forms. What you do is this: Let $\mathcal{E}^2\subset\Omega^2(M)$ be the set of multiples of $\omega$ and let $\mathcal{E}^3=\Omega^3(M)$.
We now want to define an extended complex $$ 0\to \mathcal{Q}^0\to \mathcal{Q}^1\to \mathcal{E}^2\to \mathcal{E}^3\to 0. $$ The map from $\mathcal{E}^2$ to $\mathcal{E}^3$ is just the usual exterior derivative, so the only thing that really needs to be defined is the map $D:\mathcal{Q}^1\to \mathcal{E}^2$. To do this, we first define a (first-order) operator $\delta: \mathcal{Q}^1\to\Omega^1(M)$, by requiring that $\delta(\phi)$ should be a 1-form representing $\phi$ in the quotient complex and, moreover, that $d\bigl(\delta\phi\bigr)$ should lie in $\mathcal{E}^2$, i.e., that it should be a multiple of $\omega$. (I'll let you write down the formula for $\delta$ in local coordinates.) Then, we just define $D\phi$ to be $d\bigl(\delta\phi\bigr)$. (Sounds almost trivial doesn't it?) The operator $D$ is easily verified to be second order and linear.
Now, the result is that this new complex is locally exact in positive degrees. Thus, the local condition that $\phi\in\mathcal{Q}^1$ be exact is that $D\phi=0$.
You should verify (after you have defined $D$) that this reproduces your condition precisely in the linear case you asked about.