Task/ftrs 2590 toggle for search by triage code#1025
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a feature-flagged triage-code search endpoint for the DoS Search service, while also refactoring common Lambda runtime/response construction and standardising feature-flag guarding utilities in ftrs_common.
Changes:
- Add a new
/triage_codePOST Lambda endpoint gated bydos_search_triage_code_enabled, plus supporting Terraform/APIGW wiring and monitoring. - Introduce
functions/response_util.pyto centralise Powertools runtime construction and FHIR response header/response creation. - Add reusable feature-flag guard/guard-chain utilities in
ftrs_common.feature_flagsand refactor healthcare-service endpoint to use them.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| services/dos-search/functions/response_util.py | New shared runtime/headers/response factory for dos-search Lambdas. |
| services/dos-search/functions/dos_search_triage_code_function.py | New triage-code POST endpoint with feature-flag guard chain. |
| services/dos-search/functions/dos_search_healthcare_service_function.py | Refactors healthcare-service endpoint to use new feature-flag guard chain + response util. |
| services/dos-search/functions/dos_search_ods_code_function.py | Refactors ODS Organization endpoint to use shared response util/runtime. |
| services/dos-search/functions/error_util.py | Generalises service-unavailable OperationOutcome factory to accept service/status text. |
| services/dos-search/functions/logbase.py | Adds log references for triage-code request/flag/metrics events. |
| services/dos-search/functions/constants.py | Adds shared feature-flag log context dict. |
| services/dos-search/tests/unit/functions/test_response_util.py | Unit tests for new response/runtime utilities. |
| services/dos-search/tests/unit/functions/test_dos_search_triage_code_function.py | Unit tests for the new triage-code Lambda handler + flag behaviour. |
| services/dos-search/tests/unit/functions/test_dos_search_ods_code_function.py | Updates tests to align with response util refactor (logging expectations changed). |
| services/dos-search/tests/unit/functions/test_dos_search_healthcare_service_function.py | Updates tests for refactored healthcare-service handler and new flag evaluation approach. |
| services/dos-search/tests/unit/functions/test_error_util.py | Adds tests for parameterised service-unavailable OperationOutcome. |
| application/packages/python/ftrs_common/feature_flags/feature_flag_handlers.py | New shared request-guard and feature-flag guard-chain implementation. |
| application/packages/python/ftrs_common/feature_flags/init.py | Re-exports new feature-flag guard APIs. |
| application/packages/python/ftrs_common/feature_flags/feature_flag_config.py | Adds DOS_SEARCH_TRIAGE_CODE_ENABLED flag. |
| application/packages/python/ftrs_common/tests/feature_flags/test_feature_flag_handlers.py | Unit tests for new guard/guard-chain utilities. |
| application/packages/python/ftrs_common/tests/feature_flags/test_feature_flags_client.py | Test refactors/cleanup for the feature-flags client. |
| infrastructure/toggles/toggle-registry.yaml | Registers dos_search_triage_code_enabled toggle across environments. |
| infrastructure/stacks/dos_search/api-gateway-rest-resource-triage-code.tf | Adds APIGW resource/method/integration for POST /triage_code. |
| infrastructure/stacks/dos_search/api-gateway-rest-deployment.tf | Ensures deployment depends on new triage-code APIGW integration/method/resource. |
| infrastructure/stacks/dos_search/triage_code_lambda.tf | Adds new triage-code Lambda module instantiation. |
| infrastructure/stacks/dos_search/lambda_alarms.tf | Adds triage-code Lambda to monitoring/alarms configuration. |
| infrastructure/stacks/dos_search/variables.tf | Adds triage_code_lambda_name stack variable. |
| infrastructure/dos_search.tfvars | Provides triage_code_lambda_name value for the stack. |
| services/.trivyignore | Adds an additional ignored CVE entry. |
You can also share your feedback on Copilot code review. Take the survey.
0ea3b21 to
4456148
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a new DoS Search endpoint scaffold for the HealthcareService/$search-by-triage-code operation, gated behind a new feature flag, and wires it into the dos-search build/deploy infrastructure (Lambda + API Gateway).
Changes:
- Add a new
healthcare_service_search_by_triage_codeLambda handler that returns503when the flag is disabled and501when enabled (stub). - Add the new AppConfig feature flag (registry +
FeatureFlagenum) and unit tests for the handler/flag wiring. - Provision Terraform resources for the new Lambda package and API Gateway resource/method/integration.
Reviewed changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| services/dos-search/src/healthcare_service_search_by_triage_code/handler.py | New POST handler for $search-by-triage-code, feature-flag gated, currently stubbed (501/503). |
| services/dos-search/src/healthcare_service_search_by_triage_code/init.py | Package marker for new handler module. |
| services/dos-search/tests/unit/src/healthcare_service_search_by_triage_code/test_handler.py | Unit tests covering enabled/disabled flag behavior, headers, and logging expectations. |
| services/dos-search/tests/unit/src/healthcare_service_search_by_triage_code/init.py | Test package marker. |
| services/dos-search/src/common/logbase.py | Adds new log references for triage-code endpoint flag and stub behavior. |
| services/dos-search/README.md | Documents the new endpoint and updates the code structure section. |
| services/dos-search/Makefile | Ensures the new Lambda subdir is included in packaging/build steps. |
| application/packages/python/ftrs_common/feature_flags/feature_flag_config.py | Adds new FeatureFlag enum value for the endpoint. |
| application/packages/python/ftrs_common/tests/feature_flags/test_feature_flag_config.py | Tests new flag name and LocalFlagsClient env var behavior. |
| infrastructure/toggles/toggle-registry.yaml | Registers the new AppConfig flag and API Gateway toggle entry for the route. |
| infrastructure/dos_search.tfvars | Adds tfvars for the new Lambda artefact name and handler. |
| infrastructure/stacks/dos_search/variables.tf | Adds stack variables for the new Lambda name/handler. |
| infrastructure/stacks/dos_search/data.tf | Adds S3 object lookup for the new Lambda package artefact. |
| infrastructure/stacks/dos_search/healthcare_service_search_by_triage_code_lambda.tf | Adds Terraform Lambda module for the new operation. |
| infrastructure/stacks/dos_search/api-gateway-rest-resource-healthcare-service-search-by-triage-code.tf | Adds API Gateway resource/method/integration for the new POST route. |
| infrastructure/stacks/dos_search/api-gateway-rest-deployment.tf | Includes the new API Gateway components in deployment triggers/depends_on. |
MatasDevs
left a comment
There was a problem hiding this comment.
All good, just one minor comment which you can resolve if you feel it's not necessary.
# Conflicts: # services/dos-search/src/common/logbase.py # Conflicts: # application/packages/python/ftrs_common/feature_flags/feature_flag_config.py # infrastructure/toggles/toggle-registry.yaml
Description
Context
https://nhsd-jira.digital.nhs.uk/browse/FTRS-2590
Sensitive Information Declaration
To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.