Skip to content

Commit 63baf70

Browse files
authored
Amend TRN request duplicates resolution to reflect new designs (#2869)
### Context Following changes to the Resolve Duplicate Journeys, there now exists scenarios following a recheck of duplicate records upon starting the support task where a match either 1) no longer exists once you enter the task or 2) an exact match now exists ### Changes proposed in this pull request Changes to API TRN Request and NPQ TRN Request Matches screens and tests.
1 parent 6e37473 commit 63baf70

File tree

10 files changed

+597
-60
lines changed

10 files changed

+597
-60
lines changed

TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/SupportTasks/ApiTrnRequests/Resolve/Matches.cshtml

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@page "/support-tasks/api-trn-requests/{supportTaskReference}/resolve/matches/{handler?}"
2+
@using TeachingRecordSystem.Core.Services.PersonMatching
23
@model TeachingRecordSystem.SupportUi.Pages.SupportTasks.ApiTrnRequests.Resolve.Matches
34
@{
45
ViewBag.Title = $"Compare {Model.SourceApplicationUserName} request with potential matches";
@@ -20,9 +21,24 @@
2021
</div>
2122
<div class="govuk-grid-row">
2223
<div class=@(showDuplicatesSideBySide ? "govuk-grid-column-full-from-desktop" : "govuk-grid-column-two-thirds-from-desktop")>
23-
<govuk-inset-text class="govuk-!-margin-top-0">
24-
Differences are <highlight>highlighted</highlight> on the existing records
25-
</govuk-inset-text>
24+
@if (Model.MatchOutcome == TrnRequestMatchResultOutcome.DefiniteMatch)
25+
{
26+
<govuk-inset-text class="govuk-!-margin-top-0">
27+
This request matches an existing record. To complete the task, you need to merge the request with the record.
28+
</govuk-inset-text>
29+
}
30+
else if (Model.MatchOutcome == TrnRequestMatchResultOutcome.NoMatches)
31+
{
32+
<govuk-inset-text class="govuk-!-margin-top-0">
33+
This record is no longer flagged as a potential duplicate. You can now create a new record.
34+
</govuk-inset-text>
35+
}
36+
else
37+
{
38+
<govuk-inset-text class="govuk-!-margin-top-0">
39+
Differences are <highlight>highlighted</highlight> on the existing records
40+
</govuk-inset-text>
41+
}
2642

2743
<div class="trs-potential-duplicates @(showDuplicatesSideBySide ? "trs-potential-duplicates--side-by-side" : "")">
2844
<govuk-summary-card data-testid="request" class="trs-potential-duplicates__item">
@@ -77,7 +93,7 @@
7793
</govuk-summary-list>
7894
</govuk-summary-card>
7995

80-
@if (!showDuplicatesSideBySide)
96+
@if (!showDuplicatesSideBySide && Model.MatchOutcome == TrnRequestMatchResultOutcome.PotentialMatches)
8197
{
8298
<h2 class="govuk-heading-m">Potential matches</h2>
8399
}
@@ -180,29 +196,45 @@
180196

181197
<div class="govuk-grid-row">
182198
<div class="govuk-grid-column-two-thirds-from-desktop">
183-
<govuk-radios for="PersonId">
184-
<govuk-radios-fieldset>
185-
<govuk-radios-fieldset-legend class="govuk-fieldset__legend--m">
186-
What do you want to do with the @Model.SourceApplicationUserName request?
187-
</govuk-radios-fieldset-legend>
199+
@if (Model.MatchOutcome == TrnRequestMatchResultOutcome.PotentialMatches)
200+
{
201+
<govuk-radios for="PersonId">
202+
<govuk-radios-fieldset>
203+
<govuk-radios-fieldset-legend class="govuk-fieldset__legend--m">
204+
What do you want to do with the @Model.SourceApplicationUserName request?
205+
</govuk-radios-fieldset-legend>
188206

189-
@foreach (var match in Model.PotentialDuplicates!)
190-
{
191-
<govuk-radios-item value="@match.PersonId">
192-
Merge it with Record @match.Identifier
193-
</govuk-radios-item>
194-
}
207+
@foreach (var match in Model.PotentialDuplicates!)
208+
{
209+
<govuk-radios-item value="@match.PersonId">
210+
Merge it with Record @match.Identifier
211+
</govuk-radios-item>
212+
}
195213

196-
<govuk-radios-divider>or</govuk-radios-divider>
214+
<govuk-radios-divider>or</govuk-radios-divider>
197215

198-
<govuk-radios-item value="@ResolveApiTrnRequestState.CreateNewRecordPersonIdSentinel">
199-
Create a new record from it
200-
</govuk-radios-item>
201-
</govuk-radios-fieldset>
202-
</govuk-radios>
216+
<govuk-radios-item value="@ResolveApiTrnRequestState.CreateNewRecordPersonIdSentinel">
217+
Create a new record from it
218+
</govuk-radios-item>
219+
</govuk-radios-fieldset>
220+
</govuk-radios>
221+
}
203222

204223
<div class="govuk-button-group">
205-
<govuk-button type="submit">Continue</govuk-button>
224+
@if (Model.MatchOutcome == TrnRequestMatchResultOutcome.DefiniteMatch)
225+
{
226+
<input type="hidden" asp-for="PersonId" value="@Model.PotentialDuplicates[0].PersonId" />
227+
<govuk-button type="submit" data-testid="merge-record-button">Merge this request with Record A</govuk-button>
228+
}
229+
else if (Model.MatchOutcome == TrnRequestMatchResultOutcome.NoMatches)
230+
{
231+
<input type="hidden" asp-for="PersonId" value="@ResolveApiTrnRequestState.CreateNewRecordPersonIdSentinel" />
232+
<govuk-button type="submit" data-testid="create-new-record-button">Create a record from this request</govuk-button>
233+
}
234+
else
235+
{
236+
<govuk-button type="submit" data-testid="continue-button">Continue</govuk-button>
237+
}
206238
<govuk-button type="submit" formaction="@LinkGenerator.SupportTasks.ApiTrnRequests.Resolve.MatchesCancel(Model.SupportTaskReference!, Model.JourneyInstance!.InstanceId)" class="govuk-button--secondary">Cancel</govuk-button>
207239
</div>
208240
</div>

TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/SupportTasks/ApiTrnRequests/Resolve/Matches.cshtml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.AspNetCore.Mvc.Filters;
44
using TeachingRecordSystem.Core.DataStore.Postgres;
55
using TeachingRecordSystem.Core.DataStore.Postgres.Models;
6+
using TeachingRecordSystem.Core.Services.PersonMatching;
67

78
namespace TeachingRecordSystem.SupportUi.Pages.SupportTasks.ApiTrnRequests.Resolve;
89

@@ -17,6 +18,8 @@ public class Matches(TrsDbContext dbContext, SupportUiLinkGenerator linkGenerato
1718

1819
public TrnRequestMetadata? RequestData { get; set; }
1920

21+
public TrnRequestMatchResultOutcome MatchOutcome { get; set; }
22+
2023
public string SourceApplicationUserName => RequestData!.ApplicationUser!.Name;
2124

2225
public PotentialDuplicate[]? PotentialDuplicates { get; set; }
@@ -80,6 +83,7 @@ public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingConte
8083
RequestData = GetRequestData();
8184

8285
var matchedPersonIds = JourneyInstance!.State.MatchedPersonIds.ToArray();
86+
MatchOutcome = JourneyInstance.State.MatchOutcome;
8387

8488
PotentialDuplicates = (await DbContext.Persons
8589
.Where(p => matchedPersonIds.Contains(p.PersonId))

TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/SupportTasks/ApiTrnRequests/Resolve/ResolveApiTrnRequestState.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class ResolveApiTrnRequestState : IRegisterJourney
1616
appendUniqueKey: true);
1717

1818
public required IReadOnlyCollection<Guid> MatchedPersonIds { get; init; }
19+
public TrnRequestMatchResultOutcome MatchOutcome { get; set; }
1920
public Guid? PersonId { get; set; }
2021
public bool PersonAttributeSourcesSet { get; set; }
2122
public PersonAttributeSource? FirstNameSource { get; set; }
@@ -45,6 +46,7 @@ public async Task<ResolveApiTrnRequestState> CreateAsync(SupportTask supportTask
4546

4647
var state = new ResolveApiTrnRequestState
4748
{
49+
MatchOutcome = matchResult.Outcome,
4850
MatchedPersonIds = matchResult.Outcome switch
4951
{
5052
TrnRequestMatchResultOutcome.DefiniteMatch => [matchResult.PersonId],

TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/SupportTasks/NpqTrnRequests/Resolve/Matches.cshtml

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@page "/support-tasks/npq-trn-requests/{supportTaskReference}/resolve/matches/{handler?}"
2+
@using TeachingRecordSystem.Core.Services.PersonMatching
23
@model TeachingRecordSystem.SupportUi.Pages.SupportTasks.NpqTrnRequests.Resolve.MatchesModel
34
@{
45
ViewBag.Title = "Compare potential duplicate records";
@@ -20,9 +21,24 @@
2021
</div>
2122
<div class="govuk-grid-row">
2223
<div class=@(showDuplicatesSideBySide ? "govuk-grid-column-full-from-desktop" : "govuk-grid-column-two-thirds-from-desktop")>
23-
<govuk-inset-text class="govuk-!-margin-top-0">
24-
Differences are <highlight>highlighted</highlight> on the existing records
25-
</govuk-inset-text>
24+
@if (Model.MatchOutcome == TrnRequestMatchResultOutcome.DefiniteMatch)
25+
{
26+
<govuk-inset-text class="govuk-!-margin-top-0">
27+
This request matches an existing record. To complete the task, you need to merge the request with the record.
28+
</govuk-inset-text>
29+
}
30+
else if (Model.MatchOutcome == TrnRequestMatchResultOutcome.NoMatches)
31+
{
32+
<govuk-inset-text class="govuk-!-margin-top-0">
33+
This record is no longer flagged as a potential duplicate. You can now create a new record.
34+
</govuk-inset-text>
35+
}
36+
else
37+
{
38+
<govuk-inset-text class="govuk-!-margin-top-0">
39+
Differences are <highlight>highlighted</highlight> on the existing records
40+
</govuk-inset-text>
41+
}
2642

2743
<div class="trs-potential-duplicates @(showDuplicatesSideBySide ? "trs-potential-duplicates--side-by-side" : "")">
2844
<govuk-summary-card data-testid="request" class="trs-potential-duplicates__item">
@@ -83,7 +99,7 @@
8399
</govuk-summary-list>
84100
</govuk-summary-card>
85101

86-
@if (!showDuplicatesSideBySide)
102+
@if (!showDuplicatesSideBySide && Model.MatchOutcome == TrnRequestMatchResultOutcome.PotentialMatches)
87103
{
88104
<h2 class="govuk-heading-m">Potential matches</h2>
89105
}
@@ -194,29 +210,45 @@
194210

195211
<div class="govuk-grid-row">
196212
<div class="govuk-grid-column-two-thirds-from-desktop">
197-
<govuk-radios for="PersonId">
198-
<govuk-radios-fieldset>
199-
<govuk-radios-fieldset-legend class="govuk-fieldset__legend--m">
200-
What do you want to do with the TRN request?
201-
</govuk-radios-fieldset-legend>
213+
@if (Model.MatchOutcome == TrnRequestMatchResultOutcome.PotentialMatches)
214+
{
215+
<govuk-radios for="PersonId">
216+
<govuk-radios-fieldset>
217+
<govuk-radios-fieldset-legend class="govuk-fieldset__legend--m">
218+
What do you want to do with the TRN request?
219+
</govuk-radios-fieldset-legend>
202220

203-
@foreach (var match in Model.PotentialDuplicates!)
204-
{
205-
<govuk-radios-item value="@match.PersonId">
206-
Merge it with Record @match.Identifier
207-
</govuk-radios-item>
208-
}
221+
@foreach (var match in Model.PotentialDuplicates!)
222+
{
223+
<govuk-radios-item value="@match.PersonId">
224+
Merge it with Record @match.Identifier
225+
</govuk-radios-item>
226+
}
209227

210-
<govuk-radios-divider>or</govuk-radios-divider>
228+
<govuk-radios-divider>or</govuk-radios-divider>
211229

212-
<govuk-radios-item value="@ResolveNpqTrnRequestState.CreateNewRecordPersonIdSentinel">
213-
Create a new record
214-
</govuk-radios-item>
215-
</govuk-radios-fieldset>
216-
</govuk-radios>
230+
<govuk-radios-item value="@ResolveNpqTrnRequestState.CreateNewRecordPersonIdSentinel">
231+
Create a new record
232+
</govuk-radios-item>
233+
</govuk-radios-fieldset>
234+
</govuk-radios>
235+
}
217236

218237
<div class="govuk-button-group">
219-
<govuk-button type="submit">Continue</govuk-button>
238+
@if (Model.MatchOutcome == TrnRequestMatchResultOutcome.DefiniteMatch)
239+
{
240+
<input type="hidden" asp-for="PersonId" value="@Model.PotentialDuplicates[0].PersonId" />
241+
<govuk-button type="submit" data-testid="merge-record-button">Merge this request with Record A</govuk-button>
242+
}
243+
else if (Model.MatchOutcome == TrnRequestMatchResultOutcome.NoMatches)
244+
{
245+
<input type="hidden" asp-for="PersonId" value="@ResolveNpqTrnRequestState.CreateNewRecordPersonIdSentinel" />
246+
<govuk-button type="submit" data-testid="create-new-record-button">Create a record from this request</govuk-button>
247+
}
248+
else
249+
{
250+
<govuk-button type="submit" data-testid="continue-button">Continue</govuk-button>
251+
}
220252
<govuk-button type="submit" formaction="@LinkGenerator.SupportTasks.NpqTrnRequests.Resolve.MatchesCancel(Model.SupportTaskReference!, Model.JourneyInstance!.InstanceId)" class="govuk-button--secondary" data-testid="cancel-button">Cancel</govuk-button>
221253
</div>
222254
</div>

TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/SupportTasks/NpqTrnRequests/Resolve/Matches.cshtml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.AspNetCore.Mvc.Filters;
44
using TeachingRecordSystem.Core.DataStore.Postgres;
55
using TeachingRecordSystem.Core.DataStore.Postgres.Models;
6+
using TeachingRecordSystem.Core.Services.PersonMatching;
67
using TeachingRecordSystem.SupportUi;
78
using TeachingRecordSystem.SupportUi.Pages.Shared.Evidence;
89
using TeachingRecordSystem.SupportUi.Pages.SupportTasks.ApiTrnRequests.Resolve;
@@ -14,6 +15,8 @@ public class MatchesModel(TrsDbContext dbContext, SupportUiLinkGenerator linkGen
1415
{
1516
public TrnRequestMetadata? RequestData { get; set; }
1617

18+
public TrnRequestMatchResultOutcome MatchOutcome { get; set; }
19+
1720
public PotentialDuplicate[]? PotentialDuplicates { get; set; }
1821

1922
public UploadedEvidenceFile? NpqEvidenceFile { get; set; }
@@ -76,6 +79,7 @@ public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingConte
7679
RequestData = GetRequestData();
7780

7881
var matchedPersonIds = JourneyInstance!.State.MatchedPersonIds.ToArray();
82+
MatchOutcome = JourneyInstance.State.MatchOutcome;
7983

8084
PotentialDuplicates = (await DbContext.Persons
8185
.Where(p => matchedPersonIds.Contains(p.PersonId))

TeachingRecordSystem/src/TeachingRecordSystem.SupportUi/Pages/SupportTasks/NpqTrnRequests/Resolve/ResolveNpqTrnRequestState.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class ResolveNpqTrnRequestState : IRegisterJourney
1616
appendUniqueKey: true);
1717

1818
public required IReadOnlyCollection<Guid> MatchedPersonIds { get; init; }
19+
public TrnRequestMatchResultOutcome MatchOutcome { get; set; }
1920
public Guid? PersonId { get; set; }
2021
public bool PersonAttributeSourcesSet { get; set; }
2122
public PersonAttributeSource? DateOfBirthSource { get; set; }
@@ -42,6 +43,7 @@ public async Task<ResolveNpqTrnRequestState> CreateAsync(SupportTask supportTask
4243

4344
var state = new ResolveNpqTrnRequestState
4445
{
46+
MatchOutcome = matchResult.Outcome,
4547
MatchedPersonIds = matchResult.Outcome switch
4648
{
4749
TrnRequestMatchResultOutcome.DefiniteMatch => [matchResult.PersonId],

0 commit comments

Comments
 (0)