We examine the substitution between primary and secondary care in patients with chronic conditions by using a dynamic structural model for longitudinal count data. By using a hidden Markov chain approach, the model allows for disentangling unobservable time-varying heterogeneity from the dynamic effect of utilisation of primary and secondary care. We also allow unobserved heterogeneity to depend on observable individual characteristics. We find a noticeable substitution effect with an additional primary care visit reducing utilisation of emergency care. Results indicate that the substitution effect decreases with age with diminishing marginal increments, and it is much larger in individuals with a heavy-user profile than in other individuals.