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(accident-notification): connect new api for accident-notification #15420

Merged
merged 28 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8541e4c
feat: connect new api for accident-notification
jonnigs Jun 28, 2024
f972698
feat: map and send attachments to new api
jonnigs Jul 2, 2024
ff47133
chore: remove unused code
jonnigs Jul 2, 2024
7494f1e
feat: codegen for api changes and fix dataSchema
jonnigs Sep 26, 2024
508c5d8
Merge branch 'main' into feat/new-accident-notification-client
jonnigs Oct 1, 2024
55939e2
chore: nx format:write update dirty files
andes-it Oct 1, 2024
237adec
fix: remove test
jonnigs Oct 1, 2024
e027617
chore: nx format:write update dirty files
andes-it Oct 1, 2024
8f213d1
fix: add null test to pass build
jonnigs Oct 1, 2024
bf8deed
chore: lint
jonnigs Oct 1, 2024
36cac5e
fix: Coderabbit comments
jonnigs Oct 2, 2024
6c8fdb9
Merge branch 'main' into feat/new-accident-notification-client
jonnigs Oct 2, 2024
4705a3f
feat: connect review application and addAditionalAttachment
jonnigs Oct 3, 2024
c1f68af
fix: pr comments and add test back in
jonnigs Oct 3, 2024
ed9016d
chore: use switch instead of if
jonnigs Oct 3, 2024
9b9a6a7
fix: getReportId
jonnigs Oct 3, 2024
00e3116
fix: codegen backend schema
jonnigs Oct 3, 2024
86d95a6
chore: consistent early return
jonnigs Oct 3, 2024
edc5cec
chore: simplify accidentTypeDTO
jonnigs Oct 3, 2024
019e133
fix: lint
jonnigs Oct 3, 2024
1438de9
feat: connect getAccidentReportStatus
jonnigs Oct 7, 2024
97886bc
feat: add auth to getAccidentNotificationStatus
jonnigs Oct 7, 2024
203d0eb
fix: import
jonnigs Oct 7, 2024
dd1f66b
chore: add test back in
jonnigs Oct 7, 2024
07221d7
fix: test
jonnigs Oct 8, 2024
9c62f14
chore: remove console.log
jonnigs Oct 8, 2024
eceb7b4
Merge branch 'main' into feat/new-accident-notification-client
kodiakhq[bot] Oct 9, 2024
0cc442c
Merge branch 'main' into feat/new-accident-notification-client
kodiakhq[bot] Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/application-system/api/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { DataProtectionComplaintClientConfig } from '@island.is/clients/data-pro
import { CriminalRecordClientConfig } from '@island.is/clients/criminal-record'
import { HealthInsuranceV2ClientConfig } from '@island.is/clients/icelandic-health-insurance/health-insurance'
import { VmstClientConfig } from '@island.is/clients/vmst'
import { RightsPortalClientConfig } from '@island.is/clients/icelandic-health-insurance/rights-portal'
import { FriggClientConfig } from '@island.is/clients/mms/frigg'
import { smsModuleConfig } from '@island.is/nova-sms'
import { emailModuleConfig } from '@island.is/email-service'
Expand Down Expand Up @@ -112,6 +113,7 @@ import { emailModuleConfig } from '@island.is/email-service'
CriminalRecordClientConfig,
HealthInsuranceV2ClientConfig,
VmstClientConfig,
RightsPortalClientConfig,
FriggClientConfig,
smsModuleConfig,
emailModuleConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export class ApplicationService {
to: input.to,
})
}

