careVisit

Query to specify visit-based query parameters to return line-item level patient journey data for healthcare visits.

We define a visit as group of encounters within the same event of of care.

Get Started with careVisit

If you have already setup CareQuery, run the below code to get started with your first careVisit query.

Quick Example:

🔍

Behavioral/mental health visits in Duluth, MN within the first 8 months of 2023.


# 1) import 
from care_query.care_query import CareQuery

# 2) instantiate and connect
cq = CareQuery(email = "your-email", 
               token = "your-api-token",
               sftp_key = "path/to/your/company.PEM")

# 3) build query
query_name = cq.careVisit(proc_subcategory = ['medicine - adaptive behavior services', 
                                         'medicine - health and behavior assessment/intervention',
                                         'eval. and mgmt. - psychiatric collaborative care management services', 
                                         'medicine - psychiatry'],
                     metro = ['duluth, mn-wi'],
                     min_date = "2023-01-01",
                     max_date = "2023-08-01",
                     alias = "bh_duluth_2023", # optional argument to add sftp_path prefix 
                     limit = 10000) # False returns all rows

# 4) submit query, data will return to SFTP endpoint
		# could also run .sample() to return the first 1k rows  or .execute() to get a size estimate
result_object = query_name.execute()

# 5) check query status
	# user will be sent an email upon submission and completion, check query status along the way
	# token and query_id can be left empty if within the same session as the query submission
  # if you want to get the status of a query outside of the session that submitted the query, submit your user token, and the query_id that you can find in your email.
query_name.queryStatus(token = token, query_id = query_id)

# 6) upon successful completion of query, read data directly into pandas environment
result_data = query_name.sftpToPandas()

Query Parameters

The following a parameters are available within the careVisit query, including details on the parameter values.

parameterdescriptionoptions
aliasString value for users to give a descriptive name to the data object written to each customer's CareQuery SFTP location.String
min_dateLower threshold date within the date range
of interest, observational start date
Date String
max_dateUpper threshold date within the date range
of interest, observational end date
Date String
genderPatient gender within the population of interestM,F or ['M','F']
age_minMinimum patient age identified within the population of interest0 to 120
age_maxMaximum patient age identified within the population of interest0 to 120
visit_typeDescription of the setting of carevalues available
payor_channelHealth Insurance Payor channel-of-business or line-of-businessvalues available
revenue_center_code4-digit code used to identify a specific accommodation,
ancillary service, or billing calculation on a hospital bill
values available
place_of_serviceSetting in which a healthcare service was provided by healthcare providers, insurers, and government agencies to track and bill for healthcare servicesvalues available
diag_codeICD-10 diagnosis code given to the patient within the encountervalues available
diag_categoryCategory of the ICD-10 diagnosis code
given to the patient within the encounter
values available
diag_subcategorySub-category of the ICD-10 diagnosis
code given to patient within the encounter
values available
short_diag_codeFirst three digits of the ICD-10 diagnosis
code given to the patient within the encounter
values available
diag_numTotal number of diagnoses code columns returned to the user in addition to the diagnoses list. Defaults to top 5 diagnosis codes.Any number from 0 to 25
diag_greedyBoolean indicator for 'AND' or 'OR' when multiple
diagnosis parameters specified - helps users offer various
levels of specificity without confusing and/or logic
True or False
drg_codeDiagnosis Related Group code(s) categorizes case-mix complexity and diagnoses to calculate hospital costs and reimbursement rates values available
drg_categoryDiagnosis Related Group category or categories in order to further group DRGs by service line or clinical arena values available
proc_codeCPT or HCPCS procedural code performed within the encountervalues available
proc_categoryCategory of the CPT or HCPCS
procedure performed within the encounter
values available
proc_subcategorySub-category of the CPT or HCPCS
procedure performed within the encounter
values available
proc_greedyBoolean indicator for 'AND' or 'OR' when multiple
procedure parameters specified - helps users offer various
levels of specificity without confusing and/or logic
True or False
taxonomy_codeTaxonomy of the organization or individual provider, 10-digit code that used to identify the type, classification, and area of specialization of an individual or organizational healthcare providervalues available
specialtySpecialty of the organization or individual provider(s), specific focus of a provider by patient population, disease, skill or philosophyvalues available
specialty_categorySpecialty category of the organization or individual provider(s), broad focus of a provider by patient population, disease, skill or philosophyvalues available
subspecialtySpecialty subcategory of the organization or individual
provider(s), hyper-specific focus of a provider by patient
population, disease, skill or philosophy
values available
taxonomy_greedyBoolean indicator for 'AND' or 'OR' when multiple taxonomy or specialty parameters specified - helps users offer various levels of specificity without confusing and/or logicTrue or False
ref_npiReferring provider(s) on the encounter as
indicated by their National Provider Identifiers (NPIs)
Any Valid NPI
npiNational Provider Identifier (NPI) of individual and/or
organizational provider(s) that appear on the encounter.
Any Valid NPI
stateUS State residence of the query patient populationvalues available
divisionNine distinct US State groupings as defined by the US Census Bureauvalues available
regionFour major US State groupings as defined by the US Census Bureauvalues available
metroMetropolitan and micropolitan statistical
areas according to the US Census Bureau
values available
short_zipFirst three digits the zip code of the
query patient population specified
First 3 digits of zip code(s)
limitNumber of rows returned in the data requestInteger or False
showBinary indicator as to whether you'd like
query to be printed for review upon it's creation
True or False

