Skip to content

feat(my-pages): add back "other" for organ donation registration #17228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Dec 19, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,20 @@ export class HealthDirectorateService {
if (data === null) {
return null
}
const hasExceptionComment: boolean =
data.exceptionComment !== undefined && data.exceptionComment.length > 0
const hasExceptions: boolean =
data.exceptions !== undefined && data.exceptions.length > 0
const donorStatus: Donor = {
isDonor: data?.isDonor ?? true,
isDonor: data.isDonor,
limitations: {
hasLimitations:
((data?.exceptions?.length ?? 0) > 0 && data?.isDonor) ?? false,
limitedOrgansList: data?.exceptions,
comment: data?.exceptionComment,
((hasExceptionComment || hasExceptions) && data.isDonor) ?? false,
limitedOrgansList: data.exceptions,
comment: data.exceptionComment,
},
isMinor: data.isMinor ?? false,
isTemporaryResident: data.isTemporaryResident ?? false,
}
return donorStatus
}
Expand All @@ -62,11 +68,15 @@ export class HealthDirectorateService {
input: DonorInput,
locale: Locale,
): Promise<void> {
const filteredList =
input.organLimitations?.filter((item) => item !== 'other') ?? []

return await this.organDonationApi.updateOrganDonation(
auth,
{
isDonor: input.isDonor,
exceptions: input.organLimitations ?? [],
exceptions: filteredList,
exceptionComment: input.comment,
},
locale === 'is' ? organLocale.Is : organLocale.En,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ export class Donor {

@Field(() => Limitations, { nullable: true })
limitations?: Limitations

@Field(() => Boolean, { defaultValue: false })
isMinor!: boolean

@Field(() => Boolean, { defaultValue: false })
isTemporaryResident!: boolean
}

@ObjectType('HealthDirectorateOrganDonation')
Expand All @@ -54,4 +60,7 @@ export class DonorInput {

@Field(() => [String], { nullable: true })
organLimitations?: string[]

@Field({ nullable: true })
comment?: string
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
{
"openapi": "3.0.0",
"paths": {
"/v1/me/organ-donor-status": {
"/v1/donation-exceptions": {
"get": {
"operationId": "MeDonorStatusController_getOrganDonorStatus",
"description": "Get user's donation-exception donor status",
"operationId": "DonationExceptionController_getOrgans",
"description": "Gets a list of organs that can be omitted from an donation-exception donation",
"parameters": [
{
"name": "ip",
"required": false,
"in": "query",
"description": "The IP address of the user",
"schema": { "type": "string" }
},
{
"name": "locale",
"required": false,
Expand All @@ -26,7 +19,10 @@
"description": "",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/OrganDonorDto" }
"schema": {
"type": "array",
"items": { "$ref": "#/components/schemas/OrganDto" }
}
}
}
},
Expand Down Expand Up @@ -63,37 +59,38 @@
}
}
},
"tags": ["me/organ-donor-status"]
},
"post": {
"operationId": "MeDonorStatusController_updateOrganDonorStatus",
"description": "Update user's donation-exception donor status",
"tags": ["donation-exceptions"]
}
},
"/v1/me/organ-donor-status": {
"get": {
"operationId": "MeDonorStatusController_getOrganDonorStatus",
"description": "Get user's donation-exception donor status",
"parameters": [
{
"name": "ip",
"name": "locale",
"required": false,
"in": "query",
"description": "The IP address of the user",
"schema": { "type": "string" }
"description": "The locale to use for the response",
"schema": { "$ref": "#/components/schemas/Locale" }
},
{
"name": "locale",
"name": "ip",
"required": false,
"in": "query",
"description": "The locale to use for the response",
"schema": { "$ref": "#/components/schemas/Locale" }
"description": "The IP address of the user",
"schema": { "type": "string" }
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/UpdateOrganDonorDto" }
}
}
},
"responses": {
"200": { "description": "" },
"200": {
"description": "",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/OrganDonorDto" }
}
}
},
"400": {
"description": "",
"content": {
Expand Down Expand Up @@ -128,33 +125,36 @@
}
},
"tags": ["me/organ-donor-status"]
}
},
"/v1/donation-exceptions": {
"get": {
"operationId": "DonationExceptionController_getOrgans",
"description": "Gets a list of organs that can be omitted from an donation-exception donation",
},
"post": {
"operationId": "MeDonorStatusController_updateOrganDonorStatus",
"description": "Update user's donation-exception donor status",
"parameters": [
{
"name": "locale",
"required": false,
"in": "query",
"description": "The locale to use for the response",
"schema": { "$ref": "#/components/schemas/Locale" }
},
{
"name": "ip",
"required": false,
"in": "query",
"description": "The IP address of the user",
"schema": { "type": "string" }
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": { "$ref": "#/components/schemas/OrganDto" }
}
}
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/UpdateOrganDonorDto" }
}
},
}
},
"responses": {
"200": { "description": "" },
"400": {
"description": "",
"content": {
Expand Down Expand Up @@ -188,7 +188,7 @@
}
}
},
"tags": ["donation-exceptions"]
"tags": ["me/organ-donor-status"]
}
}
},
Expand Down Expand Up @@ -226,24 +226,11 @@
},
"required": ["id", "name"]
},
"OrganDonorDto": {
"type": "object",
"properties": {
"isDonor": { "type": "boolean" },
"exceptions": {
"type": "array",
"items": { "$ref": "#/components/schemas/OrganDto" }
},
"exceptionComment": { "type": "string" },
"registrationDate": { "format": "date-time", "type": "string" }
},
"required": ["isDonor", "exceptions"]
},
"HttpProblemResponse": {
"type": "object",
"properties": {
"type": {
"type": "object",
"type": "string",
"description": "A URI reference that identifies the problem type"
},
"title": {
Expand All @@ -262,12 +249,27 @@
},
"required": ["type", "title"]
},
"OrganDonorDto": {
"type": "object",
"properties": {
"isDonor": { "type": "boolean" },
"exceptions": {
"type": "array",
"items": { "$ref": "#/components/schemas/OrganDto" }
},
"exceptionComment": { "type": "string" },
"registrationDate": { "format": "date-time", "type": "string" },
"isMinor": { "type": "boolean" },
"isTemporaryResident": { "type": "boolean" }
},
"required": ["isDonor", "exceptions"]
},
"UpdateOrganDonorDto": {
"type": "object",
"properties": {
"isDonor": { "type": "boolean" },
"exceptions": { "type": "array", "items": { "type": "string" } },
"exceptionComment": { "type": "object" }
"exceptionComment": { "type": "string" }
},
"required": ["isDonor", "exceptions"]
}
Expand Down
12 changes: 12 additions & 0 deletions libs/portals/my-pages/health/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1024,10 +1024,22 @@ export const messages = defineMessages({
defaultMessage:
'Textareitur má ekki vera tómur sé þessi valkostur valinn. ',
},
organMinor: {
id: 'sp.health:organ-minor',
defaultMessage: 'Til að geta gerst líffæragjafi þarftu að vera 18 ára.',
},
organTemporaryNationalId: {
id: 'sp.health:organ-temporary-national-id',
defaultMessage: 'Líffæragjöf er ekki heimiluð á kerfiskennitölur.',
},
other: {
id: 'sp.health:other-lower-case',
defaultMessage: 'annað',
},
otherPascalCase: {
id: 'sp.health:other',
defaultMessage: 'Annað',
},
registrationComplete: {
id: 'sp.health:registration-complete',
defaultMessage: 'Skráning tókst',
Expand Down
2 changes: 1 addition & 1 deletion libs/portals/my-pages/health/src/module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const OrganDonation = lazy(() =>
)

const OrganDonationRegistration = lazy(() =>
import('./screens/OrganDonationRegistration/RegistrationForm'),
import('./screens/OrganDonation/components/RegistrationForm'),
)

const Vaccinations = lazy(() =>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { style, keyframes } from '@vanilla-extract/css'
import { theme } from '@island.is/island-ui/theme'

export const buttonContainer = style({
gap: theme.spacing[2],
})

const fadeIn = keyframes({
from: {
opacity: 0,
},
to: {
opacity: 1,
},
})

const fadeOut = keyframes({
from: {
opacity: 1,
},
to: {
opacity: 0,
},
})

export const commentVisible = style({
animation: `${fadeIn} 0.5s forwards`,
})

export const commentHidden = style({
animation: `${fadeOut} 0.5s forwards`,
})
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,8 @@ query getDonorStatus($locale: String) {
}
comment
}
}
}
}

query getOrgansList($locale: String) {
healthDirectorateOrganDonation(locale: $locale) {
donor {
isDonor
limitations {
hasLimitations
limitedOrgansList {
id
name
}
}
isMinor
isTemporaryResident
}
organList {
id
Expand Down
Loading
Loading