fix: doctor report list shows all patient reports, upload area supports file selection, start-dev.bat starts frontends
This commit is contained in:
@@ -14,6 +14,14 @@ public class ReportService(AppDbContext db)
|
||||
.OrderByDescending(r => r.UploadedAt)
|
||||
.ToListAsync();
|
||||
|
||||
public async Task<List<Report>> GetAllReportsAsync()
|
||||
=> await db.Reports
|
||||
.Include(r => r.Patient)
|
||||
.Include(r => r.Doctor)
|
||||
.Include(r => r.Items)
|
||||
.OrderByDescending(r => r.UploadedAt)
|
||||
.ToListAsync();
|
||||
|
||||
public async Task<Report?> GetByIdAsync(Guid id)
|
||||
=> await db.Reports
|
||||
.Include(r => r.Patient)
|
||||
|
||||
@@ -16,12 +16,33 @@ public class ReportController(ReportService reportService) : ControllerBase
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetReports()
|
||||
{
|
||||
var targetUserId = UserId;
|
||||
if (Role == "doctor" && Request.Query.ContainsKey("patientId"))
|
||||
targetUserId = Guid.Parse(Request.Query["patientId"]!);
|
||||
// Patients: see own reports. Doctors: see all reports (or filter by patientId)
|
||||
if (Role == "doctor")
|
||||
{
|
||||
if (Request.Query.ContainsKey("patientId"))
|
||||
{
|
||||
var targetUserId = Guid.Parse(Request.Query["patientId"]!);
|
||||
var reports = await reportService.GetPatientReportsAsync(targetUserId);
|
||||
return Ok(reports.Select(r => new
|
||||
{
|
||||
r.Id, r.PatientId, r.Title, r.Category, r.ImageUrls, r.Status,
|
||||
r.RiskLevel, r.UploadedAt, r.CompletedAt,
|
||||
PatientName = r.Patient?.Name,
|
||||
DoctorName = r.Doctor?.Name,
|
||||
}));
|
||||
}
|
||||
var allReports = await reportService.GetAllReportsAsync();
|
||||
return Ok(allReports.Select(r => new
|
||||
{
|
||||
r.Id, r.PatientId, r.Title, r.Category, r.ImageUrls, r.Status,
|
||||
r.RiskLevel, r.UploadedAt, r.CompletedAt,
|
||||
PatientName = r.Patient?.Name,
|
||||
DoctorName = r.Doctor?.Name,
|
||||
}));
|
||||
}
|
||||
|
||||
var reports = await reportService.GetPatientReportsAsync(targetUserId);
|
||||
return Ok(reports.Select(r => new
|
||||
var myReports = await reportService.GetPatientReportsAsync(UserId);
|
||||
return Ok(myReports.Select(r => new
|
||||
{
|
||||
r.Id, r.PatientId, r.Title, r.Category, r.ImageUrls, r.Status,
|
||||
r.RiskLevel, r.UploadedAt, r.CompletedAt,
|
||||
|
||||
Reference in New Issue
Block a user