@claude-flow/plugin-healthcare-clinical 3.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,280 @@
1
+ # @claude-flow/plugin-healthcare-clinical
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@claude-flow/plugin-healthcare-clinical.svg)](https://www.npmjs.com/package/@claude-flow/plugin-healthcare-clinical)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@claude-flow/plugin-healthcare-clinical.svg)](https://www.npmjs.com/package/@claude-flow/plugin-healthcare-clinical)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ A HIPAA-compliant clinical decision support plugin that combines ultra-fast vector search for medical literature retrieval with graph neural networks for patient pathway analysis. The plugin enables semantic search across medical records, drug interaction detection, and evidence-based treatment recommendations while maintaining strict data privacy through on-device WASM processing.
8
+
9
+ ## Features
10
+
11
+ - **Patient Similarity Search**: Find similar patient cases based on clinical features (diagnoses, labs, vitals, medications)
12
+ - **Drug Interaction Detection**: Analyze drug-drug and drug-condition interactions using graph neural networks
13
+ - **Clinical Pathway Recommendations**: Suggest evidence-based clinical pathways based on diagnosis and patient history
14
+ - **Medical Literature Search**: Semantic search across medical literature (PubMed, Cochrane, UpToDate)
15
+ - **Ontology Navigation**: Navigate ICD-10, SNOMED-CT, LOINC, and RxNorm hierarchies using hyperbolic embeddings
16
+
17
+ ## Installation
18
+
19
+ ### npm
20
+
21
+ ```bash
22
+ npm install @claude-flow/plugin-healthcare-clinical
23
+ ```
24
+
25
+ ### CLI
26
+
27
+ ```bash
28
+ npx claude-flow plugins install --name @claude-flow/plugin-healthcare-clinical
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ```typescript
34
+ import { HealthcareClinicalPlugin } from '@claude-flow/plugin-healthcare-clinical';
35
+
36
+ // Initialize the plugin
37
+ const healthcare = new HealthcareClinicalPlugin({
38
+ ontologyPath: './data/ontologies',
39
+ indexPath: './data/patient-index',
40
+ hipaaCompliance: true
41
+ });
42
+
43
+ // Find similar patients
44
+ const similarPatients = await healthcare.patientSimilarity({
45
+ patientFeatures: {
46
+ diagnoses: ['E11.9', 'I10'], // ICD-10 codes
47
+ labResults: { HbA1c: 7.5, eGFR: 65 },
48
+ medications: ['metformin', 'lisinopril']
49
+ },
50
+ topK: 5
51
+ });
52
+
53
+ // Check drug interactions
54
+ const interactions = await healthcare.drugInteractions({
55
+ medications: ['warfarin', 'aspirin', 'ibuprofen'],
56
+ severity: 'major'
57
+ });
58
+
59
+ // Search medical literature
60
+ const literature = await healthcare.literatureSearch({
61
+ query: 'diabetes management in elderly patients',
62
+ sources: ['pubmed', 'cochrane'],
63
+ evidenceLevel: 'systematic-review'
64
+ });
65
+ ```
66
+
67
+ ## MCP Tools
68
+
69
+ ### 1. `healthcare/patient-similarity`
70
+
71
+ Find similar patient cases for treatment guidance.
72
+
73
+ ```typescript
74
+ // Example usage via MCP
75
+ const result = await mcp.invoke('healthcare/patient-similarity', {
76
+ patientFeatures: {
77
+ diagnoses: ['J45.20', 'J30.9'],
78
+ labResults: { FEV1: 72, eosinophils: 450 },
79
+ vitals: { peakFlow: 380 },
80
+ medications: ['budesonide', 'albuterol']
81
+ },
82
+ topK: 5,
83
+ cohortFilter: 'adult-asthma'
84
+ });
85
+ ```
86
+
87
+ ### 2. `healthcare/drug-interactions`
88
+
89
+ Detect potential drug-drug and drug-condition interactions.
90
+
91
+ ```typescript
92
+ const result = await mcp.invoke('healthcare/drug-interactions', {
93
+ medications: ['clopidogrel', 'omeprazole', 'atorvastatin'],
94
+ conditions: ['CKD-stage-3'],
95
+ severity: 'all'
96
+ });
97
+ ```
98
+
99
+ ### 3. `healthcare/clinical-pathways`
100
+
101
+ Recommend evidence-based clinical pathways.
102
+
103
+ ```typescript
104
+ const result = await mcp.invoke('healthcare/clinical-pathways', {
105
+ primaryDiagnosis: 'I21.0', // STEMI
106
+ patientHistory: {
107
+ age: 68,
108
+ comorbidities: ['E11.9', 'I10']
109
+ },
110
+ constraints: {
111
+ excludeMedications: ['aspirin'], // Allergy
112
+ outpatientOnly: false
113
+ }
114
+ });
115
+ ```
116
+
117
+ ### 4. `healthcare/literature-search`
118
+
119
+ Semantic search across medical literature.
120
+
121
+ ```typescript
122
+ const result = await mcp.invoke('healthcare/literature-search', {
123
+ query: 'SGLT2 inhibitors cardiovascular outcomes',
124
+ sources: ['pubmed', 'cochrane'],
125
+ dateRange: { from: '2020-01-01', to: '2024-12-31' },
126
+ evidenceLevel: 'rct'
127
+ });
128
+ ```
129
+
130
+ ### 5. `healthcare/ontology-navigate`
131
+
132
+ Navigate medical ontology hierarchies.
133
+
134
+ ```typescript
135
+ const result = await mcp.invoke('healthcare/ontology-navigate', {
136
+ code: 'E11',
137
+ ontology: 'icd10',
138
+ direction: 'descendants',
139
+ depth: 2
140
+ });
141
+ ```
142
+
143
+ ## Configuration Options
144
+
145
+ ```typescript
146
+ interface HealthcarePluginConfig {
147
+ // Data paths
148
+ ontologyPath: string; // Path to ontology files
149
+ indexPath: string; // Path to HNSW index storage
150
+
151
+ // HIPAA compliance
152
+ hipaaCompliance: boolean; // Enable HIPAA-compliant mode (default: true)
153
+ auditLogPath: string; // Path for audit logs
154
+ encryptionKey?: string; // AES-256 encryption key
155
+
156
+ // Performance
157
+ maxMemoryMB: number; // WASM memory limit (default: 512)
158
+ cacheSize: number; // Embedding cache size (default: 10000)
159
+
160
+ // Ontologies
161
+ enabledOntologies: string[]; // ['icd10', 'snomed', 'loinc', 'rxnorm']
162
+
163
+ // Access control
164
+ roleBasedAccess: boolean; // Enable RBAC (default: true)
165
+ }
166
+ ```
167
+
168
+ ## Security Considerations
169
+
170
+ ### HIPAA Compliance
171
+
172
+ This plugin is designed with HIPAA compliance as a core requirement:
173
+
174
+ | Requirement | Implementation |
175
+ |-------------|----------------|
176
+ | **PHI Protection** | All patient data processed exclusively in WASM sandbox |
177
+ | **Encryption at Rest** | AES-256 encryption for all stored embeddings and indexes |
178
+ | **Encryption in Transit** | TLS 1.3 minimum for any network operations |
179
+ | **Access Logging** | Immutable audit logs with tamper detection (HMAC) |
180
+ | **Minimum Necessary** | Role-based data filtering at query time |
181
+
182
+ ### On-Device Processing
183
+
184
+ - All PHI is processed locally via WASM - no cloud transmission
185
+ - WASM sandbox prevents network access and file system access
186
+ - Memory limited to 512MB to prevent exhaustion attacks
187
+ - 30-second CPU timeout per operation
188
+
189
+ ### Role-Based Access Control
190
+
191
+ ```typescript
192
+ const roles = {
193
+ PHYSICIAN: ['patient-similarity', 'drug-interactions', 'clinical-pathways', 'literature-search', 'ontology-navigate'],
194
+ NURSE: ['drug-interactions', 'ontology-navigate'],
195
+ PHARMACIST: ['drug-interactions', 'literature-search'],
196
+ RESEARCHER: ['literature-search', 'ontology-navigate'], // No patient data
197
+ CODER: ['ontology-navigate'] // Billing codes only
198
+ };
199
+ ```
200
+
201
+ ### Audit Logging
202
+
203
+ All tool invocations are logged with:
204
+ - Timestamp (ISO 8601 with timezone)
205
+ - User ID and role
206
+ - Tool name and action type
207
+ - Hashed patient identifiers (not actual PHI)
208
+ - Query hash for reproducibility
209
+
210
+ Audit logs are retained for 6 years per HIPAA requirements.
211
+
212
+ ### Input Validation
213
+
214
+ All inputs are validated using Zod schemas:
215
+ - ICD-10 codes must match format `/^[A-Z]\d{2}(\.\d{1,2})?$/`
216
+ - RxNorm CUIs validated for format
217
+ - Maximum 100 diagnoses, 50 medications per query
218
+ - String lengths capped to prevent injection attacks
219
+ - Patient identifiers must be UUIDs or match institutional format
220
+
221
+ ### Rate Limiting
222
+
223
+ ```typescript
224
+ const rateLimits = {
225
+ 'healthcare/patient-similarity': { requestsPerMinute: 30, maxConcurrent: 3 },
226
+ 'healthcare/drug-interactions': { requestsPerMinute: 60, maxConcurrent: 5 },
227
+ 'healthcare/clinical-pathways': { requestsPerMinute: 20, maxConcurrent: 2 },
228
+ 'healthcare/literature-search': { requestsPerMinute: 30, maxConcurrent: 3 },
229
+ 'healthcare/ontology-navigate': { requestsPerMinute: 120, maxConcurrent: 10 }
230
+ };
231
+ ```
232
+
233
+ ## Performance
234
+
235
+ | Metric | Target |
236
+ |--------|--------|
237
+ | Patient similarity search | <50ms for 100K records |
238
+ | Drug interaction check | <10ms for 20 medications |
239
+ | Literature search | <100ms for 1M abstracts |
240
+ | Ontology traversal | <5ms per hop |
241
+
242
+ ## Dependencies
243
+
244
+ - `micro-hnsw-wasm`: Fast similarity search (150x faster than traditional)
245
+ - `ruvector-gnn-wasm`: Graph neural networks for pathway analysis
246
+ - `ruvector-hyperbolic-hnsw-wasm`: Hierarchical medical ontology embeddings
247
+ - `ruvector-sparse-inference-wasm`: Efficient inference on sparse clinical features
248
+ - `@medplum/fhirtypes`: FHIR R4 type definitions
249
+
250
+ ## Related Plugins
251
+
252
+ | Plugin | Description | Use Case |
253
+ |--------|-------------|----------|
254
+ | [@claude-flow/plugin-legal-contracts](../legal-contracts) | Contract analysis and compliance | Healthcare vendor agreements, BAAs |
255
+ | [@claude-flow/plugin-financial-risk](../financial-risk) | Risk analysis and compliance | Healthcare billing fraud detection |
256
+ | [@claude-flow/plugin-code-intelligence](../code-intelligence) | Code analysis | EHR integration development |
257
+
258
+ ## License
259
+
260
+ MIT License
261
+
262
+ Copyright (c) 2026 Claude Flow
263
+
264
+ Permission is hereby granted, free of charge, to any person obtaining a copy
265
+ of this software and associated documentation files (the "Software"), to deal
266
+ in the Software without restriction, including without limitation the rights
267
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
268
+ copies of the Software, and to permit persons to whom the Software is
269
+ furnished to do so, subject to the following conditions:
270
+
271
+ The above copyright notice and this permission notice shall be included in all
272
+ copies or substantial portions of the Software.
273
+
274
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
275
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
276
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
277
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
278
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
279
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
280
+ SOFTWARE.
@@ -0,0 +1,70 @@
1
+ /**
2
+ * GNN Bridge - Healthcare Clinical Plugin
3
+ *
4
+ * Provides Graph Neural Network capabilities for clinical pathway
5
+ * analysis and drug interaction detection. Integrates with
6
+ * ruvector-gnn-wasm for efficient graph-based reasoning.
7
+ *
8
+ * Use Cases:
9
+ * - Clinical pathway recommendations
10
+ * - Drug interaction network analysis
11
+ * - Comorbidity pattern detection
12
+ * - Treatment outcome prediction
13
+ */
14
+ import type { GNNBridge, GNNConfig, GNNNode, GNNEdge, GNNPathResult, GNNInteractionResult, DrugInteraction, ClinicalPathway, Logger } from '../types.js';
15
+ /**
16
+ * Healthcare GNN Bridge implementation
17
+ */
18
+ export declare class HealthcareGNNBridge implements GNNBridge {
19
+ private wasmModule;
20
+ private graphPtr;
21
+ private config;
22
+ private logger;
23
+ private nodes;
24
+ private edges;
25
+ private nodeIdToIndex;
26
+ private drugInteractionGraph;
27
+ private clinicalPathwayGraph;
28
+ initialized: boolean;
29
+ constructor(config?: Partial<GNNConfig>, logger?: Logger);
30
+ /**
31
+ * Initialize the GNN bridge
32
+ */
33
+ initialize(config?: GNNConfig): Promise<void>;
34
+ /**
35
+ * Load a graph into the GNN
36
+ */
37
+ loadGraph(nodes: GNNNode[], edges: GNNEdge[]): Promise<void>;
38
+ /**
39
+ * Predict optimal pathway between nodes
40
+ */
41
+ predictPathway(startNode: string, endNode: string, constraints?: Record<string, unknown>): Promise<GNNPathResult>;
42
+ /**
43
+ * Analyze interactions between nodes
44
+ */
45
+ analyzeInteractions(nodeIds: string[]): Promise<GNNInteractionResult>;
46
+ /**
47
+ * Get clinical pathway for a diagnosis
48
+ */
49
+ getClinicalPathway(diagnosis: string): ClinicalPathway | undefined;
50
+ /**
51
+ * Check drug interactions
52
+ */
53
+ checkDrugInteractions(medications: string[], severityFilter?: string): DrugInteraction[];
54
+ /**
55
+ * Cleanup resources
56
+ */
57
+ destroy(): void;
58
+ private resolveWasmPath;
59
+ private loadWasmModule;
60
+ private getNodeIdByIndex;
61
+ private bfsPath;
62
+ private calculatePathRisk;
63
+ private severityToStrength;
64
+ }
65
+ /**
66
+ * Create a new GNN bridge instance
67
+ */
68
+ export declare function createGNNBridge(config?: Partial<GNNConfig>, logger?: Logger): HealthcareGNNBridge;
69
+ export default HealthcareGNNBridge;
70
+ //# sourceMappingURL=gnn-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gnn-bridge.d.ts","sourceRoot":"","sources":["../../src/bridges/gnn-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,OAAO,EACP,OAAO,EACP,aAAa,EACb,oBAAoB,EACpB,eAAe,EAEf,eAAe,EACf,MAAM,EACP,MAAM,aAAa,CAAC;AA2SrB;;GAEG;AACH,qBAAa,mBAAoB,YAAW,SAAS;IACnD,OAAO,CAAC,UAAU,CAA8B;IAChD,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAmC;IAChD,OAAO,CAAC,KAAK,CAAiB;IAC9B,OAAO,CAAC,aAAa,CAAkC;IACvD,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,oBAAoB,CAAuB;IAE5C,WAAW,UAAS;gBAEf,MAAM,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM;IAYxD;;OAEG;IACG,UAAU,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BnD;;OAEG;IACG,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA4ClE;;OAEG;IACG,cAAc,CAClB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACpC,OAAO,CAAC,aAAa,CAAC;IA0CzB;;OAEG;IACG,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA4B3E;;OAEG;IACH,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIlE;;OAEG;IACH,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,cAAc,GAAE,MAAc,GAAG,eAAe,EAAE;IAI/F;;OAEG;IACH,OAAO,IAAI,IAAI;YAYD,eAAe;YAUf,cAAc;IAM5B,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,OAAO;IAiCf,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,kBAAkB;CAS3B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAEjG;AAED,eAAe,mBAAmB,CAAC"}