async create(input: CreateApplicationInput, auth: Auth) {
return this.applicationApiWithAuth(auth).applicationControllerCreate({
createApplicationDto: input,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Inject, Injectable } from '@nestjs/common'
import { LOGGER_PROVIDER } from '@island.is/logging'
import type { Logger } from '@island.is/logging'
import { DocumentApi } from '@island.is/clients/icelandic-health-insurance/health-insurance'
import {
HealthInsuranceAccidentNotificationAttachmentTypes as AttachmentTypes,
HealthInsuranceAccidentNotificationConfirmationTypes as ConfirmationTypes,
Expand All @@ -12,6 +11,8 @@ import {
AccidentNotificationConfirmation,
AccidentNotificationStatus,
} from './graphql/models'
import { AccidentreportsApi } from '@island.is/clients/icelandic-health-insurance/rights-portal'
import { Auth, AuthMiddleware } from '@island.is/auth-nest-tools'

const mapStatus = (statusId: number) => {
switch (statusId) {
Expand Down Expand Up @@ -55,34 +56,42 @@ const mapConfirmationType = (confirmationTypeId: number | undefined) => {
@Injectable()
export class AccidentNotificationService {
constructor(
private readonly accidentNotificationApi: DocumentApi,
private readonly accidentReportsApi: AccidentreportsApi,
@Inject(LOGGER_PROVIDER)
private logger: Logger,
) {}

private accidentsReportsApiWithAuth(auth: Auth) {
return this.accidentReportsApi.withMiddleware(new AuthMiddleware(auth))
}
jonnigs marked this conversation as resolved.
Show resolved Hide resolved

async getAccidentNotificationStatus(
auth: Auth,
ihiDocumentID: number,
): Promise<AccidentNotificationStatus | null> {
this.logger.log('starting call to get accident', ihiDocumentID)
const accidentStatus =
await this.accidentNotificationApi.documentGetAccidentStatus({
ihiDocumentID: ihiDocumentID,
})

const accidentStatus = await this.accidentsReportsApiWithAuth(
auth,
).getAccidentReportStatus({
reportId: ihiDocumentID,
})

if (!accidentStatus) return null
return {
numberIHI: accidentStatus.numberIHI,
numberIHI: accidentStatus.requestId,
jonnigs marked this conversation as resolved.
Show resolved Hide resolved
status: accidentStatus.status ? mapStatus(accidentStatus.status) : '',
receivedAttachments: accidentStatus.attachments
?.map((x) => ({
[mapAttachmentType(x.attachmentType)]: !!x.isReceived,
[mapAttachmentType(x.type)]: !!x.received,
}))
.reduce(
(prev, curr) => ({ ...prev, ...curr }),
jonnigs marked this conversation as resolved.
Show resolved Hide resolved
{},
) as AccidentNotificationAttachment,
jonnigs marked this conversation as resolved.
Show resolved Hide resolved
receivedConfirmations: accidentStatus.confirmations
?.map((x) => ({
[mapConfirmationType(x.confirmationType)]: !!x.isReceived,
[mapConfirmationType(x.party)]: !!x.received,
}))
.reduce(
(prev, curr) => ({ ...prev, ...curr }),
jonnigs marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { Inject, UseGuards } from '@nestjs/common'
import { Args, Query, Resolver } from '@nestjs/graphql'
import { Audit } from '@island.is/nest/audit'
import { ApiScope } from '@island.is/auth/scopes'
import { IdsUserGuard, Scopes, ScopesGuard } from '@island.is/auth-nest-tools'
import {
CurrentUser,
IdsUserGuard,
Scopes,
ScopesGuard,
} from '@island.is/auth-nest-tools'
import type { User as AuthUser } from '@island.is/auth-nest-tools'
import { LOGGER_PROVIDER } from '@island.is/logging'
import type { Logger } from '@island.is/logging'
import { HealthInsuranceAccidentStatusInput } from './dto/accidentStatus.input'
Expand All @@ -27,10 +33,12 @@ export class HealthInsuranceAccidentNotificationResolver {
async accidentStatus(
@Args('input', { type: () => HealthInsuranceAccidentStatusInput })
input: HealthInsuranceAccidentStatusInput,
@CurrentUser() user: AuthUser,
): Promise<AccidentNotificationStatus | null> {
this.logger.debug(`Getting company information`)
const accidentStatus =
await this.accidentNotificationService.getAccidentNotificationStatus(
user,
input.ihiDocumentID,
)
this.logger.debug(`Getting accident status for id ${input.ihiDocumentID}`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import {
import { HealthInsuranceService } from './healthInsurance.service'
import { HealthInsuranceV2ClientModule } from '@island.is/clients/icelandic-health-insurance/health-insurance'
import { AccidentNotificationService } from './accident-notification.service'
import {
AccidentreportsApi,
RightsPortalClientModule,
} from '@island.is/clients/icelandic-health-insurance/rights-portal'

@Module({
imports: [HealthInsuranceV2ClientModule],
imports: [HealthInsuranceV2ClientModule, RightsPortalClientModule],
providers: [
HealthInsuranceService,
AccidentNotificationService,
Expand Down
Loading
Loading