TTOPM commited on
Commit
34a39c2
·
verified ·
1 Parent(s): f1bfa1e

Upload 43 files

Browse files
Files changed (43) hide show
  1. BELEL-MED/CITATION.cff +9 -0
  2. BELEL-MED/COMPLIANCE/CHANGELOG.md +3 -0
  3. BELEL-MED/COMPLIANCE/DATA_CARDS/datasets.md +7 -0
  4. BELEL-MED/COMPLIANCE/DPIA.md +18 -0
  5. BELEL-MED/COMPLIANCE/MODEL_CARDS/overview.md +4 -0
  6. BELEL-MED/COMPLIANCE/PMS_PLAN.md +5 -0
  7. BELEL-MED/COMPLIANCE/RISK_REGISTER.md +7 -0
  8. BELEL-MED/COMPLIANCE/VALIDATION_PLAN.md +11 -0
  9. BELEL-MED/GOVERNANCE/AUDIT_LEDGER_SPEC.md +4 -0
  10. BELEL-MED/GOVERNANCE/EVIDENCE_CONTRACT_SPEC.md +8 -0
  11. BELEL-MED/GOVERNANCE/POLICY_ENGINE/opa_policies.rego +14 -0
  12. BELEL-MED/GOVERNANCE/RETRACTION_WATCH.md +4 -0
  13. BELEL-MED/LEGAL/ATTRIBUTION_AND_CITATION.md +6 -0
  14. BELEL-MED/LEGAL/LICENSE-BELEL-PROTOCOL.txt +10 -0
  15. BELEL-MED/LEGAL/PROVENANCE_POLICY.md +5 -0
  16. BELEL-MED/LEGAL/TERMS_OF_USE.md +5 -0
  17. BELEL-MED/Makefile +27 -0
  18. BELEL-MED/ONE_PAGER.md +26 -0
  19. BELEL-MED/PRD/PRD_BELEL_MED.md +19 -0
  20. BELEL-MED/PRD/api/endpoints.yaml +149 -0
  21. BELEL-MED/PRD/api/schemas/ClinicalQARequest.example.json +13 -0
  22. BELEL-MED/PRD/api/schemas/ClinicalQAResponse.example.json +35 -0
  23. BELEL-MED/README.md +44 -0
  24. BELEL-MED/SECURITY.md +6 -0
  25. BELEL-MED/dist/HASHES.json +169 -0
  26. BELEL-MED/dist/RELEASE_MANIFEST.json +10 -0
  27. BELEL-MED/docs/ARCHITECTURE.md +7 -0
  28. BELEL-MED/docs/BLUEPRINT.md +68 -0
  29. BELEL-MED/docs/METRICS.md +4 -0
  30. BELEL-MED/docs/ROADMAP.md +5 -0
  31. BELEL-MED/docs/ROLLOUT_PLAN_90DAYS.md +5 -0
  32. BELEL-MED/scripts/release/build_manifest.py +24 -0
  33. BELEL-MED/scripts/release/hash_all.py +18 -0
  34. BELEL-MED/src/orchestrator/evidence_contract.py +21 -0
  35. BELEL-MED/src/orchestrator/orchestrator.py +20 -0
  36. BELEL-MED/src/orchestrator/retrieval.py +20 -0
  37. BELEL-MED/src/privacy/deid.py +20 -0
  38. BELEL-MED/src/server/app.py +29 -0
  39. BELEL-MED/src/server/policy/policy_config.yaml +7 -0
  40. BELEL-MED/src/server/routers/clinical.py +55 -0
  41. BELEL-MED/src/server/routers/radiology.py +39 -0
  42. BELEL-MED/src/server/routers/triage.py +43 -0
  43. BELEL-MED/src/trust/audit.py +22 -0
