Inspiration
Clinical trials run for years. Patient data lives scattered across session notes, emails, and spreadsheets. When a doctor asks "what happened to this patient three months ago?", nobody knows fast enough. Adverse events get missed. Documentation takes hours. We built CTMC to fix that.
What it does
CTMC is a persistent AI memory system for clinical trial teams. It:
- Remembers everything every session note is chunked, embedded using Qwen's
text-embedding-v3model, and stored as searchable semantic memory scoped to each patient and trial - Recalls on demand ask any natural language question and get a grounded answer with exact session date citations, powered by Qwen-max RAG
- Detects anomalies automatically on every new session ingestion, the agent compares new data against prior memory and fires alerts for safety concerns like escalating lab values or protocol deviations
- Generates FDA reports in one click adverse event reports, protocol deviation reports, and patient progress summaries drafted automatically from memory
- Logs every access a full compliance audit trail of every memory read and write
How we built it
Backend: Node.js / Express API with a custom memory engine. Session notes are chunked by semantic boundaries, embedded via Qwen Cloud's text-embedding-v3 API, and stored with full metadata (patient ID, trial ID, session date, chunk type). Queries are embedded and ranked by cosine similarity, then synthesized by qwen-max with strict grounding instructions to prevent hallucination.
Frontend: React + Vite with a clean clinical UI, Memory Recall chat, Log Session form, Alerts dashboard, Report Generator, and Audit Trail.
Infrastructure: Deployed on Alibaba Cloud ECS (Singapore region), running 24/7 via PM2.
AI Stack: Qwen Cloud APIs, qwen-max for synthesis and text-embedding-v3 for semantic memory.
Challenges we ran into
- Prompt engineering for grounding getting Qwen-max to answer strictly from retrieved memory chunks without hallucinating took careful system prompt design
- Anomaly detection reliability the first version of the anomaly detector parsed Qwen's JSON response incorrectly and returned false negatives; fixed by tightening the output format instructions
- Persistent memory across restarts moved from in-memory arrays to a file-based store to survive server restarts without needing a full database setup
- Codespaces networking Codespaces public URLs are unreliable for external requests; solved by deploying fully to Alibaba Cloud ECS and pointing the frontend to its own server
Accomplishments that we're proud of
- Built a fully working persistent memory pipeline from scratch using Qwen Cloud APIs, not a wrapper around an existing agent framework
- The anomaly detector fires automatically on ingestion and correctly identified escalating liver toxicity across sessions in live testing
- Generated a complete, structured FDA adverse event report from 6 months of patient memory in under 10 seconds
- Deployed a production-grade system on Alibaba Cloud ECS with PM2 process management, audit logging, and compliance trail, not just a demo prototype
- The ALT progression demo (22 → 24 → 31 → 52 → 89 → 112 U/L across 6 sessions) shows the memory genuinely accumulating clinical intelligence over time
What we learned
Retrieval-augmented generation is dramatically more useful than pure chat when the domain has high-stakes factual requirements. Grounding every answer in cited source sessions isn't just a nice-to-have, in clinical contexts it's the difference between a useful tool and a dangerous one.
What's next for CTMC, Clinical Trial Memory Coordinator
- Swap file store for Alibaba Cloud OpenSearch vector database for production scale
- Add multi-patient and multi-trial support with proper authentication
- Integrate with HL7 FHIR for real EHR data ingestion
- Add a memory timeline visualization showing how the patient's condition evolved
Built With
- alibaba
- cloud
- ecs
- express.js
- javascript
- node.js
- qwen
- qwen-max
- react
- text-embedding-v3
- vite

Log in or sign up for Devpost to join the conversation.