Skip to content

Commit

Permalink
feat(service-portal): Health - Organ donation (#15227)
Browse files Browse the repository at this point in the history
* feat: add organ donation overview

* feat: add organ donation registration

* fix: form logic

* fix: form logic

* fix: text

* fix: wrong naming

* feat: add checkboxes

* feat: simplify form

* feat: add organ donation to submenu

* feat: update list

* fix: mobile input

* fix: rewrite to fix order of checkboxes

* feat: add feature flag for routes

* feat: remove input & fix texts

* feat: add scopes

* fix: scope

* fix: domain build issues

* fix: nullable error

* feat: connect to graphql

* fix: naming

---------

Co-authored-by: lommi <jonorn@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored and oskarjs committed Aug 20, 2024
1 parent 101ed8b commit 029b85e
Show file tree
Hide file tree
Showing 18 changed files with 638 additions and 10 deletions.
1 change: 1 addition & 0 deletions apps/service-portal/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const SERVICE_PORTAL_SCOPES = [
ApiScope.healthHealthcare,
ApiScope.healthRightsStatus,
ApiScope.healthDentists,
ApiScope.healthOrganDonation,
ApiScope.healthVaccinations,
ApiScope.signatureCollection,
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ export class HealthDirectorateResolver {
constructor(private api: HealthDirectorateService) {}

/* Organ Donation */
@Query(() => DonorStatus)
@Query(() => DonorStatus, {
name: 'HealthDirectorateOrganDonationGetDonorStatus',
})
@Audit()
getDonorStatus(@CurrentUser() user: User): Promise<DonorStatus> {
return this.api.getDonorStatus(user)
}

@Query(() => DonationException)
@Query(() => DonationException, {
name: 'HealthDirectorateOrganDonationGetDonationExceptions',
})
@Audit()
getDonationExceptions(
@Args('locale', { type: () => String, nullable: true })
Expand All @@ -44,7 +48,10 @@ export class HealthDirectorateResolver {
return this.api.getDonationExceptions(user, locale)
}

@Mutation(() => Boolean)
@Mutation(() => Boolean, {
nullable: true,
name: 'HealthDirectorateOrganDonationUpdateDonorStatus',
})
@Audit()
async updateDonorStatus(
@Args('input') input: DonorStatusInput,
Expand All @@ -54,7 +61,9 @@ export class HealthDirectorateResolver {
}

/* Vaccinations */
@Query(() => [Vaccinations])
@Query(() => [Vaccinations], {
name: 'HealthDirectorateVaccinationsGetVaccinations',
})
@Audit()
getVaccinations(
@Args('locale', { type: () => String, nullable: true })
Expand Down
1 change: 1 addition & 0 deletions libs/auth/scopes/src/lib/api.scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export enum ApiScope {
intellectualProperties = '@island.is/assets/ip',
healthDentists = '@island.is/health/dentists',
healthRightsStatus = '@island.is/health/rights-status',
healthOrganDonation = '@island.is/health/organ-donation',
healthVaccinations = '@island.is/health/vaccinations',
workMachines = '@island.is/work-machines',
vinnueftirlitid = '@island.is/applications/ver',
Expand Down
4 changes: 4 additions & 0 deletions libs/service-portal/core/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1564,4 +1564,8 @@ export const m = defineMessages({
id: 'service.portal:read-more-about',
defaultMessage: 'Lesa meira um {arg}',
},
submit: {
id: 'service.portal:submit',
defaultMessage: 'Staðfesta',
},
})
71 changes: 71 additions & 0 deletions libs/service-portal/health/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,77 @@ export const messages = defineMessages({
id: 'sp.health:medicine-calculator-add-to-purchase-label',
defaultMessage: 'Bæta {arg} við lyfjakaupalista',
},
organDonation: {
id: 'sp.health:organ-donation',
defaultMessage: 'Líffæragjöf',
},
organDonationDescription: {
id: 'sp.health:organ-donation-description',
defaultMessage:
'Íslendingar eru sjálfkrafa skráðir líffæragjafar. Þau sem vilja geta breytt afstöðu sinni.',
},
readAboutOrganDonation: {
id: 'sp.health:read-about-organ-donation',
defaultMessage: 'Lesa um líffæragjöf',
},
takeOnOrganDonation: {
id: 'sp.health:take-on-organ-donation',
defaultMessage: 'Afstaða til líffæragjafar',
},
changeTake: {
id: 'sp.health:change-take',
defaultMessage: 'Breyta afstöðu',
},
organDonationLink: {
id: 'sp.health:organ-donation-link',
defaultMessage: 'https://island.is/liffaeragjof',
},
organRegistrationOtherLabel: {
id: 'sp.health:organ-registration-other-label',
defaultMessage: 'Skrifaðu hér',
},
organRegistrationOtherText: {
id: 'sp.health:organ-registration-other-text',
defaultMessage: 'Vinsamlegast skráðu hvaða líffæri hér',
},
organLimitationsError: {
id: 'sp.health:organ-limitations-error',
defaultMessage:
'Textareitur má ekki vera tómur sé þessi valkostur valinn. ',
},
other: {
id: 'sp.health:other-lower-case',
defaultMessage: 'annað',
},
registrationComplete: {
id: 'sp.health:registration-complete',
defaultMessage: 'Skráning tókst',
},
registrationFailed: {
id: 'sp.health:registration-failed',
defaultMessage: 'Skráning mistókst',
},
iAmOrganDonor: {
id: 'sp.health:i-am-organ-donor',
defaultMessage: 'Ég er líffæragjafi.',
},
iAmNotOrganDonor: {
id: 'sp.health:i-am-not-organ-donor',
defaultMessage: 'Ég banna líffæragjöf.',
},
organDonationRegistrationOptIn: {
id: 'sp.health:organ-donation-registration-opt-in',
defaultMessage: 'Við andlát mitt má nota líffæri mín til líffæragjafa.',
},
organDonationRegistrationException: {
id: 'sp.health:organ-donation-registration-exception',
defaultMessage:
'Ég gef leyfi fyrir líffæragjöf að undanskildum eftirfarandi líffærum:',
},
organDonationRegistrationOptOut: {
id: 'sp.health:organ-donation-registration-opt-out',
defaultMessage: 'Ég banna líffæragjöf.',
},
vaccinations: {
id: 'sp.health:vaccinations',
defaultMessage: 'Bólusetningar',
Expand Down
11 changes: 11 additions & 0 deletions libs/service-portal/health/src/lib/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ export const healthNavigation: PortalNavigationItem = {
},
],
},
{
name: messages.organDonation,
path: HealthPaths.HealthOrganDonation,
children: [
{
name: messages.changeRegistration,
path: HealthPaths.HealthOrganDonationRegistration,
navHide: true,
},
],
},
],
description: m.healthDescription,
}
3 changes: 3 additions & 0 deletions libs/service-portal/health/src/lib/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ export enum HealthPaths {

HealthOverview = '/heilsa/yfirlit',

HealthOrganDonation = '/heilsa/liffaeragjof',
HealthOrganDonationRegistration = '/heilsa/liffaeragjof/skraning',

HealthTherapies = '/heilsa/thjalfun',
HealthTherapiesPhysical = '/heilsa/thjalfun/sjukrathjalfun',
HealthTherapiesSpeech = '/heilsa/thjalfun/talthjalfun',
Expand Down
29 changes: 26 additions & 3 deletions libs/service-portal/health/src/module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,22 @@ const PaymentParticipation = lazy(() =>
)
const PaymentOverview = lazy(() => import('./screens/Payments/PaymentOverview'))

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

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

const VaccinationsGeneral = lazy(() =>
import('./screens/Vaccinations/VaccinationsGeneral'),
)

const VaccinationsOther = lazy(() =>
import('./screens/Vaccinations/VaccinationsOther'),
)

export const healthModule: PortalModule = {
name: 'Heilsa',
enabled: ({ isCompany }) => !isCompany,
Expand Down Expand Up @@ -196,25 +205,39 @@ export const healthModule: PortalModule = {
enabled: userInfo.scopes.includes(ApiScope.healthDentists),
element: <DentistRegistration />,
},
{
name: hm.organDonation,
path: HealthPaths.HealthOrganDonation,
key: 'HealthOrganDonation',
enabled: userInfo.scopes.includes(ApiScope.healthOrganDonation),
element: <OrganDonation />,
},
{
name: hm.organDonation,
path: HealthPaths.HealthOrganDonationRegistration,
key: 'HealthOrganDonation',
enabled: userInfo.scopes.includes(ApiScope.healthOrganDonation),
element: <OrganDonationRegistration />,
},
{
name: hm.vaccinations,
path: HealthPaths.HealthVaccinations,
key: 'HealthVaccinations',
enabled: userInfo.scopes.includes(ApiScope.healthVaccinations), // TODO: Add correct scope
enabled: userInfo.scopes.includes(ApiScope.healthVaccinations),
element: <VaccinationsGeneral />,
},
{
name: hm.generalVaccinations,
path: HealthPaths.HealthVaccinationsGeneral,
key: 'HealthVaccinations',
enabled: userInfo.scopes.includes(ApiScope.healthVaccinations), // TODO: Add correct scope
enabled: userInfo.scopes.includes(ApiScope.healthVaccinations),
element: <VaccinationsGeneral />,
},
{
name: hm.otherVaccinations,
path: HealthPaths.HealthVaccinationsOther,
key: 'HealthVaccinations',
enabled: userInfo.scopes.includes(ApiScope.healthVaccinations), // TODO: Add correct scope
enabled: userInfo.scopes.includes(ApiScope.healthVaccinations),
element: <VaccinationsOther />,
},
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
query getDonorStatus {
HealthDirectorateOrganDonationGetDonorStatus {
isDonor
exceptions
exceptionComment
registrationDate
}
}

query getOrganDonationExceptions($locale: String) {
HealthDirectorateOrganDonationGetDonationExceptions(locale: $locale) {
values {
id
name
}
}
}

mutation updateOrganDonationInfo(
$input: HealthDirectorateOrganDonorStatusInput!
) {
HealthDirectorateOrganDonationUpdateDonorStatus(input: $input)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { useLocale, useNamespaces } from '@island.is/localization'
import {
ActionCard,
IntroHeader,
LinkResolver,
} from '@island.is/service-portal/core'
import { messages as m } from '../../lib/messages'
import { Button, Box, Text } from '@island.is/island-ui/core'
import { HealthPaths } from '../../lib/paths'
import { Problem } from '@island.is/react-spa/shared'
import { useGetDonorStatusQuery } from './OrganDonation.generated'
const OrganDonation = () => {
useNamespaces('sp.health')

const { formatMessage } = useLocale()
const { data, loading, error } = useGetDonorStatusQuery()
const donorStatus = data?.HealthDirectorateOrganDonationGetDonorStatus

const exceptionText: string =
donorStatus?.exceptions?.length && donorStatus.exceptions.length > 0
? [
donorStatus?.exceptionComment,

donorStatus?.exceptions?.join(', '),
].join(':') ?? ''
: donorStatus?.exceptionComment ?? ''
return (
<Box>
<IntroHeader
title={formatMessage(m.organDonation)}
intro={formatMessage(m.organDonationDescription)}
/>
{!error && !loading && donorStatus !== null && (
<>
<Box>
<LinkResolver
href={formatMessage(m.organDonationLink)}
key="organ-donation"
>
<Button
variant="utility"
size="small"
icon="open"
iconType="outline"
>
{formatMessage(m.readAboutOrganDonation)}
</Button>
</LinkResolver>
</Box>
<Box>
<Text
variant="eyebrow"
color="purple400"
marginTop={5}
marginBottom={1}
>
{formatMessage(m.takeOnOrganDonation)}
</Text>
<ActionCard
heading={
donorStatus?.isDonor
? formatMessage(m.iAmOrganDonor)
: formatMessage(m.iAmNotOrganDonor)
}
text={exceptionText}
cta={{
url: HealthPaths.HealthOrganDonationRegistration,
label: formatMessage(m.changeTake),
centered: true,
}}
/>
</Box>
</>
)}
{error && !loading && <Problem error={error} noBorder={false} />}
{!error && !loading && data === null && (
<Problem type="no_data" noBorder={false} />
)}
</Box>
)
}

export default OrganDonation
Loading

0 comments on commit 029b85e

Please sign in to comment.