Predicting the health risks of patients based on electronic health records (EHRs) has recently attracted considerable research interest. Health risk refers to the probability of the occurrence of a specific health outcome for a specific patient. The predicted risks of a specific health outcome can be used to support decisions by healthcare professionals. Various predictive models have been developed. Compared with traditional machine learning models, deep learning-based models have achieved more promising performance. However, due to the lack of transparency, the acceptance of deep learning-based models are often limited. This paper proposes a Stacked Attention-based Network, SANet, for accurate and interpretable health risk prediction. Two novel attention-based modules, named Convolutional Attention Module and Sequential Attention Module respectively, are designed to capture patient-specific contextual information at both feature and sequence levels. Particularly, Sequential Attention Module can flexibly learn the impact of the time interval between sequential visits and significantly enhance the interpretability and robustness of learning outcomes from sequences. Experimental results on two real-world EHR datasets demonstrate the superior predictive accuracy of our method, as well as interpretability and robustness, compared to existing state-of-the-art methods. The findings extracted by this approach are also empirically confirmed by relevant literature and medical experts.