## 2 Methods  
### Dataset, Integration and Management  
The methodology followed in this work was sequenced in several phases, from the data understanding, data preparation, and generation of the models to the validation and implementation of the models. The data used in this research study corresponds to the city of Jaen, Andalusia, in southern Spain. The scope of the study through the choice of primary care centres in the District of Jaen is due a collaboration agreement that was signed between the University of Jaen and the Jaen Health District. This collaboration included the cession of data of a primary healthcare centre. It covered the number of patients treated each day at primary care centres during the years 2014-2018. In addition to this information, factors that may influence the increase or decrease in the number of people requiring primary care was also considered in the study. Some environmental values recorded in the area during this time for each day were included. All the data have been classified into three groups:  
Season data: date and number of visits to the primary care centres. These data are provided by the health centres in Jaen. Meteorological data: The meteorological data used comes from two weather stations placed in the city of Jaen, Red de Informacion Ambiental de Andalucia (REDIAM) [27]. In order to integrate this information into the database daily mean values were taken for maximum, mean and minimum temperatures, measured in degrees Celsius, humidity and rainfall. Pollution levels: This information was provided by its source with values termed either good or bad, depending on the partial index for each pollutant: sulphide dioxide SO\({}_{2}\), particles, NO\({}_{2}\) nitrogen dioxide, carbon monoxide CO and ozone O\({}_{3}\). These data are available online at REDIAM [27]. All these data were used to create a model for predicting the number of daily requests in primary healthcare. This predictive model was generated from a retrospective study of data from 2014-2017. Data for 2018 was used to validate the resulting model. Methods for determining the validity of regression models include comparing model predictions and coefficients with theory, collecting new data to test model predictions, comparing results with theoretical model estimates, and data splitting or cross-validation, in which part of the data is used to estimate model coefficients and the rest of the data is used to measure the accuracy of the model prediction [28]. In this case, the latter was chosen. In a first analysis, the year 2018 was used for a first validation; however, in order to definitively select the algorithm that best fits the data, a cross validation was carried out with the data from each year. Before starting the procedures for obtaining the predictive model it was necessary to perform a previous analysis to determine data patterns. This allowed us to define the best way to group patients in order to conduct proper integration and management of all of them. In the case of data about the number of visits to health centres during 2014-2017, there was a certain similarity in the distribution of the data based on the time of year, Figure 1. The graph shows a general tendency of the distribution function, very similar from one year to another. Overall, in holiday periods in summer and winter, August and December and January, a clear reduction was detected in the amount of visits to the primary care physician. The number of visits to the doctor was variable from some months to others. Figure 1 shows a very significant difference between the months of August and October. The demand for the first month to the second dropped by 50%. This may be due to the fact that August corresponds with the holiday period. However, other variations that are not so obvious are displayed, for example in 2017, there was a difference of 9.2% between October and November. In other years the number of patients during these two months was very similar and yet in 2017 was very different.