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,17 @@ 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_RENWAL' = 'NOT_VALID_FOR_RENWAL',
}
disaerna marked this conversation as resolved.
Show resolved Hide resolved

export const generateAidOrNutrition = (
data: AidOrNutritionDTO,
type: AidOrNutritionType,
): AidOrNutrition | null {
): AidOrNutrition | null => {
if (
!data.id ||
!data.iso ||
Expand All @@ -19,6 +26,7 @@ export function generateAidOrNutrition(
) {
return null
}
console.log(data)
disaerna marked this conversation as resolved.
Show resolved Hide resolved
return {
id: data.id,
iso: data.iso,
Expand All @@ -37,5 +45,15 @@ export function generateAidOrNutrition(
available: data.available ?? undefined,
location: data.location ?? undefined,
expiring: data.expiring ? data.expiring : false,
renewalStatus:
data.renewalStatus === 0
? AidOrNutritionRenewalStatus.VALID
: data.renewalStatus === 1
? AidOrNutritionRenewalStatus.VALID_FOR_RENEWAL
: data.renewalStatus === 2
? AidOrNutritionRenewalStatus.RENEWAL_IN_PROGRESS
: data.renewalStatus === 3
? AidOrNutritionRenewalStatus.NOT_VALID_FOR_RENWAL
: undefined,
disaerna marked this conversation as resolved.
Show resolved Hide resolved
}
}
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
}
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,46 @@
}
}
},
"/v1/aidsandnutrition/{iso}/renew": {
"get": {
"tags": ["aidsandnutrition"],
"operationId": "RenewAidOrNutrition",
"parameters": [
{
"name": "iso",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK"
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"type": "string"
}
}
}
},
"404": {
"description": "Not Found"
},
"401": {
"description": "Unauthorized"
},
"500": {
"description": "Internal Server Error"
}
}
}
},
"/v1/application": {
"post": {
"tags": ["application"],
Expand Down Expand Up @@ -2416,13 +2456,7 @@
"components": {
"schemas": {
"Minarsidur.API.Models.AccidentReports.AccidentDTO": {
"required": [
"datetime",
"dateTimeOfDoctorVisit",
"description",
"symptoms",
"type"
],
"required": ["datetime", "description", "type"],
"type": "object",
"properties": {
"type": {
Expand All @@ -2448,7 +2482,8 @@
},
"dateTimeOfDoctorVisit": {
"type": "string",
"format": "date-time"
"format": "date-time",
"nullable": true
},
"fatal": {
"type": "boolean",
Expand Down Expand Up @@ -2611,9 +2646,6 @@
"employer": {
"$ref": "#/components/schemas/Minarsidur.API.Models.AccidentReports.EmployerDTO"
},
"club": {
"$ref": "#/components/schemas/Minarsidur.API.Models.AccidentReports.ClubDTO"
},
"attachments": {
"type": "array",
"items": {
Expand All @@ -2624,25 +2656,6 @@
},
"additionalProperties": false
},
"Minarsidur.API.Models.AccidentReports.ClubDTO": {
"required": ["accidentType", "name", "nationalId"],
"type": "object",
"properties": {
"nationalId": {
"type": "string",
"nullable": true
},
"name": {
"type": "string",
"nullable": true
},
"accidentType": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false
},
"Minarsidur.API.Models.AccidentReports.EmployerDTO": {
"required": [
"companyName",
Expand Down Expand Up @@ -2912,10 +2925,18 @@
"expiring": {
"type": "boolean",
"nullable": true
},
"renewalStatus": {
"$ref": "#/components/schemas/Minarsidur.API.Models.AidsAndNutrition.AidOrNutritionDTO_RenewalStatusEnum"
}
},
"additionalProperties": false
},
"Minarsidur.API.Models.AidsAndNutrition.AidOrNutritionDTO_RenewalStatusEnum": {
"enum": [0, 1, 2, 3],
"type": "integer",
"format": "int32"
},
"Minarsidur.API.Models.AidsAndNutrition.AidOrNutritionRefundDTO": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -4134,6 +4155,10 @@
"type": "string",
"nullable": true
},
"canRegister": {
"type": "boolean",
"nullable": true
},
"waitlistRegistration": {
"type": "boolean",
"nullable": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export {
MinarsidurAPIModelsAccidentReportsInjuredDTO,
MinarsidurAPIModelsAccidentReportsAccidentDTO,
MinarsidurAPIModelsAccidentReportsEmployerDTO,
MinarsidurAPIModelsAccidentReportsClubDTO,
MinarsidurAPIModelsAccidentReportsAccidentReportAttachmentDTO,
MinarsidurAPIModelsAccidentReportsAccidentDTOAccidentLocationEnum,
MinarsidurAPIModelsAccidentReportsAccidentDTOAccidentAtSailorWorkDTOAccidentAtSailorWorkShipLocationEnum,
Expand Down
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_RENWAL
? formatMessage(messages.notValidForRenewal)
disaerna marked this conversation as resolved.
Show resolved Hide resolved
: '',
},
]}
>
<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
Expand Up @@ -14,6 +14,7 @@ import {
Divider,
SkeletonLoader,
Stack,
Text,
disaerna marked this conversation as resolved.
Show resolved Hide resolved
} from '@island.is/island-ui/core'
import { messages } from '../../lib/messages'
import HistoryTable from './HistoryTable'
Expand Down Expand Up @@ -46,6 +47,7 @@ const HealthCenter = () => {
const healthCenterData = data?.rightsPortalHealthCenterRegistrationHistory

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

if (loading)
return (
Expand Down Expand Up @@ -120,6 +122,15 @@ const HealthCenter = () => {
}
/>
<Divider />
{neighborhoodCenter && (
<>
<UserInfoLine
label={formatMessage(messages.neighborhoodHealthCenter)}
content={neighborhoodCenter}
/>
<Divider />
</>
)}
</Stack>
</Box>
)}
Expand Down
Loading