项目 / onblog/doctor

onblog/doctor

行业推荐
语言 JavaScript标签 d3cloudflare-workersd1healthcareknowledge-graphserverlesssqlitesymptom-checkertypescriptchinesediseasemedicalsymptom-check数据更新 2026-11-20 06:49:16 · 仓库 2026-11-19

一段话介绍

Educational symptom self-check on a medical knowledge graph: pick a body part and your symptoms, and it ranks candidate diseases by how much of your input they explain. Not a diagnosis. 医疗知识图谱驱动的症状自查:选身体部位、勾选症状,按「能解释你多少症状」给候选疾病排序,并筛掉不可能的科室…

本站整理,非 GitHub 官方 description。

官方 description(GitHub API 原样)
Educational symptom self-check on a medical knowledge graph: pick a body part and your symptoms, and it ranks candidate diseases by how much of your input they explain. Not a diagnosis. 医疗知识图谱驱动的症状自查:选身体部位、勾选症状,按「能解释你多少症状」给候选疾病排序,并筛掉不可能的科室;覆盖 7733 种疾病、4697 个症状。仅供科普参考,不能替代诊断。
354累计星
140Fork
—峰值日增
0上榜次数
总榜
暂未入榜
日榜
暂未入榜
周榜
暂未入榜
月榜
暂未入榜

官方快照(gh_history.db,2026-11-25):总榜 未进 Top50 · 日榜 未进 Top50 · 周榜未满 7 天基线(官方不生成) · 月榜暂无官方口径;下方四卡为站内趋势聚合(周卡按上榜次数,非官方 7 日增量窗)。

行业与场景

按行业选型 →

医学影像分析与辅助诊断

适配系统:医学影像系统、辅助诊断平台 · 得分 1.4

具备影像处理/分割识别能力,可接入 PACS 做病灶标注、初筛与报告辅助生成。

更多信息

以下三段按该项目自己的 GitHub README 章节摘录(可合理截断并标明);README 没有对应章节的留空,不编造。

我的用法
该项目通过 wrangler 初始化本地 D1 数据库、脚本转换 MySQL 样例数据并加载,npm run dev 在 8788 端口运行,npm test 和 npm run check 分别跑单测与类型检查加测试。
特点或设计要点
该设计采用单页三步流程,以身体图作为主要选择器,在图旁浮动症状面板并支持拼音过滤,结果通过模态图展示症状与疾病关联。
星标走势还差一天的数据,明天就能看到曲线
每天 10:30 记一次星标,连续两天后自动生成曲线
首次发现 — · 最近在榜 2026-11-20 · 语言 JavaScript · 贡献者 —
javascript

GitHub 项目主页介绍

来自 GitHub 仓库 README / 主页介绍正文,原样摘录,共 9,089 字节。

<div align="center">

<img src="docs/assets/logo.svg" width="104" alt="医疗知识图谱" />

# Doctor

**医疗知识图谱 — symptom self-check on a medical knowledge graph, one page, three steps, one Worker.**

<a href="https://doctor.wordtk.com"><img alt="Live demo" src="https://img.shields.io/badge/%E2%96%B6_Live_Demo-doctor.wordtk.com-79b15b?style=for-the-badge"></a>

<br/>

<img alt="license" src="https://img.shields.io/github/license/onblog/doctor?style=flat-square">
<img alt="runtime" src="https://img.shields.io/badge/runtime-Cloudflare_Workers-f38020?style=flat-square">
<img alt="database" src="https://img.shields.io/badge/database-D1-2f7d52?style=flat-square">
<img alt="data" src="https://img.shields.io/badge/data-7%2C733_diseases_%C2%B7_4%2C697_symptoms_%C2%B7_96%2C134_edges-4d7a35?style=flat-square">

<br/><br/>

🇺🇸 **English** &nbsp;·&nbsp; [🇨🇳 简体中文](README.zh-CN.md)

<br/>

<img src="docs/assets/home.webp" width="880" alt="Doctor — symptom self-check">

</div>

