Skip to content

Commit

Permalink
Add more data to the LPA
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx committed Dec 14, 2023
1 parent 9e842e7 commit a709a52
Show file tree
Hide file tree
Showing 5 changed files with 462 additions and 97 deletions.
105 changes: 95 additions & 10 deletions docs/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,70 @@ components:
InitialLpa:
type: object
required:
- type
- donor
- attorneys
- certificateProvider
- signedAt
properties:
type:
type: string
enum:
- pfa
- hw
donor:
$ref: "#/components/schemas/Donor"
attorneys:
type: array
items:
$ref: "#/components/schemas/Attorney"
minLength: 1
additionalProperties: false
certificateProvider:
$ref: "#/components/schemas/CertificateProvider"
peopleToNotify:
type: array
items:
$ref: "#/components/schemas/PersonToNotify"
howAttorneysMakeDecisions:
type: string
enum:
- jointly
- jointly-and-severally
- mixed
howAttorneysMakeDecisionsDetails:
type: string
howReplacementAttorneysMakeDecisions:
type: string
enum:
- jointly
- jointly-and-severally
- mixed
howReplacementAttorneysMakeDecisionsDetails:
type: string
howReplacementAttorneysStepIn:
type: string
enum:
- all
- one
- other
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
required:
Expand Down Expand Up @@ -271,29 +324,31 @@ 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"
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 @@ -302,13 +357,43 @@ 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
CertificateProvider:
allOf:
- $ref: "#/components/schemas/Person"
type: object
required:
- email
- carryOutBy
properties:
email:
type: string
x-faker: internet.email
carryOutBy:
type: string
enum:
- paper
- online
PersonToNotify:
allOf:
- $ref: "#/components/schemas/Person"
type: object
Update:
type: object
required:
Expand Down
28 changes: 26 additions & 2 deletions internal/shared/lpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,21 @@ package shared
import "time"

type LpaInit struct {
Donor Donor `json:"donor" dynamodbav:""`
Attorneys []Attorney `json:"attorneys" dynamodbav:""`
Type Type `json:"type"`
Donor Donor `json:"donor" dynamodbav:""`
Attorneys []Attorney `json:"attorneys" dynamodbav:""`
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 CanUseWhen `json:"whenTheLpaCanBeUsed"`
LifeSustainingTreatmentOption LifeSustainingTreatment `json:"lifeSustainingTreatmentOption"`
Restrictions string `json:"restrictions"`
SignedAt time.Time `json:"signedAt"`
}

type Lpa struct {
Expand All @@ -15,6 +28,17 @@ type Lpa struct {
UpdatedAt time.Time `json:"updatedAt" dynamodbav:""`
}

type Type string

const (
TypeHealthWelfare = Type("hw")
TypePropertyFinance = Type("pfa")
)

func (e Type) IsValid() bool {
return e == TypeHealthWelfare || e == TypePropertyFinance
}

type LpaStatus string

const (
Expand Down
89 changes: 83 additions & 6 deletions internal/shared/person.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,35 @@ type Address struct {
}

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" dynamodbav:""`
LastName string `json:"lastName"`
Address Address `json:"address" dynamodbav:""`
}

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

type CertificateProvider struct {
Person
Email string `json:"email" dynamodbav:""`
CarryOutBy CarryOutBy `json:"carryOutBy"`
}

type CarryOutBy string

const (
CarryOutByOnline = CarryOutBy("online")
CarryOutByPaper = CarryOutBy("paper")
)

func (e CarryOutBy) IsValid() bool {
return e == CarryOutByOnline || e == CarryOutByPaper
}

type AttorneyStatus string

const (
Expand All @@ -36,5 +53,65 @@ func (a AttorneyStatus) IsValid() bool {

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

type PersonToNotify struct {
Person
}

type HowMakeDecisions string

const (
HowMakeDecisionsUnset = HowMakeDecisions("")
HowMakeDecisionsJointly = HowMakeDecisions("jointly")
HowMakeDecisionsJointlyAndSeverally = HowMakeDecisions("jointly-and-severally")
HowMakeDecisionsJointlyForSomeSeverallyForOthers = HowMakeDecisions("mixed")
)

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")
HowStepInOneCanNoLongerAct = HowStepIn("one")
HowStepInAnotherWay = HowStepIn("other")
)

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

type CanUseWhen string

const (
CanUseWhenUnset = CanUseWhen("")
CanUseWhenCapacityLost = CanUseWhen("when-capacity-lost")
CanUseWhenHasCapacity = CanUseWhen("when-has-capacity")
)

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

type LifeSustainingTreatment string

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

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

0 comments on commit a709a52

Please sign in to comment.