someonesphantom commited on
Commit
ba1b2eb
Β·
1 Parent(s): ac6eeec

added docs links in readme

Browse files
Files changed (3) hide show
  1. README.md +57 -1
  2. plans/LEGAL_SOURCES.md +236 -0
  3. scripts/fetch_data.sh +109 -0
README.md CHANGED
@@ -46,10 +46,66 @@ Andrej Karpathy's LLM Wiki pattern solves this by having the AI maintain a struc
46
  | Layer | What it stores | Why |
47
  |---|---|---|
48
  | **LLM Wiki** | Patient histories, drug profiles, clinical protocols, SOPs | Evolving knowledge that needs to stay current and cross-referenced |
49
- | **Vector + BM25 RAG** | ICD-10 codes (95,000+), drug formulary, DSM-5 | Too large for the wiki; needs keyword-precise lookup |
50
  | **PostgreSQL** | Appointments, lab results, roster history | Structured data that is better queried with SQL |
51
  | **LangGraph State** | Current session data | In-memory working context for the active workflow |
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  ---
54
 
55
  ## Recommended LLMs (Free, ≀ 32B Parameters)
 
46
  | Layer | What it stores | Why |
47
  |---|---|---|
48
  | **LLM Wiki** | Patient histories, drug profiles, clinical protocols, SOPs | Evolving knowledge that needs to stay current and cross-referenced |
49
+ | **Vector + BM25 RAG** | ICD-10 / ICD-10-CM codes (74,000+), National Formulary of India, openFDA drug labels, SNOMED CT India Edition (incl. mental-health classifications via ICD-10 Chapter V) | Too large for the wiki; needs keyword-precise lookup |
50
  | **PostgreSQL** | Appointments, lab results, roster history | Structured data that is better queried with SQL |
51
  | **LangGraph State** | Current session data | In-memory working context for the active workflow |
52
 
