Skip to contents

Build a Query for an Endpoint

Usage

build(obj, qry)

Arguments

obj

An <endpoint>, <collection> or <group> object.

qry

A <query> object.

Value

A list of query parameters matched to an endpoint's fields.

Examples

build(
  endpoint("drug_state"),
  query(
    year = 2022:2024,
    state = any_of(c("GA", "NY"))))
#> <class_results>
#>  @ alias : chr "drug_state"
#>  @ title : chr "State Drug Utilization Data"
#>  @ params: chr "state"
#>  @ base  :List of 3
#>  .. $ 2024: chr "https://data.medicaid.gov/api/1/datastore/query/61729e5a-7aa8-448c-8903-ba3e0cd0ea3c/0?count=true&results=true&"| __truncated__
#>  .. $ 2023: chr "https://data.medicaid.gov/api/1/datastore/query/d890d3a9-6b00-43fd-8b31-fcba4c8e2909/0?count=true&results=true&"| __truncated__
#>  .. $ 2022: chr "https://data.medicaid.gov/api/1/datastore/query/200c2cba-e58d-4a95-aa60-14b99736808d/0?count=true&results=true&"| __truncated__
#>  @ limit : int 8000
#>  @ found : int [1:3] 262185 286759 324621
#>  @ total : int 5205065
#>  @ pages : int [1:3] 33 36 41
#>  @ error : logi [1:3] FALSE FALSE FALSE

build(endpoint("enroll_prov"),
      query(first_name = starts_with("And"),
      last_name = ends_with("ce")))
#> <class_results>
#>  @ alias : chr "enroll_prov"
#>  @ title : chr "Medicare Fee-For-Service Public Provider Enrollment"
#>  @ params: chr [1:2] "FIRST_NAME" "LAST_NAME"
#>  @ base  : chr "https://data.cms.gov/data-api/v1/dataset/2457ea29-fc82-48b0-86ec-3b0755de7515/data-viewer/stats?offset=0&size=1"| __truncated__
#>  @ limit : int 5000
#>  @ found : int 127
#>  @ total : int 2894910
#>  @ pages : int 127
#>  @ error : logi FALSE

build(endpoint("dial_facility"), query(city = "BIRMINGHAM"))
#> <class_results>
#>  @ alias : chr "dial_facility"
#>  @ title : chr "Medicare Dialysis Facilities"
#>  @ params: chr "city"
#>  @ base  :List of 6
#>  .. $ 2025: chr "https://data.cms.gov/data-api/v1/dataset/7d4e7bd1-f08a-4fca-8085-6af24026a19a/data/stats?offset=0&size=1&filter"| __truncated__
#>  .. $ 2024: chr "https://data.cms.gov/data-api/v1/dataset/62d125ff-c959-4c5c-8a46-8cacba50bfd4/data/stats?offset=0&size=1&filter"| __truncated__
#>  .. $ 2023: chr "https://data.cms.gov/data-api/v1/dataset/200e7e7e-a5a6-4450-ba18-ab53d237cc45/data/stats?offset=0&size=1&filter"| __truncated__
#>  .. $ 2022: chr "https://data.cms.gov/data-api/v1/dataset/ebc64ad1-164c-455a-80ca-cb0753e44a46/data/stats?offset=0&size=1&filter"| __truncated__
#>  .. $ 2021: chr "https://data.cms.gov/data-api/v1/dataset/e66eaf03-398f-4a8c-9d1b-6aaf25fb6425/data/stats?offset=0&size=1&filter"| __truncated__
#>  .. $ 2020: chr "https://data.cms.gov/data-api/v1/dataset/44aedde0-c535-497d-ab27-b415ec12ff5a/data/stats?offset=0&size=1&filter"| __truncated__
#>  @ limit : int 5000
#>  @ found : int [1:6] 31842 30949 31397 29704 9701304 9289559
#>  @ total : int [1:6] 11985275 11679243 11716732 10821385 9701304 9289559
#>  @ pages : int [1:6] 7 7 7 6 1941 1858
#>  @ error : logi [1:6] FALSE FALSE FALSE FALSE TRUE TRUE

