feat: FTRS-2855 initial LDA ref data changes#1083
Merged
lukasz-jercha-nhs merged 22 commits intomainfrom Apr 8, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds initial support for importing LDA reference data and introduces polymorphic Location modelling (place vs area) across the data-migration service, data layer, and CRUD location API, with accompanying automation and unit tests.
Changes:
- Implement LDA reference-data load path (event type, handler, mapper) including DHSC organisation seeding.
- Split Location domain model into
LocationPlaceandLocationArea(discriminated byfield) and update migration/CRUD logic to use non-documentsort keys. - Expand test coverage: new LDA happy-path feature and multiple unit tests (mapper/handler/application/repository).
Reviewed changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/service_automation/tests/utilities/data_migration/migration_helper.py | Adds helper to run LDA-only migration |
| tests/service_automation/tests/utilities/common/dynamoDB_tables.py | Adds org GSI for ODS-code queries |
| tests/service_automation/tests/step_definitions/data_migration_steps/test_data_migration_address_steps.py | Updates location sort-key to place |
| tests/service_automation/tests/step_definitions/data_migration_steps/test_data_migration.py | Adds LDA scenario + org-by-ODS assertions |
| tests/service_automation/tests/step_definitions/data_migration_steps/test_audit_event_tracking_steps.py | Adjusts sort-key selection for location |
| tests/service_automation/tests/step_definitions/common_steps/data_migration_steps.py | Adds “lda full migration” step |
| tests/service_automation/tests/features/data_migration_features/lda_migration_happy_path.feature | New LDA migration happy-path feature |
| tests/service_automation/tests/features/data_migration_features/gp_practice_migration_happy_path.feature | Removes partOf from expectations |
| tests/service_automation/tests/data_migration_fixtures.py | Switches test repos to LocationPlace |
| tests/service_automation/tests/conftest.py | Switches location repo type to LocationPlace |
| services/data-migration/tests/util/fixtures.py | Updates base location fixture to LocationPlace |
| services/data-migration/tests/unit/service_migration/transformer/test_base.py | Updates transformer tests for LocationPlace |
| services/data-migration/tests/unit/service_migration/test_ddb_transactions.py | Ensures location writes use field="place" |
| services/data-migration/tests/unit/reference_data_load/test_reference_application.py | Adds application test for LDA event type |
| services/data-migration/tests/unit/reference_data_load/mapper/test_lda_mapper.py | New unit tests for LDA/DHSC mappers |
| services/data-migration/tests/unit/reference_data_load/handlers/test_lda_handler.py | New unit tests for LDA handler logic |
| services/data-migration/tests/unit/common/test_diff_utils.py | Updates diff tests to LocationPlace |
| services/data-migration/tests/unit/common/test_deepdiff_location_updates.py | Updates deepdiff tests to LocationPlace |
| services/data-migration/tests/unit/common/test_deepdiff_expression_format.py | Updates deepdiff tests to LocationPlace |
| services/data-migration/tests/unit/common/test_deepdiff_edge_cases.py | Updates deepdiff tests to LocationPlace |
| services/data-migration/src/service_migration/transformer/base.py | Returns LocationPlace from transformer |
| services/data-migration/src/service_migration/models.py | Updates migration state location type |
| services/data-migration/src/service_migration/ddb_transactions.py | Uses location model’s field for updates |
| services/data-migration/src/reference_data_load/mapper/lda_mapper.py | Adds DHSC org + LDA location mapping |
| services/data-migration/src/reference_data_load/handlers/lda_handler.py | Adds LDA loader (DB select + upserts) |
| services/data-migration/src/reference_data_load/application.py | Routes ReferenceDataLoadEvent(type="lda") |
| services/data-migration/src/common/events.py | Extends event type literal to include lda |
| services/data-migration/src/common/diff_utils.py | Updates location diff typing to LocationPlace |
| services/crud-apis/location/tests/test_location_service.py | Adds CRUD tests for mixed location types |
| services/crud-apis/location/tests/test_location.py | Adds router tests for place + LDA models |
| services/crud-apis/location/app/service/location_service.py | Updates service APIs to return AnyLocation |
| services/crud-apis/location/app/router/location.py | Introduces repo parsing AnyLocation via discriminator |
| application/packages/python/ftrs_data_layer/tests/repository/dynamodb/test_attribute_level.py | Adds tests for get_first_by_id() |
| application/packages/python/ftrs_data_layer/tests/domain/test_location.py | Updates domain tests for new location models |
| application/packages/python/ftrs_data_layer/repository/dynamodb/attribute_level.py | Adds get_first_by_id() helper |
| application/packages/python/ftrs_data_layer/domain/location.py | Introduces LocationPlace, LocationArea, AnyLocation |
| application/packages/python/ftrs_data_layer/domain/legacy/organisation.py | Adds legacy organisations SQLModel |
| application/packages/python/ftrs_data_layer/domain/legacy/init.py | Exports LegacyOrganisation |
| application/packages/python/ftrs_data_layer/domain/enums.py | Adds GOVERNMENT_DEPARTMENT org type |
| application/packages/python/ftrs_data_layer/domain/init.py | Exports new location types |
| application/packages/ftrs_aws_local/tests/unit/test_reset.py | Updates imports to LocationPlace |
prjh2-nhs
previously approved these changes
Mar 31, 2026
Contributor
prjh2-nhs
left a comment
There was a problem hiding this comment.
great work on the LDAs 😎 just one small comment
Tomdango
previously approved these changes
Apr 1, 2026
prjh2-nhs
previously approved these changes
Apr 1, 2026
prjh2-nhs
previously approved these changes
Apr 1, 2026
Tomdango
previously approved these changes
Apr 2, 2026
prjh2-nhs
approved these changes
Apr 8, 2026
nsindhu26
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
LDA event changes
CRUD-API
Additional changes
Context
Ticket reference: https://nhsd-jira.digital.nhs.uk/browse/FTRS-2855
Acceptance criteria:
An organisation for DHSC is created if it does not exist following the mappings noted below.
If DHSC as an org already exists (validated by ODSCode), do not create a new one.
Each LDA that is of an active status in the organisation table, we load it across following the mapping below.
Update Location Place with additional missings fields
field change to place
Add physicalType property
Remove partOf property from the logic model (in-code)
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.