The correct option is
C QPRS
The proper sequence is QPRS. Let us see why.
The sentence starts with, 'The doctor', which is the subject. The clause (Q), i.e 'who was very competent in his profession' describes the subject. Hence, it has to immediately follow the subject. Hence, the first part of the sentence is: 'The doctor, who was very competent in his profession'.
The first part of the sentence has to be followed by the verb. The answer to the question, 'What did the doctor do'? is given in part (P) i.e 'did not like the behaviour of the patients'. Hence, (P) follows (Q).
Why/when did the doctor not like the behaviour of the patients? The answer to this question is in the phrase (R) 'when they talked at length'. So, (R) follows (P).
The final part left is (S) i.e 'about their problems'. This phrase answers the question, "What did the patients talk about?'. Hence, (S) follows (P).
So, the correct sentence is: 'The doctor, (Q) who was very competent in his profession, (P) did not like the behaviour of the patients (R) when they talked at length (S) about their problems'.
Hence, option C i.e QPRS is correct and the other options A, B and D are incorrect.