The first thing to say, before considering the sentence, is that I would never use 'grammaticality'. It is the kind of word churned out by people stupid enough to believe they can improve on 1,500 years of the English language. All you need to say is: 'I need to check the grammar of the following sentence'.
Anyway, the word I, and most English people, would use would be the subjunctive 'were'. You could use 'was', but it is less elegant. If you used the pluperfect 'had been', it would put the whole thing into the past. You would then need to change the second part of the sentence so it read: 'If I had been a doctor, I would have served the poor'.