build(collection("dialysis"), query(state = "AL"))
#> ! No query matches for dial_nation
#> $dial_listing
#> <class_results>
#>  @ alias : chr "dial_listing"
#>  @ title : chr "Dialysis Facility - Listing by Facility"
#>  @ params: chr "state"
#>  @ base  : chr "https://data.cms.gov/provider-data/api/1/datastore/query/23ew-n7w9/0?count=true&results=true&offset=0&limit=1&c"| __truncated__
#>  @ limit : int 1500
#>  @ found : int 178
#>  @ total : int 7561
#>  @ pages : int 178
#>  @ error : logi FALSE
#> 
#> $dial_nation
#> <class_results>
#>  @ alias : chr "dial_nation"
#>  @ title : chr "Dialysis Facility - National Averages"
#>  @ params: NULL
#>  @ base  : chr "https://data.cms.gov/provider-data/api/1/datastore/query/2rkq-ygai/0"
#>  @ limit : int 1500
#>  @ found : int 0
#>  @ total : int 1
#>  @ pages : int 0
#>  @ error : NULL
#> 
#> $dial_state
#> <class_results>
#>  @ alias : chr "dial_state"
#>  @ title : chr "Dialysis Facility - State Averages"
#>  @ params: chr "state"
#>  @ base  : chr "https://data.cms.gov/provider-data/api/1/datastore/query/2fpu-cgbb/0?count=true&results=true&offset=0&limit=1&c"| __truncated__
#>  @ limit : int 1500
#>  @ found : int 1
#>  @ total : int 56
#>  @ pages : int 1
#>  @ error : logi FALSE
#> 

build(
  endpoint("quality_payment"),
  query(
    year = 2021:2023,
    practice_state_or_us_territory = any_of(c("GA", "FL")),
    allowed_charges = less_than(10000)))
#> <class_results>
#>  @ alias : chr "quality_payment"
#>  @ title : chr "Quality Payment Program Experience"
#>  @ params: chr [1:2] "allowed charges" "practice state or us territory"
#>  @ base  :List of 3
#>  .. $ 2023: chr "https://data.cms.gov/data-api/v1/dataset/3545dc8e-7037-41ee-8a1d-9f3198fe4927/data/stats?offset=0&size=1&filter"| __truncated__
#>  .. $ 2022: chr "https://data.cms.gov/data-api/v1/dataset/b3438273-b4a6-44ca-8fb2-9e6026b74642/data/stats?offset=0&size=1&filter"| __truncated__
#>  .. $ 2021: chr "https://data.cms.gov/data-api/v1/dataset/8c2ab3e4-597e-43c9-9d94-7223c66d7f25/data/stats?offset=0&size=1&filter"| __truncated__
#>  @ limit : int 5000
#>  @ found : int [1:3] 0 0 10
#>  @ total : int [1:3] 524998 624200 698730
#>  @ pages : int [1:3] 0 0 10
#>  @ error : logi [1:3] FALSE FALSE FALSE

build(
  endpoint("pdc_clinician"),
  query(
    provider_first_name = starts_with("An"),
    provider_last_name = contains("J"),
    state = any_of(c("CA", "GA", "NY"))))
#> <class_results>
#>  @ alias : chr "pdc_clinician"
#>  @ title : chr "National Downloadable File"
#>  @ params: chr [1:3] "provider_first_name" "provider_last_name" "state"
#>  @ base  : chr "https://data.cms.gov/provider-data/api/1/datastore/query/mj5m-pzi6/0?count=true&results=true&offset=0&limit=1&c"| __truncated__
#>  @ limit : int 1500
#>  @ found : int 486
#>  @ total : int 2750892
#>  @ pages : int 486
#>  @ error : logi FALSE