PurposeTo develop algorithms to identify number of lines of anti-neoplastic therapy per patient based on the Danish National Patient Registry (DNPR) and identify which algorithm has the highest percentage agreement with a reference standard of documentation in medical records.Patients and MethodsWe included 179 patients diagnosed between January 1, 2012, and December 31, 2016, with stage II, III, or IV urothelial cell carcinoma or stage III or IV epithelial ovarian cancer, gastric adenocarcinoma, renal cell carcinoma, or non-small cell lung cancer (NSCLC). We developed two algorithms for number of lines of anti-neoplastic therapy based on dates and treatment codes (eg, “treatment with cisplatin” or “cytostatic treatment”) in the DNPR. First, to denote a change in line of therapy the “Time-based algorithm” used the number of days between consecutive administrations. Second, the “Drug-based algorithm” used information on drug names if available or the number of days between consecutive administrations if no drug names were specified. We calculated the percentage agreement between the algorithms setting the number of allowed days between consecutive administrations from 28 to 50 and the reference standard – information on anti-neoplastic therapy drugs abstracted from medical records and subsequently coded according to lines of anti-neoplastic therapy.ResultsFor the “Time-based algorithm”, the highest percentage agreement with the reference standard was found when using <45 days between consecutive administrations (67.6%; 95% CI: 60.1–73.8%). However, the percentage agreement was higher for the “Drug-based algorithm” using <45 days between consecutive administrations for registrations where the drug name was unspecified (90.5%; 95% CI: 85.0–93.7%).ConclusionThe algorithm for number of lines of anti-neoplastic therapy that had the highest percentage agreement with the reference standard (medical records) incorporated both registration of specific drug names and <45 days between consecutive administrations if the drug name was unspecified in routinely recorded data from DNPR.