Development of an On-Premises Retrieval-Augmented Generation System for Electronic Health Records Retrieval in Level 5 Hospitals in Kenya
Author
Kevin Comba Gatimu, James Mwikya, Stephen Mageto
Abstract
Architectural proposals for privacy-preserving clinical artificial intelligence are more numerous than working implementations, and the question of whether a full Retrieval-Augmented Generation (RAG) pipeline can in fact be built and operated within the hardware and connectivity envelope of an African county referral hospital remains largely untested. This article reports the second objective of a design science study: the development of an On-Premises RAG system for retrieving electronic health records in Level 5 hospitals in Kenya. Following the Design Science Research Methodology, a previously validated five-layer architecture was implemented as an Electron desktop application in which every component, comprising embedding generation, vector indexing and language-model inference, executes on local hardware. Embeddings were produced locally at 1,024 dimensions by qwen3-embedding-0.6b and indexed with Hierarchical Navigable Small World graphs in a MongoDB-compatible document database, while inference was served locally by Microsoft Foundry Local with automatic execution-provider selection. A synthetic corpus representing the electronic medical record database of a fictitious institution, comprising 60 patients and 120 clinical encounters across 25 referentially complete relational tables, yielded 1,603 source rows ingested as 1,603 chunks, each carrying lineage metadata to its source record. The corpus is exactly reproducible from a fixed seed and its integrity is verified before ingestion, a safeguard introduced after a defect in an earlier corpus invalidated a complete evaluation cycle. The seven requirements in the specification were implemented and verified, role-based access control mapped five cadre-aligned roles to twelve application pages, every action over patient data was written to an append-only audit log, and network monitoring during operation confirmed that no external call was made. The system operated within a 32 GB memory envelope at approximately 70 per cent resident memory, with inference executing on an integrated Intel Arc graphics processor through OpenVINO. Two boundaries are stated rather than left to inference: operation on a central processing unit alone was not demonstrated, and the implemented security controls were verified functionally but not subjected to security testing.
Keywords
Retrieval-Augmented Generation; on-premises deployment; small language models; electronic health records; system development; Kenya
Full Text:
Download Paper PDF
References
Alaran, M. A., Lawal, S. K., Jiya, M. H., Egya, S. A., Ahmed, M. M., Abdulsalam, A., Haruna, U. A., Musa, M. K., & Lucero-Prisno, D. E., III. (2025). Challenges and opportunities of artificial intelligence in African health space. Digital Health, 11, 20552076241305915. https://doi.org/10.1177/20552076241305915
Amugongo, L. M., Mascheroni, P., Brooks, S., Doering, S., & Seidel, J. (2025). Retrieval augmented generation for large language models in healthcare: A systematic review. PLOS Digital Health, 4(6), e0000877. https://doi.org/10.1371/journal.pdig.0000877
Creswell, J. W., & Plano Clark, V. L. (2018). Designing and conducting mixed methods research (3rd ed.). SAGE Publications.
Data Protection (General) Regulations, 2021, Legal Notice No. 263. (2021). Republic of Kenya. Kenya Gazette Supplement No. 186. https://www.odpc.go.ke/wp-content/uploads/2023/05/Kenya-Gazette-Supplement-No.-186-Data-Protection-General-Regulations-2021.pdf
Data Protection Act, No. 24 of 2019. (2019). Republic of Kenya. Kenya Gazette Supplement. https://www.odpc.go.ke/wp-content/uploads/2023/01/Kenya-Data-Protection-Act-2019.pdf
Digital Health Act, No. 15 of 2023. (2023). Republic of Kenya. Kenya Gazette Supplement. https://kenyalaw.org/kl/fileadmin/pdfdownloads/Acts/2023/TheDigitalHealthAct_No.15of2023.pdf
Frantar, E., Ashkboos, S., Hoefler, T., & Alistarh, D. (2023). GPTQ: Accurate post-training quantization for generative pre-trained transformers. arXiv. https://arxiv.org/abs/2210.17323v2
Gao, Y., Xiong, Y., Gao, X., Jia, K., Pan, J., Bi, Y., Dai, Y., Sun, J., Wang, M., & Wang, H. (2024). Retrieval-augmented generation for large language models: A survey. arXiv preprint arXiv:2312.10997. https://arxiv.org/abs/2312.10997
Hong, J., Duan, J., Zhang, C., Li, Z., Xie, C., Lieberman, K., Diffenderfer, J., Bartoldson, B. R., Jaiswal, A. K., Xu, K., Kailkhura, B., Hendrycks, D., Song, D., Wang, Z., & Li, B. (2024). Decoding compressed trust: Scrutinizing the trustworthiness of efficient LLMs under compression. In Proceedings of the 41st International Conference on Machine Learning (PMLR Vol. 235, pp. 18611–18633). https://proceedings.mlr.press/v235/hong24a.html
Kim, H., Hwang, H., Lee, J., Park, S., Kim, D., Lee, T., Yoon, C., Sohn, J., Park, J., Reykhart, O., Fetherston, T., Choi, D., Kwak, S. H., Chen, Q., & Kang, J. (2025). Small language models learn enhanced reasoning skills from medical textbooks. npj Digital Medicine, 8, Article 240. https://doi.org/10.1038/s41746-025-01653-8
Korom, R., Kiptinness, S., Adan, N., Said, K., Ithuli, C., Rotich, O., Kimani, B., King'ori, I., Kamau, S., Atemba, E., Aden, M., Bowman, P., Sharman, M., Soskin Hicks, R., Distler, R., Heidecke, J., Arora, R. K., & Singhal, K. (2025). AI-based clinical decision support for primary care: A real-world study. arXiv preprint arXiv:2507.16947. https://arxiv.org/abs/2507.16947
Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., Küttler, H., Lewis, M., Yih, W., Rocktäschel, T., Riedel, S., & Kiela, D. (2020). Retrieval-augmented generation for knowledge-intensive NLP tasks. In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, & H. Lin (Eds.), Advances in neural information processing systems 33 (pp. 9459–9474). Curran Associates.
Marcuzzi, F., Ning, X., Schwartz, R., & Gurevych, I. (2025). How quantization shapes bias in large language models. arXiv preprint arXiv:2508.18088. https://arxiv.org/abs/2508.18088
Mateen, B. A., Menon, V., Agweyu, A., Korom, R., Omoluabi, E., McAfee, D., Shimelash, N., Rutunda, S., Rugege, C., Williams, G., Emmanuel-Fabula, M., Denniston, A. K., Liu, X., & Miles, M. (2025). Trials for LLM-supported clinical decisions in African primary healthcare. Nature Medicine, 31(9), 2833–2835. https://doi.org/10.1038/s41591-025-03815-3
Microsoft. (2025). Foundry Local: Run AI models locally with hardware acceleration [Computer software]. Microsoft Corporation. https://github.com/microsoft/Foundry-Local
Oche, A. J., Folashade, A. G., Ghosal, T., & Biswas, A. (2025). A systematic review of key retrieval-augmented generation (RAG) systems: Progress, gaps, and future directions. arXiv preprint arXiv:2507.18910. https://arxiv.org/abs/2507.18910
Pan, G., Chodnekar, V., Roy, A., & Wang, H. (2025). A cost-benefit analysis of on-premise large language model deployment: Breaking even with commercial LLM services. arXiv preprint arXiv:2509.18101. https://arxiv.org/abs/2509.18101
Peffers, K., Tuunanen, T., Rothenberger, M. A., & Chatterjee, S. (2007). A design science research methodology for information systems research. Journal of Management Information Systems, 24(3), 45–77. https://doi.org/10.2753/MIS0742-1222240302
Pulkkinen, J., Huttu, K., & Suhonen, M. (2025). Systemic challenges in AI adoption in public social and health organizations in Finland: A technology-organisation-environment perspective. Journal of Health Organization and Management, 39(9), 435–456. https://doi.org/10.1108/JHOM-06-2025-0309
Singh, A., Ehtesham, A., Kumar, S., Khoei, T. T., & Vasilakos, A. V. (2025). Agentic retrieval-augmented generation: A survey on agentic RAG. arXiv preprint arXiv:2501.09136. https://arxiv.org/abs/2501.09136
Sriram, A., Maheswaran, N., Sundan, B., & Krishnamoorthy, S. (2025). Context-aware retrieval-augmented generation for artificial intelligence in urology. Cureus, 17(7), e88167. https://doi.org/10.7759/cureus.88167
Tornatzky, L. G., & Fleischer, M. (1990). The processes of technological innovation. Lexington Books.
Wampler, D., Nielson, D., & Seddighi, A. (2025). Engineering the RAG stack: A comprehensive review of the architecture and trust frameworks for retrieval-augmented generation systems. arXiv preprint arXiv:2601.05264. https://arxiv.org/abs/2601.05264
Wang, J., Zeng, Y., Guo, J., Ma, Y., Liu, A., & Liu, X. (2025). SLMQuant: Benchmarking small language model quantization for practical deployment. arXiv preprint arXiv:2511.13023. https://arxiv.org/abs/2511.13023
Wang, X., Dang, T., Zhang, X., Kostakos, V., Witbrock, M. J., & Jia, H. (2025). HealthSLM-Bench: Benchmarking small language models for mobile and wearable healthcare monitoring. arXiv preprint arXiv:2509.07260. https://arxiv.org/abs/2509.07260
Wołk, K. (2025). Evaluating retrieval-augmented generation variants for clinical decision support: Hallucination mitigation and secure on-premises deployment. Electronics, 14(21), Article 4227. https://doi.org/10.3390/electronics14214227
Share your valuable work from Social Media Buttons