MedPlan: A Two-Stage RAG-Based System for Personalized Medical Plan Generation

Hsin-Ling Hsu, Cong-Tinh Dao, Luning Wang, Zitao Shuai, Thao Nguyen Minh Phan, Jun-En Ding, Chun-Chieh Liao, Pengfei Hu, Xiaoxue Han, Chih-Ho Hsu, Dongsheng Luo, Wen-Chih Peng, Feng Liu, Fang-Ming Hung, Chenwei Wu

Abstract

Despite recent success in applying large language models (LLMs) to electronic health records (EHR), most systems focus primarily on assessment rather than treatment planning. We identify three critical limitations in current approaches: they generate treatment plans in a single pass rather than following the sequential reasoning process used by clinicians; they rarely incorporate patient-specific historical context; and they fail to effectively distinguish between subjective and objective clinical information. Motivated by the SOAP methodology (Subjective, Objective, Assessment, Plan), we introduce MedPlan, a novel framework that structures LLM reasoning to align with real-life clinician workflows. Our approach employs a two-stage architecture that first generates a clinical assessment based on patient symptoms and objective data, then formulates a structured treatment plan informed by this assessment and enriched with patient-specific information through retrieval-augmented generation. Comprehensive evaluation demonstrates that our method significantly outperforms baseline approaches in both assessment accuracy and treatment plan quality. Our demo system and code are available at https://github.com/JustinHsu1019/MedPlan.

Introduction

Large Language Models (LLMs) have shown significant promise in processing Electronic Health Records (EHR), yet a critical gap remains: most existing systems excel at assessment (diagnosis) but struggle with treatment planning. Current AI medical assistants often fail due to a reasoning mismatch, where models attempt to generate plans in a single pass rather than following the sequential diagnostic process used by human clinicians. Furthermore, these models frequently ignore a patient’s longitudinal historical context and struggle to distinguish between subjective patient reports and objective clinical data.

To address these challenges, we introduce MedPlan, a novel framework designed to align with the SOAP methodology (Subjective, Objective, Assessment, Plan). By mirroring the cognitive workflow of healthcare professionals, MedPlan ensures that diagnostic reasoning serves as a prerequisite for treatment formulation.

Methodology

The core of MedPlan is a two-stage Retrieval-Augmented Generation (RAG) pipeline that structures the clinical reasoning process.

Stage 1: Assessment Generation

In the first stage, the system processes the patient's current symptoms (Subjective) and laboratory data (Objective). It utilizes a sophisticated two-step retrieval process—comprising hybrid search (BM25 + bi-encoder) followed by a cross-encoder re-ranker—to extract relevant context from the patient's own history and similar "cross-patient" cases. This information is then used to generate a formal clinical Assessment (A).

Stage 2: Plan Generation

Using the Subjective and Objective data alongside the newly generated Assessment, the model performs a second round of retrieval to formulate a structured treatment Plan (P). This two-stage approach ensures the generated plan is grounded in a specific diagnostic reasoning anchor.

MedPlan's two-stage RAG-based architecture for assessment and plan generation.

To optimize performance, we fine-tuned several open-source backbones, including Medical-Llama3-8B and Medical-Mixtral-7B, using Low-Rank Adaptation (LoRA). These models were specifically trained to distinguish between patient narratives and objective measurements, ensuring high information alignment.

Data and Implementation

MedPlan was developed using a massive real-world dataset from Far Eastern Memorial Hospital (FEMH), consisting of 350,684 SOAP notes from 55,890 patients collected in 2021. The dataset covers both outpatient and emergency departments, providing a robust foundation for general medical scenarios. The RAG knowledge base was constructed from 6,000 patient records, with 3,000 additional records reserved for training and testing.

Results and Discussion

MedPlan demonstrated substantial improvements across all standard NLP metrics. On the Medical-Llama3-8B backbone, the addition of RAG components raised the BLEU score from 0.052 to 0.307 and the METEOR score from 0.173 to 0.501. Clinical validation by human physicians at FEMH further confirmed these results, showing an approximately 66% improvement in assessment quality compared to baseline LLM approaches.

Qualitative comparison between MedPlan and baseline models on a cardiovascular case study.

As illustrated in the cardiovascular case study above, baseline models often provide generic advice such as "Keep current Rx." In contrast, MedPlan correctly prioritizes specific interventions like "Cardiac catheterization" and lifestyle modifications, closely matching expert human judgment. This highlights the importance of longitudinal context; by retrieving "Self-history," the model can identify previous treatment failures and provide safer, more personalized recommendations.

Conclusion and Future Work

MedPlan represents a significant advancement in clinical AI by aligning LLM reasoning with established medical workflows. While currently limited by its reliance on a single-institution dataset, the framework's consistent performance across different backbone models suggests high potential for scalability. Future work will focus on expanding the dataset to multiple institutions and refining the system's ability to handle complex multi-morbidity cases through enhanced chain-of-thought reasoning.

Summary updated

BibTeX
@inproceedings{hsu2025medplan,
  author = {Hsin-Ling Hsu and Cong-Tinh Dao and Luning Wang and Zitao Shuai and Thao Nguyen Minh Phan and Jun-En Ding and Chun-Chieh Liao and Pengfei Hu and Xiaoxue Han and Chih-Ho Hsu and Dongsheng Luo and Wen-Chih Peng and Feng Liu and Fang-Ming Hung and Chenwei Wu},
  title = {{MedPlan: A Two-Stage RAG-Based System for Personalized Medical Plan Generation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
  url = {https://openreview.net/forum?id=NHCyoVBxmI},
}
Figure