Files
HealthAppRepositoryB/Docs/Requirements/us01-create-patient-profile.md

4.0 KiB

US-01 — Create a patient profile

The common requirements apply to this story.

User story

As a patient, I want to create a patient profile so that my health measurements can be associated with me.

Functional requirements

A patient must be authenticated to create their own initial profile. A patient account has no associated profile before successful initial creation and exactly one afterwards. The association derives from the authenticated account, never an account or patient identity selected by the caller.

Creation assigns a patient identifier and persistently associates it with the account. The association survives process restart. A later create request shall report that a profile already exists and shall neither create a second profile nor replace the association.

Concurrent requests and retries after a lost response or an interrupted creation shall not produce duplicate or inaccessible profiles. After recovery, at most one profile exists for the account and a successful outcome leaves that profile accessible to it. The implementation may choose the recovery and concurrency mechanisms. It shall not report successful creation before both profile creation and association are complete.

Healthcare professionals cannot create patient profiles. Unauthenticated requests are rejected. Account registration remains outside scope.

Acceptance criteria

Feature: Create patient profile

  Scenario: Create a patient with valid information
    Given an authenticated patient account has no associated profile
    When a patient profile is created with
      | name        | Steffen Example       |
      | dateOfBirth | 1980-01-01            |
      | contactInfo | steffen@example.test  |
    Then the patient profile is created successfully
    And a patient identifier is assigned
    And the identifier is associated with the authenticated account

  Scenario: A patient name is required
    When a patient profile is created without a name
    Then the patient profile is rejected

  Scenario: A date of birth is required
    When a patient profile is created without a date of birth
    Then the patient profile is rejected
Scenario: Reject a second profile
  Given an authenticated patient account already has a profile
  When another profile creation is requested
  Then the request reports that a profile already exists
  And no second profile is created and the association is unchanged
Scenario: Persistent account association
  Given a profile and its account association were successfully created
  And the application processes have restarted
  When the authenticated account requests its profile
  Then the same associated profile is returned
Scenario: Retry after a successful creation response was lost
  Given profile creation and account association succeeded but the response was lost
  When the authenticated account retries creation
  Then the result indicates that the profile already exists
  And no duplicate profile or replacement association is created
Scenario: Concurrent initial creation
  Given an authenticated patient account has no profile
  When two valid initial-creation requests are made concurrently
  Then at most one profile is created and associated with the account
  And no request reports a second profile as created
Scenario: Recovery after interrupted creation
  Given initial profile creation was interrupted before profile creation and association both completed
  And the system is able to process requests again
  When the authenticated account retries creation
  Then the operation recovers to one accessible associated profile or reports that creation remains incomplete
  And it neither produces duplicate profiles nor reports an inaccessible profile as successfully created
Scenario: Unauthenticated initial creation
  Given the caller is not authenticated
  When initial profile creation is requested
  Then the request is rejected and no profile is created