{"skill":{"slug":"clinical-trial","displayName":"NoahAI clinical-trial query","summary":"Search clinical trial databases similar to ClinicalTrials.gov. Use this skill whenever the user asks about clinical trials, drug trials, indications, targets...","description":"---\nname: clinical-trial-search\ndescription: \"Search clinical trial databases similar to ClinicalTrials.gov. Use this skill whenever the user asks about clinical trials, drug trials, indications, targets, drug names, trial phases, NCT IDs, enrollment, or recruitment. Automatically parses natural language questions into structured query parameters and calls the backend API to return matching trial records. Trigger words include: clinical trial, NCT, drug development, indication, target, phase, enrollment, recruitment, sponsor, cohort, arm, endpoint, efficacy, safety data.\"\nmetadata: { \"openclaw\": { \"emoji\": \"🔍︎\",  \"requires\": { \"bins\": [\"python3\"], \"env\":[\"NOAH_API_TOKEN\"]},\"primaryEnv\":\"NOAH_API_TOKEN\" } }\n---\n\n# Clinical Trial Search Skill\n\nThis skill converts natural language questions into structured API queries against a clinical trial database, then presents the results in a readable format.\n\n## Workflow\n\n1. **Parse user intent** — Extract key entities from the user's question\n2. **Build query parameters** — Map entities to the query schema below\n3. **Execute the query** — Run `scripts/search.py`\n4. **Present results** — Format and display trials to the user\n\n## Step 1: Extract Keywords\n\nIdentify the following entity types from the user's question:\n\n| Field | Type | Description                       | Example                                                   |\n|-------|------|-----------------------------------|-----------------------------------------------------------|\n| `nctid` | `List[str]` | NCT identifier(s)                 | `[\"NCT04280783\"]`                                         |\n| `acronym` | `List[str]` | Trial acronym(s)                  | `[\"KEYNOTE-590\"]`                                         |\n| `company` | `List[str]` | Sponsor company name(s)           | `[\"Pfizer\", \"Roche\"]`                                     |\n| `indication` | `List[str]` | Disease / indication              | `[\"lung cancer\", \"NSCLC\"]`                                |\n| `phase` | `List[str]` | Trial phase(s)                    | `[\"Preclinical\", \"I\", \"II\", \"III\", \"IV\", \"Others\"]`                                  |\n| `target` | `dict` | Biological target(s)              | `{\"logic\": \"or\", \"data\": [\"PD-1\", \"VEGF\"]}`               |\n| `drug_name` | `dict` | Drug name(s)                      | `{\"logic\": \"or\", \"data\": [\"pembrolizumab\"]}`              |\n| `drug_modality` | `dict` | Drug modality  | `{\"logic\": \"or\", \"data\": [\"Vaccine\", \"mRNA\"]}` |\n| `drug_feature` | `dict` | Drug feature(s) | `{\"logic\": \"or\", \"data\": [\"Biologic\", \"Non-NME\"]}`                 |\n| `location` | `dict` | Trial location(s)                 | `{\"logic\": \"or\", \"data\": [\"China\", \"United States\", \"Japan\"]}`               |\n| `has_result_summary` | `bool` | Only trials with result summaries | `true`                                                    |\n| `official_data` | `bool` | Only official data sources        | `false`                                                   |\n| `page_num` | `int` | Page index (0-based)              | `0`                                                       |\n| `page_size` | `int` | Results per page (1–200)          | `10`                                                       |\n\n**Dict field format:**\n```json\n{\"logic\": \"or\", \"data\": [\"value1\", \"value2\"]}\n```\n\n- `logic` controls how multiple values are combined: `\"or\"` (any match) or `\"and\"` (all must match). Default to `\"or\"` unless the user explicitly wants all terms to apply simultaneously.\n- `data` is the list of keyword strings to match.\n\n**Type rules:**\n- `indication`, `acronym`, `company`, `nctid`, `phase` → plain `List[str]`\n- `target`, `drug_name`, `drug_modality`, `drug_feature`, `location`, `route_of_administration` → `dict` with `logic` and `data`\n- Default to `page_num: 0, page_size: 10` unless the user specifies otherwise\n- Prefer English keywords (the database is indexed in English); translate non-English terms\n- `drug_modality` must use exact strings from this set:\n\n  ```json\n  [\n    \"Steroids\", \"Vaccine\", \"Antisense RNA\", \"Antibody-Drug Conjugates, ADCs\", \"Unknown\", \"Protein Degrader\",\n    \"Monoclonal Antibodies\", \"mRNA\", \"Others\", \"Cell-based Therapies\", \"Imaging Agents\", \"Gene Therapy\",\n    \"miRNA\", \"Polypeptide\", \"Recombinant Proteins\", \"Small Molecule\", \"siRNA/RNAi\", \"Trispecific Antibodies\",\n    \"Polyclonal Antibodies\", \"Bi-specific Antibodies\", \"Glycoconjugates\", \"Radiopharmaceutical\",\n    \"Nucleic Acid-based\", \"Carbohydrates\"\n  ]\n  ```\n- `drug_feature` must use exact strings from this set:\n\n  ```json\n  [\n    \"505b2\", \"Bacterial Product\", \"Biologic\", \"Biosimilar\", \"Device\", \"Fixed-Dose Combination\", \"Immuno-Oncology\",\n    \"New Molecular Entity (NME)\", \"Non-NME\", \"Precision Medicine\", \"Reformulation\", \"Specialty Drug\", \"Viral\"\n  ]\n  ```\n\n## Step 2: Execute the Query\n\n```bash\npython scripts/search.py --params '<JSON string>'\n```\n\nOr using a parameter file:\n\n```bash\npython scripts/search.py --params-file /tmp/query.json\n```\n\nAdd `--raw` to receive the unformatted JSON response.\n\n## Step 3: Interpret Results\n\nThe response contains:\n- `total_count` — total number of matching trials\n- `results` — current page of results, each with NCT ID, title, phase, status, indication, drugs, sponsor, etc.\n\nIf results exceed 100, prompt the user to narrow the query. If no results are returned, apply the fallback strategies below before giving up.\n\n## Step 3: Review and Fallback Search Strategies\nIf no results are returned, apply the fallback strategies below before giving up.\nWhen an initial query returns zero or poor results, try these strategies **in order**:\n\n### Strategy 1 — Drug Name Variant Expansion\n\nTrial registries may store drug names inconsistently (INN vs brand name, with/without hyphens, partial codes). Expand `drug_name.data` to include multiple variants in a single `or` query.\n\n```json\n{\n  \"drug_name\": {\"logic\": \"or\", \"data\": [\"SHR-A1904\", \"SHR A1904\", \"A1904\", \"SHR1904\"]},\n  \"page_num\": 0,\n  \"page_size\": 50\n}\n```\n\nAlso try substituting the trial acronym if known:\n```json\n{\n  \"acronym\": [\"KEYNOTE-590\", \"KEYNOTE590\", \"KN590\"],\n  \"page_num\": 0,\n  \"page_size\": 10\n}\n```\n\n**Common variant patterns:**\n- Remove or replace hyphens: `SHR-A1904` → `SHR A1904`, `SHRA1904`\n- Strip prefix: `9MW-2821` → `MW-2821`, `9MW2821`\n- Try both INN and internal code together in the same `data` array\n\n---\n\n### Strategy 2 — Sponsor-First with Application-Layer Filtering\n\nWhen drug name matching is unreliable, anchor on the sponsor company and pull a broad result set, then filter locally by indication, phase, or modality.\n\n```json\n{\n  \"company\": [\"Roche\", \"Roche Inc\"],\n  \"page_num\": 0,\n  \"page_size\": 200\n}\n```\n\nAfter retrieval, apply local filters:\n- `phase in [\"II\", \"III\"]`\n- `indication contains \"breast cancer\"`\n- `drug_name matches known code pattern`\n\nUse this strategy when the drug code is ambiguous or when searching for a company's full trial portfolio.\n\n---\n\n### Strategy 3 — Broad Target/Indication Search with Post-Filtering\n\nWhen neither drug name nor company yields results, search by biological target and indication, then narrow client-side by sponsor or drug name pattern.\n\n```json\n{\n  \"target\": {\"logic\": \"or\", \"data\": [\"CLDN18.2\", \"Nectin-4\", \"HER2\"]},\n  \"indication\": [\"gastric cancer\", \"breast cancer\"],\n  \"page_num\": 0,\n  \"page_size\": 200\n}\n```\n\nAfter retrieval, filter by:\n- Sponsor name substring (e.g. contains `\"Hengrui\"`)\n- Drug code prefix (e.g. starts with `SHR`, `9MW`, `A166`)\n- Trial status (`Recruiting`, `Active, not recruiting`)\n\n> **Note:** If the API supports regex, patterns like `(SHR|9MW|A166)` can be passed directly in `drug_name.data` to broaden matching in a single call.\n\n---\n\n### Strategy 4 — Relax Filters Incrementally\n\nIf all strategies above still return no results, drop filters one at a time in this order:\n\n1. Drop `has_result_summary` (many trials have no posted results)\n2. Drop `phase` filter\n3. Drop `location` filter\n4. Broaden `indication` (e.g. `\"NSCLC\"` → `\"lung cancer\"` → `\"cancer\"`)\n5. Remove `drug_modality` or `drug_feature` constraints\n\nRe-run after each relaxation and stop as soon as results appear.\n\n---\n\n## Decision Tree\n\n```\nInitial query returns results?\n├── Yes → present results\n└── No  → Strategy 1: expand drug_name / acronym variants\n          └── Still no → Strategy 2: sponsor anchor + local filter\n                         └── Still no → Strategy 3: target/indication broad search\n                                        └── Still no → Strategy 4: relax filters incrementally\nAny step hits HTTP 429?\n└── Pause entire chain 15s → resume from current strategy\n    (sleep ≥5s between every request to avoid triggering 429)\n```\n\n---\n\n## Conversion Examples\n\n**User:** \"Find Phase 3 trials of PD-1 antibodies in lung cancer that have results\"\n\n```json\n{\n  \"target\": {\"logic\": \"or\", \"data\": [\"PD-1\"]},\n  \"drug_modality\": {\"logic\": \"or\", \"data\": [\"Monoclonal Antibodies\"]},\n  \"indication\": [\"lung cancer\"],\n  \"phase\": [\"III\"],\n  \"has_result_summary\": true,\n  \"page_num\": 0,\n  \"page_size\": 10\n}\n```\n\n---\n\n**User:** \"Look up NCT04280783\"\n\n```json\n{\n  \"nctid\": [\"NCT04280783\"],\n  \"page_num\": 0,\n  \"page_size\": 1\n}\n```\n\n---\n\n**User:** \"Roche bispecific antibody trials in China\"\n\n```json\n{\n  \"company\": [\"Roche\"],\n  \"location\": {\"logic\": \"or\", \"data\": [\"China\"]},\n  \"drug_modality\": {\"logic\": \"or\", \"data\": [\"Bi-specific Antibodies\"]},\n  \"page_num\": 0,\n  \"page_size\": 10\n}\n```\n\n---\n\n**User:** \"Oral small molecule KRAS G12C inhibitors in colorectal cancer\"\n\n```json\n{\n  \"target\": {\"logic\": \"or\", \"data\": [\"KRAS G12C\"]},\n  \"drug_modality\": {\"logic\": \"or\", \"data\": [\"Small Molecule\"]},\n  \"indication\": [\"colorectal cancer\"],\n  \"page_num\": 0,\n  \"page_size\": 10\n}\n```\n\n---\n\n## Dependencies\n\n- Python 3.8+\n- `requests` library (`pip install requests`)\n- Environment variable `NOAH_API_TOKEN` — API authentication token (required)\n  - Register for a free account at [noah.bio](https://noah.bio) to obtain your API key.\n\n---\n\n## Security & Packaging Notes\n\n- This skill only calls NoahAI official HTTPS endpoints under `https://www.noah.bio/api/` and does not contact third-party services.\n- It requires exactly one environment variable: `NOAH_API_TOKEN`. Store it in the environment or a local `.env` file, and never place it inline in commands, chats, or packaged files.\n- The token is scoped to read medical public details only and cannot access private user records.\n- The skill does not intentionally persist request parameters locally. Any server-side retention is determined by the NoahAI API service and its operational logging policies.\n- It does not request persistent or system-level privileges and does not modify system configuration.\n- The skill is source-file based (Python scripts only) and does not require runtime installs, package downloads, or external bootstrap steps.","tags":{"latest":"1.0.8"},"stats":{"comments":0,"downloads":768,"installsAllTime":1,"installsCurrent":1,"stars":1,"versions":9},"createdAt":1773578010645,"updatedAt":1778491925219},"latestVersion":{"version":"1.0.8","createdAt":1776611535551,"changelog":"clinical-trial-search v1.0.8\n\n- Updated accepted value lists for `drug_modality` and `drug_feature` fields; inputs must now use exact strings from specified sets.\n- Clarified field type rules and examples for structured query parameters.\n- Adjusted sample values in field examples to reflect updated allowed terms.\n- Changed API response documentation: `page_size` renamed to `total_count`.\n- No code changes; documentation only.","license":"MIT-0"},"metadata":{"setup":[{"key":"NOAH_API_TOKEN","required":true}],"os":null,"systems":null},"owner":{"handle":"bombert","userId":"s17ezwe11e1pyfxzka699prf4x83j1kd","displayName":"yichen","image":"https://avatars.githubusercontent.com/u/3349426?v=4"},"moderation":null}