> Fill in sex and age, tap a body part, pick symptoms. Doctor walks a disease ↔ symptom graph,
> screens out departments that cannot apply, and ranks candidate diseases by how much of your input
> they explain. Educational self-check only — **not** a diagnostic device.

---

## Table of contents

| | |
| --- | --- |
| [What it does](#what-it-does) | [How it decides](#how-it-decides) |
| [Screens](#screens) | [Quick start](#quick-start) |
| [API](#api) | [Using the full dataset](#using-the-full-dataset) |
| [Deploy](#deploy) | [Project layout](#project-layout) |
| [Cost and limits](#cost-and-limits) | [License](#license) |

---

## What it does

- **One page, three steps** — profile → symptoms → result. No route changes, no full reloads.
- **Body map as the primary picker** — front and back figures, with hotspots for
  head, chest, abdomen, waist, pelvis, limbs. Hovering the head expands 眼/鼻/口/牙/耳/眉 in place.
- **Symptom panel floats beside the figure** — hundreds of symptoms per region, with an A–Z pinyin
  filter, so the page never jumps around.
- **Reasoning graph in a modal** — open any result and see your symptoms on the left, the diseases
  they point to on the right (the current one highlighted), and the edges that connect them.

## How it decides

1. Map each picked symptom onto the disease ↔ symptom graph.
2. Reverse-walk the edges: which diseases point at these symptoms.
3. Screen out departments by sex and age (妇科 / 男科 / 小儿科 / 老年科).
4. Rank by matched count, then by `matched / disease.symptomCount + matched × 0.1`.

The list is ordered by **how many of your symptoms each disease explains**; the ring in the UI shows
relative strength within the result set, not a probability.

## Screens

<div align="center">

| Body map with the symptom panel | Reasoning graph in the result modal |
| --- | --- |
| <img src="docs/assets/body-map.webp" width="420" alt="Body map and symptom panel"> | <img src="docs/assets/reasoning.webp" width="420" alt="Reasoning graph"> |

<img src="docs/assets/result.webp" width="880" alt="Assessment result">

</div>

## Quick start

```bash
npm install

# 1. local schema
npx wrangler d1 execute doctor --local --file=./migrations/0001_init.sql

# 2. build the demo dataset from the sample dump
node scripts/convert-mysql-dump.mjs db/sample-dump.sql

# 3. load it
node scripts/load-d1.mjs --local

# 4. run
npm run dev          # http://127.0.0.1:8788
```

`npm test` runs the algorithm unit tests, `npm run check` runs typecheck plus tests.

## API

All endpoints are JSON under `/api/`. Errors share one shape: `{ "error": "…", "code": "…" }`.

| Method | Path | Purpose |
| --- | --- | --- |
| `GET` | `/api/health` | smoke test + dataset size |
| `GET` | `/api/symptoms/search?q=&limit=` | autocomplete, Chinese or pinyin |
| `GET` | `/api/symptoms?part=&letter=&limit=` | symptoms of a body part, optional A–Z filter |
| `GET` | `/api/parts` | body part tags with counts |
| `POST` | `/api/analyze` | the self-assessment call |
| `GET` | `/api/diseases?q=` | disease search |
| `GET` | `/api/diseases/:id` | full disease record |
| `GET` | `/api/graph/explain?id=&symptoms=&per=` | reasoning graph: symptoms → diseases |
| `GET` | `/api/graph?id=` | attribute graph for one disease |

```bash
curl -X POST https://doctor.wordtk.com/api/analyze \
  -H 'content-type: application/json' \
  -d '{"sex":"female","age":28,"symptoms":["头痛","恶心"]}'
```

Chinese sex values and age ranges are accepted too, e.g.
`{"sex":"女","age":[28,35],"symptom":["头痛"]}`. Full field reference:
[docs/en/api.md](docs/en/api.md).

## Using the full dataset

The repository ships a hand-written demo subset only. The complete knowledge base is distributed
separately under a commercial license.

```bash
mkdir -p _data && cp /path/to/robot.sql _data/     # 120+ MB mysqldump
node scripts/convert-mysql-dump.mjs               # -> build/seed-*.sql
node scripts/load-d1.mjs --local                  # or --remote
```

The converter reads the mysqldump directly: it parses `CREATE TABLE` for column order, folds the
side tables that store list columns back into JSON arrays, derives sex/age department scopes,
computes pinyin keys, and emits chunked SQL small enough for `wrangler d1 execute`.

### Split the import across days

One full import is about **173,000 row writes**; the free tier allows **100,000 per day**. Split it
first, then load one batch per day:

```bash
npm run data:days                        # build/day-1 + build/day-2 + days.json
npm run data:load -- --remote --day 1    # ~86.7k writes
npm run data:load -- --remote --day 2    # the rest, next day
```

`days.json` records the row count and the table mix of each batch, so you can see the cost before
running it.

## Deploy

```bash
npx wrangler login
npx wrangler d1 create doctor          # copy the returned database_id
# paste it into wrangler.jsonc, then:
npm run data:load -- --remote
npm run deploy
```

The custom domain is **not** declared in `wrangler.jsonc`: a live origin must not sit in the
repository. Bind it once in Cloudflare Dashboard → Workers & Pages → `doctor` → Settings →
Domains & Routes; `wrangler deploy` leaves that binding untouched. The `workers.dev` subdomain
is disabled so there is only one public entry point.

The commercial-licence mailbox is deployment configuration too. Add it as a Worker variable —
Cloudflare Dashboard → Workers & Pages → `doctor` → Settings → Variables → `CONTACT_EMAIL`
(plain text; `.dev.vars` for local runs). `GET /api/site` serves it to the page; while it is
unset the contact blocks stay hidden instead of rendering an empty mail link.

## Project layout

```
src/
  index.ts            Worker entry, /api/ dispatch, error envelope
  http.ts             JSON helpers, edge cache wrapper
  db.ts               D1 helpers, row -> DTO mapping
  lib/diagnose.ts     scoring + ranking, pure and unit tested
  routes/             health, symptoms, parts, analyze, diseases, graph
public/
  index.html          single page shell (three steps)
  assets/app.css      layout and theme
  assets/app.js       step flow, body map, search, d3 reasoning graph
  assets/body/        front/back body figures
  assets/vendor/      d3 v3 (loaded only when a result is opened)
migrations/           D1 schema
db/sample-dump.sql    hand-written demo subset in mysqldump format
scripts/              dump converter, day splitter, D1 loader
tests/                algorithm tests
```

## Cost and limits

Static asset requests do not count as Worker invocations, and the API surface is small. As of
October 2026 the free plan allows 100,000 Worker requests/day with 10 ms CPU each, and D1 allows
5 million rows read/day and 100,000 rows written/day. Verify against the
[official limits](https://developers.cloudflare.com/workers/platform/limits/) before relying on them.

The hot path is one indexed join plus in-memory scoring, so CPU is not the constraint — row reads
are. That is why lookups are index seeks instead of `LIKE '%…%'` scans.

## License

Copyright (C) 2026 onblog.

The code is licensed under **AGPL-3.0-only** — see [LICENSE](LICENSE). You may use, modify,
self-host and even sell it, provided that any derivative work, and any network service built on
top of it, is released under the same license.

If that does not fit your case (closed-source distribution, or a closed-source hosted service), a
**commercial license** is available: <hello@wordtk.com>.

The **dataset** is not covered by AGPL-3.0. It is licensed separately under a commercial
agreement, so this repository ships only a small hand-written sample.

---

<div align="center">

**Doctor** · built with Cloudflare Workers, D1 and d3

<a href="https://doctor.wordtk.com">Live demo</a> ·
<a href="docs/en/api.md">API</a> ·
<a href="README.zh-CN.md">简体中文</a>

<sub>Output is for education and self-awareness only. It is not a diagnosis, treatment plan or
prescription advice, and it does not replace a doctor.</sub>

</div>
↑