Query Return Data

The careVisit query returns the JOURNEY_TABLE for all visits that meet the criterion specified within the query.

The JOURNEY_TABLE offers comprehensive detail of longitudinal patient journeys, with line-item encounter detail, insight into payor, provider, procedure, revenue code, charges and SmartAllowedAmount®.

featuredescriptionexample
journey_idRandomly generated identifier unique to each longitudinal patient journey.355ed5199ebed017821c7faa62965a61
episode_idRandomly generated identifier unique to each sequence of encounters with at least 30 days between visits.9318831e2ce3f30a83b1317b4d02ebfd
visit_idRandomly generated identifier unique to each set of encounters that occur within the same event of care.315cb4170e73bed429a86e3dbb4e95a
d6c6ce162412dfc97fce0c7a660ea2350
encounter_idRandomly generated identifier, unique to an isolated event of care.5ee14a8a88b18ce16f748baa7742b28d
60a057208872b0f650ccfae7a40ffa9e
datePrimary date of each encounter.2022-05-02
patient_stateUS State residence of the patient on each encounter.CO
patient_short_zipFirst three digits of the patient's zip code801
patient_ageAge (within 5 years) of the patient at the moment of each encounter.65
patient_genderGender/Sex of the patientM
place_of_serviceType of facility where a encounter occurred.Office
visit_typeDescription of the setting of care.Outpatient Visit
payorName of the primary payor on each encounter.Centers for Medicare & Medicaid Services (CMS)
payor_channelPayor channel-of-business, line-of-business, or plan type.Medicare
ref_npiReferring individual provider of an encounter, identified via their National Provider Identifier (NPI).1003878000
hcp_npiPrimary individual provider of an encounter, identified via their National Provider Identifier (NPI).1003878000
hcp_taxonomyPrimary taxonomy code of the individual provider on an encounter.207Q00000X - Allopathic and Osteopathic Physicians/Family Medicine
hcp_specialtyPrimary specialty of the individual provider provider on an encounter.Family Practice
hco_npiOrganizational provider of an encounter, identified via their National Provider Identifier (NPI).1063001238
hcp_npi_listList of all individual providers on an encounter, including primary and supporting providers, all designated by their National Provider Identifier (NPI)1003878000, 01920493029
hco_npi_listList of all organizational providers on an encounter, including primary and auxiliary providers, all designated by their National Provider Identifier (NPI)1063001238, 29380050392
diag_listAll diagnoses coded (problem list) within each claim encounter. The first diagnosis listed is the primary diagnosis. I10, E7849, E7800, E7800, I639
diag_1 - diag_25
(optional)
Depending on the diag_num listed within the query parameters, the user may receive diagnoses 1 through 25 as their own columns rather than an combined list. Defaulted to return the top 5 diagnoses.I10....I639
rev_center_codeRevenue code corresponding to encounter'0510'
rev_center_unitsNumber of days a revenue code has been triggered, corresponding to each encounter1.0
proc_codeProcedure code performed within encounter.99457
proc_unitsTotal number of procedure units within encounter.1.0
proc_modifierProcedure code modifier for procedure performed within encounter.GW
line_chargeLine-item charge submitted to insurers for the procedures rendered by the provider. The line charge is the pre-adjudicated value submitted to insurers.63.02
claim_chargeLine-item charge submitted to insurers along with facility and revenue center charge considerations. The line charge is the pre-adjudicated value submitted to insurers.284.49
smart_allowedLine-item estimate of allowed amount, utilizing proprietary ML on CMS, Price Transparency and Actual Adjudicated amounts to provide estimates within an average of 5% variance from actuals.$80.54

Advanced Query Logic & Recipes

As one thinks about what the healthcare visit's they'd like returned in a query...the diagnosis, procedure, location, time and specialty criterion...things can get quite complex.

careVisit gives users categorical groupings for ease of use, as well as SQL-like capabilities to tactfully specify AND and OR logic, right within the CareQuery API!

Please reference the following resources to better understand how to create rockstar queries!