Skip to content

SAS-620: DTR submission and outcome notes#314

Open
David (david-mcdowall) wants to merge 2 commits into
mainfrom
feature/SAS-620-dtr-submission-and-outcome-notes
Open

SAS-620: DTR submission and outcome notes#314
David (david-mcdowall) wants to merge 2 commits into
mainfrom
feature/SAS-620-dtr-submission-and-outcome-notes

Conversation

@david-mcdowall

Copy link
Copy Markdown
Contributor

This PR adds support for accepting optional free-text notes during the DTR add submission and add outcome flow. As per the prototype, these notes can only be added during creating or updating a referral in SAS and should co-exist so they can be displayed together on the View Referral screen and updated at any time.

Changes

  • adds submissionNote field/column
  • adds outcomeNote field/column
  • validation for new fields in the DutyToReferAggregate
  • test coverage

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds optional free-text notes to the Duty To Refer (DTR) submission and outcome flows so they can be stored, retrieved, and displayed together on the referral view.

Changes:

  • Extends the DTR API contract and persistence model with submissionNote and outcomeNote.
  • Updates domain validation and mapping/transformer layers to carry the new fields through command → aggregate → entity → DTO.
  • Adds migration and expands unit/integration test coverage for the new behaviour.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/test/kotlin/uk/gov/justice/digital/hmpps/singleaccommodationserviceapi/integration/eligibility/response/GetEligibilityReponses.kt Updates expected eligibility JSON to include the new note fields.
src/test/kotlin/uk/gov/justice/digital/hmpps/singleaccommodationserviceapi/integration/dutytorefer/json/DutyToReferJson.kt Extends test JSON builders/expected responses with submissionNote/outcomeNote.
src/test/kotlin/uk/gov/justice/digital/hmpps/singleaccommodationserviceapi/integration/dutytorefer/DutyToReferControllerIT.kt Adds integration tests around persisting/returning notes and ignoring blank notes.
query/src/test/kotlin/uk/gov/justice/digital/hmpps/singleaccommodationserviceapi/query/unit/dutytorefer/DutyToReferTransformerTest.kt Verifies query transformer maps note fields.
query/src/main/kotlin/uk/gov/justice/digital/hmpps/singleaccommodationserviceapi/query/dutytorefer/DutyToReferTransformer.kt Maps entity note columns to DTO.
mutation/src/test/kotlin/uk/gov/justice/digital/hmpps/singleaccommodationserviceapi/mutation/unit/domain/aggregate/DutyToReferAggregateTest.kt Adds unit coverage for note validation and applicability rules.
mutation/src/test/kotlin/uk/gov/justice/digital/hmpps/singleaccommodationserviceapi/mutation/unit/application/mapper/DutyToReferMapperTest.kt Verifies mapper carries note fields across snapshot/entity/DTO.
mutation/src/test/kotlin/uk/gov/justice/digital/hmpps/singleaccommodationserviceapi/mutation/factories/DutyToReferSnapshotFactory.kt Extends snapshot factory to include new note fields.
mutation/src/main/kotlin/uk/gov/justice/digital/hmpps/singleaccommodationserviceapi/mutation/domain/exceptions/DutyToReferExceptions.kt Introduces new domain exceptions for note applicability.
mutation/src/main/kotlin/uk/gov/justice/digital/hmpps/singleaccommodationserviceapi/mutation/domain/aggregate/DutyToReferAggregate.kt Adds note state to aggregate + validation rules and snapshot fields.
mutation/src/main/kotlin/uk/gov/justice/digital/hmpps/singleaccommodationserviceapi/mutation/application/service/DutyToReferApplicationService.kt Passes note fields into aggregate updates during create/update (create path needs a fix).
mutation/src/main/kotlin/uk/gov/justice/digital/hmpps/singleaccommodationserviceapi/mutation/application/mapper/DutyToReferMapper.kt Maps note fields between snapshot/entity/aggregate/DTO.
infrastructure/src/testFixtures/kotlin/uk/gov/justice/digital/hmpps/singleaccommodationserviceapi/infrastructure/factories/DutyToReferEntityFactory.kt Extends entity test factory with note fields.
infrastructure/src/main/resources/db/migration/V0032__add_notes_to_duty_to_refer.sql Adds submission_note and outcome_note columns.
infrastructure/src/main/kotlin/uk/gov/justice/digital/hmpps/singleaccommodationserviceapi/infrastructure/persistence/entity/DutyToReferEntity.kt Adds entity fields for the new note columns.
common/src/main/kotlin/uk/gov/justice/digital/hmpps/singleaccommodationserviceapi/common/dtos/DutyToReferDto.kt Extends command/DTO types to include submissionNote and outcomeNote.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 38 to 44
aggregate.updateDutyToRefer(
localAuthorityAreaId = command.localAuthorityAreaId,
submissionDate = command.submissionDate,
referenceNumber = command.referenceNumber,
status = command.status,
submissionNote = command.submissionNote,
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this was intentional as outcomeNote should never be supplied or used during the create flow and is consistent with existing behaviour (withdrawlReason, outcomeReason etc)

@david-mcdowall David (david-mcdowall) force-pushed the feature/SAS-620-dtr-submission-and-outcome-notes branch 2 times, most recently from 016006f to 92413d9 Compare June 8, 2026 09:06
@david-mcdowall David (david-mcdowall) force-pushed the feature/SAS-620-dtr-submission-and-outcome-notes branch from f354adc to 37a2f4e Compare June 8, 2026 12:49
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.

2 participants