Implement US-09 blood-pressure observation deletion
This commit is contained in:
1 parent
e4379ad2f4
commit
4cb6798ec9
7 files changed
+112
-1
No files matched your search
@@ -10,6 +10,10 @@ public sealed class ObservationController(IHttpClientFactory clients) : Controll
|
||||
public Task RecordObservation(Guid patientId, CancellationToken cancellationToken) =>
|
||||
ForwardAsync(HttpMethod.Post, $"api/patients/{patientId}/observations", cancellationToken);
|
||||
|
||||
[HttpDelete("observations/{observationId:guid}")]
|
||||
public Task DeleteObservation(Guid observationId, CancellationToken cancellationToken) =>
|
||||
ForwardAsync(HttpMethod.Delete, $"api/observations/{observationId}", cancellationToken);
|
||||
|
||||
[HttpPut("observations/{observationId:guid}")]
|
||||
public Task UpdateObservation(Guid observationId, CancellationToken cancellationToken) =>
|
||||
ForwardAsync(HttpMethod.Put, $"api/observations/{observationId}", cancellationToken);
|
||||
|
||||
@@ -6,6 +6,9 @@ namespace ObservationService.Application;
|
||||
|
||||
public sealed class ObservationApplicationService(ObservationRepository repository, IHttpClientFactory clients)
|
||||
{
|
||||
public Task<bool> DeleteAsync(Guid observationId, CancellationToken cancellationToken) =>
|
||||
repository.DeleteAsync(observationId, cancellationToken);
|
||||
|
||||
public Task<BloodPressureObservation?> UpdateAsync(Guid observationId, UpdateObservationRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace ObservationService.Application;
|
||||
|
||||
public interface ObservationRepository
|
||||
{
|
||||
Task<bool> DeleteAsync(Guid observationId, CancellationToken cancellationToken);
|
||||
Task<BloodPressureObservation?> UpdateValuesAsync(Guid observationId, int systolic, int diastolic, int pulse,
|
||||
DateTime updatedAt, CancellationToken cancellationToken);
|
||||
Task<BloodPressureObservation> SaveAsync(BloodPressureObservation observation, CancellationToken cancellationToken);
|
||||
|
||||
@@ -31,6 +31,10 @@ public sealed class ObservationController(ObservationApplicationService service)
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete("observations/{observationId:guid}")]
|
||||
public async Task<IActionResult> DeleteObservation(Guid observationId, CancellationToken cancellationToken) =>
|
||||
await service.DeleteAsync(observationId, cancellationToken) ? NoContent() : NotFound();
|
||||
|
||||
[HttpPut("observations/{observationId:guid}")]
|
||||
public async Task<ActionResult<ObservationDto>> UpdateObservation(Guid observationId, UpdateObservationRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
|
||||
@@ -6,6 +6,10 @@ namespace ObservationService.Persistence;
|
||||
|
||||
public sealed class SqlObservationRepository(ObservationDbContext db) : ObservationRepository
|
||||
{
|
||||
public async Task<bool> DeleteAsync(Guid observationId, CancellationToken cancellationToken) =>
|
||||
await db.Observations.Where(o => o.ObservationId == observationId)
|
||||
.ExecuteDeleteAsync(cancellationToken) > 0;
|
||||
|
||||
public async Task<BloodPressureObservation?> UpdateValuesAsync(Guid observationId, int systolic, int diastolic,
|
||||
int pulse, DateTime updatedAt, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
+5
-1
@@ -1,4 +1,4 @@
|
||||
# US-01–US-08: Patient profiles and blood-pressure observations
|
||||
# US-01–US-09: Patient profiles and blood-pressure observations
|
||||
|
||||
Implemented with .NET 10 LTS (see the [official download page](https://dotnet.microsoft.com/en-us/download/dotnet/10.0)), ASP.NET Core controllers, and PostgreSQL/EF Core. The API gateway, Patient/Profile service and Observation Service are separate executables and can run on separate machines. Each domain service owns its database.
|
||||
|
||||
@@ -60,6 +60,10 @@ US-07 tests cover all four acceptance scenarios, patient-specific filtering, per
|
||||
|
||||
US-08 tests cover the documented correction and rejection scenarios, correction of all three values, persistence after restart, preservation of other fields and creation time, modification timestamps, visibility in latest/history, unaffected other observations, and missing/malformed values. No new dependencies are introduced.
|
||||
|
||||
`DELETE /api/observations/{observationId}` removes the observation and returns `204 No Content`. A missing or previously deleted observation returns `404`. The Observation Service deletes the row from its own database in a single statement; deleted observations disappear from specific retrieval, history, and latest selection. Other observations and the patient profile are preserved.
|
||||
|
||||
US-09 tests cover both acceptance scenarios, persistence of deletion after restart, remaining/latest observations, deletion of the only observation, repeated deletion, and preservation of other patients' observations. No new dependencies or schema changes are required.
|
||||
|
||||
Authentication and access control are defined in US-13, US-14 and `Docs/Design/authentication-and-access-control-design.md`, and remain to be implemented as separate stories, as explicitly instructed. These endpoints currently have no access restrictions.
|
||||
|
||||
## Automated acceptance tests
|
||||
|
||||
Reference in new issue
Block a user