Package: esneft-tools
ESNEFT Analysis - Diabetes InequalitiesTable of contentsInstallationSetupRetrieve DataDownloadProcessAggregate By Practice LevelAggregate By LSOA LevelVisualisePractice MapLSOA MapFurther DocumentationContributingLicenseContactInstallationInstallation is possible viapipas shown below.Unix/macOSpython3-mpipinstallesneft_toolsWindowspy-mpipinstallesneft_toolsInstall within a Virtual Environment (optional)Unix/macOSpython-mvenvesneft_toolssourceesneft_tools/bin/activate
python3-mpipinstallesneft_toolsWindowspy-mvenvesneft_tools
esneft_tools/Scripts/Activate.ps1
py-mpipinstallesneft_toolsIf running scripts is disabled on your system then run the following command before activating your environment.Set-ExecutionPolicy-ExecutionPolicyRemoteSigned-ScopeCurrentUserGeospatial Dependencies (optional)Additional geospatial utilities may be optionally installed as below.
Note these packages have non-trivial dependencies and automatic installation may not work on all systems.An additional optional dependency, OSMnx, must be installed by the user.
Please refer to theOSMnx documentationfor further installation instructions.Clear here for codeUnix/macOSpython3-mpipinstallesneft_tools[geo]Windowspy-mpipinstallesneft_tools[geo]SetupThe logging level ofesneft_toolscan be set via thesetVerbosity()function.importloggingfromesneft_tools.utilsimportsetVerbosityfromesneft_toolsimportdownload,process,visualisesetVerbosity(logging.INFO)Retrieve Public DataDownloadFrom HostEach of theesneft_tools.download.getData().fromHost()functions retrieve a static copy of a particular data set from GitHub.
A local copy of these tables is saved to./.data-cache/by default.
Each can be obtained individually but it is recommended to retrieve all data, as below.# Instantiate data download class.getData=download.getData(cache='./.data-cache')# Retrieve all data as dictionary (recommended)data=getData.fromHost('all')all(default)Retrieve all of the below data in dictionary format (recommended).postcodeLSOAPostcode -> LSOA (2011) lookup Table fromArcGISimdLSOAIndices of Deprivation by LSOA in England fromNational Statistics (.gov.uk)populationLSOALSOA population estimates, by age and sex, fromONSethnicityLSOAProportion of ethnicity minorities (non-white) by LSOA fromNOMISareaLSOALand hectare measures by LSOA fromArcGISgpRegistrationGP registration by LSOANHS DigitalgpPracticeGP Practice information fromNHS DigitalgpStaffGPs by GP Practices fromNHS DigitalqofQuality and Outcomes Framework, 2021-22 fromNHS DigitalgeoLSOALSOA GeoJSON fromUK Data ServiceesneftLSOAList of LSOAs within ESNEFT trust.esneftOSMOpenStreetMap (OSM) data for ESNEFT area fromGeofabrikFrom SourceAlternatively, the.fromSource()method can be used to retrieve each dataset directly from its public source.
By default,esneft_toolswill retrieve the source data that matches thefromHost()methods.
Each source URL can be updated to newer versions by providing a YAML file todownload.getData()as shown below.
An example of the YAML file is shownhere.Clear here for code# Instantiate data download class.getData=download.getData(sourceURL='sourceURL.yaml',cache='./.data-cache')# Retrieve a specific dataset from host.# Note: "all" does not work with .fromSource().imdLSOA=getData.fromSource('imdLSOA')ProcessingAggregate by Practice LevelThegetGPsummaryfunction aggregates the downloaded data to practice level statistics.GPsummary=process.getGPsummary(**data,iod_cols='IMD')FieldDescriptionOrganisationCodePractice Service CodeIMDMean Index of Multiple Deprivation of Registered PatientsPatientTotal Registered PatientsQOF-DMQOF achievement for Diabetes mellitus (max 76)DM-prevalancePrevalence of Diabetes mellitusPCDSPostcodeOpenDateOpening DateCloseDateClosing DateStatusService Status (e.g. Active)PrescribingSettingService Type (e.g. GP Practice)currentStaffCurrent PractitionersdepartedStaffTotal Departed PractitionersmeanStaffAverage Working PractitionersannualStaffTurnoverMean Annual % Practitioner TurnoverLatLatitude of SiteLongLongitude of SitepatientPerGPTotal Registered Patient per Average Practitioner CountESNEFTBoolean Flag of Practices within ESNEFTNodeClosest OSM Map Node to SiteAggregate by LSOA LevelThegetLSOAsummaryfunction aggregates the downloaded data LSOA level statistics.LSOAsummary=process.getLSOAsummary(**data,iod_cols='IMD')FieldDescriptionLSOA11CDLSOA (2011) CodeLSOA11NMLSOA (2011) NameAge (median)Median Age of PopulationPopulationPopulation Estimate (2011 Census)LandHectareLand Area (Hectares)PatientTotal Registered GP PatientsIMDIndex of Multiple DeprivationIMD (q5)Index of Multiple Deprivation (quintiles)DM-prevalancePrevalence of Diabetes mellitusDensityPopulation DensityESNEFTBoolean Flag of LSOAs within ESNEFTVisualisePractice Mapfig=visualise.scatterGP(GPsummary[GPsummary['Status']=='Active'],minCount=250)Map of Practice Distributions within ESNEFT (Plotly Interactive)LSOA Mapfig=visualise.choroplethLSOA(LSOAsummary,data['geoLSOA'],colour='IMD')Choropleth Map of LSOA Domains within ESNEFT coloured by IMD (Plotly Interactive)Further DocumentationRefer to theadditional documentationfor further examples of functionality.ContributingContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make aregreatly appreciated.Fork the ProjectCreate your Feature Branch (git checkout -b feature/AmazingFeature)Commit your Changes (git commit -m 'Add some AmazingFeature')Push to the Branch (git push origin feature/AmazingFeature)Open a Pull RequestSeeCONTRIBUTING.mdfor detailed guidance.LicenseDistributed under the MIT License.SeeLICENSEfor more information.ContactIf you have any other questions please contact the author,Stephen Richer.