Po nějaký čas Cimrman vykonával funkci porodní dědek.
The main verb is "vykonával" 3sg. past tense form of vykonávat 'to perform.'
The subject is the nominative. There are theoretically two candicates for the subject: Cimrman and porodní dědek. But if we decided that porodní dědek is the subject, the sentence would not be complete in meaning ("the midhusband was performing the/a function" (what function?)); worse still, Cimrman would be left dangling in the sentence. The best solution would be to consider Cirmman as the subject and porodní dědek as specifying the direct object "funkce," thereby conveying a meaning "the function OF midhusband." Porodní dědek therefore should be in the genitive case.
The prepositon "po" in combination with the imperfective verb "vykonávat" should be interpreted as "all throughout the period"; in this meaning, this preposition takes the accusative case; the form "nějaký čas" is therefore correct.