health-data-ny-gov/new-york-state-statewide-covid19-hospitalizations-jw46-jpb7
Loading...

Query the Data Delivery Network

Query the DDN

The easiest way to query any data on Splitgraph is via the "Data Delivery Network" (DDN). The DDN is a single endpoint that speaks the PostgreSQL wire protocol. Any Splitgraph user can connect to it at data.splitgraph.com:5432 and query any version of over 40,000 datasets that are hosted or proxied by Splitgraph.

For example, you can query the new_york_state_statewide_covid19_hospitalizations table in this repository, by referencing it like:

"health-data-ny-gov/new-york-state-statewide-covid19-hospitalizations-jw46-jpb7:latest"."new_york_state_statewide_covid19_hospitalizations"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "doh_region", -- Hospital Regional DOH Office
    "patients_age_1_4", -- This field is no longer updated due to changes in HERDS reporting requirements. Currently hospitalized age category 1 to 4 years
    "patients_positive_after", -- How many of the positive COVID-19 patients were confirmed as positive AFTER admission AND since the last report?
    "cumulative_covid_19_fatalities", -- The cumulative number of in-hospital fatalities to date.   The reporting of cumulative in-hospital fatalities are from a patient-specific verified file reported by the hospital and may not match the summary level reporting of Patients Expired.  
    "patients_discharged", -- How many confirmed positive COVID-19 patients have been discharged from the facility since the last report?
    "patients_age_lt1", -- This field is no longer updated due to changes in HERDS reporting requirements. Currently hospitalized age category less than 1 year
    "patients_age_65_74", -- This field is no longer updated due to changes in HERDS reporting requirements. Currently hospitalized age category 65 to 74 years
    "hospitalized_indicator", -- This field is no longer updated due to changes in HERDS reporting requirements. An indicator on if the sum of the age groups equals the number reported as currently hospitalized
    "patients_admitted_due_to_covid", -- How many patients with confirmed COVID were admitted due to COVID or complications of COVID?
    "total_staffed_icu_beds", -- Total Staffed ICU Beds in Hospital.  Data Replaced as of May 19, 2021 by Tot_ICU_New_Beds
    "total_staffed_icu_beds_2", -- Total Staffed ICU Beds Currently Available in Hospital. Data Replaced as of May 19, 2021 by Tot_ICU_New_Occup
    "patients_age_55_64", -- This field is no longer updated due to changes in HERDS reporting requirements. Currently hospitalized age category 55 to 64 years
    "ny_forward_region", -- NY Forward Region in which the facility is located 
    "patients_expired", -- How many confirmed positive COVID-19 patients have expired in the facility since the last report?  Summary level reporting by the facility.  
    "patients_admitted_not_due_to_covid", -- How many patients with confirmed COVID were admitted where COVID was not included as one of the reasons for admission?
    "patients_age_45_54", -- This field is no longer updated due to changes in HERDS reporting requirements. Currently hospitalized age category 45 to 54 years
    "patients_age_75_84", -- This field is no longer updated due to changes in HERDS reporting requirements. Currently hospitalized age category 75 to 84 years
    "total_staffed_beds", -- Total Staffed Beds in Hospital.  Data Replaced as of May 19, 2021 by Tot_Acute_Beds
    "patients_age_20_44", -- This field is no longer updated due to changes in HERDS reporting requirements. Currently hospitalized age category 20 to 44 years
    "patients_age_greater_85", -- This field is no longer updated due to changes in HERDS reporting requirements. Currently hospitalized age category greater than 85 years 
    "facility_name", -- Hospital Name
    "patients_currently_in_icu", -- How many confirmed, positive COVID-19 patients are there in the ICU at this time?
    "total_staffed_acute_care_1", -- How many of those staffed acute care beds are currently occupied?
    "facility_county", -- The NY county that the facility is located within
    "total_staffed_icu_beds_3", -- How many of those staffed ICU beds are currently occupied?
    "total_staffed_acute_care", -- How many staffed acute care beds are currently at your hospital?
    "patients_newly_admitted", -- How many confirmed, positive COVID-19 patients have been newly admitted since the last report?
    "patients_currently_icu", -- This field is no longer updated due to changes in HERDS reporting requirements. Of the confirmed positive COVID-19 patients currently in the ICU, how many are intubated?
    "as_of_date", -- The hospital reporting date through the Health Electronic Response Data System (HERDS) survey
    "patients_age_5_19", -- This field is no longer updated due to changes in HERDS reporting requirements. Currently hospitalized age category 5 to 19 years
    "total_staffed_beds_currently", -- Total Staffed Beds Currently Available in Hospital.  Data Replaced as of May 19, 2021 by Tot_Acute_Occup
    "total_staffed_icu_beds_1", -- How many staffed ICU beds are currently at your hospital?
    "facility_network", -- The network of the facility  
    "total_new_admissions_reported", -- Total New Admissions (Patients Newly Admitted + Patients Positive After Admission)  
    "facility_pfi", -- Facility PFI
    "cumulative_covid_19_discharges", -- Cumulative Discharges
    "patients_currently" -- How many confirmed positive COVID-19 patients does the facility have in either inpatient or observation beds at this time?
