Skip to content

Commit

Permalink
MLPAB-2471 Add witnessed at times for lpa (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx authored Oct 8, 2024
1 parent da760c8 commit d2cf075
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/example-lpa.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
},
"lifeSustainingTreatmentOption": "option-a",
"signedAt": "2024-01-10T23:00:00Z",
"witnessedByCertificateProviderAt": "2024-01-11T01:00:00Z",
"certificateProviderNotRelatedConfirmedAt": "2024-01-11T22:00:00Z",
"howAttorneysMakeDecisions": "jointly"
}
8 changes: 8 additions & 0 deletions docs/schemas/2024-10/donor-details.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@
"type": "string",
"format": "date-time"
},
"witnessedByCertificateProviderAt": {
"type": "string",
"format": "date-time"
},
"witnessedByIndependentWitnessAt": {
"type": "string",
"format": "date-time"
},
"certificateProviderNotRelatedConfirmedAt": {
"type": "string",
"format": "date-time"
Expand Down
2 changes: 2 additions & 0 deletions internal/shared/lpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type LpaInit struct {
RestrictionsAndConditions string `json:"restrictionsAndConditions,omitempty"`
RestrictionsAndConditionsImages []FileUpload `json:"restrictionsAndConditionsImages,omitempty"`
SignedAt time.Time `json:"signedAt"`
WitnessedByCertificateProviderAt time.Time `json:"witnessedByCertificateProviderAt"`
WitnessedByIndependentWitnessAt *time.Time `json:"witnessedByIndependentWitnessAt,omitempty"`
CertificateProviderNotRelatedConfirmedAt *time.Time `json:"certificateProviderNotRelatedConfirmedAt,omitempty"`
}

Expand Down
2 changes: 1 addition & 1 deletion internal/shared/lpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestLpaInitMarshalJSON(t *testing.T) {
"donor":{"uid":"","firstNames":"","lastName":"","address":{"line1":"","country":""},"dateOfBirth":"","email":"","contactLanguagePreference":""},
"attorneys":null,
"certificateProvider":{"uid":"","firstNames":"","lastName":"","address":{"line1":"","country":""},"email":"","phone":"","channel":""},
"signedAt":"0001-01-01T00:00:00Z"
"signedAt":"0001-01-01T00:00:00Z","witnessedByCertificateProviderAt":"0001-01-01T00:00:00Z"
}`

data, _ := json.Marshal(LpaInit{})
Expand Down
5 changes: 3 additions & 2 deletions lambda/create/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ var (
Phone: "0777777777",
ContactLanguagePreference: shared.LangEn,
},
WhenTheLpaCanBeUsed: shared.CanUseWhenHasCapacity,
SignedAt: testNow,
WhenTheLpaCanBeUsed: shared.CanUseWhenHasCapacity,
SignedAt: testNow,
WitnessedByCertificateProviderAt: testNow,
}
)

Expand Down
2 changes: 2 additions & 0 deletions lambda/create/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func Validate(lpa shared.LpaInit) []shared.FieldError {
validate.IsValid("/whenTheLpaCanBeUsed", lpa.WhenTheLpaCanBeUsed),
validate.Unset("/lifeSustainingTreatmentOption", lpa.LifeSustainingTreatmentOption))),
validate.Time("/signedAt", lpa.SignedAt),
// validate.Time("/witnessedByCertificateProviderAt", lpa.WitnessedByCertificateProviderAt),
// validate.OptionalTime("/witnessedByIndependentWitnessAt", lpa.WitnessedByIndependentWitnessAt),
validate.OptionalTime("/certificateProviderNotRelatedConfirmedAt", lpa.CertificateProviderNotRelatedConfirmedAt),
)
}
Expand Down
10 changes: 6 additions & 4 deletions lambda/create/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ func makeLpaWithDonorAndActors() shared.LpaInit {
ContactLanguagePreference: shared.LangEn,
DateOfBirth: newDate("1956-08-08"),
},
CertificateProvider: makeCertificateProvider(),
Attorneys: []shared.Attorney{makeAttorney()},
SignedAt: time.Now(),
WhenTheLpaCanBeUsed: shared.CanUseWhenHasCapacity,
CertificateProvider: makeCertificateProvider(),
Attorneys: []shared.Attorney{makeAttorney()},
SignedAt: time.Now(),
WitnessedByCertificateProviderAt: time.Now(),
WhenTheLpaCanBeUsed: shared.CanUseWhenHasCapacity,
}
}

Expand Down Expand Up @@ -212,6 +213,7 @@ func TestValidateLpaInvalid(t *testing.T) {
{Source: "/certificateProvider/phone", Detail: "field is required"},
{Source: "/attorneys", Detail: "at least one attorney is required"},
{Source: "/signedAt", Detail: "field is required"},
// {Source: "/witnessedByCertificateProviderAt", Detail: "field is required"},
},
},
"online certificate provider missing email": {
Expand Down

0 comments on commit d2cf075

Please sign in to comment.