The most dangerous sentence in medical AI is 'the data is stored in the cloud.' For a private clinic handling patient records, diagnostic histories, and prescription data, any cloud-hosted AI system immediately raises GDPR compliance questions — and in Ukraine, additional requirements under the Law on Personal Data Protection. The solution is a RAG system that runs entirely on the clinic's own servers, with no patient data ever leaving the building.
What Is RAG and Why Does It Matter for Healthcare?
RAG — Retrieval-Augmented Generation — is an AI architecture that grounds language model responses in a specific knowledge base rather than relying on general training data. For a clinic, this means the AI assistant answers questions by searching through the clinic's verified documents: Ministry of Health protocols, PubMed articles, internal guidelines, and — critically — individual patient records.
The key advantage over a general LLM (like ChatGPT) is accuracy and auditability. A RAG system doesn't hallucinate answers from its training data; it retrieves specific documents and cites them. For clinical use, every answer includes a source reference: 'According to MOH Protocol 2024-14, updated 01.03.2024...' This makes the system medically defensible in a way that a general LLM never can be.
Architecture: Self-Hosted, Air-Gapped, GDPR-Compliant
The architecture for MedAssist (deployed at a 12-doctor Kyiv clinic, 400+ patients per day):
**Knowledge base:** 1,200+ MOH clinical protocols, 8,000 PubMed abstracts (curated by speciality), 3 years of anonymised case history summaries. All stored in a self-hosted Qdrant vector database running on a clinic server — no external network connections for the vector search component.
**LLM access:** GPT-4o is called via API for response generation only — the retrieval step uses local embeddings (OpenAI Embeddings can be replaced with a self-hosted model like `text-embedding-nomic-embed-text` for full air-gap). The documents sent to GPT-4o for response synthesis are retrieved summaries, not raw patient records — this means API calls contain clinical context, not personally identifiable information.
**FHIR R4 integration:** When a doctor asks about a specific patient ('Current medications for patient Kovalenko?'), the system queries the clinic's Medical Information System (MIS) via FHIR R4 REST API. The patient's current drug list, allergies, and chronic conditions are retrieved in structured format and injected into the RAG context — without storing patient data in the vector database.
**Audit trail:** Every query, retrieved document, and generated response is logged with timestamp and doctor ID. Required for GDPR Article 22 (automated decision-making transparency) and clinical governance.
UK Adaptation: NHS SNOMED CT and Information Governance
For UK private clinics and NHS trust deployments, the same architecture applies with two additional requirements.
First, clinical terminology must align with SNOMED CT — the standard coding system for NHS clinical data. The knowledge base indexing includes SNOMED CT concept codes alongside free-text content, enabling the system to match queries using standardised terminology rather than relying on exact word matches. A doctor asking about 'chest tightness' retrieves documents coded for both 'chest tightness (SNOMED: 23924001)' and related conditions.
Second, NHS Information Governance requires a Data Security and Protection Toolkit (DSPT) assessment for any system handling patient data. The self-hosted architecture makes DSPT compliance straightforward: data never leaves the trust's infrastructure, there are no third-party data processors for patient records, and the audit log satisfies access control requirements.
Implementation Results and Lessons Learned
For the Kyiv clinic deployment after 6 months in production:
- Clinical information retrieval time: 12 minutes (manual search across systems) → 90 seconds (RAG query)
- Doctor satisfaction: 9.2 / 10 (surveyed 12 doctors)
- Prescription errors attributed to information gaps: −23% in the first 6 months
- New doctor onboarding: orientation period reduced by 2 weeks (new doctors use RAG to navigate protocols rather than asking colleagues)
Lessons learned the hard way: anonymisation quality matters enormously. Our first iteration stored case summaries with dates and departments — recoverable to specific patients in a small clinic. The second iteration uses k-anonymity: case summaries are bucketed into cohorts (e.g., '45–55 year old female, cardiology, hypertension') before storage. Retrieval quality improved slightly because cohort-level patterns are more clinically useful than individual edge cases.
For any healthcare AI project, our recommendation is to start with a read-only system (no AI-suggested actions, only retrieved information) and expand to AI recommendations only after 3–6 months of supervised use. The technology is ready. The clinical workflows, governance structures, and staff trust take longer to build.
Related Codeworth Services
Need Help with Implementation?
The Codeworth team is ready to implement these ideas in your project. Free consultation.
Discuss the ProjectCo-founder of Codeworth with 7 years of UK fintech ML experience. Specialises in credit scoring with FCA compliance, ensemble methods including XGBoost and LightGBM, and ML experiment management via Python and MLflow. Has built production systems for credit decisioning processing millions of applications annually under FCA oversight. Holds deep knowledge of FCA model explainability requirements and Consumer Duty documentation standards.