cascade-protocol
Python SDK for the Cascade Protocol — a privacy-first, local-first standard for serializing personal health data as RDF/Turtle.
Installation
pip install cascade-protocol
With optional extras:
pip install "cascade-protocol[pandas]" # pandas DataFrame integration
pip install "cascade-protocol[validation]" # SHACL validation via pyshacl
pip install "cascade-protocol[notebooks]" # Jupyter notebook support
pip install "cascade-protocol[all]" # Everything
Quick Start
from cascade_protocol import Medication, serialize, validate, Pod
# Create a medication record
med = Medication(
id="urn:uuid:med0-0001-aaaa-bbbb-ccccddddeeee",
medication_name="Metoprolol Succinate",
is_active=True,
dose="25mg",
data_provenance="ClinicalGenerated",
schema_version="1.3",
)
# Serialize to Turtle
turtle = serialize(med)
print(turtle)
# Validate structural integrity
result = validate(turtle)
print(result.is_valid, result.errors)
# Open a Cascade Pod and query records
pod = Pod.open("./my-pod")
meds = pod.query("medications")
# Convert to pandas DataFrame (requires pandas extra)
df = meds.to_dataframe()
print(df.head())
# Reconstruct models from DataFrame
restored = Medication.from_dataframe(df)
Serialization Output
@prefix cascade: <https://ns.cascadeprotocol.org/core/v1#> .
@prefix health: <https://ns.cascadeprotocol.org/health/v1#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<urn:uuid:med0-0001-aaaa-bbbb-ccccddddeeee> a health:MedicationRecord ;
health:medicationName "Metoprolol Succinate" ;
health:isActive true ;
cascade:dataProvenance cascade:ClinicalGenerated ;
cascade:schemaVersion "1.3" ;
health:dose "25mg" .
Supported Data Types
| Class | RDF Type | Description |
|---|---|---|
Medication |
health:MedicationRecord |
Prescription and OTC drugs |
Condition |
health:ConditionRecord |
Medical diagnoses |
Allergy |
health:AllergyRecord |
Allergies and intolerances |
LabResult |
health:LabResultRecord |
Laboratory test results |
VitalSign |
clinical:VitalSign |
Vital sign measurements |
Immunization |
health:ImmunizationRecord |
Vaccine records |
Procedure |
health:ProcedureRecord |
Clinical procedures |
FamilyHistory |
health:FamilyHistoryRecord |
Family health history |
Coverage |
coverage:InsurancePlan |
Insurance coverage |
PatientProfile |
cascade:PatientProfile |
Patient demographics |
ActivitySnapshot |
health:ActivitySnapshot |
Daily activity data |
SleepSnapshot |
health:SleepSnapshot |
Nightly sleep data |
Encounter |
clinical:Encounter |
Clinical encounters and visits |
MedicationAdministration |
clinical:MedicationAdministration |
Medication administration events |
ImplantedDevice |
clinical:ImplantedDevice |
Implanted medical devices |
ImagingStudy |
clinical:ImagingStudy |
Imaging studies and results |
ClaimRecord |
coverage:ClaimRecord |
Insurance claim records |
BenefitStatement |
coverage:BenefitStatement |
Explanation of benefits |
DenialNotice |
coverage:DenialNotice |
Coverage denial notices |
AppealRecord |
coverage:AppealRecord |
Denial appeal records |
Pod API
from cascade_protocol import Pod
pod = Pod.open("./my-pod")
# Query by data type
meds = pod.query("medications")
vitals = pod.query("vital-signs")
profile = pod.query("patient-profile")
# Iterate records
for med in meds:
print(med.medication_name, med.dose)
# DataFrame conversion
df = meds.to_dataframe()
Parsing Turtle
from cascade_protocol.deserializer import parse, parse_one
# Parse multiple records
meds = parse(turtle_string, "MedicationRecord")
# Parse a single record
med = parse_one(turtle_string, "MedicationRecord")
Namespaces
from cascade_protocol.vocabularies import NAMESPACES, CURRENT_SCHEMA_VERSION
print(NAMESPACES["cascade"]) # https://ns.cascadeprotocol.org/core/v1#
print(NAMESPACES["health"]) # https://ns.cascadeprotocol.org/health/v1#
print(CURRENT_SCHEMA_VERSION) # 1.3
Privacy & Security
- Zero network calls during normal operation
- All processing is local
- No telemetry or analytics
- Data never leaves your machine
License
Apache 2.0 — see LICENSE.
Links
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cascade_protocol-1.5.0.tar.gz.
File metadata
- Download URL: cascade_protocol-1.5.0.tar.gz
- Upload date:
- Size: 93.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2998a06022fe90f475b8004f1554be7cfb8a86529ef88537f9a146cb9a507ab
|
|
| MD5 |
bcef7db11f4ac400b7b1dd0bd49d2a7e
|
|
| BLAKE2b-256 |
8e8792c31670165cfe7ce6e608aa9be9cd426f790ed439d62791feb06c0a1f3c
|
Provenance
The following attestation bundles were made for cascade_protocol-1.5.0.tar.gz:
Publisher:
release.yml on the-cascade-protocol/sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cascade_protocol-1.5.0.tar.gz -
Subject digest:
a2998a06022fe90f475b8004f1554be7cfb8a86529ef88537f9a146cb9a507ab - Sigstore transparency entry: 2341401500
- Sigstore integration time:
-
Permalink:
the-cascade-protocol/sdk-python@e369a7006193b951dd29dbf863b4765531d56d22 -
Branch / Tag:
refs/tags/v1.5.0 - Owner: https://github.com/the-cascade-protocol
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e369a7006193b951dd29dbf863b4765531d56d22 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cascade_protocol-1.5.0-py3-none-any.whl.
File metadata
- Download URL: cascade_protocol-1.5.0-py3-none-any.whl
- Upload date:
- Size: 96.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c379dcd67884aa1c6a376a3919efdcbb6f23cfef288cfe9ba0db9a5e420003d8
|
|
| MD5 |
2d80322a6e13931e69c7a1d227dd0070
|
|
| BLAKE2b-256 |
1bd333a9aabaa61bd0bcd48576e16d0303f57ac0b1c926b09dd24ddef2cb883e
|
Provenance
The following attestation bundles were made for cascade_protocol-1.5.0-py3-none-any.whl:
Publisher:
release.yml on the-cascade-protocol/sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cascade_protocol-1.5.0-py3-none-any.whl -
Subject digest:
c379dcd67884aa1c6a376a3919efdcbb6f23cfef288cfe9ba0db9a5e420003d8 - Sigstore transparency entry: 2341401508
- Sigstore integration time:
-
Permalink:
the-cascade-protocol/sdk-python@e369a7006193b951dd29dbf863b4765531d56d22 -
Branch / Tag:
refs/tags/v1.5.0 - Owner: https://github.com/the-cascade-protocol
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e369a7006193b951dd29dbf863b4765531d56d22 -
Trigger Event:
push
-
Statement type: