fix: prevent duplicate consultations in backend, health calendar shows medication dots
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user