Often in follow-up studies intermediate events occur in some patients, such as reinterventions or adverse events. These intermediate events directly affect the shapes of their longitudinal profiles. Our work is motivated by two studies in which such intermediate events have been recorded during follow-up. The first study concerns Congenital Heart Diseased patients who were followed-up echocardiographically, with several patients undergoing reintervention. The second study concerns patients who participated in the SPRINT study and experienced adverse events during follow-up. We are interested in the change of the longitudinal profiles after the occurrence of the intermediate event and in utilizing this information to improve the accuracy of the dynamic prediction for their risk. To achieve this, we propose a flexible joint modeling framework for the longitudinal and survival data that includes the intermediate event as a time-varying binary covariate in both the longitudinal and survival submodels. We consider a set of joint models that postulate different effects of the intermediate event in the longitudinal profile and the risk of the clinical endpoint, with different formulations for their association while allowing its parametrization to change after the occurrence of the intermediate event. Based on these models we derive dynamic predictions of conditional survival probabilities which are adaptive to different scenarios with respect to the occurrence of the intermediate event. We evaluate the accuracy of these predictions with a simulation study using the time-dependent area under the receiver operating characteristic curve and the expected prediction error adjusted to our setting. The results suggest that accounting for the changes in the longitudinal profiles and the instantaneous risk for the clinical endpoint is important, and improves the accuracy of the dynamic predictions.