Skip to content

Conversation

@daniel-manta-hee
Copy link
Contributor

@daniel-manta-hee daniel-manta-hee commented Dec 2, 2021

JIRA link

https://hee-dls.atlassian.net/browse/DLSV2-437

Description

Added new query in Supervisor service for retrieving requested reviews which would work in the same way as the existing signoff requested to do list. Updated the controller method and the view.

Screenshots

image


Developer checks

Checked that this code returns one record for competency with pending review.

DECLARE @adminId INT = 1
SELECT sa.id AS SelfAssessmentId, co.ID as CompetencyId, sar.ID AS RecordId, ca.ID, sd.ID AS SupervisorDelegateId, c.FirstName + ' ' + c.LastName AS DelegateName, sa.Name AS ProfileName, sasv.Requested, 0 AS SignOffRequest, 1 AS ResultsReviewRequest
    FROM   CandidateAssessmentSupervisors AS cas INNER JOIN
    CandidateAssessments AS ca ON cas.CandidateAssessmentID = ca.ID INNER JOIN
    Candidates AS c ON ca.CandidateID = c.CandidateID INNER JOIN
    SelfAssessments AS sa ON ca.SelfAssessmentID = sa.ID INNER JOIN
    SupervisorDelegates AS sd ON cas.SupervisorDelegateId = sd.ID INNER JOIN
    SelfAssessmentResults AS sar ON sar.SelfAssessmentID = sa.ID INNER JOIN
    Competencies AS co ON sar.CompetencyID = co.ID INNER JOIN					
    SelfAssessmentResultSupervisorVerifications AS sasv ON sasv.SelfAssessmentResultId = sar.ID AND sasv.CandidateAssessmentSupervisorID = cas.ID AND sar.DateTime = (
		SELECT MAX(sar2.DateTime)
		FROM SelfAssessmentResults AS sar2
		WHERE sar2.SelfAssessmentID = sar.SelfAssessmentID AND sar2.CompetencyID = co.ID
	)
WHERE (sd.SupervisorAdminID = @adminId) AND (sasv.Verified IS NULL)

image

Grouped by SelfAssessment in order to get only one record per self assessment.

DECLARE @adminId INT = 1
SELECT ca.ID, sd.ID AS SupervisorDelegateId, c.FirstName + ' ' + c.LastName AS DelegateName, sa.Name AS ProfileName, MAX(sasv.Requested) AS Requested, 0 AS SignOffRequest, 1 AS ResultsReviewRequest
      FROM   CandidateAssessmentSupervisors AS cas INNER JOIN
      CandidateAssessments AS ca ON cas.CandidateAssessmentID = ca.ID INNER JOIN
      Candidates AS c ON ca.CandidateID = c.CandidateID INNER JOIN
      SelfAssessments AS sa ON ca.SelfAssessmentID = sa.ID INNER JOIN
      SupervisorDelegates AS sd ON cas.SupervisorDelegateId = sd.ID INNER JOIN
SelfAssessmentResults AS sar ON sar.SelfAssessmentID = sa.ID INNER JOIN
Competencies AS co ON sar.CompetencyID = co.ID INNER JOIN					
      SelfAssessmentResultSupervisorVerifications AS sasv ON sasv.SelfAssessmentResultId = sar.ID AND sasv.CandidateAssessmentSupervisorID = cas.ID AND sar.DateTime = (
SELECT MAX(sar2.DateTime)
FROM SelfAssessmentResults AS sar2
WHERE sar2.SelfAssessmentID = sar.SelfAssessmentID AND sar2.CompetencyID = co.ID
)
  WHERE (sd.SupervisorAdminID = @adminId) AND (sasv.Verified IS NULL)
GROUP BY sa.ID, ca.ID, sd.ID, c.FirstName, c.LastName, sa.Name

image

else if(toDoItem.ResultsReviewRequest)
{
<li class="nhsuk-contents-list__item">
<a class="nhsuk-contents-list__link nhsuk-link--no-visited-state" asp-action="VerifyDelegateSelfAssessment" asp-route-supervisorDelegateId="@toDoItem.SupervisorDelegateId" asp-route-candidateAssessmentId="@toDoItem.ID">
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use the same action and routing as the "Review and sign-off" link above, here. The link is broken for me with the current action and route data and should go to the same place.

Copy link
Contributor

@kevwhitt-hee kevwhitt-hee left a comment

Choose a reason for hiding this comment

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

A couple of changes requested to the Index.cshtml - see comments.

@daniel-manta-hee
Copy link
Contributor Author

daniel-manta-hee commented Dec 2, 2021 via email

@kevwhitt-hee
Copy link
Contributor

Yes. Let's remove the "nhsuk-contents-list__link" from both links, please. I've tested this in browser dev mode and it looks much better,

public IEnumerable<SupervisorDashboardToDoItem> GetSupervisorDashboardToDoItemsForRequestedReviews(int adminId)
{
return connection.Query<SupervisorDashboardToDoItem>(
@"SELECT ca.ID, sd.ID AS SupervisorDelegateId, c.FirstName + ' ' + c.LastName AS DelegateName, sa.Name AS ProfileName, MAX(sasv.Requested) AS Requested, 0 AS SignOffRequest, 1 AS ResultsReviewRequest
Copy link
Contributor

Choose a reason for hiding this comment

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

Further testing suggests there is a problem with this query. I requested verification for 1 result in a second self assessment. This appeared on my supervisor To Do list three times:
image

Copy link
Contributor

Choose a reason for hiding this comment

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

The return from this query has the following return on my Dev DB for adminId = 1:
image
Note the different IDs (CandidateAssessment.IDs?) in the first column. Suggesting a problem with a join.

Copy link
Contributor

@kevwhitt-hee kevwhitt-hee left a comment

Choose a reason for hiding this comment

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

Working perfectly now.

@kevwhitt-hee kevwhitt-hee merged commit 77922b0 into master Dec 2, 2021
@kevwhitt-hee kevwhitt-hee deleted the Develop/Features/DLSV2-437-AddResultReviewRequestLinksToSupervisorToDoList branch December 9, 2021 08:14
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.

3 participants