53
+ > **Note on DSM-5:** an earlier draft referenced DSM-5 here. APA copyright forbids ingesting DSM content into generative AI without a paid licence. We use **ICD-10 Chapter V (F00–F99) / ICD-11 Chapter 06** for mental-health classification instead, which are WHO-licensed and free. See [`plans/LEGAL_SOURCES.md`](plans/LEGAL_SOURCES.md) for the full rationale and the "do-not-upload" list.
54
+
55
+ ---
56
+
57
+ ## Knowledge Sources (Verified, Licensed, Local)
58
+
59
+ Every document below is **legally redistributable for our use** and has been downloaded and integrity-checked. Run `bash scripts/fetch_data.sh` on a fresh clone to pull all of them into `data/` (gitignored β€” distributed via a shared bucket, not git). For licensing rationale and the "do-not-upload" list, see [`plans/LEGAL_SOURCES.md`](plans/LEGAL_SOURCES.md).
60
+
61
+ ### Classifications (BM25 + Chroma index)
62
+
63
+ | Source | Local path | Size / Scope | Licence |
64
+ |---|---|---|---|
65
+ | **WHO ICD-10 2019 International** (ClaML XML) | `data/icd10/icd102019en.xml` | 9.1 MB Β· **11,243 category codes** | WHO classification β€” free with attribution |
66
+ | **CDC ICD-10-CM FY2026** (US clinical modification, billing-granular) | `data/icd10/icd10cm_2026/icd10cm-codes-2026.txt` | 6.1 MB Β· **74,719 codes** | US Government β€” public domain |
67
+ | **WHO ICD-10-CM tabular index 2026** | `data/icd10/icd10cm_2026/icd10cm-order-2026.txt` | 14 MB | US Government β€” public domain |
68
+ | **WHO ICD-11 license & terms** | `data/legal/icd11-license.pdf` | 5 pg | CC BY-ND 3.0 IGO β€” commercial use + AI training explicitly permitted |
69
+ | **SNOMED CT India Edition** | _(manual fetch β€” apply at [NRCeS](https://mlds.ihtsdotools.org/#/landing/IN))_ | full international + India drug extension | Free in India (member country) |
70
+
71
+ ### Indian clinical guidelines (LLM Wiki synthesis sources)
72
+
73
+ | Source | Local path | Pages | Used for |
74
+ |---|---|---|---|
75
+ | **MoHFW β€” Standard Treatment Guidelines: Hypertension** | `data/mohfw/Hypertension_full.pdf` | **152** | Hypertension wiki page (Week 1 seed) |
76
+ | **ICMR β€” Type-1 Diabetes Management Guidelines** | `data/icmr/type1_diabetes.pdf` | **173** | T1D wiki page |
77
+ | **ICMR β€” Type-2 Diabetes Guidelines 2018** | `data/icmr/type2_diabetes_2018.pdf` | **82** | T2D wiki page (Week 1 seed) |
78
+ | **ICMR β€” Treatment Guidelines for Antimicrobial Use in Common Syndromes 2022** | `data/icmr/amr_treatment_2022_full.pdf` | **168** | CAP / UTI / sepsis / skin / CNS / GI infection pages |
79
+ | **ICMR β€” Diagnosis & Management of Carbapenem-Resistant Organisms 2022** | `data/icmr/cro_diagnosis_2022.pdf` | **24** | AMR escalation logic, handover red flags |
80
+ | **ICMR β€” Standard Treatment Workflows Vol 3 (2022)** | `data/icmr/stw_vol3_2022.pdf` | **80** | Broad cross-condition workflows |
81
+ | **AIIMS Rishikesh β€” Standard Treatment Guidelines Manual** | `data/mohfw/aiims_rishikesh_stg.pdf` | **431** | Cross-specialty reference; back-stop when ICMR is silent |
82
+
83
+ > **Wiki authorship rule:** these PDFs are *synthesis sources*, not the wiki. You **paraphrase + cite** them in markdown pages under `wiki/`. Never paste paragraphs verbatim β€” that's a derivative work and inherits any restrictions on the source. Citations go in each page's frontmatter (`source:` field β€” see [`wiki/README.md`](wiki/README.md)).
84
+
85
+ ### Drug data
86
+
87
+ | Source | Local path | Scope | Licence |
88
+ |---|---|---|---|
89
+ | **National Formulary of India, 5th edn (2016)** | `data/nfi/NFI_2016.pdf` | 60 pg excerpt (full edn via IPC on request) | Government of India β€” open |
90
+ | **WHO Model List of Essential Medicines, 23rd edn (2023)** | `data/who/WHO_EML_23_2023.pdf` | 71 pg Β· ~600 medicines | CC BY-NC-SA 3.0 IGO (re-license for commercial) |
91
+ | **openFDA drug label sample** (live API) | `data/openfda/amlodipine_sample.json` | 238 amlodipine label hits | US Gov β€” public domain |
92
+ | **RxNorm / Loinc / WHO ATC** | _(manual β€” see `scripts/fetch_data.sh`)_ | optional cross-mapping | Free with attribution |
93
+
94
+ ### Total today
95
+
96
+ **~91 MB Β· 14 files Β· 1,521 pages of guideline PDFs Β· 85,962 ICD codes ready to index.**
97
+
98
+ ### What we deliberately did NOT download
99
+
100
+ - ❌ **DSM-5 / DSM-5-TR** β€” APA all-rights-reserved; explicitly forbidden in generative AI without paid licence
101
+ - ❌ **British National Formulary (BNF)** β€” proprietary
102
+ - ❌ **NICE guidelines** β€” UK Open Content Licence is UK-only; international use needs a fee
103
+ - ❌ **MIMS India / CIMS** β€” paid commercial
104
+ - ❌ Any medical textbook (Harrison's, Davidson's, Robbins, KDT, etc.) β€” copyrighted
105
+ - ❌ UpToDate / DynaMed / BMJ Best Practice β€” subscription proprietary
106
+
107
+ See [`plans/LEGAL_SOURCES.md`](plans/LEGAL_SOURCES.md) for the full rationale and replacement strategy.
108
+
109
  ---
110
 
111
  ## Recommended LLMs (Free, ≀ 32B Parameters)
plans/LEGAL_SOURCES.md ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CliniqAI β€” Legal Source Catalog for RAG and the LLM Wiki
2
+
3
+ > What you can upload, what you must license first, and what you must never upload. Verified May 2026.
4
+
5
+ This document is the **legal gate** on every document that enters CliniqAI's knowledge layers. Read it before ingesting anything.
6
+
7
+ > ⚠️ **One-line summary:** Use **ICD-10/ICD-11 from WHO**, **SNOMED CT via NRCeS India** (free for India members), **ICMR guidelines**, **WHO guidelines**, **National Formulary of India** and **CDSCO** for everything Indian-context. **Do NOT** ingest **DSM-5**, **British National Formulary (BNF)**, **NICE guidelines** (outside UK), or any **proprietary drug database** without a paid commercial license. **Do NOT** put any real patient data into the repo or send it to a third-party LLM without DPDPA-compliant consent.
8
+
9
+ ---
10
+
11
+ ## 1. Architecture recap β€” what each layer needs
12
+
13
+ From the README:
14
+
15
+ | Layer | What it stores | What you actually upload |
16
+ |---|---|---|
17
+ | **LLM Wiki** | Patient histories, drug profiles, clinical protocols, SOPs | Markdown pages you (or the Wiki Maintenance Agent) author and update β€” synthesised from licensed sources |
18
+ | **Vector + BM25 RAG** | ICD-10 (95,000+), drug formulary, DSM-5 *(see Β§6 β€” replace this)* | The raw classification CSVs / TXT files indexed once at ingestion |
19
+ | **PostgreSQL** | Appointments, lab results, roster history | Operational data only; not a clinical knowledge source |
20
+ | **LangGraph State** | Current session | In-memory only |
21
+
22
+ So there are **three classes of documents** to track:
23
+
24
+ 1. **Reference data** (ICD, drug formulary, ATC codes) β†’ flat-file ingestion into BM25 + Chroma
25
+ 2. **Clinical guidelines** (ICMR, WHO, professional society documents) β†’ synthesised by you into condition/drug wiki pages with citations
26
+ 3. **Patient data** β†’ DPDPA-governed, never in repo, encrypted at rest, consent-tracked
27
+
28
+ ---
29
+
30
+ ## 2. Reference data β€” what's safe to ingest into BM25 + Chroma
31
+
32
+ | Source | License | Cost | Commercial use | What to upload | Attribution |
33
+ |---|---|---|---|---|---|
34
+ | **ICD-10** (WHO) | WHO classification, freely available for use; treat as **WHO IP, free attribution-required** | Free | βœ… Yes | The full ICD-10 tabular list (chapters I–XXII). Source: `icd.who.int/browse10`. **For India use the ICD-10 base** β€” the US-specific `ICD-10-CM` is a US clinical modification published by CDC/NCHS (also free). | Cite WHO in the wiki page header and on every UI surface that surfaces a code. |
35
+ | **ICD-11** (WHO) | **CC BY-ND 3.0 IGO** β€” explicitly permits commercial use, clinical decision support, AI training | Free | βœ… Yes β€” explicitly permitted | Foundation Component + Mortality and Morbidity Statistics linearization. Source: `icd.who.int/browse11`. | **Mandatory citation:** "International Classification of Diseases, Eleventh Revision (ICD-11), World Health Organization (WHO) 2019/2021. Licensed under CC BY-ND 3.0 IGO." May **not** state or imply WHO endorses CliniqAI, and may **not** make "adaptations" (you can copy and search, you can't create a derivative classification). |
36
+ | **SNOMED CT β€” India Edition** | India is a SNOMED CT Member (since 2014); affiliate license is **free for use within India** via NRCeS | Free in India | βœ… Yes (within India) | Apply for an **Affiliate License** at `mlds.ihtsdotools.org/#/landing/IN` (or via `nrces.in`). Download the SNOMED CT International Edition + the India Edition + the India Drug Extension. | Display the SNOMED CT affiliate notice in your About page. Re-license terms apply when going outside India β€” handle at internationalisation time. |
37
+ | **WHO ATC/DDD Index** (drug classification) | Owned by WHO Collaborating Centre for Drug Statistics Methodology; free for personal/research use; **fee for commercial use** | Free non-commercial / fee commercial | Mixed β€” **request a license** before production | Use the classification *codes* (which are free as factual data) but do **not** redistribute the full WHOCC database commercially without a license. | Request at `whocc.no/atc_ddd_index/license/`. |
38
+ | **WHO Model List of Essential Medicines** | CC BY-NC-SA 3.0 IGO (verify on current PDF) | Free | ⚠️ Non-commercial β€” fine for an MVP / open-source; **revisit when monetising** | Latest list as PDF/JSON. Source: `who.int/publications`. | Cite WHO; if you go commercial, get permission. |
39
+ | **National Formulary of India (NFI)** | Published by Indian Pharmacopoeia Commission (IPC), Ministry of Health & Family Welfare, GoI | Free (PDF) | βœ… Generally yes (government work) β€” cite source | NFI 5th Edition 2016 β€” 521 drug monographs. Source: NHP `nhp.gov.in/national-formulary-of-india_mtl`. | Cite "National Formulary of India (NFI), 5th edn, 2016, Indian Pharmacopoeia Commission". |
40
+ | **CDSCO approved-drugs database** | Government of India open data | Free | βœ… Yes | Approved new drugs CSV from `cdsco.gov.in/opencms/opencms/en/Data-Bank/`. | Cite CDSCO; note the date of snapshot. |
41
+ | **RxNorm** (US National Library of Medicine) | Public-domain US government data | Free | βœ… Yes | Useful for cross-mapping Indian generics to international names. Source: `nlm.nih.gov/research/umls/rxnorm`. | Cite NLM. |
42
+ | **openFDA drug labelling** | Public domain US government data | Free | βœ… Yes | Drug interactions / contraindications from US FDA labels. Source: `open.fda.gov`. | Cite openFDA. |
43
+ | **Loinc** (lab codes) | Loinc license β€” free for any use including commercial, with attribution | Free | βœ… Yes | Useful if you parse lab reports. Source: `loinc.org`. | Cite Regenstrief Institute. |
44
+
45
+ ### Practical first-week ingestion bundle (Person A β€” Day 1)
46
+
47
+ Download and check into a `data/` folder (gitignored β€” see `.gitignore`):
48
+
49
+ ```
50
+ data/icd10/ icdClaML.xml or tab-delim # WHO ICD-10 base, English
51
+ data/icd11/ foundation.json + mms.json # WHO ICD-11 API export
52
+ data/snomed/ SnomedCT_IndiaRelease_*.zip # NRCeS affiliate distribution
53
+ data/nfi/ NFI_2016.pdf + extracted.json # parse once to JSON
54
+ data/atc/ atc_2025.csv # free for research; license for prod
55
+ data/rxnorm/ RxNorm_full_*.zip # US NLM
56
+ data/loinc/ Loinc_*.zip # Regenstrief
57
+ ```
58
+
59
+ `data/` is gitignored. The first-time ingestion CLI (`python -m app.retrieval.chroma_index ingest --root data/`) builds the Chroma + BM25 indices into `chroma_db/` (also gitignored). The team distributes the indices via a shared bucket, not git.
60
+
61
+ ---
62
+
63
+ ## 3. Clinical guidelines β€” what to read, synthesise, and cite
64
+
65
+ The wiki is *your* synthesis of these. You do not copy them verbatim β€” you summarise, paraphrase, and cite. This is normal fair-use clinical content authorship.
66
+
67
+ | Source | License | Cost | Use in wiki | Caveat |
68
+ |---|---|---|---|---|
69
+ | **ICMR guidelines** (Indian Council of Medical Research) | India government work; freely available on `icmr.gov.in/guidelines`. Treat as Government Open Data β€” paraphrase + cite. | Free | βœ… Primary source for India-specific clinical practice. | Cite ICMR + publication year + the specific document. |
70
+ | **WHO clinical guidelines** | Typically CC BY-NC-SA 3.0 IGO on individual PDFs (verify each cover page) | Free | βœ… With NC restriction β€” fine for MVP; relicense or paraphrase for commercial product | Always check the inside-front-cover license block of the specific PDF. |
71
+ | **AIIMS / PGIMER / Indian society guidelines** (Cardiological Society of India, API, ESI, etc.) | Usually free PDFs; copyright varies | Free (web) | βœ… Paraphrase + cite. **Do not redistribute the PDF verbatim.** | Get the specific journal's reuse terms when in doubt. |
72
+ | **Open-access PMC / PubMed Central articles** | CC BY, CC BY-NC, or CC BY-NC-SA per article (check each) | Free | βœ… Read freely, cite, paraphrase β€” never copy paragraphs into the wiki | The article-level license appears on the PMC page. |
73
+ | **NICE guidelines (UK)** | **NICE UK Open Content Licence β€” free in UK only.** International use (which includes India) requires a fee and a license agreement. Plus, BNF and Clinical Knowledge Summaries inside NICE are third-party content NOT covered by the license. | Fee for India | ⚠️ Do not ingest NICE PDFs into the wiki. You may reference NICE's recommendations by name and link, but do not synthesise NICE content into wiki pages without a NICE international licence. | Use ICMR / WHO equivalents instead. |
74
+ | **British National Formulary (BNF)** | Proprietary (Pharmaceutical Press / RPS); not covered by NICE's open licence even on the NICE site | Paid | ❌ Do not ingest. | Use **National Formulary of India** instead. |
75
+ | **DSM-5 / DSM-5-TR** (American Psychiatric Association) | **All rights reserved.** APA explicitly states: "APA content may **not** be input into generative artificial intelligence or any other machine learning tool without written permission from APA." Electronic-product licenses are available but capped at ≀50% of total criteria, with a per-product fee + value-added requirement. | Paid + restrictive | ❌ **Do not ingest.** This is a legal problem for the README's stated scope. | **Replacement:** Use **ICD-10 Chapter V (F00–F99)** "Mental and behavioural disorders" or **ICD-11 Chapter 06** "Mental, behavioural or neurodevelopmental disorders". Both are WHO and legally usable. See Β§6. |
76
+ | **Harrison's, Davidson's, Bates, KDT, etc. β€” medical textbooks** | All rights reserved (Elsevier, McGraw-Hill, etc.) | Paid | ❌ Do not ingest. Do not paste chapters into wiki pages. | Use the underlying guideline (ICMR / WHO) that the textbook cites. |
77
+ | **UpToDate / DynaMed / BMJ Best Practice** | Subscription-only proprietary | Paid | ❌ Do not ingest. | Cite as a clinician's external reference, do not store. |
78
+ | **MIMS India / CIMS / Indian Drug Review** | Proprietary commercial | Paid | ❌ Do not ingest. | Use National Formulary of India + CDSCO. |
79
+ | **DrugBank β€” academic** | Free for academic, paid for commercial | Mixed | ⚠️ Academic version only for non-commercial MVP. Get the commercial license before launch. | Or use RxNorm + openFDA, both free for commercial use. |
80
+ | **Wikipedia clinical articles** | CC BY-SA | Free | ⚠️ Permitted but **not appropriate** as a primary clinical source. Use as a tertiary cross-check only. | If you do quote Wikipedia, the SA clause may force your wiki page to also be CC BY-SA β€” keep wiki-internal authorship as your own writing. |
81
+
82
+ ### Wiki page authorship rules (legal-safe)
83
+
84
+ 1. **Write the page yourself** β€” your wording, your structure. Paraphrase the guideline; do not copy paragraphs.
85
+ 2. **Cite every clinical claim** in the page's frontmatter `source:` field with author + year + URL.
86
+ 3. **Quote sparingly** β€” short direct quotes (≀ 2 sentences) of a guideline are normal fair use; longer passages need a licence.
87
+ 4. **Mark the date** the page was synthesised; the Wiki Maintenance Agent's lint catches stale pages (> 180 days).
88
+ 5. **Never** paste copyrighted text into the wiki and then "ask the LLM to rewrite it." That's a derivative work and inherits the source's license restrictions.
89
+
90
+ ---
91
+
92
+ ## 4. Patient data β€” DPDPA 2023 + DPDP Rules 2025
93
+
94
+ India's Digital Personal Data Protection Act was notified on **13 Nov 2025**. The substantive compliance provisions become enforceable on **13 May 2027** β€” but you should design for them today because the architectural cost of retrofitting later is enormous.
95
+
96
+ ### What DPDPA means concretely for CliniqAI
97
+
98
+ | Obligation | How CliniqAI complies |
99
+ |---|---|
100
+ | **Informed, specific, unambiguous consent** before processing personal health data | Patient onboarding step (Person B) records consent in `messages` / a `consents` table with timestamp, purpose, and version of the notice shown |
101
+ | **Time-stamped consent history** β€” every change (withdrawal, modification, re-consent) is logged | Use an append-only `consent_events` table (add to Person C's Day-10 work) |
102
+ | **Right to access / correction / erasure** | Doctor + admin tab needs a "Patient data export" and "Patient data delete" action; deletes must cascade to ChromaDB and the wiki patient page |
103
+ | **Data localisation for sensitive health data** | Run Postgres + Chroma + wiki files inside an Indian AWS region (ap-south-1 Mumbai or ap-south-2 Hyderabad). Do **not** store patient data in HF Spaces |
104
+ | **Emergency exemption** β€” consent not required for processing during medical emergencies or epidemics | The system may proceed without consent in a flagged emergency, but the event must still be logged for audit |
105
+ | **Children's data** β€” verifiable parental consent (with healthcare exemption for essential services) | If you serve paediatrics, capture guardian identity at booking |
106
+ | **Data Protection Officer** for significant data fiduciaries | Designate a DPO before commercial launch (post-hackathon) |
107
+
108
+ ### Patient data + LLM calls
109
+
110
+ The risky path is sending a patient's identifiable transcript to a third-party LLM API (Groq, OpenRouter). To stay clean:
111
+
112
+ - **De-identify before the call.** Strip name, exact DOB, address, phone, ABHA ID, MRN. Use a stable pseudonymous ID (e.g. `p-001`) inside the prompt.
113
+ - **Track what went where.** Langfuse already traces every call; ensure no raw PHI is in the prompt body β€” only the pseudonymised version.
114
+ - **Offer a local-only mode.** The README's Ollama path (Qwen2.5 32B) is the legal escape hatch for hospitals that refuse third-party processing. Wire this on Day 6 in Person C's roadmap.
115
+ - **Consent for transcription.** Before Whisper runs on an audio file, the doctor confirms verbal consent was obtained from the patient ("This consult will be recorded for AI documentation"). The consent timestamp goes into the `soap_drafts.payload` JSON.
116
+
117
+ ### Audio + transcript retention
118
+
119
+ - **Audio:** delete the file within 24h of the SOAP note being approved. There is no clinical reason to retain it longer; it's the highest-risk artefact.
120
+ - **Transcript:** retain only the `transcript_excerpt` field on the approved `SOAPNoteDraft`, not the full transcript.
121
+ - **Whisper inference:** run on HF inference for now; for production, run Whisper locally on the EC2 backend to keep the audio inside the Indian region.
122
+
123
+ ---
124
+
125
+ ## 5. ABDM / ABHA integration β€” what you must follow when wiring it up
126
+
127
+ Post-hackathon, when CliniqAI connects to ABDM:
128
+
129
+ - ABHA-linked records are subject to the **Health Data Management Policy (HDMP)** of the National Health Authority β€” read it before integrating.
130
+ - Patients must explicitly link their ABHA ID to your hospital via the NHA consent manager; you cannot store an ABHA ID without consent.
131
+ - ABDM-integrated solutions must pass NHA's sandbox certification β€” budget 2–4 weeks for this.
132
+ - You become a **Health Information User (HIU)** or **Health Information Provider (HIP)** depending on direction of flow β€” the certification differs.
133
+
134
+ ---
135
+
136
+ ## 6. README correction β€” DSM-5 cannot stay
137
+
138
+ The current README Β§"How the Knowledge System Works" lists **DSM-5** in the Vector + BM25 RAG layer. **This is not legally usable** without an APA license, and APA explicitly forbids feeding their content into generative AI. Acting on this:
139
+
140
+ **Replace with:** *ICD-10 Chapter V (F00–F99) "Mental and behavioural disorders"* (or ICD-11 Chapter 06). These are WHO classifications, free, and explicitly licensed for AI / clinical decision support use.
141
+
142
+ Suggested README edit (when you're ready to update):
143
+
144
+ ```diff
145
+ - | **Vector + BM25 RAG** | ICD-10 codes (95,000+), drug formulary, DSM-5 | Too large for the wiki; needs keyword-precise lookup |
146
+ + | **Vector + BM25 RAG** | ICD-10/11 codes (incl. Chapter V/06 mental health), National Formulary of India, SNOMED CT India Edition | Too large for the wiki; needs keyword-precise lookup |
147
+ ```
148
+
149
+ ---
150
+
151
+ ## 7. The "Do NOT upload" list β€” pin this to the wall
152
+
153
+ - ❌ DSM-5 / DSM-5-TR (any portion, including diagnostic criteria)
154
+ - ❌ British National Formulary (BNF) and BNFC
155
+ - ❌ NICE guideline PDFs (use outside the UK requires a paid license)
156
+ - ❌ MIMS India / CIMS / Indian Drug Review proprietary content
157
+ - ❌ DrugBank commercial fields without a commercial license
158
+ - ❌ Harrison's, Davidson's, Bates, KDT, Robbins, any copyrighted textbook
159
+ - ❌ UpToDate / DynaMed / BMJ Best Practice
160
+ - ❌ Paywalled journal articles (Elsevier, Wolters Kluwer, etc.)
161
+ - ❌ Any scraped PDF whose copyright statement you have not personally read
162
+ - ❌ Real patient records β€” even "anonymised" ones β€” into the git repo
163
+ - ❌ Real audio recordings into the git repo
164
+
165
+ ---
166
+
167
+ ## 8. The "Safe to upload today" list
168
+
169
+ - βœ… WHO ICD-10 tabular list
170
+ - βœ… WHO ICD-11 foundation + MMS export (CC BY-ND 3.0 IGO)
171
+ - βœ… SNOMED CT India Edition (free for India via NRCeS affiliate)
172
+ - βœ… National Formulary of India (IPC, MoHFW)
173
+ - βœ… CDSCO approved drugs database
174
+ - βœ… RxNorm (US NLM)
175
+ - βœ… openFDA drug labelling
176
+ - βœ… Loinc lab codes
177
+ - βœ… ICMR guidelines (cite + paraphrase)
178
+ - βœ… WHO clinical guidelines (CC BY-NC-SA β€” fine for MVP, paraphrase + cite)
179
+ - βœ… Open-access PMC articles (check article-level CC license; paraphrase + cite)
180
+ - βœ… Synthetic patient data you generate yourself
181
+
182
+ ---
183
+
184
+ ## 9. Citation hygiene β€” what each wiki page must show
185
+
186
+ Every clinical wiki page's frontmatter `source:` field must contain at least:
187
+
188
+ ```yaml
189
+ source:
190
+ - title: "ICMR National Guidelines on Hypertension Management"
191
+ org: "Indian Council of Medical Research"
192
+ year: 2023
193
+ url: "https://icmr.gov.in/guidelines/..."
194
+ licence: "Government of India β€” open access"
195
+ - title: "WHO ICD-10 Online β€” I10 Essential hypertension"
196
+ org: "World Health Organization"
197
+ year: 2024
198
+ url: "https://icd.who.int/browse10/2019/en#/I10"
199
+ licence: "WHO classification β€” free with attribution"
200
+ ```
201
+
202
+ The Wiki Maintenance Agent's lint pass (Person A, Day 8) should fail any page whose `source:` is empty or whose URL returns 404.
203
+
204
+ ---
205
+
206
+ ## 10. Action items (do these before any ingestion)
207
+
208
+ 1. **Apply for SNOMED CT affiliate licence** at `mlds.ihtsdotools.org/#/landing/IN` β€” free, takes ~2 days.
209
+ 2. **Read the ICD-11 license PDF** (`icd.who.int/en/docs/icd11-license.pdf`) and save it to `data/legal/icd11-license.pdf`.
210
+ 3. **Strip DSM-5 from the codebase + README**; replace with ICD-10 Chapter V / ICD-11 Chapter 06.
211
+ 4. **Add `data/` and `chroma_db/` to `.gitignore`** (already done in this repo).
212
+ 5. **Add a `consent_events` table** to the Postgres schema (Person C β€” fold into Day-10 auth/audit work).
213
+ 6. **Write a `CONSENT.md`** describing the patient-facing consent language for transcription and data processing β€” this is what doctors will read aloud during the consult.
214
+ 7. **Pick AWS region** before deploy: ap-south-1 (Mumbai) is the canonical India region for DPDPA-friendly storage.
215
+ 8. **Schedule a DPO designation** for the first commercial customer β€” even if it's a co-founder for now.
216
+
217
+ ---
218
+
219
+ ## 11. Sources
220
+
221
+ - [WHO β€” ICD-11 License (PDF)](https://cdn.who.int/media/docs/default-source/classification/icd/icd11/icd11-license.pdf)
222
+ - [WHO β€” ICD-11 Terms of Use and License Agreement](https://www.who.int/publications/m/item/icd-11-terms-of-use-and-license-agreement)
223
+ - [WHO β€” International Classification of Diseases](https://www.who.int/standards/classifications/classification-of-diseases)
224
+ - [APA β€” Permissions, Licensing, and Reprints (DSM-5)](https://www.appi.org/Support/Customer-Information/Permissions)
225
+ - [Psychiatry Online β€” Copyright (DSM)](https://psychiatryonline.org/copyright)
226
+ - [ICMR β€” Guidelines](https://www.icmr.gov.in/guidelines)
227
+ - [NICE β€” Reusing our content](https://www.nice.org.uk/re-using-our-content)
228
+ - [NICE β€” Use of NICE content in the UK](https://www.nice.org.uk/reusing-our-content/use-of-nice-content-in-the-uk)
229
+ - [NHP India β€” National Formulary of India](https://www.nhp.gov.in/national-formulary-of-india_mtl)
230
+ - [CDSCO β€” Data Bank](https://cdsco.gov.in/opencms/opencms/en/Data-Bank/Data-Bank-Sub-cat/)
231
+ - [NRCeS β€” SNOMED CT in India](https://www.nrces.in/standards/snomed-ct)
232
+ - [SNOMED International β€” Get SNOMED](https://www.snomed.org/get-snomed)
233
+ - [MeitY β€” DPDP Rules 2025 (PDF, PIB)](https://static.pib.gov.in/WriteReadData/specificdocs/documents/2025/nov/doc20251117695301.pdf)
234
+ - [Lexology β€” Navigating India's DPDPA 2025 Draft Rules](https://www.lexology.com/library/detail.aspx?g=afcc7e95-6fb7-4635-b0ee-b1e10104e3e1)
235
+ - [Archon Datastore β€” DPDPA Compliance Guide](https://www.archondatastore.com/blog/dpdpa-compliance-guide/)
236
+ - [PMC β€” Digital Data Protection in Indian Medical Research and Healthcare](https://pmc.ncbi.nlm.nih.gov/articles/PMC11754748/)
scripts/fetch_data.sh ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # fetch_data.sh β€” pull every legally-redistributable knowledge source we use.
3
+ #
4
+ # All URLs verified May 2026. The `data/` directory is gitignored β€” the team
5
+ # distributes a tarball via a shared bucket rather than committing 90 MB.
6
+ #
7
+ # Sources that require account registration / affiliate licence (cannot be
8
+ # auto-pulled) are listed at the bottom with manual instructions.
9
+ #
10
+ # Usage:
11
+ # bash scripts/fetch_data.sh # full fetch
12
+ # bash scripts/fetch_data.sh --check # verify integrity only
13
+
14
+ set -euo pipefail
15
+
16
+ UA="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
17
+ CURL=(curl -L --fail --silent --show-error -A "$UA" --connect-timeout 15 --max-time 180)
18
+
19
+ mkdir -p data/icd10 data/icd11 data/nfi data/icmr data/mohfw data/who data/openfda data/legal data/snomed data/loinc
20
+
21
+ fetch() { # fetch URL DEST_PATH LABEL
22
+ local url=$1 dest=$2 label=$3
23
+ if [[ -f "$dest" && "${1:-}" != "--force" ]]; then
24
+ local sz; sz=$(stat -f%z "$dest" 2>/dev/null || stat -c%s "$dest")
25
+ if (( sz > 1024 )); then
26
+ printf " βœ“ %-50s (cached, %s bytes)\n" "$label" "$sz"; return
27
+ fi
28
+ fi
29
+ if "${CURL[@]}" "$url" -o "$dest"; then
30
+ local sz; sz=$(stat -f%z "$dest" 2>/dev/null || stat -c%s "$dest")
31
+ printf " βœ“ %-50s (%s bytes)\n" "$label" "$sz"
32
+ else
33
+ printf " βœ— %-50s FAILED β€” %s\n" "$label" "$url"
34
+ fi
35
+ }
36
+
37
+ echo "=== Legal references ==="
38
+ fetch "https://cdn.who.int/media/docs/default-source/classification/icd/icd11/icd11-license.pdf" \
39
+ data/legal/icd11-license.pdf "ICD-11 License (CC BY-ND 3.0 IGO)"
40
+
41
+ echo
42
+ echo "=== ICD-10 β€” WHO international (2019 EN) ==="
43
+ fetch "https://icdcdn.who.int/icd10/claml/icd102019en.xml.zip" \
44
+ data/icd10/icd102019en.xml.zip "WHO ICD-10 2019 ClaML XML (zipped)"
45
+ if [[ -f data/icd10/icd102019en.xml.zip && ! -f data/icd10/icd102019en.xml ]]; then
46
+ (cd data/icd10 && unzip -oq icd102019en.xml.zip)
47
+ fi
48
+
49
+ echo
50
+ echo "=== ICD-10-CM β€” US CDC FY2026 (74,719 codes) ==="
51
+ fetch "https://ftp.cdc.gov/pub/Health_Statistics/NCHS/Publications/ICD10CM/2026/icd10cm-Code%20Descriptions-2026.zip" \
52
+ data/icd10/icd10cm_codes_2026.zip "CDC ICD-10-CM 2026 code descriptions (zipped)"
53
+ if [[ -f data/icd10/icd10cm_codes_2026.zip && ! -d data/icd10/icd10cm_2026 ]]; then
54
+ (cd data/icd10 && unzip -oq icd10cm_codes_2026.zip -d icd10cm_2026/)
55
+ fi
56
+
57
+ echo
58
+ echo "=== ICMR clinical guidelines ==="
59
+ fetch "https://bmhrc.ac.in/WriteReadData/News/202408011156447988880TreatmentGuidelinesforAntimicrobialUseinCommonSyndromes.pdf" \
60
+ data/icmr/amr_treatment_2022_full.pdf "ICMR Antimicrobial Treatment Guidelines 2022 (168pg)"
61
+ fetch "https://www.icmr.gov.in/icmrobject/custom_data/pdf/resource-guidelines/Diagnosis_and_management_of_CROs.pdf" \
62
+ data/icmr/cro_diagnosis_2022.pdf "ICMR Carbapenem-Resistant Organisms 2022"
63
+ fetch "https://www.icmr.gov.in/icmrobject/custom_data/pdf/resource-guidelines/ICMR_Guidelines_for_Management_of_Type_1_Diabetes.pdf" \
64
+ data/icmr/type1_diabetes.pdf "ICMR Type-1 Diabetes Guidelines (173pg)"
65
+ fetch "https://www.icmr.gov.in/icmrobject/custom_data/pdf/resource-guidelines/ICMR_GuidelinesType2diabetes2018_0.pdf" \
66
+ data/icmr/type2_diabetes_2018.pdf "ICMR Type-2 Diabetes Guidelines 2018"
67
+ fetch "https://www.icmr.gov.in/icmrobject/custom_data/pdf/downloadable-books/STW_Vol_3_2022.pdf" \
68
+ data/icmr/stw_vol3_2022.pdf "ICMR Standard Treatment Workflows Vol 3, 2022"
69
+
70
+ echo
71
+ echo "=== MoHFW / NHM ==="
72
+ fetch "https://nhm.gov.in/images/pdf/guidelines/nrhm-guidelines/stg/Hypertension_full.pdf" \
73
+ data/mohfw/Hypertension_full.pdf "MoHFW Hypertension STG (152pg)"
74
+ fetch "https://aiimsrishikesh.edu.in/documents/standard-treatment-guidelines.pdf" \
75
+ data/mohfw/aiims_rishikesh_stg.pdf "AIIMS Rishikesh STG Manual (431pg)"
76
+
77
+ echo
78
+ echo "=== WHO ==="
79
+ fetch "https://iris.who.int/server/api/core/bitstreams/289a875c-cc89-4914-90ad-eb3c578ebaf6/content" \
80
+ data/who/WHO_EML_23_2023.pdf "WHO Model List of Essential Medicines, 23rd ed. (2023)"
81
+
82
+ echo
83
+ echo "=== National Formulary of India ==="
84
+ fetch "https://www.ipc.gov.in/images/news/NFI-0414979118.pdf" \
85
+ data/nfi/NFI_2016.pdf "National Formulary of India 2016 (excerpt β€” full edn on request)"
86
+
87
+ echo
88
+ echo "=== openFDA (drug labels API β€” sampled, not bulk) ==="
89
+ fetch "https://api.fda.gov/drug/label.json?search=openfda.generic_name:amlodipine&limit=2" \
90
+ data/openfda/amlodipine_sample.json "openFDA amlodipine label sample"
91
+
92
+ cat <<'EOF'
93
+
94
+ === Manual steps (cannot auto-fetch) ===
95
+ - SNOMED CT India Edition: apply at https://mlds.ihtsdotools.org/#/landing/IN
96
+ (free for India; ~2 days approval; drop the release ZIP in data/snomed/)
97
+ - Loinc lab codes: register at https://loinc.org/downloads/
98
+ (free, requires email confirmation; drop the table CSV in data/loinc/)
99
+ - ICD-11 MMS export: requires WHO ICD-11 API account at
100
+ https://icd.who.int/icdapi
101
+ (free; OAuth-protected β€” Person A wires the API
102
+ client in app/retrieval/chroma_index.py)
103
+
104
+ === Reminder ===
105
+ ❌ Do NOT add DSM-5, BNF, NICE, MIMS, CIMS, DrugBank-commercial, or any
106
+ copyrighted textbook to data/. See plans/LEGAL_SOURCES.md Β§7.
107
+ βœ… Everything fetched above is licensed for our use. Citations live in the
108
+ wiki page frontmatter β€” see wiki/README.md.
109
+ EOF