## 2 Materials and Methods
### Statistical Analysis  
For each year, we calculated four control indicators of patients with T2D: Percentage with HbA1c \(<\) 7%; percentage with HbA1c \(\geq\) 9%; percentage with BP \(<\) 140/90 mmHg; percentage with LDL-C below the target. We used the 2012 Navarra \"Primary Health Care Guidelines for Type 2 Diabetes\" currently in force [31]. In patients with T2D without cardiovascular disease, the primary prevention target was LDL-cholesterol \(<\) 100 mg/dL. For patients with T2D and history of CVEs, the target was LDL-C \(<\) 70 mg/dL (secondary prevention) [31]. We analyzed the mean values of each indicator during the years of follow-up. We show the percentage of compliance and the coefficient of variation to identify the variability of the control indicators between GPPs. In addition, using a non-hierarchical K-means cluster analysis, we classified GPPs into two clusters according to the level of compliance. To calculate the probability of a patient meeting an indicator above the five-year follow-up average, we used non-conditional logistic regression. We calculated odds ratios, with 95% confidence intervals, between patients included in the GPP group with the highest level in each indicator versus the lowest group. We adjusted the models for age, sex, low-income status, and a previous CVE. We computed the Charlson comorbidity index, an index that has been validated for CVEs [32, 33, 34].  
Introducing unnecessary control variables into a multivariate model can lead to bias. DAGs (directed acyclic graphs) are a handy tool to avoid this. DAGs allow drawing a theoretical map of the relationships among variables determining what variables should be controlled in a multivariate model, avoiding bias [35]. In a DAG, arrows represent known causal effects. DAGs allow defining what variables should be handled as cofounders. Using DAGitty statistical software [36], we studied the relationship between the exposure cluster of HbA1c \(\geq\) 9% with CVEs and the potential confounding factors sex, age, low income, obesity, smoking, and CVE antecedents (Figure 1).  
The DAG shows that age and income determined where people lived and influenced the health center they were linked to and the GPP they belonged to. GPPs were associated with preventive measures clusters. Age and sex were related to the appearance of CVEs and influenced the antecedents of CVEs, obesity, and current smoking. We observed that the cluster directly affected CVEs and the control measure that affected the outcomes.  
The DAGs also showed the effects of obesity, smoking, and antecedents of CVEs on the incidence of admissions for a CVE (Figures 1 and 2). The DAG software indicated that it was necessary to adjust by sex, age, income, obesity, and current smoking to study the effects of clusters and controls in CVEs (Figure 2).  
Finally, we used Cox regression to estimate the excess risk of admissions for a CVE associated with T2D control and belonging to the GPP cluster with the highest score in the control indicators, adjusted for age, sex, low income, obesity, current smoking, history of a CVE before admission, anti-diabetes, lipid-lowering, and antihypertensive medications.  
Figure 1: Directed acyclic graph (DAG) of the effect of the cluster of HbA\(\mathrm{c1}\geq 9\%\) (exposure) on cardiovascular events (outcome). Ancestors of exposure and outcome, ancestors of outcome, ancestors of exposure, exposure, and outcome. Based on DAGitty version 3.0.  
Figure 2: Adjusted directed acyclic graph (DAG) of the effect of the cluster of HbA\(\mathrm{c1}\geq 9\%\) (exposure) on cardiovascular events (outcome). Adjusted variables, ancestors of exposure, exposure, and outcome. Based on DAGitty version 3.0.