\(\text{Ta có: }\hept{\begin{cases}a+b=5\\b+c=-7\end{cases}\Leftrightarrow a+b-b-c=12\Leftrightarrow a-c=12}\)
\(\Leftrightarrow\hept{\begin{cases}a+b=5\\b+c=-7\\a-c=12\end{cases}}\Leftrightarrow\hept{\begin{cases}\left(a+b\right)^2=25\\\left(b+c\right)^2=49\\\left(a-c\right)^2=144\end{cases}}\)
\(\Leftrightarrow2.\left(a^2+b^2+c^2+ab+bc-ac\right)=25+49+144=218\)
\(\Leftrightarrow D=a^2+b^2+c^2+ab+bc-ac=109\)
\(\text{Vậy }D=109\)