BELEL-MED/CITATION.cff ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ cff-version: 1.2.0
2
+ title: "BELEL-MED — Sovereign Health AI"
3
+ message: "Please cite this work if you use it."
4
+ authors:
5
+ - family-names: Robinson
6
+ given-names: Pearce
7
+ date-released: 2025-10-06
8
+ version: 0.1.0
9
+ repository-code: "https://github.com/TTOPM/be-core-bridge"
BELEL-MED/COMPLIANCE/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Change Log
2
+
3
+ - 2025-10-06 11:11:53Z: Initial gold-standard blueprint & reference skeleton created.
BELEL-MED/COMPLIANCE/DATA_CARDS/datasets.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Data Cards — Datasets (catalogue)
2
+
3
+ - EHR (FHIR R4/5): structured + notes
4
+ - Imaging (DICOM): modality-tagged
5
+ - Labs/Pharmacy (HL7/LIS)
6
+ - Wearables/Telemetry
7
+ - Public literature indices (with quality tags)
BELEL-MED/COMPLIANCE/DPIA.md ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Data Protection Impact Assessment (DPIA)
2
+
3
+ **System:** BELEL-MED
4
+ **Purpose:** Clinical decision support and patient triage/longitudinal coaching.
5
+ **Lawful bases:** Healthcare provision; vital interests; explicit consent where applicable.
6
+
7
+ ## Data Flows
8
+ - Sources: EHR (FHIR), imaging (DICOM), labs, pharmacy, devices, wearables.
9
+ - Storage: Encrypted at rest; segregated PHI; audit logging.
10
+ - Processing: Evidence-locked inference; role-based access; privacy-preserving learning.
11
+
12
+ ## Risks & Mitigations
13
+ - Re-identification: de-identification, DP noise, access controls.
14
+ - Misuse: policy engine fences, human-in-loop, tiered evidence thresholds.
15
+ - Bias: calibration by subgroup; continuous monitoring; fairness reports.
16
+
17
+ ## Residual Risk
18
+ Medium → reduced to Low with governance + monitoring.
BELEL-MED/COMPLIANCE/MODEL_CARDS/overview.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Model Cards — Overview
2
+
3
+ This directory contains per-modality model cards (Text, Imaging, Time-Series, Genomics).
4
+ Each card documents: intended use, data sources, training details, evaluation metrics, known limitations, and update policy.
BELEL-MED/COMPLIANCE/PMS_PLAN.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Post-Market Surveillance (PMS) Plan
2
+
3
+ - Continuous logging and periodic safety review board
4
+ - Incident reporting workflow (CAPA)
5
+ - Drift detection and recalibration triggers
BELEL-MED/COMPLIANCE/RISK_REGISTER.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Risk Register (excerpt)
2
+
3
+ | ID | Risk | Likelihood | Impact | Mitigation |
4
+ |---|---|---|---|---|
5
+ | R1 | Hallucinated citation | M | H | Evidence contract validator; authority ranking |
6
+ | R2 | Bias in subgroup | M | H | Calibration stratified; fairness audits |
7
+ | R3 | PHI leakage | L | H | DLP filters; de-identification; DP |
BELEL-MED/COMPLIANCE/VALIDATION_PLAN.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Clinical Validation Plan
2
+
3
+ ## Phases
4
+ 1) Shadow mode (no impact): compare model outputs vs. clinician ground truth.
5
+ 2) Prospective, low-risk domains with DSMB oversight.
6
+ 3) Phased expansion with pre-specified endpoints (safety, efficacy, workflow).
7
+
8
+ ## Metrics
9
+ - Alert precision/recall, time saved/note
10
+ - Med error intercepts, guideline adherence
11
+ - Clinical outcomes: readmission, ED bounce, PROMs
BELEL-MED/GOVERNANCE/AUDIT_LEDGER_SPEC.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Audit Ledger Specification
2
+
3
+ - Compute SHA-256 over: input digest, output digest, model_id, kg_version, policy_version, timestamp.
4
+ - Append to WORM store; optional blockchain anchor (periodic Merkle root).
BELEL-MED/GOVERNANCE/EVIDENCE_CONTRACT_SPEC.md ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # Evidence Contract Specification
2
+
3
+ Every clinical answer must attach:
4
+ - Ranked citations (guideline > meta-analysis > RCT > observational > textbook > historical)
5
+ - Uncertainty (aleatoric/epistemic)
6
+ - Patient-fit features used
7
+ - Audit hash (data slice + model + KG versions)
8
+ - Region flag and policy profile used
BELEL-MED/GOVERNANCE/POLICY_ENGINE/opa_policies.rego ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package belel.policies
2
+
3
+ default allow := false
4
+
5
+ # Example: prohibit autonomous medication ordering
6
+ allow {
7
+ input.action == "draft_order_set"
8
+ input.requires_signoff == true
9
+ }
10
+
11
+ deny[msg] {
12
+ input.action == "place_medication_order"
13
+ msg := "Autonomous ordering not permitted"
14
+ }
BELEL-MED/GOVERNANCE/RETRACTION_WATCH.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Retraction & Errata Watch
2
+
3
+ - Nightly sweep of literature sources; update KG flags.
4
+ - Answers referencing retracted items trigger automatic clinician alerts and recomputation.
BELEL-MED/LEGAL/ATTRIBUTION_AND_CITATION.md ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ # Attribution & Citation
2
+
3
+ If you build on this work, you **must** cite:
4
+ - "BELEL-MED — Sovereign Health AI (TTOPM)"
5
+ - Canonical anchor: TTOPM/be-core-bridge
6
+ - Include Evidence Contracts and audit provenance in outputs.
BELEL-MED/LEGAL/LICENSE-BELEL-PROTOCOL.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ BELEL Protocol Sovereign License (BPSL) v1.0
2
+ ---------------------------------------------------
3
+ Copyright (c) The Office of Pearce Robinson (TTOPM)
4
+
5
+ You may use, review, and integrate this work subject to:
6
+ 1) Mandatory attribution: cite "BELEL-MED — Sovereign Health AI (TTOPM)".
7
+ 2) Mandatory provenance: preserve Evidence Contracts and audit hooks.
8
+ 3) No plagiarism: removal of attribution/provenance is prohibited.
9
+ 4) No harmful use: clinical actions require human sign-off per local law.
10
+ 5) Derivatives must include these terms and link to canonical anchors.
BELEL-MED/LEGAL/PROVENANCE_POLICY.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Provenance & Anti-Plagiarism Policy
2
+
3
+ - Source headers inserted in all code files.
4
+ - Build step generates hashes and a CITATION.cff for citation metadata.
5
+ - Any removal of headers/hashes is a license breach.
BELEL-MED/LEGAL/TERMS_OF_USE.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Terms of Use (Excerpt)
2
+
3
+ - For assistive use by qualified clinicians.
4
+ - Not a substitute for professional judgment.
5
+ - All actions require human review and sign-off.
BELEL-MED/Makefile ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .PHONY: help dev prod test lint sbom hash manifest
2
+
3
+ help:
4
+ @echo "Targets: dev, prod, test, lint, sbom, hash, manifest"
5
+
6
+ dev:
7
+ python -m venv .venv && . .venv/bin/activate && pip install -U pip && pip install fastapi uvicorn pydantic httpx rich
8
+ UVICORN_RELOAD=true uvicorn src.server.app:app --reload
9
+
10
+ prod:
11
+ python -m venv .venv && . .venv/bin/activate && pip install -U pip && pip install fastapi uvicorn pydantic gunicorn
12
+ gunicorn -k uvicorn.workers.UvicornWorker src.server.app:app --bind 0.0.0.0:8000
13
+
14
+ test:
15
+ @echo "Add unit tests here (pytest)"; exit 0
16
+
17
+ lint:
18
+ @echo "Add linter (ruff/flake8) here"; exit 0
19
+
20
+ sbom:
21
+ @echo "Generate SBOM placeholder"; mkdir -p dist && echo "SBOM placeholder" > dist/SBOM.txt
22
+
23
+ hash:
24
+ @python scripts/release/hash_all.py
25
+
26
+ manifest:
27
+ @python scripts/release/build_manifest.py
BELEL-MED/ONE_PAGER.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BELEL-MED — The Sovereign Health AI for Safer, Faster Care
2
+
3
+ **TL;DR**: A clinician-first, evidence-locked AI that reads the whole chart, reasons across multimodal data, drafts notes and order sets for sign-off, and coaches patients between visits—**with citations, uncertainty, and audit logs baked in**.
4
+
5
+ ## Why Now
6
+ Clinicians face documentation overload, fragmented data, and safety risks. Patients need navigation across triage → treatment → recovery. BELEL-MED unifies this with verifiable intelligence.
7
+
8
+ ## What It Does
9
+ - **Whole-chart Q&A**: Ask natural questions across notes, labs, meds, imaging, sensors.
10
+ - **Evidence Contracts**: Every claim cites guidelines/trials; uncertainty always shown.
11
+ - **EHR-native**: Drafts SOAP/discharge notes, referral letters, suggested order sets.
12
+ - **Triage → Longitudinal care**: Red-flag detection; daily check-ins; adherence nudges.
13
+ - **Multimodal**: Radiology/pathology triage, ECG/telemetry, PGx dosing.
14
+ - **Safety & Governance**: Human-in-the-loop, policy fences, audit ledger, bias monitors.
15
+ - **Privacy-first**: On-prem/VPC, federated learning, differential privacy.
16
+
17
+ ## Outcomes That Matter
18
+ - Less time per note. Fewer med errors. Better guideline concordance.
19
+ - Lower readmissions and ED bounce-backs. Higher PROMs.
20
+
21
+ ## Go-To-Market
22
+ - 90-day rollout from shadow mode to limited action drafting.
23
+ - Focus on high-yield services (IM, cards, pulm, ED).
24
+
25
+ **Sovereign. Verifiable. Clinician-first.**
26
+ *Gold standard for responsible health AI.*
BELEL-MED/PRD/PRD_BELEL_MED.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BELEL-MED — Engineering PRD
2
+
3
+ ## Objectives
4
+ Deliver a sovereign, multimodal clinical assistant with evidence-locked outputs, EHR-native workflow integration, and region-aware safety policies.
5
+
6
+ ## Scope
7
+ - Multimodal RAG orchestration over FHIR/DICOM/OMOP
8
+ - Evidence Contracts attached to all answers
9
+ - Drafting: notes, messages, order sets (no auto-execute)
10
+ - Patient triage & longitudinal coach
11
+ - Audit & trust layers (hashes, ledgers), privacy-first learning
12
+
13
+ ## Non-Goals
14
+ - Fully autonomous ordering/diagnosis without human sign-off
15
+ - Replacing local governance or institutional policies
16
+
17
+ ## Success Metrics
18
+ - Time saved/note, alert precision/recall, medication error intercepts
19
+ - Guideline-concordant care, 30-day readmission, PROMs
BELEL-MED/PRD/api/endpoints.yaml ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ openapi: 3.0.3
2
+ info:
3
+ title: BELEL-MED API
4
+ version: 0.1.0
5
+ paths:
6
+ /v1/clinical/qa:
7
+ post:
8
+ summary: FHIR-aware whole-chart Q&A with evidence contracts
9
+ requestBody:
10
+ required: true
11
+ content:
12
+ application/json:
13
+ schema:
14
+ $ref: '#/components/schemas/ClinicalQARequest'
15
+ responses:
16
+ '200':
17
+ description: Evidence-locked answer
18
+ content:
19
+ application/json:
20
+ schema:
21
+ $ref: '#/components/schemas/ClinicalQAResponse'
22
+ /v1/triage:
23
+ post:
24
+ summary: Patient triage (non-diagnostic) with safety thresholds
25
+ requestBody:
26
+ required: true
27
+ content:
28
+ application/json:
29
+ schema:
30
+ $ref: '#/components/schemas/TriageRequest'
31
+ responses:
32
+ '200':
33
+ description: Triage result with escalation rules
34
+ content:
35
+ application/json:
36
+ schema:
37
+ $ref: '#/components/schemas/TriageResponse'
38
+ /v1/radiology/analyze:
39
+ post:
40
+ summary: Radiology pre-read (assistive) with explainability
41
+ requestBody:
42
+ required: true
43
+ content:
44
+ application/json:
45
+ schema:
46
+ $ref: '#/components/schemas/RadAnalyzeRequest'
47
+ responses:
48
+ '200':
49
+ description: Findings + structured impression
50
+ content:
51
+ application/json:
52
+ schema:
53
+ $ref: '#/components/schemas/RadAnalyzeResponse'
54
+ components:
55
+ schemas:
56
+ ClinicalQARequest:
57
+ type: object
58
+ properties:
59
+ patient_id: { type: string }
60
+ question: { type: string }
61
+ scope:
62
+ type: object
63
+ properties:
64
+ last_days: { type: integer }
65
+ modalities:
66
+ type: array
67
+ items: { type: string }
68
+ region: { type: string }
69
+ EvidenceItem:
70
+ type: object
71
+ properties:
72
+ id: { type: string }
73
+ type: { type: string, enum: [guideline, meta-analysis, rct, observational, textbook, historical] }
74
+ year: { type: integer }
75
+ strength: { type: string, enum: [A, B, C, D] }
76
+ url: { type: string }
77
+ ClinicalQAResponse:
78
+ type: object
79
+ properties:
80
+ summary: { type: string }
81
+ ddx_ranked:
82
+ type: array
83
+ items:
84
+ type: object
85
+ properties:
86
+ condition: { type: string }
87
+ p: { type: number }
88
+ recommendations:
89
+ type: array
90
+ items: { type: string }
91
+ contraindications_checked: { type: boolean }
92
+ uncertainty:
93
+ type: object
94
+ properties:
95
+ aleatoric: { type: number }
96
+ epistemic: { type: number }
97
+ evidence:
98
+ type: array
99
+ items: { $ref: '#/components/schemas/EvidenceItem' }
100
+ patient_fit:
101
+ type: array
102
+ items: { type: string }
103
+ audit:
104
+ type: object
105
+ properties:
106
+ data_hash: { type: string }
107
+ model_version: { type: string }
108
+ kg_version: { type: string }
109
+ TriageRequest:
110
+ type: object
111
+ properties:
112
+ symptoms:
113
+ type: array
114
+ items: { type: string }
115
+ age: { type: integer }
116
+ comorbid:
117
+ type: array
118
+ items: { type: string }
119
+ TriageResponse:
120
+ type: object
121
+ properties:
122
+ acuity: { type: string, enum: [self-care, gp, urgent, emergency] }
123
+ next_step: { type: string }
124
+ safety_advice:
125
+ type: array
126
+ items: { type: string }
127
+ escalation_triggers:
128
+ type: array
129
+ items: { type: string }
130
+ RadAnalyzeRequest:
131
+ type: object
132
+ properties:
133
+ study_uid: { type: string }
134
+ body_part: { type: string }
135
+ indication: { type: string }
136
+ RadAnalyzeResponse:
137
+ type: object
138
+ properties:
139
+ findings:
140
+ type: array
141
+ items: { type: string }
142
+ impression: { type: string }
143
+ explainability:
144
+ type: object
145
+ properties:
146
+ heatmap_ref: { type: string }
147
+ feature_importance:
148
+ type: array
149
+ items: { type: string }
BELEL-MED/PRD/api/schemas/ClinicalQARequest.example.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "patient_id": "12345",
3
+ "question": "Given current meds and eGFR 52, is SGLT2 appropriate?",
4
+ "scope": {
5
+ "last_days": 365,
6
+ "modalities": [
7
+ "notes",
8
+ "labs",
9
+ "meds"
10
+ ]
11
+ },
12
+ "region": "UK"
13
+ }
BELEL-MED/PRD/api/schemas/ClinicalQAResponse.example.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "summary": "SGLT2 is appropriate per NICE NG28 for T2DM with CKD; monitor volume status.",
3
+ "ddx_ranked": [
4
+ {
5
+ "condition": "T2DM with CKD",
6
+ "p": 0.71
7
+ }
8
+ ],
9
+ "recommendations": [
10
+ "Initiate empagliflozin 10 mg if no contraindications."
11
+ ],
12
+ "contraindications_checked": true,
13
+ "uncertainty": {
14
+ "aleatoric": 0.12,
15
+ "epistemic": 0.21
16
+ },
17
+ "evidence": [
18
+ {
19
+ "id": "NICE NG28",
20
+ "type": "guideline",
21
+ "year": 2024,
22
+ "strength": "A",
23
+ "url": "https://www.nice.org.uk/"
24
+ }
25
+ ],
26
+ "patient_fit": [
27
+ "HbA1c 8.2%",
28
+ "eGFR 52 mL/min/1.73m2"
29
+ ],
30
+ "audit": {
31
+ "data_hash": "<hash>",
32
+ "model_version": "v0.1",
33
+ "kg_version": "kg-2025-10"
34
+ }
35
+ }
BELEL-MED/README.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ![status](https://img.shields.io/badge/status-gold%20standard-brightgreen)
2
+ ![license](https://img.shields.io/badge/license-BPSL%20v1.0-blue)
3
+ ![security](https://img.shields.io/badge/security-audit%20ready-informational)
4
+ ![compliance](https://img.shields.io/badge/compliance-DPIA%2FModel%20Cards%2FValidation%20Plan-success)
5
+
6
+ # BELEL-MED — Sovereign Health AI
7
+
8
+ **Status:** Gold-standard, sovereign, evidence-locked blueprint and reference stack.
9
+ **Date:** 2025-10-06 11:11:53Z
10
+
11
+ BELEL-MED fuses the best of:
12
+ 1) Google-style multimodal retrieval & decision support,
13
+ 2) Epic-grade workflow integration (SMART-on-FHIR, OMOP, DICOM), and
14
+ 3) Cedars-Sinai/K Health triage + longitudinal care orchestration,
15
+
16
+ …and turns the dial to 11: **evidence contracts, region-aware policies, human-in-the-loop, audit-by-default, privacy-first learning**.
17
+
18
+ ## What’s inside
19
+ - `ONE_PAGER.md` — sponsor overview
20
+ - `PRD/` — Engineering PRD, endpoints, and JSON schemas
21
+ - `COMPLIANCE/` — DPIA, Model Cards, Validation plan, PMS, Risk register
22
+ - `GOVERNANCE/` — Evidence Contract spec, Audit ledger spec, OPA policies, Retraction watch
23
+ - `LEGAL/` — License, Attribution & Citation, Provenance/Terms
24
+ - `src/` — API skeleton (FastAPI), orchestrator, ingestion, trust/privacy modules
25
+ - `docs/` — Architecture, Rollout (90-day), Metrics, Roadmap
26
+
27
+ ## Core Promise
28
+ Every suggestion is **traceable**, **explainable**, **region-aware**, and **safe by default**.
29
+ All outputs **must** carry an **Evidence Contract** (citations, uncertainty, rationale, audit hash).
30
+
31
+ ---
32
+
33
+ ### Quickstart (dev)
34
+ ```bash
35
+ python -m venv .venv && source .venv/bin/activate
36
+ pip install fastapi uvicorn pydantic pydantic-settings python-multipart httpx rich
37
+ export BELEL_ENV=dev
38
+ uvicorn server.app:app --reload
39
+ ```
40
+
41
+ Open: http://127.0.0.1:8000/docs
42
+
43
+ > Note: This is a **reference skeleton**. Production deployments must integrate with real FHIR/DICOM/OMOP endpoints and institution-specific policies.
44
+
BELEL-MED/SECURITY.md ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ # Security Overview
2
+
3
+ - Encryption at rest/transit; HSM-backed keys
4
+ - RBAC/ABAC; audit logging
5
+ - Federated learning + DP for privacy
6
+ - Supply-chain: pinned dependencies; SBOM; signed releases
BELEL-MED/dist/HASHES.json ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "generated": "2025-10-06T11:18:36.512296Z",
3
+ "files": [
4
+ {
5
+ "path": "README.md",
6
+ "sha256": "062efca4193f81f73b1bf795ef60fa8ec1403ad00254a1862463c8bb22480626"
7
+ },
8
+ {
9
+ "path": "ONE_PAGER.md",
10
+ "sha256": "7c831e4a11a1e9e2f8200bfc5a6d1b8141125d4c49111c9c1119fa76e9404dce"
11
+ },
12
+ {
13
+ "path": "SECURITY.md",
14
+ "sha256": "d152a6e8b9645a243f037ee342a2019acd42c6343328ef94d6dd4f9337390451"
15
+ },
16
+ {
17
+ "path": "CITATION.cff",
18
+ "sha256": "68990dc5257d2172a3fbccb228ad065ef882af6943f3219856d44c846007d478"
19
+ },
20
+ {
21
+ "path": "Makefile",
22
+ "sha256": "b58bcd05acb052004a81393cd2e8b12f4bdc1d3103239a652e72b14a1b38edda"
23
+ },
24
+ {
25
+ "path": "PRD/PRD_BELEL_MED.md",
26
+ "sha256": "03a7c9987f270bce0b6ca765182daebd61db0b41c44304ec511e8e741f6ccfaf"
27
+ },
28
+ {
29
+ "path": "PRD/api/endpoints.yaml",
30
+ "sha256": "b464cd4f17f8a79e6ff82e7a543e0075d6e525a948728c61399956d7c37df6ab"
31
+ },
32
+ {
33
+ "path": "PRD/api/schemas/ClinicalQARequest.example.json",
34
+ "sha256": "51c2907e4d0cc451cbc5dbd2f565defd4e2ef60022b523eb51e550c67229f507"
35
+ },
36
+ {
37
+ "path": "PRD/api/schemas/ClinicalQAResponse.example.json",
38
+ "sha256": "a60ece61cc37b9b6b76eb38ac4d7f84345ef8042305a6f5cb2978b49e15442e9"
39
+ },
40
+ {
41
+ "path": "COMPLIANCE/DPIA.md",
42
+ "sha256": "8fae645ebc4d06da29ccc150328fbf49515d88fcc0bf2ec1cb852fc32315c576"
43
+ },
44
+ {
45
+ "path": "COMPLIANCE/VALIDATION_PLAN.md",
46
+ "sha256": "f3733eae2604d49e2ace4c508e43952309c2661237399c8ecbe5499acd9f01d3"
47
+ },
48
+ {
49
+ "path": "COMPLIANCE/PMS_PLAN.md",
50
+ "sha256": "2952857cb391f697ed6e6fd874c95bbf427ed4bff2e1b0669a812259a103c7c9"
51
+ },
52
+ {
53
+ "path": "COMPLIANCE/RISK_REGISTER.md",
54
+ "sha256": "1c1c8d2310ebb228004900c251e423abffba1135570c19564b3a3294c964520e"
55
+ },
56
+ {
57
+ "path": "COMPLIANCE/CHANGELOG.md",
58
+ "sha256": "6f2768eb557e3eabfcdb1cefada0895f1d174a5cb6d9f4bd9bda3fbb1f083baf"
59
+ },
60
+ {
61
+ "path": "COMPLIANCE/MODEL_CARDS/overview.md",
62
+ "sha256": "7ed59c1ffb5e7d2c91fa78103802ced09d375e2e8c848f903722f4779c328456"
63
+ },
64
+ {
65
+ "path": "COMPLIANCE/DATA_CARDS/datasets.md",
66
+ "sha256": "484e6f1e2f546e88304338f6b62fddd13efa1a9e6ab17edc4c3675230102f0b0"
67
+ },
68
+ {
69
+ "path": "GOVERNANCE/EVIDENCE_CONTRACT_SPEC.md",
70
+ "sha256": "0f6008006e670f453d95e9368761dede9d88085dbdd78af933d83abee6c25682"
71
+ },
72
+ {
73
+ "path": "GOVERNANCE/AUDIT_LEDGER_SPEC.md",
74
+ "sha256": "eec92be26bc4655a674e486bb9b9d0c7f061c122780279f889fe3e443db99326"
75
+ },
76
+ {
77
+ "path": "GOVERNANCE/RETRACTION_WATCH.md",
78
+ "sha256": "a80d9b515e2b2612cec16cb06abde7f9bddc513d63d4e92947b9b9a4e79f8e82"
79
+ },
80
+ {
81
+ "path": "GOVERNANCE/POLICY_ENGINE/opa_policies.rego",
82
+ "sha256": "cc1f8f61c311d88c5470162c6d07b4e8175cbc58ce2d500738e2896d992218c3"
83
+ },
84
+ {
85
+ "path": "LEGAL/LICENSE-BELEL-PROTOCOL.txt",
86
+ "sha256": "2c0e30044d3ce76334e21292f677093d580bc9ae71e7041e1f27c2b42ef18ae5"
87
+ },
88
+ {
89
+ "path": "LEGAL/ATTRIBUTION_AND_CITATION.md",
90
+ "sha256": "23c2835862a5cc92fc485155f9071a6522ff81875d64b82b894fe901b665bb72"
91
+ },
92
+ {
93
+ "path": "LEGAL/PROVENANCE_POLICY.md",
94
+ "sha256": "ee206faaf6850bc22f0a3a8097c1bc752ce0c52fc60eb276b26a08e847e811d6"
95
+ },
96
+ {
97
+ "path": "LEGAL/TERMS_OF_USE.md",
98
+ "sha256": "473410ea0761f0dfee282753c1117045742dde4eb9f1b26484b47813ad36195f"
99
+ },
100
+ {
101
+ "path": "src/server/app.py",
102
+ "sha256": "bb75478cd04060b88f39131e0cbc738472c9f121be4001066e8fb627161831c0"
103
+ },
104
+ {
105
+ "path": "src/server/routers/clinical.py",
106
+ "sha256": "d017e0592a9a1d07e009738eb4e0420356d5f8dd7c9c2172190a7c07b2d6dd03"
107
+ },
108
+ {
109
+ "path": "src/server/routers/triage.py",
110
+ "sha256": "5924c657b4fdf64e93302312bca1f283e7b4969534a40b33d22aa46f699eb30f"
111
+ },
112
+ {
113
+ "path": "src/server/routers/radiology.py",
114
+ "sha256": "cfe397f5379d9844346d431d3d94b6267fb6039b511a7820a5a0a22c758c1df9"
115
+ },
116
+ {
117
+ "path": "src/server/policy/policy_config.yaml",
118
+ "sha256": "ffb34fb8f1100acb687344bc4dc12e577ac835f35b3897ea065526d220936e44"
119
+ },
120
+ {
121
+ "path": "src/trust/audit.py",
122
+ "sha256": "422e279cd27dbe97893a1453363eb56971c11e56905de3b5a5e78638ccac98db"
123
+ },
124
+ {
125
+ "path": "src/privacy/deid.py",
126
+ "sha256": "516e62e07ea39f418bba203ccd20722811fc95a5f84217a3e7aaee58f26491d3"
127
+ },
128
+ {
129
+ "path": "src/orchestrator/orchestrator.py",
130
+ "sha256": "a493af3f83c4abfa6d3af6740025715f29f4e5dec861e955b4ac29ab4348329c"
131
+ },
132
+ {
133
+ "path": "src/orchestrator/retrieval.py",
134
+ "sha256": "e7c00754051b125dfbcb53b97e4a34e8cdabdcd8db1b7085f0eac05a13904a5d"
135
+ },
136
+ {
137
+ "path": "src/orchestrator/evidence_contract.py",
138
+ "sha256": "13fe0e2290f27150cbb2298c2d80cda52babfb908a8f85d0a836c502341c7bc3"
139
+ },
140
+ {
141
+ "path": "docs/ARCHITECTURE.md",
142
+ "sha256": "9f63077c6b51777234d4f7fa191b401ef9907d174662b43ef3a04ae3cb774f61"
143
+ },
144
+ {
145
+ "path": "docs/ROLLOUT_PLAN_90DAYS.md",
146
+ "sha256": "07b6c41af3c0ba920b5cf7b6eb29599f2fb06a38041241fe06f7934e182ae884"
147
+ },
148
+ {
149
+ "path": "docs/METRICS.md",
150
+ "sha256": "d4f810f19765fd1efa4011a1d6e9f48802988bfea4e3f42406972cd6837de4da"
151
+ },
152
+ {
153
+ "path": "docs/ROADMAP.md",
154
+ "sha256": "2c0bd314817cd726cc3435006c51971bafdd2c6ee57d0781973b73ebc5700fb3"
155
+ },
156
+ {
157
+ "path": "docs/BLUEPRINT.md",
158
+ "sha256": "335852ae7030147d7c629b5a54fffa13341ec877f8a29a1f30847001345a9f88"
159
+ },
160
+ {
161
+ "path": "scripts/release/hash_all.py",
162
+ "sha256": "3d021858659a1192bba0d6739d799e7f8ea2bbaeb29a2e7c236c8a1ad44ee22f"
163
+ },
164
+ {
165
+ "path": "scripts/release/build_manifest.py",
166
+ "sha256": "efe6ebdc0e4a08a0ca506628640f46d9d5a2960aa244244d7d630acdb2e28260"
167
+ }
168
+ ]
169
+ }
BELEL-MED/dist/RELEASE_MANIFEST.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "BELEL-MED Gold Standard Stack",
3
+ "version": "0.1.0",
4
+ "generated": "2025-10-06T11:18:36.603015Z",
5
+ "hashes_sha256": "ebbc5499cfcdb93850815626783fe97c909175f9262ab69e4a84bd362c809dc5",
6
+ "hashes_file": "HASHES.json",
7
+ "license": "BPSL v1.0",
8
+ "canonical_anchor": "TTOPM/be-core-bridge",
9
+ "integrity_note": "Replace with real signing (e.g., minisign/sigstore) for production"
10
+ }
BELEL-MED/docs/ARCHITECTURE.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Architecture Overview
2
+
3
+ - Data Plane: FHIR/DICOM/HL7, OMOP, quality gates
4
+ - Knowledge Plane: Literature, guidelines, knowledge graph
5
+ - Model Plane: Multimodal models + orchestrator + retrieval
6
+ - Trust/Governance: Policy engine, audit ledger, bias/fairness monitors
7
+ - Edges: Clinician SMART-on-FHIR app, Patient app
BELEL-MED/docs/BLUEPRINT.md ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BELEL-MED — Sovereign Health AI Blueprint
2
+ **Timestamp:** 2025-10-06 11:18:36Z
3
+
4
+ ## North-Star
5
+ A sovereign, evidence-locked health AI that ingests **all clinical modalities**, answers with **verifiable citations**, integrates **natively into workflows**, and operates with **zero-trust safety, regulatory-grade audit, and privacy-first learning**.
6
+
7
+ ## System Overview — 4 Planes + 2 Edges
8
+ ### A) Data Plane — Ingest & Normalize
9
+ - Connectors: FHIR R4/5 (EHR), HL7 v2, DICOM/PACS, LIS, pharmacy, claims, device SDKs (Apple HealthKit, Google Health Connect), wearables/telemetry, bedside monitors.
10
+ - Normalization: OMOP CDM mapping, units harmonization, timestamp alignment, de-identification (PHI tokenization).
11
+ - Quality: missingness/outlier reports, calibration profiles, lineage tracking.
12
+
13
+ ### B) Knowledge Plane — Current & Ancient Medical Corpus
14
+ - **Sources**: WHO, NICE, CDC/ACIP, ESC/ACC, USPSTF, IDSA; PubMed/OA; Cochrane; licensed textbooks/formularies; **historical treatises** (flagged as historical, not prescriptive).
15
+ - **Hierarchical Knowledge Graph**: conditions ↔ findings ↔ labs ↔ meds ↔ pathways ↔ trials; causal/contraindication edges; regional variants; time-stamped versions.
16
+ - **Continuous Curation**: expert panel + automated scanners; retraction/errata watch; evidence freshness scoring.
17
+
18
+ ### C) Model Plane — Multimodal & Verifiable
19
+ - **Foundation Models** (pluggable): text (clinician-tuned LLM), imaging (X-ray/CT/MRI, derm, retina, WSI), time-series (ECG/vitals/wearables), genomics/PGx, speech/vision.
20
+ - **Orchestrator**: retrieval-augmented reasoning with **Evidence Contracts** (mandatory citations, uncertainty, rationale, patient-fit).
21
+ - **Predictors**: early-warning (sepsis/AKI), readmission, longitudinal trajectories, dose calculators, DDI checks.
22
+
23
+ ### D) Trust & Governance Plane
24
+ - **Policy**: region-aware rules; scope fences (draft-only actions); OPA policies.
25
+ - **Safety Rails**: contraindication sweeps; dosage sanity; pediatric/renal/hepatic guards.
26
+ - **Bias & Fairness Monitors**: subgroup calibration; drift detection; model cards with cohort stats.
27
+ - **Audit**: append-only ledger, data lineage, consent artifacts; periodic Merkle-root anchoring.
28
+ - **Privacy**: on-prem/VPC; federated learning; differential privacy; RBAC/ABAC; KMS/HSM.
29
+
30
+ ### Edges
31
+ - **Clinician Edge**: SMART-on-FHIR EHR sidebar; PACS plug-ins; note drafting, order-set composer, patient message composer (sign-off required).
32
+ - **Patient Edge**: triage/chat, symptom checker, care-plan coach, adherence tracking; escalation thresholds defined.
33
+
34
+ ## Signature Capabilities — Best of All Worlds
35
+ - **Evidence-Locked Answers**: inline citations with strength-of-evidence; “Why/What would change” explainers.
36
+ - **EHR-Native Workflow (Epic-grade integration)**: SOAP/discharge drafts; referral letters; coding suggestions; order-set composer aligned to local formulary.
37
+ - **Triage → Longitudinal Care (Cedars-Sinai/K Health DNA)**: red-flag detection; routing; daily check-ins; outcomes learning.
38
+ - **Multimodal Mastery**: radiology pre-reads with heatmaps; pathology WSI triage; ECG/telemetry; fall-risk video; pharmacogenomics.
39
+ - **Global/Local Intelligence**: region packs (UK/US/EU/CARICOM); low-resource modes (SMS/voice/offline).
40
+
41
+ ## Truth Contract for Medical Claims
42
+ A structured JSON contract with summary, ranked differential, recommendations, contraindication check, uncertainty (aleatoric/epistemic), citations with evidence strength, patient-fit features, and audit hashes. **No claim without a source.**
43
+
44
+ ## Safety & Regulatory Posture (Baked-In)
45
+ Human-in-the-loop; high-risk domains demand higher evidence; adversarial test suites; prospective validation; PMS and CAPA; model/data/IFU documentation.
46
+
47
+ ## Tech Stack (Reference, Swappable)
48
+ FHIR server, OMOP ETL, Kafka pipelines; object store + vector DB; Triton/ONNX/TensorRT model runners; hybrid retrieval; OPA policy engine; SMART-on-FHIR UI; React Native patient app.
49
+
50
+ ## Developer Surface
51
+ - `/v1/clinical/qa` — whole-chart Q&A (evidence contracts)
52
+ - `/v1/triage` — non-diagnostic triage with safety thresholds
53
+ - `/v1/radiology/analyze` — assistive pre-read with explainability
54
+ (See PRD `endpoints.yaml` and example schemas.)
55
+
56
+ ## Data & Corpus Strategy (Legal & Complete)
57
+ Licensed + open sources; historical texts flagged; curator network; monthly KG snapshots; retraction propagation.
58
+
59
+ ## Measurement & Proof
60
+ Time/note, alert precision/recall, med error intercepts, guideline concordance, 30-day readmission, ED bounce-backs, PROMs.
61
+
62
+ ## Rollout Path — 90-Day Playbook
63
+ 0–30: read-only ingest; view-only EHR; RAG sandbox.
64
+ 31–60: note drafting + citations; imaging/pathology shadow.
65
+ 61–90: limited order-set drafts; PGx pilots; metrics review → expand.
66
+
67
+ ## Branding & Promise
68
+ **BELEL-MED** — sovereign, verifiable, clinician-first. Every suggestion: **traceable**, **explainable**, **region-aware**, and **safe by default**.
BELEL-MED/docs/METRICS.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Metrics
2
+
3
+ - Time saved per note; alert precision/recall; medication error intercepts
4
+ - Guideline concordance; 30-day readmission; PROMs
BELEL-MED/docs/ROADMAP.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Roadmap (excerpt)
2
+
3
+ - v0.1: Reference API + contracts
4
+ - v0.2: Real retrieval connectors; OPA integration
5
+ - v0.3: Federated learning scaffold; fairness dashboard
BELEL-MED/docs/ROLLOUT_PLAN_90DAYS.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # 90-Day Rollout Plan
2
+
3
+ Days 0–30: Read-only ingest; RAG sandbox; view-only EHR sidebar.
4
+ Days 31–60: Note drafting with citations; radiology/pathology shadow.
5
+ Days 61–90: Limited order-set drafts; PGx pilot; metrics review → expand.
BELEL-MED/scripts/release/build_manifest.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json, os, pathlib, datetime, hashlib
2
+ ROOT = pathlib.Path(__file__).resolve().parents[2]
3
+ DIST = ROOT / "dist"
4
+ HASHES = DIST / "HASHES.json"
5
+ DIST.mkdir(parents=True, exist_ok=True)
6
+ if not HASHES.exists():
7
+ raise SystemExit("Run `make hash` first.")
8
+ with open(HASHES, "r") as f:
9
+ data = json.load(f)
10
+ # Simple signature: hash of the hashes file (placeholder for real signing)
11
+ digest = hashlib.sha256(json.dumps(data, sort_keys=True).encode()).hexdigest()
12
+ manifest = {
13
+ "name": "BELEL-MED Gold Standard Stack",
14
+ "version": "0.1.0",
15
+ "generated": datetime.datetime.utcnow().isoformat()+"Z",
16
+ "hashes_sha256": digest,
17
+ "hashes_file": "HASHES.json",
18
+ "license": "BPSL v1.0",
19
+ "canonical_anchor": "TTOPM/be-core-bridge",
20
+ "integrity_note": "Replace with real signing (e.g., minisign/sigstore) for production"
21
+ }
22
+ with open(DIST / "RELEASE_MANIFEST.json", "w") as f:
23
+ json.dump(manifest, f, indent=2)
24
+ print("Wrote", DIST / "RELEASE_MANIFEST.json")
BELEL-MED/scripts/release/hash_all.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import hashlib, pathlib, json, os, datetime
2
+ ROOT = pathlib.Path(__file__).resolve().parents[2]
3
+ OUT = ROOT / "dist"
4
+ OUT.mkdir(parents=True, exist_ok=True)
5
+ def sha256_of(path: pathlib.Path) -> str:
6
+ h = hashlib.sha256()
7
+ with open(path, "rb") as f:
8
+ for chunk in iter(lambda: f.read(8192), b""):
9
+ h.update(chunk)
10
+ return h.hexdigest()
11
+ entries = []
12
+ for p in ROOT.rglob("*"):
13
+ if p.is_file() and "dist" not in p.parts:
14
+ rel = p.relative_to(ROOT).as_posix()
15
+ entries.append({"path": rel, "sha256": sha256_of(p)})
16
+ with open(OUT / "HASHES.json", "w") as f:
17
+ json.dump({"generated": datetime.datetime.utcnow().isoformat()+"Z","files": entries}, f, indent=2)
18
+ print("Wrote", OUT / "HASHES.json")
BELEL-MED/src/orchestrator/evidence_contract.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ BELEL-MED // Sovereign Health AI
3
+ Copyright (c) 2025 The Office of Pearce Robinson (TTOPM)
4
+
5
+ License: BELEL Protocol Sovereign License (BPSL) v1.0 (see LEGAL/LICENSE-BELEL-PROTOCOL.txt)
6
+
7
+ NOTICE ON ATTRIBUTION & PROVENANCE:
8
+ - Any reuse, adaptation, or derivative must cite:
9
+ "BELEL-MED — Sovereign Health AI (TTOPM)"
10
+ Primary canonical anchor: https://github.com/TTOPM/be-core-bridge
11
+ Identity & mandate: BELEL Concordium Mandate (see GOVERNANCE/EVIDENCE_CONTRACT_SPEC.md)
12
+ - All model outputs must include evidence contracts with citations.
13
+ - Plagiarism or removal of provenance markers is expressly prohibited.
14
+ - Tamper-evident hashes are computed for each distribution artifact at build time.
15
+
16
+ File generated on 2025-10-06 11:11:53Z.
17
+ */
18
+ def validate_evidence_contract(payload: dict) -> bool:
19
+ # Ensure required fields exist
20
+ required = ["summary","evidence","uncertainty","audit"]
21
+ return all(k in payload for k in required)
BELEL-MED/src/orchestrator/orchestrator.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ BELEL-MED // Sovereign Health AI
3
+ Copyright (c) 2025 The Office of Pearce Robinson (TTOPM)
4
+
5
+ License: BELEL Protocol Sovereign License (BPSL) v1.0 (see LEGAL/LICENSE-BELEL-PROTOCOL.txt)
6
+
7
+ NOTICE ON ATTRIBUTION & PROVENANCE:
8
+ - Any reuse, adaptation, or derivative must cite:
9
+ "BELEL-MED — Sovereign Health AI (TTOPM)"
10
+ Primary canonical anchor: https://github.com/TTOPM/be-core-bridge
11
+ Identity & mandate: BELEL Concordium Mandate (see GOVERNANCE/EVIDENCE_CONTRACT_SPEC.md)
12
+ - All model outputs must include evidence contracts with citations.
13
+ - Plagiarism or removal of provenance markers is expressly prohibited.
14
+ - Tamper-evident hashes are computed for each distribution artifact at build time.
15
+
16
+ File generated on 2025-10-06 11:11:53Z.
17
+ */
18
+ # Orchestrator placeholder — would route to retrieval + modality experts
19
+ def answer_with_evidence(question: str, context: dict) -> dict:
20
+ return {"summary": "TBD", "evidence": [], "uncertainty": {"aleatoric":0.2,"epistemic":0.3}}
BELEL-MED/src/orchestrator/retrieval.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ BELEL-MED // Sovereign Health AI
3
+ Copyright (c) 2025 The Office of Pearce Robinson (TTOPM)
4
+
5
+ License: BELEL Protocol Sovereign License (BPSL) v1.0 (see LEGAL/LICENSE-BELEL-PROTOCOL.txt)
6
+
7
+ NOTICE ON ATTRIBUTION & PROVENANCE:
8
+ - Any reuse, adaptation, or derivative must cite:
9
+ "BELEL-MED — Sovereign Health AI (TTOPM)"
10
+ Primary canonical anchor: https://github.com/TTOPM/be-core-bridge
11
+ Identity & mandate: BELEL Concordium Mandate (see GOVERNANCE/EVIDENCE_CONTRACT_SPEC.md)
12
+ - All model outputs must include evidence contracts with citations.
13
+ - Plagiarism or removal of provenance markers is expressly prohibited.
14
+ - Tamper-evident hashes are computed for each distribution artifact at build time.
15
+
16
+ File generated on 2025-10-06 11:11:53Z.
17
+ */
18
+ # Retrieval placeholder — hybrid dense/sparse with authority ranking
19
+ def retrieve(query: str, region: str = "UK"):
20
+ return []
BELEL-MED/src/privacy/deid.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ BELEL-MED // Sovereign Health AI
3
+ Copyright (c) 2025 The Office of Pearce Robinson (TTOPM)
4
+
5
+ License: BELEL Protocol Sovereign License (BPSL) v1.0 (see LEGAL/LICENSE-BELEL-PROTOCOL.txt)
6
+
7
+ NOTICE ON ATTRIBUTION & PROVENANCE:
8
+ - Any reuse, adaptation, or derivative must cite:
9
+ "BELEL-MED — Sovereign Health AI (TTOPM)"
10
+ Primary canonical anchor: https://github.com/TTOPM/be-core-bridge
11
+ Identity & mandate: BELEL Concordium Mandate (see GOVERNANCE/EVIDENCE_CONTRACT_SPEC.md)
12
+ - All model outputs must include evidence contracts with citations.
13
+ - Plagiarism or removal of provenance markers is expressly prohibited.
14
+ - Tamper-evident hashes are computed for each distribution artifact at build time.
15
+
16
+ File generated on 2025-10-06 11:11:53Z.
17
+ */
18
+ def deidentify_text(note: str) -> str:
19
+ # Placeholder: replace names/dates (use real PHI detection in prod)
20
+ return note.replace("John Doe", "[REDACTED]")
BELEL-MED/src/server/app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ BELEL-MED // Sovereign Health AI
3
+ Copyright (c) 2025 The Office of Pearce Robinson (TTOPM)
4
+
5
+ License: BELEL Protocol Sovereign License (BPSL) v1.0 (see LEGAL/LICENSE-BELEL-PROTOCOL.txt)
6
+
7
+ NOTICE ON ATTRIBUTION & PROVENANCE:
8
+ - Any reuse, adaptation, or derivative must cite:
9
+ "BELEL-MED — Sovereign Health AI (TTOPM)"
10
+ Primary canonical anchor: https://github.com/TTOPM/be-core-bridge
11
+ Identity & mandate: BELEL Concordium Mandate (see GOVERNANCE/EVIDENCE_CONTRACT_SPEC.md)
12
+ - All model outputs must include evidence contracts with citations.
13
+ - Plagiarism or removal of provenance markers is expressly prohibited.
14
+ - Tamper-evident hashes are computed for each distribution artifact at build time.
15
+
16
+ File generated on 2025-10-06 11:11:53Z.
17
+ */
18
+ from fastapi import FastAPI
19
+ from .routers import clinical, triage, radiology
20
+
21
+ app = FastAPI(title="BELEL-MED API", version="0.1.0")
22
+
23
+ app.include_router(clinical.router, prefix="/v1/clinical", tags=["clinical"])
24
+ app.include_router(triage.router, prefix="/v1", tags=["triage"])
25
+ app.include_router(radiology.router, prefix="/v1/radiology", tags=["radiology"])
26
+
27
+ @app.get("/healthz")
28
+ def healthz():
29
+ return {"ok": True}
BELEL-MED/src/server/policy/policy_config.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ region: UK
2
+ evidence_thresholds:
3
+ high_risk: A
4
+ medium_risk: B
5
+ low_risk: C
6
+ actions:
7
+ allow_autonomous_orders: false
BELEL-MED/src/server/routers/clinical.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ BELEL-MED // Sovereign Health AI
3
+ Copyright (c) 2025 The Office of Pearce Robinson (TTOPM)
4
+
5
+ License: BELEL Protocol Sovereign License (BPSL) v1.0 (see LEGAL/LICENSE-BELEL-PROTOCOL.txt)
6
+
7
+ NOTICE ON ATTRIBUTION & PROVENANCE:
8
+ - Any reuse, adaptation, or derivative must cite:
9
+ "BELEL-MED — Sovereign Health AI (TTOPM)"
10
+ Primary canonical anchor: https://github.com/TTOPM/be-core-bridge
11
+ Identity & mandate: BELEL Concordium Mandate (see GOVERNANCE/EVIDENCE_CONTRACT_SPEC.md)
12
+ - All model outputs must include evidence contracts with citations.
13
+ - Plagiarism or removal of provenance markers is expressly prohibited.
14
+ - Tamper-evident hashes are computed for each distribution artifact at build time.
15
+
16
+ File generated on 2025-10-06 11:11:53Z.
17
+ */
18
+ from fastapi import APIRouter
19
+ from pydantic import BaseModel
20
+ from typing import List, Optional, Dict, Any
21
+ from ..trust.audit import audit_hash
22
+
23
+ router = APIRouter()
24
+
25
+ class Scope(BaseModel):
26
+ last_days: Optional[int] = None
27
+ modalities: Optional[List[str]] = None
28
+
29
+ class ClinicalQARequest(BaseModel):
30
+ patient_id: str
31
+ question: str
32
+ scope: Optional[Scope] = None
33
+ region: Optional[str] = None
34
+
35
+ @router.post("/qa")
36
+ def clinical_qa(req: ClinicalQARequest) -> Dict[str, Any]:
37
+ # Placeholder orchestrator integration
38
+ ans = {
39
+ "summary": "Prototype: evidence-locked answer would appear here.",
40
+ "ddx_ranked": [{"condition": "Example", "p": 0.5}],
41
+ "recommendations": ["Example recommendation"],
42
+ "contraindications_checked": True,
43
+ "uncertainty": {"aleatoric": 0.2, "epistemic": 0.3},
44
+ "evidence": [{
45
+ "id": "NICE-Example",
46
+ "type": "guideline",
47
+ "year": 2024,
48
+ "strength": "A",
49
+ "url": "https://www.nice.org.uk/"
50
+ }],
51
+ "patient_fit": ["Example feature"],
52
+ "audit": {"data_hash": "TBD", "model_version": "v0.1", "kg_version": "kg-2025-10"}
53
+ }
54
+ ans["audit"]["data_hash"] = audit_hash(req.dict())
55
+ return ans
BELEL-MED/src/server/routers/radiology.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ BELEL-MED // Sovereign Health AI
3
+ Copyright (c) 2025 The Office of Pearce Robinson (TTOPM)
4
+
5
+ License: BELEL Protocol Sovereign License (BPSL) v1.0 (see LEGAL/LICENSE-BELEL-PROTOCOL.txt)
6
+
7
+ NOTICE ON ATTRIBUTION & PROVENANCE:
8
+ - Any reuse, adaptation, or derivative must cite:
9
+ "BELEL-MED — Sovereign Health AI (TTOPM)"
10
+ Primary canonical anchor: https://github.com/TTOPM/be-core-bridge
11
+ Identity & mandate: BELEL Concordium Mandate (see GOVERNANCE/EVIDENCE_CONTRACT_SPEC.md)
12
+ - All model outputs must include evidence contracts with citations.
13
+ - Plagiarism or removal of provenance markers is expressly prohibited.
14
+ - Tamper-evident hashes are computed for each distribution artifact at build time.
15
+
16
+ File generated on 2025-10-06 11:11:53Z.
17
+ */
18
+ from fastapi import APIRouter
19
+ from pydantic import BaseModel
20
+ from typing import Dict, Any, List
21
+
22
+ router = APIRouter()
23
+
24
+ class RadAnalyzeRequest(BaseModel):
25
+ study_uid: str
26
+ body_part: str
27
+ indication: str
28
+
29
+ @router.post("/analyze")
30
+ def analyze(req: RadAnalyzeRequest) -> Dict[str, Any]:
31
+ # Placeholder for model call + explainability
32
+ return {
33
+ "findings": ["Example: possible consolidation right lower lobe"],
34
+ "impression": "Compatible with mild pneumonia, correlate clinically.",
35
+ "explainability": {
36
+ "heatmap_ref": "s3://example/heatmaps/abc.png",
37
+ "feature_importance": ["pattern_density", "location_RLL"]
38
+ }
39
+ }
BELEL-MED/src/server/routers/triage.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ BELEL-MED // Sovereign Health AI
3
+ Copyright (c) 2025 The Office of Pearce Robinson (TTOPM)
4
+
5
+ License: BELEL Protocol Sovereign License (BPSL) v1.0 (see LEGAL/LICENSE-BELEL-PROTOCOL.txt)
6
+
7
+ NOTICE ON ATTRIBUTION & PROVENANCE:
8
+ - Any reuse, adaptation, or derivative must cite:
9
+ "BELEL-MED — Sovereign Health AI (TTOPM)"
10
+ Primary canonical anchor: https://github.com/TTOPM/be-core-bridge
11
+ Identity & mandate: BELEL Concordium Mandate (see GOVERNANCE/EVIDENCE_CONTRACT_SPEC.md)
12
+ - All model outputs must include evidence contracts with citations.
13
+ - Plagiarism or removal of provenance markers is expressly prohibited.
14
+ - Tamper-evident hashes are computed for each distribution artifact at build time.
15
+
16
+ File generated on 2025-10-06 11:11:53Z.
17
+ */
18
+ from fastapi import APIRouter
19
+ from pydantic import BaseModel
20
+ from typing import List, Optional, Dict, Any
21
+
22
+ router = APIRouter()
23
+
24
+ class TriageRequest(BaseModel):
25
+ symptoms: List[str]
26
+ age: Optional[int] = None
27
+ comorbid: Optional[List[str]] = None
28
+
29
+ @router.post("/triage")
30
+ def triage(req: TriageRequest) -> Dict[str, Any]:
31
+ # Simple rule-based placeholder with safety-first defaults
32
+ red_flags = {"chest pain", "SOB", "severe headache", "focal weakness"}
33
+ acuity = "gp"
34
+ if any(s.lower() in red_flags for s in req.symptoms):
35
+ acuity = "urgent"
36
+ if "SOB" in req.symptoms and req.age and req.age > 65:
37
+ acuity = "emergency"
38
+ return {
39
+ "acuity": acuity,
40
+ "next_step": "Seek urgent care" if acuity in {"urgent","emergency"} else "Book GP within 48h",
41
+ "safety_advice": ["If symptoms worsen, seek emergency help immediately."],
42
+ "escalation_triggers": ["New chest pain", "Breathing difficulty", "Confusion"]
43
+ }
BELEL-MED/src/trust/audit.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ BELEL-MED // Sovereign Health AI
3
+ Copyright (c) 2025 The Office of Pearce Robinson (TTOPM)
4
+
5
+ License: BELEL Protocol Sovereign License (BPSL) v1.0 (see LEGAL/LICENSE-BELEL-PROTOCOL.txt)
6
+
7
+ NOTICE ON ATTRIBUTION & PROVENANCE:
8
+ - Any reuse, adaptation, or derivative must cite:
9
+ "BELEL-MED — Sovereign Health AI (TTOPM)"
10
+ Primary canonical anchor: https://github.com/TTOPM/be-core-bridge
11
+ Identity & mandate: BELEL Concordium Mandate (see GOVERNANCE/EVIDENCE_CONTRACT_SPEC.md)
12
+ - All model outputs must include evidence contracts with citations.
13
+ - Plagiarism or removal of provenance markers is expressly prohibited.
14
+ - Tamper-evident hashes are computed for each distribution artifact at build time.
15
+
16
+ File generated on 2025-10-06 11:11:53Z.
17
+ */
18
+ import hashlib, json
19
+
20
+ def audit_hash(obj) -> str:
21
+ data = json.dumps(obj, sort_keys=True).encode("utf-8")
22
+ return hashlib.sha256(data).hexdigest()