fix: prevent duplicate consultations in backend, health calendar shows medication dots

This commit is contained in:
MingNian
2026-05-22 10:59:46 +08:00
parent 4a525124c5
commit 8caa374699
2 changed files with 64 additions and 39 deletions

View File

@@ -28,6 +28,12 @@ public class ConsultationService(AppDbContext db)
public async Task<Consultation> StartAsync(Guid patientId, Guid doctorId, string subject)
{
// Reuse existing active consultation between this patient and doctor
var existing = await db.Consultations
.FirstOrDefaultAsync(c => c.PatientId == patientId && c.DoctorId == doctorId && c.Status == "active");
if (existing != null)
return existing;
var consultation = new Consultation
{
PatientId = patientId,