  Understanding patients' journeys in healthcare system is a fundamental
prepositive task for a broad range of AI-based healthcare applications. This
task aims to learn an informative representation that can comprehensively
encode hidden dependencies among medical events and its inner entities, and
then the use of encoding outputs can greatly benefit the downstream
application-driven tasks. A patient journey is a sequence of electronic health
records (EHRs) over time that is organized at multiple levels: patient, visits
and medical codes. The key challenge of patient journey understanding is to
design an effective encoding mechanism which can properly tackle the
aforementioned multi-level structured patient journey data with temporal
sequential visits and a set of medical codes. This paper proposes a novel
self-attention mechanism that can simultaneously capture the contextual and
temporal relationships hidden in patient journeys. A multi-level self-attention
network (MusaNet) is specifically designed to learn the representations of
patient journeys that is used to be a long sequence of activities. The MusaNet
is trained in end-to-end manner using the training data derived from EHRs. We
evaluated the efficacy of our method on two medical application tasks with
real-world benchmark datasets. The results have demonstrated the proposed
MusaNet produces higher-quality representations than state-of-the-art baseline
methods. The source code is available in https://github.com/xueping/MusaNet.