FROM
    "health-data-ny-gov/new-york-state-statewide-covid19-hospitalizations-jw46-jpb7:latest"."new_york_state_statewide_covid19_hospitalizations"
LIMIT 100;

Connecting to the DDN is easy. All you need is an existing SQL client that can connect to Postgres. As long as you have a SQL client ready, you'll be able to query health-data-ny-gov/new-york-state-statewide-covid19-hospitalizations-jw46-jpb7 with SQL in under 60 seconds.

Query Your Local Engine

Install Splitgraph Locally
bash -c "$(curl -sL https://github.com/splitgraph/splitgraph/releases/latest/download/install.sh)"
 

Read the installation docs.

Splitgraph Cloud is built around Splitgraph Core (GitHub), which includes a local Splitgraph Engine packaged as a Docker image. Splitgraph Cloud is basically a scaled-up version of that local Engine. When you query the Data Delivery Network or the REST API, we mount the relevant datasets in an Engine on our servers and execute your query on it.

It's possible to run this engine locally. You'll need a Mac, Windows or Linux system to install sgr, and a Docker installation to run the engine. You don't need to know how to actually use Docker; sgrcan manage the image, container and volume for you.

There are a few ways to ingest data into the local engine.

For external repositories, the Splitgraph Engine can "mount" upstream data sources by using sgr mount. This feature is built around Postgres Foreign Data Wrappers (FDW). You can write custom "mount handlers" for any upstream data source. For an example, we blogged about making a custom mount handler for HackerNews stories.

For hosted datasets (like this repository), where the author has pushed Splitgraph Images to the repository, you can "clone" and/or "checkout" the data using sgr cloneand sgr checkout.

Cloning Data

Because health-data-ny-gov/new-york-state-statewide-covid19-hospitalizations-jw46-jpb7:latest is a Splitgraph Image, you can clone the data from Spltgraph Cloud to your local engine, where you can query it like any other Postgres database, using any of your existing tools.

First, install Splitgraph if you haven't already.

Clone the metadata with sgr clone

This will be quick, and does not download the actual data.

sgr clone health-data-ny-gov/new-york-state-statewide-covid19-hospitalizations-jw46-jpb7

Checkout the data

Once you've cloned the data, you need to "checkout" the tag that you want. For example, to checkout the latest tag:

sgr checkout health-data-ny-gov/new-york-state-statewide-covid19-hospitalizations-jw46-jpb7:latest

This will download all the objects for the latest tag of health-data-ny-gov/new-york-state-statewide-covid19-hospitalizations-jw46-jpb7 and load them into the Splitgraph Engine. Depending on your connection speed and the size of the data, you will need to wait for the checkout to complete. Once it's complete, you will be able to query the data like you would any other Postgres database.

Alternatively, use "layered checkout" to avoid downloading all the data

The data in health-data-ny-gov/new-york-state-statewide-covid19-hospitalizations-jw46-jpb7:latest is 0 bytes. If this is too big to download all at once, or perhaps you only need to query a subset of it, you can use a layered checkout.:

sgr checkout --layered health-data-ny-gov/new-york-state-statewide-covid19-hospitalizations-jw46-jpb7:latest

This will not download all the data, but it will create a schema comprised of foreign tables, that you can query as you would any other data. Splitgraph will lazily download the required objects as you query the data. In some cases, this might be faster or more efficient than a regular checkout.

Read the layered querying documentation to learn about when and why you might want to use layered queries.

Query the data with your existing tools

Once you've loaded the data into your local Splitgraph Engine, you can query it with any of your existing tools. As far as they're concerned, health-data-ny-gov/new-york-state-statewide-covid19-hospitalizations-jw46-jpb7 is just another Postgres schema.

Related Documentation:

Loading...