Skip to content
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

feat(my-pages): Health center changes #16637

Merged
merged 11 commits into from
Nov 22, 2024
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { Field, ID, ObjectType, registerEnumType } from '@nestjs/graphql'
import { AidOrNutritionType } from '../utils/generateAidOrNutrition'
import {
AidOrNutritionRenewalStatus,
AidOrNutritionType,
} from '../utils/generateAidOrNutrition'
import { PaginatedResponse } from '@island.is/nest/pagination'
import { Refund } from './aidOrNutritionRefund.model'

registerEnumType(AidOrNutritionRenewalStatus, {
name: 'RightsPortalAidOrNutritionRenewalStatus',
})

registerEnumType(AidOrNutritionType, {
name: 'RightsPortalAidOrNutritionType',
})
Expand Down Expand Up @@ -50,6 +57,9 @@ export class AidOrNutrition {

@Field()
expiring!: boolean

@Field(() => AidOrNutritionRenewalStatus, { nullable: true })
renewalStatus?: AidOrNutritionRenewalStatus
disaerna marked this conversation as resolved.
Show resolved Hide resolved
}

@ObjectType('RightsPortalPaginatedAidsOrNutrition')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,24 @@ export enum AidOrNutritionType {
NUTRITION,
}

export function generateAidOrNutrition(
export enum AidOrNutritionRenewalStatus {
'VALID' = 'VALID',
'VALID_FOR_RENEWAL' = 'VALID_FOR_RENEWAL',
'RENEWAL_IN_PROGRESS' = 'RENEWAL_IN_PROGRESS',
'NOT_VALID_FOR_RENEWAL' = 'NOT_VALID_FOR_RENEWAL',
}

const RENEWAL_STATUS_MAP = {
0: AidOrNutritionRenewalStatus.VALID,
1: AidOrNutritionRenewalStatus.VALID_FOR_RENEWAL,
2: AidOrNutritionRenewalStatus.RENEWAL_IN_PROGRESS,
3: AidOrNutritionRenewalStatus.NOT_VALID_FOR_RENEWAL,
} as const

export const generateAidOrNutrition = (
data: AidOrNutritionDTO,
type: AidOrNutritionType,
): AidOrNutrition | null {
): AidOrNutrition | null => {
if (
!data.id ||
!data.iso ||
Expand Down Expand Up @@ -37,5 +51,11 @@ export function generateAidOrNutrition(
available: data.available ?? undefined,
location: data.location ?? undefined,
expiring: data.expiring ? data.expiring : false,
renewalStatus:
data.renewalStatus !== undefined
? RENEWAL_STATUS_MAP[
data.renewalStatus as keyof typeof RENEWAL_STATUS_MAP
]
: undefined,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export class HealthCenterService {
healthCenterName: healthCenterRes.healthCenter ?? undefined,
},
history,
neighborhoodCenter: healthCenterRes.neighborhoodCenter ?? undefined,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export class HealthCenter {

@Field(() => Boolean, { nullable: true })
waitListRegistration?: boolean | null

@Field(() => Boolean, { nullable: true })
canRegister?: boolean | null
}

@ObjectType('RightsPortalPaginatedHealthCenters')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ export class HealthCenterRegistrationHistory {

@Field(() => Boolean, { nullable: true })
canRegister?: boolean

@Field({ nullable: true })
neighborhoodCenter?: string
}
40 changes: 39 additions & 1 deletion libs/portals/my-pages/health/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,31 @@ export const messages = defineMessages({
id: 'sp.health:repaid',
defaultMessage: 'Endurgreitt',
},
renewal: {
id: 'sp.health:renewal',
defaultMessage: 'Endurnýjun',
},
valid: {
id: 'sp.health:valid',
defaultMessage: 'Í gildi',
},
validForRenewal: {
id: 'sp.health:valid-for-renewal',
defaultMessage: 'Endurnýja',
},
renewalInProgress: {
id: 'sp.health:renewal-in-progress',
defaultMessage: 'Endurnýjun í gangi',
},
notValidForRenewal: {
id: 'sp.health:not-valid-for-renewal',
defaultMessage: 'Ekki hægt',
},
notValidForRenewalDetail: {
id: 'sp.health:not-valid-for-renewal-detail',
defaultMessage:
'Sjálfvirk endurnýjun er ekki í boði fyrir þetta hjálpartæki.',
},
monthlyBreakdownOfInvoices: {
id: 'sp.health:monthly-breakdown-of-invoices',
defaultMessage: 'Sundurliðun reikninga í völdum mánuði',
Expand Down Expand Up @@ -210,6 +235,15 @@ export const messages = defineMessages({
id: 'sp.health:no-health-insurance-message',
defaultMessage: 'Síðasta trygging: {arg}',
},
healthCenterNotAvailableForRegistration: {
id: 'sp.health:health-center-not-available-for-registration',
defaultMessage: 'Ekki hægt',
},
healthCenterNotAvailableForRegistrationDesc: {
id: 'sp.health:health-center-not-available-for-registration-desc',
defaultMessage:
'Þessi heilsugæslustöð er með lokað fyrir skráningar utan hverfis.',
},
paymentTarget: {
id: 'sp.health:payment-target',
defaultMessage: 'Greiðslumark',
Expand Down Expand Up @@ -300,7 +334,7 @@ export const messages = defineMessages({
},
healthCenterTitle: {
id: 'sp.health:health-center-title',
defaultMessage: 'Heilsugæsla',
defaultMessage: 'Skráð heilsugæsla',
},
healthCenterDescription: {
id: 'sp.health:health-center-intro',
Expand Down Expand Up @@ -612,6 +646,10 @@ export const messages = defineMessages({
id: 'sp.health:personal-doctor',
defaultMessage: 'Heimilslæknir',
},
neighborhoodHealthCenter: {
id: 'sp.health:neighborhood-health-center',
defaultMessage: 'Hverfisheilsugæsla',
},
doctor: {
id: 'sp.health:doctor',
defaultMessage: 'Læknir',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { RightsPortalAidOrNutrition } from '@island.is/api/schema'
import {
RightsPortalAidOrNutrition,
RightsPortalAidOrNutritionRenewalStatus,
} from '@island.is/api/schema'
import { useLocale, useNamespaces } from '@island.is/localization'
import {
DownloadFileButtons,
Expand Down Expand Up @@ -71,7 +74,7 @@ const Aids = ({ data }: Props) => {
{ value: formatMessage(messages.insuranceRatio) },
{ value: formatMessage(messages.availableRefund) },
{ value: formatMessage(messages.nextAvailableRefund) },
{ value: '' },
{ value: formatMessage(messages.renewal) },
]}
/>
<T.Body>
Expand Down Expand Up @@ -100,6 +103,22 @@ const Aids = ({ data }: Props) => {
{
value: rowItem.expiring ? expiringIcon : '',
},
{
value:
rowItem.renewalStatus ===
RightsPortalAidOrNutritionRenewalStatus.VALID
? formatMessage(messages.valid)
: rowItem.renewalStatus ===
RightsPortalAidOrNutritionRenewalStatus.VALID_FOR_RENEWAL
? formatMessage(messages.validForRenewal)
: rowItem.renewalStatus ===
RightsPortalAidOrNutritionRenewalStatus.RENEWAL_IN_PROGRESS
? formatMessage(messages.renewalInProgress)
: rowItem.renewalStatus ===
RightsPortalAidOrNutritionRenewalStatus.NOT_VALID_FOR_RENEWAL
? formatMessage(messages.notValidForRenewal)
: '',
},
]}
>
<NestedTable data={generateFoldedValues(rowItem)} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ query getHealthCenter($input: RightsPortalHealthCenterHistoryInput) {
doctor
}
canRegister
neighborhoodCenter
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import { useLocale, useNamespaces } from '@island.is/localization'
import {
EmptyState,
UserInfoLine,
IntroHeader,
CardLoader,
SJUKRATRYGGINGAR_SLUG,
} from '@island.is/portals/my-pages/core'
import { useLocation } from 'react-router-dom'
import { useGetHealthCenterQuery } from './HealthCenter.generated'
import {
AlertMessage,
Box,
Divider,
SkeletonLoader,
Stack,
} from '@island.is/island-ui/core'
import { messages } from '../../lib/messages'
import HistoryTable from './HistoryTable'
import { useLocale, useNamespaces } from '@island.is/localization'
import {
CardLoader,
EmptyState,
IntroWrapper,
SJUKRATRYGGINGAR_SLUG,
UserInfoLine,
} from '@island.is/portals/my-pages/core'
import { Problem } from '@island.is/react-spa/shared'
import subYears from 'date-fns/subYears'
import { useLocation } from 'react-router-dom'
import { messages as hm, messages } from '../../lib/messages'
import { HealthPaths } from '../../lib/paths'
import { messages as hm } from '../../lib/messages'
import { Problem } from '@island.is/react-spa/shared'
import { useGetHealthCenterQuery } from './HealthCenter.generated'
import HistoryTable from './HistoryTable'

const DEFAULT_DATE_TO = new Date()
const DEFAULT_DATE_FROM = subYears(DEFAULT_DATE_TO, 10)
Expand All @@ -46,6 +45,7 @@ const HealthCenter = () => {
const healthCenterData = data?.rightsPortalHealthCenterRegistrationHistory

const canRegister = healthCenterData?.canRegister ?? false
const neighborhoodCenter = healthCenterData?.neighborhoodCenter ?? null

if (loading)
return (
Expand All @@ -62,14 +62,13 @@ const HealthCenter = () => {
}

return (
<Box marginBottom={[6, 6, 10]}>
<IntroHeader
title={formatMessage(messages.healthCenterTitle)}
intro={formatMessage(messages.healthCenterDescription)}
serviceProviderSlug={SJUKRATRYGGINGAR_SLUG}
serviceProviderTooltip={formatMessage(messages.healthTooltip)}
/>

<IntroWrapper
marginBottom={[6, 6, 10]}
title={formatMessage(messages.healthCenterTitle)}
intro={formatMessage(messages.healthCenterDescription)}
serviceProviderSlug={SJUKRATRYGGINGAR_SLUG}
serviceProviderTooltip={formatMessage(messages.healthTooltip)}
>
{wasSuccessfulTransfer && !loading && (
<Box width="full" marginTop={4}>
<AlertMessage
Expand Down Expand Up @@ -120,6 +119,15 @@ const HealthCenter = () => {
}
/>
<Divider />
{neighborhoodCenter && (
<>
<UserInfoLine
label={formatMessage(messages.neighborhoodHealthCenter)}
content={neighborhoodCenter}
/>
<Divider />
</>
)}
</Stack>
</Box>
)}
Expand All @@ -129,7 +137,7 @@ const HealthCenter = () => {
{!loading && !error && healthCenterData?.history?.length ? (
<HistoryTable history={healthCenterData.history} />
) : null}
</Box>
</IntroWrapper>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ const HistoryTable = ({ history }: Props) => {
<T.Head>
<T.Row>
<T.HeadData>
<Text variant="medium" fontWeight="medium">
<Text variant="medium" fontWeight="semiBold">
{formatMessage(messages.from)}
</Text>
</T.HeadData>
<T.HeadData>
<Text variant="medium" fontWeight="medium">
<Text variant="medium" fontWeight="semiBold">
{formatMessage(messages.to)}
</Text>
</T.HeadData>
<T.HeadData>
<Text variant="medium" fontWeight="medium">
<Text variant="medium" fontWeight="semiBold">
{formatMessage(m.healthCenter)}
</Text>
</T.HeadData>
<T.HeadData>
<Text variant="medium" fontWeight="medium">
<Text variant="medium" fontWeight="semiBold">
{formatMessage(messages.doctor)}
</Text>
</T.HeadData>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ query getHealthCenter {
municipality
streetAddress
}
canRegister
}
totalCount
}
Expand Down
Loading
Loading