diff --git a/libs/application/templates/accident-notification/src/fields/FormOverview/index.tsx b/libs/application/templates/accident-notification/src/fields/FormOverview/index.tsx index 227054aae80e..7c79991fe36f 100644 --- a/libs/application/templates/accident-notification/src/fields/FormOverview/index.tsx +++ b/libs/application/templates/accident-notification/src/fields/FormOverview/index.tsx @@ -507,30 +507,10 @@ export const FormOverview: FC< changeScreens('timePassedHindrance')} + editAction={() => changeScreens('sportsClubInfo.employee.field')} isEditable={application.state === States.DRAFT} > - - - - - - {isProfessionalAthleteAccident(answers as FormValue) && ( + + + {missingDocuments.length !== 0 && ( diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection.ts index 9854c19b910b..ccf45395f1b9 100644 --- a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection.ts +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/aboutTheAccidentSection.ts @@ -20,7 +20,6 @@ import { fatalAccident, fatalAccidentAttachment, fishingCompanyInfo, - hindrances, injuredPersonInformation, locationAndPurpose, rescueSquadInfo, @@ -48,6 +47,7 @@ import { getAccidentTypeOptions, hideLocationAndPurpose, isAgricultureAccident, + isDateOlderThanAYear, isFatalAccident, isFishermanAccident, isGeneralWorkplaceAccident, @@ -57,74 +57,19 @@ import { isProfessionalAthleteAccident, isReportingOnBehalfOfEmployee, isReportingOnBehalfOfInjured, + isReportingOnBehalfSelf, isRepresentativeOfCompanyOrInstitute, isRescueWorkAccident, isStudiesAccident, isWorkAccident, } from '../../utils' import { isHealthInsured } from '../../utils/isHealthInsured' +import { isSportAccidentAndEmployee } from '../../utils/isSportAccidentAndEmployee' export const aboutTheAccidentSection = buildSection({ id: 'accidentType.section', title: accidentType.general.sectionTitle, children: [ - buildSubSection({ - id: 'hindrances', - title: hindrances.general.sectionTitle, - children: [ - buildMultiField({ - id: 'timePassedHindrancesMultiField', - title: hindrances.timePassedHindrance.radioFieldTitle, - children: [ - buildRadioField({ - id: 'timePassedHindrance', - title: '', - options: [ - { value: YES, label: application.general.yesOptionLabel }, - { value: NO, label: application.general.noOptionLabel }, - ], - width: 'half', - largeButtons: true, - required: true, - }), - buildAlertMessageField({ - id: 'timePassedHindranceFielAlertMessage', - title: hindrances.timePassedHindrance.errorTitle, - message: hindrances.timePassedHindrance.errorDescription, - alertType: 'info', - doesNotRequireAnswer: true, - condition: (formValue) => formValue.timePassedHindrance === YES, - }), - ], - }), - buildMultiField({ - id: 'carHindrancesMultiField', - title: hindrances.carAccident.radioFieldTitle, - children: [ - buildRadioField({ - title: '', - id: 'carAccidentHindrance', - options: [ - { value: YES, label: application.general.yesOptionLabel }, - { value: NO, label: application.general.noOptionLabel }, - ], - width: 'half', - largeButtons: true, - required: true, - }), - buildAlertMessageField({ - id: 'carAccidentHindranceFielAlertMessage', - title: hindrances.carAccident.errorTitle, - message: hindrances.carAccident.errorDescription, - alertType: 'info', - doesNotRequireAnswer: true, - condition: (formValue) => formValue.carAccidentHindrance === YES, - }), - ], - }), - ], - }), - buildSubSection({ id: 'accidentType.section', title: accidentType.general.subsectionTitle, @@ -181,6 +126,23 @@ export const aboutTheAccidentSection = buildSection({ condition: (formValue) => isAgricultureAccident(formValue), marginBottom: 5, }), + buildDescriptionField({ + id: 'accidentDetails.descriptionField', + space: 'containerGutter', + title: injuredPersonInformation.general.jobTitle, + description: injuredPersonInformation.general.jobTitleDescription, + width: 'full', + marginBottom: 2, + condition: (formValue) => isReportingOnBehalfSelf(formValue), + }), + buildTextField({ + id: 'injuredPersonInformation.jobTitle', + title: injuredPersonInformation.labels.jobTitle, + backgroundColor: 'white', + width: 'full', + maxLength: 100, + condition: (formValue) => isReportingOnBehalfSelf(formValue), + }), ], }), ], @@ -242,6 +204,14 @@ export const aboutTheAccidentSection = buildSection({ }, ], }), + buildAlertMessageField({ + id: 'attachments.injuryCertificate.alert', + title: application.labels.warningTitle, + message: application.labels.warningMessage, + alertType: 'info', + doesNotRequireAnswer: true, + condition: (formValue) => isSportAccidentAndEmployee(formValue), + }), ], }), @@ -293,7 +263,9 @@ export const aboutTheAccidentSection = buildSection({ id: 'accidentLocation.generalWorkAccident', title: accidentLocation.general.heading, description: accidentLocation.general.description, - condition: (formValue) => isGeneralWorkplaceAccident(formValue), + condition: (formValue) => + isGeneralWorkplaceAccident(formValue) || + isSportAccidentAndEmployee(formValue), children: [ buildRadioField({ id: 'accidentLocation.answer', @@ -405,7 +377,9 @@ export const aboutTheAccidentSection = buildSection({ id: 'accidentLocation.professionalAthleteAccident', title: accidentLocation.general.heading, description: accidentLocation.general.description, - condition: (formValue) => isProfessionalAthleteAccident(formValue), + condition: (formValue) => + isProfessionalAthleteAccident(formValue) && + !isSportAccidentAndEmployee(formValue), children: [ buildRadioField({ id: 'accidentLocation.answer', @@ -518,7 +492,8 @@ export const aboutTheAccidentSection = buildSection({ title: workMachine.general.sectionTitle, condition: (formValue) => isGeneralWorkplaceAccident(formValue) || - isAgricultureAccident(formValue), + isAgricultureAccident(formValue) || + isSportAccidentAndEmployee(formValue), children: [ buildMultiField({ id: 'workMachine', @@ -582,6 +557,15 @@ export const aboutTheAccidentSection = buildSection({ width: 'half', format: '##:##', }), + buildAlertMessageField({ + id: 'accidentDetails.moreThanAYearAlertMessage', + title: accidentDetails.general.moreThanAYearAlertTitle, + message: accidentDetails.general.moreThanAYearAlertMessage, + width: 'full', + alertType: 'warning', + condition: (formValue) => isDateOlderThanAYear(formValue), + marginBottom: 0, + }), buildAlertMessageField({ id: 'accidentDetails.notHealthInsuredAlertMessage', title: accidentDetails.general.insuranceAlertTitle, @@ -601,6 +585,37 @@ export const aboutTheAccidentSection = buildSection({ variant: 'textarea', maxLength: 2000, }), + buildTextField({ + id: 'accidentDetails.accidentSymptoms', + title: accidentDetails.labels.symptoms, + placeholder: accidentDetails.placeholder.symptoms, + backgroundColor: 'blue', + required: true, + rows: 10, + variant: 'textarea', + maxLength: 2000, + }), + buildDescriptionField({ + id: 'accidentDetails.descriptionField', + space: 'containerGutter', + titleVariant: 'h5', + title: accidentDetails.labels.doctorVisit, + width: 'full', + }), + buildCustomField({ + id: 'accidentDetails.dateOfDoctorVisit', + title: accidentDetails.labels.date, + component: 'DateOfAccident', + width: 'half', + }), + buildTextField({ + id: 'accidentDetails.timeOfDoctorVisit', + title: accidentDetails.labels.time, + placeholder: accidentDetails.placeholder.doctorVisitTime, + backgroundColor: 'blue', + width: 'half', + format: '##:##', + }), ], }), ], diff --git a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection.ts b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection.ts index 99ce888b0dba..43b91fcd3f80 100644 --- a/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection.ts +++ b/libs/application/templates/accident-notification/src/forms/AccidentNotificationForm/whoIsTheNotificationForSection.ts @@ -2,6 +2,7 @@ import { buildAlertMessageField, buildCheckboxField, buildCustomField, + buildDescriptionField, buildFileUploadField, buildMultiField, buildRadioField, @@ -110,6 +111,21 @@ export const whoIsTheNotificationForSection = buildSection({ width: 'half', variant: 'tel', }), + buildDescriptionField({ + id: 'accidentDetails.descriptionField', + space: 'containerGutter', + title: injuredPersonInformation.general.jobTitle, + description: injuredPersonInformation.general.jobTitleDescription, + width: 'full', + marginBottom: 2, + }), + buildTextField({ + id: 'injuredPersonInformation.jobTitle', + title: injuredPersonInformation.labels.jobTitle, + backgroundColor: 'white', + width: 'full', + maxLength: 100, + }), ], }), ], diff --git a/libs/application/templates/accident-notification/src/lib/dataSchema.ts b/libs/application/templates/accident-notification/src/lib/dataSchema.ts index f693411a8804..8777b3490c13 100644 --- a/libs/application/templates/accident-notification/src/lib/dataSchema.ts +++ b/libs/application/templates/accident-notification/src/lib/dataSchema.ts @@ -163,6 +163,9 @@ export const AccidentNotificationSchema = z.object({ descriptionOfAccident: z.string().refine((x) => x.trim().length > 0, { params: error.invalidValue, }), + accidentSymptoms: z.string().refine((x) => x.trim().length > 0, { + params: error.invalidValue, + }), }), isRepresentativeOfCompanyOrInstitue: z.array(z.string()).optional(), fishingShipInfo: z.object({ diff --git a/libs/application/templates/accident-notification/src/lib/messages/accidentDetails.ts b/libs/application/templates/accident-notification/src/lib/messages/accidentDetails.ts index eeae9b183a56..cd4dc411ef60 100644 --- a/libs/application/templates/accident-notification/src/lib/messages/accidentDetails.ts +++ b/libs/application/templates/accident-notification/src/lib/messages/accidentDetails.ts @@ -26,6 +26,18 @@ export const accidentDetails = { description: 'According to electronic information from the Director of Internal Revenue, you do not appear to have filled in the appropriate field on your tax return and are therefore not insured against household related accidents during the period in which the accident took place.', }, + moreThanAYearAlertTitle: { + id: 'an.application:accidentDetails.general.moreThanAYearAlertTitle', + defaultMessage: 'Athugið', + description: 'Alert', + }, + moreThanAYearAlertMessage: { + id: 'an.application:accidentDetails.general.moreThanAYearAlertMessage', + defaultMessage: + 'Öll slys skal að jafnaði tilkynna innan eins árs, en heimilt er að veita undanþágu frá þeirri reglu, að ákveðnum forsendum uppfylltum.', + description: + 'The accident took place more than a year ago. It is necessary to contact the Insurance Fund for further instructions.', + }, }), labels: defineMessages({ date: { @@ -43,6 +55,16 @@ export const accidentDetails = { defaultMessage: 'Ýtarleg lýsing á slysi', description: 'Description of accident', }, + symptoms: { + id: 'an.application:accidentDetails.labels.symptoms', + defaultMessage: 'Lýsing á einkennum og afleiðingum slyss', + description: 'Accident symptoms', + }, + doctorVisit: { + id: 'an.application:accidentDetails.labels.doctorVisit', + defaultMessage: 'Hvenær leitaðir þú fyrst til læknis?', + description: 'When did you first visit a doctor after the accident?', + }, }), placeholder: defineMessages({ date: { @@ -61,5 +83,15 @@ export const accidentDetails = { description: 'Write here the outline, cause and circumstances of the accident', }, + symptoms: { + id: 'an.application:accidentDetails.placeholder.symptoms', + defaultMessage: 'Skrifaðu hér einkenni og afleiðingar slyssins', + description: 'Write here the symptoms and consequences of the accident', + }, + doctorVisitTime: { + id: 'an.application:accidentDetails.placeholder.doctorVisit', + defaultMessage: 'Sláðu inn tíma heimsóknar', + description: 'Enter the time of the visit', + }, }), } diff --git a/libs/application/templates/accident-notification/src/lib/messages/application.ts b/libs/application/templates/accident-notification/src/lib/messages/application.ts index 9fbbe85322da..d2777fd04c62 100644 --- a/libs/application/templates/accident-notification/src/lib/messages/application.ts +++ b/libs/application/templates/accident-notification/src/lib/messages/application.ts @@ -4,7 +4,7 @@ export const application = { general: defineMessages({ name: { id: 'an.application:general.name', - defaultMessage: 'Slysatilkynning til Sjúkratryggingar Íslands ', + defaultMessage: 'Slysatilkynning til Sjúkratrygginga Íslands ', description: 'Accident notification to Sjúkratryggingar Íslands', }, institutionName: { @@ -30,4 +30,17 @@ export const application = { description: 'Delivery of data', }, }), + labels: defineMessages({ + warningTitle: { + id: 'an.application:application.warningTitle', + defaultMessage: 'Athugið', + description: 'Warning', + }, + warningMessage: { + id: 'an.application:application.warningDescription', + defaultMessage: + 'Ef hinn slasaði þiggur greiðslur frá íþróttafélaginu þá er málið meðhöndlað sem vinnuslys.', + description: 'Warning description', + }, + }), } diff --git a/libs/application/templates/accident-notification/src/lib/messages/injuredPersonInformation.ts b/libs/application/templates/accident-notification/src/lib/messages/injuredPersonInformation.ts index 140bd3be3b75..c2253673c238 100644 --- a/libs/application/templates/accident-notification/src/lib/messages/injuredPersonInformation.ts +++ b/libs/application/templates/accident-notification/src/lib/messages/injuredPersonInformation.ts @@ -25,6 +25,17 @@ export const injuredPersonInformation = { description: 'Description label for injured person information section when submitting for juridical person.', }, + jobTitle: { + id: 'an.application:injuredPersonInformation.general.jobTitle', + defaultMessage: 'Starfsheiti', + description: 'Job title', + }, + jobTitleDescription: { + id: 'an.application:injuredPersonInformation.general.jobTitleDescription', + defaultMessage: + 'Sláðu inn starfsheiti þess slasaða þegar slysið átti sér stað.', + description: 'Description for job title', + }, }), labels: defineMessages({ name: { @@ -47,6 +58,11 @@ export const injuredPersonInformation = { defaultMessage: 'Símanúmer', description: 'Telephone number', }, + jobTitle: { + id: 'an.application:injuredPersonInformation.labels.jobTitle', + defaultMessage: 'Starfsheiti', + description: 'Job title', + }, }), upload: defineMessages({ uploadHeader: { diff --git a/libs/application/templates/accident-notification/src/utils/isSportAccidentAndEmployee.spec.ts b/libs/application/templates/accident-notification/src/utils/isSportAccidentAndEmployee.spec.ts new file mode 100644 index 000000000000..a095aa9370ef --- /dev/null +++ b/libs/application/templates/accident-notification/src/utils/isSportAccidentAndEmployee.spec.ts @@ -0,0 +1,34 @@ +import { FormValue } from '@island.is/application/types' +import { AccidentTypeEnum, WorkAccidentTypeEnum } from '../types' +import exp from 'constants' +import { isSportAccidentAndEmployee } from './isSportAccidentAndEmployee' +import { accidentType } from '../lib/messages' + +describe('isSportAccidentAndEmployee', () => { + const sportAccidentRadio: FormValue = { + accidentType: { radioButton: AccidentTypeEnum.SPORTS }, + onPayRoll: { answer: 'yes' }, + } + + const someOtherAccident: FormValue = { + workAccident: { type: AccidentTypeEnum.HOMEACTIVITIES }, + onPayRoll: { answer: 'yes' }, + } + + const notOnPayroll: FormValue = { + accidentType: { radioButton: AccidentTypeEnum.SPORTS }, + onPayRoll: { answer: 'no' }, + } + + it('should return true for sport accidents where the person is also an employee of the sports club', () => { + expect(isSportAccidentAndEmployee(sportAccidentRadio)).toEqual(true) + }) + + it('should return false for other accidents', () => { + expect(isSportAccidentAndEmployee(someOtherAccident)).toEqual(false) + }) + + it('should return false if the person is not on payroll', () => { + expect(isSportAccidentAndEmployee(notOnPayroll)).toEqual(false) + }) +}) diff --git a/libs/application/templates/accident-notification/src/utils/isSportAccidentAndEmployee.ts b/libs/application/templates/accident-notification/src/utils/isSportAccidentAndEmployee.ts new file mode 100644 index 000000000000..e214ce3c414f --- /dev/null +++ b/libs/application/templates/accident-notification/src/utils/isSportAccidentAndEmployee.ts @@ -0,0 +1,19 @@ +import { Answer, FormValue } from '@island.is/application/types' +import { AccidentTypeEnum, YesOrNo } from '../types' +import { getValueViaPath } from '@island.is/application/core' + +// When a person is hurt in a sports accident and is an employee of the sport, the accident +// is considered a work accident. This function checks if both conditions are met. +export const isSportAccidentAndEmployee = (formValue: FormValue): boolean => { + const workAccidentType = getValueViaPath( + formValue, + 'accidentType.radioButton', + ) as AccidentTypeEnum + const onPayRoll = getValueViaPath(formValue, 'onPayRoll.answer') as YesOrNo + + if (workAccidentType === AccidentTypeEnum.SPORTS && onPayRoll === 'yes') { + return true + } + + return false +}