Repository: ministryofjustice/opg-sirius-lpa-frontend
Pull request #649: VEGA-2873 : Record court order dates for severance
Author: login: ndasmoj
Created: 2025-04-16T07:51:13Z | Merged: 2025-04-23T18:13:56Z

This PR covers [VEGA-2873](https://opgtransform.atlassian.net/browse/VEGA-2873)

I have updated the implementation of the severance flow as part of this ticket to allow the SeveranceApplication object and the bool fields `hasDonorConsented` and `severanceOrdered` to be treated as nil in Go when they are returned as empty from the API. 

In my testing I found that they are treated as empty object or false and so I changed the relevant fields in Go to pointers which then allows the object or the bool fields as nil.

## Checklist

- [x] I have updated the end-to-end tests to work with my changes
- [ ] I have added styling for Dark Mode
- [ ] I have checked that my UI changes meet accessibility standards


[VEGA-2873]: https://opgtransform.atlassian.net/browse/VEGA-2873?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ


Diff:
diff --git a/cypress/e2e/manage-restrictions.cy.js b/cypress/e2e/manage-restrictions.cy.js
index 594614e2c..b2517570d 100644
--- a/cypress/e2e/manage-restrictions.cy.js
+++ b/cypress/e2e/manage-restrictions.cy.js
@@ -183,7 +183,7 @@ describe("Manage restrictions form", () => {
     cy.addMock("/lpa-api/v1/digital-lpas/M-6666-6666-6668", "GET", {
       status: 200,
       body: {
-        uId: "M-6666-6666-66688",
+        uId: "M-6666-6666-6668",
         "opg.poas.sirius": {
           id: 888,
           uId: "M-6666-6666-6668",
@@ -238,4 +238,71 @@ describe("Manage restrictions form", () => {
       cy.contains("Severance application is required");
     });
   });
+
+  it("can be visited from the LPA details manage restrictions link when donor has given consent", () => {
+    cy.addMock("/lpa-api/v1/digital-lpas/M-6666-6666-6669", "GET", {
+      status: 200,
+      body: {
+        uId: "M-6666-6666-6669",
+        "opg.poas.sirius": {
+          id: 888,
+          uId: "M-6666-6666-6669",
+          status: "in-progress",
+          caseSubtype: "personal-welfare",
+          createdDate: "31/10/2023",
+          investigationCount: 0,
+          complaintCount: 0,
+          taskCount: 0,
+          warningCount: 0,
+          donor: {
+            id: 88,
+          },
+          application: {
+            donorFirstNames: "James",
+            donorLastName: "Rubin",
+            donorDob: "22/02/1990",
+            severanceStatus: "REQUIRED",
+            severanceApplication: {
+              hasDonorConsented: true,
+            },
+          },
+        },
+      },
+    });
+
+    cases.warnings.empty("888");
+
+    cy.addMock("/lpa-api/v1/cases/888", "GET", {
+      status: 200,
+      body: {
+        id: 888,
+        uId: "M-6666-6666-6669",
+        caseType: "DIGITAL_LPA",
+        donor: {
+          id: 6,
+        },
+      },
+    });
+
+    cy.addMock(
+      "/lpa-api/v1/cases/888/tasks?filter=status%3ANot+started%2Cactive%3Atrue&limit=99&sort=duedate%3AASC",
+      "GET",
+      {
+        status: 200,
+        body: {
+          tasks: [],
+        },
+      },
+    );
+    cy.visit("/lpa/M-6666-6666-6669/manage-restrictions").then(() => {
+      cy.contains("Manage restrictions and conditions");
+      cy.url().should("contain", "/lpa/M-6666-6666-6669/manage-restrictions");
+      cy.contains("Manage restrictions and conditions");
+      cy.contains("Date court order made");
+      cy.contains("Date court order issued");
+      cy.contains(
+        "Has severance of the restrictions and conditions been ordered?",
+      );
+    });
+  });
 });
diff --git a/internal/server/manage_restrictions.go b/internal/server/manage_restrictions.go
index 8292b3f5b..9f1c4f703 100644
--- a/internal/server/manage_restrictions.go
+++ b/internal/server/manage_restrictions.go
@@ -14,18 +14,21 @@ type ManageRestrictionsClient interface {
 	CaseSummary(sirius.Context, string) (sirius.CaseSummary, error)
 	ClearTask(sirius.Context, int) error
 	UpdateSeveranceStatus(sirius.Context, string, sirius.SeveranceStatusData) error
-	EditSeveranceApplication(sirius.Context, string, sirius.SeveranceApplicationDetails) error
+	EditSeveranceApplication(sirius.Context, string, sirius.SeveranceApplication) error
 }
 
 type manageRestrictionsData struct {
-	XSRFToken         string
-	Error             sirius.ValidationError
-	CaseUID           string
-	CaseSummary       sirius.CaseSummary
-	SeveranceAction   string
-	DonorConsentGiven string
-	FormAction        string
-	Success           bool
+	XSRFToken               string
+	Error                   sirius.ValidationError
+	CaseUID                 string
+	CaseSummary             sirius.CaseSummary
+	SeveranceAction         string
+	DonorConsentGiven       string
+	SeveranceOrderedByCourt string
+	CourtOrderDecisionDate  sirius.DateString
+	CourtOrderReceivedDate  sirius.DateString
+	FormAction              string
+	Success                 bool
 }
 
 func ManageRestrictions(client ManageRestrictionsClient, tmpl template.Template) Handler {
@@ -55,17 +58,24 @@ func ManageRestrictions(client ManageRestrictionsClient, tmpl template.Template)
 		}
 
 		data := manageRestrictionsData{
-			CaseSummary:       cs,
-			SeveranceAction:   postFormString(r, "severanceAction"),
-			DonorConsentGiven: postFormString(r, "donorConsentGiven"),
-			XSRFToken:         ctx.XSRFToken,
-			Error:             sirius.ValidationError{Field: sirius.FieldErrors{}},
-			CaseUID:           caseUID,
+			CaseSummary:             cs,
+			SeveranceAction:         postFormString(r, "severanceAction"),
+			DonorConsentGiven:       postFormString(r, "donorConsentGiven"),
+			SeveranceOrderedByCourt: postFormString(r, "severanceOrdered"),
+			CourtOrderDecisionDate:  postFormDateString(r, "courtOrderDecisionMade"),
+			CourtOrderReceivedDate:  postFormDateString(r, "courtOrderReceived"),
+			XSRFToken:               ctx.XSRFToken,
+			Error:                   sirius.ValidationError{Field: sirius.FieldErrors{}},
+			CaseUID:                 caseUID,
 		}
 
 		data.FormAction = r.FormValue("action")
 		if data.FormAction == "" && data.CaseSummary.DigitalLpa.SiriusData.Application.SeveranceStatus == "REQUIRED" {
 			data.FormAction = "donor-consent"
+
+			if data.CaseSummary.DigitalLpa.SiriusData.Application.SeveranceApplication != nil && *data.CaseSummary.DigitalLpa.SiriusData.Application.SeveranceApplication.HasDonorConsented {
+				data.FormAction = "court-order"
+			}
 		}
 
 		if r.Method == http.MethodPost {
@@ -116,8 +126,8 @@ func ManageRestrictions(client ManageRestrictionsClient, tmpl template.Template)
 						hasDonorConsented = false
 					}
 
-					err := client.EditSeveranceApplication(ctx, caseUID, sirius.SeveranceApplicationDetails{
-						HasDonorConsented: hasDonorConsented,
+					err := client.EditSeveranceApplication(ctx, caseUID, sirius.SeveranceApplication{
+						HasDonorConsented: &hasDonorConsented,
 					})
 					if handleError(w, &data, err) {
 						return err
@@ -132,6 +142,35 @@ func ManageRestrictions(client ManageRestrictionsClient, tmpl template.Template)
 					}
 				}
 			}
+
+			if data.FormAction == "court-order" {
+				severanceApplication := sirius.SeveranceApplication{}
+
+				if data.CourtOrderDecisionDate != "" {
+					severanceApplication.CourtOrderDecisionMade = data.CourtOrderDecisionDate
+				}
+
+				if data.CourtOrderReceivedDate != "" {
+					severanceApplication.CourtOrderReceived = data.CourtOrderReceivedDate
+				}
+
+				switch data.SeveranceOrderedByCourt {
+				case "severance-ordered", "severance-not-ordered":
+					isSeveranceOrdered := true
+					if data.SeveranceOrderedByCourt == "severance-not-ordered" {
+						isSeveranceOrdered = false
+					}
+
+					severanceApplication.SeveranceOrdered = &isSeveranceOrdered
+				}
+
+				err := client.EditSeveranceApplication(ctx, caseUID, severanceApplication)
+				if handleError(w, &data, err) {
+					return err
+				}
+
+				return handleSuccess(w, &data, caseUID)
+			}
 		}
 		return tmpl(w, data)
 	}
diff --git a/internal/server/manage_restrictions_test.go b/internal/server/manage_restrictions_test.go
index 0a6263ef4..0a4ed91c8 100644
--- a/internal/server/manage_restrictions_test.go
+++ b/internal/server/manage_restrictions_test.go
@@ -1,14 +1,13 @@
 package server
 
 import (
+	"github.com/ministryofjustice/opg-sirius-lpa-frontend/internal/sirius"
+	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/mock"
 	"net/http"
 	"net/url"
 	"strings"
 	"testing"
-
-	"github.com/ministryofjustice/opg-sirius-lpa-frontend/internal/sirius"
-	"github.com/stretchr/testify/assert"
-	"github.com/stretchr/testify/mock"
 )
 
 type mockManageRestrictionsClient struct {
@@ -30,11 +29,15 @@ func (m *mockManageRestrictionsClient) UpdateSeveranceStatus(ctx sirius.Context,
 	return args.Error(0)
 }
 
-func (m *mockManageRestrictionsClient) EditSeveranceApplication(ctx sirius.Context, caseUID string, severanceApplicationDetails sirius.SeveranceApplicationDetails) error {
+func (m *mockManageRestrictionsClient) EditSeveranceApplication(ctx sirius.Context, caseUID string, severanceApplicationDetails sirius.SeveranceApplication) error {
 	args := m.Called(ctx, caseUID, severanceApplicationDetails)
 	return args.Error(0)
 }
 
+func boolPointer(b bool) *bool {
+	return &b
+}
+
 var restrictionsCaseSummary = sirius.CaseSummary{
 	DigitalLpa: sirius.DigitalLpa{
 		UID: "M-1111-2222-3333",
@@ -66,6 +69,27 @@ var restrictionsCaseSummaryWithSeveranceRequired = sirius.CaseSummary{
 	},
 }
 
+var restrictionsCaseSummaryWithDonorConsentGiven = sirius.CaseSummary{
+	DigitalLpa: sirius.DigitalLpa{
+		UID: "M-1111-2222-3333",
+		SiriusData: sirius.SiriusData{
+			Application: sirius.Draft{
+				SeveranceStatus: "REQUIRED",
+				SeveranceApplication: &sirius.SeveranceApplication{
+					HasDonorConsented: boolPointer(true),
+				},
+			},
+		},
+	},
+	TaskList: []sirius.Task{
+		{
+			ID:     1,
+			Name:   "Review restrictions and conditions",
+			Status: "Not started",
+		},
+	},
+}
+
 func TestGetManageRestrictionsCases(t *testing.T) {
 	tests := []struct {
 		name          string
@@ -88,6 +112,13 @@ func TestGetManageRestrictionsCases(t *testing.T) {
 			templateError: nil,
 			expectedError: nil,
 		},
+		{
+			name:          "Get manage restrictions with donor consent given succeeds",
+			caseSummary:   restrictionsCaseSummaryWithDonorConsentGiven,
+			action:        "court-order",
+			templateError: nil,
+			expectedError: nil,
+		},
 		{
 			name:          "Get case summary errors",
 			caseSummary:   sirius.CaseSummary{},
@@ -244,17 +275,17 @@ func TestPostManageRestrictionsWithSeveranceRequiredRedirects(t *testing.T) {
 	tests := []struct {
 		name               string
 		donorConsentAction string
-		severanceDetails   *sirius.SeveranceApplicationDetails
+		severanceDetails   *sirius.SeveranceApplication
 	}{
 		{
 			name:               "Donor consent given",
 			donorConsentAction: "donor-consent-given",
-			severanceDetails:   &sirius.SeveranceApplicationDetails{HasDonorConsented: true},
+			severanceDetails:   &sirius.SeveranceApplication{HasDonorConsented: boolPointer(true)},
 		},
 		{
 			name:               "Donor refused severance",
 			donorConsentAction: "donor-consent-not-given",
-			severanceDetails:   &sirius.SeveranceApplicationDetails{HasDonorConsented: false},
+			severanceDetails:   &sirius.SeveranceApplication{HasDonorConsented: boolPointer(false)},
 		},
 	}
 
@@ -274,6 +305,68 @@ func TestPostManageRestrictionsWithSeveranceRequiredRedirects(t *testing.T) {
 
 			form := url.Values{
 				"donorConsentGiven": {tc.donorConsentAction},
+				"action":            {"donor-consent"},
+			}
+
+			req, _ := http.NewRequest(http.MethodPost, "/lpa/M-1111-2222-3333/manage-restrictions", strings.NewReader(form.Encode()))
+			req.Header.Add("Content-Type", formUrlEncoded)
+			_, err := server.serve(req)
+
+			assert.Equal(t, RedirectError("/lpa/M-1111-2222-3333/lpa-details"), err)
+			mock.AssertExpectationsForObjects(t, client, template)
+		})
+	}
+}
+
+func TestPostManageRestrictionsWithDonorConsentGivenRedirects(t *testing.T) {
+	tests := []struct {
+		name                   string
+		courtOrderDecisionMade string
+		courtOrderReceived     string
+		severanceOrderedAction string
+		severanceDetails       *sirius.SeveranceApplication
+	}{
+		{
+			name:                   "Court order decision made date given",
+			courtOrderDecisionMade: "2025-04-05",
+			courtOrderReceived:     "",
+			severanceOrderedAction: "",
+			severanceDetails: &sirius.SeveranceApplication{
+				CourtOrderDecisionMade: "2025-04-05",
+			},
+		},
+		{
+			name:                   "Court order received date and severance ordered given",
+			courtOrderDecisionMade: "2025-04-05",
+			courtOrderReceived:     "2025-04-10",
+			severanceOrderedAction: "severance-ordered",
+			severanceDetails: &sirius.SeveranceApplication{
+				CourtOrderDecisionMade: "2025-04-05",
+				CourtOrderReceived:     "2025-04-10",
+				SeveranceOrdered:       boolPointer(true),
+			},
+		},
+	}
+
+	for _, tc := range tests {
+		t.Run(tc.name, func(t *testing.T) {
+			client := &mockManageRestrictionsClient{}
+			client.
+				On("CaseSummary", mock.Anything, "M-1111-2222-3333").
+				Return(restrictionsCaseSummaryWithDonorConsentGiven, nil)
+
+			client.
+				On("EditSeveranceApplication", mock.Anything, "M-1111-2222-3333", *tc.severanceDetails).
+				Return(nil)
+
+			template := &mockTemplate{}
+			server := newMockServer("/lpa/{uid}/manage-restrictions", ManageRestrictions(client, template.Func))
+
+			form := url.Values{
+				"courtOrderDecisionMade": {tc.courtOrderDecisionMade},
+				"courtOrderReceived":     {tc.courtOrderReceived},
+				"severanceOrdered":       {tc.severanceOrderedAction},
+				"action":                 {"court-order"},
 			}
 
 			req, _ := http.NewRequest(http.MethodPost, "/lpa/M-1111-2222-3333/manage-restrictions", strings.NewReader(form.Encode()))
diff --git a/internal/sirius/create_draft.go b/internal/sirius/create_draft.go
index a2302890c..447f34f32 100644
--- a/internal/sirius/create_draft.go
+++ b/internal/sirius/create_draft.go
@@ -10,20 +10,21 @@ type Address struct {
 }
 
 type Draft struct {
-	CaseType                  []string   `json:"types"`
-	Source                    string     `json:"source"`
-	DonorFirstNames           string     `json:"donorFirstNames"`
-	DonorLastName             string     `json:"donorLastName"`
-	DonorDob                  DateString `json:"donorDob"`
-	DonorAddress              Address    `json:"donorAddress"`
-	CorrespondentFirstNames   string     `json:"correspondentFirstNames,omitempty"`
-	CorrespondentLastName     string     `json:"correspondentLastName,omitempty"`
-	CorrespondentAddress      *Address   `json:"correspondentAddress,omitempty"`
-	PhoneNumber               string     `json:"donorPhone,omitempty"`
-	Email                     string     `json:"donorEmail,omitempty"`
-	CorrespondenceByWelsh     bool       `json:"correspondenceByWelsh,omitempty"`
-	CorrespondenceLargeFormat bool       `json:"correspondenceLargeFormat,omitempty"`
-	SeveranceStatus           string     `json:"severanceStatus,omitempty"`
+	CaseType                  []string              `json:"types"`
+	Source                    string                `json:"source"`
+	DonorFirstNames           string                `json:"donorFirstNames"`
+	DonorLastName             string                `json:"donorLastName"`
+	DonorDob                  DateString            `json:"donorDob"`
+	DonorAddress              Address               `json:"donorAddress"`
+	CorrespondentFirstNames   string                `json:"correspondentFirstNames,omitempty"`
+	CorrespondentLastName     string                `json:"correspondentLastName,omitempty"`
+	CorrespondentAddress      *Address              `json:"correspondentAddress,omitempty"`
+	PhoneNumber               string                `json:"donorPhone,omitempty"`
+	Email                     string                `json:"donorEmail,omitempty"`
+	CorrespondenceByWelsh     bool                  `json:"correspondenceByWelsh,omitempty"`
+	CorrespondenceLargeFormat bool                  `json:"correspondenceLargeFormat,omitempty"`
+	SeveranceStatus           string                `json:"severanceStatus,omitempty"`
+	SeveranceApplication      *SeveranceApplication `json:"severanceApplication,omitempty"`
 }
 
 func (c *Client) CreateDraft(ctx Context, draft Draft) (map[string]string, error) {
diff --git a/internal/sirius/edit_severance_application.go b/internal/sirius/edit_severance_application.go
index 8ee14d257..c7516b505 100644
--- a/internal/sirius/edit_severance_application.go
+++ b/internal/sirius/edit_severance_application.go
@@ -4,13 +4,13 @@ import (
 	"fmt"
 )
 
-type SeveranceApplicationDetails struct {
-	HasDonorConsented      bool       `json:"hasDonorConsented"`
-	SeveranceOrdered       bool       `json:"severanceOrdered"`
-	CourtOrderDecisionMade DateString `json:"courtOrderDecisionMade"`
-	CourtOrderReceived     DateString `json:"courtOrderReceived"`
+type SeveranceApplication struct {
+	HasDonorConsented      *bool      `json:"hasDonorConsented,omitempty"`
+	SeveranceOrdered       *bool      `json:"severanceOrdered,omitempty"`
+	CourtOrderDecisionMade DateString `json:"courtOrderDecisionMade,omitempty"`
+	CourtOrderReceived     DateString `json:"courtOrderReceived,omitempty"`
 }
 
-func (c *Client) EditSeveranceApplication(ctx Context, caseUID string, severanceApplicationDetails SeveranceApplicationDetails) error {
-	return c.put(ctx, fmt.Sprintf("/lpa-api/v1/digital-lpas/%s/severance", caseUID), severanceApplicationDetails, nil)
+func (c *Client) EditSeveranceApplication(ctx Context, caseUID string, severanceApplication SeveranceApplication) error {
+	return c.put(ctx, fmt.Sprintf("/lpa-api/v1/digital-lpas/%s/severance", caseUID), severanceApplication, nil)
 }
diff --git a/internal/sirius/edit_severance_application_test.go b/internal/sirius/edit_severance_application_test.go
index 2632f144e..c08db59d2 100644
--- a/internal/sirius/edit_severance_application_test.go
+++ b/internal/sirius/edit_severance_application_test.go
@@ -10,6 +10,10 @@ import (
 	"testing"
 )
 
+func boolPointer(b bool) *bool {
+	return &b
+}
+
 func TestEditSeveranceApplication(t *testing.T) {
 	t.Parallel()
 
@@ -17,15 +21,15 @@ func TestEditSeveranceApplication(t *testing.T) {
 	assert.NoError(t, err)
 
 	testCases := []struct {
-		name                        string
-		severanceApplicationDetails SeveranceApplicationDetails
-		setup                       func()
-		expectedError               func(int) error
+		name                 string
+		severanceApplication SeveranceApplication
+		setup                func()
+		expectedError        func(int) error
 	}{
 		{
 			name: "Donor consent given",
-			severanceApplicationDetails: SeveranceApplicationDetails{
-				HasDonorConsented: true,
+			severanceApplication: SeveranceApplication{
+				HasDonorConsented: boolPointer(true),
 			},
 			setup: func() {
 				pact.
@@ -39,10 +43,7 @@ func TestEditSeveranceApplication(t *testing.T) {
 							"Content-Type": matchers.String("application/json"),
 						},
 						Body: map[string]interface{}{
-							"hasDonorConsented":      true,
-							"severanceOrdered":       false,
-							"courtOrderDecisionMade": nil,
-							"courtOrderReceived":     nil,
+							"hasDonorConsented": true,
 						},
 					}).
 					WithCompleteResponse(consumer.Response{
@@ -59,7 +60,7 @@ func TestEditSeveranceApplication(t *testing.T) {
 			assert.Nil(t, pact.ExecuteTest(t, func(config consumer.MockServerConfig) error {
 				client := NewClient(http.DefaultClient, fmt.Sprintf("http://127.0.0.1:%d", config.Port))
 
-				err := client.EditSeveranceApplication(Context{Context: context.Background()}, "M-1234-9876-4567", tc.severanceApplicationDetails)
+				err := client.EditSeveranceApplication(Context{Context: context.Background()}, "M-1234-9876-4567", tc.severanceApplication)
 
 				if tc.expectedError == nil {
 					assert.Nil(t, err)
diff --git a/web/template/manage-restrictions.gohtml b/web/template/manage-restrictions.gohtml
index d6f55bb65..bb28300a6 100644
--- a/web/template/manage-restrictions.gohtml
+++ b/web/template/manage-restrictions.gohtml
@@ -43,6 +43,43 @@
                             </div>
                         </fieldset>
 
+                    {{ else if eq .FormAction "court-order" }}
+                        <fieldset class="govuk-fieldset">
+                            <h2 class="govuk-heading-m">Record court order instructions</h2>
+
+                            <div class="govuk-form-group">
+                                <label class="govuk-label" for="f-courtOrderDecisionMade">
+                                    <strong>Date court order made</strong>
+                                </label>
+                                <input class="govuk-input govuk-!-width-one-third " type="date" id="f-courtOrderDecisionMade" name="courtOrderDecisionMade">
+                            </div>
+
+                            <div class="govuk-form-group">
+                                <label class="govuk-label" for="f-courtOrderReceived">
+                                    <strong>Date court order issued</strong>
+                                </label>
+                                <input class="govuk-input govuk-!-width-one-third " type="date" id="f-courtOrderReceived" name="courtOrderReceived">
+                            </div>
+
+                            <div class="govuk-form-group">
+                                <legend class="govuk-fieldset__legend"><strong>Has severance of the restrictions and conditions been ordered?</strong></legend>
+                                <div class="govuk-radios" data-module="govuk-radios">
+                                    <div class="govuk-radios__item">
+                                        <input class="govuk-radios__input" id="f-severanceNotOrdered" name="severanceOrdered" type="radio" value="severance-not-ordered" {{ if eq "severance-not-ordered" .SeveranceOrderedByCourt }}checked{{ end }}>
+                                        <label class="govuk-label govuk-radios__label" for="f-severanceNotOrdered">
+                                            No
+                                        </label>
+                                    </div>
+                                    <div class="govuk-radios__item">
+                                        <input class="govuk-radios__input" id="f-severanceOrdered" name="severanceOrdered" type="radio" value="severance-ordered" {{ if eq "severance-ordered" .SeveranceOrderedByCourt }}checked{{ end }}>
+                                        <label class="govuk-label govuk-radios__label" for="f-severanceOrdered">
+                                            Yes
+                                        </label>
+                                    </div>
+                                </div>
+                            </div>
+                        </fieldset>
+
                     {{ else if eq .FormAction "donor-consent" }}
                         <fieldset class="govuk-fieldset">
                             <legend class="govuk-fieldset__legend"><strong>Select an option:</strong></legend>
@@ -51,13 +88,13 @@
                             <div class="govuk-radios" data-module="govuk-radios">
                                 <div class="govuk-radios__item">
                                     <input class="govuk-radios__input" id="f-donorConsentGiven" name="donorConsentGiven" type="radio" value="donor-consent-given" {{ if eq "donor-consent-given" .DonorConsentGiven }}checked{{ end }}>
-                                    <label class="govuk-label govuk-radios__label" for="f-severanceActionRequired">
+                                    <label class="govuk-label govuk-radios__label" for="f-donorConsentGiven">
                                         Donor has provided consent to a severance application
                                     </label>
                                 </div>
                                 <div class="govuk-radios__item">
                                     <input class="govuk-radios__input" id="f-donorConsentNotGiven" name="donorConsentGiven" type="radio" value="donor-consent-not-given" {{ if eq "donor-consent-not-given" .DonorConsentGiven }}checked{{ end }}>
-                                    <label class="govuk-label govuk-radios__label" for="f-severanceActionNotRequired">
+                                    <label class="govuk-label govuk-radios__label" for="f-donorConsentNotGiven">
                                         Donor has refused severance of restriction and conditions
                                     </label>
                                 </div>
@@ -71,14 +108,14 @@
 
                             <div class="govuk-radios" data-module="govuk-radios">
                                 <div class="govuk-radios__item">
-                                    <input class="govuk-radios__input" id="f-severanceActionRequired" name="severanceAction" type="radio" value="severance-application-not-required" {{ if eq "severance-application-not-required" .SeveranceAction }}checked{{ end }}>
-                                    <label class="govuk-label govuk-radios__label" for="f-severanceActionRequired">
+                                    <input class="govuk-radios__input" id="f-severanceActionNotRequired" name="severanceAction" type="radio" value="severance-application-not-required" {{ if eq "severance-application-not-required" .SeveranceAction }}checked{{ end }}>
+                                    <label class="govuk-label govuk-radios__label" for="f-severanceActionNotRequired">
                                         Severance application is not required
                                     </label>
                                 </div>
                                 <div class="govuk-radios__item">
-                                    <input class="govuk-radios__input" id="f-severanceActionNotRequired" name="severanceAction" type="radio" value="severance-application-required" {{ if eq "severance-application-required" .SeveranceAction }}checked{{ end }}>
-                                    <label class="govuk-label govuk-radios__label" for="f-severanceActionNotRequired">
+                                    <input class="govuk-radios__input" id="f-severanceActionRequired" name="severanceAction" type="radio" value="severance-application-required" {{ if eq "severance-application-required" .SeveranceAction }}checked{{ end }}>
+                                    <label class="govuk-label govuk-radios__label" for="f-severanceActionRequired">
                                         Severance application is required
                                     </label>
                                 </div>
@@ -88,11 +125,15 @@
                 </div>
 
                 <div class="govuk-button-group">
-                    {{ if eq .FormAction "donor-consent" }}
-                        <button class="govuk-button" data-module="govuk-button" type="submit">Save and exit</button>
-                    {{ else }}
-                        <button class="govuk-button" data-module="govuk-button" type="submit">Confirm</button>
-                    {{ end }}
+                    <button class="govuk-button" data-module="govuk-button" type="submit">
+                        {{ if eq .FormAction "court-order" }}
+                            Save and continue
+                        {{ else if eq .FormAction "donor-consent" }}
+                            Save and exit
+                        {{ else }}
+                            Confirm
+                        {{ end }}
+                    </button>
                     <a data-app-iframe-cancel class="govuk-link govuk-link--no-visited-state" href="{{ prefix (printf "/lpa/%s/lpa-details" .CaseUID )}}">Cancel</a>
                 </div>
             </form>


Reviews:
user: login: github-advanced-security[bot]
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-22T14:28:40Z
user: login: gregtyler
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-23T07:55:38Z
user: login: ndasmoj
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-23T13:53:26Z
user: login: gregtyler
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-23T15:00:06Z

Review comments:
diff_hunk: @@ -55,17 +58,24 @@
 		}
 
 		data := manageRestrictionsData{
-			CaseSummary:       cs,
-			SeveranceAction:   postFormString(r, "severanceAction"),
-			DonorConsentGiven: postFormString(r, "donorConsentGiven"),
-			XSRFToken:         ctx.XSRFToken,
-			Error:             sirius.ValidationError{Field: sirius.FieldErrors{}},
-			CaseUID:           caseUID,
+			CaseSummary:             cs,
+			SeveranceAction:         postFormString(r, "severanceAction"),
+			DonorConsentGiven:       postFormString(r, "donorConsentGiven"),
+			SeveranceOrderedByCourt: postFormString(r, "severanceOrdered"),
+			CourtOrderDecisionDate:  postFormDateString(r, "courtOrderDecisionMade"),
+			CourtOrderReceivedDate:  postFormDateString(r, "courtOrderReceived"),
+			XSRFToken:               ctx.XSRFToken,
+			Error:                   sirius.ValidationError{Field: sirius.FieldErrors{}},
+			CaseUID:                 caseUID,
 		}
 
 		data.FormAction = r.FormValue("action")
 		if data.FormAction == "" && data.CaseSummary.DigitalLpa.SiriusData.Application.SeveranceStatus == "REQUIRED" {
 			data.FormAction = "donor-consent"
+
+			if data.CaseSummary.DigitalLpa.SiriusData.Application.SeveranceApplication != nil && *data.CaseSummary.DigitalLpa.SiriusData.Application.SeveranceApplication.HasDonorConsented == true {
path: internal/server/manage_restrictions.go
user: login: github-advanced-security[bot]
body: S1002: should omit comparison to bool constant, can be simplified to *data.CaseSummary.DigitalLpa.SiriusData.Application.SeveranceApplication.HasDonorConsented

[Show more details](https://github.com/ministryofjustice/opg-sirius-lpa-frontend/security/code-scanning/77)
created_at: 2025-04-22T14:28:40Z
author_association: NONE
diff_hunk: @@ -10,22 +10,26 @@ import (
 	"testing"
 )
 
+func convertToBool(b bool) *bool {
path: internal/sirius/edit_severance_application_test.go
user: login: gregtyler
body: Maybe a bit of a clearer name?
```suggestion
func boolPointer(b bool) *bool {
```
created_at: 2025-04-23T07:54:14Z
author_association: CONTRIBUTOR
diff_hunk: @@ -10,22 +10,26 @@ import (
 	"testing"
 )
 
+func convertToBool(b bool) *bool {
path: internal/sirius/edit_severance_application_test.go
user: login: ndasmoj
body: This has been done.
created_at: 2025-04-23T13:53:26Z
author_association: CONTRIBUTOR

PR comments:
user: login: codecov-commenter
created_at: 2025-04-22T15:01:01Z
body: ## [Codecov](https://app.codecov.io/gh/ministryofjustice/opg-sirius-lpa-frontend/pull/649?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ministryofjustice) Report
:x: Patch coverage is `84.21053%` with `6 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 80.46%. Comparing base ([`b39d49e`](https://app.codecov.io/gh/ministryofjustice/opg-sirius-lpa-frontend/commit/b39d49e892c038d269d7339af4439fff44f23e59?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ministryofjustice)) to head ([`36500e1`](https://app.codecov.io/gh/ministryofjustice/opg-sirius-lpa-frontend/commit/36500e1fce27d0f19c5a94ef62b1e402211d84cd?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ministryofjustice)).
:warning: Report is 230 commits behind head on main.

| [Files with missing lines](https://app.codecov.io/gh/ministryofjustice/opg-sirius-lpa-frontend/pull/649?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ministryofjustice) | Patch % | Lines |
|---|---|---|
| [internal/server/manage\_restrictions.go](https://app.codecov.io/gh/ministryofjustice/opg-sirius-lpa-frontend/pull/649?src=pr&el=tree&filepath=internal%2Fserver%2Fmanage_restrictions.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ministryofjustice#diff-aW50ZXJuYWwvc2VydmVyL21hbmFnZV9yZXN0cmljdGlvbnMuZ28=) | 83.33% | [4 Missing and 2 partials :warning: ](https://app.codecov.io/gh/ministryofjustice/opg-sirius-lpa-frontend/pull/649?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ministryofjustice) |

<details><summary>Additional details and impacted files</summary>



```diff
@@            Coverage Diff             @@
##             main     #649      +/-   ##
==========================================
- Coverage   80.47%   80.46%   -0.02%     
==========================================
  Files         134      134              
  Lines        5343     5370      +27     
==========================================
+ Hits         4300     4321      +21     
- Misses        834      838       +4     
- Partials      209      211       +2     
```
</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/ministryofjustice/opg-sirius-lpa-frontend/pull/649?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ministryofjustice).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ministryofjustice).
<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
author_association: NONE
user: login: sonarqubecloud[bot]
created_at: 2025-04-23T13:53:42Z
body: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=ministryofjustice_opg-sirius-lpa-frontend&pullRequest=649) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [6 New issues](https://sonarcloud.io/project/issues?id=ministryofjustice_opg-sirius-lpa-frontend&pullRequest=649&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=ministryofjustice_opg-sirius-lpa-frontend&pullRequest=649&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=ministryofjustice_opg-sirius-lpa-frontend&pullRequest=649&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=ministryofjustice_opg-sirius-lpa-frontend&pullRequest=649&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=ministryofjustice_opg-sirius-lpa-frontend&pullRequest=649&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=ministryofjustice_opg-sirius-lpa-frontend&pullRequest=649)


author_association: NONE