Implement US-13 patient authentication and persistent ownership
This commit is contained in:
1 parent
ebf50827d6
commit
0ce9b2b168
36 files changed
+1203
-28
No files matched your search
@@ -12,8 +12,24 @@ public sealed class PatientController(PatientApplicationService service) : Contr
|
||||
[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));
|
||||
var accountId = Request.Headers["X-Account-Id"].ToString();
|
||||
if (string.IsNullOrWhiteSpace(accountId)) return BadRequest();
|
||||
try
|
||||
{
|
||||
var patient = await service.CreatePatientAsync(request, accountId, cancellationToken);
|
||||
return CreatedAtAction(nameof(GetPatient), new { patientId = patient.PatientId }, ToDto(patient));
|
||||
}
|
||||
catch (ProfileAlreadyExistsException)
|
||||
{
|
||||
return Conflict(new { title = "A profile already exists for this account." });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("by-account/{accountId}")]
|
||||
public async Task<ActionResult<PatientDto>> GetByAccount(string accountId, CancellationToken cancellationToken)
|
||||
{
|
||||
var patient = await service.GetByAccountAsync(accountId, cancellationToken);
|
||||
return patient is null ? NotFound() : Ok(ToDto(patient));
|
||||
}
|
||||
|
||||
[HttpGet("{patientId:guid}")]
|
||||
|
||||
Reference in new issue
Block a user