Complex sentence with embedded indirect question. どうしたのか is the interrogative 'what's the matter, what happened' + nominalizer + か. ~かと思う = 'wondered whether X.' The と is the quotative marker framing the internal question as the content of their thought.