Skip to content

Commit

Permalink
MLPAB-1637 Add more data to the LPA (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx authored Dec 18, 2023
1 parent 4f51b6e commit c1afbfa
Show file tree
Hide file tree
Showing 6 changed files with 775 additions and 118 deletions.
132 changes: 122 additions & 10 deletions docs/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,73 @@ components:
InitialLpa:
type: object
required:
- lpaType
- donor
- attorneys
- certificateProvider
- signedAt
properties:
lpaType:
type: string
enum:
- property-and-affairs
- personal-welfare
donor:
$ref: "#/components/schemas/Donor"
attorneys:
type: array
items:
$ref: "#/components/schemas/Attorney"
minLength: 1
trustCorporations:
type: array
items:
$ref: "#/components/schemas/TrustCorporation"
certificateProvider:
$ref: "#/components/schemas/CertificateProvider"
peopleToNotify:
type: array
items:
$ref: "#/components/schemas/PersonToNotify"
howAttorneysMakeDecisions:
type: string
enum:
- jointly
- jointly-and-severally
- jointly-for-some-severally-for-others
howAttorneysMakeDecisionsDetails:
type: string
howReplacementAttorneysMakeDecisions:
type: string
enum:
- jointly
- jointly-and-severally
- jointly-for-some-severally-for-others
howReplacementAttorneysMakeDecisionsDetails:
type: string
howReplacementAttorneysStepIn:
type: string
enum:
- all-can-no-longer-act
- one-can-no-longer-act
- another-way
howReplacementAttorneysStepInDetails:
type: string
whenTheLpaCanBeUsed:
type: string
enum:
- when-capacity-lost
- when-has-capacity
lifeSustainingTreatmentOption:
type: string
enum:
- option-a
- option-b
restrictions:
type: string
signedAt:
type: string
format: date-time
additionalProperties: false
Address:
type: object
Expand Down Expand Up @@ -284,30 +341,32 @@ components:
type: object
required:
- firstNames
- surname
- dateOfBirth
- lastName
- address
properties:
firstNames:
type: string
x-faker: name.firstName
surname:
lastName:
type: string
x-faker: name.lastName
dateOfBirth:
type: string
format: date
email:
type: string
x-faker: internet.email
address:
$ref: "#/components/schemas/Address"
additionalProperties: false
Donor:
allOf:
- $ref: "#/components/schemas/Person"
type: object
required:
- dateOfBirth
- email
properties:
dateOfBirth:
type: string
format: date
email:
type: string
x-faker: internet.email
otherNamesKnownBy:
type: string
nullable: true
Expand All @@ -317,14 +376,67 @@ components:
allOf:
- $ref: "#/components/schemas/Person"
type: object
required:
- dateOfBirth
- email
- status
properties:
dateOfBirth:
type: string
format: date
email:
type: string
x-faker: internet.email
status:
type: string
enum:
- active
- replacement
- removed
additionalProperties: false
TrustCorporation:
type: object
required:
- name
- companyNumber
- email
- address
- status
properties:
name:
type: string
companyNumber:
type: string
email:
type: string
x-faker: internet.email
address:
$ref: "#/components/schemas/Address"
status:
type: string
enum:
- active
- replacement
- removed
CertificateProvider:
allOf:
- $ref: "#/components/schemas/Person"
type: object
required:
- email
- channel
properties:
email:
type: string
x-faker: internet.email
channel:
type: string
enum:
- paper
- online
PersonToNotify:
allOf:
- $ref: "#/components/schemas/Person"
type: object
Update:
type: object
required:
Expand Down
37 changes: 31 additions & 6 deletions internal/shared/lpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,41 @@ package shared
import "time"

type LpaInit struct {
Donor Donor `json:"donor" dynamodbav:""`
Attorneys []Attorney `json:"attorneys" dynamodbav:""`
LpaType LpaType `json:"lpaType"`
Donor Donor `json:"donor"`
Attorneys []Attorney `json:"attorneys"`
TrustCorporations []TrustCorporation `json:"trustCorporations"`
CertificateProvider CertificateProvider `json:"certificateProvider"`
PeopleToNotify []PersonToNotify `json:"peopleToNotify"`
HowAttorneysMakeDecisions HowMakeDecisions `json:"howAttorneysMakeDecisions"`
HowAttorneysMakeDecisionsDetails string `json:"howAttorneysMakeDecisionsDetails"`
HowReplacementAttorneysMakeDecisions HowMakeDecisions `json:"howReplacementAttorneysMakeDecisions"`
HowReplacementAttorneysMakeDecisionsDetails string `json:"howReplacementAttorneysMakeDecisionsDetails"`
HowReplacementAttorneysStepIn HowStepIn `json:"howReplacementAttorneysStepIn"`
HowReplacementAttorneysStepInDetails string `json:"howReplacementAttorneysStepInDetails"`
WhenTheLpaCanBeUsed CanUse `json:"whenTheLpaCanBeUsed"`
LifeSustainingTreatmentOption LifeSustainingTreatment `json:"lifeSustainingTreatmentOption"`
Restrictions string `json:"restrictions"`
SignedAt time.Time `json:"signedAt"`
}

type Lpa struct {
LpaInit
Uid string `json:"uid" dynamodbav:""`
Status LpaStatus `json:"status" dynamodbav:""`
RegistrationDate time.Time `json:"registrationDate" dynamodbav:""`
UpdatedAt time.Time `json:"updatedAt" dynamodbav:""`
Uid string `json:"uid"`
Status LpaStatus `json:"status"`
RegistrationDate time.Time `json:"registrationDate"`
UpdatedAt time.Time `json:"updatedAt"`
}

type LpaType string

const (
LpaTypePersonalWelfare = LpaType("personal-welfare")
LpaTypePropertyAndAffairs = LpaType("property-and-affairs")
)

func (e LpaType) IsValid() bool {
return e == LpaTypePersonalWelfare || e == LpaTypePropertyAndAffairs
}

type LpaStatus string
Expand Down
119 changes: 106 additions & 13 deletions internal/shared/person.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,42 @@
package shared

type Address struct {
Line1 string `json:"line1" dynamodbav:""`
Line2 string `json:"line2" dynamodbav:""`
Line3 string `json:"line3" dynamodbav:""`
Town string `json:"town" dynamodbav:""`
Postcode string `json:"postcode" dynamodbav:""`
Country string `json:"country" dynamodbav:""`
Line1 string `json:"line1"`
Line2 string `json:"line2"`
Line3 string `json:"line3"`
Town string `json:"town"`
Postcode string `json:"postcode"`
Country string `json:"country"`
}

type Person struct {
FirstNames string `json:"firstNames" dynamodbav:""`
Surname string `json:"surname" dynamodbav:""`
DateOfBirth Date `json:"dateOfBirth" dynamodbav:""`
Email string `json:"email" dynamodbav:""`
Address Address `json:"address" dynamodbav:""`
FirstNames string `json:"firstNames"`
LastName string `json:"lastName"`
Address Address `json:"address"`
}

type Donor struct {
Person
OtherNamesKnownBy string `json:"otherNamesKnownBy" dynamodbav:""`
DateOfBirth Date `json:"dateOfBirth"`
Email string `json:"email"`
OtherNamesKnownBy string `json:"otherNamesKnownBy"`
}

type CertificateProvider struct {
Person
Email string `json:"email"`
Channel Channel `json:"channel"`
}

type Channel string

const (
ChannelOnline = Channel("online")
ChannelPaper = Channel("paper")
)

func (e Channel) IsValid() bool {
return e == ChannelOnline || e == ChannelPaper
}

type AttorneyStatus string
Expand All @@ -36,5 +53,81 @@ func (a AttorneyStatus) IsValid() bool {

type Attorney struct {
Person
Status AttorneyStatus `json:"status" dynamodbav:""`
DateOfBirth Date `json:"dateOfBirth"`
Email string `json:"email"`
Status AttorneyStatus `json:"status"`
}

type TrustCorporation struct {
Name string `json:"name"`
CompanyNumber string `json:"companyNumber"`
Email string `json:"email"`
Address Address `json:"address"`
Status AttorneyStatus `json:"status"`
}

type PersonToNotify struct {
Person
}

type HowMakeDecisions string

const (
HowMakeDecisionsUnset = HowMakeDecisions("")
HowMakeDecisionsJointly = HowMakeDecisions("jointly")
HowMakeDecisionsJointlyAndSeverally = HowMakeDecisions("jointly-and-severally")
HowMakeDecisionsJointlyForSomeSeverallyForOthers = HowMakeDecisions("jointly-for-some-severally-for-others")
)

func (e HowMakeDecisions) IsValid() bool {
return e == HowMakeDecisionsJointly || e == HowMakeDecisionsJointlyAndSeverally || e == HowMakeDecisionsJointlyForSomeSeverallyForOthers
}

func (e HowMakeDecisions) Unset() bool {
return e == HowMakeDecisionsUnset
}

type HowStepIn string

const (
HowStepInUnset = HowStepIn("")
HowStepInAllCanNoLongerAct = HowStepIn("all-can-no-longer-act")
HowStepInOneCanNoLongerAct = HowStepIn("one-can-no-longer-act")
HowStepInAnotherWay = HowStepIn("another-way")
)

func (e HowStepIn) IsValid() bool {
return e == HowStepInUnset || e == HowStepInAllCanNoLongerAct || e == HowStepInOneCanNoLongerAct || e == HowStepInAnotherWay
}

type CanUse string

const (
CanUseUnset = CanUse("")
CanUseWhenCapacityLost = CanUse("when-capacity-lost")
CanUseWhenHasCapacity = CanUse("when-has-capacity")
)

func (e CanUse) IsValid() bool {
return e == CanUseWhenCapacityLost || e == CanUseWhenHasCapacity
}

func (e CanUse) Unset() bool {
return e == CanUseUnset
}

type LifeSustainingTreatment string

const (
LifeSustainingTreatmentUnset = LifeSustainingTreatment("")
LifeSustainingTreatmentOptionA = LifeSustainingTreatment("option-a")
LifeSustainingTreatmentOptionB = LifeSustainingTreatment("option-b")
)

func (e LifeSustainingTreatment) IsValid() bool {
return e == LifeSustainingTreatmentOptionA || e == LifeSustainingTreatmentOptionB
}

func (e LifeSustainingTreatment) Unset() bool {
return e == LifeSustainingTreatmentUnset
}
Loading

0 comments on commit c1afbfa

Please sign in to comment.