Implement US-10 on-demand health insights
This commit is contained in:
1 parent
4cb6798ec9
commit
a5b269cfc3
25 files changed
+482
-4
No files matched your search
@@ -0,0 +1,19 @@
|
||||
using System.Globalization;
|
||||
using InsightsService.Contracts;
|
||||
|
||||
namespace InsightsService.Clients;
|
||||
|
||||
public sealed class HttpObservationServiceClient(HttpClient client) : ObservationServiceClient
|
||||
{
|
||||
public async Task<List<ObservationDto>> GetByPeriodAsync(Guid patientId, DateTime from, DateTime to,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var start = Uri.EscapeDataString(from.ToString("O", CultureInfo.InvariantCulture));
|
||||
var end = Uri.EscapeDataString(to.ToString("O", CultureInfo.InvariantCulture));
|
||||
using var response = await client.GetAsync($"api/patients/{patientId}/observations?from={start}&to={end}",
|
||||
HttpCompletionOption.ResponseHeadersRead, cancellationToken);
|
||||
response.EnsureSuccessStatusCode();
|
||||
return await response.Content.ReadFromJsonAsync<List<ObservationDto>>(cancellationToken)
|
||||
?? throw new HttpRequestException("Observation history response was empty.");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user