|
| 1 | +## ADDED Requirements |
| 2 | + |
| 3 | +### Requirement: Search parameters extracted from CapabilityStatement |
| 4 | + |
| 5 | +The `parseCapabilities` function SHALL extract search parameter definitions from |
| 6 | +each resource's `searchParam` array in the CapabilityStatement. Each search |
| 7 | +parameter SHALL include its name and type. The `ResourceCapability` interface |
| 8 | +SHALL be extended to include a `searchParams` field containing an array of |
| 9 | +`{ name: string; type: string }` objects. |
| 10 | + |
| 11 | +#### Scenario: CapabilityStatement contains search parameters for Patient |
| 12 | + |
| 13 | +- **WHEN** the CapabilityStatement declares search parameters `gender` (token), |
| 14 | + `birthdate` (date), and `name` (string) for the Patient resource |
| 15 | +- **THEN** the parsed `ResourceCapability` for Patient SHALL include a |
| 16 | + `searchParams` array containing entries for `gender` with type `token`, |
| 17 | + `birthdate` with type `date`, and `name` with type `string` |
| 18 | + |
| 19 | +#### Scenario: CapabilityStatement has resource with no search parameters |
| 20 | + |
| 21 | +- **WHEN** the CapabilityStatement declares a resource type with no |
| 22 | + `searchParam` entries |
| 23 | +- **THEN** the parsed `ResourceCapability` for that resource SHALL have an |
| 24 | + empty `searchParams` array |
| 25 | + |
| 26 | +### Requirement: Search parameter section in search form |
| 27 | + |
| 28 | +The resource search form SHALL include a "Search parameters" section positioned |
| 29 | +between the resource type selector and the FHIRPath filters section. This |
| 30 | +section SHALL allow users to add rows, where each row consists of a parameter |
| 31 | +name dropdown and a value text input. |
| 32 | + |
| 33 | +#### Scenario: Initial form state |
| 34 | + |
| 35 | +- **WHEN** the search form is first rendered |
| 36 | +- **THEN** the search parameters section SHALL be displayed with a heading, an |
| 37 | + "Add parameter" button, and one empty parameter row |
| 38 | + |
| 39 | +#### Scenario: User adds a search parameter row |
| 40 | + |
| 41 | +- **WHEN** the user clicks the "Add parameter" button |
| 42 | +- **THEN** a new parameter row SHALL be appended with an empty parameter |
| 43 | + dropdown and an empty value input |
| 44 | + |
| 45 | +#### Scenario: User removes a search parameter row |
| 46 | + |
| 47 | +- **WHEN** the user clicks the remove button on a parameter row and there is |
| 48 | + more than one row |
| 49 | +- **THEN** that row SHALL be removed from the form |
| 50 | + |
| 51 | +#### Scenario: Last parameter row cannot be removed |
| 52 | + |
| 53 | +- **WHEN** there is only one parameter row |
| 54 | +- **THEN** the remove button on that row SHALL be disabled |
| 55 | + |
| 56 | +### Requirement: Parameter dropdown populated by resource type |
| 57 | + |
| 58 | +The parameter name dropdown in each search parameter row SHALL display the |
| 59 | +search parameters available for the currently selected resource type, as |
| 60 | +extracted from the CapabilityStatement. Each option SHALL show the parameter |
| 61 | +name, with the parameter type displayed as a badge next to it. |
| 62 | + |
| 63 | +#### Scenario: Parameter list updates on resource type change |
| 64 | + |
| 65 | +- **WHEN** the user changes the selected resource type from Patient to |
| 66 | + Observation |
| 67 | +- **THEN** the parameter dropdown options SHALL update to show search parameters |
| 68 | + declared for Observation, and any previously selected parameters that are not |
| 69 | + valid for Observation SHALL be cleared |
| 70 | + |
| 71 | +#### Scenario: No search parameters available |
| 72 | + |
| 73 | +- **WHEN** the selected resource type has no declared search parameters |
| 74 | +- **THEN** the parameter dropdown SHALL be empty and display placeholder text |
| 75 | + indicating no parameters are available |
| 76 | + |
| 77 | +### Requirement: Search parameters included in search request |
| 78 | + |
| 79 | +When the user submits the search form, any search parameter rows with both a |
| 80 | +selected parameter name and a non-empty value SHALL be included in the search |
| 81 | +request as standard FHIR query parameters alongside any FHIRPath filters. |
| 82 | + |
| 83 | +#### Scenario: Search with standard parameters only |
| 84 | + |
| 85 | +- **WHEN** the user selects resource type "Patient", adds parameter "gender" |
| 86 | + with value "male", leaves the FHIRPath filter empty, and submits the search |
| 87 | +- **THEN** the search request SHALL be sent as |
| 88 | + `GET [base]/Patient?gender=male&_count=10` |
| 89 | + |
| 90 | +#### Scenario: Search combining standard parameters and FHIRPath filters |
| 91 | + |
| 92 | +- **WHEN** the user selects resource type "Patient", adds parameter "gender" |
| 93 | + with value "male", adds FHIRPath filter `active = true`, and submits the |
| 94 | + search |
| 95 | +- **THEN** the search request SHALL be sent as |
| 96 | + `GET [base]/Patient?_query=fhirPath&filter=active = true&gender=male&_count=10` |
| 97 | + |
| 98 | +#### Scenario: Empty parameter rows are excluded |
| 99 | + |
| 100 | +- **WHEN** the user has a parameter row with no parameter selected or no value |
| 101 | + entered, and submits the search |
| 102 | +- **THEN** that row SHALL be excluded from the search request |
| 103 | + |
| 104 | +#### Scenario: Multiple values for the same parameter |
| 105 | + |
| 106 | +- **WHEN** the user adds two rows for the same parameter name with different |
| 107 | + values |
| 108 | +- **THEN** both values SHALL be sent as repeated query parameters (AND logic), |
| 109 | + e.g., `date=gt2020-01-01&date=lt2025-01-01` |
| 110 | + |
| 111 | +### Requirement: SearchRequest type extended for standard parameters |
| 112 | + |
| 113 | +The `SearchRequest` interface SHALL be extended to include a `params` field of |
| 114 | +type `Record<string, string[]>` to carry standard search parameter name-value |
| 115 | +pairs alongside the existing `filters` array. |
| 116 | + |
| 117 | +#### Scenario: SearchRequest with both filters and params |
| 118 | + |
| 119 | +- **WHEN** a search is submitted with FHIRPath filter `active = true` and |
| 120 | + search parameter `gender=male` |
| 121 | +- **THEN** the `SearchRequest` object SHALL contain |
| 122 | + `filters: ["active = true"]` and `params: { gender: ["male"] }` |
| 123 | + |
| 124 | +### Requirement: Help text for search parameters section |
| 125 | + |
| 126 | +The search parameters section SHALL include help text explaining that search |
| 127 | +parameters use standard FHIR search syntax and are combined with AND logic. |
| 128 | + |
| 129 | +#### Scenario: Help text is displayed |
| 130 | + |
| 131 | +- **WHEN** the search form is rendered |
| 132 | +- **THEN** the search parameters section SHALL display help text below the |
| 133 | + parameter rows explaining the AND combination logic and that values use |
| 134 | + standard FHIR search syntax |
0 commit comments