
Search for NHS areas by partial name and time period
Source:R/cvd_api_functions.R
cvd_area_search.RdSearches for NHS areas whose names match a given partial string, within a specified reporting time period. This function uses a case-insensitive "LIKE" search (i.e., matches any area containing the search term) and returns only areas for which data is available in the specified period.
Arguments
- partial_area_name
String (required). The substring to search for within area names (case-insensitive). This may be any part of an area name, e.g., "practice", "PCN", or a specific place.
- time_period_id
Integer (required). The reporting period (time period) to restrict the search to areas with data. use
cvd_time_period_list()to obtain valid IDs.
Value
A tibble containing details of areas matching the search term and having data for the specified time period. Typical columns include:
- AreaCode
Character. Unique code for the NHS area (e.g., "P86619").
- AreaID
Integer. Unique identifier for the NHS area
- AreaName
Character. Name of the NHS area (e.g., "Dr Mb Ghafoor & Partners").
- IsVisible
Logical or character. Indicates whether the area is visible in the API or dashboard ("Y" or "N").
- NationalLevel
Logical or character. Indicates whether the area is included in national-level aggregations ("Y" or "N").
- OdsCode
Character. ODS (Organisation Data Service) code for the area, if available. Often blank.
- SystemLevelID
Integer. Identifier for the system level (5 = GP Practices).
- SystemLevelName
Character. Name of the system level (e.g., "Practice").
- SystemLevelOrder
Integer. Display order for the system level in dashboards or reports.
If no data is found, returns a tibble describing the error.
Details
The search is case-insensitive and matches anywhere in the area name.
Only areas with available data in the chosen time period will be returned.
Use this function to quickly locate AreaIDs or codes for use in other
cvdpreventAPI calls.
Examples
if (FALSE) { # \dontrun{
# Search for areas containing "practice" in their name for time period 17
cvd_area_search(partial_area_name = "practice", time_period_id = 17) |>
dplyr::select(AreaID, AreaName, AreaCode)
# Search for areas containing "PCN" for time period 17
cvd_area_search(partial_area_name = "PCN", time_period_id = 17) |>
dplyr::select(AreaID, AreaName, AreaCode)
} # }