Using health data that is collected when someone interacts with clinical services can help researchers to better understand depression and its treatment. Most people who are diagnosed with depression are diagnosed by their GP, yet GP data are not readily available for research use across Scotland. We will use DataLoch data to study depression and its treatment across multiple sources of health data. This will include hospital data, data about prescription medications, and importantly GP records. The outputs of the project will be academic papers, as well as data tools (analysis scripts and phenotype definitions) that will be both returned to DataLoch and deposited in open science communities (e.g., HDR UK Phenotype library) to benefit future researchers. This study will result in a better understanding of how depression and its treatment are reflected in electronic health records, including better methods for identifying and treating those with depression.