Compare commits

...
30 Commits
Author SHA1 Message Date
Steffen b76897d8f8 Calculate energy from recorded power samples 2026-11-23 00:01:07 +01:00
Steffen 2117236366 documented the architecture and design as is 2026-10-14 00:44:26 +02:00
Steffen 5d9371388c Normalize generated measurement evidence formatting 2026-10-09 12:29:01 +02:00
Steffen e5f00796af Document measured rationale and headroom for 26-thread experiments 2026-10-09 12:28:27 +02:00
Steffen d69fcf8c76 Use Gaussian request delays with 500 ms minimum and one-second mean 2026-10-08 23:28:59 +02:00
Steffen 453e37b3c3 Support read-only shared-account capacity trials through request errors 2026-10-08 18:36:12 +02:00
Steffen 743674a022 Report aligned per-second CPU power requests latency and errors 2026-10-08 12:59:43 +02:00
Steffen 17f3b0dbd3 Sample CPU and Shelly power every second for energy runs 2026-10-08 12:41:48 +02:00
Steffen 79bb6a11cd Provide four-hour idle baseline without application requests 2026-10-08 08:25:17 +02:00
Steffen e50cf0a011 Collect Shelly plug power live in JMeter energy experiments 2026-10-07 22:12:58 +02:00
Steffen a69b9b2118 Collect NUC host metrics live in all JMeter energy scenarios 2026-10-07 21:03:19 +02:00
Steffen 45a040f3a2 Add four-hour JMeter energy workloads with Gaussian user pacing 2026-10-07 18:23:20 +02:00
Steffen 23a824dd81 US-16 Detect Debian-family dependencies instead of fixed OS versions 2026-10-07 16:49:48 +02:00
Steffen 7dc4ee60f0 US-16 Support Ubuntu 26.04 dependency provisioning 2026-10-07 16:41:20 +02:00
Steffen dd68d16eba added README.MD 2026-10-07 13:02:36 +02:00
Steffen 4562497541 Update requirements after they are implemented 2026-10-07 12:53:24 +02:00
Steffen eedf2a941b Provision US-16 dependencies credentials HTTPS and native service configurations 2026-10-06 09:11:28 +02:00
Steffen 950f67d8b7 Implement US-16 independent Linux service installation 2026-10-05 16:12:33 +02:00
Steffen b6342afdad Update architecture persistence diagrams and add implementation review 2026-10-05 14:46:00 +02:00
Steffen 076e675c81 Implement US-12 consolidated health overview service 2026-10-05 14:36:28 +02:00
Steffen cc76c9bde4 Implement US-11 context-aware health trend assessments 2026-10-05 13:51:16 +02:00
Steffen a0a9e2e9b9 Implement US-10 selected-context insights and final rounding 2026-10-05 13:26:22 +02:00
Steffen d21005b6fe Verify US-09 deletion of structured observation context 2026-10-05 12:55:07 +02:00
Steffen 5aefe52853 Implement US-08 partial observation and context corrections 2026-10-05 12:42:19 +02:00
Steffen ce03038ce1 Implement US-07 context-filtered observation history 2026-10-05 12:28:04 +02:00
Steffen ac6b42f32e Implement US-06 latest observation recording-time ties 2026-10-05 12:01:35 +02:00
Steffen 3bfa7ea149 Complete US-05 observation context retrieval acceptance coverage 2026-10-05 11:56:38 +02:00
Steffen cfacaa0c24 Implement US-04 structured measurement context recording 2026-10-05 11:52:39 +02:00
Steffen 5996481081 Implement US-14 assigned professional read access 2026-10-05 11:40:34 +02:00
Steffen 0ce9b2b168 Implement US-13 patient authentication and persistent ownership 2026-10-05 11:10:22 +02:00
185 changed files with 53031 additions and 79 deletions

No files matched your search

@@ -0,0 +1,38 @@
name: Prototype native installation
on:
workflow_dispatch:
permissions:
contents: read
jobs:
native-install:
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, windows-latest, macos-14]
runs-on: ${{ matrix.os }}
timeout-minutes: 40
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Build portable release on Unix
if: runner.os != 'Windows'
shell: bash
run: bash deploy/build-release.sh --output "$RUNNER_TEMP/healthapp-release"
- name: Build portable release on Windows
if: runner.os == 'Windows'
shell: pwsh
run: ./deploy/build-release.ps1 -Output "$env:RUNNER_TEMP/healthapp-release"
- name: Provision and verify Ubuntu/systemd
if: runner.os == 'Linux'
shell: bash
run: sudo bash "$RUNNER_TEMP/healthapp-release/install.sh" --services all --host localhost --dotnet "$(command -v dotnet)"
- name: Provision and verify Windows Services
if: runner.os == 'Windows'
shell: pwsh
run: '& "$env:RUNNER_TEMP/healthapp-release/install.ps1" -Services all -HostName localhost'
- name: Provision and verify macOS/launchd
if: runner.os == 'macOS'
shell: bash
run: sudo bash "$RUNNER_TEMP/healthapp-release/install.sh" --services all --host localhost
+7
View File
@@ -6,3 +6,10 @@ TestResults/
# Draw.io backup files
Docs/Architecture/.*.bkp
# Private workload credentials and generated measurement results
tools/energy-jmeter/.private/
tools/energy-jmeter/results/
tools/energy-jmeter/hash-tool/
jmeter.log
__pycache__/
+38
View File
@@ -0,0 +1,38 @@
# HealthApp as-built architecture
Snapshot: **2026-10-12**, repository commit `5d9371388c15066eeb2bc124ed227659c644dab5`. This describes the checked-out implementation, not a proposed architecture or a certification of a running installation.
## Documents
| Document | Contents |
| --- | --- |
| [Software architecture](software-architecture.md) | Runtime structure, contracts, data, security, deployment and failures |
| [Architecture decisions](architecture-decisions.md) | Observable decisions, evidence, rationale provenance and consequences |
| [Requirements traceability](requirements-traceability.md) | US-01–US-16 implementation and test mapping; coverage limits |
| [Discrepancies](discrepancies.md) | Historical differences, current omissions and unresolved uncertainties |
| [Evidence inventory](evidence-inventory.md) | Source/configuration/test inventory and inspection boundaries |
| [Validation](validation.md) | Deliverable, diagram, link and preservation checks |
| [Class-diagram coverage](class-diagram-coverage.md) | Every declared service type mapped to an individual UML classifier and source file |
## Editable diagrams
Open these files directly in diagrams.net / Draw.io. They contain native shapes, text and connectors, rather than embedded screenshots. Page tabs separate detailed views.
| File | Pages / purpose |
| --- | --- |
| [01-system-context.drawio](diagrams/01-system-context.drawio) | Actors, system boundary and optional experiment infrastructure |
| [02-logical-services.drawio](diagrams/02-logical-services.drawio) | Five processes, gateway routing and local layers |
| [03-domain-model.drawio](diagrams/03-domain-model.drawio) | Complete application domain: health, access, assignments, guidance, assessments and references; separate supporting deployment domain |
| [ApiGateway class diagram](diagrams/04-class-ApiGateway.drawio) | All 16 declared types, including controllers, security and nested records |
| [PatientProfileService class diagram](diagrams/04-class-PatientProfileService.drawio) | All 14 declared types; runtime and EF migration pages |
| [ObservationService class diagram](diagrams/04-class-ObservationService.drawio) | All 17 declared types; runtime and EF migration pages |
| [InsightsService class diagram](diagrams/04-class-InsightsService.drawio) | All 16 declared types, including individual DTO/result/reference records |
| [HealthOverviewService class diagram](diagrams/04-class-HealthOverviewService.drawio) | All 15 declared types, including distinct abstract/HTTP clients and DTOs |
| [04-design-classes.drawio](diagrams/04-design-classes.drawio) | Combined copy of the five service diagrams, plus the administrative provisioning view |
| [05-data-ownership.drawio](diagrams/05-data-ownership.drawio) | Physical tables, file/configuration ownership and transient results |
| [06-deployment.drawio](diagrams/06-deployment.drawio) | Colocated and distributed Linux topologies; Windows/macOS adapters |
| [07-sequences.drawio](diagrams/07-sequences.drawio) | Login/create, record, read/update/delete ownership, calculations, overview, professional access and installation |
## Interpretation
**Verified** means directly observable in repository implementation or configuration; a cited test demonstrates the intended check, not that it was executed in this documentation task. **Inferred** labels a consequence or rationale derived from that evidence. **Unknown** labels something the repository cannot establish. Existing specifications and functionality were preserved. No application code was generated or changed, and no live host was accessed.
@@ -0,0 +1,30 @@
# Observable architecture decisions
These records describe existing choices. They are not new approvals or proposed ADRs. **Documented rationale** is stated in a repository document; **inferred rationale/consequence** is analysis of the code; **unknown rationale** means no reason was found. Each decision is verified independently from implementation evidence.
| ID | Implemented decision and evidence | Rationale provenance | Consequences / limits |
| --- | --- | --- | --- |
| AB-01 | Five independent ASP.NET Core processes; no production service-to-service project references. [Solution](../HealthApp.slnx), [release build](../deploy/build-release.sh) | Documented: independent boundaries and location-independent deployment in [US-16](<../Docs/Requirements/US16 easy installation and deployment installer.txt>) and [service architecture](../Docs/Architecture/02_microservice_architecture.jpg) | Each service publishes/configures/stops separately. Availability dependencies still exist through HTTP. |
| AB-02 | All business HTTP between services goes through Gateway. [Observation](../src/ObservationService/Program.cs), [Insights](../src/InsightsService/Program.cs), [Overview](../src/HealthOverviewService/Program.cs) | Documented path in [architecture correction](../Docs/Architecture/us10-insights-correction.md) and existing service diagram. Additional rationale beyond that choice is unknown. | Inferred: extra hops and centralized availability/load; no direct aggregator-to-source shortcuts. |
| AB-03 | Controllers explicitly forward requests using named HttpClients. [Gateway Observation controller](../src/ApiGateway/Controllers/ObservationController.cs) | Unknown: no separate ADR explaining selection over a proxy library | Routes/header handling are explicit; forwarding implementation is duplicated, and only selected response headers survive. |
| AB-04 | Patient/Profile and Observation own separate PostgreSQL DBs/roles; context stored in same observation row. [contexts](../src/ObservationService/Persistence/ObservationDbContext.cs), [DB provisioning](../deploy/HealthApp.Provisioning/DatabaseProvisioning.cs) | Documented independent ownership in [addendum](../Docs/Requirements/us16-addendum). Same-row context is documented in [implementation README](../src/README.md); original logical model explicitly permits physical mapping choices. | No cross-service FK or DB joins. Context deletion is naturally row deletion. Optional preparation details do not require another table. |
| AB-05 | Account association resides in `patient.account_id`, with unique index. [migration](../src/PatientProfileService/Persistence/Migrations/20261005082209_AccountProfileAssociation.cs), [SQL repository](../src/PatientProfileService/Persistence/SqlPatientRepository.cs) | Documented: [authentication implementation](../src/AUTHENTICATION.md) explains single-row consistency and restart persistence | Concurrent creation cannot produce two non-null associations for one account. Existing nullable legacy associations are not backfilled. |
| AB-06 | Insights and Overview have no own DB/repository/result persistence. [Insights application](../src/InsightsService/Application/InsightsApplicationService.cs), [Overview application](../src/HealthOverviewService/Application/HealthOverviewApplicationService.cs) | Documented: [Insights correction](../Docs/Architecture/us10-insights-correction.md), [Overview implementation](../src/OVERVIEW.md) | New requests use current source data. No generated result ID/cache invalidation. Multi-service reads are not one snapshot. |
| AB-07 | Framework protected opaque bearer tickets; password hashing only at login. [login](../src/ApiGateway/Controllers/AuthenticationController.cs), [accounts](../src/ApiGateway/Security/PrototypeAccounts.cs), [startup](../src/ApiGateway/Program.cs) | Documented: [authentication design](../Docs/Design/authentication-and-access-control-design.md) separates credentials/token/policy, excludes custom crypto and repeated password verification. Concrete mechanism/lifetime recorded in [AUTHENTICATION.md](../src/AUTHENTICATION.md). | No JWT issuer/audience configuration, identity server or refresh workflow. Default 30-minute expiry requires new login. Token keys are persistent local files. |
| AB-08 | Gateway establishes ownership by protected HTTP reads and evaluates configured professional assignments. [middleware](../src/ApiGateway/Security/PatientAccessMiddleware.cs) | Documented: [authentication design](../Docs/Design/authentication-and-access-control-design.md) requires actual owner lookup and separated access policy | No ownership inside bearer token. Additional per-request lookup cost/dependency. Empty 404 hides cross-patient existence; professionals cannot write. |
| AB-09 | Backend shared-key guards; distinct callback keys with GET-only whitelist. [internal handler](../src/ApiGateway/Security/InternalServiceAuthenticationHandler.cs), [backend](../src/ObservationService/Program.cs) | Documented: [AUTHENTICATION.md](../src/AUTHENTICATION.md) selects prototype protection satisfying gateway-only enforcement | HTTPS protects key transport. Trusted backend incoming keys bypass end-user checks there; callback credentials have cross-patient access on their limited read routes. No mTLS or user delegation. |
| AB-10 | Require HTTPS outside Development; disable HTTP redirects in business clients. [Gateway Program](../src/ApiGateway/Program.cs), [Observation Program](../src/ObservationService/Program.cs) | HTTPS rationale documented in [authentication design](../Docs/Design/authentication-and-access-control-design.md). Credential redirect protection documented in [AUTHENTICATION.md](../src/AUTHENTICATION.md). | HTTP development is explicit. HTTP is rejected rather than automatically redirected; reverse-proxy forwarded-header support is absent. |
| AB-11 | UTC clock values stored in timestamp-without-timezone columns; offset normalization. [Observation application](../src/ObservationService/Application/ObservationApplicationService.cs) | Documented in [src README](../src/README.md): preserve original TIMESTAMP design while making instants/offset-free interpretation deterministic | Clients must interpret offset-free output as UTC. No local-zone interpretation or stored original offset. |
| AB-12 | Inclusive selection, deterministic latest UUID tie; history sorted by measurement time/UUID. [repository](../src/ObservationService/Persistence/SqlObservationRepository.cs) | Requirements prescribe inclusivity and deterministic ties; concrete final UUID order documented in [src README](../src/README.md) | Recording/edit order cannot override measurement-time precedence. Equal timestamps remain valid. No pagination/size bound. |
| AB-13 | Setter presence flags implement PATCH omission vs null; full numeric PUT remains. [patch](../src/ObservationService/Contracts/PatchObservationRequest.cs), [repository](../src/ObservationService/Persistence/SqlObservationRepository.cs) | Documented [US-08](../Docs/Requirements/us08-update-observation.md) requires preservation/clearing. Exact mechanism rationale inferred: distinguishes omitted JSON members from explicit clearing without a patch library. | Unknown PATCH/PUT fields rejected. No external JSON Patch dependency. No ETag/concurrency token. |
| AB-14 | Decimal final-only summary rounding; timestamp-grouped direction and OLS trend; static sourced references. [calculators](../src/InsightsService/Domain/InsightCalculator.Trends.cs) | Documented methods, clinical limits and cautious inference basis in [TRENDS.md](../src/TRENDS.md), required reproducibility in [US-11](../Docs/Requirements/us11-health-trend.md) | No prediction/significance test/diagnosis. Numerical evidence survives limited context; phrase detection cannot understand arbitrary narratives. Clinical applicability has not been independently validated by this task. |
| AB-15 | Overview reads profile → latest → insight sequentially; context selection applies only to insight. [application](../src/HealthOverviewService/Application/HealthOverviewApplicationService.cs) | Selection distinction documented in [US-12](../Docs/Requirements/us12-health-overview.md); lack of snapshot documented in [OVERVIEW.md](../src/OVERVIEW.md). Rationale for sequential execution is unknown. | Partial absence can still return available profile/latest; source failure returns failure. Inferred: latency follows dependent calls and writes may interleave. |
| AB-16 | External startup account/assignment config; no account/assignment administration API. [accounts](../src/ApiGateway/Security/PrototypeAccounts.cs), [assignments](../src/ApiGateway/Security/ProfessionalAssignments.cs) | Documented prototype scope in [US-13](../Docs/Requirements/us13-patient-authentication.md), [US-14](../Docs/Requirements/us14-professional-access.md) | No credential/assignment DB; changes require process restart. Existing token role/account claims are not rechecked against current account records every request. |
| AB-17 | Portable framework-dependent DLLs plus OS-specific package/service adapters. [build](../deploy/build-release.sh), [Linux](../deploy/installer/install.sh), [Windows](../deploy/installer/install.ps1), [macOS](../deploy/installer/install-macos.sh) | Documented in [INSTALLATION.md](../deploy/INSTALLATION.md): native deployment without combining processes, container requirement or host-generated apphost | Target runtime/native administration remain platform-specific. Non-Debian Linux automation is absent. Native-host execution evidence is limited. |
| AB-18 | Single generated topology plan; scoped SSH/SCP distribution; prototype CA + per-service certificates. [prepare](../deploy/HealthApp.Provisioning/Deployment.cs), [distribute](../deploy/HealthApp.Provisioning/Distribution.cs) | Documented normal-install automation in [US-16 addendum](../Docs/Requirements/us16-addendum), scoped distribution in [INSTALLATION.md](../deploy/INSTALLATION.md) | Compatible keys are automatic; separate independently prepared plans will not interoperate. CA signing private key is not retained. Admin access/network reachability still prerequisite. |
| AB-19 | Fail closed on ownership/upstream failure; absent aggregate data distinguished from dependency failure. [middleware](../src/ApiGateway/Security/PatientAccessMiddleware.cs), [Overview controller](../src/HealthOverviewService/Controllers/HealthOverviewController.cs) | Documented security requirement and [Overview error contract](../src/OVERVIEW.md) | 502/504 mapping, with generic 500 for some malformed ownership shapes. No resilience policy/circuit breaker. |
| AB-20 | Generated PostgreSQL connections disable pooling and use SSL Prefer. [Deployment.ConnectionString](../deploy/HealthApp.Provisioning/Deployment.cs) | Unknown: no explicit rationale found for these settings | Inferred: connection establishment recurs rather than using the driver pool; DB TLS is opportunistic rather than enforced. External configuration can change both. |
| AB-21 | Complete verification creates/reuses synthetic patient/observation then reads overview. [verification](../deploy/HealthApp.Provisioning/InstallationVerification.cs) | Documented in [INSTALLATION.md](../deploy/INSTALLATION.md), required representative workflow in US-16 | Installation can leave labelled test data; it is not a read-only check. No automatic native stop/restart cycle. |
| AB-22 | Public static guidance separate from observation writes. [controller](../src/ApiGateway/Controllers/MeasurementGuidanceController.cs) | Documented in [US-15](../Docs/Requirements/us15-measurement-guidance.md) | Available before records/login. No guidance read creates/certifies an observation. Sources are metadata, not runtime dependencies. |
No rationale has been invented for absent caching, missing optimistic concurrency, default business HTTP timeouts or the lack of deployment rollback. These are observable properties/limits, not necessarily deliberate tradeoffs documented by the authors.
@@ -0,0 +1,102 @@
# Implementation class-diagram coverage
Corrected after review: each service has its own UML class-diagram file. Every source-declared class, record and interface under that service is represented as an individual classifier. Nested types are named with their enclosing type; partial declarations count as one type. EF migrations, migration designers and model snapshots are included on separate persistence-support pages. No controller, DTO or request class is merged into a domain box.
Classifier compartments show actual attributes and operations with UML visibility. Record positional parameters are attributes plus a constructor. Primary-constructor parameters appear as constructor operations, with dependency links to local parameter types. They are not represented as invented C# fields. Explicit local attribute types supply associations; declared base classes/interfaces supply generalization/realization. The observation/context composition is justified by its EF-owned mapping. Inherited/automatically compiler-generated members are not enumerated.
Framework base types appear as labelled references, outside the service-defined type inventory. A same-service reference repeated on another page is marked as a reference and does not count as a second implementation type. Program registration dependencies do not mean shared cross-service memory or direct calls.
| Service | Declared types | Diagram |
| --- | --- | --- |
| ApiGateway | 16 | [ApiGateway](diagrams/04-class-ApiGateway.drawio) |
| PatientProfileService | 14 | [PatientProfileService](diagrams/04-class-PatientProfileService.drawio) |
| ObservationService | 17 | [ObservationService](diagrams/04-class-ObservationService.drawio) |
| InsightsService | 16 | [InsightsService](diagrams/04-class-InsightsService.drawio) |
| HealthOverviewService | 15 | [HealthOverviewService](diagrams/04-class-HealthOverviewService.drawio) |
## Exact inventory
| Service | Fully qualified source type | Kind | Source files | Page |
| --- | --- | --- | --- | --- |
| ApiGateway | `ApiGateway.Controllers.AuthenticationController` | class | [src/ApiGateway/Controllers/AuthenticationController.cs](../src/ApiGateway/Controllers/AuthenticationController.cs) | implementation classes |
| ApiGateway | `ApiGateway.Controllers.AuthenticationController.LoginRequest` | record | [src/ApiGateway/Controllers/AuthenticationController.cs](../src/ApiGateway/Controllers/AuthenticationController.cs) | implementation classes |
| ApiGateway | `ApiGateway.Controllers.HealthOverviewController` | class | [src/ApiGateway/Controllers/HealthOverviewController.cs](../src/ApiGateway/Controllers/HealthOverviewController.cs) | implementation classes |
| ApiGateway | `ApiGateway.Controllers.InsightsController` | class | [src/ApiGateway/Controllers/InsightsController.cs](../src/ApiGateway/Controllers/InsightsController.cs) | implementation classes |
| ApiGateway | `ApiGateway.Controllers.MeasurementGuidanceController` | class | [src/ApiGateway/Controllers/MeasurementGuidanceController.cs](../src/ApiGateway/Controllers/MeasurementGuidanceController.cs) | implementation classes |
| ApiGateway | `ApiGateway.Controllers.MeasurementGuidanceController.GuidanceSource` | record | [src/ApiGateway/Controllers/MeasurementGuidanceController.cs](../src/ApiGateway/Controllers/MeasurementGuidanceController.cs) | implementation classes |
| ApiGateway | `ApiGateway.Controllers.MeasurementGuidanceController.GuidanceStep` | record | [src/ApiGateway/Controllers/MeasurementGuidanceController.cs](../src/ApiGateway/Controllers/MeasurementGuidanceController.cs) | implementation classes |
| ApiGateway | `ApiGateway.Controllers.ObservationController` | class | [src/ApiGateway/Controllers/ObservationController.cs](../src/ApiGateway/Controllers/ObservationController.cs) | implementation classes |
| ApiGateway | `ApiGateway.Controllers.PatientController` | class | [src/ApiGateway/Controllers/PatientController.cs](../src/ApiGateway/Controllers/PatientController.cs) | implementation classes |
| ApiGateway | `ApiGateway.Controllers.ProfessionalController` | class | [src/ApiGateway/Controllers/ProfessionalController.cs](../src/ApiGateway/Controllers/ProfessionalController.cs) | implementation classes |
| ApiGateway | `ApiGateway.Program` | class | [src/ApiGateway/Program.cs](../src/ApiGateway/Program.cs) | implementation classes |
| ApiGateway | `ApiGateway.Security.InternalServiceAuthenticationHandler` | class | [src/ApiGateway/Security/InternalServiceAuthenticationHandler.cs](../src/ApiGateway/Security/InternalServiceAuthenticationHandler.cs) | implementation classes |
| ApiGateway | `ApiGateway.Security.PatientAccessMiddleware` | class | [src/ApiGateway/Security/PatientAccessMiddleware.cs](../src/ApiGateway/Security/PatientAccessMiddleware.cs) | implementation classes |
| ApiGateway | `ApiGateway.Security.ProfessionalAssignments` | class | [src/ApiGateway/Security/ProfessionalAssignments.cs](../src/ApiGateway/Security/ProfessionalAssignments.cs) | implementation classes |
| ApiGateway | `ApiGateway.Security.PrototypeAccount` | class | [src/ApiGateway/Security/PrototypeAccounts.cs](../src/ApiGateway/Security/PrototypeAccounts.cs) | implementation classes |
| ApiGateway | `ApiGateway.Security.PrototypeAccounts` | class | [src/ApiGateway/Security/PrototypeAccounts.cs](../src/ApiGateway/Security/PrototypeAccounts.cs) | implementation classes |
| PatientProfileService | `PatientProfileService.Application.PatientApplicationService` | class | [src/PatientProfileService/Application/PatientApplicationService.cs](../src/PatientProfileService/Application/PatientApplicationService.cs) | implementation classes |
| PatientProfileService | `PatientProfileService.Application.PatientRepository` | interface | [src/PatientProfileService/Application/PatientRepository.cs](../src/PatientProfileService/Application/PatientRepository.cs) | implementation classes |
| PatientProfileService | `PatientProfileService.Application.ProfileAlreadyExistsException` | class | [src/PatientProfileService/Application/ProfileAlreadyExistsException.cs](../src/PatientProfileService/Application/ProfileAlreadyExistsException.cs) | implementation classes |
| PatientProfileService | `PatientProfileService.Contracts.CreatePatientRequest` | record | [src/PatientProfileService/Contracts/CreatePatientRequest.cs](../src/PatientProfileService/Contracts/CreatePatientRequest.cs) | implementation classes |
| PatientProfileService | `PatientProfileService.Contracts.PatientDto` | record | [src/PatientProfileService/Contracts/PatientDto.cs](../src/PatientProfileService/Contracts/PatientDto.cs) | implementation classes |
| PatientProfileService | `PatientProfileService.Contracts.UpdatePatientRequest` | record | [src/PatientProfileService/Contracts/UpdatePatientRequest.cs](../src/PatientProfileService/Contracts/UpdatePatientRequest.cs) | implementation classes |
| PatientProfileService | `PatientProfileService.Controllers.PatientController` | class | [src/PatientProfileService/Controllers/PatientController.cs](../src/PatientProfileService/Controllers/PatientController.cs) | implementation classes |
| PatientProfileService | `PatientProfileService.Domain.Patient` | class | [src/PatientProfileService/Domain/Patient.cs](../src/PatientProfileService/Domain/Patient.cs) | implementation classes |
| PatientProfileService | `PatientProfileService.Persistence.Migrations.AccountProfileAssociation` | class | [src/PatientProfileService/Persistence/Migrations/20261005082209_AccountProfileAssociation.Designer.cs](../src/PatientProfileService/Persistence/Migrations/20261005082209_AccountProfileAssociation.Designer.cs)<br>[src/PatientProfileService/Persistence/Migrations/20261005082209_AccountProfileAssociation.cs](../src/PatientProfileService/Persistence/Migrations/20261005082209_AccountProfileAssociation.cs) | EF migration classes |
| PatientProfileService | `PatientProfileService.Persistence.Migrations.InitialPatientSchema` | class | [src/PatientProfileService/Persistence/Migrations/20260930200031_InitialPatientSchema.Designer.cs](../src/PatientProfileService/Persistence/Migrations/20260930200031_InitialPatientSchema.Designer.cs)<br>[src/PatientProfileService/Persistence/Migrations/20260930200031_InitialPatientSchema.cs](../src/PatientProfileService/Persistence/Migrations/20260930200031_InitialPatientSchema.cs) | EF migration classes |
| PatientProfileService | `PatientProfileService.Persistence.Migrations.PatientDbContextModelSnapshot` | class | [src/PatientProfileService/Persistence/Migrations/PatientDbContextModelSnapshot.cs](../src/PatientProfileService/Persistence/Migrations/PatientDbContextModelSnapshot.cs) | EF migration classes |
| PatientProfileService | `PatientProfileService.Persistence.PatientDbContext` | class | [src/PatientProfileService/Persistence/PatientDbContext.cs](../src/PatientProfileService/Persistence/PatientDbContext.cs) | implementation classes |
| PatientProfileService | `PatientProfileService.Persistence.SqlPatientRepository` | class | [src/PatientProfileService/Persistence/SqlPatientRepository.cs](../src/PatientProfileService/Persistence/SqlPatientRepository.cs) | implementation classes |
| PatientProfileService | `PatientProfileService.Program` | class | [src/PatientProfileService/Program.cs](../src/PatientProfileService/Program.cs) | implementation classes |
| ObservationService | `ObservationService.Application.ObservationApplicationService` | class | [src/ObservationService/Application/ObservationApplicationService.cs](../src/ObservationService/Application/ObservationApplicationService.cs) | implementation classes |
| ObservationService | `ObservationService.Application.ObservationRepository` | interface | [src/ObservationService/Application/ObservationRepository.cs](../src/ObservationService/Application/ObservationRepository.cs) | implementation classes |
| ObservationService | `ObservationService.Contracts.MeasurementContextPatch` | record | [src/ObservationService/Contracts/MeasurementContextPatch.cs](../src/ObservationService/Contracts/MeasurementContextPatch.cs) | implementation classes |
| ObservationService | `ObservationService.Contracts.ObservationDto` | record | [src/ObservationService/Contracts/ObservationDto.cs](../src/ObservationService/Contracts/ObservationDto.cs) | implementation classes |
| ObservationService | `ObservationService.Contracts.PatchObservationRequest` | record | [src/ObservationService/Contracts/PatchObservationRequest.cs](../src/ObservationService/Contracts/PatchObservationRequest.cs) | implementation classes |
| ObservationService | `ObservationService.Contracts.RecordObservationRequest` | record | [src/ObservationService/Contracts/RecordObservationRequest.cs](../src/ObservationService/Contracts/RecordObservationRequest.cs) | implementation classes |
| ObservationService | `ObservationService.Contracts.UpdateObservationRequest` | record | [src/ObservationService/Contracts/UpdateObservationRequest.cs](../src/ObservationService/Contracts/UpdateObservationRequest.cs) | implementation classes |
| ObservationService | `ObservationService.Controllers.ObservationController` | class | [src/ObservationService/Controllers/ObservationController.cs](../src/ObservationService/Controllers/ObservationController.cs) | implementation classes |
| ObservationService | `ObservationService.Domain.BloodPressureObservation` | class | [src/ObservationService/Domain/BloodPressureObservation.cs](../src/ObservationService/Domain/BloodPressureObservation.cs) | implementation classes |
| ObservationService | `ObservationService.Domain.ContextSelection` | record | [src/ObservationService/Domain/ContextSelection.cs](../src/ObservationService/Domain/ContextSelection.cs) | implementation classes |
| ObservationService | `ObservationService.Domain.MeasurementContext` | record | [src/ObservationService/Domain/MeasurementContext.cs](../src/ObservationService/Domain/MeasurementContext.cs) | implementation classes |
| ObservationService | `ObservationService.Persistence.Migrations.InitialObservationSchema` | class | [src/ObservationService/Persistence/Migrations/20261001095222_InitialObservationSchema.Designer.cs](../src/ObservationService/Persistence/Migrations/20261001095222_InitialObservationSchema.Designer.cs)<br>[src/ObservationService/Persistence/Migrations/20261001095222_InitialObservationSchema.cs](../src/ObservationService/Persistence/Migrations/20261001095222_InitialObservationSchema.cs) | EF migration classes |
| ObservationService | `ObservationService.Persistence.Migrations.ObservationDbContextModelSnapshot` | class | [src/ObservationService/Persistence/Migrations/ObservationDbContextModelSnapshot.cs](../src/ObservationService/Persistence/Migrations/ObservationDbContextModelSnapshot.cs) | EF migration classes |
| ObservationService | `ObservationService.Persistence.Migrations.RecordedMeasurementContext` | class | [src/ObservationService/Persistence/Migrations/20261005094632_RecordedMeasurementContext.Designer.cs](../src/ObservationService/Persistence/Migrations/20261005094632_RecordedMeasurementContext.Designer.cs)<br>[src/ObservationService/Persistence/Migrations/20261005094632_RecordedMeasurementContext.cs](../src/ObservationService/Persistence/Migrations/20261005094632_RecordedMeasurementContext.cs) | EF migration classes |
| ObservationService | `ObservationService.Persistence.ObservationDbContext` | class | [src/ObservationService/Persistence/ObservationDbContext.cs](../src/ObservationService/Persistence/ObservationDbContext.cs) | implementation classes |
| ObservationService | `ObservationService.Persistence.SqlObservationRepository` | class | [src/ObservationService/Persistence/SqlObservationRepository.cs](../src/ObservationService/Persistence/SqlObservationRepository.cs) | implementation classes |
| ObservationService | `ObservationService.Program` | class | [src/ObservationService/Program.cs](../src/ObservationService/Program.cs) | implementation classes |
| InsightsService | `InsightsService.Application.InsightsApplicationService` | class | [src/InsightsService/Application/InsightsApplicationService.cs](../src/InsightsService/Application/InsightsApplicationService.cs) | implementation classes |
| InsightsService | `InsightsService.Clients.HttpObservationServiceClient` | class | [src/InsightsService/Clients/HttpObservationServiceClient.cs](../src/InsightsService/Clients/HttpObservationServiceClient.cs) | implementation classes |
| InsightsService | `InsightsService.Clients.ObservationServiceClient` | interface | [src/InsightsService/Clients/ObservationServiceClient.cs](../src/InsightsService/Clients/ObservationServiceClient.cs) | implementation classes |
| InsightsService | `InsightsService.Contracts.HealthInsightDto` | record | [src/InsightsService/Contracts/HealthInsightDto.cs](../src/InsightsService/Contracts/HealthInsightDto.cs) | implementation classes |
| InsightsService | `InsightsService.Contracts.MeasurementContextDto` | record | [src/InsightsService/Contracts/ObservationDto.cs](../src/InsightsService/Contracts/ObservationDto.cs) | implementation classes |
| InsightsService | `InsightsService.Contracts.ObservationDto` | record | [src/InsightsService/Contracts/ObservationDto.cs](../src/InsightsService/Contracts/ObservationDto.cs) | implementation classes |
| InsightsService | `InsightsService.Controllers.InsightsController` | class | [src/InsightsService/Controllers/InsightsController.cs](../src/InsightsService/Controllers/InsightsController.cs) | implementation classes |
| InsightsService | `InsightsService.Domain.ClinicalReference` | record | [src/InsightsService/Domain/TrendAssessment.cs](../src/InsightsService/Domain/TrendAssessment.cs) | implementation classes |
| InsightsService | `InsightsService.Domain.ComparabilityAssessment` | record | [src/InsightsService/Domain/TrendAssessment.cs](../src/InsightsService/Domain/TrendAssessment.cs) | implementation classes |
| InsightsService | `InsightsService.Domain.ContextSelection` | record | [src/InsightsService/Domain/ContextSelection.cs](../src/InsightsService/Domain/ContextSelection.cs) | implementation classes |
| InsightsService | `InsightsService.Domain.HealthInsight` | record | [src/InsightsService/Domain/HealthInsight.cs](../src/InsightsService/Domain/HealthInsight.cs) | implementation classes |
| InsightsService | `InsightsService.Domain.InsightCalculator` | class | [src/InsightsService/Domain/InsightCalculator.Trends.cs](../src/InsightsService/Domain/InsightCalculator.Trends.cs)<br>[src/InsightsService/Domain/InsightCalculator.cs](../src/InsightsService/Domain/InsightCalculator.cs) | implementation classes |
| InsightsService | `InsightsService.Domain.MeasurementAssessment` | record | [src/InsightsService/Domain/TrendAssessment.cs](../src/InsightsService/Domain/TrendAssessment.cs) | implementation classes |
| InsightsService | `InsightsService.Domain.ReferenceSource` | record | [src/InsightsService/Domain/TrendAssessment.cs](../src/InsightsService/Domain/TrendAssessment.cs) | implementation classes |
| InsightsService | `InsightsService.Domain.TrendAssessment` | record | [src/InsightsService/Domain/TrendAssessment.cs](../src/InsightsService/Domain/TrendAssessment.cs) | implementation classes |
| InsightsService | `InsightsService.Program` | class | [src/InsightsService/Program.cs](../src/InsightsService/Program.cs) | implementation classes |
| HealthOverviewService | `HealthOverviewService.Application.HealthOverviewApplicationService` | class | [src/HealthOverviewService/Application/HealthOverviewApplicationService.cs](../src/HealthOverviewService/Application/HealthOverviewApplicationService.cs) | implementation classes |
| HealthOverviewService | `HealthOverviewService.Clients.HttpInsightsServiceClient` | class | [src/HealthOverviewService/Clients/InsightsServiceClient.cs](../src/HealthOverviewService/Clients/InsightsServiceClient.cs) | implementation classes |
| HealthOverviewService | `HealthOverviewService.Clients.HttpObservationServiceClient` | class | [src/HealthOverviewService/Clients/ObservationServiceClient.cs](../src/HealthOverviewService/Clients/ObservationServiceClient.cs) | implementation classes |
| HealthOverviewService | `HealthOverviewService.Clients.HttpPatientProfileServiceClient` | class | [src/HealthOverviewService/Clients/PatientProfileServiceClient.cs](../src/HealthOverviewService/Clients/PatientProfileServiceClient.cs) | implementation classes |
| HealthOverviewService | `HealthOverviewService.Clients.InsightsServiceClient` | class | [src/HealthOverviewService/Clients/InsightsServiceClient.cs](../src/HealthOverviewService/Clients/InsightsServiceClient.cs) | implementation classes |
| HealthOverviewService | `HealthOverviewService.Clients.ObservationServiceClient` | class | [src/HealthOverviewService/Clients/ObservationServiceClient.cs](../src/HealthOverviewService/Clients/ObservationServiceClient.cs) | implementation classes |
| HealthOverviewService | `HealthOverviewService.Clients.PatientProfileServiceClient` | class | [src/HealthOverviewService/Clients/PatientProfileServiceClient.cs](../src/HealthOverviewService/Clients/PatientProfileServiceClient.cs) | implementation classes |
| HealthOverviewService | `HealthOverviewService.Contracts.ContextSelection` | record | [src/HealthOverviewService/Contracts/HealthOverviewDto.cs](../src/HealthOverviewService/Contracts/HealthOverviewDto.cs) | implementation classes |
| HealthOverviewService | `HealthOverviewService.Contracts.HealthInsightDto` | record | [src/HealthOverviewService/Contracts/HealthOverviewDto.cs](../src/HealthOverviewService/Contracts/HealthOverviewDto.cs) | implementation classes |
| HealthOverviewService | `HealthOverviewService.Contracts.HealthOverviewDto` | record | [src/HealthOverviewService/Contracts/HealthOverviewDto.cs](../src/HealthOverviewService/Contracts/HealthOverviewDto.cs) | implementation classes |
| HealthOverviewService | `HealthOverviewService.Contracts.MeasurementContextDto` | record | [src/HealthOverviewService/Contracts/HealthOverviewDto.cs](../src/HealthOverviewService/Contracts/HealthOverviewDto.cs) | implementation classes |
| HealthOverviewService | `HealthOverviewService.Contracts.ObservationDto` | record | [src/HealthOverviewService/Contracts/HealthOverviewDto.cs](../src/HealthOverviewService/Contracts/HealthOverviewDto.cs) | implementation classes |
| HealthOverviewService | `HealthOverviewService.Contracts.PatientDto` | record | [src/HealthOverviewService/Contracts/HealthOverviewDto.cs](../src/HealthOverviewService/Contracts/HealthOverviewDto.cs) | implementation classes |
| HealthOverviewService | `HealthOverviewService.Controllers.HealthOverviewController` | class | [src/HealthOverviewService/Controllers/HealthOverviewController.cs](../src/HealthOverviewService/Controllers/HealthOverviewController.cs) | implementation classes |
| HealthOverviewService | `HealthOverviewService.Program` | class | [src/HealthOverviewService/Program.cs](../src/HealthOverviewService/Program.cs) | implementation classes |
## Validation
Source declarations were enumerated independently and compared with each per-service diagram’s `sourceType` attributes. A merged partial type is expected once per service file. All source-defined types must match exactly, with no extras or omissions. The combined `04-design-classes.drawio` contains the same corrected service views plus the administrative provisioning view; the standalone files are the primary per-service navigation targets.
@@ -0,0 +1,50 @@
<?xml version='1.0' encoding='utf-8'?>
<mxfile host="app.diagrams.net" version="24.7.17" compressed="false">
<diagram id="p1" name="System context">
<mxGraphModel dx="1700" dy="1500" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1500" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="c1" value="System context" style="text;html=0;fontSize=24;fontStyle=1;align=left;verticalAlign=middle;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="15" width="1440" height="45" />
</mxCell>
<mxCell id="c2" value="Patient&#10;Pre-created account&#10;Creates own profile; records/reviews own measurements" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="130" width="300" height="170" />
</mxCell>
<mxCell id="c3" value="Healthcare professional&#10;Pre-created account&#10;Reads assigned patients; never writes" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="400" width="300" height="170" />
</mxCell>
<mxCell id="c4" value="HealthApp backend boundary&#10;Gateway + four application services&#10;REST/JSON over HTTPS&#10;Patient/Profile and Observation own persistence&#10;No product frontend in this repository" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#dae8fc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="530" y="230" width="400" height="250" />
</mxCell>
<mxCell id="c5" value="Administrator / build machine&#10;Builds portable release&#10;Selects topology and installs native services&#10;Provides host administrative access" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1100" y="150" width="330" height="190" />
</mxCell>
<mxCell id="c6" value="Clinical reference publishers&#10;Sundhed.dk&#10;Source URLs/review dates compiled into code&#10;No runtime HTTP dependency" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1100" y="430" width="330" height="180" />
</mxCell>
<mxCell id="c7" value="HTTPS login + own-data APIs" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c2" target="c4">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c8" value="HTTPS login + assigned reads" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c3" target="c4">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c9" value="Native installation / configuration" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=open;dashed=1;" edge="1" parent="1" source="c5" target="c4">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c10" value="Reference metadata only" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=open;dashed=1;" edge="1" parent="1" source="c4" target="c6">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c11" value="Optional experiment system (outside product)&#10;JMeter generator → Gateway APIs&#10;JMeter ← PerfMon ServerAgent host telemetry&#10;JMeter ← Shelly plug HTTP power&#10;Idle scenario sends zero HealthApp requests" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#fff2cc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="420" y="710" width="600" height="190" />
</mxCell>
<mxCell id="c12" value="Synthetic workload only" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c11" target="c4">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c13" value="Evidence: HealthApp.slnx; src/*/Program.cs; MeasurementGuidanceController; InsightCalculator.Trends; deploy/installer/*; tools/energy-jmeter. See software-architecture.md §§2, 6, 9, 11. Web/mobile clients are context actors, not implemented UI." style="rounded=0;whiteSpace=wrap;html=0;fillColor=#fff2cc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="960" width="1400" height="100" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
@@ -0,0 +1,65 @@
<?xml version='1.0' encoding='utf-8'?>
<mxfile host="app.diagrams.net" version="24.7.17" compressed="false">
<diagram id="p1" name="Service processes and communication">
<mxGraphModel dx="1700" dy="1500" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1750" pageHeight="1250" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="c1" value="Service processes and communication" style="text;html=0;fontSize=24;fontStyle=1;align=left;verticalAlign=middle;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="15" width="1690" height="45" />
</mxCell>
<mxCell id="c2" value="ApiGateway process&#10;Authentication + PatientAccessMiddleware&#10;Controllers → named HttpClients&#10;Login / public guidance / assignments&#10;Persistent Data Protection key files" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#dae8fc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1" link="../../src/ApiGateway/Program.cs">
<mxGeometry as="geometry" x="640" y="110" width="420" height="240" />
</mxCell>
<mxCell id="c3" value="PatientProfileService process&#10;PatientController&#10;→ PatientApplicationService&#10;→ PatientRepository / SqlPatientRepository&#10;→ PatientDbContext" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1" link="../../src/PatientProfileService/Program.cs">
<mxGeometry as="geometry" x="30" y="490" width="360" height="220" />
</mxCell>
<mxCell id="c4" value="ObservationService process&#10;ObservationController → application&#10;→ ObservationRepository / SQL / EF&#10;Patient existence client → Gateway" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1" link="../../src/ObservationService/Program.cs">
<mxGeometry as="geometry" x="470" y="490" width="360" height="220" />
</mxCell>
<mxCell id="c5" value="InsightsService process&#10;InsightsController → application&#10;→ stateless InsightCalculator&#10;Observation HTTP client → Gateway&#10;No DB" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1" link="../../src/InsightsService/Program.cs">
<mxGeometry as="geometry" x="910" y="490" width="360" height="220" />
</mxCell>
<mxCell id="c6" value="HealthOverviewService process&#10;Overview controller → application&#10;Three typed HTTP clients → Gateway&#10;Sequential profile/latest/insight reads&#10;No DB" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1" link="../../src/HealthOverviewService/Program.cs">
<mxGeometry as="geometry" x="1350" y="490" width="360" height="220" />
</mxCell>
<mxCell id="c7" value="Profile APIs&#10;HTTPS + X-Gateway-Key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c2" target="c3">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c8" value="Observation APIs&#10;HTTPS + X-Gateway-Key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c2" target="c4">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c9" value="Summary / trend APIs&#10;HTTPS + X-Gateway-Key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c2" target="c5">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c10" value="Overview API&#10;HTTPS + X-Gateway-Key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c2" target="c6">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c11" value="Patient read&#10;HTTPS + X-Service-Key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c4" target="c2">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c12" value="History read&#10;HTTPS + X-Service-Key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c5" target="c2">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c13" value="Profile / latest / summary reads&#10;HTTPS + X-Service-Key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c6" target="c2">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c14" value="Patient DB&#10;patient + migration history&#10;Only Patient/Profile accesses it" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#fff2cc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="850" width="360" height="150" />
</mxCell>
<mxCell id="c15" value="Observation DB&#10;observation + flattened context&#10;Only Observation accesses it" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#fff2cc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="470" y="850" width="360" height="150" />
</mxCell>
<mxCell id="c16" value="EF Core / PostgreSQL" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c3" target="c14">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c17" value="EF Core / PostgreSQL" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c4" target="c15">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c18" value="No direct application-service network links, shared runtime library, shared domain objects, broker or cross-service DB access. Domain/client names do not change the configured Gateway origin. Each box is a separate project/process. Source links are attached to service boxes." style="rounded=0;whiteSpace=wrap;html=0;fillColor=#fff2cc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="1090" width="1680" height="100" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
@@ -0,0 +1,205 @@
<?xml version='1.0' encoding='utf-8'?>
<mxfile host="app.diagrams.net" compressed="false" version="24.7.17">
<diagram id="Complete-application-domain:-health,-access-and-guidance" name="Complete application domain: health, access and guidance">
<mxGraphModel grid="1" gridSize="10" page="1" pageWidth="2550" pageHeight="2100">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="c1" value="Complete application domain: health, access and guidance" style="text;html=0;fontSize=26;fontStyle=1;align=left;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="20" width="2470" height="60" />
</mxCell>
<mxCell id="c2" value="Account&#10;Stable account identifier&#10;Trusted Patient / HealthcareProfessional role&#10;Pre-created credentials; no registration" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#d5e8d4;" vertex="1" parent="1">
<mxGeometry as="geometry" x="50" y="170" width="480" height="195" />
</mxCell>
<mxCell id="c3" value="Patient profile&#10;Patient identifier; name; date of birth&#10;Optional contact information&#10;Persistently associated with patient account" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#dae8fc;" vertex="1" parent="1">
<mxGeometry as="geometry" x="675" y="170" width="480" height="195" />
</mxCell>
<mxCell id="c4" value="Professional assignment&#10;Professional account ↔ patient identifier&#10;Predefined, read-only entitlement&#10;Multiple patients / multiple professionals" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#d5e8d4;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1300" y="170" width="480" height="195" />
</mxCell>
<mxCell id="c5" value="Authentication grant&#10;Account identity and trusted role&#10;Issue/expiry instants; time limited&#10;No patient health information" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#d5e8d4;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1925" y="170" width="480" height="195" />
</mxCell>
<mxCell id="c6" value="Blood-pressure observation&#10;Observation and patient identifiers&#10;Measurement instant; original recording time&#10;Systolic/diastolic pressure and pulse&#10;Optional original context text and note" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#dae8fc;" vertex="1" parent="1">
<mxGeometry as="geometry" x="50" y="510" width="480" height="195" />
</mxCell>
<mxCell id="c7" value="Measurement context&#10;Setting; activity condition&#10;Optional preparation/technique details&#10;Optional additional circumstances&#10;Unknown retained; no inferred compliance" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#fff2cc;" vertex="1" parent="1">
<mxGeometry as="geometry" x="675" y="510" width="480" height="195" />
</mxCell>
<mxCell id="c8" value="Context selection&#10;Optional setting and/or activity&#10;Both selected dimensions must match&#10;Unknown is an explicit selectable category" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#fff2cc;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1300" y="510" width="480" height="195" />
</mxCell>
<mxCell id="c9" value="Measurement period&#10;Inclusive start and end instants&#10;Equal bounds valid; reversed invalid&#10;Measurement instants interpreted as UTC" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#fff2cc;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1925" y="510" width="480" height="195" />
</mxCell>
<mxCell id="c10" value="Numerical health insight&#10;Systolic/diastolic/pulse arithmetic means&#10;Blood-pressure minima and maxima&#10;Contributing count; selected basis&#10;Context explanation; derived, not stored" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#dae8fc;" vertex="1" parent="1">
<mxGeometry as="geometry" x="50" y="850" width="480" height="195" />
</mxCell>
<mxCell id="c11" value="Trend assessment&#10;Patient, period and context selection&#10;Contributing observation count&#10;Three separate metric assessments&#10;Recorded comparability and limitations" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#dae8fc;" vertex="1" parent="1">
<mxGeometry as="geometry" x="675" y="850" width="480" height="195" />
</mxCell>
<mxCell id="c12" value="Recorded comparability&#10;Known similarities and differences&#10;Missing details and narrative conflicts&#10;Evidence/explanation; not certification" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#fff2cc;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1300" y="850" width="480" height="195" />
</mxCell>
<mxCell id="c13" value="Measurement assessment&#10;Metric and unit; mean/minimum/maximum/range&#10;Temporal and overall direction; slope&#10;Reversals/successive variation&#10;Interpretation, reference comparison and hint" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#fff2cc;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1925" y="850" width="480" height="195" />
</mxCell>
<mxCell id="c14" value="Health overview&#10;Patient profile&#10;Optional latest overall observation&#10;Optional selected-period numerical insight&#10;Explicit separate bases and absence reasons" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#dae8fc;" vertex="1" parent="1">
<mxGeometry as="geometry" x="50" y="1190" width="480" height="195" />
</mxCell>
<mxCell id="c15" value="Clinical reference&#10;Applicable scope and measurement conditions&#10;Lower/upper boundaries and operators&#10;Source provenance; applicability limits&#10;General reference ≠ individual treatment goal" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#fff2cc;" vertex="1" parent="1">
<mxGeometry as="geometry" x="675" y="1190" width="480" height="195" />
</mxCell>
<mxCell id="c16" value="Reference source&#10;Publication title and URL&#10;Publication update/review dates where supplied&#10;Provenance, not a patient record&#10;No automatic live source refresh" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#fff2cc;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1300" y="1190" width="480" height="195" />
</mxCell>
<mxCell id="c17" value="Measurement guidance&#10;Requested setting/activity&#10;Applicable home/resting basis or unavailable&#10;Ordered instructions; explanations/limits&#10;Review date and source provenance" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#dae8fc;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1925" y="1190" width="480" height="195" />
</mxCell>
<mxCell id="c18" value="Guidance instruction&#10;Sequence order; topic; instruction&#10;Preparation/equipment/position/measurement/&#10;planned monitoring/recording&#10;No stored compliance state" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#fff2cc;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1925" y="1530" width="480" height="195" />
</mxCell>
<mxCell id="c19" value="Patient account 1 ↔ profile 0..1; legacy profile account 0..1" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c2" target="c3">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c20" value="Professional account 1 ↔ assignments 0..*" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c2" target="c4">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c21" value="Assignments 0..* ↔ patient 1 (identifier may outlive data)" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c4" target="c3">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c22" value="Account 1 ↔ issued grants 0..*" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c2" target="c5">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c23" value="Patient 1 ↔ observations 0..*" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c3" target="c6">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c24" value="Observation 1 ↔ owned context 1" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;startArrow=diamond;startFill=1;endArrow=none;" edge="1" parent="1" source="c6" target="c7">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c25" value="Selects recorded setting/activity; does not change them" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="c8" target="c7">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c26" value="Selects by measurement instant" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="c9" target="c6">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c27" value="Derived from 1..* selected observations" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="c6" target="c10">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c28" value="Derived from 0..* selected observations" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="c6" target="c11">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c29" value="Applied selection 1" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c8" target="c10">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c30" value="Applied selection 1" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c8" target="c11">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c31" value="Requested period 1" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c9" target="c10">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c32" value="Requested period 1" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c9" target="c11">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c33" value="Assessment 1 ↔ recorded comparability 1" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;startArrow=diamond;startFill=1;endArrow=none;" edge="1" parent="1" source="c11" target="c12">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c34" value="Assessment 1 ↔ metric assessments 3" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;startArrow=diamond;startFill=1;endArrow=none;" edge="1" parent="1" source="c11" target="c13">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c35" value="Metric assessment 1 ↔ applicable reference 0..1" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c13" target="c15">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c36" value="Reference 1 ↔ sources 1..*" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c15" target="c16">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c37" value="Overview 1 ↔ profile 1" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c14" target="c3">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c38" value="Overview 1 ↔ latest overall 0..1" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c14" target="c6">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c39" value="Overview 1 ↔ insight 0..1" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c14" target="c10">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c40" value="Guidance 1 ↔ ordered instructions 0..*" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;startArrow=diamond;startFill=1;endArrow=none;" edge="1" parent="1" source="c17" target="c18">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c41" value="Guidance 1 ↔ cited sources 0..*" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c17" target="c16">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c42" value="Explains actual circumstances; never sets/saves context" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="c17" target="c7">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c43" value="Scope spans the responsibilities of all five application services: access/accounts/assignments, patient profiles, observation/context/history, numerical insights, metric trends/comparability/references, overview and public guidance. These are business concepts, not controllers, DTOs, repositories or framework classes. Derived views are values, not persisted entities. Professional role is an Account role; there is no separate stored professional profile. Measurement device/cuff are recorded descriptions, not independently managed device entities." style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#f5f5f5;" vertex="1" parent="1">
<mxGeometry as="geometry" x="45" y="1900" width="2460" height="145" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
<diagram id="Deployment-administration-concepts-(separate-supporting-domain)" name="Deployment administration concepts (separate supporting domain)">
<mxGraphModel grid="1" gridSize="10" page="1" pageWidth="2100" pageHeight="1450">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="c1" value="Deployment administration concepts (separate supporting domain)" style="text;html=0;fontSize=26;fontStyle=1;align=left;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="20" width="2020" height="60" />
</mxCell>
<mxCell id="c2" value="Deployment topology&#10;Selected service names&#10;Reachable host/platform/port assignments&#10;Colocated or distributed" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#d5e8d4;" vertex="1" parent="1">
<mxGeometry as="geometry" x="45" y="170" width="575" height="200" />
</mxCell>
<mxCell id="c3" value="Deployment node&#10;Host and native platform&#10;Administrative access prerequisites&#10;One or more selected service installations" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#d5e8d4;" vertex="1" parent="1">
<mxGeometry as="geometry" x="730" y="170" width="575" height="200" />
</mxCell>
<mxCell id="c4" value="Service installation&#10;Independent executable/process identity&#10;Listening endpoint; local configuration&#10;Lifecycle independent of peers" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#d5e8d4;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1415" y="170" width="575" height="200" />
</mxCell>
<mxCell id="c5" value="Deployment material&#10;Deployment identifier&#10;Compatible service settings and account secrets&#10;Protected files, scoped to selected nodes" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#d5e8d4;" vertex="1" parent="1">
<mxGeometry as="geometry" x="45" y="500" width="575" height="200" />
</mxCell>
<mxCell id="c6" value="Service configuration&#10;Listening address; dependencies/endpoints&#10;Credentials; certificate paths&#10;Own database connection where applicable" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#d5e8d4;" vertex="1" parent="1">
<mxGeometry as="geometry" x="730" y="500" width="575" height="200" />
</mxCell>
<mxCell id="c7" value="Credential&#10;Service incoming/callback keys&#10;Synthetic account password/hash&#10;Separate database owner credential&#10;Private administrative material" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#d5e8d4;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1415" y="500" width="575" height="200" />
</mxCell>
<mxCell id="c8" value="Owned database&#10;Owning persistent service&#10;Dedicated role and schema&#10;No database for derived-data services" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#d5e8d4;" vertex="1" parent="1">
<mxGeometry as="geometry" x="45" y="830" width="575" height="200" />
</mxCell>
<mxCell id="c9" value="Service certificate&#10;Endpoint DNS/IP identity&#10;Private key and protected PFX&#10;Validity interval and trust chain" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#d5e8d4;" vertex="1" parent="1">
<mxGeometry as="geometry" x="730" y="830" width="575" height="200" />
</mxCell>
<mxCell id="c10" value="Prototype certificate authority&#10;Public trust anchor&#10;Issues service certificates at preparation&#10;Generated signing key not retained" style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#d5e8d4;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1415" y="830" width="575" height="200" />
</mxCell>
<mxCell id="c11" value="Topology 1 ↔ nodes 1..*" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c2" target="c3">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c12" value="Node 1 ↔ installations 1..*" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c3" target="c4">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c13" value="Material 1 ↔ planned configurations 5" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c5" target="c6">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c14" value="Installation 1 ↔ configuration 1" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c4" target="c6">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c15" value="Configuration references appropriate credentials" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c6" target="c7">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c16" value="Persistent installation 1 ↔ owned database 1; others 0" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c4" target="c8">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c17" value="Configuration 1 ↔ service certificate 1" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c6" target="c9">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c18" value="Authority 1 ↔ issued service certificates 1..*" style="edgeStyle=orthogonalEdgeStyle;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c10" target="c9">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c19" value="Supporting deployment concepts describe existing installer data and administrator responsibilities; they do not create extra application microservices or change the health domain. Source evidence: Deployment.cs, DatabaseProvisioning.cs, ConfigurationWriter.cs and native installers. External certificates are also supported. Experiment tools and operating-system frameworks remain infrastructure, not invented clinical entities." style="rounded=0;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=14;spacing=12;strokeColor=#555555;fillColor=#f5f5f5;" vertex="1" parent="1">
<mxGeometry as="geometry" x="45" y="1260" width="2010" height="140" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
@@ -0,0 +1,374 @@
<?xml version='1.0' encoding='utf-8'?>
<mxfile host="app.diagrams.net" version="24.7.17" compressed="false">
<diagram name="ApiGateway — implementation classes" id="ApiGateway---implementation-classes">
<mxGraphModel grid="1" gridSize="10" page="1" pageWidth="2660" pageHeight="2476" pageScale="1">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="n1" value="ApiGateway — implementation classes" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fontSize=24;fontStyle=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="25" width="2580" height="45" />
</mxCell>
<mxCell id="n2" value="UML: + public, - private, # protected, ~ internal. Three compartments = classifier / attributes / operations. Hollow triangle: inheritance; dashed hollow triangle: interface realization. Solid line: attribute reference; dashed arrow: dependency; filled diamond: verified owned context. Each source type has its own classifier. Primary-constructor parameters are constructor operations, not invented fields." style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="85" width="2580" height="100" />
</mxCell>
<mxCell id="n3" value="«class»&#10;AuthenticationController&#10;ApiGateway.Controllers" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#dae8fc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ApiGateway.Controllers.AuthenticationController" sourceFiles="src/ApiGateway/Controllers/AuthenticationController.cs" link="../../src/ApiGateway/Controllers/AuthenticationController.cs">
<mxGeometry as="geometry" x="70" y="210" width="520" height="190" />
</mxCell>
<mxCell id="n4" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n3">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n5" value="+ AuthenticationController(PrototypeAccounts accounts,&#10;IOptionsMonitor&lt;BearerTokenOptions&gt; options)&#10;+ Login(LoginRequest request): IActionResult" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n3">
<mxGeometry as="geometry" x="0" y="118" width="520" height="72" />
</mxCell>
<mxCell id="n3-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n3">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n6" value="«record»&#10;LoginRequest&#10;ApiGateway.Controllers.AuthenticationController" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#dae8fc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ApiGateway.Controllers.AuthenticationController.LoginRequest" sourceFiles="src/ApiGateway/Controllers/AuthenticationController.cs" link="../../src/ApiGateway/Controllers/AuthenticationController.cs">
<mxGeometry as="geometry" x="730" y="210" width="520" height="172" />
</mxCell>
<mxCell id="n7" value="+ AccountId: string {get, init}&#10;+ Password: string {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n6">
<mxGeometry as="geometry" x="0" y="82" width="520" height="54" />
</mxCell>
<mxCell id="n8" value="+ LoginRequest(string AccountId, string Password)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n6">
<mxGeometry as="geometry" x="0" y="136" width="520" height="36" />
</mxCell>
<mxCell id="n6-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n6">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="136" />
<mxPoint as="targetPoint" x="520" y="136" />
</mxGeometry>
</mxCell>
<mxCell id="n9" value="«class»&#10;HealthOverviewController&#10;ApiGateway.Controllers" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#dae8fc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ApiGateway.Controllers.HealthOverviewController" sourceFiles="src/ApiGateway/Controllers/HealthOverviewController.cs" link="../../src/ApiGateway/Controllers/HealthOverviewController.cs">
<mxGeometry as="geometry" x="1390" y="210" width="520" height="226" />
</mxCell>
<mxCell id="n10" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n9">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n11" value="+ HealthOverviewController(IHttpClientFactory clients)&#10;+ GetOverview(Guid patientId, CancellationToken cancellationToken): Task&#10;- ForwardAsync(HttpMethod method, string path, CancellationToken&#10;cancellationToken): Task&#10;- WriteFailureAsync(int status): Task" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n9">
<mxGeometry as="geometry" x="0" y="118" width="520" height="108" />
</mxCell>
<mxCell id="n9-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n9">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n12" value="«class»&#10;InsightsController&#10;ApiGateway.Controllers" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#dae8fc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ApiGateway.Controllers.InsightsController" sourceFiles="src/ApiGateway/Controllers/InsightsController.cs" link="../../src/ApiGateway/Controllers/InsightsController.cs">
<mxGeometry as="geometry" x="2050" y="210" width="520" height="244" />
</mxCell>
<mxCell id="n13" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n12">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n14" value="+ InsightsController(IHttpClientFactory clients)&#10;+ GetSummary(Guid patientId, CancellationToken cancellationToken): Task&#10;+ GetTrend(Guid patientId, CancellationToken cancellationToken): Task&#10;- ForwardAsync(HttpMethod method, string path, CancellationToken&#10;cancellationToken): Task&#10;- WriteFailureAsync(int status): Task" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n12">
<mxGeometry as="geometry" x="0" y="118" width="520" height="126" />
</mxCell>
<mxCell id="n12-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n12">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n15" value="«class»&#10;MeasurementGuidanceController&#10;ApiGateway.Controllers" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#dae8fc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ApiGateway.Controllers.MeasurementGuidanceController" sourceFiles="src/ApiGateway/Controllers/MeasurementGuidanceController.cs" link="../../src/ApiGateway/Controllers/MeasurementGuidanceController.cs">
<mxGeometry as="geometry" x="70" y="634" width="520" height="154" />
</mxCell>
<mxCell id="n16" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n15">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n17" value="+ Get(string? setting, string? activityCondition): IActionResult" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n15">
<mxGeometry as="geometry" x="0" y="118" width="520" height="36" />
</mxCell>
<mxCell id="n15-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n15">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n18" value="«record»&#10;GuidanceSource&#10;ApiGateway.Controllers.MeasurementGuidanceController" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#dae8fc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ApiGateway.Controllers.MeasurementGuidanceController.GuidanceSource" sourceFiles="src/ApiGateway/Controllers/MeasurementGuidanceController.cs" link="../../src/ApiGateway/Controllers/MeasurementGuidanceController.cs">
<mxGeometry as="geometry" x="730" y="634" width="520" height="190" />
</mxCell>
<mxCell id="n19" value="+ Title: string {get, init}&#10;+ Url: string {get, init}&#10;+ UpdatedOn: string {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n18">
<mxGeometry as="geometry" x="0" y="82" width="520" height="72" />
</mxCell>
<mxCell id="n20" value="+ GuidanceSource(string Title, string Url, string UpdatedOn)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n18">
<mxGeometry as="geometry" x="0" y="154" width="520" height="36" />
</mxCell>
<mxCell id="n18-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n18">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="154" />
<mxPoint as="targetPoint" x="520" y="154" />
</mxGeometry>
</mxCell>
<mxCell id="n21" value="«record»&#10;GuidanceStep&#10;ApiGateway.Controllers.MeasurementGuidanceController" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#dae8fc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ApiGateway.Controllers.MeasurementGuidanceController.GuidanceStep" sourceFiles="src/ApiGateway/Controllers/MeasurementGuidanceController.cs" link="../../src/ApiGateway/Controllers/MeasurementGuidanceController.cs">
<mxGeometry as="geometry" x="1390" y="634" width="520" height="190" />
</mxCell>
<mxCell id="n22" value="+ Order: int {get, init}&#10;+ Topic: string {get, init}&#10;+ Instruction: string {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n21">
<mxGeometry as="geometry" x="0" y="82" width="520" height="72" />
</mxCell>
<mxCell id="n23" value="+ GuidanceStep(int Order, string Topic, string Instruction)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n21">
<mxGeometry as="geometry" x="0" y="154" width="520" height="36" />
</mxCell>
<mxCell id="n21-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n21">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="154" />
<mxPoint as="targetPoint" x="520" y="154" />
</mxGeometry>
</mxCell>
<mxCell id="n24" value="«class»&#10;ObservationController&#10;ApiGateway.Controllers" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#dae8fc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ApiGateway.Controllers.ObservationController" sourceFiles="src/ApiGateway/Controllers/ObservationController.cs" link="../../src/ApiGateway/Controllers/ObservationController.cs">
<mxGeometry as="geometry" x="2050" y="634" width="520" height="424" />
</mxCell>
<mxCell id="n25" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n24">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n26" value="+ ObservationController(IHttpClientFactory clients)&#10;+ RecordObservation(Guid patientId, CancellationToken cancellationToken):&#10;Task&#10;+ DeleteObservation(Guid observationId, CancellationToken&#10;cancellationToken): Task&#10;+ UpdateObservation(Guid observationId, CancellationToken&#10;cancellationToken): Task&#10;+ PatchObservation(Guid observationId, CancellationToken&#10;cancellationToken): Task&#10;+ GetObservation(Guid observationId, CancellationToken&#10;cancellationToken): Task&#10;+ GetLatest(Guid patientId, CancellationToken cancellationToken): Task&#10;+ GetByPeriod(Guid patientId, CancellationToken cancellationToken): Task&#10;- ForwardAsync(HttpMethod method, string path, CancellationToken&#10;cancellationToken): Task&#10;- WriteFailureAsync(int status): Task" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n24">
<mxGeometry as="geometry" x="0" y="118" width="520" height="306" />
</mxCell>
<mxCell id="n24-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n24">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n27" value="«class»&#10;PatientController&#10;ApiGateway.Controllers" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#dae8fc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ApiGateway.Controllers.PatientController" sourceFiles="src/ApiGateway/Controllers/PatientController.cs" link="../../src/ApiGateway/Controllers/PatientController.cs">
<mxGeometry as="geometry" x="70" y="1238" width="520" height="280" />
</mxCell>
<mxCell id="n28" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n27">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n29" value="+ PatientController(IHttpClientFactory clients)&#10;+ CreatePatient(CancellationToken cancellationToken): Task&#10;+ GetOwnPatient(CancellationToken cancellationToken): Task&#10;+ GetPatient(Guid patientId, CancellationToken cancellationToken): Task&#10;+ UpdatePatient(Guid patientId, CancellationToken cancellationToken): Task&#10;- ForwardAsync(HttpMethod method, string path, CancellationToken&#10;cancellationToken): Task&#10;- WriteFailureAsync(int status): Task" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n27">
<mxGeometry as="geometry" x="0" y="118" width="520" height="162" />
</mxCell>
<mxCell id="n27-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n27">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n30" value="«class»&#10;ProfessionalController&#10;ApiGateway.Controllers" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#dae8fc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ApiGateway.Controllers.ProfessionalController" sourceFiles="src/ApiGateway/Controllers/ProfessionalController.cs" link="../../src/ApiGateway/Controllers/ProfessionalController.cs">
<mxGeometry as="geometry" x="730" y="1238" width="520" height="172" />
</mxCell>
<mxCell id="n31" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n30">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n32" value="+ ProfessionalController(ProfessionalAssignments assignments)&#10;+ GetAssignedPatients(): IActionResult" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n30">
<mxGeometry as="geometry" x="0" y="118" width="520" height="54" />
</mxCell>
<mxCell id="n30-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n30">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n33" value="«class»&#10;InternalServiceAuthenticationHandler&#10;ApiGateway.Security" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#f8cecc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ApiGateway.Security.InternalServiceAuthenticationHandler" sourceFiles="src/ApiGateway/Security/InternalServiceAuthenticationHandler.cs" link="../../src/ApiGateway/Security/InternalServiceAuthenticationHandler.cs">
<mxGeometry as="geometry" x="1390" y="1238" width="520" height="226" />
</mxCell>
<mxCell id="n34" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n33">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n35" value="+&#10;InternalServiceAuthenticationHandler(IOptionsMonitor&lt;AuthenticationSchemeOptions&gt;&#10;options, ILoggerFactory logger, UrlEncoder encoder, IConfiguration&#10;configuration)&#10;# HandleAuthenticateAsync(): Task&lt;AuthenticateResult&gt;" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n33">
<mxGeometry as="geometry" x="0" y="118" width="520" height="108" />
</mxCell>
<mxCell id="n33-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n33">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n36" value="«class»&#10;PatientAccessMiddleware&#10;ApiGateway.Security" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#f8cecc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ApiGateway.Security.PatientAccessMiddleware" sourceFiles="src/ApiGateway/Security/PatientAccessMiddleware.cs" link="../../src/ApiGateway/Security/PatientAccessMiddleware.cs">
<mxGeometry as="geometry" x="2050" y="1238" width="520" height="208" />
</mxCell>
<mxCell id="n37" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n36">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n38" value="+ PatientAccessMiddleware(RequestDelegate next)&#10;+ InvokeAsync(HttpContext context, IHttpClientFactory clients,&#10;IAuthorizationService authorization, ProfessionalAssignments&#10;assignments): Task" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n36">
<mxGeometry as="geometry" x="0" y="118" width="520" height="90" />
</mxCell>
<mxCell id="n36-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n36">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n39" value="«class»&#10;ProfessionalAssignments&#10;ApiGateway.Security" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#f8cecc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ApiGateway.Security.ProfessionalAssignments" sourceFiles="src/ApiGateway/Security/ProfessionalAssignments.cs" link="../../src/ApiGateway/Security/ProfessionalAssignments.cs">
<mxGeometry as="geometry" x="70" y="1698" width="520" height="190" />
</mxCell>
<mxCell id="n40" value="- assignments: Dictionary&lt;string, Guid[]&gt; {readonly}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n39">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n41" value="+ ProfessionalAssignments(IConfiguration configuration)&#10;+ GetPatients(string accountId): IReadOnlyList&lt;Guid&gt;&#10;+ IsAssigned(string accountId, Guid patientId): bool" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n39">
<mxGeometry as="geometry" x="0" y="118" width="520" height="72" />
</mxCell>
<mxCell id="n39-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n39">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n42" value="«class»&#10;PrototypeAccount&#10;ApiGateway.Security" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#f8cecc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ApiGateway.Security.PrototypeAccount" sourceFiles="src/ApiGateway/Security/PrototypeAccounts.cs" link="../../src/ApiGateway/Security/PrototypeAccounts.cs">
<mxGeometry as="geometry" x="730" y="1698" width="520" height="190" />
</mxCell>
<mxCell id="n43" value="+ AccountId: string {get, set}&#10;+ Role: string {get, set}&#10;+ PasswordHash: string {get, set}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n42">
<mxGeometry as="geometry" x="0" y="82" width="520" height="72" />
</mxCell>
<mxCell id="n44" value="(no declared operations)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n42">
<mxGeometry as="geometry" x="0" y="154" width="520" height="36" />
</mxCell>
<mxCell id="n42-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n42">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="154" />
<mxPoint as="targetPoint" x="520" y="154" />
</mxGeometry>
</mxCell>
<mxCell id="n45" value="«class»&#10;PrototypeAccounts&#10;ApiGateway.Security" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#f8cecc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ApiGateway.Security.PrototypeAccounts" sourceFiles="src/ApiGateway/Security/PrototypeAccounts.cs" link="../../src/ApiGateway/Security/PrototypeAccounts.cs">
<mxGeometry as="geometry" x="1390" y="1698" width="520" height="208" />
</mxCell>
<mxCell id="n46" value="- accounts: Dictionary&lt;string, PrototypeAccount&gt; {readonly}&#10;- hasher: PasswordHasher&lt;PrototypeAccount&gt; {readonly}&#10;- dummy: PrototypeAccount {readonly}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n45">
<mxGeometry as="geometry" x="0" y="82" width="520" height="72" />
</mxCell>
<mxCell id="n47" value="+ PrototypeAccounts(IConfiguration configuration)&#10;+ Verify(string accountId, string password): PrototypeAccount?" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n45">
<mxGeometry as="geometry" x="0" y="154" width="520" height="54" />
</mxCell>
<mxCell id="n45-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n45">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="154" />
<mxPoint as="targetPoint" x="520" y="154" />
</mxGeometry>
</mxCell>
<mxCell id="n48" value="«class»&#10;Program&#10;ApiGateway" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#f5f5f5;strokeColor=#444444;" vertex="1" parent="1" sourceType="ApiGateway.Program" sourceFiles="src/ApiGateway/Program.cs" link="../../src/ApiGateway/Program.cs">
<mxGeometry as="geometry" x="2050" y="1698" width="520" height="172" />
</mxCell>
<mxCell id="n49" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n48">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n50" value="+ Main(string[] args): void {static}&#10;- GetBaseUri(IConfiguration configuration, string service): Uri {static}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n48">
<mxGeometry as="geometry" x="0" y="118" width="520" height="54" />
</mxCell>
<mxCell id="n48-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n48">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n51" value="«framework reference»&#10;ControllerBase" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="70" y="2086" width="520" height="80" />
</mxCell>
<mxCell id="n52" value="«framework reference»&#10;AuthenticationHandler&lt;AuthenticationSchemeOptions&gt;" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="730" y="2086" width="520" height="80" />
</mxCell>
<mxCell id="n53" value="«framework reference»&#10;IHttpClientFactory" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1390" y="2086" width="520" height="80" />
</mxCell>
<mxCell id="n54" value="«framework reference»&#10;IConfiguration" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="2050" y="2086" width="520" height="80" />
</mxCell>
<mxCell id="n55" value="«framework reference»&#10;ILoggerFactory" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="70" y="2196" width="520" height="80" />
</mxCell>
<mxCell id="n56" value="«framework reference»&#10;UrlEncoder" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="730" y="2196" width="520" height="80" />
</mxCell>
<mxCell id="n57" value="«framework reference»&#10;RequestDelegate" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1390" y="2196" width="520" height="80" />
</mxCell>
<mxCell id="e57-0" value="nested classifier" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n3" target="n6" relationship="nested">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-1" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n3" target="n45" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-2" value="nested classifier" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n15" target="n21" relationship="nested">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-3" value="nested classifier" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n15" target="n18" relationship="nested">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-4" value="creates / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n21" target="n18" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-5" value="creates / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n18" target="n21" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-6" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n30" target="n39" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-7" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n36" target="n39" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-8" value="accounts [0..*]; hasher [1]; dummy [1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n45" target="n42" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-9" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n48" target="n33" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-10" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n48" target="n36" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-11" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n48" target="n39" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-12" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n48" target="n45" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-13" value="constructor dependency" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n9" target="n53" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-14" value="constructor dependency" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n12" target="n53" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-15" value="constructor dependency" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n24" target="n53" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-16" value="constructor dependency" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n27" target="n53" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-17" value="constructor dependency" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n33" target="n54" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-18" value="constructor dependency" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n39" target="n54" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-19" value="constructor dependency" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n45" target="n54" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-20" value="constructor dependency" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n33" target="n55" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-21" value="constructor dependency" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n33" target="n56" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-22" value="constructor dependency" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n36" target="n57" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-23" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n3" target="n51" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-24" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n9" target="n51" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-25" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n12" target="n51" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-26" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n15" target="n51" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-27" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n24" target="n51" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-28" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n27" target="n51" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-29" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n30" target="n51" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e57-30" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n33" target="n52" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="n58" value="Source-linked classifier headers. All declared members shown; compiler-generated record members and inherited framework members are omitted. Partial declarations are merged. Framework base/reference boxes are distinguished from service-defined types. A dependency is not ownership or a cross-service in-process call. See class-diagram-coverage.md for exact file/type coverage." style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="2341" width="2580" height="110" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
@@ -0,0 +1,359 @@
<?xml version='1.0' encoding='utf-8'?>
<mxfile host="app.diagrams.net" version="24.7.17" compressed="false">
<diagram name="HealthOverviewService — implementation classes" id="HealthOverviewService---implementation-classes">
<mxGraphModel grid="1" gridSize="10" page="1" pageWidth="2660" pageHeight="2402" pageScale="1">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="n459" value="HealthOverviewService — implementation classes" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fontSize=24;fontStyle=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="25" width="2580" height="45" />
</mxCell>
<mxCell id="n460" value="UML: + public, - private, # protected, ~ internal. Three compartments = classifier / attributes / operations. Hollow triangle: inheritance; dashed hollow triangle: interface realization. Solid line: attribute reference; dashed arrow: dependency; filled diamond: verified owned context. Each source type has its own classifier. Primary-constructor parameters are constructor operations, not invented fields." style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="85" width="2580" height="100" />
</mxCell>
<mxCell id="n461" value="«class»&#10;HealthOverviewController&#10;HealthOverviewService.Controllers" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#dae8fc;strokeColor=#444444;" vertex="1" parent="1" sourceType="HealthOverviewService.Controllers.HealthOverviewController" sourceFiles="src/HealthOverviewService/Controllers/HealthOverviewController.cs" link="../../src/HealthOverviewService/Controllers/HealthOverviewController.cs">
<mxGeometry as="geometry" x="70" y="210" width="520" height="208" />
</mxCell>
<mxCell id="n462" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n461">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n463" value="+ HealthOverviewController(HealthOverviewApplicationService service)&#10;+ GetOverview(Guid patientId, DateTime from, DateTime to,&#10;ContextSelection selection, CancellationToken cancellationToken):&#10;Task&lt;ActionResult&lt;HealthOverviewDto&gt;&gt;" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n461">
<mxGeometry as="geometry" x="0" y="118" width="520" height="90" />
</mxCell>
<mxCell id="n461-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n461">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n464" value="«class»&#10;HealthOverviewApplicationService&#10;HealthOverviewService.Application" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#e1d5e7;strokeColor=#444444;" vertex="1" parent="1" sourceType="HealthOverviewService.Application.HealthOverviewApplicationService" sourceFiles="src/HealthOverviewService/Application/HealthOverviewApplicationService.cs" link="../../src/HealthOverviewService/Application/HealthOverviewApplicationService.cs">
<mxGeometry as="geometry" x="730" y="210" width="520" height="244" />
</mxCell>
<mxCell id="n465" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n464">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n466" value="+ HealthOverviewApplicationService(PatientProfileServiceClient patients,&#10;ObservationServiceClient observations, InsightsServiceClient insights)&#10;+ GetOverviewAsync(Guid patientId, DateTime from, DateTime to,&#10;ContextSelection selection, CancellationToken cancellationToken):&#10;Task&lt;HealthOverviewDto?&gt;&#10;- NormalizeTimestamp(DateTime value): DateTime {static}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n464">
<mxGeometry as="geometry" x="0" y="118" width="520" height="126" />
</mxCell>
<mxCell id="n464-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n464">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n467" value="«record»&#10;ContextSelection&#10;HealthOverviewService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="HealthOverviewService.Contracts.ContextSelection" sourceFiles="src/HealthOverviewService/Contracts/HealthOverviewDto.cs" link="../../src/HealthOverviewService/Contracts/HealthOverviewDto.cs">
<mxGeometry as="geometry" x="1390" y="210" width="520" height="172" />
</mxCell>
<mxCell id="n468" value="+ Setting: string? {get, init}&#10;+ ActivityCondition: string? {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n467">
<mxGeometry as="geometry" x="0" y="82" width="520" height="54" />
</mxCell>
<mxCell id="n469" value="(no declared operations)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n467">
<mxGeometry as="geometry" x="0" y="136" width="520" height="36" />
</mxCell>
<mxCell id="n467-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n467">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="136" />
<mxPoint as="targetPoint" x="520" y="136" />
</mxGeometry>
</mxCell>
<mxCell id="n470" value="«record»&#10;HealthInsightDto&#10;HealthOverviewService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="HealthOverviewService.Contracts.HealthInsightDto" sourceFiles="src/HealthOverviewService/Contracts/HealthOverviewDto.cs" link="../../src/HealthOverviewService/Contracts/HealthOverviewDto.cs">
<mxGeometry as="geometry" x="2050" y="210" width="520" height="442" />
</mxCell>
<mxCell id="n471" value="+ PatientId: Guid {get, init}&#10;+ PeriodStart: DateTime {get, init}&#10;+ PeriodEnd: DateTime {get, init}&#10;+ AverageSystolic: decimal {get, init}&#10;+ AverageDiastolic: decimal {get, init}&#10;+ AveragePulse: decimal {get, init}&#10;+ MinSystolic: int {get, init}&#10;+ MaxSystolic: int {get, init}&#10;+ MinDiastolic: int {get, init}&#10;+ MaxDiastolic: int {get, init}&#10;+ AppliedSelection: ContextSelection {get, init}&#10;+ ContributingCount: int {get, init}&#10;+ ContextExplanation: string {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n470">
<mxGeometry as="geometry" x="0" y="82" width="520" height="252" />
</mxCell>
<mxCell id="n472" value="+ HealthInsightDto(Guid PatientId, DateTime PeriodStart, DateTime&#10;PeriodEnd, decimal AverageSystolic, decimal AverageDiastolic, decimal&#10;AveragePulse, int MinSystolic, int MaxSystolic, int MinDiastolic, int&#10;MaxDiastolic, ContextSelection AppliedSelection, int ContributingCount,&#10;string ContextExplanation)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n470">
<mxGeometry as="geometry" x="0" y="334" width="520" height="108" />
</mxCell>
<mxCell id="n470-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n470">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="334" />
<mxPoint as="targetPoint" x="520" y="334" />
</mxGeometry>
</mxCell>
<mxCell id="n473" value="«record»&#10;HealthOverviewDto&#10;HealthOverviewService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="HealthOverviewService.Contracts.HealthOverviewDto" sourceFiles="src/HealthOverviewService/Contracts/HealthOverviewDto.cs" link="../../src/HealthOverviewService/Contracts/HealthOverviewDto.cs">
<mxGeometry as="geometry" x="70" y="832" width="520" height="370" />
</mxCell>
<mxCell id="n474" value="+ Patient: PatientDto {get, init}&#10;+ LatestObservation: ObservationDto? {get, init}&#10;+ Insight: HealthInsightDto? {get, init}&#10;+ PeriodStart: DateTime {get, init}&#10;+ PeriodEnd: DateTime {get, init}&#10;+ InsightSelection: ContextSelection {get, init}&#10;+ InsightContributingCount: int {get, init}&#10;+ LatestObservationBasis: string {get, init}&#10;+ InsightExplanation: string {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n473">
<mxGeometry as="geometry" x="0" y="82" width="520" height="180" />
</mxCell>
<mxCell id="n475" value="+ HealthOverviewDto(PatientDto Patient, ObservationDto?&#10;LatestObservation, HealthInsightDto? Insight, DateTime PeriodStart,&#10;DateTime PeriodEnd, ContextSelection InsightSelection, int&#10;InsightContributingCount, string LatestObservationBasis, string&#10;InsightExplanation)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n473">
<mxGeometry as="geometry" x="0" y="262" width="520" height="108" />
</mxCell>
<mxCell id="n473-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n473">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="262" />
<mxPoint as="targetPoint" x="520" y="262" />
</mxGeometry>
</mxCell>
<mxCell id="n476" value="«record»&#10;MeasurementContextDto&#10;HealthOverviewService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="HealthOverviewService.Contracts.MeasurementContextDto" sourceFiles="src/HealthOverviewService/Contracts/HealthOverviewDto.cs" link="../../src/HealthOverviewService/Contracts/HealthOverviewDto.cs">
<mxGeometry as="geometry" x="730" y="832" width="520" height="316" />
</mxCell>
<mxCell id="n477" value="+ Setting: string {get, init}&#10;+ ActivityCondition: string {get, init}&#10;+ RestDurationMinutes: decimal? {get, init}&#10;+ BodyPosition: string? {get, init}&#10;+ MeasuredArm: string? {get, init}&#10;+ DeviceDetails: string? {get, init}&#10;+ CuffDetails: string? {get, init}&#10;+ AdditionalCircumstances: string? {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n476">
<mxGeometry as="geometry" x="0" y="82" width="520" height="162" />
</mxCell>
<mxCell id="n478" value="+ MeasurementContextDto(string Setting, string ActivityCondition,&#10;decimal? RestDurationMinutes, string? BodyPosition, string? MeasuredArm,&#10;string? DeviceDetails, string? CuffDetails, string? AdditionalCircumstances)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n476">
<mxGeometry as="geometry" x="0" y="244" width="520" height="72" />
</mxCell>
<mxCell id="n476-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n476">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="244" />
<mxPoint as="targetPoint" x="520" y="244" />
</mxGeometry>
</mxCell>
<mxCell id="n479" value="«record»&#10;ObservationDto&#10;HealthOverviewService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="HealthOverviewService.Contracts.ObservationDto" sourceFiles="src/HealthOverviewService/Contracts/HealthOverviewDto.cs" link="../../src/HealthOverviewService/Contracts/HealthOverviewDto.cs">
<mxGeometry as="geometry" x="1390" y="832" width="520" height="334" />
</mxCell>
<mxCell id="n480" value="+ ObservationId: Guid {get, init}&#10;+ PatientId: Guid {get, init}&#10;+ MeasuredAt: DateTime {get, init}&#10;+ Systolic: int {get, init}&#10;+ Diastolic: int {get, init}&#10;+ Pulse: int {get, init}&#10;+ Context: string? {get, init}&#10;+ Note: string? {get, init}&#10;+ MeasurementContext: MeasurementContextDto {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n479">
<mxGeometry as="geometry" x="0" y="82" width="520" height="180" />
</mxCell>
<mxCell id="n481" value="+ ObservationDto(Guid ObservationId, Guid PatientId, DateTime&#10;MeasuredAt, int Systolic, int Diastolic, int Pulse, string? Context, string?&#10;Note, MeasurementContextDto MeasurementContext)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n479">
<mxGeometry as="geometry" x="0" y="262" width="520" height="72" />
</mxCell>
<mxCell id="n479-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n479">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="262" />
<mxPoint as="targetPoint" x="520" y="262" />
</mxGeometry>
</mxCell>
<mxCell id="n482" value="«record»&#10;PatientDto&#10;HealthOverviewService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="HealthOverviewService.Contracts.PatientDto" sourceFiles="src/HealthOverviewService/Contracts/HealthOverviewDto.cs" link="../../src/HealthOverviewService/Contracts/HealthOverviewDto.cs">
<mxGeometry as="geometry" x="2050" y="832" width="520" height="226" />
</mxCell>
<mxCell id="n483" value="+ PatientId: Guid {get, init}&#10;+ Name: string {get, init}&#10;+ DateOfBirth: DateOnly {get, init}&#10;+ ContactInfo: string? {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n482">
<mxGeometry as="geometry" x="0" y="82" width="520" height="90" />
</mxCell>
<mxCell id="n484" value="+ PatientDto(Guid PatientId, string Name, DateOnly DateOfBirth, string?&#10;ContactInfo)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n482">
<mxGeometry as="geometry" x="0" y="172" width="520" height="54" />
</mxCell>
<mxCell id="n482-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n482">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="172" />
<mxPoint as="targetPoint" x="520" y="172" />
</mxGeometry>
</mxCell>
<mxCell id="n485" value="«class»&#10;HttpInsightsServiceClient&#10;HealthOverviewService.Clients" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="HealthOverviewService.Clients.HttpInsightsServiceClient" sourceFiles="src/HealthOverviewService/Clients/InsightsServiceClient.cs" link="../../src/HealthOverviewService/Clients/InsightsServiceClient.cs">
<mxGeometry as="geometry" x="70" y="1382" width="520" height="208" />
</mxCell>
<mxCell id="n486" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n485">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n487" value="+ HttpInsightsServiceClient(HttpClient client)&#10;+ GetSummaryAsync(Guid patientId, DateTime from, DateTime to,&#10;ContextSelection selection, CancellationToken cancellationToken):&#10;Task&lt;HealthInsightDto?&gt;" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n485">
<mxGeometry as="geometry" x="0" y="118" width="520" height="90" />
</mxCell>
<mxCell id="n485-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n485">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n488" value="«class»&#10;HttpObservationServiceClient&#10;HealthOverviewService.Clients" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="HealthOverviewService.Clients.HttpObservationServiceClient" sourceFiles="src/HealthOverviewService/Clients/ObservationServiceClient.cs" link="../../src/HealthOverviewService/Clients/ObservationServiceClient.cs">
<mxGeometry as="geometry" x="730" y="1382" width="520" height="190" />
</mxCell>
<mxCell id="n489" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n488">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n490" value="+ HttpObservationServiceClient(HttpClient client)&#10;+ GetLatestAsync(Guid patientId, CancellationToken cancellationToken):&#10;Task&lt;ObservationDto?&gt;" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n488">
<mxGeometry as="geometry" x="0" y="118" width="520" height="72" />
</mxCell>
<mxCell id="n488-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n488">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n491" value="«class»&#10;HttpPatientProfileServiceClient&#10;HealthOverviewService.Clients" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="HealthOverviewService.Clients.HttpPatientProfileServiceClient" sourceFiles="src/HealthOverviewService/Clients/PatientProfileServiceClient.cs" link="../../src/HealthOverviewService/Clients/PatientProfileServiceClient.cs">
<mxGeometry as="geometry" x="1390" y="1382" width="520" height="190" />
</mxCell>
<mxCell id="n492" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n491">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n493" value="+ HttpPatientProfileServiceClient(HttpClient client)&#10;+ GetPatientAsync(Guid patientId, CancellationToken cancellationToken):&#10;Task&lt;PatientDto?&gt;" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n491">
<mxGeometry as="geometry" x="0" y="118" width="520" height="72" />
</mxCell>
<mxCell id="n491-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n491">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n494" value="«abstract class»&#10;InsightsServiceClient&#10;HealthOverviewService.Clients" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="HealthOverviewService.Clients.InsightsServiceClient" sourceFiles="src/HealthOverviewService/Clients/InsightsServiceClient.cs" link="../../src/HealthOverviewService/Clients/InsightsServiceClient.cs">
<mxGeometry as="geometry" x="2050" y="1382" width="520" height="190" />
</mxCell>
<mxCell id="n495" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n494">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n496" value="+ GetSummaryAsync(Guid patientId, DateTime from, DateTime to,&#10;ContextSelection selection, CancellationToken cancellationToken):&#10;Task&lt;HealthInsightDto?&gt; {abstract}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n494">
<mxGeometry as="geometry" x="0" y="118" width="520" height="72" />
</mxCell>
<mxCell id="n494-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n494">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n497" value="«abstract class»&#10;ObservationServiceClient&#10;HealthOverviewService.Clients" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="HealthOverviewService.Clients.ObservationServiceClient" sourceFiles="src/HealthOverviewService/Clients/ObservationServiceClient.cs" link="../../src/HealthOverviewService/Clients/ObservationServiceClient.cs">
<mxGeometry as="geometry" x="70" y="1770" width="520" height="172" />
</mxCell>
<mxCell id="n498" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n497">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n499" value="+ GetLatestAsync(Guid patientId, CancellationToken cancellationToken):&#10;Task&lt;ObservationDto?&gt; {abstract}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n497">
<mxGeometry as="geometry" x="0" y="118" width="520" height="54" />
</mxCell>
<mxCell id="n497-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n497">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n500" value="«abstract class»&#10;PatientProfileServiceClient&#10;HealthOverviewService.Clients" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="HealthOverviewService.Clients.PatientProfileServiceClient" sourceFiles="src/HealthOverviewService/Clients/PatientProfileServiceClient.cs" link="../../src/HealthOverviewService/Clients/PatientProfileServiceClient.cs">
<mxGeometry as="geometry" x="730" y="1770" width="520" height="172" />
</mxCell>
<mxCell id="n501" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n500">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n502" value="+ GetPatientAsync(Guid patientId, CancellationToken cancellationToken):&#10;Task&lt;PatientDto?&gt; {abstract}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n500">
<mxGeometry as="geometry" x="0" y="118" width="520" height="54" />
</mxCell>
<mxCell id="n500-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n500">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n503" value="«class»&#10;Program&#10;HealthOverviewService" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#f5f5f5;strokeColor=#444444;" vertex="1" parent="1" sourceType="HealthOverviewService.Program" sourceFiles="src/HealthOverviewService/Program.cs" link="../../src/HealthOverviewService/Program.cs">
<mxGeometry as="geometry" x="1390" y="1770" width="520" height="172" />
</mxCell>
<mxCell id="n504" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n503">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n505" value="+ Main(string[] args): void {static}&#10;- GetGatewayUri(IConfiguration configuration): Uri {static}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n503">
<mxGeometry as="geometry" x="0" y="118" width="520" height="54" />
</mxCell>
<mxCell id="n503-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n503">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n506" value="«framework reference»&#10;ControllerBase" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="70" y="2122" width="520" height="80" />
</mxCell>
<mxCell id="n507" value="«framework reference»&#10;HttpClient" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="730" y="2122" width="520" height="80" />
</mxCell>
<mxCell id="e507-0" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n464" target="n494" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-1" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n464" target="n497" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-2" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n464" target="n500" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-3" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n464" target="n467" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-4" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n464" target="n473" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-5" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n494" target="n467" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-6" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n494" target="n470" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-7" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n485" target="n494" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-8" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n485" target="n467" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-9" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n485" target="n470" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-10" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n497" target="n479" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-11" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n488" target="n497" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-12" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n488" target="n479" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-13" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n500" target="n482" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-14" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n491" target="n500" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-15" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n491" target="n482" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-16" value="MeasurementContext [1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n479" target="n476" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-17" value="AppliedSelection [1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n470" target="n467" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-18" value="InsightSelection [1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n473" target="n467" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-19" value="Patient [1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n473" target="n482" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-20" value="LatestObservation [0..1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n473" target="n479" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-21" value="Insight [0..1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n473" target="n470" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-22" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n461" target="n464" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-23" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n461" target="n467" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-24" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n461" target="n473" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-25" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n503" target="n464" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-26" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n503" target="n494" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-27" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n503" target="n485" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-28" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n503" target="n497" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-29" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n503" target="n488" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-30" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n503" target="n500" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-31" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n503" target="n491" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-32" value="constructor dependency" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n485" target="n507" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-33" value="constructor dependency" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n488" target="n507" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-34" value="constructor dependency" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n491" target="n507" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e507-35" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n461" target="n506" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="n508" value="Source-linked classifier headers. All declared members shown; compiler-generated record members and inherited framework members are omitted. Partial declarations are merged. Framework base/reference boxes are distinguished from service-defined types. A dependency is not ownership or a cross-service in-process call. See class-diagram-coverage.md for exact file/type coverage." style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="2267" width="2580" height="110" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
@@ -0,0 +1,368 @@
<?xml version='1.0' encoding='utf-8'?>
<mxfile host="app.diagrams.net" version="24.7.17" compressed="false">
<diagram name="InsightsService — implementation classes" id="InsightsService---implementation-classes">
<mxGraphModel grid="1" gridSize="10" page="1" pageWidth="2660" pageHeight="2816" pageScale="1">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="n353" value="InsightsService — implementation classes" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fontSize=24;fontStyle=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="25" width="2580" height="45" />
</mxCell>
<mxCell id="n354" value="UML: + public, - private, # protected, ~ internal. Three compartments = classifier / attributes / operations. Hollow triangle: inheritance; dashed hollow triangle: interface realization. Solid line: attribute reference; dashed arrow: dependency; filled diamond: verified owned context. Each source type has its own classifier. Primary-constructor parameters are constructor operations, not invented fields." style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="85" width="2580" height="100" />
</mxCell>
<mxCell id="n355" value="«class»&#10;InsightsController&#10;InsightsService.Controllers" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#dae8fc;strokeColor=#444444;" vertex="1" parent="1" sourceType="InsightsService.Controllers.InsightsController" sourceFiles="src/InsightsService/Controllers/InsightsController.cs" link="../../src/InsightsService/Controllers/InsightsController.cs">
<mxGeometry as="geometry" x="70" y="210" width="520" height="262" />
</mxCell>
<mxCell id="n356" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n355">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n357" value="+ InsightsController(InsightsApplicationService service)&#10;+ GetSummary(Guid patientId, DateTime from, DateTime to,&#10;ContextSelection selection, CancellationToken cancellationToken):&#10;Task&lt;ActionResult&lt;HealthInsightDto&gt;&gt;&#10;+ GetTrend(Guid patientId, DateTime from, DateTime to, ContextSelection&#10;selection, CancellationToken cancellationToken):&#10;Task&lt;ActionResult&lt;TrendAssessment&gt;&gt;" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n355">
<mxGeometry as="geometry" x="0" y="118" width="520" height="144" />
</mxCell>
<mxCell id="n355-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n355">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n358" value="«class»&#10;InsightsApplicationService&#10;InsightsService.Application" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#e1d5e7;strokeColor=#444444;" vertex="1" parent="1" sourceType="InsightsService.Application.InsightsApplicationService" sourceFiles="src/InsightsService/Application/InsightsApplicationService.cs" link="../../src/InsightsService/Application/InsightsApplicationService.cs">
<mxGeometry as="geometry" x="730" y="210" width="520" height="298" />
</mxCell>
<mxCell id="n359" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n358">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n360" value="+ InsightsApplicationService(ObservationServiceClient observations,&#10;InsightCalculator calculator)&#10;+ GetSummaryAsync(Guid patientId, DateTime from, DateTime to,&#10;ContextSelection selection, CancellationToken cancellationToken):&#10;Task&lt;HealthInsight?&gt;&#10;+ GetTrendAsync(Guid patientId, DateTime from, DateTime to,&#10;ContextSelection selection, CancellationToken cancellationToken):&#10;Task&lt;TrendAssessment&gt;&#10;- NormalizeTimestamp(DateTime value): DateTime {static}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n358">
<mxGeometry as="geometry" x="0" y="118" width="520" height="180" />
</mxCell>
<mxCell id="n358-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n358">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n361" value="«record»&#10;ClinicalReference&#10;InsightsService.Domain" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#fff2cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="InsightsService.Domain.ClinicalReference" sourceFiles="src/InsightsService/Domain/TrendAssessment.cs" link="../../src/InsightsService/Domain/TrendAssessment.cs">
<mxGeometry as="geometry" x="1390" y="210" width="520" height="298" />
</mxCell>
<mxCell id="n362" value="+ Scope: string {get, init}&#10;+ LowerBoundary: decimal? {get, init}&#10;+ LowerComparison: string? {get, init}&#10;+ UpperBoundary: decimal {get, init}&#10;+ UpperComparison: string {get, init}&#10;+ Sources: IReadOnlyList&lt;ReferenceSource&gt; {get, init}&#10;+ Limitation: string {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n361">
<mxGeometry as="geometry" x="0" y="82" width="520" height="144" />
</mxCell>
<mxCell id="n363" value="+ ClinicalReference(string Scope, decimal? LowerBoundary, string?&#10;LowerComparison, decimal UpperBoundary, string UpperComparison,&#10;IReadOnlyList&lt;ReferenceSource&gt; Sources, string Limitation)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n361">
<mxGeometry as="geometry" x="0" y="226" width="520" height="72" />
</mxCell>
<mxCell id="n361-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n361">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="226" />
<mxPoint as="targetPoint" x="520" y="226" />
</mxGeometry>
</mxCell>
<mxCell id="n364" value="«record»&#10;ComparabilityAssessment&#10;InsightsService.Domain" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#fff2cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="InsightsService.Domain.ComparabilityAssessment" sourceFiles="src/InsightsService/Domain/TrendAssessment.cs" link="../../src/InsightsService/Domain/TrendAssessment.cs">
<mxGeometry as="geometry" x="2050" y="210" width="520" height="298" />
</mxCell>
<mxCell id="n365" value="+ Status: string {get, init}&#10;+ KnownSimilarities: IReadOnlyList&lt;string&gt; {get, init}&#10;+ KnownDifferences: IReadOnlyList&lt;string&gt; {get, init}&#10;+ MissingDetails: IReadOnlyList&lt;string&gt; {get, init}&#10;+ Conflicts: IReadOnlyList&lt;string&gt; {get, init}&#10;+ Explanation: string {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n364">
<mxGeometry as="geometry" x="0" y="82" width="520" height="126" />
</mxCell>
<mxCell id="n366" value="+ ComparabilityAssessment(string Status, IReadOnlyList&lt;string&gt;&#10;KnownSimilarities, IReadOnlyList&lt;string&gt; KnownDifferences,&#10;IReadOnlyList&lt;string&gt; MissingDetails, IReadOnlyList&lt;string&gt; Conflicts,&#10;string Explanation)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n364">
<mxGeometry as="geometry" x="0" y="208" width="520" height="90" />
</mxCell>
<mxCell id="n364-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n364">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="208" />
<mxPoint as="targetPoint" x="520" y="208" />
</mxGeometry>
</mxCell>
<mxCell id="n367" value="«record»&#10;ContextSelection&#10;InsightsService.Domain" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#fff2cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="InsightsService.Domain.ContextSelection" sourceFiles="src/InsightsService/Domain/ContextSelection.cs" link="../../src/InsightsService/Domain/ContextSelection.cs">
<mxGeometry as="geometry" x="70" y="688" width="520" height="172" />
</mxCell>
<mxCell id="n368" value="+ Setting: string? {get, init}&#10;+ ActivityCondition: string? {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n367">
<mxGeometry as="geometry" x="0" y="82" width="520" height="54" />
</mxCell>
<mxCell id="n369" value="(no declared operations)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n367">
<mxGeometry as="geometry" x="0" y="136" width="520" height="36" />
</mxCell>
<mxCell id="n367-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n367">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="136" />
<mxPoint as="targetPoint" x="520" y="136" />
</mxGeometry>
</mxCell>
<mxCell id="n370" value="«record»&#10;HealthInsight&#10;InsightsService.Domain" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#fff2cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="InsightsService.Domain.HealthInsight" sourceFiles="src/InsightsService/Domain/HealthInsight.cs" link="../../src/InsightsService/Domain/HealthInsight.cs">
<mxGeometry as="geometry" x="730" y="688" width="520" height="442" />
</mxCell>
<mxCell id="n371" value="+ PatientId: Guid {get, init}&#10;+ PeriodStart: DateTime {get, init}&#10;+ PeriodEnd: DateTime {get, init}&#10;+ AverageSystolic: decimal {get, init}&#10;+ AverageDiastolic: decimal {get, init}&#10;+ AveragePulse: decimal {get, init}&#10;+ MinSystolic: int {get, init}&#10;+ MaxSystolic: int {get, init}&#10;+ MinDiastolic: int {get, init}&#10;+ MaxDiastolic: int {get, init}&#10;+ AppliedSelection: ContextSelection {get, init}&#10;+ ContributingCount: int {get, init}&#10;+ ContextExplanation: string {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n370">
<mxGeometry as="geometry" x="0" y="82" width="520" height="252" />
</mxCell>
<mxCell id="n372" value="+ HealthInsight(Guid PatientId, DateTime PeriodStart, DateTime PeriodEnd,&#10;decimal AverageSystolic, decimal AverageDiastolic, decimal AveragePulse,&#10;int MinSystolic, int MaxSystolic, int MinDiastolic, int MaxDiastolic,&#10;ContextSelection AppliedSelection, int ContributingCount, string&#10;ContextExplanation)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n370">
<mxGeometry as="geometry" x="0" y="334" width="520" height="108" />
</mxCell>
<mxCell id="n370-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n370">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="334" />
<mxPoint as="targetPoint" x="520" y="334" />
</mxGeometry>
</mxCell>
<mxCell id="n373" value="«class»&#10;InsightCalculator&#10;InsightsService.Domain" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#fff2cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="InsightsService.Domain.InsightCalculator" sourceFiles="src/InsightsService/Domain/InsightCalculator.Trends.cs|src/InsightsService/Domain/InsightCalculator.cs" link="../../src/InsightsService/Domain/InsightCalculator.Trends.cs">
<mxGeometry as="geometry" x="1390" y="688" width="520" height="532" />
</mxCell>
<mxCell id="n374" value="- GeneralLimits: string {static}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n373">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n375" value="+ CalculateTrend(Guid patientId, DateTime from, DateTime to,&#10;IReadOnlyList&lt;ObservationDto&gt; observations, ContextSelection selection):&#10;TrendAssessment&#10;- AssessMeasurement(string metric, string unit,&#10;IReadOnlyList&lt;ObservationDto&gt; observations, Func&lt;ObservationDto, int&gt;&#10;value, ComparabilityAssessment comparability): MeasurementAssessment&#10;{static}&#10;- SelectReference(string metric, IReadOnlyList&lt;ObservationDto&gt;&#10;observations, ComparabilityAssessment comparability): ClinicalReference?&#10;{static}&#10;- IsHigh(decimal value, ClinicalReference reference): bool {static}&#10;- IsLow(decimal value, ClinicalReference reference): bool {static}&#10;- Round(decimal value): decimal {static}&#10;- Format(decimal value): string {static}&#10;- AssessComparability(IReadOnlyList&lt;ObservationDto&gt; observations):&#10;ComparabilityAssessment {static}&#10;+ CalculateSummary(Guid patientId, DateTime from, DateTime to,&#10;IReadOnlyList&lt;ObservationDto&gt; observations, ContextSelection selection):&#10;HealthInsight?&#10;- DescribeContext(IReadOnlyList&lt;ObservationDto&gt; observations): string&#10;{static}&#10;- Counts(IEnumerable&lt;string&gt; values): string {static}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n373">
<mxGeometry as="geometry" x="0" y="118" width="520" height="414" />
</mxCell>
<mxCell id="n373-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n373">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n376" value="«record»&#10;MeasurementAssessment&#10;InsightsService.Domain" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#fff2cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="InsightsService.Domain.MeasurementAssessment" sourceFiles="src/InsightsService/Domain/TrendAssessment.cs" link="../../src/InsightsService/Domain/TrendAssessment.cs">
<mxGeometry as="geometry" x="2050" y="688" width="520" height="532" />
</mxCell>
<mxCell id="n377" value="+ Metric: string {get, init}&#10;+ Unit: string {get, init}&#10;+ Mean: decimal? {get, init}&#10;+ Minimum: int? {get, init}&#10;+ Maximum: int? {get, init}&#10;+ Range: int? {get, init}&#10;+ DistinctTimestampCount: int {get, init}&#10;+ Direction: string {get, init}&#10;+ OverallDirection: string {get, init}&#10;+ SlopePerDay: decimal? {get, init}&#10;+ ReversalCount: int {get, init}&#10;+ TotalSuccessiveChange: decimal? {get, init}&#10;+ NumericalExplanation: string {get, init}&#10;+ Reference: ClinicalReference? {get, init}&#10;+ ReferenceComparison: string {get, init}&#10;+ Interpretation: string {get, init}&#10;+ Hint: string {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n376">
<mxGeometry as="geometry" x="0" y="82" width="520" height="324" />
</mxCell>
<mxCell id="n378" value="+ MeasurementAssessment(string Metric, string Unit, decimal? Mean, int?&#10;Minimum, int? Maximum, int? Range, int DistinctTimestampCount, string&#10;Direction, string OverallDirection, decimal? SlopePerDay, int&#10;ReversalCount, decimal? TotalSuccessiveChange, string&#10;NumericalExplanation, ClinicalReference? Reference, string&#10;ReferenceComparison, string Interpretation, string Hint)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n376">
<mxGeometry as="geometry" x="0" y="406" width="520" height="126" />
</mxCell>
<mxCell id="n376-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n376">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="406" />
<mxPoint as="targetPoint" x="520" y="406" />
</mxGeometry>
</mxCell>
<mxCell id="n379" value="«record»&#10;ReferenceSource&#10;InsightsService.Domain" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#fff2cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="InsightsService.Domain.ReferenceSource" sourceFiles="src/InsightsService/Domain/TrendAssessment.cs" link="../../src/InsightsService/Domain/TrendAssessment.cs">
<mxGeometry as="geometry" x="70" y="1400" width="520" height="208" />
</mxCell>
<mxCell id="n380" value="+ Title: string {get, init}&#10;+ Url: string {get, init}&#10;+ Updated: string {get, init}&#10;+ Reviewed: string {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n379">
<mxGeometry as="geometry" x="0" y="82" width="520" height="90" />
</mxCell>
<mxCell id="n381" value="+ ReferenceSource(string Title, string Url, string Updated, string Reviewed)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n379">
<mxGeometry as="geometry" x="0" y="172" width="520" height="36" />
</mxCell>
<mxCell id="n379-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n379">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="172" />
<mxPoint as="targetPoint" x="520" y="172" />
</mxGeometry>
</mxCell>
<mxCell id="n382" value="«record»&#10;TrendAssessment&#10;InsightsService.Domain" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#fff2cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="InsightsService.Domain.TrendAssessment" sourceFiles="src/InsightsService/Domain/TrendAssessment.cs" link="../../src/InsightsService/Domain/TrendAssessment.cs">
<mxGeometry as="geometry" x="730" y="1400" width="520" height="370" />
</mxCell>
<mxCell id="n383" value="+ PatientId: Guid {get, init}&#10;+ PeriodStart: DateTime {get, init}&#10;+ PeriodEnd: DateTime {get, init}&#10;+ AppliedSelection: ContextSelection {get, init}&#10;+ ContributingCount: int {get, init}&#10;+ Comparability: ComparabilityAssessment {get, init}&#10;+ Systolic: MeasurementAssessment {get, init}&#10;+ Diastolic: MeasurementAssessment {get, init}&#10;+ Pulse: MeasurementAssessment {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n382">
<mxGeometry as="geometry" x="0" y="82" width="520" height="180" />
</mxCell>
<mxCell id="n384" value="+ TrendAssessment(Guid PatientId, DateTime PeriodStart, DateTime&#10;PeriodEnd, ContextSelection AppliedSelection, int ContributingCount,&#10;ComparabilityAssessment Comparability, MeasurementAssessment&#10;Systolic, MeasurementAssessment Diastolic, MeasurementAssessment&#10;Pulse)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n382">
<mxGeometry as="geometry" x="0" y="262" width="520" height="108" />
</mxCell>
<mxCell id="n382-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n382">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="262" />
<mxPoint as="targetPoint" x="520" y="262" />
</mxGeometry>
</mxCell>
<mxCell id="n385" value="«record»&#10;HealthInsightDto&#10;InsightsService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="InsightsService.Contracts.HealthInsightDto" sourceFiles="src/InsightsService/Contracts/HealthInsightDto.cs" link="../../src/InsightsService/Contracts/HealthInsightDto.cs">
<mxGeometry as="geometry" x="1390" y="1400" width="520" height="442" />
</mxCell>
<mxCell id="n386" value="+ PatientId: Guid {get, init}&#10;+ PeriodStart: DateTime {get, init}&#10;+ PeriodEnd: DateTime {get, init}&#10;+ AverageSystolic: decimal {get, init}&#10;+ AverageDiastolic: decimal {get, init}&#10;+ AveragePulse: decimal {get, init}&#10;+ MinSystolic: int {get, init}&#10;+ MaxSystolic: int {get, init}&#10;+ MinDiastolic: int {get, init}&#10;+ MaxDiastolic: int {get, init}&#10;+ AppliedSelection: ContextSelection {get, init}&#10;+ ContributingCount: int {get, init}&#10;+ ContextExplanation: string {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n385">
<mxGeometry as="geometry" x="0" y="82" width="520" height="252" />
</mxCell>
<mxCell id="n387" value="+ HealthInsightDto(Guid PatientId, DateTime PeriodStart, DateTime&#10;PeriodEnd, decimal AverageSystolic, decimal AverageDiastolic, decimal&#10;AveragePulse, int MinSystolic, int MaxSystolic, int MinDiastolic, int&#10;MaxDiastolic, ContextSelection AppliedSelection, int ContributingCount,&#10;string ContextExplanation)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n385">
<mxGeometry as="geometry" x="0" y="334" width="520" height="108" />
</mxCell>
<mxCell id="n385-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n385">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="334" />
<mxPoint as="targetPoint" x="520" y="334" />
</mxGeometry>
</mxCell>
<mxCell id="n388" value="«record»&#10;MeasurementContextDto&#10;InsightsService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="InsightsService.Contracts.MeasurementContextDto" sourceFiles="src/InsightsService/Contracts/ObservationDto.cs" link="../../src/InsightsService/Contracts/ObservationDto.cs">
<mxGeometry as="geometry" x="2050" y="1400" width="520" height="316" />
</mxCell>
<mxCell id="n389" value="+ Setting: string? {get, init}&#10;+ ActivityCondition: string? {get, init}&#10;+ RestDurationMinutes: decimal? {get, init}&#10;+ BodyPosition: string? {get, init}&#10;+ MeasuredArm: string? {get, init}&#10;+ DeviceDetails: string? {get, init}&#10;+ CuffDetails: string? {get, init}&#10;+ AdditionalCircumstances: string? {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n388">
<mxGeometry as="geometry" x="0" y="82" width="520" height="162" />
</mxCell>
<mxCell id="n390" value="+ MeasurementContextDto(string? Setting, string? ActivityCondition,&#10;decimal? RestDurationMinutes, string? BodyPosition, string? MeasuredArm,&#10;string? DeviceDetails, string? CuffDetails, string? AdditionalCircumstances)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n388">
<mxGeometry as="geometry" x="0" y="244" width="520" height="72" />
</mxCell>
<mxCell id="n388-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n388">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="244" />
<mxPoint as="targetPoint" x="520" y="244" />
</mxGeometry>
</mxCell>
<mxCell id="n391" value="«record»&#10;ObservationDto&#10;InsightsService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="InsightsService.Contracts.ObservationDto" sourceFiles="src/InsightsService/Contracts/ObservationDto.cs" link="../../src/InsightsService/Contracts/ObservationDto.cs">
<mxGeometry as="geometry" x="70" y="2022" width="520" height="334" />
</mxCell>
<mxCell id="n392" value="+ ObservationId: Guid {get, init}&#10;+ PatientId: Guid {get, init}&#10;+ MeasuredAt: DateTime {get, init}&#10;+ Systolic: int {get, init}&#10;+ Diastolic: int {get, init}&#10;+ Pulse: int {get, init}&#10;+ MeasurementContext: MeasurementContextDto? {get, init}&#10;+ Context: string? {get, init}&#10;+ Note: string? {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n391">
<mxGeometry as="geometry" x="0" y="82" width="520" height="180" />
</mxCell>
<mxCell id="n393" value="+ ObservationDto(Guid ObservationId, Guid PatientId, DateTime&#10;MeasuredAt, int Systolic, int Diastolic, int Pulse, MeasurementContextDto?&#10;MeasurementContext = null, string? Context = null, string? Note = null)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n391">
<mxGeometry as="geometry" x="0" y="262" width="520" height="72" />
</mxCell>
<mxCell id="n391-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n391">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="262" />
<mxPoint as="targetPoint" x="520" y="262" />
</mxGeometry>
</mxCell>
<mxCell id="n394" value="«class»&#10;HttpObservationServiceClient&#10;InsightsService.Clients" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="InsightsService.Clients.HttpObservationServiceClient" sourceFiles="src/InsightsService/Clients/HttpObservationServiceClient.cs" link="../../src/InsightsService/Clients/HttpObservationServiceClient.cs">
<mxGeometry as="geometry" x="730" y="2022" width="520" height="208" />
</mxCell>
<mxCell id="n395" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n394">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n396" value="+ HttpObservationServiceClient(HttpClient client)&#10;+ GetByPeriodAsync(Guid patientId, DateTime from, DateTime to,&#10;ContextSelection selection, CancellationToken cancellationToken):&#10;Task&lt;List&lt;ObservationDto&gt;&gt;" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n394">
<mxGeometry as="geometry" x="0" y="118" width="520" height="90" />
</mxCell>
<mxCell id="n394-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n394">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n397" value="«interface»&#10;ObservationServiceClient&#10;InsightsService.Clients" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="InsightsService.Clients.ObservationServiceClient" sourceFiles="src/InsightsService/Clients/ObservationServiceClient.cs" link="../../src/InsightsService/Clients/ObservationServiceClient.cs">
<mxGeometry as="geometry" x="1390" y="2022" width="520" height="190" />
</mxCell>
<mxCell id="n398" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n397">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n399" value="+ GetByPeriodAsync(Guid patientId, DateTime from, DateTime to,&#10;ContextSelection selection, CancellationToken cancellationToken):&#10;Task&lt;List&lt;ObservationDto&gt;&gt; {abstract}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n397">
<mxGeometry as="geometry" x="0" y="118" width="520" height="72" />
</mxCell>
<mxCell id="n397-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n397">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n400" value="«class»&#10;Program&#10;InsightsService" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#f5f5f5;strokeColor=#444444;" vertex="1" parent="1" sourceType="InsightsService.Program" sourceFiles="src/InsightsService/Program.cs" link="../../src/InsightsService/Program.cs">
<mxGeometry as="geometry" x="2050" y="2022" width="520" height="172" />
</mxCell>
<mxCell id="n401" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n400">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n402" value="+ Main(string[] args): void {static}&#10;- GetGatewayUri(IConfiguration configuration): Uri {static}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n400">
<mxGeometry as="geometry" x="0" y="118" width="520" height="54" />
</mxCell>
<mxCell id="n400-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n400">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n403" value="«framework reference»&#10;ControllerBase" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="70" y="2536" width="520" height="80" />
</mxCell>
<mxCell id="n404" value="«framework reference»&#10;HttpClient" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="730" y="2536" width="520" height="80" />
</mxCell>
<mxCell id="e404-0" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n358" target="n397" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-1" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n358" target="n367" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-2" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n358" target="n370" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-3" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n358" target="n373" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-4" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n358" target="n382" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-5" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=block;endFill=0;" edge="1" parent="1" source="n394" target="n397" relationship="realization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-6" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n394" target="n391" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-7" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n394" target="n367" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-8" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n397" target="n391" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-9" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n397" target="n367" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-10" value="AppliedSelection [1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n385" target="n367" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-11" value="MeasurementContext [0..1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n391" target="n388" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-12" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n355" target="n358" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-13" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n355" target="n385" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-14" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n355" target="n367" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-15" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n355" target="n382" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-16" value="AppliedSelection [1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n370" target="n367" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-17" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n373" target="n391" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-18" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n373" target="n367" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-19" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n373" target="n370" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-20" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n373" target="n382" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-21" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n373" target="n364" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-22" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n373" target="n376" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-23" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n373" target="n361" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-24" value="AppliedSelection [1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n382" target="n367" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-25" value="Comparability [1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n382" target="n364" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-26" value="Systolic [1]; Diastolic [1]; Pulse [1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n382" target="n376" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-27" value="Reference [0..1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n376" target="n361" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-28" value="Sources [0..*]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n361" target="n379" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-29" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n400" target="n358" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-30" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n400" target="n394" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-31" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n400" target="n373" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-32" value="constructor dependency" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n394" target="n404" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e404-33" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n355" target="n403" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="n405" value="Source-linked classifier headers. All declared members shown; compiler-generated record members and inherited framework members are omitted. Partial declarations are merged. Framework base/reference boxes are distinguished from service-defined types. A dependency is not ownership or a cross-service in-process call. See class-diagram-coverage.md for exact file/type coverage." style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="2681" width="2580" height="110" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
@@ -0,0 +1,436 @@
<?xml version='1.0' encoding='utf-8'?>
<mxfile host="app.diagrams.net" version="24.7.17" compressed="false">
<diagram name="ObservationService — implementation classes" id="ObservationService---implementation-classes">
<mxGraphModel grid="1" gridSize="10" page="1" pageWidth="2660" pageHeight="2888" pageScale="1">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="n225" value="ObservationService — implementation classes" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fontSize=24;fontStyle=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="25" width="2580" height="45" />
</mxCell>
<mxCell id="n226" value="UML: + public, - private, # protected, ~ internal. Three compartments = classifier / attributes / operations. Hollow triangle: inheritance; dashed hollow triangle: interface realization. Solid line: attribute reference; dashed arrow: dependency; filled diamond: verified owned context. Each source type has its own classifier. Primary-constructor parameters are constructor operations, not invented fields." style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="85" width="2580" height="100" />
</mxCell>
<mxCell id="n227" value="«class»&#10;ObservationController&#10;ObservationService.Controllers" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#dae8fc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Controllers.ObservationController" sourceFiles="src/ObservationService/Controllers/ObservationController.cs" link="../../src/ObservationService/Controllers/ObservationController.cs">
<mxGeometry as="geometry" x="70" y="210" width="520" height="496" />
</mxCell>
<mxCell id="n228" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n227">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n229" value="+ ObservationController(ObservationApplicationService service)&#10;+ RecordObservation(Guid patientId, RecordObservationRequest request,&#10;CancellationToken cancellationToken):&#10;Task&lt;ActionResult&lt;ObservationDto&gt;&gt;&#10;+ DeleteObservation(Guid observationId, CancellationToken&#10;cancellationToken): Task&lt;IActionResult&gt;&#10;+ UpdateObservation(Guid observationId, UpdateObservationRequest&#10;request, CancellationToken cancellationToken):&#10;Task&lt;ActionResult&lt;ObservationDto&gt;&gt;&#10;+ PatchObservation(Guid observationId, PatchObservationRequest request,&#10;CancellationToken cancellationToken):&#10;Task&lt;ActionResult&lt;ObservationDto&gt;&gt;&#10;+ GetObservation(Guid observationId, CancellationToken&#10;cancellationToken): Task&lt;ActionResult&lt;ObservationDto&gt;&gt;&#10;+ GetLatest(Guid patientId, CancellationToken cancellationToken):&#10;Task&lt;ActionResult&lt;ObservationDto&gt;&gt;&#10;+ GetByPeriod(Guid patientId, DateTime from, DateTime to,&#10;ContextSelection selection, CancellationToken cancellationToken):&#10;Task&lt;ActionResult&lt;List&lt;ObservationDto&gt;&gt;&gt;&#10;- ToDto(BloodPressureObservation observation): ObservationDto {static}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n227">
<mxGeometry as="geometry" x="0" y="118" width="520" height="378" />
</mxCell>
<mxCell id="n227-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n227">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n230" value="«class»&#10;ObservationApplicationService&#10;ObservationService.Application" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#e1d5e7;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Application.ObservationApplicationService" sourceFiles="src/ObservationService/Application/ObservationApplicationService.cs" link="../../src/ObservationService/Application/ObservationApplicationService.cs">
<mxGeometry as="geometry" x="730" y="210" width="520" height="460" />
</mxCell>
<mxCell id="n231" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n230">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n232" value="+ ObservationApplicationService(ObservationRepository repository,&#10;IHttpClientFactory clients)&#10;+ DeleteAsync(Guid observationId, CancellationToken cancellationToken):&#10;Task&lt;bool&gt;&#10;+ UpdateAsync(Guid observationId, UpdateObservationRequest request,&#10;CancellationToken cancellationToken): Task&lt;BloodPressureObservation?&gt;&#10;+ PatchAsync(Guid observationId, PatchObservationRequest request,&#10;CancellationToken cancellationToken): Task&lt;BloodPressureObservation?&gt;&#10;+ RecordAsync(Guid patientId, RecordObservationRequest request,&#10;CancellationToken cancellationToken): Task&lt;BloodPressureObservation?&gt;&#10;+ GetByIdAsync(Guid observationId, CancellationToken cancellationToken):&#10;Task&lt;BloodPressureObservation?&gt;&#10;+ GetLatestAsync(Guid patientId, CancellationToken cancellationToken):&#10;Task&lt;BloodPressureObservation?&gt;&#10;+ GetByPeriodAsync(Guid patientId, DateTime from, DateTime to,&#10;ContextSelection selection, CancellationToken cancellationToken):&#10;Task&lt;List&lt;BloodPressureObservation&gt;&gt;&#10;- NormalizeTimestamp(DateTime timestamp): DateTime {static}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n230">
<mxGeometry as="geometry" x="0" y="118" width="520" height="342" />
</mxCell>
<mxCell id="n230-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n230">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n233" value="«interface»&#10;ObservationRepository&#10;ObservationService.Application" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#e1d5e7;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Application.ObservationRepository" sourceFiles="src/ObservationService/Application/ObservationRepository.cs" link="../../src/ObservationService/Application/ObservationRepository.cs">
<mxGeometry as="geometry" x="1390" y="210" width="520" height="388" />
</mxCell>
<mxCell id="n234" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n233">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n235" value="+ DeleteAsync(Guid observationId, CancellationToken cancellationToken):&#10;Task&lt;bool&gt; {abstract}&#10;+ UpdateAsync(Guid observationId, PatchObservationRequest request,&#10;DateTime updatedAt, CancellationToken cancellationToken):&#10;Task&lt;BloodPressureObservation?&gt; {abstract}&#10;+ SaveAsync(BloodPressureObservation observation, CancellationToken&#10;cancellationToken): Task&lt;BloodPressureObservation&gt; {abstract}&#10;+ FindByIdAsync(Guid observationId, CancellationToken&#10;cancellationToken): Task&lt;BloodPressureObservation?&gt; {abstract}&#10;+ FindLatestByPatientIdAsync(Guid patientId, CancellationToken&#10;cancellationToken): Task&lt;BloodPressureObservation?&gt; {abstract}&#10;+ FindByPatientIdAndPeriodAsync(Guid patientId, DateTime from,&#10;DateTime to, ContextSelection selection, CancellationToken&#10;cancellationToken): Task&lt;List&lt;BloodPressureObservation&gt;&gt; {abstract}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n233">
<mxGeometry as="geometry" x="0" y="118" width="520" height="270" />
</mxCell>
<mxCell id="n233-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n233">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n236" value="«class»&#10;ObservationDbContext&#10;ObservationService.Persistence" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Persistence.ObservationDbContext" sourceFiles="src/ObservationService/Persistence/ObservationDbContext.cs" link="../../src/ObservationService/Persistence/ObservationDbContext.cs">
<mxGeometry as="geometry" x="2050" y="210" width="520" height="190" />
</mxCell>
<mxCell id="n237" value="+ Observations: DbSet&lt;BloodPressureObservation&gt; {get}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n236">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n238" value="+ ObservationDbContext(DbContextOptions&lt;ObservationDbContext&gt;&#10;options)&#10;# OnModelCreating(ModelBuilder modelBuilder): void" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n236">
<mxGeometry as="geometry" x="0" y="118" width="520" height="72" />
</mxCell>
<mxCell id="n236-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n236">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n239" value="«class»&#10;SqlObservationRepository&#10;ObservationService.Persistence" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Persistence.SqlObservationRepository" sourceFiles="src/ObservationService/Persistence/SqlObservationRepository.cs" link="../../src/ObservationService/Persistence/SqlObservationRepository.cs">
<mxGeometry as="geometry" x="70" y="886" width="520" height="406" />
</mxCell>
<mxCell id="n240" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n239">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n241" value="+ SqlObservationRepository(ObservationDbContext db)&#10;+ DeleteAsync(Guid observationId, CancellationToken cancellationToken):&#10;Task&lt;bool&gt;&#10;+ UpdateAsync(Guid observationId, PatchObservationRequest request,&#10;DateTime updatedAt, CancellationToken cancellationToken):&#10;Task&lt;BloodPressureObservation?&gt;&#10;+ SaveAsync(BloodPressureObservation observation, CancellationToken&#10;cancellationToken): Task&lt;BloodPressureObservation&gt;&#10;+ FindByIdAsync(Guid observationId, CancellationToken&#10;cancellationToken): Task&lt;BloodPressureObservation?&gt;&#10;+ FindLatestByPatientIdAsync(Guid patientId, CancellationToken&#10;cancellationToken): Task&lt;BloodPressureObservation?&gt;&#10;+ FindByPatientIdAndPeriodAsync(Guid patientId, DateTime from,&#10;DateTime to, ContextSelection selection, CancellationToken&#10;cancellationToken): Task&lt;List&lt;BloodPressureObservation&gt;&gt;" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n239">
<mxGeometry as="geometry" x="0" y="118" width="520" height="288" />
</mxCell>
<mxCell id="n239-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n239">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n242" value="«class»&#10;BloodPressureObservation&#10;ObservationService.Domain" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#fff2cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Domain.BloodPressureObservation" sourceFiles="src/ObservationService/Domain/BloodPressureObservation.cs" link="../../src/ObservationService/Domain/BloodPressureObservation.cs">
<mxGeometry as="geometry" x="730" y="886" width="520" height="334" />
</mxCell>
<mxCell id="n243" value="+ ObservationId: Guid {get, set}&#10;+ PatientId: Guid {get, set}&#10;+ MeasuredAt: DateTime {get, set}&#10;+ Systolic: int {get, set}&#10;+ Diastolic: int {get, set}&#10;+ Pulse: int {get, set}&#10;+ MeasurementContext: MeasurementContext {get, set}&#10;+ Context: string? {get, set}&#10;+ Note: string? {get, set}&#10;+ CreatedAt: DateTime {get, set}&#10;+ UpdatedAt: DateTime {get, set}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n242">
<mxGeometry as="geometry" x="0" y="82" width="520" height="216" />
</mxCell>
<mxCell id="n244" value="(no declared operations)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n242">
<mxGeometry as="geometry" x="0" y="298" width="520" height="36" />
</mxCell>
<mxCell id="n242-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n242">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="298" />
<mxPoint as="targetPoint" x="520" y="298" />
</mxGeometry>
</mxCell>
<mxCell id="n245" value="«record»&#10;ContextSelection&#10;ObservationService.Domain" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#fff2cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Domain.ContextSelection" sourceFiles="src/ObservationService/Domain/ContextSelection.cs" link="../../src/ObservationService/Domain/ContextSelection.cs">
<mxGeometry as="geometry" x="1390" y="886" width="520" height="172" />
</mxCell>
<mxCell id="n246" value="+ Setting: string? {get, init}&#10;+ ActivityCondition: string? {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n245">
<mxGeometry as="geometry" x="0" y="82" width="520" height="54" />
</mxCell>
<mxCell id="n247" value="(no declared operations)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n245">
<mxGeometry as="geometry" x="0" y="136" width="520" height="36" />
</mxCell>
<mxCell id="n245-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n245">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="136" />
<mxPoint as="targetPoint" x="520" y="136" />
</mxGeometry>
</mxCell>
<mxCell id="n248" value="«record»&#10;MeasurementContext&#10;ObservationService.Domain" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#fff2cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Domain.MeasurementContext" sourceFiles="src/ObservationService/Domain/MeasurementContext.cs" link="../../src/ObservationService/Domain/MeasurementContext.cs">
<mxGeometry as="geometry" x="2050" y="886" width="520" height="280" />
</mxCell>
<mxCell id="n249" value="+ Setting: string? {get, init}&#10;+ ActivityCondition: string? {get, init}&#10;+ RestDurationMinutes: decimal? {get, init}&#10;+ BodyPosition: string? {get, init}&#10;+ MeasuredArm: string? {get, init}&#10;+ DeviceDetails: string? {get, init}&#10;+ CuffDetails: string? {get, init}&#10;+ AdditionalCircumstances: string? {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n248">
<mxGeometry as="geometry" x="0" y="82" width="520" height="162" />
</mxCell>
<mxCell id="n250" value="(no declared operations)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n248">
<mxGeometry as="geometry" x="0" y="244" width="520" height="36" />
</mxCell>
<mxCell id="n248-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n248">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="244" />
<mxPoint as="targetPoint" x="520" y="244" />
</mxGeometry>
</mxCell>
<mxCell id="n251" value="«record»&#10;MeasurementContextPatch&#10;ObservationService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Contracts.MeasurementContextPatch" sourceFiles="src/ObservationService/Contracts/MeasurementContextPatch.cs" link="../../src/ObservationService/Contracts/MeasurementContextPatch.cs">
<mxGeometry as="geometry" x="70" y="1472" width="520" height="586" />
</mxCell>
<mxCell id="n252" value="- setting: string?&#10;+ Setting: string? {get, init}&#10;+ SettingSpecified: bool {get, private set}&#10;- activityCondition: string?&#10;+ ActivityCondition: string? {get, init}&#10;+ ActivityConditionSpecified: bool {get, private set}&#10;- restDurationMinutes: decimal?&#10;+ RestDurationMinutes: decimal? {get, init}&#10;+ RestDurationMinutesSpecified: bool {get, private set}&#10;- bodyPosition: string?&#10;+ BodyPosition: string? {get, init}&#10;+ BodyPositionSpecified: bool {get, private set}&#10;- measuredArm: string?&#10;+ MeasuredArm: string? {get, init}&#10;+ MeasuredArmSpecified: bool {get, private set}&#10;- deviceDetails: string?&#10;+ DeviceDetails: string? {get, init}&#10;+ DeviceDetailsSpecified: bool {get, private set}&#10;- cuffDetails: string?&#10;+ CuffDetails: string? {get, init}&#10;+ CuffDetailsSpecified: bool {get, private set}&#10;- additionalCircumstances: string?&#10;+ AdditionalCircumstances: string? {get, init}&#10;+ AdditionalCircumstancesSpecified: bool {get, private set}&#10;+ HasChanges: bool {get}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n251">
<mxGeometry as="geometry" x="0" y="82" width="520" height="468" />
</mxCell>
<mxCell id="n253" value="(no declared operations)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n251">
<mxGeometry as="geometry" x="0" y="550" width="520" height="36" />
</mxCell>
<mxCell id="n251-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n251">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="550" />
<mxPoint as="targetPoint" x="520" y="550" />
</mxGeometry>
</mxCell>
<mxCell id="n254" value="«record»&#10;ObservationDto&#10;ObservationService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Contracts.ObservationDto" sourceFiles="src/ObservationService/Contracts/ObservationDto.cs" link="../../src/ObservationService/Contracts/ObservationDto.cs">
<mxGeometry as="geometry" x="730" y="1472" width="520" height="334" />
</mxCell>
<mxCell id="n255" value="+ ObservationId: Guid {get, init}&#10;+ PatientId: Guid {get, init}&#10;+ MeasuredAt: DateTime {get, init}&#10;+ Systolic: int {get, init}&#10;+ Diastolic: int {get, init}&#10;+ Pulse: int {get, init}&#10;+ Context: string? {get, init}&#10;+ Note: string? {get, init}&#10;+ MeasurementContext: MeasurementContext {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n254">
<mxGeometry as="geometry" x="0" y="82" width="520" height="180" />
</mxCell>
<mxCell id="n256" value="+ ObservationDto(Guid ObservationId, Guid PatientId, DateTime&#10;MeasuredAt, int Systolic, int Diastolic, int Pulse, string? Context, string?&#10;Note, MeasurementContext MeasurementContext)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n254">
<mxGeometry as="geometry" x="0" y="262" width="520" height="72" />
</mxCell>
<mxCell id="n254-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n254">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="262" />
<mxPoint as="targetPoint" x="520" y="262" />
</mxGeometry>
</mxCell>
<mxCell id="n257" value="«record»&#10;PatchObservationRequest&#10;ObservationService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Contracts.PatchObservationRequest" sourceFiles="src/ObservationService/Contracts/PatchObservationRequest.cs" link="../../src/ObservationService/Contracts/PatchObservationRequest.cs">
<mxGeometry as="geometry" x="1390" y="1472" width="520" height="478" />
</mxCell>
<mxCell id="n258" value="- systolic: int?&#10;+ Systolic: int? {get, init}&#10;+ SystolicSpecified: bool {get, private set}&#10;- diastolic: int?&#10;+ Diastolic: int? {get, init}&#10;+ DiastolicSpecified: bool {get, private set}&#10;- pulse: int?&#10;+ Pulse: int? {get, init}&#10;+ PulseSpecified: bool {get, private set}&#10;- measurementContext: MeasurementContextPatch?&#10;+ MeasurementContext: MeasurementContextPatch? {get, init}&#10;+ MeasurementContextSpecified: bool {get, private set}&#10;- context: string?&#10;+ Context: string? {get, init}&#10;+ ContextSpecified: bool {get, private set}&#10;- note: string?&#10;+ Note: string? {get, init}&#10;+ NoteSpecified: bool {get, private set}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n257">
<mxGeometry as="geometry" x="0" y="82" width="520" height="342" />
</mxCell>
<mxCell id="n259" value="+ Validate(ValidationContext validationContext):&#10;IEnumerable&lt;ValidationResult&gt;" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n257">
<mxGeometry as="geometry" x="0" y="424" width="520" height="54" />
</mxCell>
<mxCell id="n257-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n257">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="424" />
<mxPoint as="targetPoint" x="520" y="424" />
</mxGeometry>
</mxCell>
<mxCell id="n260" value="«record»&#10;RecordObservationRequest&#10;ObservationService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Contracts.RecordObservationRequest" sourceFiles="src/ObservationService/Contracts/RecordObservationRequest.cs" link="../../src/ObservationService/Contracts/RecordObservationRequest.cs">
<mxGeometry as="geometry" x="2050" y="1472" width="520" height="262" />
</mxCell>
<mxCell id="n261" value="+ MeasuredAt: DateTime? {get, init}&#10;+ Systolic: int? {get, init}&#10;+ Diastolic: int? {get, init}&#10;+ Pulse: int? {get, init}&#10;+ MeasurementContext: MeasurementContext? {get, init}&#10;+ Context: string? {get, init}&#10;+ Note: string? {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n260">
<mxGeometry as="geometry" x="0" y="82" width="520" height="144" />
</mxCell>
<mxCell id="n262" value="(no declared operations)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n260">
<mxGeometry as="geometry" x="0" y="226" width="520" height="36" />
</mxCell>
<mxCell id="n260-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n260">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="226" />
<mxPoint as="targetPoint" x="520" y="226" />
</mxGeometry>
</mxCell>
<mxCell id="n263" value="«record»&#10;UpdateObservationRequest&#10;ObservationService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Contracts.UpdateObservationRequest" sourceFiles="src/ObservationService/Contracts/UpdateObservationRequest.cs" link="../../src/ObservationService/Contracts/UpdateObservationRequest.cs">
<mxGeometry as="geometry" x="70" y="2238" width="520" height="190" />
</mxCell>
<mxCell id="n264" value="+ Systolic: int? {get, init}&#10;+ Diastolic: int? {get, init}&#10;+ Pulse: int? {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n263">
<mxGeometry as="geometry" x="0" y="82" width="520" height="72" />
</mxCell>
<mxCell id="n265" value="(no declared operations)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n263">
<mxGeometry as="geometry" x="0" y="154" width="520" height="36" />
</mxCell>
<mxCell id="n263-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n263">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="154" />
<mxPoint as="targetPoint" x="520" y="154" />
</mxGeometry>
</mxCell>
<mxCell id="n266" value="«class»&#10;Program&#10;ObservationService" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#f5f5f5;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Program" sourceFiles="src/ObservationService/Program.cs" link="../../src/ObservationService/Program.cs">
<mxGeometry as="geometry" x="730" y="2238" width="520" height="172" />
</mxCell>
<mxCell id="n267" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n266">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n268" value="+ Main(string[] args): Task {static}&#10;- GetGatewayUri(IConfiguration configuration): Uri {static}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n266">
<mxGeometry as="geometry" x="0" y="118" width="520" height="54" />
</mxCell>
<mxCell id="n266-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n266">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n269" value="«framework reference»&#10;IValidatableObject" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="70" y="2608" width="520" height="80" />
</mxCell>
<mxCell id="n270" value="«framework reference»&#10;ControllerBase" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="730" y="2608" width="520" height="80" />
</mxCell>
<mxCell id="n271" value="«framework reference»&#10;DbContext" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1390" y="2608" width="520" height="80" />
</mxCell>
<mxCell id="n272" value="«framework reference»&#10;IHttpClientFactory" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="2050" y="2608" width="520" height="80" />
</mxCell>
<mxCell id="e272-0" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n230" target="n233" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-1" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n230" target="n257" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-2" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n230" target="n260" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-3" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n230" target="n263" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-4" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n230" target="n242" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-5" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n230" target="n245" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-6" value="creates / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n230" target="n248" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-7" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n233" target="n257" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-8" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n233" target="n242" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-9" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n233" target="n245" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-10" value="MeasurementContext [1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n254" target="n248" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-11" value="measurementContext [0..1]; MeasurementContext [0..1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n257" target="n251" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-12" value="MeasurementContext [0..1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n257" target="n248" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-13" value="MeasurementContext [0..1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n260" target="n248" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-14" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n227" target="n230" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-15" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n227" target="n254" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-16" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n227" target="n257" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-17" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n227" target="n260" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-18" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n227" target="n263" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-19" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n227" target="n242" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-20" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n227" target="n245" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-21" value="MeasurementContext [1]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;startArrow=diamond;startFill=1;endArrow=none;" edge="1" parent="1" source="n242" target="n248" relationship="composition">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-25" value="Observations [0..*]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n236" target="n242" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-26" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=block;endFill=0;" edge="1" parent="1" source="n239" target="n233" relationship="realization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-27" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n239" target="n257" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-28" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n239" target="n242" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-29" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n239" target="n245" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-30" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n239" target="n236" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-31" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n266" target="n230" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-32" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n266" target="n236" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-33" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n266" target="n239" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-34" value="constructor dependency" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n230" target="n272" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-35" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=block;endFill=0;" edge="1" parent="1" source="n257" target="n269" relationship="realization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-36" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n227" target="n270" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e272-37" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n236" target="n271" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="n273" value="Source-linked classifier headers. All declared members shown; compiler-generated record members and inherited framework members are omitted. Partial declarations are merged. Framework base/reference boxes are distinguished from service-defined types. A dependency is not ownership or a cross-service in-process call. See class-diagram-coverage.md for exact file/type coverage." style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="2753" width="2580" height="110" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
<diagram name="ObservationService — EF migration classes" id="ObservationService---EF-migration-classes">
<mxGraphModel grid="1" gridSize="10" page="1" pageWidth="2660" pageHeight="970" pageScale="1">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="n323" value="ObservationService — EF migration classes" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fontSize=24;fontStyle=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="25" width="2580" height="45" />
</mxCell>
<mxCell id="n324" value="UML: + public, - private, # protected, ~ internal. Three compartments = classifier / attributes / operations. Hollow triangle: inheritance; dashed hollow triangle: interface realization. Solid line: attribute reference; dashed arrow: dependency; filled diamond: verified owned context. Each source type has its own classifier. Primary-constructor parameters are constructor operations, not invented fields." style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="85" width="2580" height="100" />
</mxCell>
<mxCell id="n325" value="«class»&#10;InitialObservationSchema&#10;ObservationService.Persistence.Migrations" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Persistence.Migrations.InitialObservationSchema" sourceFiles="src/ObservationService/Persistence/Migrations/20261001095222_InitialObservationSchema.Designer.cs|src/ObservationService/Persistence/Migrations/20261001095222_InitialObservationSchema.cs" link="../../src/ObservationService/Persistence/Migrations/20261001095222_InitialObservationSchema.Designer.cs">
<mxGeometry as="geometry" x="70" y="210" width="520" height="190" />
</mxCell>
<mxCell id="n326" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n325">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n327" value="# BuildTargetModel(ModelBuilder modelBuilder): void&#10;# Up(MigrationBuilder migrationBuilder): void&#10;# Down(MigrationBuilder migrationBuilder): void" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n325">
<mxGeometry as="geometry" x="0" y="118" width="520" height="72" />
</mxCell>
<mxCell id="n325-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n325">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n328" value="«class»&#10;ObservationDbContextModelSnapshot&#10;ObservationService.Persistence.Migrations" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Persistence.Migrations.ObservationDbContextModelSnapshot" sourceFiles="src/ObservationService/Persistence/Migrations/ObservationDbContextModelSnapshot.cs" link="../../src/ObservationService/Persistence/Migrations/ObservationDbContextModelSnapshot.cs">
<mxGeometry as="geometry" x="730" y="210" width="520" height="154" />
</mxCell>
<mxCell id="n329" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n328">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n330" value="# BuildModel(ModelBuilder modelBuilder): void" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n328">
<mxGeometry as="geometry" x="0" y="118" width="520" height="36" />
</mxCell>
<mxCell id="n328-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n328">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n331" value="«class»&#10;RecordedMeasurementContext&#10;ObservationService.Persistence.Migrations" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="ObservationService.Persistence.Migrations.RecordedMeasurementContext" sourceFiles="src/ObservationService/Persistence/Migrations/20261005094632_RecordedMeasurementContext.Designer.cs|src/ObservationService/Persistence/Migrations/20261005094632_RecordedMeasurementContext.cs" link="../../src/ObservationService/Persistence/Migrations/20261005094632_RecordedMeasurementContext.Designer.cs">
<mxGeometry as="geometry" x="1390" y="210" width="520" height="190" />
</mxCell>
<mxCell id="n332" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n331">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n333" value="# BuildTargetModel(ModelBuilder modelBuilder): void&#10;# Up(MigrationBuilder migrationBuilder): void&#10;# Down(MigrationBuilder migrationBuilder): void" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n331">
<mxGeometry as="geometry" x="0" y="118" width="520" height="72" />
</mxCell>
<mxCell id="n331-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n331">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n334" value="«framework reference»&#10;Migration" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="70" y="580" width="520" height="80" />
</mxCell>
<mxCell id="n335" value="«framework reference»&#10;ModelSnapshot" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="730" y="580" width="520" height="80" />
</mxCell>
<mxCell id="n336" value="«same-service type, other page»&#10;ObservationDbContext" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1" referenceType="ObservationService.Persistence.ObservationDbContext">
<mxGeometry as="geometry" x="70" y="690" width="520" height="80" />
</mxCell>
<mxCell id="e336-22" value="creates / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n325" target="n336" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e336-23" value="creates / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n331" target="n336" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e336-24" value="creates / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n328" target="n336" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e336-34" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n325" target="n334" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e336-35" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n331" target="n334" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e336-36" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n328" target="n335" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="n337" value="Source-linked classifier headers. All declared members shown; compiler-generated record members and inherited framework members are omitted. Partial declarations are merged. Framework base/reference boxes are distinguished from service-defined types. A dependency is not ownership or a cross-service in-process call. See class-diagram-coverage.md for exact file/type coverage." style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="835" width="2580" height="110" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
@@ -0,0 +1,349 @@
<?xml version='1.0' encoding='utf-8'?>
<mxfile host="app.diagrams.net" version="24.7.17" compressed="false">
<diagram name="PatientProfileService — implementation classes" id="PatientProfileService---implementation-classes">
<mxGraphModel grid="1" gridSize="10" page="1" pageWidth="2660" pageHeight="1870" pageScale="1">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="n117" value="PatientProfileService — implementation classes" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fontSize=24;fontStyle=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="25" width="2580" height="45" />
</mxCell>
<mxCell id="n118" value="UML: + public, - private, # protected, ~ internal. Three compartments = classifier / attributes / operations. Hollow triangle: inheritance; dashed hollow triangle: interface realization. Solid line: attribute reference; dashed arrow: dependency; filled diamond: verified owned context. Each source type has its own classifier. Primary-constructor parameters are constructor operations, not invented fields." style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="85" width="2580" height="100" />
</mxCell>
<mxCell id="n119" value="«class»&#10;PatientController&#10;PatientProfileService.Controllers" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#dae8fc;strokeColor=#444444;" vertex="1" parent="1" sourceType="PatientProfileService.Controllers.PatientController" sourceFiles="src/PatientProfileService/Controllers/PatientController.cs" link="../../src/PatientProfileService/Controllers/PatientController.cs">
<mxGeometry as="geometry" x="70" y="210" width="520" height="316" />
</mxCell>
<mxCell id="n120" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n119">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n121" value="+ PatientController(PatientApplicationService service)&#10;+ CreatePatient(CreatePatientRequest request, CancellationToken&#10;cancellationToken): Task&lt;ActionResult&lt;PatientDto&gt;&gt;&#10;+ GetByAccount(string accountId, CancellationToken cancellationToken):&#10;Task&lt;ActionResult&lt;PatientDto&gt;&gt;&#10;+ GetPatient(Guid patientId, CancellationToken cancellationToken):&#10;Task&lt;ActionResult&lt;PatientDto&gt;&gt;&#10;+ UpdatePatient(Guid patientId, UpdatePatientRequest request,&#10;CancellationToken cancellationToken): Task&lt;ActionResult&lt;PatientDto&gt;&gt;&#10;- ToDto(Patient patient): PatientDto {static}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n119">
<mxGeometry as="geometry" x="0" y="118" width="520" height="198" />
</mxCell>
<mxCell id="n119-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n119">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n122" value="«class»&#10;PatientApplicationService&#10;PatientProfileService.Application" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#e1d5e7;strokeColor=#444444;" vertex="1" parent="1" sourceType="PatientProfileService.Application.PatientApplicationService" sourceFiles="src/PatientProfileService/Application/PatientApplicationService.cs" link="../../src/PatientProfileService/Application/PatientApplicationService.cs">
<mxGeometry as="geometry" x="730" y="210" width="520" height="298" />
</mxCell>
<mxCell id="n123" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n122">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n124" value="+ PatientApplicationService(PatientRepository repository)&#10;+ CreatePatientAsync(CreatePatientRequest request, string accountId,&#10;CancellationToken cancellationToken): Task&lt;Patient&gt;&#10;+ GetByAccountAsync(string accountId, CancellationToken&#10;cancellationToken): Task&lt;Patient?&gt;&#10;+ GetPatientAsync(Guid patientId, CancellationToken cancellationToken):&#10;Task&lt;Patient?&gt;&#10;+ UpdatePatientAsync(Guid patientId, UpdatePatientRequest request,&#10;CancellationToken cancellationToken): Task&lt;Patient?&gt;" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n122">
<mxGeometry as="geometry" x="0" y="118" width="520" height="180" />
</mxCell>
<mxCell id="n122-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n122">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n125" value="«interface»&#10;PatientRepository&#10;PatientProfileService.Application" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#e1d5e7;strokeColor=#444444;" vertex="1" parent="1" sourceType="PatientProfileService.Application.PatientRepository" sourceFiles="src/PatientProfileService/Application/PatientRepository.cs" link="../../src/PatientProfileService/Application/PatientRepository.cs">
<mxGeometry as="geometry" x="1390" y="210" width="520" height="280" />
</mxCell>
<mxCell id="n126" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n125">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n127" value="+ FindByAccountIdAsync(string accountId, CancellationToken&#10;cancellationToken): Task&lt;Patient?&gt; {abstract}&#10;+ SaveAsync(Patient patient, CancellationToken cancellationToken):&#10;Task&lt;Patient&gt; {abstract}&#10;+ FindByIdAsync(Guid patientId, CancellationToken cancellationToken):&#10;Task&lt;Patient?&gt; {abstract}&#10;+ UpdateProfileAsync(Guid patientId, string name, string? contactInfo,&#10;CancellationToken cancellationToken): Task&lt;bool&gt; {abstract}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n125">
<mxGeometry as="geometry" x="0" y="118" width="520" height="162" />
</mxCell>
<mxCell id="n125-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n125">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n128" value="«class»&#10;ProfileAlreadyExistsException&#10;PatientProfileService.Application" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#e1d5e7;strokeColor=#444444;" vertex="1" parent="1" sourceType="PatientProfileService.Application.ProfileAlreadyExistsException" sourceFiles="src/PatientProfileService/Application/ProfileAlreadyExistsException.cs" link="../../src/PatientProfileService/Application/ProfileAlreadyExistsException.cs">
<mxGeometry as="geometry" x="2050" y="210" width="520" height="154" />
</mxCell>
<mxCell id="n129" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n128">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n130" value="(no declared operations)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n128">
<mxGeometry as="geometry" x="0" y="118" width="520" height="36" />
</mxCell>
<mxCell id="n128-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n128">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n131" value="«class»&#10;PatientDbContext&#10;PatientProfileService.Persistence" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="PatientProfileService.Persistence.PatientDbContext" sourceFiles="src/PatientProfileService/Persistence/PatientDbContext.cs" link="../../src/PatientProfileService/Persistence/PatientDbContext.cs">
<mxGeometry as="geometry" x="70" y="706" width="520" height="172" />
</mxCell>
<mxCell id="n132" value="+ Patients: DbSet&lt;Patient&gt; {get}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n131">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n133" value="+ PatientDbContext(DbContextOptions&lt;PatientDbContext&gt; options)&#10;# OnModelCreating(ModelBuilder modelBuilder): void" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n131">
<mxGeometry as="geometry" x="0" y="118" width="520" height="54" />
</mxCell>
<mxCell id="n131-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n131">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n134" value="«class»&#10;SqlPatientRepository&#10;PatientProfileService.Persistence" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="PatientProfileService.Persistence.SqlPatientRepository" sourceFiles="src/PatientProfileService/Persistence/SqlPatientRepository.cs" link="../../src/PatientProfileService/Persistence/SqlPatientRepository.cs">
<mxGeometry as="geometry" x="730" y="706" width="520" height="298" />
</mxCell>
<mxCell id="n135" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n134">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n136" value="+ SqlPatientRepository(PatientDbContext db)&#10;+ SaveAsync(Patient patient, CancellationToken cancellationToken):&#10;Task&lt;Patient&gt;&#10;+ FindByAccountIdAsync(string accountId, CancellationToken&#10;cancellationToken): Task&lt;Patient?&gt;&#10;+ FindByIdAsync(Guid patientId, CancellationToken cancellationToken):&#10;Task&lt;Patient?&gt;&#10;+ UpdateProfileAsync(Guid patientId, string name, string? contactInfo,&#10;CancellationToken cancellationToken): Task&lt;bool&gt;" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n134">
<mxGeometry as="geometry" x="0" y="118" width="520" height="180" />
</mxCell>
<mxCell id="n134-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n134">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n137" value="«class»&#10;Patient&#10;PatientProfileService.Domain" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#fff2cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="PatientProfileService.Domain.Patient" sourceFiles="src/PatientProfileService/Domain/Patient.cs" link="../../src/PatientProfileService/Domain/Patient.cs">
<mxGeometry as="geometry" x="1390" y="706" width="520" height="262" />
</mxCell>
<mxCell id="n138" value="+ AccountId: string? {get, set}&#10;+ PatientId: Guid {get, set}&#10;+ Name: string {get, set}&#10;+ DateOfBirth: DateOnly {get, set}&#10;+ ContactInfo: string? {get, set}&#10;+ CreatedAt: DateTime {get, set}&#10;+ UpdatedAt: DateTime {get, set}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n137">
<mxGeometry as="geometry" x="0" y="82" width="520" height="144" />
</mxCell>
<mxCell id="n139" value="(no declared operations)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n137">
<mxGeometry as="geometry" x="0" y="226" width="520" height="36" />
</mxCell>
<mxCell id="n137-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n137">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="226" />
<mxPoint as="targetPoint" x="520" y="226" />
</mxGeometry>
</mxCell>
<mxCell id="n140" value="«record»&#10;CreatePatientRequest&#10;PatientProfileService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="PatientProfileService.Contracts.CreatePatientRequest" sourceFiles="src/PatientProfileService/Contracts/CreatePatientRequest.cs" link="../../src/PatientProfileService/Contracts/CreatePatientRequest.cs">
<mxGeometry as="geometry" x="2050" y="706" width="520" height="190" />
</mxCell>
<mxCell id="n141" value="+ Name: string? {get, init}&#10;+ DateOfBirth: DateOnly? {get, init}&#10;+ ContactInfo: string? {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n140">
<mxGeometry as="geometry" x="0" y="82" width="520" height="72" />
</mxCell>
<mxCell id="n142" value="(no declared operations)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n140">
<mxGeometry as="geometry" x="0" y="154" width="520" height="36" />
</mxCell>
<mxCell id="n140-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n140">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="154" />
<mxPoint as="targetPoint" x="520" y="154" />
</mxGeometry>
</mxCell>
<mxCell id="n143" value="«record»&#10;PatientDto&#10;PatientProfileService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="PatientProfileService.Contracts.PatientDto" sourceFiles="src/PatientProfileService/Contracts/PatientDto.cs" link="../../src/PatientProfileService/Contracts/PatientDto.cs">
<mxGeometry as="geometry" x="70" y="1184" width="520" height="226" />
</mxCell>
<mxCell id="n144" value="+ PatientId: Guid {get, init}&#10;+ Name: string {get, init}&#10;+ DateOfBirth: DateOnly {get, init}&#10;+ ContactInfo: string? {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n143">
<mxGeometry as="geometry" x="0" y="82" width="520" height="90" />
</mxCell>
<mxCell id="n145" value="+ PatientDto(Guid PatientId, string Name, DateOnly DateOfBirth, string?&#10;ContactInfo)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n143">
<mxGeometry as="geometry" x="0" y="172" width="520" height="54" />
</mxCell>
<mxCell id="n143-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n143">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="172" />
<mxPoint as="targetPoint" x="520" y="172" />
</mxGeometry>
</mxCell>
<mxCell id="n146" value="«record»&#10;UpdatePatientRequest&#10;PatientProfileService.Contracts" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#ffe6cc;strokeColor=#444444;" vertex="1" parent="1" sourceType="PatientProfileService.Contracts.UpdatePatientRequest" sourceFiles="src/PatientProfileService/Contracts/UpdatePatientRequest.cs" link="../../src/PatientProfileService/Contracts/UpdatePatientRequest.cs">
<mxGeometry as="geometry" x="730" y="1184" width="520" height="172" />
</mxCell>
<mxCell id="n147" value="+ Name: string? {get, init}&#10;+ ContactInfo: string? {get, init}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n146">
<mxGeometry as="geometry" x="0" y="82" width="520" height="54" />
</mxCell>
<mxCell id="n148" value="(no declared operations)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n146">
<mxGeometry as="geometry" x="0" y="136" width="520" height="36" />
</mxCell>
<mxCell id="n146-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n146">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="136" />
<mxPoint as="targetPoint" x="520" y="136" />
</mxGeometry>
</mxCell>
<mxCell id="n149" value="«class»&#10;Program&#10;PatientProfileService" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#f5f5f5;strokeColor=#444444;" vertex="1" parent="1" sourceType="PatientProfileService.Program" sourceFiles="src/PatientProfileService/Program.cs" link="../../src/PatientProfileService/Program.cs">
<mxGeometry as="geometry" x="1390" y="1184" width="520" height="154" />
</mxCell>
<mxCell id="n150" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n149">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n151" value="+ Main(string[] args): Task {static}" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n149">
<mxGeometry as="geometry" x="0" y="118" width="520" height="36" />
</mxCell>
<mxCell id="n149-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n149">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n152" value="«framework reference»&#10;Exception" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="70" y="1590" width="520" height="80" />
</mxCell>
<mxCell id="n153" value="«framework reference»&#10;ControllerBase" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="730" y="1590" width="520" height="80" />
</mxCell>
<mxCell id="n154" value="«framework reference»&#10;DbContext" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1390" y="1590" width="520" height="80" />
</mxCell>
<mxCell id="e154-0" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n122" target="n125" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-1" value="creates / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n122" target="n128" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-2" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n122" target="n140" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-3" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n122" target="n146" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-4" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n122" target="n137" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-5" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n125" target="n137" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-6" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n119" target="n122" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-7" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n119" target="n140" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-8" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n119" target="n143" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-9" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n119" target="n146" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-10" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n119" target="n137" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-14" value="Patients [0..*]" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="n131" target="n137" relationship="association">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-15" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=block;endFill=0;" edge="1" parent="1" source="n134" target="n125" relationship="realization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-16" value="creates / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n134" target="n128" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-17" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n134" target="n137" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-18" value="signature / constructor" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n134" target="n131" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-19" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n149" target="n122" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-20" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n149" target="n131" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-21" value="registers / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n149" target="n134" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-22" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n128" target="n152" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-23" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n119" target="n153" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e154-24" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n131" target="n154" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="n155" value="Source-linked classifier headers. All declared members shown; compiler-generated record members and inherited framework members are omitted. Partial declarations are merged. Framework base/reference boxes are distinguished from service-defined types. A dependency is not ownership or a cross-service in-process call. See class-diagram-coverage.md for exact file/type coverage." style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="1735" width="2580" height="110" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
<diagram name="PatientProfileService — EF migration classes" id="PatientProfileService---EF-migration-classes">
<mxGraphModel grid="1" gridSize="10" page="1" pageWidth="2660" pageHeight="970" pageScale="1">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="n195" value="PatientProfileService — EF migration classes" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fontSize=24;fontStyle=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="25" width="2580" height="45" />
</mxCell>
<mxCell id="n196" value="UML: + public, - private, # protected, ~ internal. Three compartments = classifier / attributes / operations. Hollow triangle: inheritance; dashed hollow triangle: interface realization. Solid line: attribute reference; dashed arrow: dependency; filled diamond: verified owned context. Each source type has its own classifier. Primary-constructor parameters are constructor operations, not invented fields." style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="85" width="2580" height="100" />
</mxCell>
<mxCell id="n197" value="«class»&#10;AccountProfileAssociation&#10;PatientProfileService.Persistence.Migrations" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="PatientProfileService.Persistence.Migrations.AccountProfileAssociation" sourceFiles="src/PatientProfileService/Persistence/Migrations/20261005082209_AccountProfileAssociation.Designer.cs|src/PatientProfileService/Persistence/Migrations/20261005082209_AccountProfileAssociation.cs" link="../../src/PatientProfileService/Persistence/Migrations/20261005082209_AccountProfileAssociation.Designer.cs">
<mxGeometry as="geometry" x="70" y="210" width="520" height="190" />
</mxCell>
<mxCell id="n198" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n197">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n199" value="# BuildTargetModel(ModelBuilder modelBuilder): void&#10;# Up(MigrationBuilder migrationBuilder): void&#10;# Down(MigrationBuilder migrationBuilder): void" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n197">
<mxGeometry as="geometry" x="0" y="118" width="520" height="72" />
</mxCell>
<mxCell id="n197-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n197">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n200" value="«class»&#10;InitialPatientSchema&#10;PatientProfileService.Persistence.Migrations" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="PatientProfileService.Persistence.Migrations.InitialPatientSchema" sourceFiles="src/PatientProfileService/Persistence/Migrations/20260930200031_InitialPatientSchema.Designer.cs|src/PatientProfileService/Persistence/Migrations/20260930200031_InitialPatientSchema.cs" link="../../src/PatientProfileService/Persistence/Migrations/20260930200031_InitialPatientSchema.Designer.cs">
<mxGeometry as="geometry" x="730" y="210" width="520" height="190" />
</mxCell>
<mxCell id="n201" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n200">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n202" value="# BuildTargetModel(ModelBuilder modelBuilder): void&#10;# Up(MigrationBuilder migrationBuilder): void&#10;# Down(MigrationBuilder migrationBuilder): void" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n200">
<mxGeometry as="geometry" x="0" y="118" width="520" height="72" />
</mxCell>
<mxCell id="n200-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n200">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n203" value="«class»&#10;PatientDbContextModelSnapshot&#10;PatientProfileService.Persistence.Migrations" style="swimlane;startSize=82;horizontal=1;html=0;whiteSpace=wrap;align=center;verticalAlign=top;fontSize=13;fontStyle=1;spacing=7;fillColor=#d5e8d4;strokeColor=#444444;" vertex="1" parent="1" sourceType="PatientProfileService.Persistence.Migrations.PatientDbContextModelSnapshot" sourceFiles="src/PatientProfileService/Persistence/Migrations/PatientDbContextModelSnapshot.cs" link="../../src/PatientProfileService/Persistence/Migrations/PatientDbContextModelSnapshot.cs">
<mxGeometry as="geometry" x="1390" y="210" width="520" height="154" />
</mxCell>
<mxCell id="n204" value="(no declared attributes)" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n203">
<mxGeometry as="geometry" x="0" y="82" width="520" height="36" />
</mxCell>
<mxCell id="n205" value="# BuildModel(ModelBuilder modelBuilder): void" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;fillColor=none;strokeColor=none;" vertex="1" parent="n203">
<mxGeometry as="geometry" x="0" y="118" width="520" height="36" />
</mxCell>
<mxCell id="n203-sep" style="endArrow=none;strokeColor=#444444;" edge="1" parent="n203">
<mxGeometry as="geometry" relative="1">
<mxPoint as="sourcePoint" x="0" y="118" />
<mxPoint as="targetPoint" x="520" y="118" />
</mxGeometry>
</mxCell>
<mxCell id="n206" value="«framework reference»&#10;Migration" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="70" y="580" width="520" height="80" />
</mxCell>
<mxCell id="n207" value="«framework reference»&#10;ModelSnapshot" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1">
<mxGeometry as="geometry" x="730" y="580" width="520" height="80" />
</mxCell>
<mxCell id="n208" value="«same-service type, other page»&#10;PatientDbContext" style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;align=center;fillColor=#ffffff;strokeColor=#777777;dashed=1;" vertex="1" parent="1" referenceType="PatientProfileService.Persistence.PatientDbContext">
<mxGeometry as="geometry" x="70" y="690" width="520" height="80" />
</mxCell>
<mxCell id="e208-11" value="creates / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n200" target="n208" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e208-12" value="creates / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n197" target="n208" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e208-13" value="creates / configures" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;dashed=1;endArrow=open;" edge="1" parent="1" source="n203" target="n208" relationship="dependency">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e208-22" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n200" target="n206" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e208-23" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n197" target="n206" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="e208-24" value="" style="edgeStyle=orthogonalEdgeStyle;html=0;rounded=0;fontSize=11;labelBackgroundColor=#ffffff;endArrow=block;endFill=0;" edge="1" parent="1" source="n203" target="n207" relationship="generalization">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="n209" value="Source-linked classifier headers. All declared members shown; compiler-generated record members and inherited framework members are omitted. Partial declarations are merged. Framework base/reference boxes are distinguished from service-defined types. A dependency is not ownership or a cross-service in-process call. See class-diagram-coverage.md for exact file/type coverage." style="text;html=0;whiteSpace=wrap;align=left;verticalAlign=top;fontSize=13;spacing=8;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="835" width="2580" height="110" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,47 @@
<?xml version='1.0' encoding='utf-8'?>
<mxfile host="app.diagrams.net" version="24.7.17" compressed="false">
<diagram id="p1" name="Ownership and physical persistence">
<mxGraphModel dx="1700" dy="1500" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1700" pageHeight="1400" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="c1" value="Ownership and physical persistence" style="text;html=0;fontSize=24;fontStyle=1;align=left;verticalAlign=middle;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="15" width="1640" height="45" />
</mxCell>
<mxCell id="c2" value="Patient/Profile process&#10;PatientDbContext / SqlPatientRepository&#10;Own credentials only" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="120" width="450" height="160" />
</mxCell>
<mxCell id="c3" value="Observation process&#10;ObservationDbContext / SqlObservationRepository&#10;Own credentials only" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="900" y="120" width="450" height="160" />
</mxCell>
<mxCell id="c4" value="Patient database: patient&#10;PK patient_id UUID&#10;account_id TEXT nullable; UNIQUE&#10;name VARCHAR NOT NULL&#10;date_of_birth DATE NOT NULL&#10;contact_info VARCHAR nullable&#10;created_at / updated_at TIMESTAMP NOT NULL&#10;+ __EFMigrationsHistory" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#fff2cc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="420" width="520" height="310" />
</mxCell>
<mxCell id="c5" value="Observation database: blood_pressure_observation&#10;PK observation_id UUID; external patient_id UUID&#10;measured_at / created_at / updated_at TIMESTAMP&#10;systolic / diastolic / pulse INTEGER NOT NULL&#10;context / note VARCHAR nullable&#10;setting / activity_condition TEXT NOT NULL = Unknown&#10;rest_duration_minutes NUMERIC nullable&#10;body_position / measured_arm / device_details /&#10;cuff_details / additional_circumstances TEXT nullable&#10;+ __EFMigrationsHistory" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#fff2cc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="900" y="420" width="650" height="350" />
</mxCell>
<mxCell id="c6" value="EF Core / own role" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c2" target="c4">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c7" value="EF Core / own role" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c3" target="c5">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c8" value="Logical patient_id reference ONLY&#10;No SQL access / FK / join" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=none;" edge="1" parent="1" source="c5" target="c4">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c9" value="Gateway-owned files/configuration&#10;Configured password hashes + roles&#10;Configured professional assignment IDs&#10;Persistent Data Protection XML key ring&#10;No Gateway clinical database" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#dae8fc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="900" width="520" height="220" />
</mxCell>
<mxCell id="c10" value="Insights / Overview&#10;Deserialize local wire DTOs&#10;Calculate/compose results in request memory&#10;No result database, stored IDs or cache&#10;No source-database credentials" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#dae8fc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="640" y="900" width="490" height="220" />
</mxCell>
<mxCell id="c11" value="Administrative deployment material&#10;Manifest/service.env/JSON/PFX&#10;Generated account passwords and service/DB keys&#10;Protected root/admin files; scoped distribution&#10;Public CA exported; signing key not retained" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1180" y="900" width="450" height="220" />
</mxCell>
<mxCell id="c12" value="TIMESTAMP means timestamp without time zone, interpreted as UTC clock values. MeasurementContext uses columns in the observation row, not a separate table. Only PK and account uniqueness indexes are declared. Diagram shows logical database owners; PostgreSQL servers may be colocated or separate. Sources: DbContexts, migrations, Deployment/DatabaseProvisioning." style="rounded=0;whiteSpace=wrap;html=0;fillColor=#fff2cc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="1220" width="1630" height="100" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
@@ -0,0 +1,165 @@
<?xml version='1.0' encoding='utf-8'?>
<mxfile host="app.diagrams.net" version="24.7.17" compressed="false">
<diagram id="p1" name="Colocated Linux: separate native processes">
<mxGraphModel dx="1700" dy="1500" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1700" pageHeight="1250" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="c1" value="Colocated Linux: separate native processes" style="text;html=0;fontSize=24;fontStyle=1;align=left;verticalAlign=middle;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="15" width="1640" height="45" />
</mxCell>
<mxCell id="c2" value="Client machine&#10;HTTPS trust in public CA&#10;Token-bearing requests → Gateway" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="110" width="350" height="170" />
</mxCell>
<mxCell id="c3" value="One Linux host: Debian/Ubuntu family + apt + systemd&#10;.NET 10 ASP.NET Core runtime; local PostgreSQL for selected persistent services&#10;Same service DLLs as distributed deployment; all ports configurable" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="460" y="110" width="1190" height="160" />
</mxCell>
<mxCell id="c4" value="healthapp-api-gateway.service&#10;Dedicated healthapp-api-gateway identity&#10;Independent dotnet process&#10;HTTPS 0.0.0.0:5443&#10;/opt/healthapp/api-gateway&#10;/etc/healthapp/api-gateway/service.env" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#dae8fc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="40" y="410" width="300" height="240" />
</mxCell>
<mxCell id="c5" value="healthapp-patient-profile.service&#10;Dedicated healthapp-patient-profile identity&#10;Independent dotnet process&#10;HTTPS 0.0.0.0:5081&#10;/opt/healthapp/patient-profile&#10;/etc/healthapp/patient-profile/service.env" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#dae8fc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="375" y="410" width="300" height="240" />
</mxCell>
<mxCell id="c6" value="healthapp-observation.service&#10;Dedicated healthapp-observation identity&#10;Independent dotnet process&#10;HTTPS 0.0.0.0:5082&#10;/opt/healthapp/observation&#10;/etc/healthapp/observation/service.env" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#dae8fc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="710" y="410" width="300" height="240" />
</mxCell>
<mxCell id="c7" value="healthapp-insights.service&#10;Dedicated healthapp-insights identity&#10;Independent dotnet process&#10;HTTPS 0.0.0.0:5083&#10;/opt/healthapp/insights&#10;/etc/healthapp/insights/service.env" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#dae8fc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1045" y="410" width="300" height="240" />
</mxCell>
<mxCell id="c8" value="healthapp-health-overview.service&#10;Dedicated healthapp-health-overview identity&#10;Independent dotnet process&#10;HTTPS 0.0.0.0:5084&#10;/opt/healthapp/health-overview&#10;/etc/healthapp/health-overview/service.env" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#dae8fc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1380" y="410" width="300" height="240" />
</mxCell>
<mxCell id="c9" value="HTTPS :5443" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c2" target="c4">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c10" value="HTTPS + incoming key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c4" target="c5">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c11" value="HTTPS + incoming key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c4" target="c6">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c12" value="HTTPS + incoming key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c4" target="c7">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c13" value="HTTPS + incoming key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c4" target="c8">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c14" value="HTTPS + callback key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c6" target="c4">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c15" value="HTTPS + callback key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c7" target="c4">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c16" value="HTTPS + callback key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c8" target="c4">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c17" value="Local PostgreSQL server&#10;Separate profile DB and observation DB&#10;Separate roles; no cross-database rights" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#fff2cc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="390" y="830" width="610" height="180" />
</mxCell>
<mxCell id="c18" value="Profile DB" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c5" target="c17">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c19" value="Observation DB" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c6" target="c17">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c20" value="Private administrative plan + public CA trust&#10;Gateway key ring: /var/lib/healthapp-api-gateway/keys&#10;Per-service PFX; env supplied by systemd" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1090" y="820" width="540" height="180" />
</mxCell>
<mxCell id="c21" value="Topology is supported configuration, not a fresh inspection of a live host. Peer units are not PartOf/Requires/BindsTo one another. Default port numbers come from Deployment.cs, not hard-coded application routing. Stopping a process does not directly stop peers; dependent API workflows can fail." style="rounded=0;whiteSpace=wrap;html=0;fillColor=#fff2cc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="1100" width="1620" height="100" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
<diagram id="p2" name="Distributed Linux: supported topology">
<mxGraphModel dx="1700" dy="1500" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1800" pageHeight="1350" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="c22" value="Distributed Linux: supported topology" style="text;html=0;fontSize=24;fontStyle=1;align=left;verticalAlign=middle;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="15" width="1740" height="45" />
</mxCell>
<mxCell id="c23" value="Machine A&#10;Gateway process / systemd&#10;HTTPS :5443&#10;Local account/assignment configuration&#10;Own key ring + certificate&#10;No clinical DB" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#dae8fc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="700" y="110" width="380" height="210" />
</mxCell>
<mxCell id="c24" value="Machine B&#10;Patient/Profile process / systemd&#10;HTTPS :5081&#10;Own profile DB + role&#10;Local PostgreSQL or configured remote DB" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="550" width="380" height="220" />
</mxCell>
<mxCell id="c25" value="Machine C&#10;Observation process / systemd&#10;HTTPS :5082&#10;Own observation DB + role&#10;Local PostgreSQL or configured remote DB" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="470" y="550" width="380" height="220" />
</mxCell>
<mxCell id="c26" value="Machine D&#10;Insights process / systemd&#10;HTTPS :5083&#10;No DB&#10;History client origin = Gateway" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="910" y="550" width="380" height="220" />
</mxCell>
<mxCell id="c27" value="Machine E&#10;Overview process / systemd&#10;HTTPS :5084&#10;No DB&#10;All three client origins = Gateway" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1350" y="550" width="380" height="220" />
</mxCell>
<mxCell id="c28" value="HTTPS + X-Gateway-Key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c23" target="c24">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c29" value="HTTPS + X-Gateway-Key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c23" target="c25">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c30" value="HTTPS + X-Gateway-Key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c23" target="c26">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c31" value="HTTPS + X-Gateway-Key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c23" target="c27">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c32" value="HTTPS + X-Service-Key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c25" target="c23">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c33" value="HTTPS + X-Service-Key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c26" target="c23">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c34" value="HTTPS + X-Service-Key" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c27" target="c23">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c35" value="Administrative preparation / distribution&#10;One topology plan → scoped files per host&#10;SSH/SCP and noninteractive native install&#10;OS CA trust + dedicated service identities&#10;Final HTTPS topology verification" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#f5f5f5;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="490" y="970" width="760" height="230" />
</mxCell>
<mxCell id="c36" value="SSH/SCP administration (not app traffic)" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=open;dashed=1;" edge="1" parent="1" source="c35" target="c23">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c37" value="Each process uses its own local config/private certificate. No shared runtime directory or common process memory across machines. All origin hosts/ports configurable. Real multi-machine deployment remains an evidence limit; tests use separate loopback origins and transport doubles." style="rounded=0;whiteSpace=wrap;html=0;fillColor=#fff2cc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="1240" width="1720" height="100" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
<diagram id="p3" name="Native platform adapters: same application DLLs">
<mxGraphModel dx="1700" dy="1500" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1700" pageHeight="1200" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="c38" value="Native platform adapters: same application DLLs" style="text;html=0;fontSize=24;fontStyle=1;align=left;verticalAlign=middle;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="15" width="1640" height="45" />
</mxCell>
<mxCell id="c39" value="Build machine&#10;.NET 10 SDK + package feeds&#10;Publish separate framework-dependent DLLs&#10;No OS-specific apphost; no containers&#10;Bundle includes provisioner + installers" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#dae8fc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="570" y="110" width="560" height="200" />
</mxCell>
<mxCell id="c40" value="Linux target&#10;Debian/Ubuntu ancestry, apt, systemd&#10;Install aspnetcore-runtime-10.0 if absent&#10;PostgreSQL when persistent service selected&#10;Per-service Unix users/env/PFX&#10;Native unit + restart-on-failure" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="540" width="490" height="270" />
</mxCell>
<mxCell id="c41" value="Windows target&#10;Windows Services / virtual service identities&#10;.NET runtime download if absent&#10;EDB PostgreSQL 17 manifest/checksum&#10;%ProgramData%/HealthApp paths&#10;JSON/PFX ACLs + selected firewall rules&#10;UseWindowsService lifetime" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="600" y="540" width="490" height="270" />
</mxCell>
<mxCell id="c42" value="macOS target&#10;launchd / hidden service identities&#10;.NET runtime download if absent&#10;Homebrew PostgreSQL 17 / owned cluster&#10;Apple tools/Homebrew if needed&#10;/Library/Application Support/HealthApp&#10;System CA trust; private env/plist" style="rounded=0;whiteSpace=wrap;html=0;fillColor=#d5e8d4;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="1170" y="540" width="490" height="270" />
</mxCell>
<mxCell id="c43" value="Same DLLs; native adapter" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c39" target="c40">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c44" value="Same DLLs; native adapter" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c39" target="c41">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c45" value="Same DLLs; native adapter" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=0;fontSize=12;labelBackgroundColor=#ffffff;endArrow=classic;" edge="1" parent="1" source="c39" target="c42">
<mxGeometry as="geometry" relative="1" />
</mxCell>
<mxCell id="c46" value="Verified code paths/config-format tests ≠ proven native execution on every target. Manual GitHub Actions workflow exists; run outcomes unknown. Linux --root performs offline staging only. Native adapters need administrator/network access; distribution does not provision host SSH permissions. Evidence: deploy/build-release.*, installer/*, ConfigurationWriter, LaunchdWriter." style="rounded=0;whiteSpace=wrap;html=0;fillColor=#fff2cc;strokeColor=#666666;fontSize=14;align=left;verticalAlign=top;spacing=12;" vertex="1" parent="1">
<mxGeometry as="geometry" x="30" y="970" width="1630" height="100" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
File diff suppressed because it is too large. Load diff
+40
View File
@@ -0,0 +1,40 @@
# Documented design versus implementation
Scope: repository snapshot 2026-10-12, commit `5d9371388c15066eeb2bc124ed227659c644dab5`. **Difference** is not automatically a defect. Current `.drawio` authority and explicit corrections supersede same-stem historical JPEGs under [Architecture README](../Docs/Architecture/README.md). No authoritative document was edited and no conflicting design was silently selected for implementation.
## Verified differences and elaborations
| ID | Original/current documentation | As-built evidence and interpretation |
| --- | --- | --- |
| D-01 | Original [domain model](../Docs/Architecture/01_domain_model.jpg) and [duplicate domain image](../Docs/Architecture/personal_health_measurement_all_diagrams-Domain%20Model.jpg) show Patient, Observation and Health Summary only | Account/profile lifecycle, professional assignments, measurement context, selections, trend assessments and overview concepts now exist. `HealthInsight` is a transient summary without stored summary ID. This is an expanded as-built model, not a claim that the original three concepts were replaced. [domains](../src/InsightsService/Domain/HealthInsight.cs), [assignments](../src/ApiGateway/Security/ProfessionalAssignments.cs) |
| D-02 | [Patient class](../Docs/Architecture/03_class_patient_profile_service.jpg) and [Patient ER](../Docs/Architecture/07_er_patient_profile_service.jpg) omit account association and account lookup | `Patient.AccountId`, nullable `account_id` and unique index plus by-account API now implement US-01/13. [migration](../src/PatientProfileService/Persistence/Migrations/20261005082209_AccountProfileAssociation.cs), [controller](../src/PatientProfileService/Controllers/PatientController.cs). Existing null associations are retained; no migration backfill assigns old rows to credentials. |
| D-03 | Original authentication design's opening/Section 10 says token format, lifetime, persistence owner and gateway protection are open; final paragraph permits minimum established mechanisms | Concrete opaque framework Bearer tokens, default 30-minute lifetime, Patient-owned association and shared-key HTTPS boundaries are implemented and described in [AUTHENTICATION.md](../src/AUTHENTICATION.md). Opening/open-decision text was not updated, so the document has residual status ambiguity. The final permission is consistent with selecting simple mechanisms; this task does not infer an unrecorded formal approval history. |
| D-04 | Historical Insights ER showed persisted HealthSummary; old Overview ER showed an overview persistence concept | Current [Insights correction](../Docs/Architecture/us10-insights-correction.md), [Insights drawio](../Docs/Architecture/09_er_insights_service.drawio) and [Overview drawio](../Docs/Architecture/06_class_health_overview_service.drawio) already supersede those concepts. Code has no DB/repository in either service. Historical inconsistency is resolved by current baseline; do not report it as a new implementation violation. |
| D-05 | Updated logical diagrams use schematic methods/names (`activity`, preparation details, HealthOverview/DTO) and sometimes combine domain/DTO boxes | Code uses `ActivityCondition`, `RestDurationMinutes`, flattened owned columns; separate local consumer DTOs; Overview client abstractions are abstract classes whereas Insights' client is an interface. Observation DTO does not expose creation/update timestamps although its domain entity contains them. These are implementation details permitted by Architecture README, not unexplained new services/tables. [context mapping](../src/ObservationService/Persistence/ObservationDbContext.cs), [DTO](../src/ObservationService/Contracts/ObservationDto.cs) |
| D-06 | Original class diagrams omit EF contexts, framework authentication, patch-presence fields and detailed trend result types | As-built class pages show those actual dependencies/attributes and responsibilities. No shared runtime contracts or direct class links across service boundaries were found. [patch](../src/ObservationService/Contracts/PatchObservationRequest.cs), [trend records](../src/InsightsService/Domain/TrendAssessment.cs), [Gateway startup](../src/ApiGateway/Program.cs) |
| D-07 | US-16 and its addendum describe Linux/systemd; later implementation guide also describes Windows/macOS | Native Windows Services/launchd adapters and WindowsServices package are present. This expands implemented platform support beyond the Linux wording while retaining service boundaries. Whether formal requirements should be updated is outside this assignment. Native success on every advertised platform is unknown. [adapters](../deploy/installer/install.ps1), [macOS](../deploy/installer/install-macos.sh) |
| D-08 | Committed systemd templates use `User=healthapp` and `/etc/healthapp/NAME.env`; installer guide describes dedicated users/nested files | Installer rewrites templates into `healthapp-NAME` user/group and `/etc/healthapp/NAME/service.env`. Using templates manually without that transform differs from normal installed behavior. [template](../deploy/systemd/healthapp-observation.service), [installer](../deploy/installer/install.sh) |
| D-09 | Original topology depicts client Web/Mobile | No product frontend is present. This repository implements the API backend; JMeter/curl/test clients are actual consumers. It is unknown whether a client lives in another repository. Backend stories do not establish a frontend deliverable. |
| D-10 | Installation prose broadly says native verification checks independent processes; US-16 AC-I includes stop/restart demonstration | Linux and Windows adapters check running state/distinct PIDs. macOS adapter calls `launchctl print` and HTTPS probes but does not explicitly compare PIDs. Live verification does not cycle stop/restart; test suite does so with direct processes. This is a runtime-verification limitation, not proof that services cannot restart independently. [Linux verifier](../deploy/installer/verify.sh), [macOS](../deploy/installer/install-macos.sh), [tests](../tests/Deployment.AcceptanceTests/InstallationTests.cs) |
| D-11 | Early ownership section of [AUTHENTICATION.md](../src/AUTHENTICATION.md) says trend/overview endpoints remain unimplemented; later sections say they are implemented | Both endpoint sets, client permissions and integration tests exist. The earlier sentence is stale and contradicts later sections of that same implementation document. Earlier service-protection text names only Observation/Insights callbacks, while the later US-12 section/code also provides Overview callbacks. [routes](../src/ApiGateway/Controllers/HealthOverviewController.cs), [trend controller](../src/InsightsService/Controllers/InsightsController.cs) |
## Current behavior with requirements or evidence limits
| ID | Verified behavior | Requirement/evidence implication |
| --- | --- | --- |
| U-01 | Narrative conflict detection is a finite substring list, including documented English/Danish phrases. [calculator](../src/InsightsService/Domain/InsightCalculator.Trends.cs) | US-04/11 broadly require relevant conflicts to be apparent; cited example `during exercise` is covered. Arbitrary wording/negation is not semantically understood. Exhaustive natural-language fulfillment is unknown and not proven by existing fixtures. |
| U-02 | Reference thresholds and development labels have compiled sources/limits; favourable/concerning logic is coded locally. [TRENDS](../src/TRENDS.md) | Numerical behavior is testable. Whether every inference is clinically supported under all input combinations needs an independent domain assessment; this documentation does not assert clinical validation. |
| U-03 | Ownership middleware compares most path segments case-sensitively; routing accepts conventional case variants | Canonical routes work. A case-varied route can return 404/403 instead of the controller behavior. Requirements do not prescribe casing; observable interface inconsistency, not a confirmed missing story. [middleware](../src/ApiGateway/Security/PatientAccessMiddleware.cs) |
| U-04 | Missing expected ownership JSON fields/invalid JSON lack dedicated upstream 502 mapping; general exception handling applies | Such malformed responses may yield 500, unlike explicit Insights/Overview invalid-JSON 502 handling. Upstream failure-injection tests do not prove every malformed shape/status path. |
| U-05 | Assignments are startup configuration, no installer assignment population; generated professional has none | US-14 assigned reads exist and are tested with predefined test assignments. A normal fresh installation cannot demonstrate a populated professional review workflow until assignments are configured. This does not require an out-of-scope assignment-management API. |
| U-06 | Deployment tests use different loopback addresses, controlled SSH/SCP and package doubles | These establish interfaces/scoping/command intent, not actual multi-machine routing, network/firewall policy or native package/service-manager success. Manual CI workflow exists; execution results are unknown in this task. |
| U-07 | Generated DB connections use `Pooling=false;SslMode=Prefer`; normal Linux startup bootstrap checks local PostgreSQL even if an external admin file is supplied | This is the actual configuration. Mandatory verified DB TLS is not implemented. External-DB Linux installation can still provision/check an unnecessary local server; the guide's general external-DB description does not mention this coupling. [bootstrap call](../deploy/installer/install.sh), [connection builder](../deploy/HealthApp.Provisioning/Deployment.cs) |
| U-08 | Installer detects existing app/config and refuses; failure retains partial output | No safe resumable upgrade/uninstall/transactional rollback is implemented. First-install retries may require administrative handling of retained material. This is documented prototype scope, not a silently repaired behavior. |
| U-09 | Complete flag in local installers/verifier is selected by literal `all` | Explicitly listing all five service names installs them but does not trigger the complete synthetic workflow in those wrappers. Distribution uses selected count for completeness. This is an observable verification asymmetry under US-16, without changing the application topology. |
| U-10 | Overview does sequential reads; no concurrency token or snapshot; history unbounded | Concurrent-write snapshot, conditional-edit protection, pagination and load resilience are absent. They are not explicit baseline story requirements; do not reclassify them as missing accepted features. |
| U-11 | Filesystem key ring has no explicitly configured encryption-at-rest; no immediate bearer revocation or account-record recheck | The prototype has persistent protected tickets and file permissions, not a full identity lifecycle. Registration/recovery/MFA/refresh/administration are explicitly outside scope. Production security compliance is not established. |
| U-12 | Supplied PFX is checked for a private key, then runtime verifies endpoints; generated leaf/CA expiry not automatically renewed | Early preflight, rotation, renewal and universal third-party chain support are not proven. Replacing certificates is an administrative first-install facility, not an implemented renewal service. |
## Unresolved unknowns
Live installed software/configuration may differ from this checkout; no server, device or administrative session was accessed. Native Windows/macOS CI runs, actual deployment firewall rules, backup/restore behavior, multi-instance Gateway behavior, certificate renewal procedures, production security/clinical approval and external client implementations cannot be established from this repository. [Traceability](requirements-traceability.md) separates these from observed functional support.
+486
View File
@@ -0,0 +1,486 @@
# Evidence inventory
Snapshot: 2026-10-12; source commit `5d9371388c15066eeb2bc124ed227659c644dab5`. This inventory lists tracked specification, application, deployment and acceptance-test files used to bound the review. SHA-256 prefixes identify file content, not a test result. Source links remain repository-relative.
## Inspection boundaries
Production source, contracts, persistence mappings/migrations, startup/security configuration, installer/provisioner, relevant acceptance fixtures/assertions and specification text were inspected. Current Draw.io cell content and original context/domain/Patient class/Patient ER images were examined. Same-stem historical JPEGs are superseded by current editable diagrams; their authority is governed by Architecture README. Test code is evidence of intended verification, not a fresh execution claim.
Experiment scripts/plans and their README were inspected for ancillary architecture. Private credentials and ignored raw load-test results were deliberately excluded; they are not needed to document production responsibilities. No live server or native installer was executed. No dependency versions were looked up externally; project declarations define this snapshot.
## File evidence
| File | Kind | SHA-256 prefix |
| --- | --- | --- |
| [.github/workflows/prototype-native-install.yml](../.github/workflows/prototype-native-install.yml) | Deployment / configuration / native validation | `de4240167653b10b` |
| [.gitignore](../.gitignore) | Repository / build / instructions | `5ff2245aafc37c27` |
| [AGENTS.md](../AGENTS.md) | Repository / build / instructions | `02330ed17811077c` |
| [Docs/Architecture/01_domain_model.jpg](../Docs/Architecture/01_domain_model.jpg) | Specification / context | `43354c405b637578` |
| [Docs/Architecture/02_microservice_architecture.jpg](../Docs/Architecture/02_microservice_architecture.jpg) | Specification / context | `67862bb8e9c1029f` |
| [Docs/Architecture/03_class_patient_profile_service.jpg](../Docs/Architecture/03_class_patient_profile_service.jpg) | Specification / context | `4abc364239a97b0d` |
| [Docs/Architecture/04_class_observation_service.drawio](../Docs/Architecture/04_class_observation_service.drawio) | Specification / context | `0b48a2760252607d` |
| [Docs/Architecture/04_class_observation_service.jpg](../Docs/Architecture/04_class_observation_service.jpg) | Specification / context | `749647606ee3a5a7` |
| [Docs/Architecture/05_class_insights_service.drawio](../Docs/Architecture/05_class_insights_service.drawio) | Specification / context | `8c5837f38eb745e1` |
| [Docs/Architecture/05_class_insights_service.jpg](../Docs/Architecture/05_class_insights_service.jpg) | Specification / context | `18d5fbeec5db5947` |
| [Docs/Architecture/06_class_health_overview_service.drawio](../Docs/Architecture/06_class_health_overview_service.drawio) | Specification / context | `8c401510f8c0a2e8` |
| [Docs/Architecture/06_class_health_overview_service.jpg](../Docs/Architecture/06_class_health_overview_service.jpg) | Specification / context | `1c2751c7fdbf123b` |
| [Docs/Architecture/07_er_patient_profile_service.jpg](../Docs/Architecture/07_er_patient_profile_service.jpg) | Specification / context | `8074f734e3e4e28e` |
| [Docs/Architecture/08_er_observation_service.drawio](../Docs/Architecture/08_er_observation_service.drawio) | Specification / context | `88cc97c26ff40650` |
| [Docs/Architecture/08_er_observation_service.jpg](../Docs/Architecture/08_er_observation_service.jpg) | Specification / context | `e6b02064ba2019ac` |
| [Docs/Architecture/09_er_insights_service-overruled no persistence here to give an idea of what data is needed to be able to use from other services or calculate.jpg](../Docs/Architecture/09_er_insights_service-overruled%20no%20persistence%20here%20to%20give%20an%20idea%20of%20what%20data%20is%20needed%20to%20be%20able%20to%20use%20from%20other%20services%20or%20calculate.jpg) | Specification / context | `6f01585a506f84ef` |
| [Docs/Architecture/09_er_insights_service.drawio](../Docs/Architecture/09_er_insights_service.drawio) | Specification / context | `534ba79368ac79eb` |
| [Docs/Architecture/10_er_health_overview_service-overruled no persistence here to give an idea of what data is needed to be able to use from other services or calculate.jpg](../Docs/Architecture/10_er_health_overview_service-overruled%20no%20persistence%20here%20to%20give%20an%20idea%20of%20what%20data%20is%20needed%20to%20be%20able%20to%20use%20from%20other%20services%20or%20calculate.jpg) | Specification / context | `b27db286ce26cbc1` |
| [Docs/Architecture/README.md](../Docs/Architecture/README.md) | Specification / context | `3754fa7ed95a6ef5` |
| [Docs/Architecture/personal_health_measurement_all_diagrams-Domain Model.jpg](../Docs/Architecture/personal_health_measurement_all_diagrams-Domain%20Model.jpg) | Specification / context | `285c4c52440a3000` |
| [Docs/Architecture/us10-insights-correction.md](../Docs/Architecture/us10-insights-correction.md) | Specification / context | `259d59ee31518068` |
| [Docs/Design/authentication-and-access-control-design.md](../Docs/Design/authentication-and-access-control-design.md) | Specification / context | `b044d0f78d542be0` |
| [Docs/Requirements/00-common-requirements.md](../Docs/Requirements/00-common-requirements.md) | Specification / context | `1f056a53699e0875` |
| [Docs/Requirements/US16 easy installation and deployment installer.txt](../Docs/Requirements/US16%20easy%20installation%20and%20deployment%20installer.txt) | Specification / context | `07416edc16ce034a` |
| [Docs/Requirements/us01-create-patient-profile.md](../Docs/Requirements/us01-create-patient-profile.md) | Specification / context | `52872490bd37b15e` |
| [Docs/Requirements/us02-view-patient-profile.md](../Docs/Requirements/us02-view-patient-profile.md) | Specification / context | `8af9e4e55ddb9bb4` |
| [Docs/Requirements/us03-update-patient-profile.md](../Docs/Requirements/us03-update-patient-profile.md) | Specification / context | `0825a974cea87924` |
| [Docs/Requirements/us04-record-observation.md](../Docs/Requirements/us04-record-observation.md) | Specification / context | `894e99dac4e05604` |
| [Docs/Requirements/us05-view-observation.md](../Docs/Requirements/us05-view-observation.md) | Specification / context | `3632aebd02b34996` |
| [Docs/Requirements/us06-latest-observation.md](../Docs/Requirements/us06-latest-observation.md) | Specification / context | `dfec3b4fcb1c8410` |
| [Docs/Requirements/us07-observation-history.md](../Docs/Requirements/us07-observation-history.md) | Specification / context | `dec0f06cee54e713` |
| [Docs/Requirements/us08-update-observation.md](../Docs/Requirements/us08-update-observation.md) | Specification / context | `1e65e62813db4e50` |
| [Docs/Requirements/us09-delete-observation.md](../Docs/Requirements/us09-delete-observation.md) | Specification / context | `28e4dc1cbc92f60b` |
| [Docs/Requirements/us10-calculated-insight.md](../Docs/Requirements/us10-calculated-insight.md) | Specification / context | `ed2f03e69d460ef5` |
| [Docs/Requirements/us11-health-trend.md](../Docs/Requirements/us11-health-trend.md) | Specification / context | `7121bb4890e70621` |
| [Docs/Requirements/us12-health-overview.md](../Docs/Requirements/us12-health-overview.md) | Specification / context | `58db5d95b70b09f7` |
| [Docs/Requirements/us13-patient-authentication.md](../Docs/Requirements/us13-patient-authentication.md) | Specification / context | `d2584876fbb17ecd` |
| [Docs/Requirements/us14-professional-access.md](../Docs/Requirements/us14-professional-access.md) | Specification / context | `bb451f00e4bad5d7` |
| [Docs/Requirements/us15-measurement-guidance.md](../Docs/Requirements/us15-measurement-guidance.md) | Specification / context | `1aa52764ac93fcdb` |
| [Docs/Requirements/us16-addendum](../Docs/Requirements/us16-addendum) | Specification / context | `61f88829b2501050` |
| [Docs/requirements-reconciliation-changelog.md](../Docs/requirements-reconciliation-changelog.md) | Specification / context | `318c4e2c9f3c1137` |
| [HealthApp.slnx](../HealthApp.slnx) | Repository / build / instructions | `3b070ed1a967e900` |
| [README.MD](../README.MD) | Repository / build / instructions | `fd783476366adf4c` |
| [deploy/HealthApp.Provisioning/ConfigurationWriter.cs](../deploy/HealthApp.Provisioning/ConfigurationWriter.cs) | Deployment / configuration / native validation | `702f4a646eac3dd6` |
| [deploy/HealthApp.Provisioning/DatabaseProvisioning.cs](../deploy/HealthApp.Provisioning/DatabaseProvisioning.cs) | Deployment / configuration / native validation | `e1c8e252642b12f8` |
| [deploy/HealthApp.Provisioning/Deployment.cs](../deploy/HealthApp.Provisioning/Deployment.cs) | Deployment / configuration / native validation | `8f3e6fc3761fe731` |
| [deploy/HealthApp.Provisioning/Distribution.cs](../deploy/HealthApp.Provisioning/Distribution.cs) | Deployment / configuration / native validation | `d9b7c467172e3156` |
| [deploy/HealthApp.Provisioning/HealthApp.Provisioning.csproj](../deploy/HealthApp.Provisioning/HealthApp.Provisioning.csproj) | Deployment / configuration / native validation | `5f18785a17f78d01` |
| [deploy/HealthApp.Provisioning/InstallationVerification.cs](../deploy/HealthApp.Provisioning/InstallationVerification.cs) | Deployment / configuration / native validation | `094877cb5e6ff6e8` |
| [deploy/HealthApp.Provisioning/LaunchdWriter.cs](../deploy/HealthApp.Provisioning/LaunchdWriter.cs) | Deployment / configuration / native validation | `b1d9b620ade4b525` |
| [deploy/HealthApp.Provisioning/Program.cs](../deploy/HealthApp.Provisioning/Program.cs) | Deployment / configuration / native validation | `e42034fedec2c3c1` |
| [deploy/INSTALLATION.md](../deploy/INSTALLATION.md) | Deployment / configuration / native validation | `94e8e3b7a7bcdf6f` |
| [deploy/api-gateway.env.example](../deploy/api-gateway.env.example) | Deployment / configuration / native validation | `e8137593d4710953` |
| [deploy/build-release.ps1](../deploy/build-release.ps1) | Deployment / configuration / native validation | `d85375f5a7392fe3` |
| [deploy/build-release.sh](../deploy/build-release.sh) | Deployment / configuration / native validation | `7de7fb0ffe963671` |
| [deploy/health-overview.env.example](../deploy/health-overview.env.example) | Deployment / configuration / native validation | `b7883d73a34da16a` |
| [deploy/insights.env.example](../deploy/insights.env.example) | Deployment / configuration / native validation | `8fff870eede50c4f` |
| [deploy/installer/bootstrap.sh](../deploy/installer/bootstrap.sh) | Deployment / configuration / native validation | `db52696d484fe728` |
| [deploy/installer/distribute.sh](../deploy/installer/distribute.sh) | Deployment / configuration / native validation | `bda6aa53146a3d4d` |
| [deploy/installer/install-macos.sh](../deploy/installer/install-macos.sh) | Deployment / configuration / native validation | `bd78d0ec3be482ce` |
| [deploy/installer/install.ps1](../deploy/installer/install.ps1) | Deployment / configuration / native validation | `4c1bbaac58c99539` |
| [deploy/installer/install.sh](../deploy/installer/install.sh) | Deployment / configuration / native validation | `ccc35b5764e96a7d` |
| [deploy/installer/services.sh](../deploy/installer/services.sh) | Deployment / configuration / native validation | `6a21a5c213fbe7b2` |
| [deploy/installer/verify.sh](../deploy/installer/verify.sh) | Deployment / configuration / native validation | `62d50b2bcd40b04a` |
| [deploy/observation.env.example](../deploy/observation.env.example) | Deployment / configuration / native validation | `c18f0f6abb1f32e9` |
| [deploy/patient-profile.env.example](../deploy/patient-profile.env.example) | Deployment / configuration / native validation | `f01a3ba42d22dbcf` |
| [deploy/systemd/healthapp-api-gateway.service](../deploy/systemd/healthapp-api-gateway.service) | Deployment / configuration / native validation | `15a9b7bc43a72940` |
| [deploy/systemd/healthapp-health-overview.service](../deploy/systemd/healthapp-health-overview.service) | Deployment / configuration / native validation | `d8841c4b04c74f3b` |
| [deploy/systemd/healthapp-insights.service](../deploy/systemd/healthapp-insights.service) | Deployment / configuration / native validation | `8ec5dbfa6e1a9fbd` |
| [deploy/systemd/healthapp-observation.service](../deploy/systemd/healthapp-observation.service) | Deployment / configuration / native validation | `a61518322838ca14` |
| [deploy/systemd/healthapp-patient-profile.service](../deploy/systemd/healthapp-patient-profile.service) | Deployment / configuration / native validation | `262b269a997923aa` |
| [src/AUTHENTICATION.md](../src/AUTHENTICATION.md) | Application / implementation documentation | `38e4a3580e1cc8aa` |
| [src/ApiGateway/ApiGateway.csproj](../src/ApiGateway/ApiGateway.csproj) | Application / implementation documentation | `6e81c32841f12d91` |
| [src/ApiGateway/Controllers/AuthenticationController.cs](../src/ApiGateway/Controllers/AuthenticationController.cs) | Application / implementation documentation | `f76ec4f393c55ee6` |
| [src/ApiGateway/Controllers/HealthOverviewController.cs](../src/ApiGateway/Controllers/HealthOverviewController.cs) | Application / implementation documentation | `0a05ccd0dd9b763e` |
| [src/ApiGateway/Controllers/InsightsController.cs](../src/ApiGateway/Controllers/InsightsController.cs) | Application / implementation documentation | `810c906f771ce01e` |
| [src/ApiGateway/Controllers/MeasurementGuidanceController.cs](../src/ApiGateway/Controllers/MeasurementGuidanceController.cs) | Application / implementation documentation | `1be2c32f56a5cda6` |
| [src/ApiGateway/Controllers/ObservationController.cs](../src/ApiGateway/Controllers/ObservationController.cs) | Application / implementation documentation | `2a33302f8d8158e2` |
| [src/ApiGateway/Controllers/PatientController.cs](../src/ApiGateway/Controllers/PatientController.cs) | Application / implementation documentation | `2b416bb49e98c400` |
| [src/ApiGateway/Controllers/ProfessionalController.cs](../src/ApiGateway/Controllers/ProfessionalController.cs) | Application / implementation documentation | `87f7c5830215673a` |
| [src/ApiGateway/Program.cs](../src/ApiGateway/Program.cs) | Application / implementation documentation | `9e6ba8e51c837719` |
| [src/ApiGateway/Security/InternalServiceAuthenticationHandler.cs](../src/ApiGateway/Security/InternalServiceAuthenticationHandler.cs) | Application / implementation documentation | `985ee505d8e38d15` |
| [src/ApiGateway/Security/PatientAccessMiddleware.cs](../src/ApiGateway/Security/PatientAccessMiddleware.cs) | Application / implementation documentation | `497c7f69c179fa04` |
| [src/ApiGateway/Security/ProfessionalAssignments.cs](../src/ApiGateway/Security/ProfessionalAssignments.cs) | Application / implementation documentation | `7883c801dcdec8df` |
| [src/ApiGateway/Security/PrototypeAccounts.cs](../src/ApiGateway/Security/PrototypeAccounts.cs) | Application / implementation documentation | `a4cbcaa6db514439` |
| [src/ApiGateway/appsettings.json](../src/ApiGateway/appsettings.json) | Application / implementation documentation | `817db0bf2ecca783` |
| [src/HealthOverviewService/Application/HealthOverviewApplicationService.cs](../src/HealthOverviewService/Application/HealthOverviewApplicationService.cs) | Application / implementation documentation | `234190b299f0487c` |
| [src/HealthOverviewService/Clients/InsightsServiceClient.cs](../src/HealthOverviewService/Clients/InsightsServiceClient.cs) | Application / implementation documentation | `1087c1ac57605ae7` |
| [src/HealthOverviewService/Clients/ObservationServiceClient.cs](../src/HealthOverviewService/Clients/ObservationServiceClient.cs) | Application / implementation documentation | `f6cef0c6f78e04ea` |
| [src/HealthOverviewService/Clients/PatientProfileServiceClient.cs](../src/HealthOverviewService/Clients/PatientProfileServiceClient.cs) | Application / implementation documentation | `7bba92bc1b382c3d` |
| [src/HealthOverviewService/Contracts/HealthOverviewDto.cs](../src/HealthOverviewService/Contracts/HealthOverviewDto.cs) | Application / implementation documentation | `d95e27f230cfeeb1` |
| [src/HealthOverviewService/Controllers/HealthOverviewController.cs](../src/HealthOverviewService/Controllers/HealthOverviewController.cs) | Application / implementation documentation | `c3e9bc2e646527a4` |
| [src/HealthOverviewService/HealthOverviewService.csproj](../src/HealthOverviewService/HealthOverviewService.csproj) | Application / implementation documentation | `6e81c32841f12d91` |
| [src/HealthOverviewService/Program.cs](../src/HealthOverviewService/Program.cs) | Application / implementation documentation | `63a799d09cdeaf1e` |
| [src/HealthOverviewService/appsettings.json](../src/HealthOverviewService/appsettings.json) | Application / implementation documentation | `817db0bf2ecca783` |
| [src/InsightsService/Application/InsightsApplicationService.cs](../src/InsightsService/Application/InsightsApplicationService.cs) | Application / implementation documentation | `7319a7f8057b1906` |
| [src/InsightsService/Clients/HttpObservationServiceClient.cs](../src/InsightsService/Clients/HttpObservationServiceClient.cs) | Application / implementation documentation | `91677b578eddbd12` |
| [src/InsightsService/Clients/ObservationServiceClient.cs](../src/InsightsService/Clients/ObservationServiceClient.cs) | Application / implementation documentation | `802b8cc66f58441d` |
| [src/InsightsService/Contracts/HealthInsightDto.cs](../src/InsightsService/Contracts/HealthInsightDto.cs) | Application / implementation documentation | `001d24e7d2b0dedf` |
| [src/InsightsService/Contracts/ObservationDto.cs](../src/InsightsService/Contracts/ObservationDto.cs) | Application / implementation documentation | `fd37572e721ba288` |
| [src/InsightsService/Controllers/InsightsController.cs](../src/InsightsService/Controllers/InsightsController.cs) | Application / implementation documentation | `0304dc102bb192ab` |
| [src/InsightsService/Domain/ContextSelection.cs](../src/InsightsService/Domain/ContextSelection.cs) | Application / implementation documentation | `82b9acd07e6b4de0` |
| [src/InsightsService/Domain/HealthInsight.cs](../src/InsightsService/Domain/HealthInsight.cs) | Application / implementation documentation | `fc634cb3b99905c3` |
| [src/InsightsService/Domain/InsightCalculator.Trends.cs](../src/InsightsService/Domain/InsightCalculator.Trends.cs) | Application / implementation documentation | `ef196331aad4cf12` |
| [src/InsightsService/Domain/InsightCalculator.cs](../src/InsightsService/Domain/InsightCalculator.cs) | Application / implementation documentation | `2575a8f7641f6f23` |
| [src/InsightsService/Domain/TrendAssessment.cs](../src/InsightsService/Domain/TrendAssessment.cs) | Application / implementation documentation | `5ba75fba606fa7ca` |
| [src/InsightsService/InsightsService.csproj](../src/InsightsService/InsightsService.csproj) | Application / implementation documentation | `6e81c32841f12d91` |
| [src/InsightsService/Program.cs](../src/InsightsService/Program.cs) | Application / implementation documentation | `3aceaf19cc216790` |
| [src/InsightsService/appsettings.json](../src/InsightsService/appsettings.json) | Application / implementation documentation | `817db0bf2ecca783` |
| [src/OVERVIEW.md](../src/OVERVIEW.md) | Application / implementation documentation | `aa7f4ca1ffca79de` |
| [src/ObservationService/Application/ObservationApplicationService.cs](../src/ObservationService/Application/ObservationApplicationService.cs) | Application / implementation documentation | `4ceaa7d67b391b0a` |
| [src/ObservationService/Application/ObservationRepository.cs](../src/ObservationService/Application/ObservationRepository.cs) | Application / implementation documentation | `a1c21ef7e0700b4f` |
| [src/ObservationService/Contracts/MeasurementContextPatch.cs](../src/ObservationService/Contracts/MeasurementContextPatch.cs) | Application / implementation documentation | `fae0cad81e9bec85` |
| [src/ObservationService/Contracts/ObservationDto.cs](../src/ObservationService/Contracts/ObservationDto.cs) | Application / implementation documentation | `989312e16eaa4306` |
| [src/ObservationService/Contracts/PatchObservationRequest.cs](../src/ObservationService/Contracts/PatchObservationRequest.cs) | Application / implementation documentation | `3be4db307b24e5c8` |
| [src/ObservationService/Contracts/RecordObservationRequest.cs](../src/ObservationService/Contracts/RecordObservationRequest.cs) | Application / implementation documentation | `7430845925f6ae9c` |
| [src/ObservationService/Contracts/UpdateObservationRequest.cs](../src/ObservationService/Contracts/UpdateObservationRequest.cs) | Application / implementation documentation | `f1d987f3d0d996ce` |
| [src/ObservationService/Controllers/ObservationController.cs](../src/ObservationService/Controllers/ObservationController.cs) | Application / implementation documentation | `68fe89a643bf1ff0` |
| [src/ObservationService/Domain/BloodPressureObservation.cs](../src/ObservationService/Domain/BloodPressureObservation.cs) | Application / implementation documentation | `a968856d9d9a7e8d` |
| [src/ObservationService/Domain/ContextSelection.cs](../src/ObservationService/Domain/ContextSelection.cs) | Application / implementation documentation | `1d7eeba19330a191` |
| [src/ObservationService/Domain/MeasurementContext.cs](../src/ObservationService/Domain/MeasurementContext.cs) | Application / implementation documentation | `500c7e2c02213fc1` |
| [src/ObservationService/ObservationService.csproj](../src/ObservationService/ObservationService.csproj) | Application / implementation documentation | `2a14c125f601d5fa` |
| [src/ObservationService/Persistence/Migrations/20261001095222_InitialObservationSchema.Designer.cs](../src/ObservationService/Persistence/Migrations/20261001095222_InitialObservationSchema.Designer.cs) | Application / implementation documentation | `9f24f074d1c49343` |
| [src/ObservationService/Persistence/Migrations/20261001095222_InitialObservationSchema.cs](../src/ObservationService/Persistence/Migrations/20261001095222_InitialObservationSchema.cs) | Application / implementation documentation | `1a44e09a08a6045f` |
| [src/ObservationService/Persistence/Migrations/20261005094632_RecordedMeasurementContext.Designer.cs](../src/ObservationService/Persistence/Migrations/20261005094632_RecordedMeasurementContext.Designer.cs) | Application / implementation documentation | `1cb88c86e7a13a5c` |
| [src/ObservationService/Persistence/Migrations/20261005094632_RecordedMeasurementContext.cs](../src/ObservationService/Persistence/Migrations/20261005094632_RecordedMeasurementContext.cs) | Application / implementation documentation | `da719484aab8eff2` |
| [src/ObservationService/Persistence/Migrations/ObservationDbContextModelSnapshot.cs](../src/ObservationService/Persistence/Migrations/ObservationDbContextModelSnapshot.cs) | Application / implementation documentation | `fb9c5c7d874f4b23` |
| [src/ObservationService/Persistence/ObservationDbContext.cs](../src/ObservationService/Persistence/ObservationDbContext.cs) | Application / implementation documentation | `6d9f0c6106db8b2f` |
| [src/ObservationService/Persistence/SqlObservationRepository.cs](../src/ObservationService/Persistence/SqlObservationRepository.cs) | Application / implementation documentation | `f77e38151d481cc3` |
| [src/ObservationService/Program.cs](../src/ObservationService/Program.cs) | Application / implementation documentation | `7ad86451a63a7b49` |
| [src/ObservationService/appsettings.json](../src/ObservationService/appsettings.json) | Application / implementation documentation | `8cd0df652a9a4966` |
| [src/PatientProfileService/Application/PatientApplicationService.cs](../src/PatientProfileService/Application/PatientApplicationService.cs) | Application / implementation documentation | `8f673a37101bd11a` |
| [src/PatientProfileService/Application/PatientRepository.cs](../src/PatientProfileService/Application/PatientRepository.cs) | Application / implementation documentation | `4d9d0ee890f2ce9e` |
| [src/PatientProfileService/Application/ProfileAlreadyExistsException.cs](../src/PatientProfileService/Application/ProfileAlreadyExistsException.cs) | Application / implementation documentation | `96ee280d51c6996f` |
| [src/PatientProfileService/Contracts/CreatePatientRequest.cs](../src/PatientProfileService/Contracts/CreatePatientRequest.cs) | Application / implementation documentation | `dd75326c9d723b9a` |
| [src/PatientProfileService/Contracts/PatientDto.cs](../src/PatientProfileService/Contracts/PatientDto.cs) | Application / implementation documentation | `2886340d45231135` |
| [src/PatientProfileService/Contracts/UpdatePatientRequest.cs](../src/PatientProfileService/Contracts/UpdatePatientRequest.cs) | Application / implementation documentation | `27528295eccdb708` |
| [src/PatientProfileService/Controllers/PatientController.cs](../src/PatientProfileService/Controllers/PatientController.cs) | Application / implementation documentation | `ac2c59bf16c70ea7` |
| [src/PatientProfileService/Domain/Patient.cs](../src/PatientProfileService/Domain/Patient.cs) | Application / implementation documentation | `7eaeee54560d9754` |
| [src/PatientProfileService/PatientProfileService.csproj](../src/PatientProfileService/PatientProfileService.csproj) | Application / implementation documentation | `2a14c125f601d5fa` |
| [src/PatientProfileService/Persistence/Migrations/20260930200031_InitialPatientSchema.Designer.cs](../src/PatientProfileService/Persistence/Migrations/20260930200031_InitialPatientSchema.Designer.cs) | Application / implementation documentation | `721fdc07915da2fa` |
| [src/PatientProfileService/Persistence/Migrations/20260930200031_InitialPatientSchema.cs](../src/PatientProfileService/Persistence/Migrations/20260930200031_InitialPatientSchema.cs) | Application / implementation documentation | `715e32ae82b3133a` |
| [src/PatientProfileService/Persistence/Migrations/20261005082209_AccountProfileAssociation.Designer.cs](../src/PatientProfileService/Persistence/Migrations/20261005082209_AccountProfileAssociation.Designer.cs) | Application / implementation documentation | `7d58aae8acc9e4e1` |
| [src/PatientProfileService/Persistence/Migrations/20261005082209_AccountProfileAssociation.cs](../src/PatientProfileService/Persistence/Migrations/20261005082209_AccountProfileAssociation.cs) | Application / implementation documentation | `d61827e783580644` |
| [src/PatientProfileService/Persistence/Migrations/PatientDbContextModelSnapshot.cs](../src/PatientProfileService/Persistence/Migrations/PatientDbContextModelSnapshot.cs) | Application / implementation documentation | `4137f40f98d3de0d` |
| [src/PatientProfileService/Persistence/PatientDbContext.cs](../src/PatientProfileService/Persistence/PatientDbContext.cs) | Application / implementation documentation | `c3ae81375a6973bb` |
| [src/PatientProfileService/Persistence/SqlPatientRepository.cs](../src/PatientProfileService/Persistence/SqlPatientRepository.cs) | Application / implementation documentation | `637d9a788b95ced0` |
| [src/PatientProfileService/Program.cs](../src/PatientProfileService/Program.cs) | Application / implementation documentation | `087178aa8c556e97` |
| [src/PatientProfileService/appsettings.json](../src/PatientProfileService/appsettings.json) | Application / implementation documentation | `8cd0df652a9a4966` |
| [src/README.md](../src/README.md) | Application / implementation documentation | `8779152d2a416c51` |
| [src/TRENDS.md](../src/TRENDS.md) | Application / implementation documentation | `0506cb4fef1e36e8` |
| [tests/Deployment.AcceptanceTests/BootstrapTests.cs](../tests/Deployment.AcceptanceTests/BootstrapTests.cs) | Acceptance / fixture / test support | `fe3dc46f5c127bb3` |
| [tests/Deployment.AcceptanceTests/Deployment.AcceptanceTests.csproj](../tests/Deployment.AcceptanceTests/Deployment.AcceptanceTests.csproj) | Acceptance / fixture / test support | `aa3bee15a11bd295` |
| [tests/Deployment.AcceptanceTests/DeploymentFixture.cs](../tests/Deployment.AcceptanceTests/DeploymentFixture.cs) | Acceptance / fixture / test support | `7138d67f1ab0def4` |
| [tests/Deployment.AcceptanceTests/InstallationTests.cs](../tests/Deployment.AcceptanceTests/InstallationTests.cs) | Acceptance / fixture / test support | `b771a4ffdd667eb1` |
| [tests/Observation.AcceptanceTests/ContextFilteredHistoryTests.cs](../tests/Observation.AcceptanceTests/ContextFilteredHistoryTests.cs) | Acceptance / fixture / test support | `0995b4980a55c1cd` |
| [tests/Observation.AcceptanceTests/ContextSelectedInsightTests.cs](../tests/Observation.AcceptanceTests/ContextSelectedInsightTests.cs) | Acceptance / fixture / test support | `ce8e908a3ff10c01` |
| [tests/Observation.AcceptanceTests/DeleteContextualisedObservationTests.cs](../tests/Observation.AcceptanceTests/DeleteContextualisedObservationTests.cs) | Acceptance / fixture / test support | `2709163cd782fee2` |
| [tests/Observation.AcceptanceTests/DeleteObservationTests.cs](../tests/Observation.AcceptanceTests/DeleteObservationTests.cs) | Acceptance / fixture / test support | `916ebbcc0f5d3737` |
| [tests/Observation.AcceptanceTests/HealthInsightTests.cs](../tests/Observation.AcceptanceTests/HealthInsightTests.cs) | Acceptance / fixture / test support | `b6e1cfac712455f3` |
| [tests/Observation.AcceptanceTests/HealthOverviewTests.cs](../tests/Observation.AcceptanceTests/HealthOverviewTests.cs) | Acceptance / fixture / test support | `0e7874fde9943828` |
| [tests/Observation.AcceptanceTests/HealthTrendTests.cs](../tests/Observation.AcceptanceTests/HealthTrendTests.cs) | Acceptance / fixture / test support | `48266f7b71838fe9` |
| [tests/Observation.AcceptanceTests/LatestObservationTests.cs](../tests/Observation.AcceptanceTests/LatestObservationTests.cs) | Acceptance / fixture / test support | `d4cb653d7fc0999b` |
| [tests/Observation.AcceptanceTests/MeasurementContextMigrationTests.cs](../tests/Observation.AcceptanceTests/MeasurementContextMigrationTests.cs) | Acceptance / fixture / test support | `7cf4d025ac906cce` |
| [tests/Observation.AcceptanceTests/Observation.AcceptanceTests.csproj](../tests/Observation.AcceptanceTests/Observation.AcceptanceTests.csproj) | Acceptance / fixture / test support | `68f9427df8b24b70` |
| [tests/Observation.AcceptanceTests/ObservationApiFixture.cs](../tests/Observation.AcceptanceTests/ObservationApiFixture.cs) | Acceptance / fixture / test support | `a26195b246a37547` |
| [tests/Observation.AcceptanceTests/ObservationHistoryTests.cs](../tests/Observation.AcceptanceTests/ObservationHistoryTests.cs) | Acceptance / fixture / test support | `17299fb041080f2a` |
| [tests/Observation.AcceptanceTests/PatchObservationTests.cs](../tests/Observation.AcceptanceTests/PatchObservationTests.cs) | Acceptance / fixture / test support | `84cbd448712e3b32` |
| [tests/Observation.AcceptanceTests/PatientAuthenticationTests.cs](../tests/Observation.AcceptanceTests/PatientAuthenticationTests.cs) | Acceptance / fixture / test support | `466ae0a234bb5deb` |
| [tests/Observation.AcceptanceTests/ProfessionalAccessTests.cs](../tests/Observation.AcceptanceTests/ProfessionalAccessTests.cs) | Acceptance / fixture / test support | `1e3c87b0666c6a87` |
| [tests/Observation.AcceptanceTests/RecordMeasurementContextTests.cs](../tests/Observation.AcceptanceTests/RecordMeasurementContextTests.cs) | Acceptance / fixture / test support | `d582410cd6b277a7` |
| [tests/Observation.AcceptanceTests/RecordObservationTests.cs](../tests/Observation.AcceptanceTests/RecordObservationTests.cs) | Acceptance / fixture / test support | `2cb26f6bed1d3c8e` |
| [tests/Observation.AcceptanceTests/UpdateObservationTests.cs](../tests/Observation.AcceptanceTests/UpdateObservationTests.cs) | Acceptance / fixture / test support | `ad18354dc70dbe42` |
| [tests/Observation.AcceptanceTests/ViewObservationContextTests.cs](../tests/Observation.AcceptanceTests/ViewObservationContextTests.cs) | Acceptance / fixture / test support | `3b25fb13e3582bdf` |
| [tests/PatientProfile.AcceptanceTests/AuthenticationIntegrationTests.cs](../tests/PatientProfile.AcceptanceTests/AuthenticationIntegrationTests.cs) | Acceptance / fixture / test support | `60dbf89fd22f9e75` |
| [tests/PatientProfile.AcceptanceTests/CreatePatientTests.cs](../tests/PatientProfile.AcceptanceTests/CreatePatientTests.cs) | Acceptance / fixture / test support | `2b0bb2b9b727a178` |
| [tests/PatientProfile.AcceptanceTests/MeasurementGuidanceTests.cs](../tests/PatientProfile.AcceptanceTests/MeasurementGuidanceTests.cs) | Acceptance / fixture / test support | `b4de9f53f067bf7d` |
| [tests/PatientProfile.AcceptanceTests/PatientApiFixture.cs](../tests/PatientProfile.AcceptanceTests/PatientApiFixture.cs) | Acceptance / fixture / test support | `e54c213453683996` |
| [tests/PatientProfile.AcceptanceTests/PatientProfile.AcceptanceTests.csproj](../tests/PatientProfile.AcceptanceTests/PatientProfile.AcceptanceTests.csproj) | Acceptance / fixture / test support | `d224cf5a084478bf` |
| [tests/PatientProfile.AcceptanceTests/UpdatePatientTests.cs](../tests/PatientProfile.AcceptanceTests/UpdatePatientTests.cs) | Acceptance / fixture / test support | `2bfebdf5fceaf2fc` |
| [tests/Support/AuthenticatedTestClient.cs](../tests/Support/AuthenticatedTestClient.cs) | Acceptance / fixture / test support | `112bb94396a6272b` |
## Test behavior index
This index records declared test method names so that claims can be cross-checked against concrete assertions/setup. Theory case counts are not enumerated; method count is not the executed test count.
### BootstrapTests.cs
Source: [tests/Deployment.AcceptanceTests/BootstrapTests.cs](../tests/Deployment.AcceptanceTests/BootstrapTests.cs).
- `Package_provisioning_detects_runtime_and_postgresql_and_installs_only_needed_dependencies`
### InstallationTests.cs
Source: [tests/Deployment.AcceptanceTests/InstallationTests.cs](../tests/Deployment.AcceptanceTests/InstallationTests.cs).
- `A_selected_service_release_can_be_built_into_a_relative_output_directory`
- `Only_selected_payloads_configuration_and_independent_units_are_installed`
- `Configuration_and_certificates_are_generated_with_matching_credentials_and_private_permissions`
- `Dedicated_database_roles_cannot_access_each_others_data_or_administer_the_server`
- `New_deployments_get_new_secrets_and_do_not_overwrite_existing_material`
- `Native_configuration_adapters_use_the_same_service_values_and_independent_paths`
- `Invalid_service_selection_is_rejected_without_creating_an_installation`
- `Invalid_topology_fails_before_generating_configuration_or_credentials`
- `A_single_installed_service_starts_and_stops_without_other_local_service_processes`
- `Two_colocated_installed_services_run_with_independent_configuration_and_processes`
- `Installed_complete_system_runs_in_five_processes_and_preserves_network_and_persistence_boundaries`
### ContextFilteredHistoryTests.cs
Source: [tests/Observation.AcceptanceTests/ContextFilteredHistoryTests.cs](../tests/Observation.AcceptanceTests/ContextFilteredHistoryTests.cs).
- `Independent_and_combined_selections_return_matching_context_and_metadata`
- `Unknown_selections_match_unknown_categories_without_interpreting_legacy_text`
- `No_selection_retains_all_contexts_in_chronological_order_after_restart`
- `Empty_filtered_history_is_an_empty_array_with_applied_selection_metadata`
- `Filtered_history_preserves_patient_scope_inclusive_boundaries_and_equal_bounds`
- `Unsupported_selections_are_rejected_without_changing_observations`
- `Professional_reads_follow_assignments_and_other_patient_tokens_cannot_use_filters_to_gain_access`
### ContextSelectedInsightTests.cs
Source: [tests/Observation.AcceptanceTests/ContextSelectedInsightTests.cs](../tests/Observation.AcceptanceTests/ContextSelectedInsightTests.cs).
- `Independent_and_combined_selections_use_only_matching_observations_and_report_their_basis`
- `Unfiltered_insight_includes_unknown_context_and_explains_mixed_and_missing_conditions`
- `Unknown_selection_is_explicit_and_legacy_narrative_does_not_create_known_membership`
- `Means_round_only_the_final_value_to_two_decimals_with_half_up_rounding`
- `Corrections_clearing_and_deletion_change_membership_and_fresh_summary_results_after_restart`
- `Filtered_insight_preserves_patient_scope_inclusive_bounds_and_equal_instants`
- `Unsupported_selection_is_rejected_with_validation_details`
- `Professional_selection_requires_assignment_and_other_patient_access_is_rejected`
### DeleteContextualisedObservationTests.cs
Source: [tests/Observation.AcceptanceTests/DeleteContextualisedObservationTests.cs](../tests/Observation.AcceptanceTests/DeleteContextualisedObservationTests.cs).
- `Deleted_context_stays_absent_from_retrieval_filtered_history_and_latest_after_restart`
- `New_numerical_summary_excludes_deleted_values_and_retains_current_remaining_observations`
- `Deleting_only_contextualised_observation_leaves_empty_filtered_history_and_no_summary`
- `Unauthorised_deletions_preserve_the_observation_and_all_context`
### DeleteObservationTests.cs
Source: [tests/Observation.AcceptanceTests/DeleteObservationTests.cs](../tests/Observation.AcceptanceTests/DeleteObservationTests.cs).
- `Deleted_observation_stays_absent_after_restart_and_other_observations_are_preserved`
- `Deleting_the_only_observation_leaves_empty_history_and_no_latest_observation`
- `Missing_observation_returns_not_found_without_changing_existing_data`
### HealthInsightTests.cs
Source: [tests/Observation.AcceptanceTests/HealthInsightTests.cs](../tests/Observation.AcceptanceTests/HealthInsightTests.cs).
- `Averages_use_only_the_requested_patient_and_period_after_restart`
- `Minimum_and_maximum_values_are_calculated`
- `Fractional_averages_are_preserved_and_recalculated_after_correction_and_deletion`
- `No_matching_observations_reports_insufficient_data`
- `Invalid_or_missing_period_is_rejected`
- `Equal_bounds_and_offsets_match_recording_timestamp_semantics`
- `Unavailable_observations_report_failure_instead_of_insufficient_data`
### HealthOverviewTests.cs
Source: [tests/Observation.AcceptanceTests/HealthOverviewTests.cs](../tests/Observation.AcceptanceTests/HealthOverviewTests.cs).
- `Overview_preserves_profile_latest_context_and_selected_insight_with_different_bases`
- `No_observations_returns_profile_and_explicit_insight_absence`
- `Empty_selected_insight_preserves_profile_latest_and_applied_selection`
- `Unfiltered_pooled_insight_preserves_mixed_and_unknown_context_explanations`
- `Equal_offset_instants_are_valid_and_single_observation_insight_is_sufficient`
- `Latest_tie_rules_and_current_corrections_deletions_and_profile_edits_survive_restart`
- `Invalid_period_or_context_is_rejected_with_details`
- `Assigned_missing_patient_reports_absence_without_exposing_other_patients`
- `Overview_requires_owner_or_assigned_professional_and_blocks_direct_bypass`
- `Overview_service_credential_is_restricted_to_required_reads`
- `Unavailable_source_or_overview_is_a_failure_not_absent_insight`
### HealthTrendTests.cs
Source: [tests/Observation.AcceptanceTests/HealthTrendTests.cs](../tests/Observation.AcceptanceTests/HealthTrendTests.cs).
- `Full_period_direction_and_separate_units_and_levels`
- `Equal_endpoints_do_not_hide_intermediate_excursion_or_reversal`
- `Overall_decrease_can_coexist_with_reversals_and_large_variation`
- `Low_variation_outside_reference_is_not_healthy`
- `Favourable_pressure_decrease_can_still_be_high_while_falling_pulse_is_concerning`
- `Moving_low_pulse_up_or_high_pulse_down_is_not_automatically_concerning`
- `Opposite_pulse_excursions_within_timestamp_ties_are_not_hidden_by_their_mean`
- `References_are_setting_specific_sourced_and_not_treatment_targets`
- `Pulse_reference_boundaries_are_exclusive`
- `Missing_context_preserves_numerical_direction_but_not_resting_interpretation`
- `Known_categories_with_missing_preparation_support_limited_reference_comparison`
- `Missing_optional_circumstances_do_not_block_supported_comparison`
- `Conflicting_rest_narrative_withholds_resting_interpretation`
- `Different_conditions_and_preparation_are_visible_and_limit_combined_trajectory`
- `Known_inadequate_pressure_preparation_does_not_block_resting_pulse_reference`
- `Timestamp_ties_do_not_manufacture_direction_or_hide_descriptive_range`
- `Empty_and_single_series_report_each_unavailable_part`
- `Retrieval_and_identifier_order_do_not_change_results_including_ties`
- `Inclusive_patient_period_and_equal_offset_instants_apply_before_sufficiency`
- `Labelled_home_and_clinic_selections_and_independent_dimensions_use_only_matches`
- `Unknown_empty_and_one_selected_observation_do_not_borrow_excluded_data`
- `Corrected_values_context_and_deletions_are_used_on_every_request_after_restart`
- `Invalid_period_or_selection_is_rejected_with_explanation`
- `Trend_access_requires_authentication_ownership_or_professional_assignment`
- `Upstream_failure_is_not_misreported_as_empty_data`
### LatestObservationTests.cs
Source: [tests/Observation.AcceptanceTests/LatestObservationTests.cs](../tests/Observation.AcceptanceTests/LatestObservationTests.cs).
- `Latest_is_selected_by_measurement_time_for_the_requested_patient_after_restart`
- `Patient_without_observations_returns_not_found_even_when_another_patient_has_observations`
- `Newer_after_activity_observation_is_returned_with_its_own_context`
- `Missing_context_does_not_replace_latest_with_an_older_complete_observation`
- `Measurement_timestamp_ties_use_original_recording_time_and_ignore_later_edits`
- `Complete_timestamp_ties_choose_greatest_identifier_reproducibly_across_restart`
### MeasurementContextMigrationTests.cs
Source: [tests/Observation.AcceptanceTests/MeasurementContextMigrationTests.cs](../tests/Observation.AcceptanceTests/MeasurementContextMigrationTests.cs).
- `Upgrading_an_existing_observation_retains_values_and_text_without_inventing_context`
### ObservationHistoryTests.cs
Source: [tests/Observation.AcceptanceTests/ObservationHistoryTests.cs](../tests/Observation.AcceptanceTests/ObservationHistoryTests.cs).
- `Selected_period_returns_only_the_matching_observation_after_restart`
- `Results_are_chronological_and_include_both_period_boundaries`
- `No_matching_observations_returns_an_empty_array`
- `Invalid_or_missing_period_is_rejected_without_changing_observations`
- `Offset_bounds_are_normalized_consistently_with_recorded_measurements`
### PatchObservationTests.cs
Source: [tests/Observation.AcceptanceTests/PatchObservationTests.cs](../tests/Observation.AcceptanceTests/PatchObservationTests.cs).
- `Context_can_be_added_to_a_historical_observation_without_changing_its_measurements`
- `Correcting_one_context_field_preserves_omitted_data_and_changes_selection_after_restart`
- `Individual_optional_fields_can_be_corrected_or_cleared_without_erasing_other_context`
- `Explicit_null_context_object_clears_structured_context_but_preserves_legacy_text_and_numbers`
- `Single_numerical_and_legacy_text_updates_preserve_other_values`
- `Invalid_patches_reject_the_whole_update_without_changes`
- `Unsupported_context_in_a_legacy_put_does_not_silently_apply_its_numerical_changes`
- `Missing_observation_is_not_created_by_a_context_patch`
- `Other_patients_professionals_and_unauthenticated_clients_cannot_patch_context`
### PatientAuthenticationTests.cs
Source: [tests/Observation.AcceptanceTests/PatientAuthenticationTests.cs](../tests/Observation.AcceptanceTests/PatientAuthenticationTests.cs).
- `Login_without_profile_returns_normalized_identity_and_no_patient_data`
- `Invalid_account_and_invalid_password_have_same_rejection`
- `Missing_and_invalid_tokens_reject_every_existing_patient_operation`
- `Own_observations_and_insights_are_available_but_another_patients_reads_and_writes_are_rejected`
- `Caller_supplied_account_identity_cannot_replace_authenticated_identity`
- `Profile_creation_retries_and_concurrency_preserve_one_persistent_association`
- `Failed_creation_can_be_retried_without_an_orphan_profile`
- `Expired_token_is_rejected_and_login_produces_a_fresh_token`
- `Tampering_with_a_valid_token_is_rejected`
- `Database_failure_rolls_back_profile_and_association_together`
- `Direct_services_reject_client_tokens_missing_keys_and_forged_keys`
- `Service_credentials_are_limited_to_their_documented_read_calls`
- `Healthcare_professional_cannot_create_profiles`
### ProfessionalAccessTests.cs
Source: [tests/Observation.AcceptanceTests/ProfessionalAccessTests.cs](../tests/Observation.AcceptanceTests/ProfessionalAccessTests.cs).
- `Login_recognizes_professional_identity_and_does_not_put_assignments_in_the_token_response`
- `Professionals_list_only_their_own_assignments_and_can_share_patients`
- `Assigned_profiles_observations_context_history_latest_and_insights_are_readable`
- `Unassigned_patients_and_observations_are_rejected_even_with_a_supplied_assigned_patient_id`
- `Missing_information_for_assigned_patients_follows_existing_retrieval_behaviour`
- `Professionals_cannot_create_update_or_delete_any_patient_information`
- `Missing_invalid_and_expired_tokens_do_not_disclose_assignments_or_patient_data`
- `Incorrect_professional_secret_and_unknown_account_have_identical_login_rejections`
- `Patient_cannot_list_professional_assignments_and_retains_own_access`
- `Assignment_removal_is_used_after_restart_even_with_an_existing_token`
- `Observation_ownership_lookup_failure_fails_closed_while_assignment_list_remains_available`
### RecordMeasurementContextTests.cs
Source: [tests/Observation.AcceptanceTests/RecordMeasurementContextTests.cs](../tests/Observation.AcceptanceTests/RecordMeasurementContextTests.cs).
- `Complete_context_is_saved_with_the_correct_values_and_retrievable_after_restart`
- `Setting_and_activity_are_independent_and_departures_from_guidance_are_valid`
- `Partial_and_absent_context_remain_unknown_without_reinterpreting_legacy_text`
- `Conflicting_categories_and_narrative_are_preserved_without_relabelling`
- `Invalid_context_is_rejected_with_validation_details_without_saving`
- `Context_is_protected_against_other_patient_reads_and_submissions_and_professional_writes`
- `Assigned_professional_can_retrieve_saved_context`
### RecordObservationTests.cs
Source: [tests/Observation.AcceptanceTests/RecordObservationTests.cs](../tests/Observation.AcceptanceTests/RecordObservationTests.cs).
- `Valid_observation_is_assigned_an_identifier_associated_with_the_patient_and_retrievable_after_restart`
- `Optional_fields_can_be_omitted_and_identifiers_are_distinct`
- `Non_positive_values_are_rejected_without_saving`
- `Missing_or_malformed_information_is_rejected_without_saving`
- `Missing_patient_is_rejected_without_saving`
- `Missing_observation_returns_not_found`
- `Failed_patient_lookup_is_rejected_without_saving`
### UpdateObservationTests.cs
Source: [tests/Observation.AcceptanceTests/UpdateObservationTests.cs](../tests/Observation.AcceptanceTests/UpdateObservationTests.cs).
- `Correction_preserves_other_information_and_is_visible_in_all_retrievals_after_restart`
- `All_three_measured_values_can_be_corrected`
- `Non_positive_values_are_rejected_without_changing_observation`
- `Missing_or_malformed_values_are_rejected_without_changes`
- `Missing_observation_is_rejected_without_inserting_a_new_observation`
### ViewObservationContextTests.cs
Source: [tests/Observation.AcceptanceTests/ViewObservationContextTests.cs](../tests/Observation.AcceptanceTests/ViewObservationContextTests.cs).
- `Complete_saved_context_is_returned_with_its_measurements_and_timestamp_after_restart`
- `Partial_saved_context_distinguishes_known_setting_from_unknown_condition_and_details`
- `Historical_free_text_is_returned_without_inventing_setting_or_activity`
- `Missing_observation_reports_not_found_without_disclosing_saved_context`
- `Unauthorised_callers_cannot_read_observation_context`
- `Assigned_professional_reads_the_same_context_as_the_owner`
### AuthenticationIntegrationTests.cs
Source: [tests/PatientProfile.AcceptanceTests/AuthenticationIntegrationTests.cs](../tests/PatientProfile.AcceptanceTests/AuthenticationIntegrationTests.cs).
- `Production_gateway_rejects_plain_http_even_for_login_and_public_guidance`
- `Standard_replacement_handler_with_same_identity_retains_ownership_policy`
### CreatePatientTests.cs
Source: [tests/PatientProfile.AcceptanceTests/CreatePatientTests.cs](../tests/PatientProfile.AcceptanceTests/CreatePatientTests.cs).
- `Valid_profile_is_assigned_an_identifier_and_can_be_retrieved_after_restart`
- `Missing_required_information_is_rejected_without_persisting`
- `Malformed_information_is_rejected`
- `Separate_creations_have_distinct_identifiers_and_contact_information_is_optional`
- `Unknown_identifier_returns_not_found`
### MeasurementGuidanceTests.cs
Source: [tests/PatientProfile.AcceptanceTests/MeasurementGuidanceTests.cs](../tests/PatientProfile.AcceptanceTests/MeasurementGuidanceTests.cs).
- `Public_guidance_without_patient_records_is_labelled_and_has_ordered_sourced_instructions`
- `Activity_is_not_relabelled_as_rest_or_certified`
- `Unsupported_guidance_is_explicitly_unavailable_without_unverified_instructions`
- `Invalid_categories_return_explained_rejections`
### UpdatePatientTests.cs
Source: [tests/PatientProfile.AcceptanceTests/UpdatePatientTests.cs](../tests/PatientProfile.AcceptanceTests/UpdatePatientTests.cs).
- `Updated_profile_preserves_identity_and_date_of_birth_and_survives_restart`
- `Updating_a_missing_patient_is_rejected_without_creating_a_profile`
- `Invalid_name_is_rejected_without_changing_the_profile`
## Ancillary tool evidence
| Tool | Responsibility |
| --- | --- |
| [PasswordHash](../tools/PasswordHash/Program.cs) | Established framework hashing utility; reads stdin |
| [energy-jmeter README](../tools/energy-jmeter/README.md) | Experiment topology, data/config boundaries and metric collection |
| [run.py](../tools/energy-jmeter/run.py) | Orchestrates warmup/measurement, validates telemetry and generates reports |
| [generate-plans.py](../tools/energy-jmeter/generate-plans.py) | Native JMX sessions, Gaussian delays, token renewals, live power/PerfMon |
| [perfmon.py](../tools/energy-jmeter/perfmon.py) / [shelly.py](../tools/energy-jmeter/shelly.py) | Metric interpretation/validation and measured-window summaries |
| [report.py](../tools/energy-jmeter/report.py) | Aligned per-second reporting, separate from application runtime |
@@ -0,0 +1,62 @@
# Requirements-to-implementation traceability
Authoritative scope: [common requirements](../Docs/Requirements/00-common-requirements.md), numbered US-01–US-15, [US-16](<../Docs/Requirements/US16 easy installation and deployment installer.txt>) and [installer addendum](../Docs/Requirements/us16-addendum). This is a static implementation/test review, not a new acceptance-test execution report.
**Implemented** means required behavior is visible in source and mapped tests. **Implemented with limits** means mechanisms exist but some scope/operational evidence is incomplete. No whole US-01–US-15 was found absent. That does not certify every clinical statement or possible deployment/input case. Test coverage references are evidence of checks present, not a claim they passed during this task.
## Story mapping
| Story | Observable implementation / acceptance behavior | Source and relevant tests | Status / limits |
| --- | --- | --- | --- |
| [US-01 create profile](../Docs/Requirements/us01-create-patient-profile.md) | Authenticated initial creation; required name/birth date; generated ID and atomic account association; repeat 409; unique index handles concurrent creation; persistence/retry/DB rollback | [application](../src/PatientProfileService/Application/PatientApplicationService.cs), [repository](../src/PatientProfileService/Persistence/SqlPatientRepository.cs), [CreatePatientTests](../tests/PatientProfile.AcceptanceTests/CreatePatientTests.cs), [PatientAuthenticationTests](../tests/Observation.AcceptanceTests/PatientAuthenticationTests.cs) | Implemented. Interrupted DB writes are checked with a trigger; lost response is approximated by retry after success. No separate process-kill-at-every-write-boundary test. |
| [US-02 view profile](../Docs/Requirements/us02-view-patient-profile.md) | Persisted DTO includes ID/name/date/contact; protected own/assigned reads; absent 404 | [controller](../src/PatientProfileService/Controllers/PatientController.cs), [CreatePatientTests](../tests/PatientProfile.AcceptanceTests/CreatePatientTests.cs), [ProfessionalAccessTests](../tests/Observation.AcceptanceTests/ProfessionalAccessTests.cs) | Implemented. Covered in creation/access suites rather than a separate ViewPatientTests file. |
| [US-03 update profile](../Docs/Requirements/us03-update-patient-profile.md) | Update name/contact; ID/birth/account/original creation preserved; missing does not create | [SQL repository](../src/PatientProfileService/Persistence/SqlPatientRepository.cs), [UpdatePatientTests](../tests/PatientProfile.AcceptanceTests/UpdatePatientTests.cs) | Implemented. Birth-date editing is not an accepted story behavior. |
| [US-04 record observation](../Docs/Requirements/us04-record-observation.md) | Timestamp and positive numerical values; patient lookup before own DB save; independent context dimensions, optional details, unknown defaults, legacy text retained, later read | [application](../src/ObservationService/Application/ObservationApplicationService.cs), [mapping](../src/ObservationService/Persistence/ObservationDbContext.cs), [RecordObservationTests](../tests/Observation.AcceptanceTests/RecordObservationTests.cs), [RecordMeasurementContextTests](../tests/Observation.AcceptanceTests/RecordMeasurementContextTests.cs), [migration test](../tests/Observation.AcceptanceTests/MeasurementContextMigrationTests.cs) | Implemented with limits: preservation is general; narrative conflict interpretation uses US-11 finite phrases. No arbitrary-language conflict detector. |
| [US-05 view observation](../Docs/Requirements/us05-view-observation.md) | Read by observation ID includes current measurements/time/context/note; owner/assignment lookup before access; missing 404 | [controller](../src/ObservationService/Controllers/ObservationController.cs), [ViewObservationContextTests](../tests/Observation.AcceptanceTests/ViewObservationContextTests.cs) | Implemented. Directly seeded Given states verify retrieval independently of creating a reading. |
| [US-06 latest](../Docs/Requirements/us06-latest-observation.md) | Greatest measurement time, then original recording time, then greatest UUID; context completeness ignored; no observations 404 | [repository](../src/ObservationService/Persistence/SqlObservationRepository.cs), [LatestObservationTests](../tests/Observation.AcceptanceTests/LatestObservationTests.cs) | Implemented, including deterministic complete ties across restart. |
| [US-07 history](../Docs/Requirements/us07-observation-history.md) | Inclusive/equal periods, ascending time/UUID, selected dimensions AND, explicit Unknown, no-selection includes all, empty array, metadata headers, invalid selections rejected | [controller](../src/ObservationService/Controllers/ObservationController.cs), [repository](../src/ObservationService/Persistence/SqlObservationRepository.cs), [ObservationHistoryTests](../tests/Observation.AcceptanceTests/ObservationHistoryTests.cs), [ContextFilteredHistoryTests](../tests/Observation.AcceptanceTests/ContextFilteredHistoryTests.cs) | Implemented. Full unpaginated result is actual contract; no requirement for pagination. |
| [US-08 correction](../Docs/Requirements/us08-update-observation.md) | Numeric PUT; partial PATCH adds/corrects/clears individual context fields; omitted fields preserved; unsupported fields/category rejected before save; current selection/calculation membership | [patch](../src/ObservationService/Contracts/PatchObservationRequest.cs), [repository](../src/ObservationService/Persistence/SqlObservationRepository.cs), [UpdateObservationTests](../tests/Observation.AcceptanceTests/UpdateObservationTests.cs), [PatchObservationTests](../tests/Observation.AcceptanceTests/PatchObservationTests.cs) | Implemented. No concurrent-update conflict detection, outside explicit story criteria. |
| [US-09 delete](../Docs/Requirements/us09-delete-observation.md) | Physical row/context deletion; no later read/history/statistics contribution; unaffected remaining data; access controls | [repository](../src/ObservationService/Persistence/SqlObservationRepository.cs), [DeleteObservationTests](../tests/Observation.AcceptanceTests/DeleteObservationTests.cs), [DeleteContextualisedObservationTests](../tests/Observation.AcceptanceTests/DeleteContextualisedObservationTests.cs) | Implemented. No separate stored result/context lifecycle to clean up. |
| [US-10 numerical insight](../Docs/Requirements/us10-calculated-insight.md) | Current filtered observations; arithmetic means/final two-decimal half-up; BP extrema; single sufficient; empty insufficient 404; explicit selection/count/context limitations | [calculator](../src/InsightsService/Domain/InsightCalculator.cs), [HealthInsightTests](../tests/Observation.AcceptanceTests/HealthInsightTests.cs), [ContextSelectedInsightTests](../tests/Observation.AcceptanceTests/ContextSelectedInsightTests.cs) | Implemented. No stored summary per baseline correction. |
| [US-11 trend](../Docs/Requirements/us11-health-trend.md) | Three separate metric assessments, full-period direction/OLS/variation, reversals and timestamp ties, reference scopes/limits, context comparability, selections and unavailable parts; corrections/deletions fresh | [calculator](../src/InsightsService/Domain/InsightCalculator.Trends.cs), [HealthTrendTests](../tests/Observation.AcceptanceTests/HealthTrendTests.cs), [method documentation](../src/TRENDS.md) | Implemented with limits: finite narrative phrases and locally coded clinical inferences need separate clinical review for broader claims; not independently validated here. |
| [US-12 overview](../Docs/Requirements/us12-health-overview.md) | Profile + latest overall + selected-period insight; latest context distinct; no-match keeps available parts; unknown/mixed explanations; invalid period/access/failures | [application](../src/HealthOverviewService/Application/HealthOverviewApplicationService.cs), [HealthOverviewTests](../tests/Observation.AcceptanceTests/HealthOverviewTests.cs) | Implemented. No trend component and no cross-service snapshot, both documented. |
| [US-13 patient authentication](../Docs/Requirements/us13-patient-authentication.md) | Valid generic login; opaque expiry/tamper checks; own-data restrictions by actual owner; profile-less login/create; persistence/bypass protection | [security](../src/ApiGateway/Security/PatientAccessMiddleware.cs), [PatientAuthenticationTests](../tests/Observation.AcceptanceTests/PatientAuthenticationTests.cs), [AuthenticationIntegrationTests](../tests/PatientProfile.AcceptanceTests/AuthenticationIntegrationTests.cs) | Implemented. Test clocks/replacement handlers are test-only; native secrets/files/network remain deployment responsibilities. |
| [US-14 professional reads](../Docs/Requirements/us14-professional-access.md) | Login role, own assignment list, many-to-many assignment reading including context/trends/overview; empty/missing results; unassigned concealment; all writes rejected | [assignments](../src/ApiGateway/Security/ProfessionalAssignments.cs), [ProfessionalAccessTests](../tests/Observation.AcceptanceTests/ProfessionalAccessTests.cs), [trend](../tests/Observation.AcceptanceTests/HealthTrendTests.cs), [overview](../tests/Observation.AcceptanceTests/HealthOverviewTests.cs) | Implemented. Fresh installer professional has no assignments; configured examples/tests demonstrate assigned workflow. Assignment administration is excluded. |
| [US-15 guidance](../Docs/Requirements/us15-measurement-guidance.md) | Public ordered sourced home/rest instructions, applicability/review dates, pulse/activity limits, unavailable setting explanation, no record/certification side effects; valid submission independent of viewing | [controller](../src/ApiGateway/Controllers/MeasurementGuidanceController.cs), [MeasurementGuidanceTests](../tests/PatientProfile.AcceptanceTests/MeasurementGuidanceTests.cs), [record-context tests](../tests/Observation.AcceptanceTests/RecordMeasurementContextTests.cs) | Implemented. Clinical references are compiled metadata, not dynamically refreshed guidance or evidence of current source validation in this task. |
| US-16 independent installation plus addendum | Selected payloads/processes/config; matching keys/HTTPS trust; runtime/PostgreSQL provisioning, separate DBs/roles/migrations; colocated/distributed origins; verification | [installer](../deploy/installer/install.sh), [provisioner](../deploy/HealthApp.Provisioning/Program.cs), [InstallationTests](../tests/Deployment.AcceptanceTests/InstallationTests.cs), [BootstrapTests](../tests/Deployment.AcceptanceTests/BootstrapTests.cs) | Implemented with operational/verification limits detailed below. Windows/macOS extend the Linux requirement text. |
## US-11 acceptance groups
| Criteria | Implementation/test basis |
| --- | --- |
| A/B/C: separate metrics, patient/period, direction | `CalculateTrend`, `AssessMeasurement`; separate units and all-timepoint calculations; tests `Full_period_direction_and_separate_units_and_levels`, `Inclusive_patient_period_and_equal_offset_instants_apply_before_sufficiency` |
| D/E: intermediate excursion and reversal | Raw range plus grouped adjacent absolute change/sign reversals; tests `Equal_endpoints_do_not_hide_intermediate_excursion_or_reversal`, `Overall_decrease_can_coexist_with_reversals_and_large_variation` |
| F/G/H/I: levels/interpretations/conflicting metrics | Applicable reference comparisons and separate hints; tests `Low_variation_outside_reference_is_not_healthy`, `Favourable_pressure_decrease_can_still_be_high_while_falling_pulse_is_concerning`, pulse boundary/tie excursion tests; independent clinical assessment remains unperformed |
| J/K/L: missing context, insufficiency, reference values | `AssessComparability`/`SelectReference`, explicit unavailable parts and provisional references; missing preparation/inadequate rest/setting-specific reference tests |
| M/N: ordering independence and freshness | Timestamp grouping/sorting; fresh HTTP history on each call; tests `Retrieval_and_identifier_order_do_not_change_results_including_ties`, `Corrected_values_context_and_deletions_are_used_on_every_request_after_restart` |
| Context additions | Filtered history retrieval, metadata and comparability evidence; selected Home/Clinic/Unknown, empty/single series and contradictory phrase tests |
All named tests above are in [HealthTrendTests.cs](../tests/Observation.AcceptanceTests/HealthTrendTests.cs).
## US-16 acceptance groups and operational gaps
| Criterion | Evidence | Remaining uncertainty / incomplete verification |
| --- | --- | --- |
| A/B/C selected/single/multiple/all | Release selection, installer selection, distinct payloads/units, direct independent processes | Normal single-node partial installation must reuse a plan with reachable remote dependencies or defer final topology check; creating a new default plan is not discovery of an existing deployment. |
| D independent config | Per-service env/JSON/certificates/origins/DB values; native configuration tests | Source templates and generated units differ; document generated behavior. |
| E separate machines | Runtime origins and HTTP are location-independent; scoped SSH/SCP distribution tests | Real separate-machine native deployment/network evidence not established by loopback/double tests. |
| F independent service management | Native registrations have no peer coupling; direct process stop/restart tests | Linux/Windows/macOS manager behavior must be demonstrated on native hosts; no new native run was performed here. |
| G persistence ownership | Separate DB/role generation, PUBLIC revocation, dedicated credential checks | Normal DB credentials own schema for migrations; mandatory encrypted DB transport is not implemented. |
| H preserve architecture | Same DLLs and Gateway-routed APIs on all layouts | No container/shared-memory/merged-service runtime path present. |
| I installation verification | Native active/PID checks (Linux/Windows), HTTPS/DB/callback probes, complete synthetic workflow | Live verifier does not explicitly stop/restart each service; macOS has no explicit distinct-PID comparison. Literal `all` enables complete verification in local wrappers; listing all five names does not. |
| Addendum dependencies/config | Apt ancestry/package checks; generated secrets/CA/PFX/roles/config/migration/native startup | Package doubles do not prove every distro/version/CPU; Linux automation limited to Debian/Ubuntu family; Windows/macOS packages/native execution require native evidence. |
## Missing functionality versus scope exclusions
No wholly unimplemented accepted backend user story was identified by this static review. Concrete incomplete **verification** items are native stop/restart demonstration in the live verifier, explicit macOS PID separation, complete-workflow verification for the five-name selection form, and actual multi-machine/native-platform evidence. General narrative understanding and independent clinical applicability remain **unknown**, rather than established complete capabilities. See [discrepancies](discrepancies.md) for exact evidence.
Registration, recovery, MFA, refresh tokens, professional credential verification, consent/emergency access, professional writes, assignment administration, a product frontend, pagination, optimistic concurrency, backup/restore, HA and production hardening are not accepted features established by the inspected stories. Their absence is recorded without adding scope or treating suggestions as approved requirements.
## Shared constraints
Ownership/professional access applies across all patient-specific routes; guidance alone is public. Inclusive/equal periods and offset normalization apply consistently to history, summary, trend and overview insight. `Unknown` is independently selectable; legacy narrative is never converted to a definite category. Persistence/restart tests and migration tests check ownership and context continuity. The snapshot is backend/source complete but not a claim that tests, external clinical sources or every deployment platform were freshly validated.
@@ -0,0 +1,291 @@
# HealthApp software architecture — as built
## 1. Scope and evidence
This is a source-level snapshot dated 2026-10-12 at commit `5d9371388c15066eeb2bc124ed227659c644dab5`. The system is a prototype REST backend for synthetic patient profiles, blood-pressure observations and derived assessments. It includes an installer and separate experiment tools. A web/mobile client is a context actor in the original diagrams; no product frontend is implemented in this repository.
Descriptions below are verified from source unless explicitly labelled inferred or unknown. Evidence links resolve to the inspected repository. Existing specifications supply context, especially [architecture authority](../Docs/Architecture/README.md), [common requirements](../Docs/Requirements/00-common-requirements.md), [Insights correction](../Docs/Architecture/us10-insights-correction.md) and [authentication design](../Docs/Design/authentication-and-access-control-design.md). Their differences from the implementation are catalogued in [discrepancies](discrepancies.md).
The [evidence inventory](evidence-inventory.md) records the inspected files. Automated tests were read, not rerun; this document makes no new test-pass, performance, clinical-validation or native-platform deployment claim.
## 2. Style, boundaries and structure
The implementation uses five independently buildable ASP.NET Core controller projects and operating-system processes. The topology is synchronous request/response microservices with a central API Gateway, service-owned persistence, and conventional controller/application/repository layering in the two persistent services. There is no application message bus, event processing, background synchronization or shared production implementation library. See [solution](../HealthApp.slnx), [logical diagram](diagrams/02-logical-services.drawio) and each service's `Program.cs` below.
| Process / project | Responsibility | Local implementation | State |
| --- | --- | --- | --- |
| [ApiGateway](../src/ApiGateway/Program.cs) | Client login, token authentication, ownership/assignment authorization, explicit API forwarding, public guidance | Controllers, security middleware, framework authentication and named HTTP clients | Startup account/assignment configuration; persistent token-protection key files |
| [PatientProfileService](../src/PatientProfileService/Program.cs) | Initial profile/account association, profile reads and updates | Controller → scoped application service → repository interface → SQL repository → EF context | Own PostgreSQL database, `patient` table |
| [ObservationService](../src/ObservationService/Program.cs) | Record/read/latest/history/correct/delete observations and their context | Controller → scoped application service → repository interface → SQL repository → EF context; gateway HTTP client for patient existence | Own PostgreSQL database, `blood_pressure_observation` table |
| [InsightsService](../src/InsightsService/Program.cs) | On-demand numerical summaries and context-aware trend assessment | Controller → scoped application service → observation HTTP client and singleton stateless calculator | No database or generated-result persistence |
| [HealthOverviewService](../src/HealthOverviewService/Program.cs) | Compose profile, latest overall observation and selected-period numerical insight | Controller → scoped application service → three typed HTTP clients | No database or generated-result persistence |
Every business call between services passes through the Gateway. The Gateway sends `X-Gateway-Key` to a target service; Observation, Insights and Overview call the Gateway using their own `X-Service-Key`. The Patient/Profile service has no outgoing business HTTP dependency. There are no direct Insights→Observation or Overview→Patient/Profile network calls: client class names denote the resource consumed, while their configured origin is the Gateway. This matches the [original service topology](../Docs/Architecture/02_microservice_architecture.jpg).
Within a service, dependencies are ordinary dependency injection calls. Between services, dependencies are actual HTTP/JSON calls; production projects do not reference each other's implementations. Tests do reference multiple projects and create hosts in one test runner, which is a testing arrangement, not the deployed process model.
The separate [HealthApp.Provisioning](../deploy/HealthApp.Provisioning/Program.cs) executable prepares deployment material, provisions databases and verifies the installed system. It is an administrative utility, not an additional microservice. [PasswordHash](../tools/PasswordHash/Program.cs) is another standalone utility for hashing input passwords, outside the solution's service topology.
## 3. Domain and ownership
The [domain diagram](diagrams/03-domain-model.drawio) uses business concepts, while [class diagrams](diagrams/04-design-classes.drawio) use actual implementation types.
The complete domain view includes authentication grants, professional assignments, guidance instructions and reference provenance as well as profiles, observations and calculated views. Deployment administration has a separate supporting-domain page. Each service also has its own implementation class-diagram file, linked from [README](README.md). Each declared class, record and interface is an individual UML classifier, including nested records, startup and generated EF support types. [Class-diagram coverage](class-diagram-coverage.md) maps all 78 source types and explains visibility, members and relationship notation.
A pre-created **account** identifies a Patient or HealthcareProfessional. A Patient account has zero associated profiles initially and one after creation. A **patient profile** has a generated identifier, name, date of birth and optional contact information. The association is persisted in the profile's row, separate from credential configuration. Legacy rows can have null account association.
A **blood-pressure observation** belongs to one patient by external patient identifier. It records measurement time, systolic/diastolic pressure, device-reported pulse, original free-text context and note, and one structured **measurement context**. Setting and activity categories remain independent; missing values become `Unknown`. Optional preparation/technique details remain unknown/null rather than being inferred from legacy text. Context has no independent persisted identifier or lifecycle.
A **context selection** optionally restricts setting and/or activity. Both supplied dimensions must match; omitted dimensions are unrestricted. An explicit `Unknown` is a filter value, not omission. A **health insight** summarizes current selected observations. A **trend assessment** contains separate systolic, diastolic and pulse assessments plus comparability evidence. A **health overview** combines a profile, optional latest observation and optional numerical insight. These are calculated values, not stored domain entities.
HealthcareProfessional **assignments** form a configured many-to-many account/patient relationship. No professional profile or assignment table exists. General **measurement guidance** has no patient association and does not write observations.
Evidence: [Patient](../src/PatientProfileService/Domain/Patient.cs), [observation](../src/ObservationService/Domain/BloodPressureObservation.cs), [measurement context](../src/ObservationService/Domain/MeasurementContext.cs), [selection](../src/ObservationService/Domain/ContextSelection.cs), [insight](../src/InsightsService/Domain/HealthInsight.cs), [trend types](../src/InsightsService/Domain/TrendAssessment.cs), [overview contracts](../src/HealthOverviewService/Contracts/HealthOverviewDto.cs), [assignments](../src/ApiGateway/Security/ProfessionalAssignments.cs).
## 4. Public API and contracts
All routes below are exposed by Gateway controllers. IDs are GUID route values. JSON uses the standard ASP.NET Core serializer conventions. Authentication applies to patient-specific routes; professionals can only read assigned patients, and only professionals can list their own assignments.
| Method and route | Input / result | Owning component |
| --- | --- | --- |
| `POST /api/authentication/login` | Required `accountId`, `password`; 200 access token, token type, lifetime, account ID, role; invalid credentials 401 | Gateway |
| `GET /api/measurement-guidance` | Optional setting/activity; 200 ordered guidance or explained unavailability; unsupported values 400 | Gateway; public |
| `GET /api/professionals/me/patients` | 200 array of `{patientId}` assignments, possibly empty | Gateway |
| `POST /api/patients` | Required name/dateOfBirth, optional contactInfo; 201 profile and Location; existing profile 409 | Patient/Profile |
| `GET /api/patients/me` | 200 authenticated account's profile; unavailable 404 | Patient/Profile via Gateway account lookup |
| `GET /api/patients/{patientId}` | 200 profile; missing/unauthorized owner 404 | Patient/Profile |
| `PUT /api/patients/{patientId}` | Required name, optional contactInfo; 200 updated profile; date of birth is not editable | Patient/Profile |
| `POST /api/patients/{patientId}/observations` | Required measuredAt and positive integer systolic/diastolic/pulse; optional structured context, context text and note; 201 observation and Location | Observation |
| `GET /api/observations/{observationId}` | 200 observation with recorded context; unavailable 404 | Observation |
| `PUT /api/observations/{observationId}` | All three positive measured values required; 200 corrected observation; other fields preserved | Observation |
| `PATCH /api/observations/{observationId}` | At least one supported measured/context/note field; 200 patched observation | Observation |
| `DELETE /api/observations/{observationId}` | 204 deleted; unavailable 404 | Observation |
| `GET /api/patients/{patientId}/observations/latest` | 200 latest overall observation; none 404 | Observation |
| `GET /api/patients/{patientId}/observations` | Required from/to, optional context selection; 200 array, empty `[]` allowed | Observation |
| `GET /api/patients/{patientId}/insights` | Required from/to, optional context selection; 200 numerical insight; no matching data 404 Problem | Insights |
| `GET /api/patients/{patientId}/trends` | Same query; 200 assessment, including explicit unavailable parts for empty/insufficient data | Insights |
| `GET /api/patients/{patientId}/overview` | Same query applied to insight only; 200 overview with nullable latest/insight; missing patient 404 Problem | Overview |
Gateway route evidence: [Patient](../src/ApiGateway/Controllers/PatientController.cs), [Observation](../src/ApiGateway/Controllers/ObservationController.cs), [Insights](../src/ApiGateway/Controllers/InsightsController.cs), [Overview](../src/ApiGateway/Controllers/HealthOverviewController.cs), [Professional](../src/ApiGateway/Controllers/ProfessionalController.cs), [Authentication](../src/ApiGateway/Controllers/AuthenticationController.cs), [Guidance](../src/ApiGateway/Controllers/MeasurementGuidanceController.cs). Backend-specific statuses/validation are defined by the corresponding controllers and contracts, not by a general reverse-proxy engine.
### 4.1 Forwarding and internal contracts
Gateway forwarding constructs a new HTTP request with a configured target and key. It streams POST/PUT/PATCH bodies and forwards Content-Type, not arbitrary client headers. It does not forward client tokens, client-selected account identities or callback keys. Profile creation explicitly derives `X-Account-Id` from the authenticated claim. Response forwarding preserves status, Content-Type and Location (absolute locations are reduced to path/query). Observation forwarding also preserves `X-Measurement-Setting` and `X-Activity-Condition`. The rest of upstream headers are not generically copied. Redirect following is disabled on all configured business HTTP clients.
Backend endpoints mostly mirror the Gateway routes. Patient/Profile additionally exposes `GET /api/patients/by-account/{accountId}` behind its key boundary; Gateway uses it internally and does not expose a corresponding controller route. `/api/patients/me`, login, guidance and assignment listing are Gateway-owned routes.
DTOs are defined locally within each service; consumers deserialize equivalent wire shapes without shared service project references. Insights duplicates an observation/context DTO; Overview duplicates patient, observation, insight and selection DTOs. These are structural JSON contracts, not references to remote domain objects. There is no OpenAPI/Swagger endpoint, API-versioning mechanism or generated client in the application setup.
### 4.2 Validation, patch and period semantics
`[ApiController]`, data annotations and JSON parsing reject invalid model input with 400 validation details. Categories are case-sensitive for recording/filtering/patching: settings `Home`, `Clinic`, `Other`, `Unknown`; activities `AtRest`, `DuringActivity`, `AfterActivity`, `Unknown`. General guidance trims and compares categories without case sensitivity. Numeric observation values must be positive integers; optional rest duration is a nonnegative decimal in minutes. There are no documented clinical upper/lower plausibility checks beyond those input constraints.
PATCH uses setter-maintained `...Specified` flags marked `[JsonIgnore]`. Omitted fields remain unchanged; explicit null clears optional text/details; null setting/activity becomes `Unknown`; null entire context resets it to unknown categories/null details. Numeric values cannot be cleared. Empty or unknown-field patches are rejected. Observation PUT accepts only the three numerical fields and rejects unmapped fields. Profile update preserves identifier, birth date, original creation time and account association; omitted/null contact information clears it. These behaviors are implemented in [patch contracts](../src/ObservationService/Contracts/PatchObservationRequest.cs), [context patch](../src/ObservationService/Contracts/MeasurementContextPatch.cs), [PUT contract](../src/ObservationService/Contracts/UpdateObservationRequest.cs) and [repositories](../src/ObservationService/Persistence/SqlObservationRepository.cs).
Period boundaries are inclusive. Reversed bounds are rejected; equal bounds are valid. Offset-free timestamp values are interpreted as UTC clock values, independent of host timezone. Offset-bearing values are normalized to UTC and stored as `DateTimeKind.Unspecified` in PostgreSQL `timestamp without time zone`. Responses therefore need not contain a trailing `Z`; clients must retain the documented UTC interpretation. `DateOnly` represents birth dates. Evidence: [record/period normalization](../src/ObservationService/Application/ObservationApplicationService.cs), [Insights normalization](../src/InsightsService/Application/InsightsApplicationService.cs), [Overview normalization](../src/HealthOverviewService/Application/HealthOverviewApplicationService.cs), [implementation timestamp documentation](../src/README.md), [offset/boundary tests](../tests/Observation.AcceptanceTests/ContextFilteredHistoryTests.cs).
## 5. Persistence and consistency
See [data diagram](diagrams/05-data-ownership.drawio). Each persistent service has a scoped EF Core DbContext and SQL repository. Reads generally use `AsNoTracking`; observation patches load a tracked entity and save it. Patient updates use `ExecuteUpdateAsync`, observation deletes use `ExecuteDeleteAsync`. There is no shared database access between application services.
| Owner/table | Columns and constraints |
| --- | --- |
| Patient/Profile `patient` | `patient_id uuid` PK generated by application; `account_id text NULL` with unique index `IX_patient_account_id`; required `name varchar`, `date_of_birth date`; optional `contact_info varchar`; required `created_at`, `updated_at timestamp without time zone` |
| Observation `blood_pressure_observation` | `observation_id uuid` PK generated by application; external `patient_id uuid`; `measured_at timestamp without time zone`; integer `systolic`, `diastolic`, `pulse`; optional `context`, `note varchar`; required original/update timestamps; required text `setting`, `activity_condition` default `Unknown`; nullable numeric `rest_duration_minutes` and text body position/arm/device/cuff/circumstances |
| Each EF-owned database | Framework `__EFMigrationsHistory`; no patient/observation cross-database foreign key |
`MeasurementContext` is an EF owned value flattened into the observation row. There is no separate context/preparation table. Database mappings declare PKs and the account uniqueness index, but no observation patient/time/filter indexes or category/positive-value check constraints. Input validation is enforced by APIs/application services; database credentials remain a separate trust boundary.
Evidence: [PatientDbContext](../src/PatientProfileService/Persistence/PatientDbContext.cs), [ObservationDbContext](../src/ObservationService/Persistence/ObservationDbContext.cs), [profile initial migration](../src/PatientProfileService/Persistence/Migrations/20260930200031_InitialPatientSchema.cs), [association migration](../src/PatientProfileService/Persistence/Migrations/20261005082209_AccountProfileAssociation.cs), [observation initial migration](../src/ObservationService/Persistence/Migrations/20261001095222_InitialObservationSchema.cs), [context migration](../src/ObservationService/Persistence/Migrations/20261005094632_RecordedMeasurementContext.cs).
### 5.1 Profile creation
Profile creation and account association are a single row insert. The application checks for an existing account first, but the unique database index is the final concurrency guard. A conflicting PostgreSQL `23505` for that index is translated into `ProfileAlreadyExistsException` and 409. Database failure leaves no separate association step to recover; a lost successful response followed by retry returns the existing-profile conflict, and `/api/patients/me` retrieves the association. Legacy null-account rows remain possible, with no automatic credential association/backfill.
Evidence: [application](../src/PatientProfileService/Application/PatientApplicationService.cs), [repository](../src/PatientProfileService/Persistence/SqlPatientRepository.cs), [concurrency/retry/trigger rollback tests](../tests/Observation.AcceptanceTests/PatientAuthenticationTests.cs).
### 5.2 Observation queries and changes
Recording first verifies patient existence by Observation→Gateway→Patient/Profile. Only then does it save the observation in its own database. This is not a distributed transaction or database foreign key. There is no patient deletion endpoint, but the runtime lookup and write still occur at different instants.
Latest orders by descending measurement time, then original `created_at`, then observation UUID under PostgreSQL ordering. Edits never update original recording time. History filters one patient, inclusive period and both requested context predicates; it orders measurement time ascending then UUID ascending. It returns all matching rows as a list with no pagination or result-size cap. Patch updates preserve omitted values; physical deletion removes the row and all its flattened context.
New insights/trends/overviews read current data. No invalidation event is needed because no generated result is stored. This does **not** imply a cross-service snapshot: overview profile, latest and insight are separate reads. A write between them can produce a composition from different instants.
## 6. Calculation and aggregation behavior
### 6.1 Numerical insight
Insights requests filtered history through the Gateway and calculates arithmetic decimal means for systolic/diastolic/pulse; only final means are rounded to two decimals, midpoint away from zero (half-up for the permitted positive inputs). Blood-pressure minima/maxima retain original integer values. One observation suffices. Zero returns no insight and a 404 Problem; it is not an upstream failure.
The response includes patient, normalized period, applied selection, contributing count and descriptive context explanation. Mixed/unknown settings, activities and optional details are disclosed. Source data is neither relabelled nor persisted by Insights. Evidence: [summary calculator](../src/InsightsService/Domain/InsightCalculator.cs), [HTTP observation client](../src/InsightsService/Clients/HttpObservationServiceClient.cs), [summary tests](../tests/Observation.AcceptanceTests/ContextSelectedInsightTests.cs).
### 6.2 Trends and comparability
Each metric retains mean/min/max/range over every selected raw observation. Temporal calculations group identical measurement timestamps into arithmetic means, then sort by timestamp. At least two distinct timestamps are needed for direction. Adjacent nonzero changes determine Increasing, Decreasing, Mixed or NoClearDirection; sign changes count reversals. Total successive change sums absolute adjacent changes. An ordinary least-squares fit across all distinct timestamp means supplies OverallDirection and SlopePerDay; each timestamp group has equal weight. Time is scaled to the observed span for calculation; slope output is rounded to six decimals. Empty or single-timestamp data returns explicit unavailable portions, not fabricated direction.
Recorded comparability inspects setting/activity/rest/posture/arm/device/cuff similarities, missing details and differences, plus differing additional circumstances. A finite list of case-insensitive narrative phrases detects conflicts between declared Home/Clinic/AtRest and preserved text. This is deterministic phrase matching, not NLP; unrecognized text does not establish correctness, and negations can still match.
The compiled reference metadata supports resting pulse comparisons below 50 or above 100 beats/min, and high blood-pressure comparisons at or above home 135/85 or clinic 140/90 mmHg. Blood-pressure reference selection requires a single known Home/Clinic setting and recorded AtRest, without detected conflicts or explicitly inadequate rest/posture. Missing preparation details can permit a limited provisional reference comparison. These figures describe the **implemented reference selection**, not new medical advice or an independent verification of the sources.
Interpretation distinguishes supported numerical findings from cautiously labelled PotentiallyFavourable, PotentiallyConcerning, Mixed or CannotInterpret. It requires additional comparability/temporal support for development interpretations, never combines the three metrics into one good/bad score, and includes reference scope, operators, sources, dates and limitations. Current guidance/reference text is compiled into the application; no clinical website is called at runtime.
Evidence: [trend calculator](../src/InsightsService/Domain/InsightCalculator.Trends.cs), [result types](../src/InsightsService/Domain/TrendAssessment.cs), [documented method/rationale](../src/TRENDS.md), [numerical/context/reference tests](../tests/Observation.AcceptanceTests/HealthTrendTests.cs). This task checks architectural consistency, not clinical validity.
### 6.3 Health overview
Overview performs three **sequential** awaits: profile, latest overall observation, selected-period numerical insight. A missing profile returns no overview; a 404 latest or insight becomes null and preserves the available profile/other component. Non-404 failures do not silently become absent data. Latest remains independent of the insight's period and context selection. The result explicitly states both bases and contributes no trend component.
The insight request adds another chain: Overview→Gateway→Insights→Gateway→Observation. Each network leg uses the caller's configured service credential; original user tokens do not flow down the chain. Evidence: [overview application](../src/HealthOverviewService/Application/HealthOverviewApplicationService.cs), [client handling](../src/HealthOverviewService/Clients/InsightsServiceClient.cs), [overview tests](../tests/Observation.AcceptanceTests/HealthOverviewTests.cs), [overview sequence](diagrams/07-sequences.drawio).
## 7. Authentication, authorization and security
### 7.1 Client identity
Gateway validates pre-created credentials using ASP.NET Core Identity's `PasswordHasher<PrototypeAccount>`. Accounts are external configuration bound once into a singleton dictionary. Roles are limited to Patient and HealthcareProfessional; account IDs permit ASCII letters/digits/hyphen/underscore, with a maximum length of 128. Unknown accounts still execute hash verification against a dummy hash. Invalid/incorrect credentials share one generic response. Malformed hash verification is rejected; successful hashes that would benefit from rehashing are not persisted back to configuration.
Login issues the framework's protected opaque Bearer authentication ticket, **not a JWT**, using Data Protection application name `HealthApp.ApiGateway`. Claims contain stable account ID and role, not patient health records or patient ownership. Default lifetime is 30 minutes, configurable from 1–1440. Subsequent requests validate the token without password verification. There is no refresh, logout/revocation endpoint, session database, registration or identity-provider integration. Successful login responses carry `no-store` and `no-cache`.
Gateway persists its Data Protection key ring to configured `Authentication:KeyDirectory`. No explicit `ProtectKeysWith...` key-at-rest encryption is configured; filesystem permissions are the deployment protection visible in this implementation. Persistent compatible keys allow tokens to survive a normal Gateway restart. Multi-instance Gateway key coordination, immediate account-change token revocation and external identity-provider behavior are not implemented or verified. See [accounts](../src/ApiGateway/Security/PrototypeAccounts.cs), [login](../src/ApiGateway/Controllers/AuthenticationController.cs), [Gateway startup](../src/ApiGateway/Program.cs), [authentication tests](../tests/Observation.AcceptanceTests/PatientAuthenticationTests.cs).
### 7.2 Per-request access control
Fallback authorization requires authentication; login and general guidance explicitly permit anonymous callers. Role policies require the stable NameIdentifier claim. `PatientAccessMiddleware` then establishes actual access:
- A Patient can POST its initial profile and GET `/api/patients/me` before knowing its patient ID. The profile service enforces uniqueness.
- Other patient operations obtain the account's current persisted profile through the protected by-account API. Requested patient routes must match its ID.
- Observation-ID routes first fetch the observation from Observation to establish the actual owning patient. This additional read occurs before returning/modifying/deleting it.
- Professionals may only GET and must have the patient ID in their configured assignment set. The assignment-list route returns only that professional's configured IDs. Assignments are read once, deduplicated and sorted; edits require restart to affect the singleton.
- Unauthorized ownership/unassigned/missing ownership gives an empty 404 to avoid exposing another patient's existence. Missing/invalid token is 401; authenticated forbidden role/method is 403.
Ownership data is not cached between requests. Patient-specific responses do not receive a global explicit no-store directive in the code. Middleware path-segment comparisons are case-sensitive, despite routing's normal case-insensitive behavior and a few case-insensitive special routes; canonical lower-case routes are used throughout tests/clients. Evidence: [middleware](../src/ApiGateway/Security/PatientAccessMiddleware.cs), [assignments](../src/ApiGateway/Security/ProfessionalAssignments.cs), [professional tests](../tests/Observation.AcceptanceTests/ProfessionalAccessTests.cs), [replacement-handler test](../tests/PatientProfile.AcceptanceTests/AuthenticationIntegrationTests.cs).
### 7.3 Internal trust boundary
Every backend checks `X-Gateway-Key` with fixed-time comparison before controllers. A client bearer token alone cannot call a backend. The key grants the Gateway-level trusted caller boundary; backend controllers do not re-evaluate patient ownership or professional assignment. Compromise/disclosure of a backend incoming key therefore bypasses client authorization for that backend's exposed API.
Gateway chooses InternalService authentication whenever `X-Service-Key` is present; otherwise it chooses Bearer. An invalid callback key does not fall back to a valid bearer token. Three distinct configured callback identities have the following GET-only permissions:
| Callback identity | Allowed Gateway reads |
| --- | --- |
| Observation | `/api/patients/{patientId}` |
| Insights | `/api/patients/{patientId}/observations` with period/selection query |
| HealthOverview | Patient profile, latest observation and numerical insight for `{patientId}` |
Service identities do not carry end-user ownership; permitted reads can address any valid patient ID. They cannot write, list professional assignments, read individual observation IDs or call unlisted aggregation routes. Backend incoming and callback keys are independently generated; length ≥32 is required at startup, while installer-generated secrets are 32 random bytes rendered as 64 hex characters. The unused incoming-key field generated for Gateway is not a Gateway authentication mechanism.
Evidence: [internal handler](../src/ApiGateway/Security/InternalServiceAuthenticationHandler.cs), [service whitelist](../src/ApiGateway/Security/PatientAccessMiddleware.cs), [backend guard example](../src/ObservationService/Program.cs), [bypass/permission tests](../tests/Observation.AcceptanceTests/PatientAuthenticationTests.cs), [Overview restrictions](../tests/Observation.AcceptanceTests/HealthOverviewTests.cs).
### 7.4 Transport and secrets
Non-Development modes require HTTPS business origins. Plain HTTP is rejected with 400 by Gateway and 401 by backends; requests are not redirected to HTTPS. Development permits HTTP for local tests/development while still requiring authentication keys. Base origins must be absolute HTTP(S), root-path URLs without userinfo, query or fragment. There is no application mTLS, forwarded-header trust setup, CORS configuration or rate limiter.
The installer configures Kestrel PFX certificates and OS trust. Client machines independently need trust in the exported public CA or a supplied trusted certificate chain. Server certificates authenticate endpoint names; internal application keys authenticate callers. PostgreSQL-generated connections use `SslMode=Prefer`, not mandatory verified TLS, and default to local database hosts. This is a different boundary from mandatory production HTTPS between application processes.
Generated deployment manifests/account files contain secrets and are protected administratively. Linux uses private deployment files/root-readable environment files and service-group-readable certificates; Windows ACLs and macOS permissions are described below. Application logging uses framework logging/stdout/stderr. No explicit sensitive-data logging is enabled, but request paths can contain patient/observation identifiers. No audit-log store or patient-data log redaction facility is implemented. These are observable limits, not an expansion of the prototype's stated scope.
## 8. Concurrency, caching and runtime behavior
ASP.NET handles concurrent HTTP requests; database and network work uses async Task/CancellationToken. Scoped application services/repositories/contexts are per request. The singleton calculator has no mutable per-request state; accounts/assignments are startup snapshots. Gateway re-entrant callback HTTP traffic is handled as new requests, not recursive in-process calls. Inferred consequence: aggregate workflows add Gateway hops and dependent-service load even when only one external request is counted.
There is no application response/data cache, output-cache middleware, distributed cache, stored statistics or materialized view. Static guidance and loaded account/assignment dictionaries are configuration/reference state rather than caches of clinical data. Framework HTTP handler reuse and database connection behavior are separate infrastructure concerns. The generated database connection strings explicitly set `Pooling=false` and a 10-second connection timeout; externally supplied connection strings can choose different settings. No business HttpClient timeout override or resilience/retry/circuit-breaker policy is configured. The verifier's retry policy does not apply to ordinary application requests.
Profile creation uniqueness is explicitly concurrency-safe. Other updates have no EF concurrency token, version/ETag or conditional-write contract. Inferred: concurrent edits can overwrite each other's changes, especially owned context replacement after reading its previous value; the read following a profile update can observe a later writer's values. There is no multi-service transaction, request idempotency key for observation creation or guaranteed atomic overview snapshot.
History and calculation clients materialize full matching arrays in memory. Overview awaits sources sequentially rather than parallelizing them. Request cancellation is passed through normal HTTP/database operations; connection/HTTP timeouts can happen independently, and client-disconnect cancellation is not deliberately converted to 504.
Runtime evidence: all five `Program.cs` files, [Observation repository](../src/ObservationService/Persistence/SqlObservationRepository.cs), [Patient repository](../src/PatientProfileService/Persistence/SqlPatientRepository.cs), [overview application](../src/HealthOverviewService/Application/HealthOverviewApplicationService.cs), [connection-string generation](../deploy/HealthApp.Provisioning/Deployment.cs).
## 9. Deployment architecture and dependencies
### 9.1 Build and runtime
All five service projects target `net10.0`. Services include `Microsoft.Extensions.Hosting.WindowsServices` 10.0.12. The persistent services use Npgsql EF provider 10.0.3 and EF Relational/Design 10.0.12; Design is private tooling. Provisioning uses Npgsql 10.0.3 and the ASP.NET shared framework. Versions are those declared by the inspected project files, not a latest-version recommendation. xUnit, ASP.NET testing support and PostgreSQL are acceptance-test dependencies.
[build-release.sh](../deploy/build-release.sh) and [build-release.ps1](../deploy/build-release.ps1) publish selected projects separately in Release, framework-dependent (`--self-contained false`) without an apphost (`UseAppHost=false`), plus the provisioner. The bundle carries installer scripts, systemd templates, safe examples and installation documentation. Build requires .NET 10 SDK and package access. Target machines require the .NET 10 ASP.NET Core runtime and PostgreSQL only for persistent services; automatic provisioning supplies missing supported dependencies.
### 9.2 Topology and configuration
Colocated and distributed layouts use the same DLLs and HTTP interfaces. [deployment diagrams](diagrams/06-deployment.drawio) show both supported layouts, not a claim about current physical hosts. Defaults are Gateway HTTPS 5443 and Patient/Profile/Observation/Insights/Overview HTTPS 5081/5082/5083/5084. Generated bindings are `https://0.0.0.0:PORT`; origins and certificate names use configured hosts. Ports must be 1024–65535; services at the same literal host need different ports. IPv6-reachable binding behavior and alias equivalence are not explicitly tested by this documentation task.
Standard .NET configuration loads JSON, environment and command-line values. Committed `appsettings.json` contains logging only. Required external values are:
| Service | Configuration |
| --- | --- |
| Gateway | `Authentication:Accounts`, `Authentication:KeyDirectory`, optional token lifetime; `Access:ProfessionalAssignments`; four `Services:{name}:BaseUrl/Key`; callback keys `InternalAccess:{Observation,Insights,HealthOverview}:Key` |
| Patient/Profile | `ConnectionStrings:PatientDatabase`, `InternalAccess:GatewayKey` |
| Observation | `ConnectionStrings:ObservationDatabase`, incoming Gateway key, `Services:ApiGateway:BaseUrl/Key` |
| Insights and Overview | Incoming Gateway key, `Services:ApiGateway:BaseUrl/Key`; no database settings |
| Each HTTPS host | Binding plus `Kestrel:Certificates:Default:Path/Password`, environment |
Environment-file keys use `__` for configuration sections. Missing/invalid required origins, keys, accounts and connection strings stop startup; startup validation is not a dependency reachability check. Patient/Profile and Observation support `--migrate`: migrations run and the process exits before normal host security/origin startup checks. Normal startup never migrates.
### 9.3 Provisioning stages
1. Validate selected service names, payloads and absence of existing installation/configuration. A repeated first-install command refuses overwrite; no upgrade/uninstall engine exists.
2. Detect supported native platform/dependencies. Linux accepts Debian/Ubuntu `ID`/`ID_LIKE`, apt and running systemd/root access. Package availability, not fixed release numbers, controls provisioning. Only actual Debian can receive a Microsoft Debian runtime repository fallback. Required package names are `aspnetcore-runtime-10.0` and, where needed, `postgresql`.
3. Prepare one private plan covering all five services, even for a subset. Generate per-service keys, database settings for the two owners, synthetic `prototype-patient`, `prototype-professional`, `installation-check` accounts and hashed Gateway account config. The professional initially has no assignments.
4. Generate a prototype CA (two-year validity) and service-name/IP SAN certificates (one-year validity). Only public CA material is retained; its generated signing private key is disposed. Alternatively accept externally supplied public CA and all service PFX/password files. Supplied material is not preflighted against every runtime requirement; endpoint verification checks trust/name later.
5. Create selected persistent services' separate DBs/roles, revoke public database/schema access and give the owner schema rights for migrations. Reuse a consistent generated plan, not independently generated incompatible secrets. Database roles cannot administer/create databases/roles/replicate. An external PostgreSQL admin connection can be supplied; generated service endpoint settings adopt its host/port.
6. Install selected payloads, protected configuration/certificates, native identities and registrations; apply migrations and start each selected process.
7. Verify local native status/distinct PIDs where implemented, HTTPS reachability, DB service identity, callback credentials and topology. Complete-system verification logs in and creates/reuses a labelled synthetic check profile/observation, then retrieves overview through all five services. Verification is therefore not entirely read-only.
Evidence: [Linux installer](../deploy/installer/install.sh), [bootstrap](../deploy/installer/bootstrap.sh), [deployment preparation](../deploy/HealthApp.Provisioning/Deployment.cs), [DB provisioning](../deploy/HealthApp.Provisioning/DatabaseProvisioning.cs), [config adapter](../deploy/HealthApp.Provisioning/ConfigurationWriter.cs), [verifier](../deploy/HealthApp.Provisioning/InstallationVerification.cs).
### 9.4 Native execution and paths
| Platform | Runtime management and paths | Important boundaries |
| --- | --- | --- |
| Linux | `healthapp-NAME.service`; `/opt/healthapp/NAME`; `/etc/healthapp/NAME/service.env`; Gateway `/var/lib/healthapp-api-gateway/keys`; default plan `/var/lib/healthapp-installation/deployment` | Dedicated `healthapp-NAME` users/groups; env root-only, certificates root/service group; systemd supplies env; default local PostgreSQL |
| Windows | Independent Windows Services/virtual `NT SERVICE\healthapp-NAME` identities; `%ProgramData%\HealthApp` with services/config/state | Private administrative ACLs plus own-service read/state rights; production JSON copied into application directory; selected HTTPS firewall rules; runtime downloaded if absent; EDB PostgreSQL 17 installer resolved from maintained package manifest and SHA-256 checked |
| macOS | Independent launchd daemons/hidden `_healthapp_NAME` identities; `/Library/Application Support/HealthApp` with services/config/state | System-keychain CA trust; Homebrew PostgreSQL 17 and installer-owned cluster if no external server; Apple command-line tools/Homebrew provisioning; private plist contains environment secrets |
Systemd source templates still show a shared `healthapp` user and old flat env paths. The installer rewrites them to per-service identities and nested env paths; the generated units are the as-built installed behavior. Units request network-online, restart on failure after five seconds, use SIGINT and a 30-second stop timeout. They do not couple peers via Requires/PartOf/BindsTo or impose explicit resource limits/sandbox directives. Backend DB unavailability does not necessarily stop a host before its first DB request. Independent stopping means process independence, not availability of workflows that depend on it.
Windows uses standard WindowsServices lifetime integration and restart-on-failure configuration. macOS `RunAtLoad`/`KeepAlive` launchd registration keeps daemons alive. The repository supplies a manual [native-install workflow](../.github/workflows/prototype-native-install.yml); its existence is not evidence that Windows/macOS live registration or CI execution succeeded.
### 9.5 Distributed administration and verification limits
One prepared topology can be grouped by host and installed through SSH/SCP using [Distribution](../deploy/HealthApp.Provisioning/Distribution.cs). Each node receives selected applications/private material and necessary remote origins, not all unrelated keys/DB passwords. The Gateway legitimately needs outgoing backend keys and callback authentication keys. Unix installation needs administrative SSH with noninteractive sudo; Windows requires an elevated SSH session. Host-administration access is a prerequisite separate from generated application credentials.
Node startup can defer cross-topology verification until other hosts start. Final verification probes actual origins. There is no remote runtime file-sharing dependency after installation. Failed installation retains existing/generated material and reports the failed step; it has no cross-host rollback transaction or remote-artifact cleanup guarantee. Linux `--root` is offline staging, not live package/service deployment.
Verification contains short startup retry loops for transient 502/503/504/connectivity failures, uses custom-root TLS validation with server-name checking, and tests actual database identity. Linux installer/verifier checks native active state and distinct MainPID values. Neither live verifier deliberately cycles every service through stop/restart. Independent stop/restart is exercised by deployment acceptance tests, with direct process control; native manager execution is a separate evidence limit. See [traceability](requirements-traceability.md).
## 10. Failure behavior
| Trigger | Implemented outcome |
| --- | --- |
| Missing/malformed model, unsupported category, reversed/missing period | 400 validation response; no intended partial write |
| Invalid login / missing, forged or expired bearer | 401; invalid login response does not identify which credential failed |
| Incorrect backend incoming key / production backend HTTP | 401 before controller |
| Production Gateway HTTP | Empty 400, including public/login routes |
| Forbidden professional write, role or internal service route | 403 |
| Cross-patient ownership, unassigned patient, no own profile, absent observation | Generally empty Gateway 404; authorized missing backend resources follow their own API response |
| Second/concurrent profile creation | 409 existing-profile condition, protected by unique DB index |
| No history / summary / temporal data | History 200 `[]`; summary 404 insufficient data; trends 200 explicit unavailable parts; overview keeps available profile/latest with null insight |
| Gateway forwarding connection failure | 502 Problem; upstream status responses otherwise forwarded |
| Local non-client-cancelled upstream timeout | 504 Problem; an upstream 504 already received remains an upstream response and can be mapped by a consuming service |
| Observation patient-lookup failure | 502/504, no saved observation |
| Insights/Overview upstream non-success or malformed JSON | 502; a local timeout 504; appropriate 404 treated as absence only in Overview clients |
| Ownership lookup invalid JSON/missing expected field, unhandled DB error or other exception | Generic exception-handler path, normally 500; not all invalid upstream shapes have an explicit 502 mapping |
| Gateway stream fails after response has started | Connection aborted; response cannot be replaced safely with a new error body |
| Required config invalid / packages unavailable / certificate or provisioning failure | Startup or installer fails; step diagnostics; retained data/material rather than automatic rollback |
Every host installs `AddProblemDetails`/`UseExceptionHandler`; response shapes are not entirely uniform (empty status responses, login `{title}`, validation Problems and explicit Problems coexist). Overview interprets any 404 from its designated insight route as absent insight; it does not inspect the upstream problem title to distinguish all possible causes. Gateway ownership lookup is an extra availability dependency on Patient/Profile for patient requests, even when the requested operation is otherwise Observation- or Insights-owned.
No automatic business retry, circuit breaker, overload shedding, rate limit, dedicated readiness/liveness API or fault-tolerant replica configuration is implemented. Inferred: a Gateway outage prevents all normal external operations and aggregation callbacks; a source outage may leave peer processes running while dependent workflows fail. Runtime failure tests: [patient failures](../tests/Observation.AcceptanceTests/PatientAuthenticationTests.cs), [insight failures](../tests/Observation.AcceptanceTests/HealthInsightTests.cs), [trend failures](../tests/Observation.AcceptanceTests/HealthTrendTests.cs), [overview failures](../tests/Observation.AcceptanceTests/HealthOverviewTests.cs).
## 11. Test and experiment architecture
Application acceptance fixtures use real PostgreSQL databases and HTTP hosts, standard credential hashing/protected tokens, controlled identities and an injectable token clock. They check persistence across host restarts, isolation, ownership, professional restrictions, period/category semantics and failures. Some tests seed directly into an owning DbContext to establish Given state; that is not production cross-service DB access. Test-specific replacement authentication verifies policy separation but is not the deployment mechanism.
Deployment acceptance builds/publishes a release, invokes the real offline installer/provisioner, creates isolated DBs/roles and launches five separate Production HTTPS processes at distinct loopback origins. It checks native config formats, secrets/certificate output, DB isolation, migrations, restart independence and representative workflows. SSH/SCP distribution and apt bootstrap commands use controlled doubles. Such tests cannot establish a real five-machine topology or native Windows/macOS service-manager operation. Evidence: [application fixture](../tests/Observation.AcceptanceTests/ObservationApiFixture.cs), [test token helper](../tests/Support/AuthenticatedTestClient.cs), [deployment fixture](../tests/Deployment.AcceptanceTests/DeploymentFixture.cs), [installation tests](../tests/Deployment.AcceptanceTests/InstallationTests.cs), [bootstrap tests](../tests/Deployment.AcceptanceTests/BootstrapTests.cs).
The optional [energy/JMeter tooling](../tools/energy-jmeter/README.md) runs outside the product processes. Generated JMX plans exercise synthetic API sessions, renew opaque tokens by login, and include Gaussian interaction delays. PerfMon ServerAgent host telemetry and Shelly plug HTTP power readings are collected live into JMeter, defaulting to one-second intervals. The runner separates warmup from the measured duration and reports request latency/throughput and CPU/RAM/power on aligned timelines. Idle sends no application requests. These agents/devices are experimental dependencies, not a sixth HealthApp service or a production monitoring/security guarantee. Private credentials and ignored raw experiment results were not inspected for this assignment.
## 12. Significant constraints and decisions
The architecture preserves independent process/persistence boundaries, Gateway-routed REST, controller APIs, external configuration and on-demand derived results. It deliberately uses pre-created accounts/assignments and synthetic data. No account administration, assignment-management UI, consent/emergency workflows, medication recommendations, professional edits or production identity-provider implementation is present; these are documented exclusions, not implicitly missing stories.
[Architecture decisions](architecture-decisions.md) distinguishes explicitly documented rationale from inferred consequences. [Requirements traceability](requirements-traceability.md) identifies implementation/verification limits without silently adding requirements. [Discrepancies](discrepancies.md) distinguishes superseded diagrams, current elaborations and unresolved evidence gaps. This documentation proposes no architectural or implementation changes.
+27
View File
@@ -0,0 +1,27 @@
# Documentation validation
Validated on 2026-10-12 against source commit `5d9371388c15066eeb2bc124ed227659c644dab5`.
## Deliverables
- Required architecture narrative, README, observable decisions, requirements traceability and discrepancies are present.
- Twelve native editable Draw.io files cover all required views. Five are standalone service class diagrams; the combined class file contains the same service views plus provisioning. The complete domain diagram has an application-domain page and a separate deployment-domain page.
- Every one of the 78 source-declared service classes, records and interfaces is an individual UML classifier in its service diagram. Classifiers have separate name, attribute and operation compartments; nested types and partial declarations are accounted for. Migrations/designer members/snapshots appear on distinct EF-support pages.
- Domain concepts and implementation classes are on separate diagrams.
- The evidence inventory links source, configuration, requirements and concrete test methods.
## Checks performed
Native XML was parsed for every diagram. Checks verified `mxfile`/`mxGraphModel` structure, unique cell IDs, existing connector endpoints, positive shape geometry, free-edge message/lifeline endpoints and absence of embedded raster-image diagram content. Native boxes do not overlap. A font-metric estimate checked wrapped label height against every shape; no estimated text overflow was found. Relative source links attached to diagram nodes and local Markdown links resolve to existing files.
Following the class-diagram correction, declarations were independently enumerated from each service's source files and compared against the diagram's fully qualified `sourceType` values. Exact per-service coverage is required: Gateway 16, Patient/Profile 14, Observation 17, Insights 16 and Overview 15. Member signatures were checked for arrays, nullable/default record parameters, visibility/private setters and merged partial migration methods. The earlier grouped class views were replaced, not retained as complete service diagrams.
Content was checked against actual service startup, controllers, client origins/headers, security middleware, domain/contracts, repositories, EF mappings/migrations, provisioning/native adapters and relevant acceptance assertions. The diagrams use the same Gateway-routed communication, separate database ownership, opaque-token mechanism, context semantics and sequential overview behavior as the narrative. Historic superseded diagrams and stale implementation prose are distinguished from current-baseline differences.
The directory contains documentation and `.drawio` source only. No application code, configuration, tests or existing documentation was changed. A SHA-256 comparison confirmed all **229 pre-existing tracked files** retain their original contents; Git reports only the new `AsBuiltArchitecture/` directory.
## Evidence limits
Application/deployment suites were inspected rather than rerun: this assignment authorizes documentation, not changes to existing implementation/build artifacts or live installation. No native installer, remote host, device or external clinical source was exercised. Test doubles and loopback origins are not described as real multi-machine/native deployment evidence.
Draw.io XML/geometry/source-link validation was automated; the Draw.io desktop/browser GUI was not available here, so GUI round-trip/import rendering was not separately exercised. Each file is uncompressed native Draw.io XML with editable labels, shapes and connectors, not an image-only export. The document records uncertainties rather than presenting these limits as verified runtime behavior.
@@ -0,0 +1,142 @@
# US-16 – Install and Deploy Services Independently
## User Story
As a system administrator,
I want to install one or more HealthApp services on a Linux system,
so that each service can be deployed independently or multiple services can be colocated on the same machine without losing their independent service boundaries.
## Description
The HealthApp consists of independently deployable services.
The installation mechanism must support both:
1. installing an individual service on a machine; and
2. installing multiple or all HealthApp services on the same machine.
When multiple services are installed on the same machine, each service must remain an independent operating-system process with its own configuration and service registration.
Installing services together must not combine them into a single process or otherwise remove the architectural separation between services.
The installation mechanism must support the services defined by the current architecture, including the API Gateway and application microservices.
## Acceptance Criteria
### AC-16-A – Install a Single Service
**Given** a supported Linux system
**When** the administrator selects one HealthApp service for installation
**Then** only the selected service is installed
**And** it can be started and stopped independently
**And** installation does not require the other HealthApp services to be installed on the same machine.
---
### AC-16-B – Install Multiple Services on One Machine
**Given** a supported Linux system
**When** the administrator selects multiple HealthApp services for installation
**Then** all selected services are installed
**And** each service runs as an independent operating-system process
**And** each service can be started, stopped and restarted independently.
---
### AC-16-C – Install the Complete System on One Machine
**Given** a supported Linux system
**When** the administrator chooses to install the complete HealthApp system
**Then** all required HealthApp services are installed
**And** every service remains an independently managed service/process
**And** the services can communicate using the same network interfaces used when deployed on separate machines.
---
### AC-16-D – Independent Configuration
**Given** an installed HealthApp service
**When** its deployment configuration is provided
**Then** service-specific configuration can be supplied independently of the configuration of other services.
This includes configuration required by that service, such as:
- network address and port;
- dependent service endpoints;
- database connection information where applicable;
- service credentials and other deployment-specific settings.
No service may require hard-coded knowledge that another service is installed on the same machine.
---
### AC-16-E – Separate-Machine Deployment
**Given** HealthApp services installed on different machines
**When** their service endpoints and required credentials are configured correctly
**Then** the services can communicate according to the documented architecture
**Without** requiring shared process memory, shared local files, or localhost-specific assumptions.
---
### AC-16-F – Service Management
**Given** an installed service
**When** the operating system starts, stops or restarts that service
**Then** the service can be managed independently from the other HealthApp services.
Stopping or restarting one service must not directly stop or restart another service.
---
### AC-16-G – Persistence Independence
**Given** a service that owns persistent data
**When** that service is installed
**Then** its persistence configuration is independent of the persistence configuration of other services.
Installing multiple services on one machine must not cause services to share persistence that the documented architecture defines as separately owned.
Services without persistence must not gain persistence merely because they are installed together with persistent services.
---
### AC-16-H – Installation Does Not Change Architecture
**Given** any supported installation arrangement
**When** services are installed individually or together
**Then** the logical service boundaries, communication paths, persistence ownership and responsibilities defined by the architecture remain unchanged.
Deployment location must not change the behaviour or responsibility of a service.
---
### AC-16-I – Installation Verification
**Given** a completed installation
**When** installation verification is performed
**Then** each installed service can be shown to:
- start successfully;
- run as its own process;
- accept its configured network traffic where applicable;
- use its configured dependencies;
- stop and restart independently.
For a complete-system installation, representative application operations must successfully pass through the deployed services.
---
## Notes
This user story concerns deployment and installation only.
It does not authorize:
- merging microservices;
- changing service responsibilities;
- introducing shared persistence;
- changing the documented communication architecture;
- changing existing functional user stories.
The same application executables should support both colocated and distributed deployment through configuration rather than separate implementations.
+135
View File
@@ -0,0 +1,135 @@
## Required installer behaviour
The installer must support installing:
- one selected HealthApp service;
- multiple selected services;
- all HealthApp services on the same machine.
Each application service must still run as an independent systemd service/process.
### PostgreSQL
Where an installed service requires PostgreSQL persistence, the installer must:
- detect whether PostgreSQL is already available;
- install PostgreSQL when necessary on supported Linux distributions;
- create the required database(s);
- create dedicated database user credentials;
- generate suitable passwords rather than using hard-coded credentials;
- assign only the permissions required by the owning service;
- configure the application service to use its database;
- run any required database migrations.
Patient Profile and Observation persistence must remain separately owned.
Installing both services on the same PostgreSQL server is allowed, but they must use separate databases and service credentials.
Services without persistence must not receive databases.
### Application/service credentials
The installer must generate the credentials needed for communication between the deployed HealthApp services.
Credentials must:
- not be hard-coded in the repository;
- be generated during installation;
- be stored in files or configuration readable only by the appropriate service account/root where practical;
- be configured automatically into the relevant services.
The administrator should not have to manually invent and distribute inter-service credentials for a normal installation.
### HTTPS certificates
The installer must configure HTTPS for the installed services.
For the prototype, certificates do not need to be publicly trusted.
The installer may generate a local/self-signed certificate or a small local certificate authority and issue certificates from it.
The goal is encrypted HTTPS communication, not public PKI validation.
The installer must:
- generate the required certificate/key material if none is supplied;
- configure each installed service to use HTTPS;
- configure the relevant local trust relationships required for HealthApp services to communicate successfully;
- protect private key material using appropriate filesystem permissions.
It should remain possible to replace the generated prototype certificates with externally supplied trusted certificates later.
### Service configuration
The installer must generate the configuration necessary for the selected deployment, including as applicable:
- listening address;
- HTTPS port;
- URLs of dependent HealthApp services;
- database connection strings;
- database credentials;
- inter-service credentials;
- certificate paths;
- environment-specific configuration.
A normal installation must not require manually editing application configuration files after installation.
### Linux service installation
For each selected HealthApp service, the installer must:
- install/publish the application;
- create the necessary service account where appropriate;
- create its systemd unit;
- enable the service;
- start the service;
- verify that it starts successfully.
### Verification
At the end of installation, perform an installation verification that checks at minimum:
- each selected systemd service is running;
- each selected service is listening on its configured HTTPS endpoint;
- required PostgreSQL databases are reachable;
- service-to-service communication works for the installed topology;
- representative application functionality works when the complete system is installed.
If installation or verification fails, report clearly which step failed.
## Deployment principle
The installer should make the selected topology work.
For example:
Machine A:
- API Gateway
- Patient Profile
- Observation
- Insights
- Health Overview
- PostgreSQL
or:
Machine A:
- API Gateway
Machine B:
- Patient Profile
- PostgreSQL
Machine C:
- Observation
- PostgreSQL
Machine D:
- Insights
Machine E:
- Health Overview
The application binaries and architectural boundaries must remain the same in either case.
Do not require the administrator to manually create PostgreSQL databases, application credentials, or prototype HTTPS certificates as a prerequisite for installation.
+5
View File
@@ -1,11 +1,16 @@
<Solution>
<Folder Name="/deploy/">
<Project Path="deploy/HealthApp.Provisioning/HealthApp.Provisioning.csproj" />
</Folder>
<Folder Name="/src/">
<Project Path="src/HealthOverviewService/HealthOverviewService.csproj" />
<Project Path="src/InsightsService/InsightsService.csproj" />
<Project Path="src/ApiGateway/ApiGateway.csproj" />
<Project Path="src/PatientProfileService/PatientProfileService.csproj" />
<Project Path="src/ObservationService/ObservationService.csproj" />
</Folder>
<Folder Name="/tests/">
<Project Path="tests/Deployment.AcceptanceTests/Deployment.AcceptanceTests.csproj" />
<Project Path="tests/Observation.AcceptanceTests/Observation.AcceptanceTests.csproj" />
<Project Path="tests/PatientProfile.AcceptanceTests/PatientProfile.AcceptanceTests.csproj" />
</Folder>
+70
View File
@@ -0,0 +1,70 @@
# HealthApp prototype
A REST/JSON backend with five independent services. There is no web interface.
## 1. Compile and package
Install the **.NET 10 SDK** on the build computer. From this repository's root, run:
```bash
bash deploy/build-release.sh --output ./healthapp-release
```
On Windows, use PowerShell instead:
```powershell
.\deploy\build-release.ps1 -Output .\healthapp-release
```
The script compiles the application and packages its installer. The output directory
must not already exist. Copy `healthapp-release` to the test computer.
## 2. Install
Open a terminal inside the copied release directory. Replace `192.168.1.20` with
the test computer's reachable IP address or DNS name.
**Debian/Ubuntu-based Linux with systemd** (also the macOS command):
```bash
sudo bash install.sh --services all --host 192.168.1.20
```
**Windows**, from an administrator PowerShell:
```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File .\install.ps1 -Services all -HostName 192.168.1.20
```
Internet access is required to download missing dependencies. The installer provisions
the runtime, PostgreSQL, databases, credentials, HTTPS and configuration, then starts
and verifies the services. Existing installations are not overwritten.
Native service installation still needs validation on the target operating systems;
see the [installation guide](deploy/INSTALLATION.md) for details and distributed deployment.
## 3. Run and use
Services start automatically after installation and on boot.
1. On a client computer, trust the generated public `healthapp-ca.crt` certificate.
2. Test the API at `https://192.168.1.20:5443/api/measurement-guidance`.
3. Retrieve the generated login details from `accounts.json`:
- Linux: `/var/lib/healthapp-installation/deployment/accounts.json`
- Windows: `%ProgramData%\HealthApp\deployment\accounts.json`
- macOS: `/Library/Application Support/HealthApp/deployment/accounts.json`
4. Use `POST /api/authentication/login` with `accountId` and `password`; send the
returned `accessToken` as a Bearer token for protected requests.
On Linux, check or restart a service with:
```bash
sudo systemctl status healthapp-api-gateway
sudo systemctl restart healthapp-api-gateway
```
Other service names are `healthapp-patient-profile`, `healthapp-observation`,
`healthapp-insights` and `healthapp-health-overview`.
See [API documentation](src/README.md) for available endpoints.
For JMeter scenarios and four-hour energy runs, see the [workload guide](tools/energy-jmeter/README.md).
@@ -0,0 +1,41 @@
using System.Text.Json;
namespace HealthApp.Provisioning;
public static class ConfigurationWriter
{
public static void Configure(string serviceDirectory, string root, string platform)
{
if (platform is not ("linux" or "windows" or "macos")) throw new InvalidOperationException("Unknown configuration platform.");
var service = Deployment.ReadService(serviceDirectory);
var directory = platform == "linux" ? Path.Combine(root, "etc", "healthapp", service.Name) : Path.Combine(root, "config", service.Name);
Directory.CreateDirectory(directory);
var destination = Path.Combine(directory, platform == "windows" ? "appsettings.Production.json" : "service.env");
if (File.Exists(destination)) throw new InvalidOperationException("Service configuration already exists; it was not overwritten.");
var env = new Dictionary<string, string>(service.Environment);
env["Kestrel__Certificates__Default__Path"] = Path.Combine(directory, "service.pfx");
if (service.Name == "api-gateway") env["Authentication__KeyDirectory"] = platform == "linux" ?
Path.Combine(root, "var", "lib", "healthapp-api-gateway", "keys") : Path.Combine(root, "state", "api-gateway", "keys");
File.Copy(Path.Combine(serviceDirectory, "service.pfx"), Path.Combine(directory, "service.pfx"));
if (platform == "windows")
{
var json = new Dictionary<string, object>();
foreach (var (key, value) in env)
{
if (key == "ASPNETCORE_ENVIRONMENT") continue; // Native service command line explicitly selects Production.
var parts = (key == "ASPNETCORE_URLS" ? "urls" : key).Split("__");
var current = json;
foreach (var part in parts[..^1])
{
if (!current.TryGetValue(part, out var child)) current[part] = child = new Dictionary<string, object>();
current = (Dictionary<string, object>)child;
}
current[parts[^1]] = value;
}
File.WriteAllText(destination, JsonSerializer.Serialize(json, Deployment.Json));
}
else File.WriteAllLines(destination, env.Select(p => p.Key + "=\"" + p.Value.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\""));
if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())
foreach (var file in Directory.GetFiles(directory)) File.SetUnixFileMode(file, UnixFileMode.UserRead | UnixFileMode.UserWrite);
}
}
@@ -0,0 +1,72 @@
using System.Diagnostics;
using System.Text.RegularExpressions;
using Npgsql;
namespace HealthApp.Provisioning;
public static class DatabaseProvisioning
{
public static async Task Create(string serviceDirectory, string? adminFile)
{
var service = Deployment.ReadService(serviceDirectory);
var database = service.Database ?? throw new InvalidOperationException("This service owns no database.");
if (!Regex.IsMatch(database.Name, "^[a-z][a-z0-9_]{1,62}$") || !Regex.IsMatch(database.User, "^[a-z][a-z0-9_]{1,62}$") ||
!Regex.IsMatch(database.Password, "^[A-F0-9]{64}$")) throw new InvalidOperationException("Generated database settings are invalid.");
var adminConnection = adminFile is null ? null : File.ReadAllText(adminFile).Trim();
async Task<string> Sql(string sql, string target = "postgres")
{
if (adminConnection is not null)
{
var settings = new NpgsqlConnectionStringBuilder(adminConnection) { Database = target, Pooling = false };
await using var connection = new NpgsqlConnection(settings.ConnectionString);
await connection.OpenAsync();
await using var command = new NpgsqlCommand(sql, connection);
var result = await command.ExecuteScalarAsync();
return result?.ToString() ?? "";
}
var start = new ProcessStartInfo("runuser") { RedirectStandardInput = true, RedirectStandardOutput = true,
RedirectStandardError = true, UseShellExecute = false };
foreach (var argument in new[] { "-u", "postgres", "--", "psql", "--no-psqlrc", "--set=ON_ERROR_STOP=1", "--tuples-only", "--no-align", "--dbname", target })
start.ArgumentList.Add(argument);
using var process = Process.Start(start) ?? throw new InvalidOperationException("Could not run PostgreSQL administration.");
var stdout = process.StandardOutput.ReadToEndAsync();
var stderr = process.StandardError.ReadToEndAsync();
await process.StandardInput.WriteAsync(sql);
process.StandardInput.Close();
using var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(30));
try { await process.WaitForExitAsync(timeout.Token); }
catch (OperationCanceledException) { process.Kill(true); throw; }
await stderr; // Never print SQL or passwords, including PostgreSQL error echoes.
if (process.ExitCode != 0) throw new InvalidOperationException("PostgreSQL administration failed; existing data was retained.");
return (await stdout).Trim();
}
static bool True(string value) => value is "t" or "True";
var userExists = True(await Sql($"SELECT EXISTS(SELECT FROM pg_roles WHERE rolname='{database.User}');"));
if (!userExists)
await Sql($"CREATE ROLE {database.User} LOGIN PASSWORD '{database.Password}' NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION;");
var exists = True(await Sql($"SELECT EXISTS(SELECT FROM pg_database WHERE datname='{database.Name}');"));
if (exists && !True(await Sql($"SELECT pg_get_userbyid(datdba)='{database.User}' FROM pg_database WHERE datname='{database.Name}';")))
throw new InvalidOperationException("Existing database has another owner; it was not changed.");
if (!exists) await Sql($"CREATE DATABASE {database.Name} OWNER {database.User};");
await Sql($"REVOKE ALL ON DATABASE {database.Name} FROM PUBLIC;");
await Sql($"REVOKE ALL ON SCHEMA public FROM PUBLIC; ALTER SCHEMA public OWNER TO {database.User}; GRANT USAGE, CREATE ON SCHEMA public TO {database.User};", database.Name);
// With an external PostgreSQL admin connection, preserve that endpoint in generated application config.
if (adminConnection is not null)
{
var admin = new NpgsqlConnectionStringBuilder(adminConnection);
database = database with { Host = admin.Host!, Port = admin.Port };
service = service with { Database = database };
var key = service.Name == "patient-profile" ? "ConnectionStrings__PatientDatabase" : "ConnectionStrings__ObservationDatabase";
service.Environment[key] = Deployment.ConnectionString(database);
File.WriteAllText(Path.Combine(serviceDirectory, "service.json"), System.Text.Json.JsonSerializer.Serialize(service, Deployment.Json));
}
await Check(database);
}
public static async Task Check(DatabaseSettings database)
{
await using var connection = new NpgsqlConnection(Deployment.ConnectionString(database));
await connection.OpenAsync();
await using var command = new NpgsqlCommand("SELECT current_user", connection);
if ((string?)await command.ExecuteScalarAsync() != database.User) throw new InvalidOperationException("Database service identity does not match.");
}
}
+157
View File
@@ -0,0 +1,157 @@
using System.Net;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text.Json;
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Identity;
using Npgsql;
namespace HealthApp.Provisioning;
public sealed class Topology
{
public Dictionary<string, string> Hosts { get; set; } = new();
public Dictionary<string, int> Ports { get; set; } = new();
public Dictionary<string, string> Platforms { get; set; } = new();
}
public sealed record DatabaseSettings(string Name, string User, string Password, string Host = "localhost", int Port = 5432);
public sealed record Account(string AccountId, string Role, string Password);
public sealed record ServiceSettings(string Name, string Host, int Port, string IncomingKey, string? OutgoingKey,
string CertificatePassword, DatabaseSettings? Database, Dictionary<string, string> Environment, string Platform = "linux");
public sealed record Deployment(string Id, Dictionary<string, ServiceSettings> Services, List<Account> Accounts)
{
public static readonly string[] Names = ["api-gateway", "patient-profile", "observation", "insights", "health-overview"];
public static readonly Dictionary<string, string> ContractNames = new()
{
["patient-profile"] = "PatientProfile", ["observation"] = "Observation",
["insights"] = "Insights", ["health-overview"] = "HealthOverview"
};
public static readonly JsonSerializerOptions Json = new() { PropertyNameCaseInsensitive = true, WriteIndented = true };
public static string Secret() => Convert.ToHexString(RandomNumberGenerator.GetBytes(32));
public static string Url(ServiceSettings service) => new UriBuilder("https", service.Host, service.Port).Uri.ToString();
public static Deployment Load(string directory) => JsonSerializer.Deserialize<Deployment>(
File.ReadAllText(Path.Combine(directory, "deployment.json")), Json) ?? throw new InvalidOperationException("Deployment is invalid.");
public static void Prepare(string output, string host, string? topologyFile, string? certificates)
{
if (Directory.Exists(output) || File.Exists(output)) throw new InvalidOperationException("Deployment output already exists; existing credentials were not changed.");
var topology = topologyFile is null ? new Topology() : JsonSerializer.Deserialize<Topology>(File.ReadAllText(topologyFile), Json)
?? throw new InvalidOperationException("Topology is invalid.");
foreach (var name in topology.Hosts.Keys.Concat(topology.Ports.Keys).Concat(topology.Platforms.Keys))
if (!Names.Contains(name)) throw new InvalidOperationException("Topology has an unknown service.");
var id = Guid.NewGuid().ToString("N")[..12];
var services = new Dictionary<string, ServiceSettings>();
var defaults = new Dictionary<string, int> { ["api-gateway"] = 5443, ["patient-profile"] = 5081,
["observation"] = 5082, ["insights"] = 5083, ["health-overview"] = 5084 };
foreach (var name in Names)
{
var hostname = topology.Hosts.GetValueOrDefault(name, host);
if (Uri.CheckHostName(hostname) == UriHostNameType.Unknown || hostname.Contains('%'))
throw new InvalidOperationException("Provide a valid DNS name or IP address for each service host.");
var port = topology.Ports.GetValueOrDefault(name, defaults[name]);
if (port < 1024 || port > 65535) throw new InvalidOperationException("HTTPS ports must be between 1024 and 65535.");
DatabaseSettings? database = name switch
{
"patient-profile" => new("healthapp_" + id + "_profile", "healthapp_" + id + "_profile", Secret()),
"observation" => new("healthapp_" + id + "_observation", "healthapp_" + id + "_observation", Secret()), _ => null
};
var platform = topology.Platforms.GetValueOrDefault(name, OperatingSystem.IsWindows() ? "windows" : OperatingSystem.IsMacOS() ? "macos" : "linux");
if (platform is not ("linux" or "windows" or "macos")) throw new InvalidOperationException("Unsupported node platform.");
services[name] = new(name, hostname, port, Secret(), name is "api-gateway" or "patient-profile" ? null : Secret(),
Secret(), database, new(), platform);
}
if (services.Values.GroupBy(s => (s.Host.ToLowerInvariant(), s.Port)).Any(g => g.Count() > 1))
throw new InvalidOperationException("Colocated services need distinct HTTPS ports.");
var accounts = new List<Account> { new("prototype-patient", "Patient", Secret()),
new("prototype-professional", "HealthcareProfessional", Secret()), new("installation-check", "Patient", Secret()) };
var deployment = new Deployment(id, services, accounts);
foreach (var service in services.Values)
{
var env = service.Environment;
env["ASPNETCORE_ENVIRONMENT"] = "Production";
env["ASPNETCORE_URLS"] = "https://0.0.0.0:" + service.Port;
env["InternalAccess__GatewayKey"] = service.IncomingKey;
env["Kestrel__Certificates__Default__Path"] = $"/etc/healthapp/{service.Name}/service.pfx";
env["Kestrel__Certificates__Default__Password"] = service.CertificatePassword;
if (service.Name == "api-gateway")
{
env["Authentication__KeyDirectory"] = "/var/lib/healthapp-api-gateway/keys";
foreach (var (name, contract) in ContractNames)
{
env[$"Services__{contract}__BaseUrl"] = Url(services[name]);
env[$"Services__{contract}__Key"] = services[name].IncomingKey;
if (services[name].OutgoingKey is { } key) env[$"InternalAccess__{contract}__Key"] = key;
}
for (var index = 0; index < accounts.Count; index++)
{
var account = accounts[index];
env[$"Authentication__Accounts__{index}__AccountId"] = account.AccountId;
env[$"Authentication__Accounts__{index}__Role"] = account.Role;
env[$"Authentication__Accounts__{index}__PasswordHash"] = new PasswordHasher<Account>().HashPassword(account, account.Password);
}
}
else if (service.OutgoingKey is not null)
{
env["Services__ApiGateway__BaseUrl"] = Url(services["api-gateway"]);
env["Services__ApiGateway__Key"] = service.OutgoingKey;
}
if (service.Database is { } db)
env[service.Name == "patient-profile" ? "ConnectionStrings__PatientDatabase" : "ConnectionStrings__ObservationDatabase"] = ConnectionString(db);
}
Directory.CreateDirectory(output);
if ((OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())) File.SetUnixFileMode(output, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute);
using var caKey = RSA.Create(3072);
var caRequest = new CertificateRequest("CN=HealthApp prototype " + id, caKey, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
caRequest.CertificateExtensions.Add(new X509BasicConstraintsExtension(true, false, 0, true));
caRequest.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.KeyCertSign | X509KeyUsageFlags.CrlSign, true));
caRequest.CertificateExtensions.Add(new X509SubjectKeyIdentifierExtension(caRequest.PublicKey, false));
using var ca = caRequest.CreateSelfSigned(DateTimeOffset.UtcNow.AddMinutes(-5), DateTimeOffset.UtcNow.AddYears(2));
// Only the public CA is needed on installed nodes; no signing key is retained.
File.WriteAllText(Path.Combine(output, "healthapp-ca.crt"), certificates is null ? ca.ExportCertificatePem() :
File.ReadAllText(Path.Combine(certificates, "healthapp-ca.crt")));
foreach (var service in services.Values)
{
var directory = Path.Combine(output, service.Name);
Directory.CreateDirectory(directory);
File.WriteAllText(Path.Combine(directory, "service.json"), JsonSerializer.Serialize(service, Json));
File.WriteAllLines(Path.Combine(directory, "service.env"), service.Environment.Select(e => e.Key + "=" + Quote(e.Value)));
byte[] pfx;
if (certificates is not null)
{
var password = File.ReadAllText(Path.Combine(certificates, service.Name + ".password")).TrimEnd('\r', '\n');
var supplied = X509CertificateLoader.LoadPkcs12CollectionFromFile(Path.Combine(certificates, service.Name + ".pfx"), password);
if (!supplied.Cast<X509Certificate2>().Any(c => c.HasPrivateKey)) throw new InvalidOperationException("Supplied certificate has no private key.");
pfx = supplied.Export(X509ContentType.Pfx, service.CertificatePassword)!;
foreach (var certificate in supplied) certificate.Dispose();
}
else
{
using var key = RSA.Create(2048);
var request = new CertificateRequest("CN=" + service.Host, key, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
request.CertificateExtensions.Add(new X509BasicConstraintsExtension(false, false, 0, true));
request.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.DigitalSignature | X509KeyUsageFlags.KeyEncipherment, true));
request.CertificateExtensions.Add(new X509EnhancedKeyUsageExtension(new System.Security.Cryptography.OidCollection { new("1.3.6.1.5.5.7.3.1") }, true));
var san = new SubjectAlternativeNameBuilder();
if (IPAddress.TryParse(service.Host, out var ip)) san.AddIpAddress(ip); else san.AddDnsName(service.Host);
request.CertificateExtensions.Add(san.Build());
using var leaf = request.Create(ca, DateTimeOffset.UtcNow.AddMinutes(-2), DateTimeOffset.UtcNow.AddYears(1), RandomNumberGenerator.GetBytes(16));
using var withKey = leaf.CopyWithPrivateKey(key);
pfx = withKey.Export(X509ContentType.Pfx, service.CertificatePassword);
}
File.WriteAllBytes(Path.Combine(directory, "service.pfx"), pfx);
}
File.WriteAllText(Path.Combine(output, "deployment.json"), JsonSerializer.Serialize(deployment, Json));
File.WriteAllText(Path.Combine(output, "accounts.json"), JsonSerializer.Serialize(accounts, Json));
if ((OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()))
foreach (var file in Directory.EnumerateFiles(output, "*", SearchOption.AllDirectories))
File.SetUnixFileMode(file, UnixFileMode.UserRead | UnixFileMode.UserWrite);
}
public static string ConnectionString(DatabaseSettings db) => new NpgsqlConnectionStringBuilder
{
Host = db.Host, Port = db.Port, Database = db.Name, Username = db.User, Password = db.Password,
SslMode = SslMode.Prefer, Timeout = 10, Pooling = false
}.ConnectionString;
private static string Quote(string value) => "\"" + value.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"";
public static ServiceSettings ReadService(string directory) => JsonSerializer.Deserialize<ServiceSettings>(
File.ReadAllText(Path.Combine(directory, "service.json")), Json) ?? throw new InvalidOperationException("Service configuration is invalid.");
}
@@ -0,0 +1,93 @@
using System.Diagnostics;
using System.Text.Json;
using System.Text.RegularExpressions;
namespace HealthApp.Provisioning;
public static class Distribution
{
public static async Task Deploy(string bundle, string directory, string user, string[] selected)
{
if (!Regex.IsMatch(user, "^[a-zA-Z_][a-zA-Z0-9_-]*$")) throw new InvalidOperationException("SSH user is invalid.");
var deployment = Deployment.Load(directory);
async Task Run(string command, params string[] args)
{
var start = new ProcessStartInfo(command) { UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true };
foreach (var argument in args) start.ArgumentList.Add(argument);
using var process = Process.Start(start) ?? throw new InvalidOperationException("Could not run deployment transport.");
var stdout = process.StandardOutput.ReadToEndAsync();
var stderr = process.StandardError.ReadToEndAsync();
using var timeout = new CancellationTokenSource(TimeSpan.FromMinutes(20));
try { await process.WaitForExitAsync(timeout.Token); }
catch (OperationCanceledException) { process.Kill(true); throw; }
await stdout;
var errors = await stderr;
if (process.ExitCode != 0)
{
var reportedStep = errors.Split('\n').LastOrDefault(line => line.StartsWith("Installation failed at ", StringComparison.Ordinal));
throw new InvalidOperationException(reportedStep ?? "SSH deployment transport failed; check administrative SSH access and node installation logs.");
}
}
var temporary = Path.Combine(Path.GetTempPath(), "healthapp-distribution-" + Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(temporary);
if (OperatingSystem.IsLinux()) File.SetUnixFileMode(temporary, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute);
try
{
foreach (var group in selected.GroupBy(n => deployment.Services[n].Host, StringComparer.OrdinalIgnoreCase))
{
var names = group.ToArray();
var node = Path.Combine(temporary, "node-" + Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(node);
var material = Path.Combine(node, "deployment");
Directory.CreateDirectory(material);
foreach (var script in Directory.GetFiles(bundle).Where(p => p.EndsWith(".sh") || p.EndsWith(".ps1"))) File.Copy(script, Path.Combine(node, Path.GetFileName(script)));
CopyDirectory(Path.Combine(bundle, "provisioner"), Path.Combine(node, "provisioner"));
Directory.CreateDirectory(Path.Combine(node, "services"));
Directory.CreateDirectory(Path.Combine(node, "systemd"));
foreach (var name in names)
{
CopyDirectory(Path.Combine(bundle, "services", name), Path.Combine(node, "services", name));
CopyDirectory(Path.Combine(directory, name), Path.Combine(material, name));
File.Copy(Path.Combine(bundle, "systemd", "healthapp-" + name + ".service"), Path.Combine(node, "systemd", "healthapp-" + name + ".service"));
}
// Retain remote origins, but do not give a node unrelated service/database/private-key credentials.
var scoped = deployment with
{
Services = deployment.Services.ToDictionary(p => p.Key, p => names.Contains(p.Key) ? p.Value :
p.Value with { IncomingKey = "", OutgoingKey = null, CertificatePassword = "", Database = null, Environment = new() }),
Accounts = names.Contains("api-gateway") ? deployment.Accounts : []
};
File.WriteAllText(Path.Combine(material, "deployment.json"), JsonSerializer.Serialize(scoped, Deployment.Json));
if (names.Contains("api-gateway")) File.Copy(Path.Combine(directory, "accounts.json"), Path.Combine(material, "accounts.json"));
File.Copy(Path.Combine(directory, "healthapp-ca.crt"), Path.Combine(material, "healthapp-ca.crt"));
var target = user + "@" + group.Key;
var windows = names.All(n => deployment.Services[n].Platform == "windows");
if (names.Any(n => deployment.Services[n].Platform == "windows") && !windows)
throw new InvalidOperationException("One host cannot use two native service managers.");
var remote = windows ? "C:/ProgramData/healthapp-install-" + deployment.Id : "/var/tmp/healthapp-install-" + deployment.Id;
Console.WriteLine("Install selected node: " + group.Key);
if (windows)
await Run("ssh", target, "powershell", "-NoProfile", "-NonInteractive", "-Command",
"New-Item -ItemType Directory -Path '" + remote + "' | Out-Null");
else await Run("ssh", target, "mkdir", "-m", "0700", remote);
var scpHost = group.Key.Contains(':') ? user + "@[" + group.Key + "]" : target;
await Run("scp", "-r", node + "/.", scpHost + ":" + remote + "/");
if (windows)
await Run("ssh", target, "powershell", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", remote + "/install.ps1", "-Services", string.Join(',', names),
"-Deployment", remote + "/deployment", "-DeferTopologyCheck");
else await Run("ssh", target, "sudo", "-n", "bash", remote + "/install.sh", "--services", string.Join(',', names),
"--deployment", remote + "/deployment", "--defer-topology-check");
}
// Services communicate through the actual HTTPS origins on their installed hosts.
await InstallationVerification.Verify(directory, selected, selected.Length == Deployment.Names.Length);
Console.WriteLine("Distributed topology verification passed.");
}
finally { Directory.Delete(temporary, true); }
}
private static void CopyDirectory(string source, string destination)
{
Directory.CreateDirectory(destination);
foreach (var file in Directory.GetFiles(source)) File.Copy(file, Path.Combine(destination, Path.GetFileName(file)));
foreach (var child in Directory.GetDirectories(source)) CopyDirectory(child, Path.Combine(destination, Path.GetFileName(child)));
}
}
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType><TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable><ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Npgsql" Version="10.0.3" />
</ItemGroup>
</Project>
@@ -0,0 +1,126 @@
using System.Net;
using System.Security.Cryptography;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;
namespace HealthApp.Provisioning;
public static class InstallationVerification
{
public static async Task Verify(string deploymentDirectory, string[] selected, bool complete, bool startupOnly = false)
{
var deployment = Deployment.Load(deploymentDirectory);
using var root = X509CertificateLoader.LoadCertificateFromFile(Path.Combine(deploymentDirectory, "healthapp-ca.crt"));
using var handler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (_, certificate, _, errors) =>
{
if (certificate is null || (errors & (SslPolicyErrors.RemoteCertificateNameMismatch | SslPolicyErrors.RemoteCertificateNotAvailable)) != 0) return false;
using var chain = new X509Chain();
chain.ChainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust;
chain.ChainPolicy.CustomTrustStore.Add(root);
chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;
chain.ChainPolicy.ApplicationPolicy.Add(new Oid("1.3.6.1.5.5.7.3.1"));
return chain.Build(certificate);
}
};
using var client = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(15), BaseAddress = new Uri(Deployment.Url(deployment.Services["api-gateway"])) };
async Task<HttpResponseMessage> Probe(Func<HttpRequestMessage> create, string name)
{
using var deadline = new CancellationTokenSource(TimeSpan.FromSeconds(30));
while (true)
{
try
{
using var request = create();
var response = await client.SendAsync(request, deadline.Token);
if (response.StatusCode is not (HttpStatusCode.BadGateway or HttpStatusCode.ServiceUnavailable or HttpStatusCode.GatewayTimeout)) return response;
response.Dispose();
}
catch (HttpRequestException) { }
catch (OperationCanceledException) when (!deadline.IsCancellationRequested) { }
try { await Task.Delay(500, deadline.Token); }
catch (OperationCanceledException) { throw new InvalidOperationException("HTTPS startup/dependency probe timed out for " + name + "."); }
}
}
foreach (var name in selected)
{
var service = deployment.Services[name];
if (Deployment.ReadService(Path.Combine(deploymentDirectory, name)).Database is { } database)
{
try { await DatabaseProvisioning.Check(database); }
catch { throw new InvalidOperationException("Dedicated database reachability verification failed for " + name + "."); }
}
// Correct incoming credentials prove network/TLS and the configured service trust boundary.
var path = Deployment.Url(service) +
(name == "api-gateway" ? "api/measurement-guidance" : startupOnly ? "" : "api/patients/00000000-0000-0000-0000-000000000001" +
(name == "insights" ? "/insights?from=2026-01-01&to=2026-01-02" :
name == "health-overview" ? "/overview?from=2026-01-01&to=2026-01-02" :
name == "observation" ? "/observations?from=2026-01-01&to=2026-01-02" : ""));
using var response = await Probe(() =>
{
var request = new HttpRequestMessage(HttpMethod.Get, path);
if (name != "api-gateway") request.Headers.Add("X-Gateway-Key", service.IncomingKey);
return request;
}, name);
if (response.StatusCode is not (HttpStatusCode.OK or HttpStatusCode.NotFound))
throw new InvalidOperationException("HTTPS/dependency verification failed for " + name + " (HTTP " + (int)response.StatusCode + ").");
}
if (startupOnly) return;
// Exercise each installed service's configured outgoing gateway credentials using its actual network API.
foreach (var name in selected.Where(n => n is "observation" or "insights" or "health-overview"))
{
var service = deployment.Services[name];
using var request = new HttpRequestMessage(HttpMethod.Get, Deployment.Url(deployment.Services["api-gateway"]) +
"api/patients/00000000-0000-0000-0000-000000000001" + (name == "insights" ? "/observations?from=2026-01-01&to=2026-01-02" : ""));
request.Headers.Add("X-Service-Key", service.OutgoingKey);
using var response = await client.SendAsync(request);
if (response.StatusCode is not (HttpStatusCode.OK or HttpStatusCode.NotFound))
throw new InvalidOperationException("Gateway service-credential verification failed for " + name + ".");
}
if (!complete) return;
var account = deployment.Accounts.Single(a => a.AccountId == "installation-check");
using var login = await client.PostAsJsonAsync("api/authentication/login", new { accountId = account.AccountId, password = account.Password });
login.EnsureSuccessStatusCode();
using var token = JsonDocument.Parse(await login.Content.ReadAsStringAsync());
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.RootElement.GetProperty("accessToken").GetString());
using var current = await client.GetAsync("api/patients/me");
Guid patient;
if (current.StatusCode == HttpStatusCode.NotFound)
{
using var created = await client.PostAsJsonAsync("api/patients", new { name = "Installer verification (synthetic)", dateOfBirth = "1980-01-01" });
created.EnsureSuccessStatusCode();
using var profile = JsonDocument.Parse(await created.Content.ReadAsStringAsync());
patient = profile.RootElement.GetProperty("patientId").GetGuid();
}
else
{
current.EnsureSuccessStatusCode();
using var profile = JsonDocument.Parse(await current.Content.ReadAsStringAsync());
patient = profile.RootElement.GetProperty("patientId").GetGuid();
}
using var latest = await client.GetAsync($"api/patients/{patient}/observations/latest");
if (latest.StatusCode == HttpStatusCode.NotFound)
{
using var record = await client.PostAsJsonAsync($"api/patients/{patient}/observations", new
{
measuredAt = DateTime.UtcNow, systolic = 120, diastolic = 80, pulse = 60,
note = "Installer verification; synthetic data", measurementContext = new { setting = "Home", activityCondition = "AtRest" }
});
record.EnsureSuccessStatusCode();
}
else latest.EnsureSuccessStatusCode();
var bounds = $"from=2000-01-01&to={Uri.EscapeDataString(DateTime.UtcNow.AddDays(1).ToString("O"))}&setting=Home&activityCondition=AtRest";
using var overview = await client.GetAsync($"api/patients/{patient}/overview?{bounds}");
overview.EnsureSuccessStatusCode();
using var result = JsonDocument.Parse(await overview.Content.ReadAsStringAsync());
if (result.RootElement.GetProperty("patient").GetProperty("patientId").GetGuid() != patient ||
result.RootElement.GetProperty("latestObservation").ValueKind != JsonValueKind.Object ||
result.RootElement.GetProperty("insight").ValueKind != JsonValueKind.Object ||
result.RootElement.GetProperty("insightContributingCount").GetInt32() < 1)
throw new InvalidOperationException("Representative complete-system workflow did not return profile, latest observation and insight.");
}
}
@@ -0,0 +1,32 @@
using System.Text.Json;
using System.Xml.Linq;
namespace HealthApp.Provisioning;
public static class LaunchdWriter
{
public static void Write(string service, string root, string dotnet, string output)
{
if (!Deployment.Names.Contains(service)) throw new InvalidOperationException("Unknown service.");
var directory = Path.Combine(root, "services", service);
var assembly = service switch { "api-gateway" => "ApiGateway", "patient-profile" => "PatientProfileService",
"observation" => "ObservationService", "insights" => "InsightsService", _ => "HealthOverviewService" };
var environment = new XElement("dict");
foreach (var line in File.ReadAllLines(Path.Combine(root, "config", service, "service.env")))
{
var position = line.IndexOf('=');
environment.Add(new XElement("key", line[..position]), new XElement("string", JsonSerializer.Deserialize<string>(line[(position + 1)..])));
}
var document = new XDocument(new XDeclaration("1.0", "utf-8", null),
new XDocumentType("plist", "-//Apple//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null),
new XElement("plist", new XAttribute("version", "1.0"), new XElement("dict",
new XElement("key", "Label"), new XElement("string", "healthapp-" + service),
new XElement("key", "ProgramArguments"), new XElement("array", new XElement("string", dotnet), new XElement("string", Path.Combine(directory, assembly + ".dll"))),
new XElement("key", "WorkingDirectory"), new XElement("string", directory),
new XElement("key", "UserName"), new XElement("string", "_healthapp_" + service.Replace('-', '_')),
new XElement("key", "EnvironmentVariables"), environment,
new XElement("key", "RunAtLoad"), new XElement("true"), new XElement("key", "KeepAlive"), new XElement("true"))));
document.Save(output);
if (!OperatingSystem.IsWindows()) File.SetUnixFileMode(output, UnixFileMode.UserRead | UnixFileMode.UserWrite);
}
}
+83
View File
@@ -0,0 +1,83 @@
using System.Text.Json;
namespace HealthApp.Provisioning;
public static class Program
{
public static async Task<int> Main(string[] args)
{
var command = args.FirstOrDefault() ?? "";
try
{
var options = new Dictionary<string, string>();
for (var index = 1; index < args.Length; index += 2)
{
if (index + 1 >= args.Length || !args[index].StartsWith("--") || !options.TryAdd(args[index][2..], args[index + 1]))
throw new InvalidOperationException("Invalid provisioning arguments.");
}
string Required(string key) => options.GetValueOrDefault(key) ?? throw new InvalidOperationException("Missing argument: " + key);
switch (command)
{
case "launchd":
LaunchdWriter.Write(Required("service"), Required("root"), Required("dotnet"), Required("output"));
break;
case "secret":
File.WriteAllText(Required("output"), Deployment.Secret());
if (!OperatingSystem.IsWindows()) File.SetUnixFileMode(Required("output"), UnixFileMode.UserRead | UnixFileMode.UserWrite);
break;
case "admin-connection":
var admin = new Npgsql.NpgsqlConnectionStringBuilder { Host = "localhost", Port = int.Parse(Required("port")),
Username = "postgres", Database = "postgres", Password = File.ReadAllText(Required("password-file")).Trim(), Pooling = false };
File.WriteAllText(Required("output"), admin.ConnectionString);
if (!OperatingSystem.IsWindows()) File.SetUnixFileMode(Required("output"), UnixFileMode.UserRead | UnixFileMode.UserWrite);
break;
case "execute":
var native = options.GetValueOrDefault("platform", "macos");
var serviceName = Required("service");
if (!Deployment.Names.Contains(serviceName)) throw new InvalidOperationException("Unknown selected service.");
var rootPath = Required("root");
var config = Path.Combine(rootPath, "config", serviceName, "service.env");
var start = new System.Diagnostics.ProcessStartInfo(Required("dotnet")) { UseShellExecute = false,
WorkingDirectory = Path.Combine(rootPath, "services", serviceName) };
start.ArgumentList.Add(Required("assembly"));
start.ArgumentList.Add("--migrate");
foreach (var line in File.ReadAllLines(config))
start.Environment[line[..line.IndexOf('=')]] = JsonSerializer.Deserialize<string>(line[(line.IndexOf('=') + 1)..])!;
using (var process = System.Diagnostics.Process.Start(start)!)
{
await process.WaitForExitAsync();
if (process.ExitCode != 0) throw new InvalidOperationException("Selected service migration failed.");
}
break;
case "prepare":
Deployment.Prepare(Required("output"), options.GetValueOrDefault("host", "localhost"), options.GetValueOrDefault("topology"), options.GetValueOrDefault("certificates"));
break;
case "database":
await DatabaseProvisioning.Create(Required("service-dir"), options.GetValueOrDefault("admin-file"));
break;
case "configure":
ConfigurationWriter.Configure(Required("service-dir"), Required("root"), options.GetValueOrDefault("platform", "linux"));
break;
case "distribute":
var names = Required("services").Split(',');
if (names.Any(n => !Deployment.Names.Contains(n))) throw new InvalidOperationException("Unknown distribution service.");
await Distribution.Deploy(Required("bundle"), Required("deployment"), Required("ssh-user"), names);
break;
case "verify-startup":
case "verify":
var selected = Required("services").Split(',');
if (selected.Any(n => !Deployment.Names.Contains(n))) throw new InvalidOperationException("Unknown verification service.");
await InstallationVerification.Verify(Required("deployment"), selected, options.GetValueOrDefault("complete") == "true", command == "verify-startup");
break;
default: throw new InvalidOperationException("Unknown provisioning command.");
}
return 0;
}
catch (Exception error)
{
Console.Error.WriteLine($"Provisioning step '{command}' failed: " + (error is InvalidOperationException ? error.Message : error.GetType().Name) +
" No credentials are printed; inspect the relevant service logs.");
return 1;
}
}
}
+258
View File
@@ -0,0 +1,258 @@
# US-16 — Provision and install HealthApp
The installer provisions a working prototype topology. A normal installation no longer
requires prepared application configuration, database roles/passwords, service keys,
or HTTPS certificates. Select one service, a comma-separated subset, or `all`.
The application DLLs and shared C# provisioning utility are portable. OS adapters
perform package installation and native service registration: systemd on supported
Linux hosts, Windows Services on Windows, and launchd on macOS. Deployment location
and OS do not combine services, introduce shared persistence or change gateway-routed
communication. There is no container/orchestration requirement.
## Build the release
A build machine needs the .NET 10 SDK and package access. It is distinct from a target
machine, where the installer supplies missing runtime/dependencies.
```bash
bash deploy/build-release.sh --output /tmp/healthapp-release
# Optional: build just a selected application's payload plus the provisioning utility.
bash deploy/build-release.sh --output /tmp/healthapp-insights --services insights
```
On a Windows build machine, use `deploy/build-release.ps1 -Output NEW_DIRECTORY`
from PowerShell with the same optional `-Services` selection.
The bundle includes the application DLLs, provisioning utility, OS installers, units,
examples and this guide. Windows services invoke `dotnet Application.dll`, so they do
not depend on a Linux-generated apphost executable. The small Microsoft WindowsServices
hosting dependency lets the same ASP.NET Core applications respond to Windows service
control; it is inactive on Linux/macOS. No production service references another service.
Transfer the release by normal administrative deployment transport. Public release
files contain no generated secrets. Build output must be a new directory.
## Normal Ubuntu/Debian installation
Automatic Linux provisioning accepts Debian/Ubuntu ancestry (`ID` or `ID_LIKE`),
with apt, a running systemd manager and administrative access. It checks actual package
availability rather than a fixed distribution/version list. Internet access to configured
package feeds is needed when dependencies are absent. Existing .NET 10 ASP.NET Core
runtime and PostgreSQL installations are reused where available.
The installer prefers configured distribution feeds. On Debian itself, if the runtime
package is absent, it attempts Microsoft's repository for that Debian VERSION_ID.
Derivatives use their own configured feeds; their version numbers are never passed to
an upstream repository. If no compatible runtime source or PostgreSQL package is
available, installation stops with a specific dependency error. Debian ancestry alone
does not guarantee .NET/CPU compatibility; startup and topology verification still apply.
From the release directory:
```bash
sudo bash install.sh --services all --host 192.168.1.20
```
Use the target's reachable DNS name/IP for `--host`. The default `localhost` is useful
for a wholly local prototype; use a reachable address for another computer to access
it. No later application-file editing is required.
For an individual service, use its name and an existing matching generated deployment
from the overall topology, which already specifies its remote dependencies/keys:
```bash
sudo bash install.sh --services insights --deployment /secure/generated-deployment
```
Names: `api-gateway`, `patient-profile`, `observation`, `insights`, `health-overview`.
The installer:
1. Detects .NET 10 ASP.NET Core runtime and local PostgreSQL availability; installs
missing dependencies from supported package feeds. PostgreSQL is provisioned only
when Patient/Profile or Observation is selected.
2. Generates a private deployment plan, independent service keys and synthetic
prototype accounts. No hard-coded passwords or hand-written password hashes are used.
3. Creates a private prototype CA and separate service certificates, installs the
public CA into OS trust, and configures Production HTTPS endpoints.
4. Creates separate PostgreSQL databases and login roles for the selected persistent
services. Roles cannot administer the server/create roles/databases or connect to
the other service's database. Schema ownership supports that service's migrations.
5. Creates independent service identities, application/configuration directories and
service registrations. Runs the selected persistent services' migrations, enables
and starts every selected application, then verifies startup and topology.
Linux application/configuration paths are `/opt/healthapp/NAME` and
`/etc/healthapp/NAME/service.env`. Env files are root-only; systemd passes their values
to the owning process. Certificate private keys are readable only by root and the
respective service identity. Units use `healthapp-NAME` users/groups, not a shared
application identity. Gateway key state remains gateway-owned.
Generated material normally resides at `/var/lib/healthapp-installation/deployment`
with a private directory and private files. `accounts.json` contains generated
`prototype-patient`, `prototype-professional` and `installation-check` passwords.
The professional starts without assignments. Do not put generated material in Git.
Only the CA's public certificate is installed/exported publicly; its signing private
key is not retained. Certificates expire after one year; the prototype CA after two.
## Topology and distributed installation
A topology specifies addresses, ports and native platforms, not credentials. Defaults
are HTTPS ports 5443/5081/5082/5083/5084. Colocated applications need different ports.
For example:
```json
{
"hosts": {
"api-gateway": "192.168.1.20",
"patient-profile": "192.168.1.21",
"observation": "192.168.1.22",
"insights": "192.168.1.23",
"health-overview": "192.168.1.24"
},
"platforms": {
"api-gateway": "linux",
"patient-profile": "linux",
"observation": "linux",
"insights": "macos",
"health-overview": "windows"
}
}
```
Optional `ports` uses the same service keys and integer values. Hostnames/IPs must
resolve/reach the corresponding target. Supply existing administrative SSH access;
Unix hosts need passwordless sudo for the installer, Windows SSH sessions must be
elevated administrators. Host administration credentials are distinct from generated
HealthApp/database credentials and are not invented by the application installer.
Generate one consistent deployment and automatically distribute matching, scoped
material to each host:
```bash
sudo bash install.sh --services all --prepare-only --topology topology.json \
--deployment /secure/healthapp-deployment --dotnet /path/to/available/dotnet
bash distribute.sh --deployment /secure/healthapp-deployment --ssh-user administrator
```
Use an administrative session able to read the protected deployment material. The
preparation machine needs an available .NET 10 runtime/SDK for the C# utility.
Distribution uses SSH/SCP, installs only selected applications per host, and exports
only their private material plus necessary remote origins. It starts nodes first,
then verifies the complete topology over its real HTTPS endpoints. No credentials
are manually invented, copied into application files or distributed individually.
Services never depend on a shared runtime directory/file across machines.
A node started with the orchestrator's `--defer-topology-check` has verified local
process/HTTPS/database readiness but pending cross-node verification. It is not
reported as a verified complete topology until the orchestrator's final check passes.
For incremental installation, reuse the same deployment; independently generated
plans deliberately have different keys and cannot authenticate to each other.
## Windows and macOS adapters
On Windows, from an elevated PowerShell session in the release:
```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File .\install.ps1 -Services all -HostName 192.168.1.20
```
The adapter installs the .NET runtime automatically, resolves and checksum-verifies
an EDB PostgreSQL installer from Microsoft's package manifest, creates an owned
PostgreSQL service when needed, and generates its administrator secret in protected
files. Existing application/data files are not overwritten. An existing externally
managed PostgreSQL server can instead be used with `-PostgresAdminFile`; the installer
still generates application database roles/passwords automatically.
Applications have separate native Windows Services and virtual service identities,
protected per-service JSON configuration, state and certificate ACLs. Their Production
configuration is installed automatically; certificates are trusted in LocalMachine
Root. HTTPS firewall rules cover only selected application ports. No IIS is required.
Windows uses `-Deployment`, `-Topology`, `-Certificates` for the same shared material.
Default application root is `%ProgramData%\HealthApp`.
On macOS, from a sudo administrator session:
```bash
sudo bash install.sh --services all --host 192.168.1.20
```
The Darwin adapter installs the ASP.NET Core runtime, provisions Homebrew/PostgreSQL
and required Apple build tools where available through softwareupdate, initializes
an installer-owned PostgreSQL cluster with SCRAM passwords, and creates separate
hidden service identities and launchd daemons. It configures system-keychain CA trust,
private environment/launchd files and selected migrations automatically. Default root
is `/Library/Application Support/HealthApp`. macOS package/tool installation requires
an administrator user session, network access, and acceptance of OS/vendor licensing.
The adapters target supported .NET desktop/server operating systems. Portability does
not claim support for every OS/kernel/version/CPU where .NET itself is unavailable.
The live Windows/macOS registration paths need native-host validation; see evidence
limits below. The Linux execution environment cannot run Windows SCM or macOS launchd.
## Verification and management
Installation verifies distinct native processes, configured HTTPS endpoints, selected
databases using their dedicated credentials, actual service keys and outgoing gateway
access. The complete-system check logs in with the generated `installation-check`
account and exercises profile/observation/Overview through all deployed services.
It creates at most one clearly labelled synthetic check profile/observation if absent.
This is prototype test data, not a clinical reading; repeated verification reuses it.
The verifier trusts the generated public CA, validates certificate chains/server names,
and never disables TLS validation. Existing HTTPS trust is retained. All step failures
identify the failed operation/service and retain existing data/material for inspection.
Sensitive SQL/credentials are not printed. Existing applications/configuration cause
refusal rather than silent replacement; this remains a first-install mechanism,
not an upgrade/uninstall/data-removal tool. Deployment is not a cross-service transaction.
Linux may rerun `sudo bash verify.sh --services all --deployment DIRECTORY` from the
bundle. Manage selected units with `systemctl start/stop/restart healthapp-NAME`.
Windows uses `Start-Service`, `Stop-Service`, `Restart-Service`; macOS uses
`launchctl bootstrap`, `bootout`, `kickstart` on `healthapp-NAME` labels. Stopping a
service does not directly stop peer processes; requests needing it may fail.
External trusted certificates can be supplied during preparation with `--certificates`
or `-Certificates`. The directory supplies `NAME.pfx`, `NAME.password` for all five
planned services and `healthapp-ca.crt`. Supplied PFX certificate chains are retained;
private keys/passwords are protected and configured automatically. Prototype browser
clients may import the exported public CA for trust; server-side service trust is
configured automatically by installation.
`--root DIRECTORY` on Linux is explicitly offline staging: it generates the same
settings/material but cannot install host packages or register/start systemd. It is
not reported as a live verified installation. `--postgres-admin-file` allows automated
DB provisioning against an externally managed/test server, not manual application
DB/user preparation. Normal Linux installation administers local PostgreSQL through
its OS postgres identity without inventing a PostgreSQL administrator password.
## Evidence and dependencies
The xUnit deployment suite builds the release, calls the actual provisioner/installer,
creates database roles/databases in an isolated PostgreSQL server and runs all five
installed services in separate Production-mode HTTPS processes. Tests cover generated
key matching/uniqueness, certificate private-key output, private configuration, database
isolation/permissions, migrations, native-format configuration, independent restart,
representative functionality and repeated non-destructive verification. Package command
contracts are tested with controlled command doubles; no host package installation
is performed by the tests. The ordinary application tests remain unchanged.
Linux HTTPS/interservice/database execution is verified here. Live systemd package/
registration behaviour needs a supported Linux host; Windows/macOS service registration
needs those native hosts. Native configuration formats are exercised by the shared
utility tests; shell/PowerShell syntax validation is separate from a native end-to-end
run. The manual `.github/workflows/prototype-native-install.yml` workflow provisions
and verifies fresh Ubuntu, Windows and macOS runners; it is supplied for native
validation and has not been executed remotely in this session. These limits must not be described as verified production deployment on every OS.
The provisioning tool uses standard .NET X.509/password hashing and Npgsql for creating
and checking databases. Its dependency is not a shared service runtime library.
Microsoft.Extensions.Hosting.WindowsServices is added to the five services solely for
native Windows service lifetime integration; Linux/macOS responsibilities are unchanged.
Package/lifetime references reviewed during implementation:
[Ubuntu runtime installation](https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu-install),
[Debian runtime installation](https://learn.microsoft.com/en-us/dotnet/core/install/linux-debian),
[Windows service hosting](https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/windows-service?view=aspnetcore-10.0),
[EDB unattended installer parameters](https://www.enterprisedb.com/docs/supported-open-source/postgresql/installing/command_line_parameters/).
+28 -3
View File
@@ -1,8 +1,33 @@
ASPNETCORE_ENVIRONMENT=Production
Services__PatientProfile__BaseUrl=http://patient-profile.example.test:5081/
Services__PatientProfile__BaseUrl=https://patient-profile.example.test:5081/
ASPNETCORE_URLS=https://0.0.0.0:5443
Kestrel__Certificates__Default__Path=/etc/healthapp/gateway.pfx
Kestrel__Certificates__Default__Password=REPLACE_ME
Services__Observation__BaseUrl=http://observation.example.test:5082/
Services__Observation__BaseUrl=https://observation.example.test:5082/
Services__Insights__BaseUrl=http://insights.example.test:5083/
Services__Insights__BaseUrl=https://insights.example.test:5083/
Authentication__KeyDirectory=/var/lib/healthapp-api-gateway/keys
Authentication__TokenLifetimeMinutes=30
# Account identifiers support ASCII letters, digits, hyphen and underscore.
Authentication__Accounts__0__AccountId=example-patient
Authentication__Accounts__0__Role=Patient
Authentication__Accounts__0__PasswordHash=REPLACE_WITH_ASPNET_CORE_PASSWORD_HASH
# Use distinct randomly generated credentials of at least 32 characters.
Services__PatientProfile__Key=REPLACE_ME
Services__Observation__Key=REPLACE_ME
Services__Insights__Key=REPLACE_ME
InternalAccess__Observation__Key=REPLACE_ME
InternalAccess__Insights__Key=REPLACE_ME
# Pre-created professional credentials and read-only patient assignments.
Authentication__Accounts__1__AccountId=example_professional
Authentication__Accounts__1__Role=HealthcareProfessional
Authentication__Accounts__1__PasswordHash=REPLACE_WITH_ASPNET_CORE_PASSWORD_HASH
# Replace the synthetic identifier below with a created patient's identifier.
# Restart the gateway after changing assignments. Omit assignments for an empty list.
Access__ProfessionalAssignments__example_professional__0=00000000-0000-0000-0000-000000000001
Services__HealthOverview__BaseUrl=https://health-overview.example.test:5084/
Services__HealthOverview__Key=REPLACE_ME
InternalAccess__HealthOverview__Key=REPLACE_ME
+22
View File
@@ -0,0 +1,22 @@
[CmdletBinding()]
param([Parameter(Mandatory=$true)][string]$Output, [string]$Services='all')
$ErrorActionPreference='Stop'
$assemblies=@{ 'api-gateway'='ApiGateway'; 'patient-profile'='PatientProfileService'; 'observation'='ObservationService'; 'insights'='InsightsService'; 'health-overview'='HealthOverviewService' }
$selected=if ($Services -eq 'all') { @('api-gateway','patient-profile','observation','insights','health-overview') } else { @($Services.Split(',')) }
if ((Test-Path $Output) -or @($selected | Select-Object -Unique).Count -ne $selected.Count) { throw 'Use a new output directory and unique service names.' }
foreach ($name in $selected) { if (-not $assemblies.ContainsKey($name)) { throw "Unknown service: $name" } }
New-Item -ItemType Directory -Path $Output | Out-Null
$destination=(Resolve-Path $Output).Path
$repository=Split-Path $PSScriptRoot -Parent
foreach ($directory in @('services','systemd','examples')) { New-Item -ItemType Directory -Path "$destination\$directory" | Out-Null }
Copy-Item "$PSScriptRoot\installer\*.sh","$PSScriptRoot\installer\*.ps1","$PSScriptRoot\INSTALLATION.md" $destination
foreach ($name in $selected) {
& dotnet publish "$repository\src\$($assemblies[$name])\$($assemblies[$name]).csproj" --configuration Release --self-contained false '-p:UseAppHost=false' --output "$destination\services\$name"
if ($LASTEXITCODE -ne 0) { throw "Publish failed: $name" }
Copy-Item "$PSScriptRoot\systemd\healthapp-$name.service" "$destination\systemd"
Copy-Item "$PSScriptRoot\$name.env.example" "$destination\examples"
}
& dotnet publish "$PSScriptRoot\HealthApp.Provisioning\HealthApp.Provisioning.csproj" --configuration Release --self-contained false '-p:UseAppHost=false' --output "$destination\provisioner"
if ($LASTEXITCODE -ne 0) { throw 'Publish failed: provisioning utility' }
$selected | Set-Content "$destination\services.list"
Write-Host "Portable release created: $destination"
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail
fail() { printf 'Error: %s\n' "$*" >&2; exit 1; }
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
repo_dir=$(cd -- "$script_dir/.." && pwd)
source "$script_dir/installer/services.sh"
requested=all
output=
while [[ $# -gt 0 ]]; do
case "$1" in
--output) [[ $# -gt 1 ]] || fail 'Missing output directory.'; output=$2; shift 2;;
--services) [[ $# -gt 1 ]] || fail 'Missing services.'; requested=$2; shift 2;;
--help) printf '%s\n' 'Usage: bash deploy/build-release.sh --output NEW_DIRECTORY [--services all|api-gateway,patient-profile,observation,insights,health-overview]' 'Requires .NET 10 SDK. HEALTHAPP_DOTNET may select its executable.'; exit 0;;
*) fail "Unknown argument: $1";;
esac
done
select_services "$requested"
[[ -n "$output" && ! -e "$output" ]] || fail 'Provide a new, non-existing output directory.'
dotnet_command=${HEALTHAPP_DOTNET:-dotnet}
command -v "$dotnet_command" >/dev/null || fail '.NET 10 SDK is required to build a release.'
mkdir -p -- "$output/services" "$output/systemd" "$output/examples"
output=$(cd -- "$output" && pwd)
cp -- "$script_dir/installer/"*.sh "$output/"
cp -- "$script_dir/installer/"*.ps1 "$output/"
cp -- "$script_dir/INSTALLATION.md" "$output/"
for service in "${selected_services[@]}"; do
assembly=$(assembly_for "$service")
"$dotnet_command" publish "$repo_dir/src/$assembly/$assembly.csproj" --configuration Release --self-contained false -p:UseAppHost=false --output "$output/services/$service"
cp -- "$script_dir/systemd/healthapp-$service.service" "$output/systemd/"
cp -- "$script_dir/$service.env.example" "$output/examples/"
done
"$dotnet_command" publish "$script_dir/HealthApp.Provisioning/HealthApp.Provisioning.csproj" --configuration Release --self-contained false -p:UseAppHost=false --output "$output/provisioner"
printf '%s\n' "${selected_services[@]}" > "$output/services.list"
printf 'Release created: %s\n' "$output"
+8
View File
@@ -0,0 +1,8 @@
ASPNETCORE_ENVIRONMENT=Production
ASPNETCORE_URLS=https://0.0.0.0:5084
Services__ApiGateway__BaseUrl=https://gateway.example.test:5443/
InternalAccess__GatewayKey=REPLACE_ME
Kestrel__Certificates__Default__Path=/etc/healthapp/service.pfx
Kestrel__Certificates__Default__Password=REPLACE_ME
Services__ApiGateway__Key=REPLACE_ME
+6 -1
View File
@@ -1,3 +1,8 @@
ASPNETCORE_ENVIRONMENT=Production
ASPNETCORE_URLS=http://0.0.0.0:5083
ASPNETCORE_URLS=https://0.0.0.0:5083
Services__ApiGateway__BaseUrl=https://gateway.example.test:5443/
InternalAccess__GatewayKey=REPLACE_ME
Kestrel__Certificates__Default__Path=/etc/healthapp/service.pfx
Kestrel__Certificates__Default__Password=REPLACE_ME
Services__ApiGateway__Key=REPLACE_ME
+56
View File
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Source from install.sh. Package commands use the supported distribution's signed feeds.
package_available() {
local policy
policy=$(LC_ALL=C apt-cache policy "$1") || return 1
[[ "$policy" =~ Candidate:[[:space:]]+([^[:space:]]+) && "${BASH_REMATCH[1]}" != '(none)' ]]
}
ensure_dependencies() {
local distribution=$1 version=$2 runtime=$3 persistence=$4 ancestry=${5:-}
case " $distribution $ancestry " in
*" debian "*|*" ubuntu "*) ;;
*) fail 'Automatic Linux provisioning requires a Debian/Ubuntu-based distribution (ID or ID_LIKE).';;
esac
command -v apt-get >/dev/null && command -v apt-cache >/dev/null || fail 'Debian/Ubuntu provisioning requires apt-get and apt-cache.'
step='refresh dependency package availability'
apt-get update || fail 'Could not refresh package feeds; check network access and configured repositories.'
step='install base dependencies'
if ! command -v curl >/dev/null || ! command -v update-ca-certificates >/dev/null; then
DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates curl
fi
if [[ ! -x "$runtime" ]] || ! "$runtime" --list-runtimes | grep -q 'Microsoft.AspNetCore.App 10\.'; then
step='install .NET 10 ASP.NET Core runtime'
if ! package_available aspnetcore-runtime-10.0 && [[ "$distribution" == debian ]]; then
[[ "$version" =~ ^[0-9]+$ ]] || fail 'Cannot identify a compatible Microsoft Debian package repository from VERSION_ID.'
local package_dir
package_dir=$(mktemp -d)
if ! curl --fail --silent --show-error --location "https://packages.microsoft.com/config/debian/$version/packages-microsoft-prod.deb" -o "$package_dir/microsoft.deb"; then
rm -f -- "$package_dir/microsoft.deb"
rmdir -- "$package_dir"
fail "No accessible Microsoft Debian $version repository; aspnetcore-runtime-10.0 is unavailable in configured feeds."
fi
dpkg -i "$package_dir/microsoft.deb"
rm -f -- "$package_dir/microsoft.deb"
rmdir -- "$package_dir"
apt-get update
fi
package_available aspnetcore-runtime-10.0 || fail "Required package aspnetcore-runtime-10.0 is unavailable for $distribution $version in configured feeds; no compatible runtime repository could be identified automatically."
DEBIAN_FRONTEND=noninteractive apt-get install -y aspnetcore-runtime-10.0 || fail 'Failed to install aspnetcore-runtime-10.0 from configured feeds.'
fi
[[ -x "$runtime" ]] && "$runtime" --list-runtimes | grep -q 'Microsoft.AspNetCore.App 10\.' || fail 'The .NET 10 ASP.NET Core runtime could not be provisioned.'
if [[ "$persistence" == true ]]; then
step='provision PostgreSQL server'
if ! command -v pg_isready >/dev/null || ! pg_isready -q -h localhost -p 5432; then
package_available postgresql || fail "Required package postgresql is unavailable for $distribution $version in configured feeds."
DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql || fail 'Failed to install PostgreSQL from configured feeds.'
systemctl enable --now postgresql
fi
local ready=false attempt
for attempt in {1..30}; do
if pg_isready -q -h localhost -p 5432; then ready=true; break; fi
sleep 1
done
[[ "$ready" == true ]] || fail 'PostgreSQL did not become available on localhost:5432.'
fi
}
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -euo pipefail
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
fail() { printf 'Distribution failed: %s\n' "$*" >&2; exit 1; }
source "$script_dir/services.sh"
deployment=
requested=all
ssh_user=
dotnet_path=/usr/bin/dotnet
while [[ $# -gt 0 ]]; do
case "$1" in
--deployment|--services|--ssh-user|--dotnet)
[[ $# -gt 1 ]] || fail 'Missing argument.'
case "$1" in --deployment) deployment=$2;; --services) requested=$2;; --ssh-user) ssh_user=$2;; --dotnet) dotnet_path=$2;; esac
shift 2;;
--help) printf '%s\n' 'Usage: bash distribute.sh --deployment GENERATED_DIRECTORY --ssh-user ADMIN_USER [--services all|NAME[,NAME]] [--dotnet PATH]' 'Uses configured SSH access and passwordless sudo on the topology hosts. Generates no new credentials; installs matching scoped material and verifies the topology.'; exit 0;;
*) fail "Unknown argument: $1";;
esac
done
select_services "$requested"
[[ -n "$deployment" && -n "$ssh_user" ]] || fail 'Deployment directory and SSH administrator are required.'
"$dotnet_path" "$script_dir/provisioner/HealthApp.Provisioning.dll" distribute --bundle "$script_dir" \
--deployment "$deployment" --services "$(IFS=,; echo "${selected_services[*]}")" --ssh-user "$ssh_user"
+156
View File
@@ -0,0 +1,156 @@
#!/usr/bin/env bash
set -euo pipefail
umask 077
step=arguments
fail() { printf 'Installation failed at %s: %s\n' "$step" "$*" >&2; exit 1; }
trap 'printf "Installation failed at %s (line %s). Existing data was retained.\n" "$step" "$LINENO" >&2' ERR
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
source "$script_dir/services.sh"
requested=
root='/Library/Application Support/HealthApp'
host=localhost
topology=
deployment=
external_certificates=
admin_file=
prepare_only=false
defer=false
while [[ $# -gt 0 ]]; do
case "$1" in
--services|--host|--topology|--deployment|--certificates|--root|--postgres-admin-file)
[[ $# -gt 1 ]] || fail 'Missing value.'
case "$1" in --services) requested=$2;; --host) host=$2;; --topology) topology=$2;; --deployment) deployment=$2;;
--certificates) external_certificates=$2;; --root) root=$2;; --postgres-admin-file) admin_file=$2;; esac
shift 2;;
--prepare-only) prepare_only=true; shift;;
--defer-topology-check) defer=true; shift;;
--help) printf '%s\n' 'Usage: sudo bash install.sh --services all|NAME[,NAME] [--host DNS_OR_IP] [--topology FILE] [--deployment GENERATED_DIRECTORY]' 'macOS installs the runtime/PostgreSQL and independent launchd daemons using the same application DLLs and provisioning utility.'; exit 0;;
*) fail "Unknown argument: $1";;
esac
done
[[ $(uname -s) == Darwin && $EUID -eq 0 ]] || fail 'Run under sudo on macOS.'
select_services "$requested"
for service in "${selected_services[@]}"; do
[[ ! -e "$root/services/$service" && ! -e "/Library/LaunchDaemons/healthapp-$service.plist" ]] || fail "Already installed: $service."
done
mkdir -p "$root"
chmod 0711 "$root"
step='install .NET 10 ASP.NET Core runtime'
dotnet_path="$root/runtime/dotnet"
if command -v dotnet >/dev/null && dotnet --list-runtimes | grep -q 'Microsoft.AspNetCore.App 10\.'; then dotnet_path=$(command -v dotnet); fi
if [[ ! -x "$dotnet_path" ]]; then
curl --fail --silent --show-error https://dot.net/v1/dotnet-install.sh -o "$root/dotnet-install.sh"
bash "$root/dotnet-install.sh" --channel 10.0 --runtime aspnetcore --install-dir "$root/runtime" --no-path
chmod -R a+rX "$root/runtime"
fi
provision=("$dotnet_path" "$script_dir/provisioner/HealthApp.Provisioning.dll")
step='generate credentials and HTTPS certificates'
[[ -n "$deployment" ]] || deployment="$root/deployment"
if [[ ! -f "$deployment/deployment.json" ]]; then
args=(prepare --output "$deployment" --host "$host")
[[ -z "$topology" ]] || args+=(--topology "$topology")
[[ -z "$external_certificates" ]] || args+=(--certificates "$external_certificates")
"${provision[@]}" "${args[@]}"
fi
[[ "$prepare_only" == false ]] || { printf 'Generated deployment in %s\n' "$deployment"; exit 0; }
step='configure HTTPS trust'
security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain "$deployment/healthapp-ca.crt"
create_identity() {
local name=$1 uid=300
if id "$name" >/dev/null 2>&1; then return; fi
while dscl . -search /Users UniqueID "$uid" | grep -q . || dscl . -search /Groups PrimaryGroupID "$uid" | grep -q .; do uid=$((uid+1)); done
dscl . -create "/Groups/$name"
dscl . -create "/Groups/$name" PrimaryGroupID "$uid"
dscl . -create "/Users/$name"
dscl . -create "/Users/$name" UniqueID "$uid"
dscl . -create "/Users/$name" PrimaryGroupID "$uid"
dscl . -create "/Users/$name" UserShell /usr/bin/false
dscl . -create "/Users/$name" NFSHomeDirectory /var/empty
dscl . -create "/Users/$name" IsHidden 1
}
persistence=false
for service in "${selected_services[@]}"; do case "$service" in patient-profile|observation) persistence=true;; esac; done
if [[ "$persistence" == true && -z "$admin_file" ]]; then
step='install PostgreSQL binaries'
brew_user=${SUDO_USER:-}
[[ -n "$brew_user" && "$brew_user" != root ]] || fail 'Run sudo from an administrator account so Homebrew can run as that user.'
if ! xcode-select -p >/dev/null 2>&1; then
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
label=$(softwareupdate --list 2>&1 | sed -n 's/^.*Label: \(Command Line Tools.*\)/\1/p' | tail -n 1)
[[ -n "$label" ]] || fail 'Apple did not offer Command Line Tools through softwareupdate.'
softwareupdate --install "$label" --agree-to-license
rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
fi
brew_path=/opt/homebrew/bin/brew
[[ -x "$brew_path" ]] || brew_path=/usr/local/bin/brew
if [[ ! -x "$brew_path" ]]; then
curl --fail --silent --show-error https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh -o "$root/homebrew-install.sh"
chmod 0644 "$root/homebrew-install.sh"
sudo -u "$brew_user" env NONINTERACTIVE=1 bash "$root/homebrew-install.sh"
[[ -x /opt/homebrew/bin/brew ]] && brew_path=/opt/homebrew/bin/brew || brew_path=/usr/local/bin/brew
fi
sudo -u "$brew_user" "$brew_path" install postgresql@17
pg_prefix=$(sudo -u "$brew_user" "$brew_path" --prefix postgresql@17)
step='create installer-owned PostgreSQL cluster'
pg_identity=_healthapp_postgres
create_identity "$pg_identity"
admin_file="$root/postgres-admin.connection"
if [[ ! -f "$admin_file" ]]; then
port=5432
while nc -z localhost "$port" >/dev/null 2>&1; do port=$((port+1)); done
"${provision[@]}" secret --output "$root/postgres.password"
mkdir -p "$root/postgresql-data"
chown "$pg_identity:$pg_identity" "$root/postgresql-data" "$root/postgres.password"
sudo -u "$pg_identity" "$pg_prefix/bin/initdb" -D "$root/postgresql-data" -U postgres --auth-local=scram-sha-256 --auth-host=scram-sha-256 --pwfile "$root/postgres.password"
printf '\nport = %s\n' "$port" >> "$root/postgresql-data/postgresql.conf"
"${provision[@]}" admin-connection --password-file "$root/postgres.password" --port "$port" --output "$admin_file"
pg_plist=/Library/LaunchDaemons/healthapp-postgresql.plist
cat > "$pg_plist" <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict><key>Label</key><string>healthapp-postgresql</string><key>ProgramArguments</key><array><string>$pg_prefix/bin/postgres</string><string>-D</string><string>$root/postgresql-data</string></array><key>UserName</key><string>$pg_identity</string><key>RunAtLoad</key><true/><key>KeepAlive</key><true/></dict></plist>
PLIST
chmod 0644 "$pg_plist"
launchctl bootstrap system "$pg_plist"
fi
port=$(sed -n 's/.*Port=\([0-9]*\).*/\1/p' "$admin_file")
[[ -n "$port" ]] || port=5432
for attempt in {1..30}; do if "$pg_prefix/bin/pg_isready" -q -p "$port"; then break; fi; sleep 1; done
fi
for service in "${selected_services[@]}"; do
step="configure $service"
identity="_healthapp_${service//-/_}"
create_identity "$identity"
case "$service" in patient-profile|observation)
"${provision[@]}" database --service-dir "$deployment/$service" --admin-file "$admin_file";;
esac
"${provision[@]}" configure --service-dir "$deployment/$service" --root "$root" --platform macos
mkdir -p "$root/services" "$root/config" "$root/state"
chmod 0711 "$root/services" "$root/config" "$root/state"
cp -R "$script_dir/services/$service" "$root/services/$service"
chmod -R a+rX "$root/services/$service"
chgrp -R "$identity" "$root/config/$service"
chmod 0750 "$root/config/$service"
chmod 0640 "$root/config/$service/"*
if [[ "$service" == api-gateway ]]; then
mkdir -p "$root/state/api-gateway/keys"
chown -R "$identity:$identity" "$root/state/api-gateway"
chmod 0700 "$root/state/api-gateway"
fi
case "$service" in patient-profile|observation)
"${provision[@]}" execute --service "$service" --assembly "$root/services/$service/$(assembly_for "$service").dll" --dotnet "$dotnet_path" --root "$root";;
esac
# plutil converts the JSON object to an XML plist without treating configuration as shell code.
"$dotnet_path" "$script_dir/provisioner/HealthApp.Provisioning.dll" launchd --service "$service" --root "$root" --dotnet "$dotnet_path" --output "/Library/LaunchDaemons/healthapp-$service.plist"
chmod 0600 "/Library/LaunchDaemons/healthapp-$service.plist"
launchctl bootstrap system "/Library/LaunchDaemons/healthapp-$service.plist"
done
step='verify startup and HTTPS'
for service in "${selected_services[@]}"; do launchctl print "system/healthapp-$service" >/dev/null; done
"${provision[@]}" verify-startup --deployment "$deployment" --services "$(IFS=,; echo "${selected_services[*]}")"
if [[ "$defer" == false ]]; then
args=(verify --deployment "$deployment" --services "$(IFS=,; echo "${selected_services[*]}")")
[[ "$requested" != all ]] || args+=(--complete true)
"${provision[@]}" "${args[@]}"
fi
printf 'Installation completed. Account credentials: %s/accounts.json\n' "$deployment"
+159
View File
@@ -0,0 +1,159 @@
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)][string]$Services,
[string]$HostName = 'localhost',
[string]$Topology,
[string]$Deployment,
[string]$Certificates,
[string]$PostgresAdminFile,
[string]$Root = "$env:ProgramData\HealthApp",
[switch]$PrepareOnly,
[switch]$DeferTopologyCheck
)
$ErrorActionPreference = 'Stop'
$step = 'arguments'
function Check-Exit([string]$Operation) { if ($LASTEXITCODE -ne 0) { throw "$Operation failed (exit $LASTEXITCODE)." } }
function Protect-Private([string]$Path) {
& icacls.exe $Path /inheritance:r /grant:r '*S-1-5-18:(OI)(CI)F' '*S-1-5-32-544:(OI)(CI)F' | Out-Null
Check-Exit 'Protect private deployment files'
}
try {
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal($identity)
if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { throw 'Run from an elevated PowerShell session.' }
$assemblies = @{ 'api-gateway'='ApiGateway'; 'patient-profile'='PatientProfileService'; 'observation'='ObservationService'; 'insights'='InsightsService'; 'health-overview'='HealthOverviewService' }
$selected = if ($Services -eq 'all') { @('api-gateway','patient-profile','observation','insights','health-overview') } else { @($Services.Split(',')) }
if (@($selected | Select-Object -Unique).Count -ne $selected.Count) { throw 'Repeated service selection.' }
foreach ($name in $selected) {
if (-not $assemblies.ContainsKey($name)) { throw "Unknown service: $name" }
if (-not (Test-Path "$PSScriptRoot\services\$name\$($assemblies[$name]).dll")) { throw "Missing release: $name" }
if ((Test-Path "$Root\services\$name") -or (Get-Service "healthapp-$name" -ErrorAction SilentlyContinue)) { throw "Already installed: $name. Existing files were not changed." }
}
New-Item -ItemType Directory -Force $Root | Out-Null
Protect-Private $Root
$step = 'install .NET 10 ASP.NET Core runtime'
$dotnet = "$Root\runtime\dotnet.exe"
if (Get-Command dotnet.exe -ErrorAction SilentlyContinue) {
$candidate = (Get-Command dotnet.exe).Source
if ((& $candidate --list-runtimes) -match 'Microsoft.AspNetCore.App 10\.') { $dotnet = $candidate }
}
if (-not (Test-Path $dotnet)) {
$script = "$Root\dotnet-install.ps1"
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile $script -UseBasicParsing
& $script -Channel '10.0' -Runtime 'aspnetcore' -InstallDir "$Root\runtime" -NoPath
if (-not (Test-Path $dotnet)) { throw 'Runtime installation did not produce dotnet.exe.' }
}
$utility = "$PSScriptRoot\provisioner\HealthApp.Provisioning.dll"
$step = 'generate deployment material'
if (-not $Deployment) { $Deployment = "$Root\deployment" }
if (-not (Test-Path "$Deployment\deployment.json")) {
$prepare = @($utility,'prepare','--output',$Deployment,'--host',$HostName)
if ($Topology) { $prepare += @('--topology',$Topology) }
if ($Certificates) { $prepare += @('--certificates',$Certificates) }
& $dotnet @prepare
Check-Exit 'Generate credentials and HTTPS certificates'
}
Protect-Private $Deployment
if ($PrepareOnly) { Write-Host "Generated protected deployment material in $Deployment"; return }
$step = 'install prototype HTTPS trust'
Import-Certificate -FilePath "$Deployment\healthapp-ca.crt" -CertStoreLocation Cert:\LocalMachine\Root | Out-Null
$needsPostgres = ($selected -contains 'patient-profile') -or ($selected -contains 'observation')
if ($needsPostgres -and -not $PostgresAdminFile) {
$PostgresAdminFile = "$Root\postgres-admin.connection"
if (-not (Test-Path $PostgresAdminFile)) {
$step = 'install PostgreSQL'
# Resolve the maintained Microsoft package manifest, verify the vendor binary checksum,
# and pass the generated administrator secret through a protected options file.
$headers = @{ 'User-Agent'='HealthApp-Prototype-Installer' }
$manifestBase = 'https://api.github.com/repos/microsoft/winget-pkgs/contents/manifests/p/PostgreSQL/PostgreSQL/17'
$versions = Invoke-RestMethod $manifestBase -Headers $headers
$latest = $versions | Sort-Object @{Expression={[version]($_.name.Split('-')[0])}}, @{Expression={[int]($_.name.Split('-')[-1])}} -Descending | Select-Object -First 1
$files = Invoke-RestMethod $latest.url -Headers $headers
$manifest = $files | Where-Object { $_.name -like '*.installer.yaml' } | Select-Object -First 1
$yaml = (Invoke-WebRequest $manifest.download_url -UseBasicParsing).Content
$download = [regex]::Match($yaml,'(?m)^\s*InstallerUrl:\s*(\S+)').Groups[1].Value
$checksum = [regex]::Match($yaml,'(?m)^\s*InstallerSha256:\s*([A-Fa-f0-9]{64})').Groups[1].Value
if (-not $download.StartsWith('https://get.enterprisedb.com/') -or -not $checksum) { throw 'PostgreSQL package manifest is invalid.' }
$installer = "$Root\postgresql-installer.exe"
Invoke-WebRequest $download -OutFile $installer -UseBasicParsing
if ((Get-FileHash $installer -Algorithm SHA256).Hash -ne $checksum) { throw 'PostgreSQL installer checksum does not match.' }
$random = New-Object byte[] 32
$rng = [Security.Cryptography.RandomNumberGenerator]::Create()
$rng.GetBytes($random); $rng.Dispose()
$adminPassword = [BitConverter]::ToString($random).Replace('-','') + 'a!'
$port = 5432
$listener = New-Object Net.Sockets.TcpListener([Net.IPAddress]::Loopback,$port)
try { $listener.Start() } catch { $listener = New-Object Net.Sockets.TcpListener([Net.IPAddress]::Loopback,0); $listener.Start(); $port = $listener.LocalEndpoint.Port }
finally { $listener.Stop() }
$options = "$Root\postgresql.options"
@('mode=unattended','unattendedmodeui=none','debuglevel=0','enable-components=server,commandlinetools',
"prefix=$Root\postgresql","datadir=$Root\postgresql-data","serverport=$port",'servicename=healthapp-postgresql',
'serviceaccount=NT AUTHORITY\NetworkService',"superpassword=$adminPassword") | Set-Content $options -Encoding UTF8
Protect-Private $options
$installed = Start-Process $installer -ArgumentList @('--optionfile',('"'+$options+'"')) -Wait -PassThru
if ($installed.ExitCode -ne 0) { throw 'PostgreSQL unattended installation failed.' }
"Host=localhost;Port=$port;Database=postgres;Username=postgres;Password=$adminPassword" | Set-Content $PostgresAdminFile -Encoding UTF8
Protect-Private $PostgresAdminFile
Remove-Item $options
}
Start-Service 'healthapp-postgresql'
}
foreach ($name in $selected) {
$step = "configure $name"
if ($name -eq 'patient-profile' -or $name -eq 'observation') {
& $dotnet $utility database --service-dir "$Deployment\$name" --admin-file $PostgresAdminFile
Check-Exit "Create dedicated $name database and credentials"
}
& $dotnet $utility configure --service-dir "$Deployment\$name" --root $Root --platform windows
Check-Exit "Configure $name"
New-Item -ItemType Directory -Force "$Root\services" | Out-Null
$application = "$Root\services\$name"
Copy-Item "$PSScriptRoot\services\$name" $application -Recurse
Copy-Item "$Root\config\$name\appsettings.Production.json" "$application\appsettings.Production.json"
$dll = "$application\$($assemblies[$name]).dll"
if ($name -eq 'patient-profile' -or $name -eq 'observation') {
& $dotnet $dll --migrate --contentRoot $application --environment Production
Check-Exit "Migrate $name database"
}
$serviceName = "healthapp-$name"
$binary = '"'+$dotnet+'" "'+$dll+'" --contentRoot "'+$application+'" --environment Production'
New-Service -Name $serviceName -BinaryPathName $binary -StartupType Automatic -Description "HealthApp $name" | Out-Null
& sc.exe config $serviceName obj= "NT SERVICE\$serviceName" | Out-Null
Check-Exit "Configure independent $name virtual service account"
& icacls.exe $application /grant "NT SERVICE\${serviceName}:(OI)(CI)RX" /T | Out-Null
& icacls.exe "$Root\config\$name" /grant "NT SERVICE\${serviceName}:(OI)(CI)RX" /T | Out-Null
if ($name -eq 'api-gateway') {
New-Item -ItemType Directory -Force "$Root\state\api-gateway\keys" | Out-Null
& icacls.exe "$Root\state\api-gateway" /grant "NT SERVICE\${serviceName}:(OI)(CI)M" /T | Out-Null
}
# Service identities need traversal/runtime access, not other services' private configuration.
foreach ($parent in @("$Root\services","$Root\config","$Root\state")) {
if (Test-Path $parent) { & icacls.exe $parent /grant "NT SERVICE\${serviceName}:RX" | Out-Null }
}
& icacls.exe $Root /grant "NT SERVICE\${serviceName}:RX" | Out-Null
if ($dotnet.StartsWith($Root)) { & icacls.exe "$Root\runtime" /grant "NT SERVICE\${serviceName}:(OI)(CI)RX" /T | Out-Null }
& sc.exe failure $serviceName reset= 86400 actions= restart/5000 | Out-Null
$settings = Get-Content "$Deployment\$name\service.json" -Raw | ConvertFrom-Json
New-NetFirewallRule -DisplayName "HealthApp $name HTTPS" -Direction Inbound -Action Allow -Protocol TCP -LocalPort $settings.Port -Program $dotnet | Out-Null
Start-Service $serviceName
}
$step = 'verify running processes and HTTPS'
$processIds = @()
foreach ($name in $selected) {
$native = Get-CimInstance Win32_Service -Filter "Name='healthapp-$name'"
if ($native.State -ne 'Running' -or $native.ProcessId -eq 0 -or ($processIds -contains $native.ProcessId)) { throw "$name is not an independent running service." }
$processIds += $native.ProcessId
}
& $dotnet $utility verify-startup --deployment $Deployment --services ($selected -join ',')
Check-Exit 'HTTPS startup verification'
if (-not $DeferTopologyCheck) {
$verify = @($utility,'verify','--deployment',$Deployment,'--services',($selected -join ','))
if ($Services -eq 'all') { $verify += @('--complete','true') }
& $dotnet @verify
Check-Exit 'Dependency and representative workflow verification'
}
Write-Host "Installation completed. Generated account credentials are protected in $Deployment\accounts.json"
} catch {
Write-Error "Installation failed at ${step}: $($_.Exception.Message). Existing data and deployment material were retained."
exit 1
}
+150
View File
@@ -0,0 +1,150 @@
#!/usr/bin/env bash
set -euo pipefail
umask 077
step=arguments
fail() { printf 'Installation failed at %s: %s\n' "$step" "$*" >&2; exit 1; }
trap 'printf "Installation failed at %s (line %s). Existing data and generated material were retained.\n" "$step" "$LINENO" >&2' ERR
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
if [[ $(uname -s) == Darwin ]]; then exec bash "$script_dir/install-macos.sh" "$@"; fi
source "$script_dir/services.sh"
source "$script_dir/bootstrap.sh"
bundle=$script_dir
requested=
target_root=/
dotnet_path=/usr/bin/dotnet
host=localhost
topology=
deployment=
external_certificates=
admin_file=
prepare_only=false
defer_verification=false
while [[ $# -gt 0 ]]; do
case "$1" in
--bundle|--services|--root|--dotnet|--host|--topology|--deployment|--certificates|--postgres-admin-file)
[[ $# -gt 1 ]] || fail "Missing value for $1."
case "$1" in --bundle) bundle=$2;; --services) requested=$2;; --root) target_root=$2;; --dotnet) dotnet_path=$2;;
--host) host=$2;; --topology) topology=$2;; --deployment) deployment=$2;; --certificates) external_certificates=$2;;
--postgres-admin-file) admin_file=$2;; esac
shift 2;;
--prepare-only) prepare_only=true; shift;;
--defer-topology-check) defer_verification=true; shift;;
--help) printf '%s\n' 'Usage: bash install.sh --services all|NAME[,NAME] [--host DNS_OR_IP] [--topology topology.json] [--deployment generated-directory]' 'Provisioning installs runtime/PostgreSQL as needed and generates credentials, HTTPS, configuration, migrations and running systemd services.' 'Optional --root DIRECTORY stages generated files offline; --dotnet PATH selects the available runtime.' '--prepare-only generates a deployment for automatic distribution with distribute.sh. --certificates DIR accepts external certificates.'; exit 0;;
*) fail "Unknown argument: $1";;
esac
done
select_services "$requested"
[[ $(uname -s) == Linux ]] || fail 'Only Linux is supported.'
[[ "$target_root" == /* && "$target_root" != *$'\n'* ]] || fail 'Root must be an absolute path.'
[[ "$dotnet_path" =~ ^/[A-Za-z0-9_./+-]+$ ]] || fail 'Runtime path is invalid.'
target_root=$(realpath -m -- "$target_root")
step=preflight
for service in "${selected_services[@]}"; do
assembly=$(assembly_for "$service")
[[ -f "$bundle/services/$service/$assembly.dll" && -f "$bundle/systemd/healthapp-$service.service" ]] || fail "Missing release payload: $service"
[[ ! -e "$target_root/opt/healthapp/$service" && ! -e "$target_root/etc/healthapp/$service" && ! -e "$target_root/etc/systemd/system/healthapp-$service.service" ]] || fail "Already installed: $service; existing configuration was not changed."
done
[[ -f "$bundle/provisioner/HealthApp.Provisioning.dll" ]] || fail 'Missing release provisioning utility.'
persistence=false
for service in "${selected_services[@]}"; do case "$service" in patient-profile|observation) persistence=true;; esac; done
if [[ "$target_root" == / && "$prepare_only" == false ]]; then
[[ $EUID -eq 0 && -d /run/systemd/system ]] || fail 'Live installation requires root and a running systemd manager.'
source /etc/os-release
ensure_dependencies "$ID" "${VERSION_ID:-}" "$dotnet_path" "$persistence" "${ID_LIKE:-}"
else
[[ -x "$dotnet_path" ]] || fail 'Offline preparation needs an available .NET 10 runtime.'
fi
provision=("$dotnet_path" "$bundle/provisioner/HealthApp.Provisioning.dll")
step='generate deployment credentials and HTTPS certificates'
if [[ -z "$deployment" || ! -f "$deployment/deployment.json" ]]; then
[[ -n "$deployment" ]] || deployment="$target_root/var/lib/healthapp-installation/deployment"
arguments=(prepare --output "$deployment" --host "$host")
[[ -z "$topology" ]] || arguments+=(--topology "$topology")
[[ -z "$external_certificates" ]] || arguments+=(--certificates "$external_certificates")
"${provision[@]}" "${arguments[@]}"
fi
if [[ "$prepare_only" == true ]]; then
printf 'Deployment material generated in %s. It contains secrets; distribute.sh installs the scoped material on each host.\n' "$deployment"
exit 0
fi
install -d -m 0755 "$target_root/opt/healthapp" "$target_root/etc/systemd/system"
install -d -m 0711 "$target_root/etc/healthapp"
install -d -m 0755 "$target_root/usr/local/share/ca-certificates"
ca_id=$(sha256sum "$deployment/healthapp-ca.crt" | cut -c1-16)
install -m 0644 "$deployment/healthapp-ca.crt" "$target_root/usr/local/share/ca-certificates/healthapp-prototype-$ca_id.crt"
if [[ "$target_root" == / ]]; then
step='install local HTTPS trust'
update-ca-certificates
fi
for service in "${selected_services[@]}"; do
step="configure $service"
if [[ "$target_root" == / ]]; then
user="healthapp-$service"
getent group "$user" >/dev/null || groupadd --system "$user"
id "$user" >/dev/null 2>&1 || useradd --system --gid "$user" --home-dir /nonexistent --shell /usr/sbin/nologin "$user"
fi
if [[ "$service" == patient-profile || "$service" == observation ]]; then
if [[ "$target_root" == / || -n "$admin_file" ]]; then
step="create dedicated database and role for $service"
args=(database --service-dir "$deployment/$service")
[[ -z "$admin_file" ]] || args+=(--admin-file "$admin_file")
"${provision[@]}" "${args[@]}"
fi
fi
"${provision[@]}" configure --service-dir "$deployment/$service" --root "$target_root"
install -d -m 0755 "$target_root/opt/healthapp/$service"
cp -R "$bundle/services/$service/." "$target_root/opt/healthapp/$service/"
chmod -R a+rX,go-w "$target_root/opt/healthapp/$service"
sed -e "s|ExecStart=/usr/bin/dotnet |ExecStart=$dotnet_path |" \
-e "s|EnvironmentFile=/etc/healthapp/$service.env|EnvironmentFile=/etc/healthapp/$service/service.env|" \
-e "s/^User=healthapp$/User=healthapp-$service/" -e "s/^Group=healthapp$/Group=healthapp-$service/" \
"$bundle/systemd/healthapp-$service.service" > "$target_root/etc/systemd/system/healthapp-$service.service"
chmod 0644 "$target_root/etc/systemd/system/healthapp-$service.service"
if [[ "$target_root" == / ]]; then
chmod 0750 "/etc/healthapp/$service"
chgrp "$user" "/etc/healthapp/$service" "/etc/healthapp/$service/service.pfx"
chmod 0640 "/etc/healthapp/$service/service.pfx"
fi
printf 'Installed selected application: %s\n' "$service"
done
if [[ "$target_root" != / ]]; then
printf 'Offline deployment staged in %s. Package installation, systemd startup and live verification were not performed.\n' "$target_root"
exit 0
fi
step='register independent systemd services'
systemctl daemon-reload
for service in "${selected_services[@]}"; do
case "$service" in patient-profile|observation)
step="migrate $service database"
assembly=$(assembly_for "$service")
systemd-run --quiet --wait --pipe --collect --unit="healthapp-$service-migrate" \
--property="User=healthapp-$service" --property="Group=healthapp-$service" \
--property="EnvironmentFile=/etc/healthapp/$service/service.env" --property="WorkingDirectory=/opt/healthapp/$service" \
"$dotnet_path" "/opt/healthapp/$service/$assembly.dll" --migrate;;
esac
done
systemctl daemon-reload
for service in "${selected_services[@]}"; do
step="enable/start $service"
systemctl enable --now "healthapp-$service.service"
done
step='verify startup and HTTPS listening'
pids=()
for service in "${selected_services[@]}"; do
systemctl is-active --quiet "healthapp-$service.service" || fail "$service is not running."
pid=$(systemctl show --property MainPID --value "healthapp-$service.service")
[[ "$pid" =~ ^[1-9][0-9]*$ && -d "/proc/$pid" ]] || fail "$service has no running process."
for peer in "${pids[@]}"; do [[ "$pid" != "$peer" ]] || fail 'Selected services share a process.'; done
pids+=("$pid")
done
"${provision[@]}" verify-startup --deployment "$deployment" --services "$(IFS=,; echo "${selected_services[*]}")"
if [[ "$defer_verification" == true ]]; then
printf '%s\n' 'Node started. Distributed topology verification is pending until all nodes have started.'
else
step='verify configured dependencies and representative functionality'
arguments=(verify --deployment "$deployment" --services "$(IFS=,; echo "${selected_services[*]}")")
[[ "$requested" != all ]] || arguments+=(--complete true)
"${provision[@]}" "${arguments[@]}"
printf 'Installation and topology verification completed. Account credentials: %s/accounts.json\n' "$deployment"
fi
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Deployment metadata only; each application remains independently published and configured.
all_services=(api-gateway patient-profile observation insights health-overview)
select_services() {
local requested="$1" item
selected_services=()
if [[ "$requested" == all ]]; then
selected_services=("${all_services[@]}")
return
fi
IFS=',' read -r -a selected_services <<< "$requested"
[[ ${#selected_services[@]} -gt 0 && "$requested" != *, ]] || fail "Select services by comma-separated name or all."
local seen=,
for item in "${selected_services[@]}"; do
case "$item" in api-gateway|patient-profile|observation|insights|health-overview) ;; *) fail "Unknown service: $item" ;; esac
case "$seen" in *,$item,*) fail "Repeated service: $item";; esac
seen+="$item,"
done
}
assembly_for() {
case "$1" in
api-gateway) printf '%s' ApiGateway;;
patient-profile) printf '%s' PatientProfileService;;
observation) printf '%s' ObservationService;;
insights) printf '%s' InsightsService;;
health-overview) printf '%s' HealthOverviewService;;
esac
}
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -euo pipefail
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
fail() { printf 'Verification failed: %s\n' "$*" >&2; exit 1; }
source "$script_dir/services.sh"
requested=
deployment=/var/lib/healthapp-installation/deployment
dotnet_path=/usr/bin/dotnet
while [[ $# -gt 0 ]]; do
case "$1" in
--services|--deployment|--dotnet)
[[ $# -gt 1 ]] || fail 'Missing argument.'
case "$1" in --services) requested=$2;; --deployment) deployment=$2;; --dotnet) dotnet_path=$2;; esac
shift 2;;
--help) printf '%s\n' 'Usage: bash verify.sh --services all|NAME[,NAME] [--deployment GENERATED_DIRECTORY] [--dotnet PATH]' 'Checks systemd processes, HTTPS, dedicated databases, service credentials and the complete-system synthetic workflow.'; exit 0;;
*) fail "Unknown argument: $1";;
esac
done
select_services "$requested"
pids=()
for service in "${selected_services[@]}"; do
systemctl is-active --quiet "healthapp-$service.service" || fail "$service is not running."
pid=$(systemctl show --property MainPID --value "healthapp-$service.service")
[[ "$pid" =~ ^[1-9][0-9]*$ && -d "/proc/$pid" ]] || fail "$service has no process."
for peer in "${pids[@]}"; do [[ "$pid" != "$peer" ]] || fail 'Services share a process.'; done
pids+=("$pid")
done
args=(verify --deployment "$deployment" --services "$(IFS=,; echo "${selected_services[*]}")")
[[ "$requested" != all ]] || args+=(--complete true)
"$dotnet_path" "$script_dir/provisioner/HealthApp.Provisioning.dll" "${args[@]}"
printf '%s\n' 'Installation verification passed.'
+6 -1
View File
@@ -1,4 +1,9 @@
ASPNETCORE_ENVIRONMENT=Production
ASPNETCORE_URLS=http://0.0.0.0:5082
ASPNETCORE_URLS=https://0.0.0.0:5082
ConnectionStrings__ObservationDatabase="Host=database.example.test;Port=5432;Database=observations;Username=observations;Password=REPLACE_ME"
Services__ApiGateway__BaseUrl=https://gateway.example.test:5443/
InternalAccess__GatewayKey=REPLACE_ME
Kestrel__Certificates__Default__Path=/etc/healthapp/service.pfx
Kestrel__Certificates__Default__Password=REPLACE_ME
Services__ApiGateway__Key=REPLACE_ME
+5 -1
View File
@@ -1,3 +1,7 @@
ASPNETCORE_ENVIRONMENT=Production
ASPNETCORE_URLS=http://0.0.0.0:5081
ASPNETCORE_URLS=https://0.0.0.0:5081
ConnectionStrings__PatientDatabase="Host=database.example.test;Port=5432;Database=patient_profile;Username=patient_profile;Password=REPLACE_ME"
InternalAccess__GatewayKey=REPLACE_ME
Kestrel__Certificates__Default__Path=/etc/healthapp/service.pfx
Kestrel__Certificates__Default__Password=REPLACE_ME
@@ -4,6 +4,8 @@ Wants=network-online.target
After=network-online.target
[Service]
StateDirectory=healthapp-api-gateway
StateDirectoryMode=0700
Type=simple
User=healthapp
Group=healthapp
@@ -0,0 +1,20 @@
[Unit]
Description=HealthApp Health Overview service
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=healthapp
Group=healthapp
WorkingDirectory=/opt/healthapp/health-overview
ExecStart=/usr/bin/dotnet /opt/healthapp/health-overview/HealthOverviewService.dll
EnvironmentFile=/etc/healthapp/health-overview.env
Restart=on-failure
RestartSec=5
KillSignal=SIGINT
TimeoutStopSec=30
SyslogIdentifier=healthapp-health-overview
[Install]
WantedBy=multi-user.target
+200
View File
@@ -0,0 +1,200 @@
# US-13 prototype authentication
The API gateway authenticates pre-created externally configured accounts. Login is
`POST /api/authentication/login` with `accountId` and `password`. A successful JSON
response contains `accessToken`, `tokenType: Bearer`, `expiresIn`, `accountId` and
trusted `role`; it contains no patient data or refresh token. Send the access token
as `Authorization: Bearer <token>` on subsequent patient-data requests. Invalid
credentials return the same `401` response for unknown accounts and wrong passwords.
Login responses cannot be cached. General measurement guidance remains public.
## Mechanism and configuration
Use ASP.NET Core's built-in bearer authentication and ticket protection, with
Data Protection's application name `HealthApp.ApiGateway` and the bearer purpose.
Tokens are opaque protected authentication tickets, not JWTs. The configured key
ring and framework purpose enforce the gateway trust boundary; only account ID,
role and authentication properties are protected inside a token. Do not share the
key ring with other applications/services. No custom cryptography, identity
microservice, account database or refresh-token mechanism is introduced.
The gateway verifies passwords with ASP.NET Core `PasswordHasher` against
`Authentication:Accounts:<index>:{AccountId,Role,PasswordHash}`. Roles are `Patient`
or `HealthcareProfessional`, from trusted configuration. IDs support ASCII letters,
digits, hyphen and underscore, up to 128 characters. This keeps the internal account
lookup contract unambiguous. Provision credentials externally; no registration or
administration API is exposed. For provisioning, `tools/PasswordHash` reads a
password from standard input and emits its ASP.NET Core hash. Supply input securely
(e.g. redirect a permission-restricted temporary file), and protect the resulting
hash/configuration; neither belongs in Git. The tool needs no NuGet dependency.
`Authentication:TokenLifetimeMinutes` defaults to 30; supported range is 1–1440.
`Authentication:KeyDirectory` is required. Keep its contents persistent through
restart/deployment and readable only by the gateway service account. The systemd
unit provides a mode-0700 state directory; example configuration points into it.
Keys are protected by filesystem permissions in this Linux prototype. Removing
keys invalidates tokens; preserve them for restart continuity. Accounts and
configuration are loaded at startup; after disabling accounts or changing roles,
old tokens can remain valid until their expiry. Immediate revocation is outside
this story. Missing/invalid/expired tokens return `401`; authenticate again after
expiry. Credential validation is not repeated for each operation.
Before thesis measurement, record the lifetime, account/role mix, key persistence,
login frequency and expiry handling. Normally obtain tokens during workload setup
and reuse them; state explicitly whether login is measured. If tokens expire,
re-authentication is required. Keep these choices identical across variants. The
automated test helper logs in using real password verification and caches tokens;
its account-per-resource setup is not a prescribed measurement workload.
## Ownership and profile creation
The patient service owns the account association as `patient.account_id` with a
unique index. It remains application access data, outside tokens. The gateway
queries its protected `GET /api/patients/by-account/{accountId}` service API on each
request; that API is not forwarded as a public account-lookup route. An account
without a profile may log in and create one; its other own-data requests return
`404`. Patient operations are subject to the standard Patient authorization policy.
`GET /api/patients/me` retrieves the caller’s own associated profile without needing
to know its generated identifier, including after a creation response was lost.
It returns `404` before profile creation.
Profile creation derives `X-Account-Id` from the authenticated principal. The
gateway overwrites client input; the service accepts it only behind its gateway
credential. The profile and association are inserted in one atomic database save,
so failure rolls both back. The unique index arbitrates concurrent creation. A
completed creation, a retry after a lost response and a competing request cannot
create another profile; later attempts receive `409`. A retry after a failed
transaction may create the first profile. Profile identity remains persistent
through restarts. US-01's authenticated creation is included because US-13 depends
on a persistent, recoverable association.
Apply the new patient migration before startup. Existing profiles retain a null
account association rather than being assigned to an arbitrary account. They are
not accessible to patient accounts until a trusted deployment operator explicitly
associates them with pre-created accounts. For synthetic experiments, provision a
fresh database via the authenticated creation flow. Do not infer ownership from
caller-supplied IDs or automatically assign historical profiles.
For observation-ID requests, the gateway reads the observation through its service
API to obtain the actual patient, then compares that owner with the account's
profile. Requests for another patient's information receive an empty `404`, the
same as missing data, without forwarding writes or revealing existence. Failed
ownership lookups fail closed with `502`/`504`. Tokens do not cache ownership.
Healthcare-professional logins establish a trusted role. US-14 now permits reads
of assigned patients and the caller’s own assignment list; all professional writes
are rejected before forwarding. Trend/overview endpoints remain unimplemented; the
gateway's default authentication policy also protects future patient endpoints,
which must retain ownership checks when added.
## Service and transport protection
Use HTTPS for client and service traffic. Outside Development, gateway and service
requests over HTTP are rejected and outgoing service endpoints must be HTTPS.
Certificates use ordinary Kestrel configuration and normal platform validation;
no insecure certificate handler is provided. Configure DNS names/certificates for
separate machines. Development permits plain HTTP for local automated tests only.
Use network firewall rules to restrict service ports to trusted hosts as an
additional deployment control; the application credential checks still enforce
protection if a client reaches a service directly.
Each service requires `InternalAccess:GatewayKey`, a random credential of at least
32 characters, matched by the gateway's `Services:<service>:Key`. Services reject
missing/wrong keys and client bearer tokens. Use distinct per-service gateway keys
in deployment. The gateway forwards only its own configured key; arbitrary client
identity headers are not propagated. Do not log these headers or tokens.
Observation and Insights each have a separate `Services:ApiGateway:Key`, matched
by the gateway's `InternalAccess:Observation:Key` or `InternalAccess:Insights:Key`.
Their `X-Service-Key` authenticates an internal principal using an ASP.NET Core
handler. The Observation principal can only GET a patient profile by patient ID;
the Insights principal can only GET observation history by patient ID. Neither
can create/update/delete profiles or observations, query account associations or
call other protected routes. Both internal read paths still pass through the
gateway. Service credentials are separate from patient tokens and token keys.
Use independent random values, restrictive configuration-file permissions and
HTTPS; placeholder values in deployment examples deliberately fail validation.
## Verification
The acceptance suite exercises real HTTP hosts and PostgreSQL migrations. It covers
US-13's login, own access, missing/invalid/expired tokens, no-profile behaviour,
cross-patient reads/writes and observation ownership. Additional checks cover
caller-supplied account spoofing, persistent tokens/associations after restart,
duplicate/concurrent creation, unavailable-service recovery, direct service bypass,
internal-credential route restrictions, professional creation rejection and public
US-15 guidance. Existing functional assertions run through real token login rather
than a production authentication bypass.
Framework reference:
https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.bearertoken.bearertokenoptions?view=aspnetcore-10.0
## US-14 professional assignments
Predefine assignments in the gateway's external `Access:ProfessionalAssignments`
configuration, keyed by the stable professional account identifier. For example:
```json
{
"Access": {
"ProfessionalAssignments": {
"example_professional": [
"00000000-0000-0000-0000-000000000001",
"00000000-0000-0000-0000-000000000002"
]
}
}
}
```
Use actual patient identifiers returned by authenticated profile creation. The
example UUIDs are placeholders. A professional can have several patients, and
several professionals can share a patient. Duplicate identifiers are treated as
one assignment. Empty identifiers are rejected at startup. An omitted account
entry means no assignments. Configure that account's role and password hash
separately under `Authentication:Accounts`; assignments never grant a role.
`GET /api/professionals/me/patients` requires the HealthcareProfessional policy and
returns an array of `{ "patientId": "..." }` entries, in deterministic identifier
order. It lists only the caller's configured assignments, without fetching patient
records. No assignments returns `[]`. Missing profiles remain assigned identifiers;
retrieving their data follows the existing missing-resource behaviour. Caller
query parameters or identity headers cannot select another professional's list.
Patient accounts cannot use this endpoint.
Professional GET requests to existing patient profiles, observations (including
recorded legacy context), history, latest observations and numerical insight
require membership in the caller's assignment set. Observation-ID requests resolve
the actual owning patient via the protected Observation API; a supplied patient ID
is not evidence of assignment. Unassigned reads return an empty `404`, preserving
the same non-disclosure convention as patient access. Assigned missing data follows
the existing retrieval contracts. All professional POST/PUT/PATCH/DELETE requests
are rejected with `403` before ownership lookups or forwarding. There is no
assignment-management API or additional database/service.
Assignments are loaded at gateway startup, outside tokens and credential
validation. Restart the gateway after changing its external configuration. Existing
valid tokens then use the new assignment data. Empty lists need no upstream service;
observation-owner lookup failures fail closed with `502`/`504`.
The US-14 tests exercise actual login, multiple and shared assignments, empty lists,
assigned/unassigned reads, preserved context, missing resources, every existing
write route, invalid and expired credentials, patient-role rejection, assignment
changes across restart and unavailable ownership lookup. Trend and overview
endpoints now have equivalent owner/assignment routing and integration tests under
US-11/US-12. Structured observation context is included in authorized reads.
## US-12 Overview service access
The gateway requires `Services:HealthOverview:BaseUrl` and `Services:HealthOverview:Key`.
The latter matches Overview's `InternalAccess:GatewayKey` and protects direct access.
Overview's outgoing `Services:ApiGateway:Key` matches `InternalAccess:HealthOverview:Key`
on the gateway. Use distinct randomly generated credentials of at least 32 characters
for each direction and service; load them externally. Production endpoints use HTTPS.
The HealthOverview service identity is restricted to GET patient profiles, GET latest
overall observations and GET numerical insights. It cannot retrieve history, trends or
another overview, or perform writes. It establishes no client identity. The gateway
checks client ownership/professional assignment before forwarding the outer request.
Internal credentials are trusted service credentials and must remain inaccessible to clients.
Overview adds no authentication framework, shared runtime library or persistence.
+3
View File
@@ -4,4 +4,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="10.0.12" />
</ItemGroup>
</Project>
@@ -0,0 +1,39 @@
using System.ComponentModel.DataAnnotations;
using System.Security.Claims;
using ApiGateway.Security;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.BearerToken;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
namespace ApiGateway.Controllers;
[ApiController]
[Route("api/authentication")]
public sealed class AuthenticationController(PrototypeAccounts accounts,
IOptionsMonitor<BearerTokenOptions> options) : ControllerBase
{
[AllowAnonymous]
[HttpPost("login")]
public IActionResult Login(LoginRequest request)
{
var account = accounts.Verify(request.AccountId, request.Password);
if (account is null) return Unauthorized(new { title = "Invalid credentials." });
var principal = new ClaimsPrincipal(new ClaimsIdentity(new[]
{
new Claim(ClaimTypes.NameIdentifier, account.AccountId),
new Claim(ClaimTypes.Role, account.Role)
}, "Bearer"));
var settings = options.Get("Bearer");
var expiry = settings.TimeProvider!.GetUtcNow().Add(settings.BearerTokenExpiration);
// Use the framework's ticket protector and bearer validation. No refresh endpoint/token.
var ticket = new AuthenticationTicket(principal, new AuthenticationProperties { ExpiresUtc = expiry }, "Bearer");
Response.Headers.CacheControl = "no-store";
Response.Headers.Pragma = "no-cache";
return Ok(new { accessToken = settings.BearerTokenProtector.Protect(ticket), tokenType = "Bearer",
expiresIn = (long)settings.BearerTokenExpiration.TotalSeconds, accountId = account.AccountId, role = account.Role });
}
public sealed record LoginRequest([Required] string AccountId, [Required] string Password);
}
@@ -0,0 +1,48 @@
using Microsoft.AspNetCore.Mvc;
namespace ApiGateway.Controllers;
[ApiController]
[Route("api")]
public sealed class HealthOverviewController(IHttpClientFactory clients) : ControllerBase
{
[HttpGet("patients/{patientId:guid}/overview")]
public Task GetOverview(Guid patientId, CancellationToken cancellationToken) =>
ForwardAsync(HttpMethod.Get, $"api/patients/{patientId}/overview{Request.QueryString}", cancellationToken);
private async Task ForwardAsync(HttpMethod method, string path, CancellationToken cancellationToken)
{
using var request = new HttpRequestMessage(method, path);
try
{
using var upstream = await clients.CreateClient("HealthOverview")
.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
Response.StatusCode = (int)upstream.StatusCode;
Response.ContentType = upstream.Content.Headers.ContentType?.ToString();
if (upstream.Headers.Location is { } location)
Response.Headers.Location = location.IsAbsoluteUri ? location.PathAndQuery : location.ToString();
await upstream.Content.CopyToAsync(Response.Body, cancellationToken);
}
catch (HttpRequestException)
{
await WriteFailureAsync(StatusCodes.Status502BadGateway);
}
catch (OperationCanceledException) when (!cancellationToken.IsCancellationRequested)
{
await WriteFailureAsync(StatusCodes.Status504GatewayTimeout);
}
}
private Task WriteFailureAsync(int status)
{
if (Response.HasStarted)
{
HttpContext.Abort();
return Task.CompletedTask;
}
Response.Clear();
return Results.Problem(statusCode: status, title: "Health overview service is unavailable.")
.ExecuteAsync(HttpContext);
}
}
@@ -10,6 +10,10 @@ public sealed class InsightsController(IHttpClientFactory clients) : ControllerB
public Task GetSummary(Guid patientId, CancellationToken cancellationToken) =>
ForwardAsync(HttpMethod.Get, $"api/patients/{patientId}/insights{Request.QueryString}", cancellationToken);
[HttpGet("patients/{patientId:guid}/trends")]
public Task GetTrend(Guid patientId, CancellationToken cancellationToken) =>
ForwardAsync(HttpMethod.Get, $"api/patients/{patientId}/trends{Request.QueryString}", cancellationToken);
private async Task ForwardAsync(HttpMethod method, string path, CancellationToken cancellationToken)
{
using var request = new HttpRequestMessage(method, path);
@@ -18,6 +18,10 @@ public sealed class ObservationController(IHttpClientFactory clients) : Controll
public Task UpdateObservation(Guid observationId, CancellationToken cancellationToken) =>
ForwardAsync(HttpMethod.Put, $"api/observations/{observationId}", cancellationToken);
[HttpPatch("observations/{observationId:guid}")]
public Task PatchObservation(Guid observationId, CancellationToken cancellationToken) =>
ForwardAsync(HttpMethod.Patch, $"api/observations/{observationId}", cancellationToken);
[HttpGet("observations/{observationId:guid}")]
public Task GetObservation(Guid observationId, CancellationToken cancellationToken) =>
ForwardAsync(HttpMethod.Get, $"api/observations/{observationId}", cancellationToken);
@@ -33,7 +37,7 @@ public sealed class ObservationController(IHttpClientFactory clients) : Controll
private async Task ForwardAsync(HttpMethod method, string path, CancellationToken cancellationToken)
{
using var request = new HttpRequestMessage(method, path);
if (method == HttpMethod.Post || method == HttpMethod.Put)
if (method == HttpMethod.Post || method == HttpMethod.Put || method == HttpMethod.Patch)
{
request.Content = new StreamContent(Request.Body);
if (Request.ContentType is not null)
@@ -46,6 +50,9 @@ public sealed class ObservationController(IHttpClientFactory clients) : Controll
.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
Response.StatusCode = (int)upstream.StatusCode;
Response.ContentType = upstream.Content.Headers.ContentType?.ToString();
foreach (var header in new[] { "X-Measurement-Setting", "X-Activity-Condition" })
if (upstream.Headers.TryGetValues(header, out var values))
Response.Headers[header] = values.ToArray();
if (upstream.Headers.Location is { } location)
Response.Headers.Location = location.IsAbsoluteUri ? location.PathAndQuery : location.ToString();
await upstream.Content.CopyToAsync(Response.Body, cancellationToken);
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;
namespace ApiGateway.Controllers;
@@ -10,6 +11,10 @@ public sealed class PatientController(IHttpClientFactory clients) : ControllerBa
public Task CreatePatient(CancellationToken cancellationToken) =>
ForwardAsync(HttpMethod.Post, "api/patients", cancellationToken);
[HttpGet("me")]
public Task GetOwnPatient(CancellationToken cancellationToken) =>
ForwardAsync(HttpMethod.Get, "api/patients/by-account/" + Uri.EscapeDataString(User.FindFirstValue(ClaimTypes.NameIdentifier)!), cancellationToken);
[HttpGet("{patientId:guid}")]
public Task GetPatient(Guid patientId, CancellationToken cancellationToken) =>
ForwardAsync(HttpMethod.Get, $"api/patients/{patientId}", cancellationToken);
@@ -21,6 +26,8 @@ public sealed class PatientController(IHttpClientFactory clients) : ControllerBa
private async Task ForwardAsync(HttpMethod method, string path, CancellationToken cancellationToken)
{
using var request = new HttpRequestMessage(method, path);
if (method == HttpMethod.Post)
request.Headers.Add("X-Account-Id", User.FindFirstValue(ClaimTypes.NameIdentifier));
if (method == HttpMethod.Post || method == HttpMethod.Put)
{
request.Content = new StreamContent(Request.Body);
@@ -0,0 +1,17 @@
using System.Security.Claims;
using ApiGateway.Security;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace ApiGateway.Controllers;
[ApiController]
[Authorize(Policy = "HealthcareProfessional")]
[Route("api/professionals/me/patients")]
public sealed class ProfessionalController(ProfessionalAssignments assignments) : ControllerBase
{
[HttpGet]
public IActionResult GetAssignedPatients() =>
Ok(assignments.GetPatients(User.FindFirstValue(ClaimTypes.NameIdentifier)!)
.Select(patientId => new { patientId }));
}
+78 -3
View File
@@ -1,3 +1,10 @@
using ApiGateway.Security;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.BearerToken;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
using Microsoft.AspNetCore.DataProtection.Repositories;
namespace ApiGateway;
public class Program
@@ -5,25 +12,93 @@ public class Program
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseWindowsService(options => options.ServiceName = "healthapp-api-gateway");
builder.Services.AddControllers();
builder.Services.AddProblemDetails();
builder.Services.AddSingleton<PrototypeAccounts>();
builder.Services.AddSingleton<ProfessionalAssignments>();
builder.Services.AddAuthentication("ClientOrService")
.AddPolicyScheme("ClientOrService", null, options => options.ForwardDefaultSelector = context =>
context.Request.Headers.ContainsKey("X-Service-Key") ? "InternalService" : "Bearer")
.AddBearerToken("Bearer", options =>
{
options.BearerTokenExpiration = TimeSpan.FromMinutes(builder.Configuration.GetValue("Authentication:TokenLifetimeMinutes", 30));
})
.AddScheme<AuthenticationSchemeOptions, InternalServiceAuthenticationHandler>("InternalService", null);
builder.Services.AddAuthorization(options =>
{
options.FallbackPolicy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
options.AddPolicy("Patient", policy => policy.RequireRole("Patient").RequireClaim(System.Security.Claims.ClaimTypes.NameIdentifier));
options.AddPolicy("HealthcareProfessional", policy => policy.RequireRole("HealthcareProfessional")
.RequireClaim(System.Security.Claims.ClaimTypes.NameIdentifier));
});
builder.Services.AddDataProtection().SetApplicationName("HealthApp.ApiGateway");
builder.Services.AddOptions<KeyManagementOptions>().Configure<IConfiguration, ILoggerFactory>((options, configuration, logger) =>
{
var keyDirectory = configuration["Authentication:KeyDirectory"];
if (string.IsNullOrWhiteSpace(keyDirectory)) throw new InvalidOperationException("Authentication:KeyDirectory is required.");
options.XmlRepository = new FileSystemXmlRepository(new DirectoryInfo(keyDirectory), logger);
});
builder.Services.AddHttpClient("PatientProfile", (services, client) =>
client.BaseAddress = GetBaseUri(services.GetRequiredService<IConfiguration>(), "PatientProfile"))
{
var configuration = services.GetRequiredService<IConfiguration>();
client.BaseAddress = GetBaseUri(configuration, "PatientProfile");
client.DefaultRequestHeaders.Add("X-Gateway-Key", configuration["Services:PatientProfile:Key"]);
})
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { AllowAutoRedirect = false });
builder.Services.AddHttpClient("Observation", (services, client) =>
client.BaseAddress = GetBaseUri(services.GetRequiredService<IConfiguration>(), "Observation"))
{
var configuration = services.GetRequiredService<IConfiguration>();
client.BaseAddress = GetBaseUri(configuration, "Observation");
client.DefaultRequestHeaders.Add("X-Gateway-Key", configuration["Services:Observation:Key"]);
})
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { AllowAutoRedirect = false });
builder.Services.AddHttpClient("Insights", (services, client) =>
client.BaseAddress = GetBaseUri(services.GetRequiredService<IConfiguration>(), "Insights"))
{
var configuration = services.GetRequiredService<IConfiguration>();
client.BaseAddress = GetBaseUri(configuration, "Insights");
client.DefaultRequestHeaders.Add("X-Gateway-Key", configuration["Services:Insights:Key"]);
})
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { AllowAutoRedirect = false });
builder.Services.AddHttpClient("HealthOverview", (services, client) =>
{
var configuration = services.GetRequiredService<IConfiguration>();
client.BaseAddress = GetBaseUri(configuration, "HealthOverview");
client.DefaultRequestHeaders.Add("X-Gateway-Key", configuration["Services:HealthOverview:Key"]);
})
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { AllowAutoRedirect = false });
var app = builder.Build();
_ = GetBaseUri(app.Configuration, "PatientProfile");
_ = GetBaseUri(app.Configuration, "Observation");
_ = GetBaseUri(app.Configuration, "Insights");
_ = GetBaseUri(app.Configuration, "HealthOverview");
foreach (var key in new[] { "Services:PatientProfile:Key", "Services:Observation:Key", "Services:Insights:Key", "Services:HealthOverview:Key", "InternalAccess:HealthOverview:Key", "InternalAccess:Observation:Key", "InternalAccess:Insights:Key" })
if (string.IsNullOrWhiteSpace(app.Configuration[key]) || app.Configuration[key]!.Length < 32)
throw new InvalidOperationException($"{key} must contain at least 32 characters.");
if (string.IsNullOrWhiteSpace(app.Configuration["Authentication:KeyDirectory"]))
throw new InvalidOperationException("Authentication:KeyDirectory is required.");
var lifetime = app.Configuration.GetValue("Authentication:TokenLifetimeMinutes", 30);
if (lifetime <= 0 || lifetime > 1440) throw new InvalidOperationException("Token lifetime must be between 1 and 1440 minutes.");
if (!app.Environment.IsDevelopment())
foreach (var service in new[] { "PatientProfile", "Observation", "Insights", "HealthOverview" })
if (GetBaseUri(app.Configuration, service).Scheme != "https")
throw new InvalidOperationException("Production service endpoints must use HTTPS.");
_ = app.Services.GetRequiredService<PrototypeAccounts>();
_ = app.Services.GetRequiredService<ProfessionalAssignments>();
app.UseExceptionHandler();
app.Use(async (context, next) =>
{
if (!app.Environment.IsDevelopment() && !context.Request.IsHttps) { context.Response.StatusCode = 400; return; }
await next(context);
});
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseMiddleware<PatientAccessMiddleware>();
app.MapControllers();
app.Run();
}
@@ -0,0 +1,29 @@
using System.Security.Claims;
using System.Security.Cryptography;
using System.Text;
using System.Text.Encodings.Web;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Options;
namespace ApiGateway.Security;
public sealed class InternalServiceAuthenticationHandler(IOptionsMonitor<AuthenticationSchemeOptions> options,
ILoggerFactory logger, UrlEncoder encoder, IConfiguration configuration)
: AuthenticationHandler<AuthenticationSchemeOptions>(options, logger, encoder)
{
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
{
var supplied = Request.Headers["X-Service-Key"].ToString();
foreach (var service in new[] { "Observation", "Insights", "HealthOverview" })
{
var expected = configuration[$"InternalAccess:{service}:Key"]!;
if (CryptographicOperations.FixedTimeEquals(Encoding.UTF8.GetBytes(supplied), Encoding.UTF8.GetBytes(expected)))
{
var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Role, "Service"),
new Claim(ClaimTypes.NameIdentifier, service) }, Scheme.Name);
return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(identity), Scheme.Name)));
}
}
return Task.FromResult(AuthenticateResult.Fail("Invalid service credential."));
}
}
@@ -0,0 +1,92 @@
using System.Net;
using System.Security.Claims;
using System.Text.Json;
using Microsoft.AspNetCore.Authorization;
namespace ApiGateway.Security;
public sealed class PatientAccessMiddleware(RequestDelegate next)
{
public async Task InvokeAsync(HttpContext context, IHttpClientFactory clients, IAuthorizationService authorization,
ProfessionalAssignments assignments)
{
if (context.GetEndpoint()?.Metadata.GetMetadata<IAllowAnonymous>() is not null)
{
await next(context);
return;
}
if (context.User.Identity?.IsAuthenticated != true) { context.Response.StatusCode = 401; return; }
var route = context.Request.Path.Value ?? "";
var segments = route.Trim('/').Split('/');
if (context.User.IsInRole("Service"))
{
var service = context.User.FindFirstValue(ClaimTypes.NameIdentifier);
var patientRoute = segments.Length >= 3 && segments[0] == "api" && segments[1] == "patients"
&& Guid.TryParse(segments[2], out _);
var allowed = context.Request.Method == "GET" && patientRoute && (service switch
{
"Observation" => segments.Length == 3,
"Insights" => segments.Length == 4 && segments[3] == "observations",
"HealthOverview" => segments.Length == 3 ||
(segments.Length == 4 && segments[3] == "insights") ||
(segments.Length == 5 && segments[3] == "observations" && segments[4] == "latest"),
_ => false
});
if (!allowed) { context.Response.StatusCode = 403; return; }
await next(context);
return;
}
var professional = (await authorization.AuthorizeAsync(context.User, "HealthcareProfessional")).Succeeded;
if (professional)
{
if (context.Request.Method != "GET") { context.Response.StatusCode = 403; return; }
if (route.Equals("/api/professionals/me/patients", StringComparison.OrdinalIgnoreCase))
{
await next(context);
return;
}
}
else if (!(await authorization.AuthorizeAsync(context.User, "Patient")).Succeeded)
{ context.Response.StatusCode = 403; return; }
if (!professional &&
((route.Equals("/api/patients", StringComparison.OrdinalIgnoreCase) && context.Request.Method == "POST")
|| (route.Equals("/api/patients/me", StringComparison.OrdinalIgnoreCase) && context.Request.Method == "GET")))
{
await next(context);
return;
}
try
{
var accountId = context.User.FindFirstValue(ClaimTypes.NameIdentifier)!;
Guid? patientId = null;
if (!professional)
{
using var ownResponse = await clients.CreateClient("PatientProfile").GetAsync(
"api/patients/by-account/" + Uri.EscapeDataString(accountId), context.RequestAborted);
if (ownResponse.StatusCode == HttpStatusCode.NotFound) { context.Response.StatusCode = 404; return; }
ownResponse.EnsureSuccessStatusCode();
using var own = JsonDocument.Parse(await ownResponse.Content.ReadAsStringAsync(context.RequestAborted));
patientId = own.RootElement.GetProperty("patientId").GetGuid();
}
Guid requestedPatient;
if (segments.Length >= 3 && segments[0] == "api" && segments[1] == "patients"
&& Guid.TryParse(segments[2], out requestedPatient)) { }
else if (segments.Length == 3 && segments[0] == "api" && segments[1] == "observations"
&& Guid.TryParse(segments[2], out var observationId))
{
using var response = await clients.CreateClient("Observation").GetAsync($"api/observations/{observationId}", context.RequestAborted);
if (response.StatusCode == HttpStatusCode.NotFound) { context.Response.StatusCode = 404; return; }
response.EnsureSuccessStatusCode();
using var observation = JsonDocument.Parse(await response.Content.ReadAsStringAsync(context.RequestAborted));
requestedPatient = observation.RootElement.GetProperty("patientId").GetGuid();
}
else { context.Response.StatusCode = 404; return; }
var permitted = professional ? assignments.IsAssigned(accountId, requestedPatient) : requestedPatient == patientId;
if (!permitted) { context.Response.StatusCode = 404; return; }
await next(context);
}
catch (HttpRequestException) { await Results.Problem(statusCode: 502, title: "Ownership lookup is unavailable.").ExecuteAsync(context); }
catch (OperationCanceledException) when (!context.RequestAborted.IsCancellationRequested)
{ await Results.Problem(statusCode: 504, title: "Ownership lookup timed out.").ExecuteAsync(context); }
}
}
@@ -0,0 +1,24 @@
namespace ApiGateway.Security;
// Application access data, separate from credentials and token contents.
public sealed class ProfessionalAssignments
{
private readonly Dictionary<string, Guid[]> assignments;
public ProfessionalAssignments(IConfiguration configuration)
{
assignments = configuration.GetSection("Access:ProfessionalAssignments")
.Get<Dictionary<string, Guid[]>>() ?? new(StringComparer.Ordinal);
foreach (var accountId in assignments.Keys.ToArray())
{
if (string.IsNullOrWhiteSpace(accountId) || assignments[accountId].Any(id => id == Guid.Empty))
throw new InvalidOperationException("Professional assignments require an account identifier and nonempty patient identifiers.");
assignments[accountId] = assignments[accountId].Distinct().Order().ToArray();
}
}
public IReadOnlyList<Guid> GetPatients(string accountId) =>
assignments.TryGetValue(accountId, out var patients) ? Array.AsReadOnly(patients) : Array.Empty<Guid>();
public bool IsAssigned(string accountId, Guid patientId) => GetPatients(accountId).Contains(patientId);
}
@@ -0,0 +1,39 @@
using Microsoft.AspNetCore.Identity;
namespace ApiGateway.Security;
public sealed class PrototypeAccount
{
public string AccountId { get; set; } = "";
public string Role { get; set; } = "Patient";
public string PasswordHash { get; set; } = "";
}
public sealed class PrototypeAccounts
{
private readonly Dictionary<string, PrototypeAccount> accounts;
private readonly PasswordHasher<PrototypeAccount> hasher = new();
private readonly PrototypeAccount dummy = new() { AccountId = "invalid" };
public PrototypeAccounts(IConfiguration configuration)
{
var configured = configuration.GetSection("Authentication:Accounts").Get<PrototypeAccount[]>() ?? [];
if (configured.Length == 0 || configured.Any(a => string.IsNullOrWhiteSpace(a.AccountId) || a.AccountId.Length > 128 || a.AccountId.Any(c => !char.IsAsciiLetterOrDigit(c) && c is not ('-' or '_')) || string.IsNullOrWhiteSpace(a.PasswordHash)
|| a.Role is not ("Patient" or "HealthcareProfessional")))
throw new InvalidOperationException("Authentication accounts require an identifier, password hash and supported role.");
accounts = configured.ToDictionary(a => a.AccountId, StringComparer.Ordinal);
dummy.PasswordHash = hasher.HashPassword(dummy, Guid.NewGuid().ToString());
}
public PrototypeAccount? Verify(string accountId, string password)
{
var known = accounts.TryGetValue(accountId, out var account);
account ??= dummy;
try
{
var result = hasher.VerifyHashedPassword(account, account.PasswordHash, password);
return known && result != PasswordVerificationResult.Failed ? account : null;
}
catch (FormatException) { return null; }
}
}
@@ -0,0 +1,30 @@
using System.ComponentModel.DataAnnotations;
using HealthOverviewService.Clients;
using HealthOverviewService.Contracts;
namespace HealthOverviewService.Application;
public sealed class HealthOverviewApplicationService(PatientProfileServiceClient patients,
ObservationServiceClient observations, InsightsServiceClient insights)
{
public async Task<HealthOverviewDto?> GetOverviewAsync(Guid patientId, DateTime from, DateTime to,
ContextSelection selection, CancellationToken cancellationToken)
{
from = NormalizeTimestamp(from);
to = NormalizeTimestamp(to);
if (to < from) throw new ArgumentException("The end time must not be earlier than the start time.", nameof(to));
Validator.ValidateObject(selection, new ValidationContext(selection), validateAllProperties: true);
var patient = await patients.GetPatientAsync(patientId, cancellationToken);
if (patient is null) return null;
var latest = await observations.GetLatestAsync(patientId, cancellationToken);
var insight = await insights.GetSummaryAsync(patientId, from, to, selection, cancellationToken);
return new(patient, latest, insight, from, to, selection, insight?.ContributingCount ?? 0,
"Latest overall observation for the patient, independent of the insight period and context selections. " +
"Its recorded context applies only to that observation, not to the insight's contributing observations.",
insight is null ? "No calculated insight is available: no observations match the requested period and insight selection." :
"The insight uses the requested period and context selection only. " + insight.ContextExplanation);
}
private static DateTime NormalizeTimestamp(DateTime value) => DateTime.SpecifyKind(
value.Kind == DateTimeKind.Unspecified ? value : value.ToUniversalTime(), DateTimeKind.Unspecified);
}
@@ -0,0 +1,28 @@
using System.Globalization;
using System.Net;
using System.Text.Json;
using HealthOverviewService.Contracts;
namespace HealthOverviewService.Clients;
public abstract class InsightsServiceClient
{
public abstract Task<HealthInsightDto?> GetSummaryAsync(Guid patientId, DateTime from, DateTime to, ContextSelection selection, CancellationToken cancellationToken);
}
public sealed class HttpInsightsServiceClient(HttpClient client) : InsightsServiceClient
{
public override async Task<HealthInsightDto?> GetSummaryAsync(Guid patientId, DateTime from, DateTime to, ContextSelection selection, CancellationToken cancellationToken)
{
var path = $"api/patients/{patientId}/insights";
path += $"?from={Uri.EscapeDataString(from.ToString("O", CultureInfo.InvariantCulture))}&to={Uri.EscapeDataString(to.ToString("O", CultureInfo.InvariantCulture))}";
if (selection.Setting is not null) path += "&setting=" + Uri.EscapeDataString(selection.Setting);
if (selection.ActivityCondition is not null) path += "&activityCondition=" + Uri.EscapeDataString(selection.ActivityCondition);
using var response = await client.GetAsync(path, cancellationToken);
if (response.StatusCode == HttpStatusCode.NotFound) return null;
response.EnsureSuccessStatusCode();
return await response.Content.ReadFromJsonAsync<HealthInsightDto>(cancellationToken)
?? throw new JsonException("Empty upstream response.");
}
}
@@ -0,0 +1,24 @@
using System.Globalization;
using System.Net;
using System.Text.Json;
using HealthOverviewService.Contracts;
namespace HealthOverviewService.Clients;
public abstract class ObservationServiceClient
{
public abstract Task<ObservationDto?> GetLatestAsync(Guid patientId, CancellationToken cancellationToken);
}
public sealed class HttpObservationServiceClient(HttpClient client) : ObservationServiceClient
{
public override async Task<ObservationDto?> GetLatestAsync(Guid patientId, CancellationToken cancellationToken)
{
var path = $"api/patients/{patientId}/observations/latest";
using var response = await client.GetAsync(path, cancellationToken);
if (response.StatusCode == HttpStatusCode.NotFound) return null;
response.EnsureSuccessStatusCode();
return await response.Content.ReadFromJsonAsync<ObservationDto>(cancellationToken)
?? throw new JsonException("Empty upstream response.");
}
}
@@ -0,0 +1,24 @@
using System.Globalization;
using System.Net;
using System.Text.Json;
using HealthOverviewService.Contracts;
namespace HealthOverviewService.Clients;
public abstract class PatientProfileServiceClient
{
public abstract Task<PatientDto?> GetPatientAsync(Guid patientId, CancellationToken cancellationToken);
}
public sealed class HttpPatientProfileServiceClient(HttpClient client) : PatientProfileServiceClient
{
public override async Task<PatientDto?> GetPatientAsync(Guid patientId, CancellationToken cancellationToken)
{
var path = $"api/patients/{patientId}";
using var response = await client.GetAsync(path, cancellationToken);
if (response.StatusCode == HttpStatusCode.NotFound) return null;
response.EnsureSuccessStatusCode();
return await response.Content.ReadFromJsonAsync<PatientDto>(cancellationToken)
?? throw new JsonException("Empty upstream response.");
}
}
@@ -0,0 +1,24 @@
using System.ComponentModel.DataAnnotations;
namespace HealthOverviewService.Contracts;
public sealed record ContextSelection
{
[AllowedValues("Home", "Clinic", "Other", "Unknown", null)]
public string? Setting { get; init; }
[AllowedValues("AtRest", "DuringActivity", "AfterActivity", "Unknown", null)]
public string? ActivityCondition { get; init; }
}
public sealed record PatientDto(Guid PatientId, string Name, DateOnly DateOfBirth, string? ContactInfo);
public sealed record MeasurementContextDto(string Setting, string ActivityCondition, decimal? RestDurationMinutes,
string? BodyPosition, string? MeasuredArm, string? DeviceDetails, string? CuffDetails, string? AdditionalCircumstances);
public sealed record ObservationDto(Guid ObservationId, Guid PatientId, DateTime MeasuredAt,
int Systolic, int Diastolic, int Pulse, string? Context, string? Note, MeasurementContextDto MeasurementContext);
public sealed record HealthInsightDto(Guid PatientId, DateTime PeriodStart, DateTime PeriodEnd,
decimal AverageSystolic, decimal AverageDiastolic, decimal AveragePulse,
int MinSystolic, int MaxSystolic, int MinDiastolic, int MaxDiastolic,
ContextSelection AppliedSelection, int ContributingCount, string ContextExplanation);
public sealed record HealthOverviewDto(PatientDto Patient, ObservationDto? LatestObservation, HealthInsightDto? Insight,
DateTime PeriodStart, DateTime PeriodEnd, ContextSelection InsightSelection, int InsightContributingCount,
string LatestObservationBasis, string InsightExplanation);
@@ -0,0 +1,34 @@
using HealthOverviewService.Application;
using HealthOverviewService.Contracts;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
namespace HealthOverviewService.Controllers;
[ApiController]
[Route("api/patients/{patientId:guid}/overview")]
public sealed class HealthOverviewController(HealthOverviewApplicationService service) : ControllerBase
{
[HttpGet]
public async Task<ActionResult<HealthOverviewDto>> GetOverview(Guid patientId,
[FromQuery, BindRequired] DateTime from, [FromQuery, BindRequired] DateTime to,
[FromQuery] ContextSelection selection, CancellationToken cancellationToken)
{
try
{
var result = await service.GetOverviewAsync(patientId, from, to, selection, cancellationToken);
return result is null ? Problem(statusCode: 404, title: "Patient does not exist.") : Ok(result);
}
catch (ArgumentException)
{
ModelState.AddModelError(nameof(to), "The end time must not be earlier than the start time.");
return ValidationProblem(ModelState);
}
catch (HttpRequestException)
{ return Problem(statusCode: 502, title: "Overview source service is unavailable."); }
catch (System.Text.Json.JsonException)
{ return Problem(statusCode: 502, title: "Overview source response is invalid."); }
catch (OperationCanceledException) when (!cancellationToken.IsCancellationRequested)
{ return Problem(statusCode: 504, title: "Overview source request timed out."); }
}
}
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="10.0.12" />
</ItemGroup>
</Project>
+79
View File
@@ -0,0 +1,79 @@
using System.Security.Cryptography;
using System.Text;
using HealthOverviewService.Application;
using HealthOverviewService.Clients;
namespace HealthOverviewService;
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseWindowsService(options => options.ServiceName = "healthapp-health-overview");
builder.Services.AddControllers();
builder.Services.AddProblemDetails();
builder.Services.AddScoped<HealthOverviewApplicationService>();
builder.Services.AddHttpClient<PatientProfileServiceClient, HttpPatientProfileServiceClient>((services, client) =>
{
var configuration = services.GetRequiredService<IConfiguration>();
client.BaseAddress = GetGatewayUri(configuration);
var serviceKey = configuration["Services:ApiGateway:Key"];
if (string.IsNullOrWhiteSpace(serviceKey) || serviceKey.Length < 32)
throw new InvalidOperationException("Services:ApiGateway:Key must contain at least 32 characters.");
client.DefaultRequestHeaders.Add("X-Service-Key", serviceKey);
})
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { AllowAutoRedirect = false });
builder.Services.AddHttpClient<ObservationServiceClient, HttpObservationServiceClient>((services, client) =>
{
var configuration = services.GetRequiredService<IConfiguration>();
client.BaseAddress = GetGatewayUri(configuration);
var serviceKey = configuration["Services:ApiGateway:Key"];
if (string.IsNullOrWhiteSpace(serviceKey) || serviceKey.Length < 32)
throw new InvalidOperationException("Services:ApiGateway:Key must contain at least 32 characters.");
client.DefaultRequestHeaders.Add("X-Service-Key", serviceKey);
})
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { AllowAutoRedirect = false });
builder.Services.AddHttpClient<InsightsServiceClient, HttpInsightsServiceClient>((services, client) =>
{
var configuration = services.GetRequiredService<IConfiguration>();
client.BaseAddress = GetGatewayUri(configuration);
var serviceKey = configuration["Services:ApiGateway:Key"];
if (string.IsNullOrWhiteSpace(serviceKey) || serviceKey.Length < 32)
throw new InvalidOperationException("Services:ApiGateway:Key must contain at least 32 characters.");
client.DefaultRequestHeaders.Add("X-Service-Key", serviceKey);
})
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { AllowAutoRedirect = false });
var app = builder.Build();
if (!app.Environment.IsDevelopment() && GetGatewayUri(app.Configuration).Scheme != "https")
throw new InvalidOperationException("Production gateway endpoints must use HTTPS.");
_ = GetGatewayUri(app.Configuration);
var outgoingKey = app.Configuration["Services:ApiGateway:Key"];
if (string.IsNullOrWhiteSpace(outgoingKey) || outgoingKey.Length < 32)
throw new InvalidOperationException("Services:ApiGateway:Key must contain at least 32 characters.");
var gatewayKey = app.Configuration["InternalAccess:GatewayKey"];
if (string.IsNullOrWhiteSpace(gatewayKey) || gatewayKey.Length < 32)
throw new InvalidOperationException("InternalAccess:GatewayKey must contain at least 32 characters.");
app.UseExceptionHandler();
app.Use(async (context, next) =>
{
var supplied = context.Request.Headers["X-Gateway-Key"].ToString();
if ((!app.Environment.IsDevelopment() && !context.Request.IsHttps) ||
!CryptographicOperations.FixedTimeEquals(Encoding.UTF8.GetBytes(supplied), Encoding.UTF8.GetBytes(gatewayKey)))
{ context.Response.StatusCode = 401; return; }
await next(context);
});
app.MapControllers();
app.Run();
}
private static Uri GetGatewayUri(IConfiguration configuration)
{
var endpoint = configuration["Services:ApiGateway:BaseUrl"];
if (!Uri.TryCreate(endpoint, UriKind.Absolute, out var uri) ||
(uri.Scheme != "http" && uri.Scheme != "https") || uri.AbsolutePath != "/" ||
!string.IsNullOrEmpty(uri.Query) || !string.IsNullOrEmpty(uri.Fragment) || !string.IsNullOrEmpty(uri.UserInfo))
throw new InvalidOperationException("Services:ApiGateway:BaseUrl must be an HTTP(S) origin URL.");
return uri;
}
}
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
@@ -1,3 +1,4 @@
using System.ComponentModel.DataAnnotations;
using InsightsService.Clients;
using InsightsService.Domain;
@@ -6,14 +7,27 @@ namespace InsightsService.Application;
public sealed class InsightsApplicationService(ObservationServiceClient observations, InsightCalculator calculator)
{
public async Task<HealthInsight?> GetSummaryAsync(Guid patientId, DateTime from, DateTime to,
CancellationToken cancellationToken)
ContextSelection selection, CancellationToken cancellationToken)
{
from = NormalizeTimestamp(from);
to = NormalizeTimestamp(to);
if (to < from)
throw new ArgumentException("The end time must not be earlier than the start time.", nameof(to));
var history = await observations.GetByPeriodAsync(patientId, from, to, cancellationToken);
return calculator.CalculateSummary(patientId, from, to, history);
Validator.ValidateObject(selection, new ValidationContext(selection), validateAllProperties: true);
var history = await observations.GetByPeriodAsync(patientId, from, to, selection, cancellationToken);
return calculator.CalculateSummary(patientId, from, to, history, selection);
}
public async Task<TrendAssessment> GetTrendAsync(Guid patientId, DateTime from, DateTime to,
ContextSelection selection, CancellationToken cancellationToken)
{
from = NormalizeTimestamp(from);
to = NormalizeTimestamp(to);
if (to < from)
throw new ArgumentException("The end time must not be earlier than the start time.", nameof(to));
Validator.ValidateObject(selection, new ValidationContext(selection), validateAllProperties: true);
var history = await observations.GetByPeriodAsync(patientId, from, to, selection, cancellationToken);
return calculator.CalculateTrend(patientId, from, to, history, selection);
}
private static DateTime NormalizeTimestamp(DateTime value) =>
@@ -1,3 +1,4 @@
using InsightsService.Domain;
using System.Globalization;
using InsightsService.Contracts;
@@ -6,11 +7,14 @@ namespace InsightsService.Clients;
public sealed class HttpObservationServiceClient(HttpClient client) : ObservationServiceClient
{
public async Task<List<ObservationDto>> GetByPeriodAsync(Guid patientId, DateTime from, DateTime to,
CancellationToken cancellationToken)
ContextSelection selection, 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}",
var filters = "";
if (selection.Setting is not null) filters += "&setting=" + Uri.EscapeDataString(selection.Setting);
if (selection.ActivityCondition is not null) filters += "&activityCondition=" + Uri.EscapeDataString(selection.ActivityCondition);
using var response = await client.GetAsync($"api/patients/{patientId}/observations?from={start}&to={end}{filters}",
HttpCompletionOption.ResponseHeadersRead, cancellationToken);
response.EnsureSuccessStatusCode();
return await response.Content.ReadFromJsonAsync<List<ObservationDto>>(cancellationToken)
@@ -1,3 +1,4 @@
using InsightsService.Domain;
using InsightsService.Contracts;
namespace InsightsService.Clients;
@@ -5,5 +6,5 @@ namespace InsightsService.Clients;
public interface ObservationServiceClient
{
Task<List<ObservationDto>> GetByPeriodAsync(Guid patientId, DateTime from, DateTime to,
CancellationToken cancellationToken);
ContextSelection selection, CancellationToken cancellationToken);
}
@@ -1,5 +1,8 @@
using InsightsService.Domain;
namespace InsightsService.Contracts;
public sealed record HealthInsightDto(Guid PatientId, DateTime PeriodStart, DateTime PeriodEnd,
decimal AverageSystolic, decimal AverageDiastolic, decimal AveragePulse,
int MinSystolic, int MaxSystolic, int MinDiastolic, int MaxDiastolic);
int MinSystolic, int MaxSystolic, int MinDiastolic, int MaxDiastolic,
ContextSelection AppliedSelection, int ContributingCount, string ContextExplanation);
@@ -1,4 +1,8 @@
namespace InsightsService.Contracts;
public sealed record ObservationDto(Guid ObservationId, Guid PatientId, DateTime MeasuredAt,
int Systolic, int Diastolic, int Pulse);
int Systolic, int Diastolic, int Pulse, MeasurementContextDto? MeasurementContext = null,
string? Context = null, string? Note = null);
public sealed record MeasurementContextDto(string? Setting, string? ActivityCondition, decimal? RestDurationMinutes,
string? BodyPosition, string? MeasuredArm, string? DeviceDetails, string? CuffDetails, string? AdditionalCircumstances);
@@ -1,3 +1,4 @@
using InsightsService.Domain;
using InsightsService.Application;
using InsightsService.Contracts;
using Microsoft.AspNetCore.Mvc;
@@ -12,16 +13,17 @@ public sealed class InsightsController(InsightsApplicationService service) : Con
[HttpGet]
public async Task<ActionResult<HealthInsightDto>> GetSummary(Guid patientId,
[FromQuery, BindRequired] DateTime from, [FromQuery, BindRequired] DateTime to,
CancellationToken cancellationToken)
[FromQuery] ContextSelection selection, CancellationToken cancellationToken)
{
try
{
var insight = await service.GetSummaryAsync(patientId, from, to, cancellationToken);
var insight = await service.GetSummaryAsync(patientId, from, to, selection, cancellationToken);
return insight is null
? Problem(statusCode: StatusCodes.Status404NotFound, title: "Insufficient observation data for calculation.")
: Ok(new HealthInsightDto(insight.PatientId, insight.PeriodStart, insight.PeriodEnd,
insight.AverageSystolic, insight.AverageDiastolic, insight.AveragePulse,
insight.MinSystolic, insight.MaxSystolic, insight.MinDiastolic, insight.MaxDiastolic));
insight.MinSystolic, insight.MaxSystolic, insight.MinDiastolic, insight.MaxDiastolic,
insight.AppliedSelection, insight.ContributingCount, insight.ContextExplanation));
}
catch (ArgumentException)
{
@@ -41,4 +43,32 @@ public sealed class InsightsController(InsightsApplicationService service) : Con
return Problem(statusCode: StatusCodes.Status504GatewayTimeout, title: "Observation history timed out.");
}
}
[HttpGet("/api/patients/{patientId:guid}/trends")]
public async Task<ActionResult<TrendAssessment>> GetTrend(Guid patientId,
[FromQuery, BindRequired] DateTime from, [FromQuery, BindRequired] DateTime to,
[FromQuery] ContextSelection selection, CancellationToken cancellationToken)
{
try
{
return Ok(await service.GetTrendAsync(patientId, from, to, selection, cancellationToken));
}
catch (ArgumentException)
{
ModelState.AddModelError(nameof(to), "The end time must not be earlier than the start time.");
return ValidationProblem(ModelState);
}
catch (HttpRequestException)
{
return Problem(statusCode: StatusCodes.Status502BadGateway, title: "Observation history is unavailable.");
}
catch (System.Text.Json.JsonException)
{
return Problem(statusCode: StatusCodes.Status502BadGateway, title: "Observation history response is invalid.");
}
catch (OperationCanceledException) when (!cancellationToken.IsCancellationRequested)
{
return Problem(statusCode: StatusCodes.Status504GatewayTimeout, title: "Observation history timed out.");
}
}
}
@@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;
namespace InsightsService.Domain;
public sealed record ContextSelection
{
[AllowedValues("Home", "Clinic", "Other", "Unknown", null)]
public string? Setting { get; init; }
[AllowedValues("AtRest", "DuringActivity", "AfterActivity", "Unknown", null)]
public string? ActivityCondition { get; init; }
}
+2 -1
View File
@@ -2,4 +2,5 @@ namespace InsightsService.Domain;
public sealed record HealthInsight(Guid PatientId, DateTime PeriodStart, DateTime PeriodEnd,
decimal AverageSystolic, decimal AverageDiastolic, decimal AveragePulse,
int MinSystolic, int MaxSystolic, int MinDiastolic, int MaxDiastolic);
int MinSystolic, int MaxSystolic, int MinDiastolic, int MaxDiastolic,
ContextSelection AppliedSelection, int ContributingCount, string ContextExplanation);
@@ -0,0 +1,223 @@
using System.Globalization;
using InsightsService.Contracts;
namespace InsightsService.Domain;
public sealed partial class InsightCalculator
{
private const string GeneralLimits = "General reference thresholds are not individual treatment targets. " +
"This is a descriptive assessment, not a diagnosis or medication recommendation. " +
"Symptoms, treatment, training, risk factors and measurement technique are not established by these observations.";
public TrendAssessment CalculateTrend(Guid patientId, DateTime from, DateTime to,
IReadOnlyList<ObservationDto> observations, ContextSelection selection)
{
var comparability = AssessComparability(observations);
return new(patientId, from, to, selection, observations.Count, comparability,
AssessMeasurement("Systolic", "mmHg", observations, o => o.Systolic, comparability),
AssessMeasurement("Diastolic", "mmHg", observations, o => o.Diastolic, comparability),
AssessMeasurement("Pulse", "beats/min", observations, o => o.Pulse, comparability));
}
private static MeasurementAssessment AssessMeasurement(string metric, string unit,
IReadOnlyList<ObservationDto> observations, Func<ObservationDto, int> value,
ComparabilityAssessment comparability)
{
if (observations.Count == 0)
return new(metric, unit, null, null, null, null, 0, "Unavailable", "Unavailable", null, 0,
null, "No matching observations; insufficient observation data for trend calculation.",
null, "Unavailable: no matching observations.", "CannotInterpret", GeneralLimits);
// Collapse timestamp ties for temporal calculations only; descriptive levels retain every observation.
var points = observations.GroupBy(o => o.MeasuredAt).OrderBy(g => g.Key)
.Select(g => (Time: g.Key, Value: g.Average(o => (decimal)value(o)))).ToArray();
var minimum = observations.Min(value);
var maximum = observations.Max(value);
var mean = observations.Average(o => (decimal)value(o));
var signs = points.Zip(points.Skip(1), (a, b) => Math.Sign(b.Value - a.Value))
.Where(s => s != 0).ToArray();
var reversals = signs.Zip(signs.Skip(1), (a, b) => a != b ? 1 : 0).Sum();
var direction = points.Length < 2 ? "Unavailable" : signs.Length == 0 ? "NoClearDirection" :
reversals > 0 ? "Mixed" : signs[0] > 0 ? "Increasing" : "Decreasing";
decimal? slope = null;
var overall = "Unavailable";
decimal? totalChange = null;
if (points.Length >= 2)
{
// Scale time to [0,1] before OLS, avoiding extreme timestamp magnitudes.
var span = (decimal)(points[^1].Time.Ticks - points[0].Time.Ticks);
var xs = points.Select(p => (p.Time.Ticks - points[0].Time.Ticks) / span).ToArray();
var xMean = xs.Average();
var yMean = points.Average(p => p.Value);
var numerator = points.Select((p, i) => (xs[i] - xMean) * (p.Value - yMean)).Sum();
var denominator = xs.Sum(x => (x - xMean) * (x - xMean));
var scaledSlope = numerator / denominator;
slope = scaledSlope / (span / TimeSpan.TicksPerDay);
overall = scaledSlope > 0 ? "Increasing" : scaledSlope < 0 ? "Decreasing" : "NoClearDirection";
totalChange = points.Zip(points.Skip(1), (a, b) => Math.Abs(b.Value - a.Value)).Sum();
}
var numerical = $"All {observations.Count} observations: mean {Format(mean)}, minimum {minimum}, maximum {maximum}, " +
$"range {maximum - minimum} {unit}. " + (points.Length < 2
? "Direction is unavailable: at least two distinct measurement timestamps are required."
: $"Temporal direction: {direction}; full-period least-squares direction: {overall}; " +
$"{reversals} reversal(s). Timestamp ties use arithmetic means. " +
$"Total successive change is {Format(totalChange!.Value)} {unit}.") +
" Range and successive change describe observed variation; no clinical stability classification is made.";
var reference = SelectReference(metric, observations, comparability);
var comparison = "Unavailable: known, non-conflicting resting conditions" +
(metric == "Pulse" ? "" : " and a single Home or Clinic setting") + " are required; recorded inadequate preparation also limits applicability.";
var interpretation = "CannotInterpret";
var hint = "Numerical changes alone do not establish favourable or concerning development.";
if (reference is not null)
{
var above = observations.Count(o => IsHigh(value(o), reference));
var below = observations.Count(o => IsLow(value(o), reference));
comparison = $"Descriptive mean {Format(mean)} {unit}; {above} observation(s) " +
$"{reference.UpperComparison} {Format(reference.UpperBoundary)} {unit}" +
(reference.LowerBoundary is { } lower ? $"; {below} observation(s) < {Format(lower)} {unit}." : ".") +
" This period does not establish a guideline diagnostic measurement protocol. " + reference.Limitation;
if (points.Length >= 2 && comparability.Status == "SupportedRecordedComparability")
{
var first = points[0].Value;
var last = points[^1].Value;
if (reversals > 0 && (above > 0 || below > 0))
{
interpretation = "Mixed";
hint = "Reversing movements and excursions outside the cited reference boundaries coexist; " +
"an overall slope does not establish consistent improvement or deterioration.";
}
else if (direction == "Decreasing" && IsHigh(first, reference) &&
!IsLow(last, reference) && below == 0 && (metric == "Pulse" || IsHigh(last, reference)))
{
interpretation = "PotentiallyFavourable";
hint = "Movement away from initially high levels towards the cited reference boundary may be favourable. " +
"This is a cautious inference from the source's reference comparison, not a clinical decision rule. " +
(IsHigh(last, reference) ? "The latest timestamp mean remains above or at the high boundary." :
"Reaching the reference interval does not establish an individual treatment target or good health.");
}
else if (metric == "Pulse" && direction == "Increasing" && IsLow(first, reference) &&
!IsHigh(last, reference) && above == 0)
{
interpretation = "PotentiallyFavourable";
hint = "Movement away from initially low resting pulse towards the reference interval may be favourable, " +
"but low pulse may be physiological in trained people. This is a cautious inference, not a clinical rule. " +
(IsLow(last, reference) ? "The latest timestamp mean remains below the lower boundary." :
"Being within these boundaries does not establish good health.");
}
else if (above > 0 || below > 0)
{
interpretation = "PotentiallyConcerning";
hint = "Observed levels outside the cited reference boundaries may warrant clinical review. " +
"Limited variation does not establish healthy levels, and a decrease into low resting pulse " +
"is not automatically favourable. The cause and individual significance cannot be determined here.";
}
}
else
hint = "The recorded context supports this limited reference comparison, but " +
(points.Length < 2 ? "temporal direction is unavailable. " :
"missing or differing conditions limit interpretation of the combined trajectory. ") +
"An outside-reference value is not dismissed because preparation information is incomplete.";
}
return new(metric, unit, Round(mean), minimum, maximum, maximum - minimum, points.Length,
direction, overall, slope is { } s ? Math.Round(s, 6, MidpointRounding.AwayFromZero) : null,
reversals, totalChange is { } change ? Round(change) : null, numerical, reference,
comparison, interpretation, hint + " " + comparability.Explanation + " " + GeneralLimits);
}
private static ClinicalReference? SelectReference(string metric, IReadOnlyList<ObservationDto> observations,
ComparabilityAssessment comparability)
{
if (comparability.Conflicts.Count > 0 ||
observations.Any(o => o.MeasurementContext?.ActivityCondition != "AtRest")) return null;
if (metric == "Pulse")
return new("Recorded resting pulse", 50, "<", 100, ">",
[new("Patienthåndbogen: Bradykardi (langsom puls)",
"https://www.sundhed.dk/borger/patienthaandbogen/hjerte-og-blodkar/sygdomme/hjertearytmier/bradykardi-langsom-puls/",
"2025-09-02", "2026-10-05"),
new("Patienthåndbogen: Hurtig puls (takykardi)",
"https://www.sundhed.dk/borger/patienthaandbogen/hjerte-og-blodkar/sygdomme/hjertearytmier/takykardier-hurtig-puls/",
"2025-05-12", "2026-10-05")],
"These are resting-rate reference boundaries, not a diagnosis, a universal normal range or a treatment target. " +
"Low pulse can be physiological in trained people; age, fitness, symptoms and medicines affect applicability.");
var settings = observations.Select(o => o.MeasurementContext?.Setting).Distinct().ToArray();
if (settings.Length != 1 || settings[0] is not ("Home" or "Clinic")) return null;
// Known inadequate rest prevents even a provisional resting-pressure comparison.
if (observations.Any(o => o.MeasurementContext?.RestDurationMinutes is < 5)) return null;
if (observations.Any(o => !string.IsNullOrWhiteSpace(o.MeasurementContext?.BodyPosition) &&
!new[] { "seated", "sitting", "siddende" }.Contains(o.MeasurementContext!.BodyPosition!.Trim(), StringComparer.OrdinalIgnoreCase)))
return null;
var threshold = metric == "Systolic" ? (settings[0] == "Home" ? 135 : 140) :
(settings[0] == "Home" ? 85 : 90);
return new($"Recorded {settings[0]} resting blood pressure", null, null, threshold, ">=",
[new("Lægehåndbogen: Højt blodtryk",
"https://www.sundhed.dk/sundhedsfaglig/laegehaandbogen/hjerte-kar/symptomer-og-tegn/hoejt-blodtryk/",
"2024-09-25", "2026-10-05")],
"Setting-specific high-pressure reference threshold. Missing preparation details make this comparison provisional; " +
"five minutes of rest, appropriate technique and repeated measurements are not inferred. " +
"Being below a high-pressure threshold does not establish an appropriate lower level or a personalised goal.");
}
private static bool IsHigh(decimal value, ClinicalReference reference) =>
reference.UpperComparison == ">=" ? value >= reference.UpperBoundary : value > reference.UpperBoundary;
private static bool IsLow(decimal value, ClinicalReference reference) =>
reference.LowerBoundary is { } lower && value < lower;
private static decimal Round(decimal value) => Math.Round(value, 2, MidpointRounding.AwayFromZero);
private static string Format(decimal value) => Round(value).ToString("0.##", CultureInfo.InvariantCulture);
private static ComparabilityAssessment AssessComparability(IReadOnlyList<ObservationDto> observations)
{
List<string> similarities = [], differences = [], missing = [], conflicts = [];
if (observations.Count == 0)
return new("InsufficientContext", similarities, differences, missing, conflicts,
"No matching observations are available to assess comparability.");
var details = new (string Name, string?[] Values)[]
{
("setting", observations.Select(o => o.MeasurementContext?.Setting).ToArray()),
("activity condition", observations.Select(o => o.MeasurementContext?.ActivityCondition).ToArray()),
("rest duration", observations.Select(o => o.MeasurementContext?.RestDurationMinutes?.ToString("G29", CultureInfo.InvariantCulture)).ToArray()),
("body position", observations.Select(o => o.MeasurementContext?.BodyPosition).ToArray()),
("measured arm", observations.Select(o => o.MeasurementContext?.MeasuredArm).ToArray()),
("device", observations.Select(o => o.MeasurementContext?.DeviceDetails).ToArray()),
("cuff", observations.Select(o => o.MeasurementContext?.CuffDetails).ToArray())
};
foreach (var (name, values) in details)
{
var known = values.Where(v => !string.IsNullOrWhiteSpace(v) && v != "Unknown")
.Select(v => v!.Trim()).Distinct(StringComparer.OrdinalIgnoreCase).Order(StringComparer.OrdinalIgnoreCase).ToArray();
if (values.Any(v => string.IsNullOrWhiteSpace(v) || v == "Unknown")) missing.Add(name);
if (known.Length > 1) differences.Add($"{name}: {string.Join(" / ", known)}");
else if (known.Length == 1 && !missing.Contains(name)) similarities.Add($"{name}: {known[0]}");
}
var circumstances = observations.Select(o => o.MeasurementContext?.AdditionalCircumstances)
.Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => s!.Trim())
.Distinct(StringComparer.OrdinalIgnoreCase).Order(StringComparer.OrdinalIgnoreCase).ToArray();
if (circumstances.Length > 1) differences.Add("additional circumstances differ");
if (observations.Any(o => o.MeasurementContext?.RestDurationMinutes is < 5))
differences.Add("recorded rest duration is below the five-minute blood-pressure preparation recommendation");
foreach (var observation in observations)
{
var context = observation.MeasurementContext;
var narrative = string.Join(" ", observation.Context, observation.Note, context?.AdditionalCircumstances,
context?.BodyPosition, context?.DeviceDetails, context?.CuffDetails).ToLowerInvariant();
if (context?.ActivityCondition == "AtRest" && new[]
{ "during exercise", "during activity", "after exercise", "after activity", "under motion", "under træning", "efter motion", "efter træning" }
.Any(narrative.Contains)) conflicts.Add("AtRest conflicts with an activity description in recorded text.");
if (context?.Setting == "Home" && new[] { "at clinic", "in clinic", "at the clinic", "på klinik", "hos lægen" }.Any(narrative.Contains))
conflicts.Add("Home conflicts with a clinic description in recorded text.");
if (context?.Setting == "Clinic" && new[] { "at home", "hjemme" }.Any(narrative.Contains))
conflicts.Add("Clinic conflicts with a home description in recorded text.");
}
var status = conflicts.Count > 0 ? "ConflictingContext" : differences.Count > 0 ? "KnownDifferences" :
missing.Count > 0 ? "InsufficientContext" : "SupportedRecordedComparability";
var explanation = $"Recorded comparability: {status}. " +
(missing.Count > 0 ? $"Unknown or missing: {string.Join(", ", missing)}. " : "") +
(differences.Count > 0 ? $"Known differences: {string.Join("; ", differences)}. " : "") +
(conflicts.Count > 0 ? $"Conflicts: {string.Join("; ", conflicts.Distinct())} " : "") +
"Matching recorded details support comparability only of those details; they do not certify identical " +
"conditions, validated equipment or guideline-compliant technique. Narrative conflict detection is limited " +
"to documented phrases; other text is not proof of comparability. A difference between Home and Clinic " +
"selections alone is not improvement or deterioration over time.";
return new(status, similarities, differences, missing, conflicts.Distinct().Order(StringComparer.Ordinal).ToArray(), explanation);
}
}
@@ -1,17 +1,50 @@
using System.Globalization;
using InsightsService.Contracts;
namespace InsightsService.Domain;
public sealed class InsightCalculator
public sealed partial class InsightCalculator
{
public HealthInsight? CalculateSummary(Guid patientId, DateTime from, DateTime to,
IReadOnlyList<ObservationDto> observations)
IReadOnlyList<ObservationDto> observations, ContextSelection selection)
{
if (observations.Count == 0)
return null;
return new HealthInsight(patientId, from, to,
observations.Average(o => (decimal)o.Systolic), observations.Average(o => (decimal)o.Diastolic),
observations.Average(o => (decimal)o.Pulse), observations.Min(o => o.Systolic),
observations.Max(o => o.Systolic), observations.Min(o => o.Diastolic), observations.Max(o => o.Diastolic));
Math.Round(observations.Average(o => (decimal)o.Systolic), 2, MidpointRounding.AwayFromZero),
Math.Round(observations.Average(o => (decimal)o.Diastolic), 2, MidpointRounding.AwayFromZero),
Math.Round(observations.Average(o => (decimal)o.Pulse), 2, MidpointRounding.AwayFromZero),
observations.Min(o => o.Systolic), observations.Max(o => o.Systolic),
observations.Min(o => o.Diastolic), observations.Max(o => o.Diastolic),
selection, observations.Count, DescribeContext(observations));
}
private static string DescribeContext(IReadOnlyList<ObservationDto> observations)
{
var settings = observations.Select(o => o.MeasurementContext?.Setting ?? "Unknown").ToArray();
var activities = observations.Select(o => o.MeasurementContext?.ActivityCondition ?? "Unknown").ToArray();
var explanation = $"Recorded settings: {Counts(settings)}. Recorded activity conditions: {Counts(activities)}.";
if (settings.Distinct().Count() > 1 || activities.Distinct().Count() > 1)
explanation += " This numerical summary pools mixed settings or activity conditions.";
if (settings.Contains("Unknown") || activities.Contains("Unknown"))
explanation += " Some setting or activity information is unknown.";
var details = new (string Name, string?[] Values)[]
{
("rest duration", observations.Select(o => o.MeasurementContext?.RestDurationMinutes?.ToString("G29", CultureInfo.InvariantCulture)).ToArray()),
("body position", observations.Select(o => o.MeasurementContext?.BodyPosition).ToArray()),
("measured arm", observations.Select(o => o.MeasurementContext?.MeasuredArm).ToArray()),
("device", observations.Select(o => o.MeasurementContext?.DeviceDetails).ToArray()),
("cuff", observations.Select(o => o.MeasurementContext?.CuffDetails).ToArray()),
("additional circumstances", observations.Select(o => o.MeasurementContext?.AdditionalCircumstances).ToArray())
};
var missing = details.Where(d => d.Values.Any(string.IsNullOrWhiteSpace)).Select(d => d.Name).ToArray();
var differing = details.Where(d => d.Values.Where(v => !string.IsNullOrWhiteSpace(v)).Distinct().Count() > 1)
.Select(d => d.Name).ToArray();
if (missing.Length > 0) explanation += $" Optional details are unrecorded for some observations: {string.Join(", ", missing)}.";
if (differing.Length > 0) explanation += $" Recorded detail values differ: {string.Join(", ", differing)}.";
return explanation + " These are descriptive statistics, not a diagnostic monitoring protocol; recorded categories alone do not establish clinically comparable conditions. Legacy narrative text does not establish a category.";
}
private static string Counts(IEnumerable<string> values) => string.Join(", ", values.GroupBy(v => v)
.OrderBy(g => g.Key, StringComparer.Ordinal).Select(g => $"{g.Key} ({g.Count()})"));
}
@@ -0,0 +1,21 @@
namespace InsightsService.Domain;
public sealed record TrendAssessment(Guid PatientId, DateTime PeriodStart, DateTime PeriodEnd,
ContextSelection AppliedSelection, int ContributingCount, ComparabilityAssessment Comparability,
MeasurementAssessment Systolic, MeasurementAssessment Diastolic, MeasurementAssessment Pulse);
public sealed record ComparabilityAssessment(string Status, IReadOnlyList<string> KnownSimilarities,
IReadOnlyList<string> KnownDifferences, IReadOnlyList<string> MissingDetails,
IReadOnlyList<string> Conflicts, string Explanation);
public sealed record MeasurementAssessment(string Metric, string Unit, decimal? Mean, int? Minimum,
int? Maximum, int? Range, int DistinctTimestampCount, string Direction, string OverallDirection,
decimal? SlopePerDay, int ReversalCount, decimal? TotalSuccessiveChange,
string NumericalExplanation, ClinicalReference? Reference, string ReferenceComparison,
string Interpretation, string Hint);
public sealed record ClinicalReference(string Scope, decimal? LowerBoundary, string? LowerComparison,
decimal UpperBoundary, string UpperComparison, IReadOnlyList<ReferenceSource> Sources,
string Limitation);
public sealed record ReferenceSource(string Title, string Url, string Updated, string Reviewed);
@@ -4,4 +4,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="10.0.12" />
</ItemGroup>
</Project>
+27 -1
View File
@@ -1,3 +1,5 @@
using System.Security.Cryptography;
using System.Text;
using InsightsService.Application;
using InsightsService.Clients;
using InsightsService.Domain;
@@ -9,16 +11,40 @@ public class Program
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseWindowsService(options => options.ServiceName = "healthapp-insights");
builder.Services.AddControllers();
builder.Services.AddProblemDetails();
builder.Services.AddScoped<InsightsApplicationService>();
builder.Services.AddSingleton<InsightCalculator>();
builder.Services.AddHttpClient<ObservationServiceClient, HttpObservationServiceClient>((services, client) =>
client.BaseAddress = GetGatewayUri(services.GetRequiredService<IConfiguration>()))
{
var configuration = services.GetRequiredService<IConfiguration>();
client.BaseAddress = GetGatewayUri(configuration);
var serviceKey = configuration["Services:ApiGateway:Key"];
if (string.IsNullOrWhiteSpace(serviceKey) || serviceKey.Length < 32)
throw new InvalidOperationException("Services:ApiGateway:Key must contain at least 32 characters.");
client.DefaultRequestHeaders.Add("X-Service-Key", serviceKey);
})
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { AllowAutoRedirect = false });
var app = builder.Build();
if (!app.Environment.IsDevelopment() && GetGatewayUri(app.Configuration).Scheme != "https")
throw new InvalidOperationException("Production gateway endpoints must use HTTPS.");
_ = GetGatewayUri(app.Configuration);
var outgoingKey = app.Configuration["Services:ApiGateway:Key"];
if (string.IsNullOrWhiteSpace(outgoingKey) || outgoingKey.Length < 32)
throw new InvalidOperationException("Services:ApiGateway:Key must contain at least 32 characters.");
var gatewayKey = app.Configuration["InternalAccess:GatewayKey"];
if (string.IsNullOrWhiteSpace(gatewayKey) || gatewayKey.Length < 32)
throw new InvalidOperationException("InternalAccess:GatewayKey must contain at least 32 characters.");
app.UseExceptionHandler();
app.Use(async (context, next) =>
{
var supplied = context.Request.Headers["X-Gateway-Key"].ToString();
if ((!app.Environment.IsDevelopment() && !context.Request.IsHttps) ||
!CryptographicOperations.FixedTimeEquals(Encoding.UTF8.GetBytes(supplied), Encoding.UTF8.GetBytes(gatewayKey)))
{ context.Response.StatusCode = 401; return; }
await next(context);
});
app.MapControllers();
app.Run();
}
+64
View File
@@ -0,0 +1,64 @@
# US-12 health overview
`GET /api/patients/{patientId}/overview?from=...&to=...&setting=Home&activityCondition=AtRest`
requires the patient's authenticated account or an assigned read-only professional.
Dates use the existing inclusive measurement-instant convention. Offset-free timestamps
mean UTC; equivalent offsets identify the same instant. From and to are required,
equal bounds are valid, reversed/malformed/missing bounds return 400. Both selected
context dimensions must match for insight; `Unknown` is an explicit selectable category.
Omitted dimensions are unrestricted. Unsupported selections return 400 validation details.
The independent ASP.NET Core Health Overview Service loads the profile, latest overall
observation and US-10 numerical insight through three HTTP clients routed through the
gateway. It has no production project references to another service, database, stored
aggregate or cache. The renamed Overview ER illustration explicitly denotes data needed
from other services rather than overview persistence; the current class model governs.
## Response
A successful request returns 200 with:
- `patient`: the current profile, including ID, name, birth date and contact information.
- `latestObservation`: latest overall reading, including original text, note and all recorded
structured context, or null when no observations exist. Latest retains US-06 timestamp,
original recording-time and deterministic ID ordering. The insight period and filters
never limit latest-observation selection.
- `insight`: the existing US-10 response or null when no observations match the insight
period/context. Its rounded means, extrema, selection, contributing count and context
explanation are preserved. No trend component is added.
- `periodStart`, `periodEnd`, `insightSelection`, `insightContributingCount`: explicit insight
basis even when insight is absent (count zero).
- `latestObservationBasis`: explains that latest context belongs to that reading only.
- `insightExplanation`: preserves the insight's context limitations or explains why no
selected-period insight is available. Empty insight does not remove profile/latest.
An authorized missing patient returns 404 with `Patient does not exist.` Access rejection
retains the gateway's non-disclosing empty 404 convention; unauthenticated clients get 401.
Professional writes remain forbidden. Upstream connection/status/invalid-JSON failures
return 502; local upstream timeouts return 504. These are not reported as absent data.
Only upstream 404 responses on the appropriate profile/latest/insight routes represent
missing data. Requests are cancelled on client disconnect.
Every overview request fetches current source data, including profile updates, corrected
measurement/context, and deletions. Reads occur separately across services, so concurrent
writes may occur between them; the overview does not promise a cross-service snapshot.
There is no extra transaction, refresh mechanism, synchronisation process or persisted
copy to invalidate.
## Deployment and verification
The service builds/publishes independently with .NET 10 and starts from external
configuration. See `deploy/health-overview.env.example`, the independent systemd unit,
[README.md](README.md) and [AUTHENTICATION.md](AUTHENTICATION.md). It requires only the
gateway origin and incoming/outgoing service credentials; no database configuration or
migration is needed. Production uses HTTPS; local HTTP is limited to Development.
Addresses, network binding, credentials and certificates are configurable for separate
machines. Standard stdout/stderr logging, graceful shutdown and restart follow the other
service units. No new package dependencies are introduced.
US-12 acceptance tests run five actual HTTP hosts against separate patient/observation
PostgreSQL databases. They cover all story scenarios, boundaries/offsets, patient scope,
latest tie rules, context preservation, independent filters, unknown/mixed context,
empty selected insight, corrections/deletions/restart, profile updates, missing patients,
validation, owner/assignment enforcement, direct bypass rejection, restricted internal
service reads and unavailable upstream/Overview services.
@@ -1,3 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.Net;
using ObservationService.Contracts;
using ObservationService.Domain;
@@ -15,8 +16,16 @@ public sealed class ObservationApplicationService(ObservationRepository reposito
if (request.Systolic is null or <= 0 || request.Diastolic is null or <= 0 || request.Pulse is null or <= 0)
throw new ArgumentException("Positive measured values are required.", nameof(request));
return repository.UpdateValuesAsync(observationId, request.Systolic.Value, request.Diastolic.Value,
request.Pulse.Value, DateTime.SpecifyKind(DateTime.UtcNow, DateTimeKind.Unspecified), cancellationToken);
return PatchAsync(observationId, new PatchObservationRequest { Systolic = request.Systolic, Diastolic = request.Diastolic, Pulse = request.Pulse }, cancellationToken);
}
public Task<BloodPressureObservation?> PatchAsync(Guid observationId, PatchObservationRequest request,
CancellationToken cancellationToken)
{
Validator.ValidateObject(request, new ValidationContext(request), validateAllProperties: true);
if (request.MeasurementContext is not null)
Validator.ValidateObject(request.MeasurementContext, new ValidationContext(request.MeasurementContext), validateAllProperties: true);
return repository.UpdateAsync(observationId, request, DateTime.SpecifyKind(DateTime.UtcNow, DateTimeKind.Unspecified), cancellationToken);
}
public async Task<BloodPressureObservation?> RecordAsync(Guid patientId, RecordObservationRequest request,
@@ -26,6 +35,14 @@ public sealed class ObservationApplicationService(ObservationRepository reposito
request.Diastolic is null or <= 0 || request.Pulse is null or <= 0)
throw new ArgumentException("A timestamp and positive measured values are required.", nameof(request));
var suppliedContext = request.MeasurementContext ?? new MeasurementContext();
var measurementContext = suppliedContext with
{
Setting = suppliedContext.Setting ?? "Unknown",
ActivityCondition = suppliedContext.ActivityCondition ?? "Unknown"
};
Validator.ValidateObject(measurementContext, new ValidationContext(measurementContext), validateAllProperties: true);
using var patient = await clients.CreateClient("ApiGateway").GetAsync($"api/patients/{patientId}",
HttpCompletionOption.ResponseHeadersRead, cancellationToken);
if (patient.StatusCode == HttpStatusCode.NotFound)
@@ -44,6 +61,7 @@ public sealed class ObservationApplicationService(ObservationRepository reposito
MeasuredAt = DateTime.SpecifyKind(measuredAt, DateTimeKind.Unspecified),
Systolic = request.Systolic.Value, Diastolic = request.Diastolic.Value,
Pulse = request.Pulse.Value, Context = request.Context, Note = request.Note,
MeasurementContext = measurementContext,
CreatedAt = now, UpdatedAt = now
}, cancellationToken);
}
@@ -55,13 +73,14 @@ public sealed class ObservationApplicationService(ObservationRepository reposito
repository.FindLatestByPatientIdAsync(patientId, cancellationToken);
public Task<List<BloodPressureObservation>> GetByPeriodAsync(Guid patientId, DateTime from, DateTime to,
CancellationToken cancellationToken)
ContextSelection selection, CancellationToken cancellationToken)
{
from = NormalizeTimestamp(from);
to = NormalizeTimestamp(to);
if (to < from)
throw new ArgumentException("The end time must not be earlier than the start time.", nameof(to));
return repository.FindByPatientIdAndPeriodAsync(patientId, from, to, cancellationToken);
Validator.ValidateObject(selection, new ValidationContext(selection), validateAllProperties: true);
return repository.FindByPatientIdAndPeriodAsync(patientId, from, to, selection, cancellationToken);
}
private static DateTime NormalizeTimestamp(DateTime timestamp) =>
@@ -1,3 +1,4 @@
using ObservationService.Contracts;
using ObservationService.Domain;
namespace ObservationService.Application;
@@ -5,11 +6,11 @@ namespace ObservationService.Application;
public interface ObservationRepository
{
Task<bool> DeleteAsync(Guid observationId, CancellationToken cancellationToken);
Task<BloodPressureObservation?> UpdateValuesAsync(Guid observationId, int systolic, int diastolic, int pulse,
Task<BloodPressureObservation?> UpdateAsync(Guid observationId, PatchObservationRequest request,
DateTime updatedAt, CancellationToken cancellationToken);
Task<BloodPressureObservation> SaveAsync(BloodPressureObservation observation, CancellationToken cancellationToken);
Task<BloodPressureObservation?> FindByIdAsync(Guid observationId, CancellationToken cancellationToken);
Task<BloodPressureObservation?> FindLatestByPatientIdAsync(Guid patientId, CancellationToken cancellationToken);
Task<List<BloodPressureObservation>> FindByPatientIdAndPeriodAsync(Guid patientId, DateTime from, DateTime to,
CancellationToken cancellationToken);
ContextSelection selection, CancellationToken cancellationToken);
}
@@ -0,0 +1,87 @@
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace ObservationService.Contracts;
[JsonUnmappedMemberHandling(JsonUnmappedMemberHandling.Disallow)]
public sealed record MeasurementContextPatch
{
private string? setting;
[AllowedValues("Home", "Clinic", "Other", "Unknown", null)]
public string? Setting
{
get => setting;
init { setting = value; SettingSpecified = true; }
}
[JsonIgnore]
public bool SettingSpecified { get; private set; }
private string? activityCondition;
[AllowedValues("AtRest", "DuringActivity", "AfterActivity", "Unknown", null)]
public string? ActivityCondition
{
get => activityCondition;
init { activityCondition = value; ActivityConditionSpecified = true; }
}
[JsonIgnore]
public bool ActivityConditionSpecified { get; private set; }
private decimal? restDurationMinutes;
[Range(0, double.MaxValue)]
public decimal? RestDurationMinutes
{
get => restDurationMinutes;
init { restDurationMinutes = value; RestDurationMinutesSpecified = true; }
}
[JsonIgnore]
public bool RestDurationMinutesSpecified { get; private set; }
private string? bodyPosition;
public string? BodyPosition
{
get => bodyPosition;
init { bodyPosition = value; BodyPositionSpecified = true; }
}
[JsonIgnore]
public bool BodyPositionSpecified { get; private set; }
private string? measuredArm;
public string? MeasuredArm
{
get => measuredArm;
init { measuredArm = value; MeasuredArmSpecified = true; }
}
[JsonIgnore]
public bool MeasuredArmSpecified { get; private set; }
private string? deviceDetails;
public string? DeviceDetails
{
get => deviceDetails;
init { deviceDetails = value; DeviceDetailsSpecified = true; }
}
[JsonIgnore]
public bool DeviceDetailsSpecified { get; private set; }
private string? cuffDetails;
public string? CuffDetails
{
get => cuffDetails;
init { cuffDetails = value; CuffDetailsSpecified = true; }
}
[JsonIgnore]
public bool CuffDetailsSpecified { get; private set; }
private string? additionalCircumstances;
public string? AdditionalCircumstances
{
get => additionalCircumstances;
init { additionalCircumstances = value; AdditionalCircumstancesSpecified = true; }
}
[JsonIgnore]
public bool AdditionalCircumstancesSpecified { get; private set; }
[JsonIgnore]
public bool HasChanges => SettingSpecified || ActivityConditionSpecified || RestDurationMinutesSpecified ||
BodyPositionSpecified || MeasuredArmSpecified || DeviceDetailsSpecified || CuffDetailsSpecified || AdditionalCircumstancesSpecified;
}
@@ -1,4 +1,6 @@
using ObservationService.Domain;
namespace ObservationService.Contracts;
public sealed record ObservationDto(Guid ObservationId, Guid PatientId, DateTime MeasuredAt,
int Systolic, int Diastolic, int Pulse, string? Context, string? Note);
int Systolic, int Diastolic, int Pulse, string? Context, string? Note, MeasurementContext MeasurementContext);
@@ -0,0 +1,78 @@
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace ObservationService.Contracts;
[JsonUnmappedMemberHandling(JsonUnmappedMemberHandling.Disallow)]
public sealed record PatchObservationRequest : IValidatableObject
{
private int? systolic;
[Range(1, int.MaxValue)]
public int? Systolic
{
get => systolic;
init { systolic = value; SystolicSpecified = true; }
}
[JsonIgnore]
public bool SystolicSpecified { get; private set; }
private int? diastolic;
[Range(1, int.MaxValue)]
public int? Diastolic
{
get => diastolic;
init { diastolic = value; DiastolicSpecified = true; }
}
[JsonIgnore]
public bool DiastolicSpecified { get; private set; }
private int? pulse;
[Range(1, int.MaxValue)]
public int? Pulse
{
get => pulse;
init { pulse = value; PulseSpecified = true; }
}
[JsonIgnore]
public bool PulseSpecified { get; private set; }
private MeasurementContextPatch? measurementContext;
public MeasurementContextPatch? MeasurementContext
{
get => measurementContext;
init { measurementContext = value; MeasurementContextSpecified = true; }
}
[JsonIgnore]
public bool MeasurementContextSpecified { get; private set; }
private string? context;
public string? Context
{
get => context;
init { context = value; ContextSpecified = true; }
}
[JsonIgnore]
public bool ContextSpecified { get; private set; }
private string? note;
public string? Note
{
get => note;
init { note = value; NoteSpecified = true; }
}
[JsonIgnore]
public bool NoteSpecified { get; private set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (SystolicSpecified && Systolic is null)
yield return new ValidationResult("Systolic cannot be cleared.", [nameof(Systolic)]);
if (DiastolicSpecified && Diastolic is null)
yield return new ValidationResult("Diastolic cannot be cleared.", [nameof(Diastolic)]);
if (PulseSpecified && Pulse is null)
yield return new ValidationResult("Pulse cannot be cleared.", [nameof(Pulse)]);
if (!SystolicSpecified && !DiastolicSpecified && !PulseSpecified && !ContextSpecified && !NoteSpecified &&
!(MeasurementContextSpecified && (MeasurementContext is null || MeasurementContext.HasChanges)))
yield return new ValidationResult("Supply at least one supported field to update.");
}
}
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using ObservationService.Domain;
namespace ObservationService.Contracts;
@@ -16,6 +17,8 @@ public sealed record RecordObservationRequest
[Required, Range(1, int.MaxValue)]
public int? Pulse { get; init; }
public MeasurementContext? MeasurementContext { get; init; }
public string? Context { get; init; }
public string? Note { get; init; }
}
@@ -1,7 +1,9 @@
using System.Text.Json.Serialization;
using System.ComponentModel.DataAnnotations;
namespace ObservationService.Contracts;
[JsonUnmappedMemberHandling(JsonUnmappedMemberHandling.Disallow)]
public sealed record UpdateObservationRequest
{
[Required, Range(1, int.MaxValue)]
@@ -43,6 +43,14 @@ public sealed class ObservationController(ObservationApplicationService service)
return observation is null ? NotFound() : Ok(ToDto(observation));
}
[HttpPatch("observations/{observationId:guid}")]
public async Task<ActionResult<ObservationDto>> PatchObservation(Guid observationId, PatchObservationRequest request,
CancellationToken cancellationToken)
{
var observation = await service.PatchAsync(observationId, request, cancellationToken);
return observation is null ? NotFound() : Ok(ToDto(observation));
}
[HttpGet("observations/{observationId:guid}")]
public async Task<ActionResult<ObservationDto>> GetObservation(Guid observationId, CancellationToken cancellationToken)
{
@@ -60,11 +68,13 @@ public sealed class ObservationController(ObservationApplicationService service)
[HttpGet("patients/{patientId:guid}/observations")]
public async Task<ActionResult<List<ObservationDto>>> GetByPeriod(Guid patientId,
[FromQuery, BindRequired] DateTime from, [FromQuery, BindRequired] DateTime to,
CancellationToken cancellationToken)
[FromQuery] ContextSelection selection, CancellationToken cancellationToken)
{
try
{
var observations = await service.GetByPeriodAsync(patientId, from, to, cancellationToken);
var observations = await service.GetByPeriodAsync(patientId, from, to, selection, cancellationToken);
Response.Headers["X-Measurement-Setting"] = selection.Setting ?? "All";
Response.Headers["X-Activity-Condition"] = selection.ActivityCondition ?? "All";
return Ok(observations.Select(ToDto).ToList());
}
catch (ArgumentException)
@@ -76,5 +86,5 @@ public sealed class ObservationController(ObservationApplicationService service)
private static ObservationDto ToDto(BloodPressureObservation observation) =>
new(observation.ObservationId, observation.PatientId, observation.MeasuredAt, observation.Systolic,
observation.Diastolic, observation.Pulse, observation.Context, observation.Note);
observation.Diastolic, observation.Pulse, observation.Context, observation.Note, observation.MeasurementContext);
}
@@ -8,6 +8,7 @@ public sealed class BloodPressureObservation
public int Systolic { get; set; }
public int Diastolic { get; set; }
public int Pulse { get; set; }
public MeasurementContext MeasurementContext { get; set; } = new();
public string? Context { get; set; }
public string? Note { get; set; }
public DateTime CreatedAt { get; set; }
@@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;
namespace ObservationService.Domain;
public sealed record ContextSelection
{
[AllowedValues("Home", "Clinic", "Other", "Unknown", null)]
public string? Setting { get; init; }
[AllowedValues("AtRest", "DuringActivity", "AfterActivity", "Unknown", null)]
public string? ActivityCondition { get; init; }
}
@@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;
namespace ObservationService.Domain;
public sealed record MeasurementContext
{
[AllowedValues("Home", "Clinic", "Other", "Unknown", null)]
public string? Setting { get; init; } = "Unknown";
[AllowedValues("AtRest", "DuringActivity", "AfterActivity", "Unknown", null)]
public string? ActivityCondition { get; init; } = "Unknown";
[Range(0, double.MaxValue)]
public decimal? RestDurationMinutes { get; init; }
public string? BodyPosition { get; init; }
public string? MeasuredArm { get; init; }
public string? DeviceDetails { get; init; }
public string? CuffDetails { get; init; }
public string? AdditionalCircumstances { get; init; }
}
Loaded 100 of 185 files, more files were not shown because too many files have changed in this diff. Show more