ny-gov/act-admission-to-discharge-outcomes-5-year-window-fs34-eajg
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 act_admission_to_discharge_outcomes_5_year_window table in this repository, by referencing it like:

"ny-gov/act-admission-to-discharge-outcomes-5-year-window-fs34-eajg:latest"."act_admission_to_discharge_outcomes_5_year_window"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "denominator", -- Number of individuals discharged from ACT for aggregation groups above.
    "aot_status_at_admission", -- Aggregation level: AOT court order status at admission (On AOT, Not On AOT, All)
    "living_situation_unstably", -- Number of Individuals discharged from ACT who were unstably housed (moving around with no stable permanent home) at admission
    "substance_use_disorder_at", -- Number of Individuals discharged from ACT who had a substance use disorder at admission
    "discharge_year", -- Aggregation level:  Year of discharge from ACT 
    "region_name", -- Aggregation level: New York State or Name of the OMH region (i.e. Central New York, Hudson River, Long Island, New York City, and Western New York) 
    "living_situation_unstably_1", -- Number of Individuals discharged from ACT who were unstably housed (moving around with no stable permanent home) at discharge
    "living_situation_homeless_1", -- Number of Individuals discharged from ACT who were homeless (e.g., in a homeless shelter or on the street) at discharge
    "employed_at_admission", -- Number of Individuals discharged from ACT who were employed at admission
    "psychiatric_hospitalization_1", -- Number of Individuals discharged from ACT who had any psychiatric hospitalization in the past 6 months at discharge
    "property_damage_at_discharge", -- Number of Individuals discharged from ACT who had damaged or destroyed property or created a public disturbance in the past six months at discharge  
    "harm_to_others_at_admission", -- Number of Individuals discharged from ACT who had expressed homicidal ideation, were suspected of sexual abuse, physically abused and/or assaulted others, threatened physical violence to others, verbally assaulted others, or engaged in arson in the past six months at admission
    "harm_to_self_at_discharge", -- Number of Individuals discharged from ACT who had attempted suicide, engaged in self-injurious behavior, or expressed suicidal ideation in the past six months at discharge
    "harm_to_self_at_admission", -- Number of Individuals discharged from ACT who had attempted suicide, engaged in self-injurious behavior, or expressed suicidal ideation in the past six months at admission
    "forensic_involvement_at_1", -- Number of Individuals discharged from ACT who were arrested or incarcerated in the past six months or were currently involved with the criminal justice system (e.g., on probation or parole) at discharge
    "forensic_involvement_at", -- Number of Individuals discharged from ACT who were arrested or incarcerated in the past six months or were currently involved with the criminal justice system (e.g., on probation or parole) at admission
    "active_aot_status_at_discharge", -- Number of Individuals discharged from ACT who had an active AOT status at discharge
    "active_aot_status_at_admission", -- Number of Individuals discharged from ACT who had an active AOT status at admission
    "homeless_at_discharge", -- Number of Individuals discharged from ACT who were currently homeless or had any days of homelessness in the past six months at discharge
    "homeless_at_admission", -- Number of Individuals discharged from ACT who were currently homeless or had any days of homelessness in the past six months at admission 
    "any_substance_use_at_discharge", -- Number of Individuals discharged from ACT who had any alcohol or drug use in the past six months at discharge Note: Drugs include Cocaine, Cannabis, Amphetamines, Cracks, Inhalants, Opiates, etc.  
    "any_substance_use_at_admission", -- Number of Individuals discharged from ACT who had any alcohol or drug use in the past six months at admission Note: Drugs include Cocaine, Cannabis, Amphetamines, Cracks, Inhalants, Opiates, etc.  
    "psychiatric_er_visit_at_1", -- Number of Individuals discharged from ACT who had any psychiatric ER visit in the past 6 months at discharge
    "psychiatric_er_visit_at", -- Number of Individuals discharged from ACT who had any psychiatric ER visit in the past 6 months at admission
    "psychiatric_hospitalization", -- Number of Individuals discharged from ACT who had any psychiatric hospitalization in the past 6 months at admission 
    "employed_at_discharge", -- Number of Individuals discharged from ACT who were employed at discharge
    "education_enrollment_at_1", -- Number of Individuals discharged from ACT who were enrolled in education/training at discharge
    "education_enrollment_at", -- Number of Individuals discharged from ACT who were enrolled in education/training at admission
    "living_situation_homeless", -- Number of Individuals discharged from ACT who were homeless (e.g., in a homeless shelter or on the street) at admission
    "living_situation_institution_1", -- Number of Individuals discharged from ACT who lived in an institution such as a hospital or prison at discharge
    "living_situation_institution", -- Number of Individuals discharged from ACT who lived in an institution such as a hospital or prison at admission
    "living_situation_supported_1", -- Number of Individuals discharged from ACT who lived in supportive housing (any permanent or temporary housing program with supports) at discharge
    "living_situation_supported", -- Number of Individuals discharged from ACT who lived in supportive housing (any permanent or temporary housing program with supports) at admission
    "living_situation_private_1", -- Number of Individuals discharged from ACT who lived in private residence (apartment or house) at discharge
    "living_situation_private", -- Number of Individuals discharged from ACT who lived in private residence (apartment or house) at admission
    "mental_health_diagnosis", -- Aggregation level: Mental Health Diagnosis at admission, including Schizophrenia, Bipolar Disorder, Depression, Other, Unknown, All.  Note:  If there is no row for a given aggregation level it means that there are no participants in that group.  For example, there are no participants discharged in 2014 in the Central NY Region who were on AOT at admission and had a diagnosis of Depression at admission.
    "date_created", -- Date and Time the dataset was created
    "property_damage_at_admission", -- Number of Individuals discharged from ACT who had damaged or destroyed property or created a public disturbance in the past six months at admission  
    "harm_to_others_at_discharge", -- Number of Individuals discharged from ACT who had expressed homicidal ideation, were suspected of sexual abuse, physically abused and/or assaulted others, threatened physical violence to others, verbally assaulted others, or engaged in arson in the past six months at discharge
    "substance_use_disorder_at_1" -- Number of Individuals discharged from ACT who had a substance use disorder at discharge
FROM
    "ny-gov/act-admission-to-discharge-outcomes-5-year-window-fs34-eajg:latest"."act_admission_to_discharge_outcomes_5_year_window"
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 ny-gov/act-admission-to-discharge-outcomes-5-year-window-fs34-eajg 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 ny-gov/act-admission-to-discharge-outcomes-5-year-window-fs34-eajg: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 ny-gov/act-admission-to-discharge-outcomes-5-year-window-fs34-eajg

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 ny-gov/act-admission-to-discharge-outcomes-5-year-window-fs34-eajg:latest

This will download all the objects for the latest tag of ny-gov/act-admission-to-discharge-outcomes-5-year-window-fs34-eajg 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 ny-gov/act-admission-to-discharge-outcomes-5-year-window-fs34-eajg: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 ny-gov/act-admission-to-discharge-outcomes-5-year-window-fs34-eajg: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, ny-gov/act-admission-to-discharge-outcomes-5-year-window-fs34-eajg is just another Postgres schema.

Related Documentation:

Loading...