This function queries the ODS Search API.

ods_get_organisations(
  name = as.character(NA),
  post_code = as.character(NA),
  last_change_date = as.Date(NA),
  status = c(NA, "active", "inactive"),
  primary_role_id = as.character(NA),
  non_primary_role_id = as.character(NA),
  org_record_class = as.character(NA)
)

ods_get_trusts(
  name = as.character(NA),
  post_code = as.character(NA),
  last_change_date = as.Date(NA),
  status = c(NA, "active", "inactive"),
  non_primary_role_id = as.character(NA),
  org_record_class = as.character(NA)
)

ods_get_trust_sites(
  name = as.character(NA),
  post_code = as.character(NA),
  last_change_date = as.Date(NA),
  status = c(NA, "active", "inactive"),
  non_primary_role_id = as.character(NA),
  org_record_class = as.character(NA)
)

ods_get_ccgs(
  name = as.character(NA),
  post_code = as.character(NA),
  last_change_date = as.Date(NA),
  status = c(NA, "active", "inactive"),
  non_primary_role_id = as.character(NA),
  org_record_class = as.character(NA)
)

Arguments

name

a character: queries organisations that contain that word in the name of the organisation

post_code

a character: queries organisations based on their postcode. You can search by either the full postcode, or a partial postcode. If you use a partial postcode then it must be at least the Outcode portion of the postcode (e.g. B1, WV10).

last_change_date

a date: queries all organisations that have been changed after that date

status

a character (either active or inactive): searches for organisations based on their status

primary_role_id

a character: queries all organisations that have the specified primary role (see ods_get_roles)

non_primary_role_id

a character: queries all organisations that have the role as a secondary role (see ods_get_roles)

org_record_class

a character: queries all organisations based on their record class TODO: implement a function that queries this API

Value

a tibble of organisations

Details

One or more arguments should be specified, if not it will default (with a warning to using the primary role of "NHS Trust")

Examples

if (FALSE) { # this will default to getting organisations with a primary role of "NHS # TRUST", but it will throw a warning: ods_get_organisations() # you could be more specific and specify that you want to use a primary role # of "NHS TRUST" using the code from ods_get_roles() primary_role_id <- ods_get_roles() %>% filter(displayName == "NHS TRUST") %>% pull(id) ods_get_organisations(primary_role_id = primary_role_id) # or, you could use the specific functions for the primary role id's ods_get_trusts() ods_get_trust_sites() ods_get_ccgs() # you can use as many of the arguments as you like # get current active CCG's ods_get_ccgs(status = "active") # get NHS Trust Sites with "Royal" in their name ods_get_trust_sites(name = "Royal") }