Files
HealthAppRepositoryB/Reference/ArchitectureA/src/ApiGateway/Controllers/MeasurementGuidanceController.cs
T

63 lines
4.8 KiB
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace ApiGateway.Controllers;
[ApiController]
[AllowAnonymous]
[Route("api/measurement-guidance")]
public sealed class MeasurementGuidanceController : ControllerBase
{
[HttpGet]
public IActionResult Get([FromQuery] string? setting, [FromQuery] string? activityCondition)
{
var requestedSetting = string.IsNullOrWhiteSpace(setting) ? "Unknown" : setting.Trim();
var requestedActivity = string.IsNullOrWhiteSpace(activityCondition) ? "Unknown" : activityCondition.Trim();
if (!new[] { "Home", "Clinic", "Other", "Unknown" }.Contains(requestedSetting, StringComparer.OrdinalIgnoreCase))
return Problem(statusCode: 400, title: "Unsupported measurement setting.");
if (!new[] { "AtRest", "DuringActivity", "AfterActivity", "Unknown" }.Contains(requestedActivity, StringComparer.OrdinalIgnoreCase))
return Problem(statusCode: 400, title: "Unsupported activity condition.");
var available = requestedSetting.Equals("Home", StringComparison.OrdinalIgnoreCase)
|| requestedSetting.Equals("Unknown", StringComparison.OrdinalIgnoreCase);
return Ok(new
{
available,
requestedSetting,
requestedActivityCondition = requestedActivity,
applicableSetting = available ? "Home" : null,
applicableActivityCondition = available ? "AtRest" : null,
reviewedOn = available ? "2026-10-04" : null,
explanation = available
? "These instructions apply to resting home self-measurement, not a clinical measurement protocol. Unknown conditions remain unknown; requesting guidance does not record a setting or certify compliance."
: "Verified guidance is unavailable for the requested setting. Home instructions have not been substituted for clinical or other-setting instructions.",
steps = available ? new[]
{
new GuidanceStep(1, "Equipment", "Use a validated upper-arm device with a cuff suited to your arm. Follow its instructions for placement and maintenance; incorrect cuff size can distort readings."),
new GuidanceStep(2, "Preparation", "Choose a quiet place. Avoid smoking for 30 minutes beforehand and rest seated for five minutes."),
new GuidanceStep(3, "Position", "Sit with back and arm supported and legs uncrossed. Put the cuff on bare skin, clear of tight clothing, and keep the arm relaxed and still during measurement."),
new GuidanceStep(4, "Measure", "Use the device as instructed. Reproduce your setting, posture and preparation when possible to help later comparisons."),
new GuidanceStep(5, "Planned monitoring", "The cited Danish home protocol uses three readings in the morning before breakfast and three in the evening before dinner, over three consecutive days. This planned series differs from saving one observation; follow individually supplied clinical instructions."),
new GuidanceStep(6, "Record", "Save actual blood-pressure values in mmHg, device-reported pulse in beats/minute, and measurement time. Record setting, activity and preparation where known, including departures from routine. Do not discard, change or invent values to fit guidance.")
} : Array.Empty<GuidanceStep>(),
pulseExplanation = available
? "Rest and activity affect the context of pulse readings. One device-reported pulse value does not assess rhythm regularity."
: null,
activityExplanation = available
? "During-activity and after-activity measurements differ from resting measurements. Record the actual conditions; do not relabel them as resting. Such observations remain valid to record."
: null,
limitations = available
? "Guidance does not guarantee accuracy or replace device or individual clinical instructions. It does not recommend medication changes. Viewing or declining it does not save or alter observations, certify a procedure, or prevent a valid submission."
: null,
sources = available ? new[]
{
new GuidanceSource("Sundhed.dk — Højt blodtryk", "https://www.sundhed.dk/sundhedsfaglig/laegehaandbogen/hjerte-kar/symptomer-og-tegn/hoejt-blodtryk/", "2024-09-25"),
new GuidanceSource("Sundhed.dk — Blodtryksmåling", "https://www.sundhed.dk/sundhedsfaglig/laegehaandbogen/undersoegelser-og-proever/kliniske-procedurer/hjertekar/blodtryksmaaling/", "2025-03-13")
} : Array.Empty<GuidanceSource>()
});
}
private sealed record GuidanceStep(int Order, string Topic, string Instruction);
private sealed record GuidanceSource(string Title, string Url, string UpdatedOn);
}