scriptJourney

Query patient's full prescription claims history with line item detail, by specifying ANY and ALL prescription parameters where criterion are met across the entire journey

Get Started with scriptEncounter

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

Example:

🔍

Cardiovascular disease doctors prescribing blood viscosity reducers in the first 3 quarters in 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.scriptJourney(substance = "blood viscosity reducer [epc]",
                         subspecialty = "internal medicine - cardiovascular disease",
                         min_date = "2023-01-01",
                         max_date = "2023-09-01",
                         alias = "cvd_viscocity_reducers", # 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
query_name.queryStatus()

# 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 scriptJourney query, including details on the parameter values.

parameterdescriptionoptions
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
ndcFDA National Drug Code version 11 standardized code for a dispensed drugAny Valid National Drug Code
(Please see SCRIPT_DETAIL_TABLE or Unformatted NDC11 for full list of options)
pharm_classClassifications of a drug product based on its therapeutic action, or how it works in the bodyvalues available
substanceThe active ingredient in a drug productvalues available
marketing_categoryClassification of a drug product based on its regulatory status and how it is marketedvalues available
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 philosophyvalues available
npiNational Provider Identifier (NPI) of individual and/or organizational provider(s) that appear on the encounter.Any Valid National
Provider Identifier (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 Speed

scriptEncounter - depending on the complexity and size of the query, most queries will return results within 5 seconds to 20 minutes.

⏲️

Median Query Speed: 12 minute and 30 seconds

Query Return Data

The scriptJourney query returns the SCRIPT_TABLE for all encounters that meet the criterion specified within the query.

The SCRIPT_TABLE provides prescription claim with comprehensive drug and provider details, across entire longitudinal journeys.

featuredescriptionexample
journey_idRandomly generated identifier unique to each longitudinal patient journey.355ed5199ebed017821c7faa62965a61
script_idRandomly generated identifier unique to each prescription claim.9318831e2ce3f30a83b1317b4d02ebfd
group_idRandomly generated identifier unique to each payor plan corresponding to the prescription written.315cb4170e73bed429a86e3dbb4e95a
script_dateDate the prescription was written2022-01-21
service_dateDate that the prescription was filled, services rendered, or the payer began coverage following Part A expiration in a long-term care setting2019-02-25
patient_stateUS State residence of the patient on each encounterAZ
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.62
patient_genderGender/Sex of the patientM
hcp_npiNational Provider Identifier (NPI) of the individual that wrote the prescription for the patient.1003878000
hcp_taxonomyPrimary taxonomy code of the individual provider who wrote the prescription.207Q00000X
hcp_specialtyPrimary specialty of the individual provider provider wrote the prescription.family medicine - general
hco_npiNational Provider Identifier (NPI) of the organization that fulfilled the prescription1063001238
ndcFDA National Drug Code version 11 standardized code for a dispensed drug68645054154
proprietary_nameUnique brand name of a drug product as assigned by the drug manufacturerglimepiride
refillsMaximum number of refills authorized1
quantity_prescribedQuantity of drug units prescribed0
quantity_dispensedQuantity of drug units dispensed30
fill_numberRefill number for the current SCRIPT_ID1
days_supplyEstimated number of days the dispensed drugs will last30
unit_of_measureUnits of measure for the quantity_dispensedEA
submitted_costPharmacy submitted cost of the claim$46.00
patient_payPatient cost responsibility as determined by payor$5.90
copay_insurancePatient cost responsibility as copay or coinsurance$0.00
plan_payPayor cost responsibility$1.50

Advanced Query Logic & Recipes

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

scriptEncounter 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!