Query the Data Delivery Network
Query the DDNThe 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 professional_medical_billing_services_sv1_detail
table in this repository, by referencing it like:
"texas-gov/professional-medical-billing-services-sv1-detail-7au4-j7bg:latest"."professional_medical_billing_services_sv1_detail"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"service_adjustment_amount_3", -- DN# 733 - The dollar amount of the fourth adjustment paid or credited to the line item.
"bill_id", -- Bill ID uniquely identifies a bill and links line items to the bill.
"service_adjustment_group_2", -- DN# 731 - A code indicating the general category of the third adjustment made to the dollar amount paid or credited to the line item.
"fourth_diagnosis_pointer", -- DN# 557 - References the diagnosis code (ICD-9 CM or ICD-10 CM) for which the medical services were rendered.
"service_adjustment_group_4", -- DN# 731 - A code indicating the general category of the fifth adjustment made to the dollar amount paid or credited to the line item.
"days_units_code", -- DN# 553 - Indicates the time or units billed or paid. DA = Days MJ = Minutes UN = Unit
"provider_agreement_line_code", -- DN# 42 - Indicates the type of provider agreement applicable to the line item. H = Network N = No Agreement P = Participation Agreement Y = PPO Agreement
"service_adjustment_reason_4", -- DN# 732 - A code indicating the detailed reason of the fifth adjustment made to the dollar amount paid or credited to the line item.
"service_adjustment_amount_4", -- DN# 733 - The dollar amount of the fifth adjustment paid or credited to the line item.
"fourth_hcpcs_modifier_paid", -- DN# 727 - The fourth two-character code identifying special circumstances related to the procedure paid.
"third_hcpcs_modifier_paid", -- DN# 727 - The third two-character code identifying special circumstances related to the procedure paid.
"service_adjustment_units_4", -- DN# 734 - The number of units applicable to the fifth adjustment to the line item.
"rendering_line_provider", -- DN# 592 - The unique National Provider ID of the rendering line provider.
"number_of_service_adjustments", -- The number of service adjustments for the line item.
"days_units_paid", -- DN# 580 - The number of services paid for the line item in days or units.
"service_adjustment_group", -- DN# 731 - A code indicating the general category of the first adjustment made to the dollar amount paid or credited to the line item. CO = Contractual Obligations OA = Other Adjustments PI = Payer initiated reductions PR = Patient Responsibility
"second_hcpcs_modifier_paid", -- DN# 727 - The second two-character code identifying special circumstances related to the procedure paid.
"first_hcpcs_modifier_paid", -- DN# 727 - The first two-character code identifying special circumstances related to the procedure paid.
"service_adjustment_reason", -- DN# 732 - A code indicating the detailed reason of the first adjustment made to the dollar amount paid or credited to the line item.
"hcpcs_line_procedure_paid", -- DN# 726 - Identifies the treatment that was rendered and paid.
"total_amount_paid_per_line", -- DN# 574 - The total dollar amount paid or credited to the line item.
"treatment_line_authorization", -- DN# 738 - Defaults to the Treatment Authorization Number (DN581 at the bill level) unless a data element is transmitted in this field. Y = reported, N = not reported.
"service_line_to_date", -- DN# 605 - The ending date that services were performed for the line item.
"service_line_from_date", -- DN# 605 - The starting date that services were performed for the line item.
"service_adjustment_amount", -- DN# 733 - The dollar amount of the first adjustment paid or credited to the line item.
"second_diagnosis_pointer", -- DN# 557 - References the diagnosis code (ICD-9 CM or ICD-10 CM) for which the medical services were rendered.
"first_diagnosis_pointer", -- DN# 557 - References the diagnosis code (ICD-9 CM or ICD-10 CM) for which the medical services were rendered.
"days_units_billed", -- DN# 554 - The number of services billed for the line item in days or units.
"total_charge_per_line", -- DN# 552 - The service charge amount for the line item.
"procedure_description", -- DN# 551 - Free form text describing the treatment rendered.
"fourth_hcpcs_modifier_billed", -- DN# 717 - The fourth two-character code identifying special circumstances related to the procedure billed.
"third_hcpcs_modifier_billed", -- DN# 717 - The third two-character code identifying special circumstances related to the procedure billed.
"service_adjustment_group_1", -- DN# 731 - A code indicating the general category of the second adjustment made to the dollar amount paid or credited to the line item.
"second_hcpcs_modifier_billed", -- DN# 717 - The second two-character code identifying special circumstances related to the procedure billed.
"first_hcpcs_modifier_billed", -- DN# 717 - The first two-character code identifying special circumstances related to the procedure billed.
"service_adjustment_units_1", -- DN# 734 - The number of units applicable to the second adjustment to the line item.
"hcpcs_line_procedure_billed", -- DN# 714 - Identifies the treatment that was rendered and billed. HCPCS is the abbreviation for Health Care Financing Administration's Common Procedure Coding System. HCPCS codes include Level 1 CPT procedure codes.
"bill_selection_date", -- Bill Selection Date is a date field common to bill and bill line item records. It is usually the earliest date of service on a bill.
"service_adjustment_units", -- DN# 734 - The number of units applicable to the first adjustment to the line item.
"crna_supervision_indicator", -- DN# 568 - Flags that a Certified Registered Nurse Anesthetist (CRNA) was supervised. Y = Yes, N = No
"service_adjustment_amount_2", -- DN# 733 - The dollar amount of the third adjustment paid or credited to the line item.
"third_diagnosis_pointer", -- DN# 557 - References the diagnosis code (ICD-9 CM or ICD-10 CM) for which the medical services were rendered.
"line_number", -- The number of the line item on the bill.
"service_adjustment_units_2", -- DN# 734 - The number of units applicable to the third adjustment to the line item.
"contract_line_type_code", -- DN# 741 - A two-character code indicating the line item contractual arrangement for provider reimbursement. 01 = Diagnosis Related Group 02 = Per Diem 03 = Variable Per Diem 04 = Flat 05 = Capitate 06 = Percent 09 = Other
"service_adjustment_amount_1", -- DN# 733 - The dollar amount of the second adjustment paid or credited to the line item.
"service_adjustment_group_3", -- DN# 731 - A code indicating the general category of the fourth adjustment made to the dollar amount paid or credited to the line item.
"service_adjustment_reason_2", -- DN# 732 - A code indicating the detailed reason of the third adjustment made to the dollar amount paid or credited to the line item.
"service_adjustment_reason_1", -- DN# 732 - A code indicating the detailed reason of the second adjustment made to the dollar amount paid or credited to the line item.
"service_adjustment_reason_3", -- DN# 732 - A code indicating the detailed reason of the fourth adjustment made to the dollar amount paid or credited to the line item.
"place_of_service_line_code", -- DN# 600 - Identifies the place where the medical service was rendered. Examples: 21 = Inpatient Hospital 56 = Psychiatric Residential Treatment Center 72 = Rural Health Clinic
"bill_detail_id", -- Bill Detail ID uniquely identifies a bill line item.
"service_adjustment_units_3" -- DN# 734 - The number of units applicable to the fourth adjustment to the line item.
FROM
"texas-gov/professional-medical-billing-services-sv1-detail-7au4-j7bg:latest"."professional_medical_billing_services_sv1_detail"
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 texas-gov/professional-medical-billing-services-sv1-detail-7au4-j7bg
with SQL in under 60 seconds.
Query Your Local Engine
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; sgr
can 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 clone
and sgr checkout
.
Cloning Data
Because texas-gov/professional-medical-billing-services-sv1-detail-7au4-j7bg: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 texas-gov/professional-medical-billing-services-sv1-detail-7au4-j7bg
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 texas-gov/professional-medical-billing-services-sv1-detail-7au4-j7bg:latest
This will download all the objects for the latest
tag of texas-gov/professional-medical-billing-services-sv1-detail-7au4-j7bg
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 texas-gov/professional-medical-billing-services-sv1-detail-7au4-j7bg: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 texas-gov/professional-medical-billing-services-sv1-detail-7au4-j7bg: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, texas-gov/professional-medical-billing-services-sv1-detail-7au4-j7bg
is just another Postgres schema.