Implement US-13 patient authentication and persistent ownership
This commit is contained in:
1 parent
ebf50827d6
commit
0ce9b2b168
36 files changed
+1203
-28
No files matched your search
+24
-3
@@ -1,11 +1,21 @@
|
||||
# US-01–US-10: Patient profiles and blood-pressure observations
|
||||
# Patient profiles, observations, insights and authentication
|
||||
|
||||
Implemented with .NET 10 LTS (see the [official download page](https://dotnet.microsoft.com/en-us/download/dotnet/10.0)), ASP.NET Core controllers, and PostgreSQL/EF Core. The API gateway, Patient/Profile service, Observation Service, and Insights Service are separate executables and can run on separate machines. Patient/Profile and Observation each own a database. Insights calculates on demand without persistence, following `Docs/Requirements/US_10_Correction` and `Docs/Architecture/us10-insights-correction.md`.
|
||||
Implemented with .NET 10 LTS (see the [official download page](https://dotnet.microsoft.com/en-us/download/dotnet/10.0)), ASP.NET Core controllers, and PostgreSQL/EF Core. The API gateway, Patient/Profile service, Observation Service, and Insights Service are separate executables and can run on separate machines. Patient/Profile and Observation each own a database. Insights calculates on demand without persistence, following `Docs/Architecture/us10-insights-correction.md`.
|
||||
|
||||
The controller calls `PatientApplicationService`, which uses `PatientRepository`, implemented by `SqlPatientRepository`. The service owns the `patient` table from the ER diagram, including creation/update timestamps stored as UTC in PostgreSQL `timestamp` columns.
|
||||
|
||||
US-13 now protects the patient-data APIs. Read [AUTHENTICATION.md](AUTHENTICATION.md)
|
||||
for login, persistent profile ownership, deployment credentials and token settings.
|
||||
Configure the required keys/accounts before startup. The revised US-01 creation
|
||||
lifecycle is included; US-14 assigned-professional access remains pending.
|
||||
|
||||
## Build and run
|
||||
|
||||
Load external service configuration using the updated `deploy/*.env.example` templates.
|
||||
Use HTTPS certificates for all production endpoints. For local HTTP development
|
||||
only, set `ASPNETCORE_ENVIRONMENT=Development` on each process; all credentials and
|
||||
the gateway key directory are still required.
|
||||
|
||||
Install a .NET 10 SDK and provision an empty PostgreSQL database owned by the Patient/Profile service's database user. From the repository root:
|
||||
|
||||
```bash
|
||||
@@ -38,9 +48,16 @@ Send requests to the gateway:
|
||||
```bash
|
||||
curl -i http://127.0.0.1:5080/api/patients \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Bearer YOUR_LOGIN_TOKEN' \
|
||||
-d '{"name":"Steffen Example","dateOfBirth":"1980-01-01","contactInfo":"steffen@example.test"}'
|
||||
```
|
||||
|
||||
`POST /api/authentication/login` accepts `accountId` and `password` and returns a
|
||||
protected access token. Include `Authorization: Bearer YOUR_LOGIN_TOKEN` on each
|
||||
patient-data request below. Initial profile creation is permitted once per patient
|
||||
account; repeated/concurrent attempts report `409`. `GET /api/patients/me` retrieves
|
||||
the account’s profile when its generated identifier is not yet known.
|
||||
|
||||
`POST /api/patients` returns `201 Created`, a relative `Location: /api/patients/{patientId}` header, and a JSON profile containing `patientId`, `name`, `dateOfBirth`, and `contactInfo`. Identifiers are generated UUIDs and the database primary key enforces uniqueness. Names must be nonblank; dates of birth must be supplied as valid `YYYY-MM-DD` dates. Invalid requests return `400` validation problem details and do not create profiles. Contact information is optional because US-01 does not require it.
|
||||
|
||||
`GET /api/patients/{patientId}` retrieves the persisted profile, or returns `404` when absent. Retrieval is included because US-01 explicitly requires it. The gateway returns `502` for connection failures and `504` for upstream timeouts.
|
||||
@@ -73,7 +90,11 @@ The independent Insights Service follows the documented controller/application-s
|
||||
|
||||
US-10 tests use all four HTTP hosts and the existing separate patient/observation test databases. They cover all five acceptance scenarios, fractional averages, patient and inclusive-period filtering, equal/offset bounds, corrections/deletions, restart, malformed/missing periods, and unavailable observation retrieval. Insights introduces no external dependencies. Trend calculation remains outside this story.
|
||||
|
||||
Authentication and access control are defined in US-13, US-14 and `Docs/Design/authentication-and-access-control-design.md`, and remain to be implemented as separate stories, as explicitly instructed. These endpoints currently have no access restrictions.
|
||||
US-13 authentication and patient ownership are implemented as described in
|
||||
[AUTHENTICATION.md](AUTHENTICATION.md). The account-to-profile association is persisted
|
||||
in the patient service. US-14 assigned-professional read access remains pending;
|
||||
professional patient-data operations are denied until then. Updated context, tie
|
||||
and rounding requirements in other stories remain to be implemented incrementally.
|
||||
|
||||
## Automated acceptance tests
|
||||
|
||||
|
||||
Reference in new issue
Block a user