Skip to content

feat: FTRS-2855 initial LDA ref data changes#1083

Merged
lukasz-jercha-nhs merged 22 commits intomainfrom
task/FTRS-2855-LDA-records
Apr 8, 2026
Merged

feat: FTRS-2855 initial LDA ref data changes#1083
lukasz-jercha-nhs merged 22 commits intomainfrom
task/FTRS-2855-LDA-records

Conversation

@lukasz-jercha-nhs
Copy link
Copy Markdown
Contributor

@lukasz-jercha-nhs lukasz-jercha-nhs commented Mar 25, 2026

Description

LDA event changes

  • implement LDA locations import using the reference lambda
  • split location model into location area and location place
  • Updated AttributeLevelRepository class to support multiple subclasses (literals and model adapter) and models without sort key
  • added int test

CRUD-API

  • updated APIs to support both location types
  • fixed an issue on PUT request - it didnt validate the PATH id against the resource body id

Additional changes

  • added some vscode search exclusions
  • removed unused parameter partOf from location model

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.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 LocationPlace and LocationArea (discriminated by field) and update migration/CRUD logic to use non-document sort 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

Comment thread application/packages/python/ftrs_data_layer/domain/enums.py Outdated
Comment thread services/crud-apis/location/app/service/location_service.py
Comment thread services/crud-apis/location/app/router/location.py Outdated
Comment thread services/crud-apis/location/app/router/location.py Outdated
prjh2-nhs
prjh2-nhs previously approved these changes Mar 31, 2026
Copy link
Copy Markdown
Contributor

@prjh2-nhs prjh2-nhs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work on the LDAs 😎 just one small comment

Comment thread services/crud-apis/location/tests/test_location_service.py Outdated
Tomdango
Tomdango previously approved these changes Apr 1, 2026
Comment thread services/crud-apis/location/app/service/location_service.py
Comment thread services/crud-apis/location/tests/test_location_service.py Outdated
prjh2-nhs
prjh2-nhs previously approved these changes Apr 1, 2026
prjh2-nhs
prjh2-nhs previously approved these changes Apr 1, 2026
Tomdango
Tomdango previously approved these changes Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants