Implement US-01 patient profile creation and retrieval
This commit is contained in:
1 parent
d6f79a91c0
commit
eb2cf2e54a
30 files changed
+792
No files matched your search
@@ -0,0 +1,28 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using PatientProfileService.Application;
|
||||
using PatientProfileService.Contracts;
|
||||
using PatientProfileService.Domain;
|
||||
|
||||
namespace PatientProfileService.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/patients")]
|
||||
public sealed class PatientController(PatientApplicationService service) : ControllerBase
|
||||
{
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<PatientDto>> CreatePatient(CreatePatientRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var patient = await service.CreatePatientAsync(request, cancellationToken);
|
||||
return CreatedAtAction(nameof(GetPatient), new { patientId = patient.PatientId }, ToDto(patient));
|
||||
}
|
||||
|
||||
[HttpGet("{patientId:guid}")]
|
||||
public async Task<ActionResult<PatientDto>> GetPatient(Guid patientId, CancellationToken cancellationToken)
|
||||
{
|
||||
var patient = await service.GetPatientAsync(patientId, cancellationToken);
|
||||
return patient is null ? NotFound() : Ok(ToDto(patient));
|
||||
}
|
||||
|
||||
private static PatientDto ToDto(Patient patient) =>
|
||||
new(patient.PatientId, patient.Name, patient.DateOfBirth, patient.ContactInfo);
|
||||
}
|
||||
Reference in new issue
Block a user