CodeFinder - Medical Code Search
FastAPI service tra cứu mã y tế (ICD10, ICPC2, CPT, SERVICE, PROCEDURE). Hybrid search: ChromaDB vector (all-MiniLM-L6-v2) + BM25. 3-tier cache. Port 8060.
Base URL
https://pnt.badt.vn/codefinder
Authentication
Bearer token:
Authorization: Bearer <API_AI_TOKEN>
API Endpoints
/lookup
Core
Tra cứu mã y tế. Hỗ trợ hybrid search (ChromaDB + BM25) với weight alpha.
| Param | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | Search query (1-500 ký tự) |
| code_type | string | No | ICD10, ICPC2, CPT, SERVICE, PROCEDURE, ALL (mặc định: ALL) |
| n_results | int | No | Số lượng kết quả (1-50, mặc định: 10) |
| use_cache | bool | No | Dùng cache (mặc định: true) |
| alpha | float | No | Hybrid weight: 1.0 = vector, 0.0 = BM25 |
/batch-lookup
Batch
Tra cứu hàng loạt (tối đa 20 queries).
| Param | Type | Required | Description |
|---|---|---|---|
| queries | array | Yes | List of lookup request objects (max 20) |
/search
Query
Tra cứu nhanh qua query params.
| Param | Type | Required | Description |
|---|---|---|---|
| q | string | Yes | Search text |
| type | string | No | Code type (mặc định: ALL) |
| n | int | No | Results count |
/code/{code_type}/{code}
Direct
Tra cứu trực tiếp bằng mã code. Kiểm tra L1 cache → L2 Redis → database.
/health
Utility
Health check: database, cache, search engine status.
Analytics
/analytics/top-queriesAnalyticsTop queries phổ biến. Params: limit, hours, code_type.
/analytics/slow-queriesAnalyticsQueries chậm. Params: threshold_ms, limit, hours.
/analytics/performanceAnalyticsPerformance summary trong khoảng thời gian.
/analytics/cache-recommendationsAnalyticsĐề xuất cache dựa trên hit count.
Admin
/admin/invalidate-cacheAdminXóa toàn bộ cache.
/admin/optimize-cacheAdminWarm cache với popular queries.
/admin/index-healthAdminKiểm tra index status (ChromaDB + BM25).
/admin/rebuild-indexAdminRebuild index cho code type cụ thể.
/admin/rebuild-status/{job_id}AdminKiểm tra trạng thái rebuild job.
/statsAdminChi tiết cache + search engine stats.
Request Example
curl -X POST https://pnt.badt.vn/codefinder/lookup \
-H "Authorization: Bearer $API_AI_TOKEN" \
-H "Content-Type: application/json" \
-d '{"text": "tăng huyết áp", "code_type": "ICD10", "n_results": 5}'
Response Example
{
"results": [
{"code": "I10", "description": "Essential (primary) hypertension", "score": 0.92},
{"code": "I11.9", "description": "Hypertensive heart disease without heart failure", "score": 0.85}
],
"query": "tăng huyết áp",
"code_type": "ICD10",
"response_time_ms": 45,
"cache_hit": true
}