A Semiparametric Approach to Hidden Markov Models under Longitudinal Observations