Scandinavian journal of public health
Algorithm for forming hospital care episodes by combining attendance contacts in the Danish National Patient Register: A methodological consensus-driven study
Abstract
Studying complete hospital care episodes from register data, for instance when assessing length of stay, discharges and readmissions, can cause methodological difficulties due to the lack of a contact linkage identifier. We aimed to develop an algorithm combining sequential attendance contacts in the Danish National Patient Register (DNPR) into hospital care episodes, spanning the entire duration and all contacts from hospital arrival to departure.
The algorithm was developed under the consensus of experts from research institutions across Denmark. It reads in second and third version DNPR data, deletes contacts without attendance, duplicates elective outpatient contacts corresponding to attendance dates and modifies contact types (e.g. repeated acute contacts), among others. Thereafter, sequential contacts within 4 h are marked as the same hospital care episode, consisting of one or more DNPR contact. We tested the algorithm in a data set of adults living in Denmark during 2013-2021 and compared different hourly cut-offs.
For the demonstration, we included 120.2 m contacts from 5.7 m persons, combined into 105.9 m hospital care episodes. Of the hospital care episodes, 6.4% were acute inpatients, 8.3% were acute outpatients, 2.0% were elective inpatients and 83.3% were elective outpatients. Using 4 h as our recommendation, 3-h, 5-h and 6-h cut-offs for contact combining revealed only minor differences in the number of hospital care episodes (<0.4%), whereas 12-h (<1.7%) and 24-h cut-offs (<43.1%) had a larger impact.
The algorithm automates data reading, modification and linkage of sequential attendance contacts. The algorithm can be initiated as a SAS macro and is available from an online repository.
Source and rights
Published by Scandinavian journal of public health, 2026. The guideline itself is at the source linked here.
Prognia summarises this guideline for reference and education. It is not medical advice. Always check the official guideline and current local protocols before acting on it.



