From ea26d4c8d75a8518064276174d1a37c343fd6ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristen=20H=C3=A6rum?= Date: Thu, 28 Nov 2024 15:04:30 +0100 Subject: [PATCH] Feature/sykemelding forbedre status tilbakemelding (#3681) * Refactor exception handling and update sykemelding responses Replaced custom exceptions with ResponseStatusException for better HTTP response handling. Updated service and controller methods to return SykemeldningResponseDTO for more informative responses. Added SykemeldningResponseDTO class in the DTO library. * Refactor exception handling in SykemeldingConsumer Replaced custom exceptions with ResponseStatusException to standardize error handling across the application. Modified relevant unit tests and command logic to align with this change. * Add test and prod configurations for sykemelding API #deploy-test-sykemelding-api Created a new `config-test.yml` for the development environment and a new `application-prod.yml` for the production environment. Updated the Dockerfile and workflow to support these configurations, including enabling TokenX for production. * Rename config-test.yml to config.test.yml #deploy-test-sykemelding-api This change standardizes the naming convention for configuration files. It ensures consistency across the project and simplifies future maintenance. * Add SPRING_PROFILES_ACTIVE env variable to configs #deploy-test-sykemelding-api This commit introduces the SPRING_PROFILES_ACTIVE environment variable to the test and production configuration files. It sets the value to 'dev' for the test environment and 'prod' for the production environment to ensure appropriate profile activation. * Change profile annotation for LocalVaultConfig #deploy-test-sykemelding-api Updated the @Profile annotation from "dev" to "local" in LocalVaultConfig class. This change ensures that the configuration is applied only when the "local" profile is active. * Refactor profiles and update URLs for local and dev environments #deploy-test-synt-sykemelding-api #deploy-test-sykemelding-api Updated the configuration to differentiate between 'local' and 'dev' profiles, ensuring appropriate URL endpoints for each environment. This includes changes in the OAuth2 setup, Spring profiles, and Dockerfile adjustments. Added new configuration files to support "prod" and "local" environments. * Add new application to proxy config #deploy-pdl-proxy Included the testnav-synt-sykemelding-api-dev application under the dev-gcp cluster in the proxy configuration file. This change ensures proper routing and access for the new development environment. * Add test environment configs for synt-sykemelding-api-dev #deploy-test-dolly-backend #deploy-arbeidsforhold-service Added new application entries for 'testnav-synt-sykemelding-api-dev' in both arbeidsforhold-service and dolly-backend configuration files. This change ensures the new environment is recognized and integrated into the existing test setup. * Add testnav-synt-sykemelding-api-dev to config file #deploy-organisasjon-service Updated the configurational dependencies to include the new application testnav-synt-sykemelding-api-dev. This change is necessary for the development environment setup and ensures that all relevant services are listed for proper integration. * Update logging config for dev and local profiles #deploy-test-sykemelding-api #deploy-test-synt-sykemelding-api Expanded the "prod" profile to include "dev" for consistent logging and changed "dev" to "local" to better differentiate environments. This will improve clarity and maintainability of the logging configuration. * Update application-local.yaml with sykemelding API dev config Renamed 'testnav-synt-sykemelding-api' to 'testnav-synt-sykemelding-api-dev' and added 'testnav-pdl-forvalter-dev' name. This ensures proper configuration for the development environment. * Refactor sykemelding classes and fix DTO typo #deploy-test-dolly-backend #deploy-test-sykemelding-api #deploy-test-synt-sykemelding-api Refactored the Sykemelding classes to use a new response DTO and improved logging for better traceability. Also corrected the typo in SykemeldingResponseDTO across the codebase, ensuring consistent naming conventions. Updated application URLs in the configuration files. * Remove unused logging and add new API configuration. #deploy-test-dolly-backend Eliminated unused logging of sykemelding response status for clarity and simplicity. Added configuration entries for testnav-sykemelding-api and testnav-synt-sykemelding-api to support new integrations. * Deploy #deploy-arbeidsforhold-service #deploy-helsepersonell-service * Update dependencies and API URLs for dev environment #deploy-test-sykemelding-api Changed SpringDoc dependency from webflux to webmvc in build.gradle to match project requirements. Also corrected the URL for the testnav-synt-sykemelding-api in the local configuration file. * Remove Avro schema dependencies #deploy-test-sykemelding-api Removed the inclusion of 'avro-schema' from both `settings.gradle` and `build.gradle`. The change involved eliminating related dependencies including Kafka clients and Avro serializers that are no longer required. * Add testnav-sykemelding-api-dev to config.test.yml #deploy-test-dolly-backend This commit updates the configuration file to include the testnav-sykemelding-api-dev application. This ensures that the application is recognized and properly configured during testing environments. * Add sykemeldingId for tracking submissions. #deploy-test-frontend Incorporated 'sykemeldingId' to enable tracking of sykemelding submissions in the components `SyntSykemelding.tsx` and `DetaljertSykemelding.tsx`. This enhancement allows for improved data traceability and management. Additionally, code formatting was refined for uniformity and clarity. * Reorder error message checks and fix sykemelding config #deploy-test-dolly-backend Reordered error message checks in ErrorStatusDecoder for more logical processing, checking for a 'message' before 'error'. Also corrected the configuration name for testnav-synt-sykemelding-api in application-local.yaml to ensure proper service references. * Refactor variable name for clarity in KodeverkGetCommand #deploy-test-dolly-backend Renamed the variable "kodeverk" to "kodeverket" to improve code clarity and consistency with naming conventions. This change ensures better understanding and readability of the code, reducing potential confusion during future developments or reviews. --- .github/workflows/app.sykemelding-api.yml | 1 + .../workflows/app.synt-sykemelding-api.yml | 1 + apps/arbeidsforhold-service/config.yml | 2 + .../ArbeidsforholdApiApplicationStarter.java | 2 +- apps/dolly-backend/config.test.yml | 2 + .../dolly/DollyBackendApplicationStarter.java | 2 +- .../sykemelding/SykemeldingClient.java | 1 + .../command/SykemeldingPostCommand.java | 10 +- .../command/SyntSykemeldingPostCommand.java | 8 +- .../sykemelding/dto/SykemeldingResponse.java | 2 + .../kodeverk/command/KodeverkGetCommand.java | 5 + .../errorhandling/ErrorStatusDecoder.java | 6 +- .../src/main/resources/application-dev.yaml | 6 + .../src/main/resources/application-local.yaml | 6 +- .../fagsystem/sykdom/visning/Visning.tsx | 210 +++++++++--------- .../visning/partials/DetaljertSykemelding.tsx | 205 +++++++++-------- .../visning/partials/SyntSykemelding.tsx | 4 + ...lsepersonellServiceApplicationStarter.java | 2 +- apps/organisasjon-service/config.yml | 1 + apps/sykemelding-api/Dockerfile | 2 - apps/sykemelding-api/build.gradle | 7 +- apps/sykemelding-api/config.test.yml | 74 ++++++ apps/sykemelding-api/config.yml | 3 + apps/sykemelding-api/settings.gradle | 1 - .../sykemelding/config/LocalVaultConfig.java | 2 +- .../sykemelding/consumer/SyfoConsumer.java | 12 +- .../provider/SykemeldingController.java | 18 +- .../service/SykemeldingService.java | 5 +- .../src/main/resources/application-prod.yml | 8 + .../src/main/resources/application.yml | 4 - .../src/main/resources/logback-spring.xml | 4 +- apps/synt-sykemelding-api/Dockerfile | 4 +- apps/synt-sykemelding-api/config.test.yml | 73 ++++++ apps/synt-sykemelding-api/config.yml | 3 + .../config/LocalVaultConfig.java | 2 +- .../consumer/HelsepersonellConsumer.java | 5 +- .../consumer/PdlProxyConsumer.java | 7 +- .../consumer/SykemeldingConsumer.java | 7 +- .../consumer/SyntElsamConsumer.java | 5 +- .../command/PostSykemeldingCommand.java | 18 +- .../command/PostSyntSykemeldingCommand.java | 5 +- .../GenererSykemeldingerException.java | 8 - .../HelsepersonellNotFoundException.java | 8 - .../exception/LagreSykemeldingException.java | 7 - .../exception/PdlPersonException.java | 8 - .../provider/SyntSykemeldingController.java | 28 +-- .../service/SykemeldingService.java | 7 +- .../src/main/resources/application-dev.yml | 20 +- .../src/main/resources/application-local.yml | 13 ++ .../src/main/resources/application-prod.yml | 8 + .../src/main/resources/application.yml | 4 - .../src/main/resources/logback-spring.xml | 4 +- .../consumer/SykemeldingConsumerTest.java | 16 +- .../v1/SykemeldingResponseDTO.java | 17 ++ libs/reactive-proxy/package-lock.json | 6 + proxies/pdl-proxy/config.yml | 2 + 56 files changed, 563 insertions(+), 338 deletions(-) create mode 100644 apps/sykemelding-api/config.test.yml create mode 100644 apps/sykemelding-api/src/main/resources/application-prod.yml create mode 100644 apps/synt-sykemelding-api/config.test.yml delete mode 100644 apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/exception/GenererSykemeldingerException.java delete mode 100644 apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/exception/HelsepersonellNotFoundException.java delete mode 100644 apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/exception/LagreSykemeldingException.java delete mode 100644 apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/exception/PdlPersonException.java create mode 100644 apps/synt-sykemelding-api/src/main/resources/application-local.yml create mode 100644 apps/synt-sykemelding-api/src/main/resources/application-prod.yml create mode 100644 libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/SykemeldingResponseDTO.java create mode 100644 libs/reactive-proxy/package-lock.json diff --git a/.github/workflows/app.sykemelding-api.yml b/.github/workflows/app.sykemelding-api.yml index 13b32b61caa..10a312277dc 100644 --- a/.github/workflows/app.sykemelding-api.yml +++ b/.github/workflows/app.sykemelding-api.yml @@ -17,6 +17,7 @@ jobs: cluster: "dev-gcp" working-directory: "apps/sykemelding-api" deploy-tag: "#deploy-sykemelding-api" + deploy-tag-test: "#deploy-test-sykemelding-api" permissions: contents: read id-token: write diff --git a/.github/workflows/app.synt-sykemelding-api.yml b/.github/workflows/app.synt-sykemelding-api.yml index a9dd896a2d1..fa1c0105f66 100644 --- a/.github/workflows/app.synt-sykemelding-api.yml +++ b/.github/workflows/app.synt-sykemelding-api.yml @@ -19,6 +19,7 @@ jobs: with: working-directory: "apps/synt-sykemelding-api" deploy-tag: "#deploy-synt-sykemelding-api" + deploy-tag-test: "#deploy-test-synt-sykemelding-api" permissions: contents: read id-token: write diff --git a/apps/arbeidsforhold-service/config.yml b/apps/arbeidsforhold-service/config.yml index 553ffc6f0b4..f5ead086d9d 100644 --- a/apps/arbeidsforhold-service/config.yml +++ b/apps/arbeidsforhold-service/config.yml @@ -28,6 +28,8 @@ spec: cluster: dev-gcp - application: testnav-synt-sykemelding-api cluster: dev-gcp + - application: testnav-synt-sykemelding-api-dev + cluster: dev-gcp outbound: external: - host: testnav-aareg-proxy.dev-fss-pub.nais.io diff --git a/apps/arbeidsforhold-service/src/main/java/no/nav/registre/testnorge/arbeidsforholdservice/ArbeidsforholdApiApplicationStarter.java b/apps/arbeidsforhold-service/src/main/java/no/nav/registre/testnorge/arbeidsforholdservice/ArbeidsforholdApiApplicationStarter.java index 5afc9f4e4fa..575e1cf149b 100644 --- a/apps/arbeidsforhold-service/src/main/java/no/nav/registre/testnorge/arbeidsforholdservice/ArbeidsforholdApiApplicationStarter.java +++ b/apps/arbeidsforhold-service/src/main/java/no/nav/registre/testnorge/arbeidsforholdservice/ArbeidsforholdApiApplicationStarter.java @@ -9,4 +9,4 @@ public class ArbeidsforholdApiApplicationStarter { public static void main(String[] args) { SpringApplication.run(ArbeidsforholdApiApplicationStarter.class, args); } -} \ No newline at end of file +} diff --git a/apps/dolly-backend/config.test.yml b/apps/dolly-backend/config.test.yml index c99e52ac2e3..ed956306f6d 100644 --- a/apps/dolly-backend/config.test.yml +++ b/apps/dolly-backend/config.test.yml @@ -39,7 +39,9 @@ spec: - application: testnav-person-service - application: testnav-skattekort-service - application: testnav-sykemelding-api + - application: testnav-sykemelding-api-dev - application: testnav-synt-sykemelding-api + - application: testnav-synt-sykemelding-api-dev - application: testnav-tps-messaging-service - application: testnav-yrkesskade-proxy - application: testnorge-profil-api-dev diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/DollyBackendApplicationStarter.java b/apps/dolly-backend/src/main/java/no/nav/dolly/DollyBackendApplicationStarter.java index 6af8668f777..f0ef428e58d 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/DollyBackendApplicationStarter.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/DollyBackendApplicationStarter.java @@ -10,4 +10,4 @@ public static void main(String[] args) { SpringApplication.run(DollyBackendApplicationStarter.class, args); } -} \ No newline at end of file +} diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/SykemeldingClient.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/SykemeldingClient.java index c7714481e7c..07980a32425 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/SykemeldingClient.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/SykemeldingClient.java @@ -188,6 +188,7 @@ private void saveTransaksjonId(SykemeldingResponse sykemelding, Long bestillingI log.info("Lagrer transaksjon for {} i q1 ", sykemelding.getIdent()); + sykemelding.getSykemeldingRequest().setSykemeldingId(sykemelding.getMsgId()); transaksjonMappingService.save(TransaksjonMapping.builder() .ident(sykemelding.getIdent()) .bestillingId(bestillingId) diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/command/SykemeldingPostCommand.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/command/SykemeldingPostCommand.java index 06549e69549..14877f9a865 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/command/SykemeldingPostCommand.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/command/SykemeldingPostCommand.java @@ -1,12 +1,13 @@ package no.nav.dolly.bestilling.sykemelding.command; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import no.nav.dolly.bestilling.sykemelding.domain.DetaljertSykemeldingRequest; import no.nav.dolly.bestilling.sykemelding.dto.SykemeldingResponse; +import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingResponseDTO; import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; import no.nav.testnav.libs.securitycore.config.UserConstant; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; import reactor.util.retry.Retry; @@ -16,6 +17,7 @@ import static no.nav.dolly.util.TokenXUtil.getUserJwt; +@Slf4j @RequiredArgsConstructor public class SykemeldingPostCommand implements Callable> { @@ -35,10 +37,10 @@ public Mono call() { .header(UserConstant.USER_HEADER_JWT, getUserJwt()) .bodyValue(request) .retrieve() - .toBodilessEntity() - .timeout(Duration.ofMinutes(4)) + .bodyToMono(SykemeldingResponseDTO.class) .map(response -> SykemeldingResponse.builder() - .status(HttpStatus.valueOf(response.getStatusCode().value())) + .status(response.getStatus()) + .msgId(response.getSykemeldingId()) .ident(request.getPasient().getIdent()) .sykemeldingRequest(SykemeldingResponse.SykemeldingRequest.builder() .detaljertSykemeldingRequest(request) diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/command/SyntSykemeldingPostCommand.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/command/SyntSykemeldingPostCommand.java index 2b781fa2dc8..fcbfd4b5dac 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/command/SyntSykemeldingPostCommand.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/command/SyntSykemeldingPostCommand.java @@ -3,10 +3,10 @@ import lombok.RequiredArgsConstructor; import no.nav.dolly.bestilling.sykemelding.domain.SyntSykemeldingRequest; import no.nav.dolly.bestilling.sykemelding.dto.SykemeldingResponse; +import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingResponseDTO; import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; import no.nav.testnav.libs.securitycore.config.UserConstant; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; import reactor.util.retry.Retry; @@ -34,10 +34,10 @@ public Mono call() { .header(UserConstant.USER_HEADER_JWT, getUserJwt()) .bodyValue(sykemeldingRequest) .retrieve() - .toBodilessEntity() - .timeout(Duration.ofMinutes(4)) + .bodyToMono(SykemeldingResponseDTO.class) .map(response -> SykemeldingResponse.builder() - .status(HttpStatus.valueOf(response.getStatusCode().value())) + .status(response.getStatus()) + .msgId(response.getSykemeldingId()) .ident(sykemeldingRequest.getIdent()) .sykemeldingRequest(SykemeldingResponse.SykemeldingRequest.builder() .syntSykemeldingRequest(sykemeldingRequest) diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/dto/SykemeldingResponse.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/dto/SykemeldingResponse.java index 9126e4bff3c..2575ecc536c 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/dto/SykemeldingResponse.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/dto/SykemeldingResponse.java @@ -18,6 +18,7 @@ public class SykemeldingResponse { private HttpStatus status; private String avvik; private SykemeldingRequest sykemeldingRequest; + private String msgId; private String ident; @Data @@ -27,6 +28,7 @@ public class SykemeldingResponse { @JsonInclude(JsonInclude.Include.NON_EMPTY) public static class SykemeldingRequest { + private String sykemeldingId; private SyntSykemeldingRequest syntSykemeldingRequest; private DetaljertSykemeldingRequest detaljertSykemeldingRequest; } diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/consumer/kodeverk/command/KodeverkGetCommand.java b/apps/dolly-backend/src/main/java/no/nav/dolly/consumer/kodeverk/command/KodeverkGetCommand.java index 91b2382e5cb..d2466162e2e 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/consumer/kodeverk/command/KodeverkGetCommand.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/consumer/kodeverk/command/KodeverkGetCommand.java @@ -4,6 +4,7 @@ import no.nav.testnav.libs.dto.kodeverkservice.v1.KodeverkDTO; import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; import reactor.util.retry.Retry; @@ -31,6 +32,10 @@ public Mono call() { .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) .retrieve() .bodyToMono(KodeverkDTO.class) + .map(kodeverket -> { + kodeverket.setStatus(HttpStatus.OK); + return kodeverket; + }) .doOnError(WebClientFilter::logErrorMessage) .onErrorResume(error -> Mono.just(KodeverkDTO.builder() .kodeverknavn(kodeverk) diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/errorhandling/ErrorStatusDecoder.java b/apps/dolly-backend/src/main/java/no/nav/dolly/errorhandling/ErrorStatusDecoder.java index 893a8f55d12..466a74505e3 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/errorhandling/ErrorStatusDecoder.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/errorhandling/ErrorStatusDecoder.java @@ -102,10 +102,10 @@ public String getStatusMessage(String json) { if (json.contains("{")) { try { Map status = objectMapper.readValue(json, Map.class); - if (status.containsKey(ERROR) && isNotBlank((String) status.get(ERROR))) { - builder.append("error=").append(status.get(ERROR)).append("; "); - } else if (status.containsKey(MESSAGE) && isNotBlank((String) status.get(MESSAGE))) { + if (status.containsKey(MESSAGE) && isNotBlank((String) status.get(MESSAGE))) { builder.append("message=").append(encodeStatus((String) status.get(MESSAGE))).append("; "); + } else if (status.containsKey(ERROR) && isNotBlank((String) status.get(ERROR))) { + builder.append("error=").append(status.get(ERROR)).append("; "); } else if (status.containsKey(MELDING) && isNotBlank((String) status.get(MELDING))) { builder.append(encodeStatus((String) status.get(MELDING))); } else if (status.containsKey(DETAILS) && status.get(DETAILS) instanceof List) { diff --git a/apps/dolly-backend/src/main/resources/application-dev.yaml b/apps/dolly-backend/src/main/resources/application-dev.yaml index 6bef737e63a..a64b00aaada 100644 --- a/apps/dolly-backend/src/main/resources/application-dev.yaml +++ b/apps/dolly-backend/src/main/resources/application-dev.yaml @@ -22,3 +22,9 @@ consumers: testnav-pdl-forvalter: name: testnav-pdl-forvalter-dev url: http://testnav-pdl-forvalter-dev.dolly.svc.cluster.local + testnav-sykemelding-api: + name: testnav-sykemelding-api-dev + url: http://testnav-sykemelding-api-dev.dolly.svc.cluster.local + testnav-synt-sykemelding-api: + name: testnav-synt-sykemelding-api-dev + url: http://testnav-synt-sykemelding-api-dev.dolly.svc.cluster.local \ No newline at end of file diff --git a/apps/dolly-backend/src/main/resources/application-local.yaml b/apps/dolly-backend/src/main/resources/application-local.yaml index e4ec31e8b75..72fb6260486 100644 --- a/apps/dolly-backend/src/main/resources/application-local.yaml +++ b/apps/dolly-backend/src/main/resources/application-local.yaml @@ -54,9 +54,11 @@ consumers: testnav-organisasjon-service: url: https://testnav-organisasjon-service.intern.dev.nav.no testnav-synt-sykemelding-api: - url: https://testnav-synt-sykemelding-api.intern.dev.nav.no + name: testnav-synt-sykemelding-api-dev + url: https://testnav-synt-sykemelding-api-dev.intern.dev.nav.no testnav-sykemelding-api: - url: http://testnav-sykemelding-api.intern.dev.nav.no + name: testnav-sykemelding-api-dev + url: https://testnav-sykemelding-api-dev.intern.dev.nav.no testnav-miljoer-service: url: https://testnav-miljoer-service.intern.dev.nav.no testnav-arbeidsplassencv-proxy: diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/sykdom/visning/Visning.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/sykdom/visning/Visning.tsx index f21dc60938e..660ab7fe61f 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/sykdom/visning/Visning.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/sykdom/visning/Visning.tsx @@ -1,119 +1,131 @@ import _ from 'lodash' import SubOverskrift from '@/components/ui/subOverskrift/SubOverskrift' -import { SyntSykemelding } from './partials/SyntSykemelding' -import { DetaljertSykemelding } from './partials/DetaljertSykemelding' -import { Sykemelding, SykemeldingDetaljert, SykemeldingSynt } from '../SykemeldingTypes' -import { erGyldig } from '@/components/transaksjonid/GyldigeBestillinger' -import { Alert } from '@navikt/ds-react' +import {SyntSykemelding} from './partials/SyntSykemelding' +import {DetaljertSykemelding} from './partials/DetaljertSykemelding' +import { + Sykemelding, + SykemeldingDetaljert, + SykemeldingSynt +} from '../SykemeldingTypes' +import {erGyldig} from '@/components/transaksjonid/GyldigeBestillinger' +import {Alert} from '@navikt/ds-react' import React from 'react' -import { MiljoTabs } from '@/components/ui/miljoTabs/MiljoTabs' -import { useBestilteMiljoer } from '@/utils/hooks/useBestilling' +import {MiljoTabs} from '@/components/ui/miljoTabs/MiljoTabs' +import {useBestilteMiljoer} from '@/utils/hooks/useBestilling' import Loading from '@/components/ui/loading/Loading' export const sjekkManglerSykemeldingData = (sykemeldingData) => { - return ( - !sykemeldingData || - sykemeldingData?.length < 1 || - sykemeldingData?.every((miljoData) => !miljoData.data) - ) + return ( + !sykemeldingData || + sykemeldingData?.length < 1 || + sykemeldingData?.every((miljoData) => !miljoData.data) + ) } export const sjekkManglerSykemeldingBestilling = (sykemeldingBestilling) => { - return !sykemeldingBestilling || sykemeldingBestilling?.length < 1 + return !sykemeldingBestilling || sykemeldingBestilling?.length < 1 } -const VisningAvBestilling = ({ bestillinger }) => { - if (!bestillinger) { - return null - } - - return bestillinger?.map((bestilling: SykemeldingSynt | SykemeldingDetaljert, idx: number) => { - if (!bestilling.erGjenopprettet) { - const syntSykemelding = _.get(bestilling, 'data.sykemelding.syntSykemelding') - const detaljertSykemelding = _.get(bestilling, 'data.sykemelding.detaljertSykemelding') - - return syntSykemelding ? ( - - ) : detaljertSykemelding ? ( - - ) : null - } - }) +const VisningAvBestilling = ({bestillinger}) => { + if (!bestillinger) { + return null + } + + return bestillinger?.map((bestilling: SykemeldingSynt | SykemeldingDetaljert, idx: number) => { + if (!bestilling.erGjenopprettet) { + const syntSykemelding = _.get(bestilling, 'data.sykemelding.syntSykemelding') + const detaljertSykemelding = _.get(bestilling, 'data.sykemelding.detaljertSykemelding') + + return syntSykemelding ? ( + + ) : detaljertSykemelding ? ( + + ) : null + } + }) } -const VisningAvTransaksjonsId = ({ data }) => { - if (!data) { - return null - } - - const syntSykemelding = _.get(data, 'syntSykemeldingRequest') - const detaljertSykemelding = _.get(data, 'detaljertSykemeldingRequest') - - return syntSykemelding ? ( - - ) : detaljertSykemelding ? ( - - ) : null +const VisningAvTransaksjonsId = ({data}) => { + if (!data) { + return null + } + + const syntSykemelding = _.get(data, 'syntSykemeldingRequest') + const detaljertSykemelding = _.get(data, 'detaljertSykemeldingRequest') + const sykemeldingId = _.get(data, 'sykemeldingId') + + if (syntSykemelding) { + syntSykemelding['sykemeldingId'] = sykemeldingId + return + } + if (detaljertSykemelding) { + detaljertSykemelding['sykemeldingId'] = sykemeldingId + return < DetaljertSykemelding sykemelding={detaljertSykemelding}/> + } } export const SykemeldingVisning = ({ - data, - loading, - bestillingIdListe, - tilgjengeligMiljoe, - bestillinger, -}: Sykemelding) => { - const { bestilteMiljoer } = useBestilteMiljoer(bestillingIdListe, 'SYKEMELDING') - - if (loading) { - return - } - - if (!data && !bestillinger) { - return null - } - - const manglerFagsystemData = - sjekkManglerSykemeldingData(data) && sjekkManglerSykemeldingBestilling(bestillinger) - - const miljoerMedData = data?.map((miljoData) => miljoData.data && miljoData.miljo) - const errorMiljoer = bestilteMiljoer?.filter((miljo) => !miljoerMedData?.includes(miljo)) - - const forsteMiljo = data?.find((miljoData) => miljoData?.data)?.miljo - - const filteredData = - tilgjengeligMiljoe && data?.filter((item) => tilgjengeligMiljoe.includes(item.miljo)) - - return ( -
- - {manglerFagsystemData ? ( - - Fant ikke sykemelding-data på person - - ) : sjekkManglerSykemeldingData(data) ? ( - - ) : ( - - - - )} -
- ) + data, + loading, + bestillingIdListe, + tilgjengeligMiljoe, + bestillinger, + }: Sykemelding) => { + const {bestilteMiljoer} = useBestilteMiljoer(bestillingIdListe, 'SYKEMELDING') + + if (loading) { + return + } + + if (!data && !bestillinger) { + return null + } + + const manglerFagsystemData = + sjekkManglerSykemeldingData(data) && sjekkManglerSykemeldingBestilling(bestillinger) + + const miljoerMedData = data?.map((miljoData) => miljoData.data && miljoData.miljo) + const errorMiljoer = bestilteMiljoer?.filter((miljo) => !miljoerMedData?.includes(miljo)) + + const forsteMiljo = data?.find((miljoData) => miljoData?.data)?.miljo + + const filteredData = + tilgjengeligMiljoe && data?.filter((item) => tilgjengeligMiljoe.includes(item.miljo)) + + return ( +
+ + {manglerFagsystemData ? ( + + Fant ikke sykemelding-data på person + + ) : sjekkManglerSykemeldingData(data) ? ( + + ) : ( + + + + )} +
+ ) } SykemeldingVisning.filterValues = (bestillinger: Array, ident: string) => { - if (!bestillinger) { - return null - } - - return bestillinger.filter( - (bestilling: any) => - bestilling.data?.sykemelding && erGyldig(bestilling.id, 'SYKEMELDING', ident), - ) + if (!bestillinger) { + return null + } + + return bestillinger.filter( + (bestilling: any) => + bestilling.data?.sykemelding && erGyldig(bestilling.id, 'SYKEMELDING', ident), + ) } diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/sykdom/visning/partials/DetaljertSykemelding.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/sykdom/visning/partials/DetaljertSykemelding.tsx index 68b98a77b40..4fe1c7172eb 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/sykdom/visning/partials/DetaljertSykemelding.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/sykdom/visning/partials/DetaljertSykemelding.tsx @@ -1,100 +1,119 @@ import * as React from 'react' -import { formatStringDates, oversettBoolean } from '@/utils/DataFormatter' -import { TitleValue } from '@/components/ui/titleValue/TitleValue' -import { Bidiagnoser } from './Bidiagnoser' -import { Perioder } from './Perioder' -import { ArbeidKodeverk } from '@/config/kodeverk' -import { SykemeldingDetaljert } from '@/components/fagsystem/sykdom/SykemeldingTypes' +import {formatStringDates, oversettBoolean} from '@/utils/DataFormatter' +import {TitleValue} from '@/components/ui/titleValue/TitleValue' +import {Bidiagnoser} from './Bidiagnoser' +import {Perioder} from './Perioder' +import {ArbeidKodeverk} from '@/config/kodeverk' +import { + SykemeldingDetaljert +} from '@/components/fagsystem/sykdom/SykemeldingTypes' import styled from 'styled-components' export const SykemeldingKategori = styled.div` - width: 100%; - h4 { - margin-top: 5px; - margin-bottom: 15px; - } + width: 100%; + + h4 { + margin-top: 5px; + margin-bottom: 15px; + } ` -export const DetaljertSykemelding = ({ sykemelding, idx }: SykemeldingDetaljert) => { - return ( -
- -
- - - -
- <> - -

Diagnose

-
-
- - -
- - - <> - -

Helsepersonell

-
-
- - - - -
- - <> - -

Arbeidsgiver

-
-
- - - -
- - - <> - -

Detaljer

-
-
- - - - -
- -
-
- ) +export const DetaljertSykemelding = ({ + sykemelding, + idx + }: SykemeldingDetaljert) => { + console.log('sykemelding', sykemelding) + return ( +
+ +
+ + + +
+ <> + +

Diagnose

+
+
+ + +
+ + + <> + +

Helsepersonell

+
+
+ + + + +
+ + <> + +

Arbeidsgiver

+
+
+ + + +
+ + + <> + +

Detaljer

+
+
+ + + + + +
+ +
+
+ ) } diff --git a/apps/dolly-frontend/src/main/js/src/components/fagsystem/sykdom/visning/partials/SyntSykemelding.tsx b/apps/dolly-frontend/src/main/js/src/components/fagsystem/sykdom/visning/partials/SyntSykemelding.tsx index f67334cee4c..2c19e33f8b8 100644 --- a/apps/dolly-frontend/src/main/js/src/components/fagsystem/sykdom/visning/partials/SyntSykemelding.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/fagsystem/sykdom/visning/partials/SyntSykemelding.tsx @@ -8,5 +8,9 @@ export const SyntSykemelding = ({ sykemelding, idx }: SykemeldingSynt) => ( + ) diff --git a/apps/helsepersonell-service/src/main/java/no/nav/registre/testnorge/helsepersonellservice/HelsepersonellServiceApplicationStarter.java b/apps/helsepersonell-service/src/main/java/no/nav/registre/testnorge/helsepersonellservice/HelsepersonellServiceApplicationStarter.java index aa032265a42..1a3041608b2 100644 --- a/apps/helsepersonell-service/src/main/java/no/nav/registre/testnorge/helsepersonellservice/HelsepersonellServiceApplicationStarter.java +++ b/apps/helsepersonell-service/src/main/java/no/nav/registre/testnorge/helsepersonellservice/HelsepersonellServiceApplicationStarter.java @@ -9,4 +9,4 @@ public class HelsepersonellServiceApplicationStarter { public static void main(String[] args) { SpringApplication.run(HelsepersonellServiceApplicationStarter.class, args); } -} \ No newline at end of file +} diff --git a/apps/organisasjon-service/config.yml b/apps/organisasjon-service/config.yml index 5fd5cef84b2..322487c6a0b 100644 --- a/apps/organisasjon-service/config.yml +++ b/apps/organisasjon-service/config.yml @@ -31,6 +31,7 @@ spec: - application: testnav-orgnummer-service - application: testnav-oversikt-frontend - application: testnav-synt-sykemelding-api + - application: testnav-synt-sykemelding-api-dev - application: testnorge-statisk-data-forvalter cluster: dev-fss outbound: diff --git a/apps/sykemelding-api/Dockerfile b/apps/sykemelding-api/Dockerfile index 4a36f93546f..89a589699dd 100644 --- a/apps/sykemelding-api/Dockerfile +++ b/apps/sykemelding-api/Dockerfile @@ -1,8 +1,6 @@ FROM ghcr.io/navikt/baseimages/temurin:21 LABEL maintainer="Team Dolly" -ENV JAVA_OPTS="-Dspring.profiles.active=prod" - ADD /build/libs/app.jar /app/app.jar EXPOSE 8080 diff --git a/apps/sykemelding-api/build.gradle b/apps/sykemelding-api/build.gradle index e7893d2c807..a41d620d9c0 100644 --- a/apps/sykemelding-api/build.gradle +++ b/apps/sykemelding-api/build.gradle @@ -10,7 +10,6 @@ sonarqube { } dependencies { - implementation "no.nav.testnav.libs:avro-schema" implementation "no.nav.testnav.libs:commands" implementation "no.nav.testnav.libs:data-transfer-objects" implementation "no.nav.testnav.libs:reactive-core" @@ -22,19 +21,15 @@ dependencies { implementation "org.springframework.boot:spring-boot-starter-web" implementation "org.springframework.boot:spring-boot-starter-security" - implementation "org.springdoc:springdoc-openapi-starter-webflux-ui:$versions.springdoc" + implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:$versions.springdoc" implementation "io.swagger.core.v3:swagger-annotations-jakarta:$versions.swagger" implementation "com.ibm.mq:mq-jms-spring-boot-starter:$versions.mq" - implementation "org.springframework.kafka:spring-kafka" implementation "jakarta.xml.bind:jakarta.xml.bind-api:$versions.jakartaXmlBindApi" implementation "jakarta.activation:jakarta.activation-api:$versions.jakartaActivation" implementation "org.glassfish.jaxb:jaxb-runtime:$versions.jaxb" implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml" - implementation "org.apache.kafka:kafka-clients:$versions.apacheKafka" - implementation "io.confluent:kafka-avro-serializer:$versions.avro" - testImplementation "no.nav.testnav.libs:testing" testImplementation "org.springframework.security:spring-security-test" testImplementation "org.springframework.cloud:spring-cloud-contract-wiremock" diff --git a/apps/sykemelding-api/config.test.yml b/apps/sykemelding-api/config.test.yml new file mode 100644 index 00000000000..c22417b88ff --- /dev/null +++ b/apps/sykemelding-api/config.test.yml @@ -0,0 +1,74 @@ +apiVersion: "nais.io/v1alpha1" +kind: "Application" +metadata: + name: testnav-sykemelding-api-dev + namespace: dolly + labels: + team: dolly + annotations: + nginx.ingress.kubernetes.io/proxy-read-timeout: "600" + nginx.ingress.kubernetes.io/proxy-send-timeout: "600" + nginx.ingress.kubernetes.io/proxy-body-size: "512m" +spec: + webproxy: true + tokenx: + enabled: true + azure: + application: + allowAllUsers: true + enabled: true + tenant: nav.no + image: "{{image}}" + port: 8080 + liveness: + path: /internal/isAlive + initialDelay: 4 + periodSeconds: 5 + failureThreshold: 500 + observability: + logging: + destinations: + - id: elastic + autoInstrumentation: + enabled: true + runtime: java + readiness: + path: /internal/isReady + initialDelay: 4 + periodSeconds: 5 + failureThreshold: 500 + prometheus: + enabled: true + path: /internal/metrics + replicas: + min: 1 + max: 1 + envFrom: + - secret: dolly-sykemelding-mq + env: + - name: SPRING_PROFILES_ACTIVE + value: dev + resources: + requests: + cpu: 200m + memory: 4000Mi + limits: + memory: 5000Mi + accessPolicy: + inbound: + rules: + - application: dolly-backend + - application: dolly-backend-dev + - application: dolly-frontend + - application: dolly-frontend-dev + - application: dolly-idporten + - application: team-dolly-lokal-app + - application: testnav-oversikt-frontend + - application: testnav-synt-sykemelding-api-dev + outbound: + external: + - host: mqls04.preprod.local + ports: + - port: 1413 + ingresses: + - "https://testnav-sykemelding-api-dev.intern.dev.nav.no" \ No newline at end of file diff --git a/apps/sykemelding-api/config.yml b/apps/sykemelding-api/config.yml index bb498bac7a2..38ec28ef58a 100644 --- a/apps/sykemelding-api/config.yml +++ b/apps/sykemelding-api/config.yml @@ -45,6 +45,9 @@ spec: max: 1 envFrom: - secret: dolly-sykemelding-mq + env: + - name: SPRING_PROFILES_ACTIVE + value: prod resources: requests: cpu: 200m diff --git a/apps/sykemelding-api/settings.gradle b/apps/sykemelding-api/settings.gradle index 8caaf392e5b..4c0a23fa254 100644 --- a/apps/sykemelding-api/settings.gradle +++ b/apps/sykemelding-api/settings.gradle @@ -6,7 +6,6 @@ rootProject.name = 'sykemelding-api' includeBuild "../../plugins/java" -includeBuild '../../libs/avro-schema' includeBuild '../../libs/commands' includeBuild '../../libs/data-transfer-objects' includeBuild '../../libs/reactive-core' diff --git a/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/config/LocalVaultConfig.java b/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/config/LocalVaultConfig.java index c35a141e2f2..480a0aaedf3 100644 --- a/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/config/LocalVaultConfig.java +++ b/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/config/LocalVaultConfig.java @@ -5,6 +5,6 @@ import org.springframework.context.annotation.Profile; @Configuration -@Profile("dev") +@Profile("local") public class LocalVaultConfig extends AbstractLocalVaultConfiguration { } \ No newline at end of file diff --git a/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/consumer/SyfoConsumer.java b/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/consumer/SyfoConsumer.java index f9ad67d4ced..d121155f9df 100644 --- a/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/consumer/SyfoConsumer.java +++ b/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/consumer/SyfoConsumer.java @@ -2,7 +2,9 @@ import lombok.extern.slf4j.Slf4j; import no.nav.registre.testnorge.sykemelding.domain.Sykemelding; +import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingResponseDTO; import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; import org.springframework.jms.core.JmsTemplate; import org.springframework.stereotype.Component; @@ -17,10 +19,16 @@ public SyfoConsumer(JmsTemplate jmsTemplate, @Value("${syfo.queue.name}") String this.queueName = queueName; } - public void send(Sykemelding sykemelding) { - String xml = sykemelding.toXml(); + public SykemeldingResponseDTO send(Sykemelding sykemelding) { + + var xml = sykemelding.toXml(); log.info("Legger sykemelding på kø med MsgId {}\n{}", sykemelding.getMsgId(), sykemelding); jmsTemplate.send(queueName, session -> session.createTextMessage(xml)); log.trace(xml); + + return SykemeldingResponseDTO.builder() + .sykemeldingId(sykemelding.getMsgId()) + .status(HttpStatus.OK) + .build(); } } \ No newline at end of file diff --git a/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/provider/SykemeldingController.java b/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/provider/SykemeldingController.java index 7279719f55b..54a10649acc 100644 --- a/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/provider/SykemeldingController.java +++ b/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/provider/SykemeldingController.java @@ -1,18 +1,16 @@ package no.nav.registre.testnorge.sykemelding.provider; import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; +import no.nav.registre.testnorge.sykemelding.domain.ApplicationInfo; +import no.nav.registre.testnorge.sykemelding.domain.Sykemelding; +import no.nav.registre.testnorge.sykemelding.service.SykemeldingService; +import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingDTO; +import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingResponseDTO; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingDTO; -import no.nav.registre.testnorge.sykemelding.domain.ApplicationInfo; -import no.nav.registre.testnorge.sykemelding.domain.Sykemelding; -import no.nav.registre.testnorge.sykemelding.service.SykemeldingService; - @RestController @RequestMapping("/api/v1/sykemeldinger") @RequiredArgsConstructor @@ -22,8 +20,8 @@ public class SykemeldingController { private final ApplicationInfo applicationInfo; @PostMapping - public ResponseEntity create(@RequestBody SykemeldingDTO dto) { - service.send(new Sykemelding(dto, applicationInfo)); - return ResponseEntity.ok().build(); + public SykemeldingResponseDTO create(@RequestBody SykemeldingDTO dto) { + + return service.send(new Sykemelding(dto, applicationInfo)); } } diff --git a/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/service/SykemeldingService.java b/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/service/SykemeldingService.java index 0009eb98a9e..e8a9e4f2302 100644 --- a/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/service/SykemeldingService.java +++ b/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/service/SykemeldingService.java @@ -3,6 +3,7 @@ import lombok.RequiredArgsConstructor; import no.nav.registre.testnorge.sykemelding.consumer.SyfoConsumer; import no.nav.registre.testnorge.sykemelding.domain.Sykemelding; +import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingResponseDTO; import org.springframework.stereotype.Service; @Service @@ -10,8 +11,8 @@ public class SykemeldingService { private final SyfoConsumer syfoConsumer; - public void send(Sykemelding sykemelding) { + public SykemeldingResponseDTO send(Sykemelding sykemelding) { - syfoConsumer.send(sykemelding); + return syfoConsumer.send(sykemelding); } } \ No newline at end of file diff --git a/apps/sykemelding-api/src/main/resources/application-prod.yml b/apps/sykemelding-api/src/main/resources/application-prod.yml new file mode 100644 index 00000000000..0311ce578e3 --- /dev/null +++ b/apps/sykemelding-api/src/main/resources/application-prod.yml @@ -0,0 +1,8 @@ +spring: + security: + oauth2: + resourceserver: + tokenx: + issuer-uri: ${TOKEN_X_ISSUER} + jwk-set-uri: ${TOKEN_X_JWKS_URI} + accepted-audience: ${TOKEN_X_CLIENT_ID} \ No newline at end of file diff --git a/apps/sykemelding-api/src/main/resources/application.yml b/apps/sykemelding-api/src/main/resources/application.yml index 341ca3b64f1..357f2b5c5f6 100644 --- a/apps/sykemelding-api/src/main/resources/application.yml +++ b/apps/sykemelding-api/src/main/resources/application.yml @@ -16,10 +16,6 @@ spring: issuer-uri: ${AAD_ISSUER_URI}/v2.0 jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys accepted-audience: ${azure.app.client.id}, api://${azure.app.client.id} - tokenx: - issuer-uri: ${TOKEN_X_ISSUER} - jwk-set-uri: ${TOKEN_X_JWKS_URI} - accepted-audience: ${TOKEN_X_CLIENT_ID} cloud: vault: enabled: false diff --git a/apps/sykemelding-api/src/main/resources/logback-spring.xml b/apps/sykemelding-api/src/main/resources/logback-spring.xml index 87916258c05..2523e5d41b7 100644 --- a/apps/sykemelding-api/src/main/resources/logback-spring.xml +++ b/apps/sykemelding-api/src/main/resources/logback-spring.xml @@ -1,6 +1,6 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/apps/synt-sykemelding-api/Dockerfile b/apps/synt-sykemelding-api/Dockerfile index 4a36f93546f..8fcd643d0ff 100644 --- a/apps/synt-sykemelding-api/Dockerfile +++ b/apps/synt-sykemelding-api/Dockerfile @@ -1,8 +1,6 @@ FROM ghcr.io/navikt/baseimages/temurin:21 LABEL maintainer="Team Dolly" -ENV JAVA_OPTS="-Dspring.profiles.active=prod" - -ADD /build/libs/app.jar /app/app.jar +COPY /build/libs/app.jar /app/app.jar EXPOSE 8080 diff --git a/apps/synt-sykemelding-api/config.test.yml b/apps/synt-sykemelding-api/config.test.yml new file mode 100644 index 00000000000..7ec70c4d0cd --- /dev/null +++ b/apps/synt-sykemelding-api/config.test.yml @@ -0,0 +1,73 @@ +apiVersion: "nais.io/v1alpha1" +kind: "Application" +metadata: + name: testnav-synt-sykemelding-api-dev + namespace: dolly + annotations: + nginx.ingress.kubernetes.io/proxy-read-timeout: "3600" + nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" + labels: + team: dolly +spec: + image: "{{image}}" + port: 8080 + webproxy: true + tokenx: + enabled: true + azure: + application: + allowAllUsers: true + enabled: true + tenant: nav.no + liveness: + path: /internal/isAlive + initialDelay: 4 + periodSeconds: 5 + failureThreshold: 500 + observability: + logging: + destinations: + - id: elastic + autoInstrumentation: + enabled: true + runtime: java + readiness: + path: /internal/isReady + initialDelay: 4 + periodSeconds: 5 + failureThreshold: 500 + prometheus: + enabled: true + path: /internal/metrics + replicas: + min: 1 + max: 1 + vault: + enabled: true + resources: + requests: + cpu: 200m + memory: 4000Mi + limits: + memory: 5000Mi + accessPolicy: + inbound: + rules: + - application: dolly-backend + - application: dolly-backend-dev + - application: team-dolly-lokal-app + - application: testnav-oversikt-frontend + outbound: + rules: + - application: synthdata-elsam-gcp + - application: testnav-organisasjon-service + - application: testnav-arbeidsforhold-service + - application: testnav-helsepersonell-service + - application: testnav-sykemelding-api-dev + external: + - host: testnav-pdl-proxy.dev-fss-pub.nais.io + ingresses: + - "https://testnav-synt-sykemelding-api-dev.intern.dev.nav.no" + env: + - name: SPRING_PROFILES_ACTIVE + value: dev \ No newline at end of file diff --git a/apps/synt-sykemelding-api/config.yml b/apps/synt-sykemelding-api/config.yml index 2493281b221..d1622f0bba1 100644 --- a/apps/synt-sykemelding-api/config.yml +++ b/apps/synt-sykemelding-api/config.yml @@ -68,3 +68,6 @@ spec: - host: testnav-pdl-proxy.dev-fss-pub.nais.io ingresses: - "https://testnav-synt-sykemelding-api.intern.dev.nav.no" + env: + - name: SPRING_PROFILES_ACTIVE + value: prod \ No newline at end of file diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/LocalVaultConfig.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/LocalVaultConfig.java index be09110b7fa..c7ec9427324 100644 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/LocalVaultConfig.java +++ b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/LocalVaultConfig.java @@ -5,6 +5,6 @@ import org.springframework.context.annotation.Profile; @Configuration -@Profile("dev") +@Profile("local") public class LocalVaultConfig extends AbstractLocalVaultConfiguration { } \ No newline at end of file diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/HelsepersonellConsumer.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/HelsepersonellConsumer.java index 8cd27ace590..814acafdccf 100644 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/HelsepersonellConsumer.java +++ b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/HelsepersonellConsumer.java @@ -5,11 +5,12 @@ import no.nav.testnav.apps.syntsykemeldingapi.config.Consumers; import no.nav.testnav.apps.syntsykemeldingapi.consumer.command.GetHelsepersonellCommand; import no.nav.testnav.apps.syntsykemeldingapi.domain.HelsepersonellListe; -import no.nav.testnav.apps.syntsykemeldingapi.exception.HelsepersonellNotFoundException; import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.server.ResponseStatusException; import static java.util.Objects.nonNull; @@ -44,7 +45,7 @@ public HelsepersonellListe hentHelsepersonell() { return new HelsepersonellListe(response); } else { log.warn("Feil oppsto i henting av helsepersonell"); - throw new HelsepersonellNotFoundException("Feil i henting av helsepersonell"); + throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Feil i henting av helsepersonell"); } } } \ No newline at end of file diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/PdlProxyConsumer.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/PdlProxyConsumer.java index 52d2327642a..0e916558c72 100644 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/PdlProxyConsumer.java +++ b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/PdlProxyConsumer.java @@ -4,13 +4,14 @@ import no.nav.testnav.apps.syntsykemeldingapi.config.Consumers; import no.nav.testnav.apps.syntsykemeldingapi.consumer.command.GetPdlPersonCommand; import no.nav.testnav.apps.syntsykemeldingapi.domain.pdl.PdlPerson; -import no.nav.testnav.apps.syntsykemeldingapi.exception.PdlPersonException; import no.nav.testnav.apps.syntsykemeldingapi.util.FilLaster; import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.client.ExchangeStrategies; import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.server.ResponseStatusException; import java.io.BufferedReader; import java.io.IOException; @@ -60,12 +61,12 @@ public PdlPerson getPdlPerson(String ident) { if (nonNull(response) && !response.getErrors().isEmpty()) { var melding = response.getErrors().get(0).getMessage(); log.error("Klarte ikke hente pdlperson: " + melding); - throw new PdlPersonException("Feil i henting av person fra pdl" + melding); + throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Feil i henting av person fra pdl" + melding); } return response; } catch (Exception e) { log.error("Klarte ikke hente pdlperson.", e); - throw new PdlPersonException("Feil i henting av person fra pdl"); + throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Feil i henting av person fra pdl"); } } diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumer.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumer.java index 60acfddd441..87b327b5899 100644 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumer.java +++ b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumer.java @@ -4,6 +4,7 @@ import no.nav.testnav.apps.syntsykemeldingapi.config.Consumers; import no.nav.testnav.apps.syntsykemeldingapi.consumer.command.PostSykemeldingCommand; import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingDTO; +import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingResponseDTO; import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; import org.springframework.stereotype.Component; @@ -29,8 +30,10 @@ public SykemeldingConsumer( .build(); } - public void opprettSykemelding(SykemeldingDTO sykemelding) { - tokenExchange.exchange(serverProperties).flatMap(accessToken -> + public SykemeldingResponseDTO opprettSykemelding(SykemeldingDTO sykemelding) { + + return tokenExchange.exchange(serverProperties) + .flatMap(accessToken -> new PostSykemeldingCommand(webClient, accessToken.getTokenValue(), sykemelding).call()) .block(); } diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SyntElsamConsumer.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SyntElsamConsumer.java index 1a754f8a8e1..85e1b91820f 100644 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SyntElsamConsumer.java +++ b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SyntElsamConsumer.java @@ -5,12 +5,13 @@ import no.nav.testnav.apps.syntsykemeldingapi.config.Consumers; import no.nav.testnav.apps.syntsykemeldingapi.consumer.command.PostSyntSykemeldingCommand; import no.nav.testnav.apps.syntsykemeldingapi.consumer.dto.SyntSykemeldingHistorikkDTO; -import no.nav.testnav.apps.syntsykemeldingapi.exception.GenererSykemeldingerException; import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.client.ExchangeStrategies; import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.server.ResponseStatusException; import java.time.LocalDate; import java.util.Map; @@ -54,7 +55,7 @@ public SyntSykemeldingHistorikkDTO genererSykemeldinger(String ident, LocalDate .block(); if (isNull(response)) { - throw new GenererSykemeldingerException("Klarte ikke å generere sykemeldinger."); + throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Klarte ikke å generere sykemeldinger."); } log.info("Sykemelding generert."); return response.get(ident); diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/command/PostSykemeldingCommand.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/command/PostSykemeldingCommand.java index f0137a236cb..3570ec16745 100644 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/command/PostSykemeldingCommand.java +++ b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/command/PostSykemeldingCommand.java @@ -3,9 +3,12 @@ import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.syntsykemeldingapi.exception.LagreSykemeldingException; import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingDTO; +import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingResponseDTO; +import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; +import org.springframework.http.HttpStatus; import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.server.ResponseStatusException; import reactor.core.publisher.Mono; import java.util.concurrent.Callable; @@ -14,7 +17,7 @@ @Slf4j @RequiredArgsConstructor -public class PostSykemeldingCommand implements Callable> { +public class PostSykemeldingCommand implements Callable> { private final WebClient webClient; private final String token; @@ -22,7 +25,7 @@ public class PostSykemeldingCommand implements Callable> { @SneakyThrows @Override - public Mono call() { + public Mono call() { return webClient.post() .uri(builder -> builder.path("/api/v1/sykemeldinger").build() @@ -30,10 +33,9 @@ public Mono call() { .header(AUTHORIZATION, "Bearer " + token) .bodyValue(sykemelding) .retrieve() - .bodyToMono(String.class) - .onErrorResume(throwable -> { - log.error("Feil oppsto i innsending av sykemelding", throwable); - throw new LagreSykemeldingException("Feil oppsto i innsending av sykemelding"); - }); + .bodyToMono(SykemeldingResponseDTO.class) + .doOnError(WebClientFilter::logErrorMessage) + .onErrorResume(throwable -> + Mono.error(new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Feil oppsto i innsending av sykemelding"))); } } diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/command/PostSyntSykemeldingCommand.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/command/PostSyntSykemeldingCommand.java index 9b359589dd0..0a6c70719e0 100644 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/command/PostSyntSykemeldingCommand.java +++ b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/command/PostSyntSykemeldingCommand.java @@ -3,10 +3,11 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import no.nav.testnav.apps.syntsykemeldingapi.consumer.dto.SyntSykemeldingHistorikkDTO; -import no.nav.testnav.apps.syntsykemeldingapi.exception.GenererSykemeldingerException; import no.nav.testnav.libs.commands.utils.WebClientFilter; import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpStatus; import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.server.ResponseStatusException; import reactor.core.publisher.Mono; import reactor.util.retry.Retry; @@ -39,7 +40,7 @@ public Mono> call() { .filter(WebClientFilter::is5xxException)) .onErrorResume(throwable -> { log.error("Klarte ikke å hente data fra synthdata-elsam", throwable); - throw new GenererSykemeldingerException("Klarte ikke å generere sykemeldinger."); + throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Klarte ikke å generere sykemeldinger."); }); } } diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/exception/GenererSykemeldingerException.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/exception/GenererSykemeldingerException.java deleted file mode 100644 index 82c222ce5e6..00000000000 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/exception/GenererSykemeldingerException.java +++ /dev/null @@ -1,8 +0,0 @@ -package no.nav.testnav.apps.syntsykemeldingapi.exception; - -public class GenererSykemeldingerException extends RuntimeException { - - public GenererSykemeldingerException(String message) { - super(message); - } -} diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/exception/HelsepersonellNotFoundException.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/exception/HelsepersonellNotFoundException.java deleted file mode 100644 index 5af4175bc7b..00000000000 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/exception/HelsepersonellNotFoundException.java +++ /dev/null @@ -1,8 +0,0 @@ -package no.nav.testnav.apps.syntsykemeldingapi.exception; - -public class HelsepersonellNotFoundException extends RuntimeException { - - public HelsepersonellNotFoundException(String message) { - super(message); - } -} diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/exception/LagreSykemeldingException.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/exception/LagreSykemeldingException.java deleted file mode 100644 index bec944dc7b5..00000000000 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/exception/LagreSykemeldingException.java +++ /dev/null @@ -1,7 +0,0 @@ -package no.nav.testnav.apps.syntsykemeldingapi.exception; - -public class LagreSykemeldingException extends RuntimeException { - public LagreSykemeldingException(String message) { - super(message); - } -} diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/exception/PdlPersonException.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/exception/PdlPersonException.java deleted file mode 100644 index f071a9a967f..00000000000 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/exception/PdlPersonException.java +++ /dev/null @@ -1,8 +0,0 @@ -package no.nav.testnav.apps.syntsykemeldingapi.exception; - -public class PdlPersonException extends RuntimeException { - - public PdlPersonException(String message) { - super(message); - } -} diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/provider/SyntSykemeldingController.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/provider/SyntSykemeldingController.java index f3c24a063dc..7659c7d3723 100644 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/provider/SyntSykemeldingController.java +++ b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/provider/SyntSykemeldingController.java @@ -2,42 +2,24 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; - import no.nav.testnav.apps.syntsykemeldingapi.service.SykemeldingService; +import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingResponseDTO; import no.nav.testnav.libs.dto.synt.sykemelding.v1.SyntSykemeldingDTO; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.client.HttpClientErrorException; @RestController @Slf4j @RequestMapping("/api/v1/synt-sykemelding") @RequiredArgsConstructor public class SyntSykemeldingController { - private final SykemeldingService service; + private final SykemeldingService sykemeldingService; @PostMapping - public ResponseEntity opprett(@RequestBody SyntSykemeldingDTO sykemelding) { - service.opprettSykemelding(sykemelding); - return ResponseEntity.ok().build(); - } - - @ControllerAdvice - public static class ExceptionHandlerAdvice { - - @ExceptionHandler(HttpClientErrorException.class) - public ResponseEntity handleException(HttpClientErrorException e) { - log.error("Klarte ikke å finne arbeidsforhold", e); - return ResponseEntity - .status(HttpStatus.NOT_FOUND) - .body("Klarte ikke å finne aktivt arbeidsforhold for personen"); - } + public SykemeldingResponseDTO opprett(@RequestBody SyntSykemeldingDTO sykemelding) { + + return sykemeldingService.opprettSykemelding(sykemelding); } } \ No newline at end of file diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/service/SykemeldingService.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/service/SykemeldingService.java index 6bef1a391dd..dea8c92f9a8 100644 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/service/SykemeldingService.java +++ b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/service/SykemeldingService.java @@ -9,11 +9,10 @@ import no.nav.testnav.apps.syntsykemeldingapi.consumer.SyntElsamConsumer; import no.nav.testnav.apps.syntsykemeldingapi.domain.Person; import no.nav.testnav.apps.syntsykemeldingapi.domain.Sykemelding; +import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingResponseDTO; import no.nav.testnav.libs.dto.synt.sykemelding.v1.SyntSykemeldingDTO; import org.springframework.stereotype.Service; -import java.util.Objects; - import static java.util.Objects.nonNull; @Slf4j @@ -26,7 +25,7 @@ public class SykemeldingService { private final ArbeidsforholdAdapter arbeidsforholdAdapter; private final PdlProxyConsumer pdlProxyConsumer; - public void opprettSykemelding(SyntSykemeldingDTO syntSykemelding) { + public SykemeldingResponseDTO opprettSykemelding(SyntSykemeldingDTO syntSykemelding) { var pdlData = pdlProxyConsumer.getPdlPerson(syntSykemelding.getIdent()); var pasient = new Person(pdlData); @@ -44,7 +43,7 @@ public void opprettSykemelding(SyntSykemeldingDTO syntSykemelding) { ); var helsepersonellListe = helsepersonellConsumer.hentHelsepersonell(); - sykemeldingConsumer.opprettSykemelding( + return sykemeldingConsumer.opprettSykemelding( new Sykemelding(pasient, historikk, syntSykemelding, helsepersonellListe.getRandomLege(), arbeidsforhold).toDTO() ); } diff --git a/apps/synt-sykemelding-api/src/main/resources/application-dev.yml b/apps/synt-sykemelding-api/src/main/resources/application-dev.yml index d2bdd15fc8a..e0dc5a65e3c 100644 --- a/apps/synt-sykemelding-api/src/main/resources/application-dev.yml +++ b/apps/synt-sykemelding-api/src/main/resources/application-dev.yml @@ -1,12 +1,22 @@ -TOKEN_X_CLIENT_ID: dev-gcp:dolly:testnav-synt-sykemelding-api +spring: + security: + oauth2: + resourceserver: + tokenx: + issuer-uri: ${TOKEN_X_ISSUER} + jwk-set-uri: ${TOKEN_X_JWKS_URI} + accepted-audience: ${TOKEN_X_CLIENT_ID} consumers: synt-sykemelding: - url: https://synthdata-elsam-gcp.intern.dev.nav.no + url: http://synthdata-elsam-gcp.intern.dolly.svc.cluster.local testnav-organisasjon-service: - url: https://testnav-organisasjon-service.intern.dev.nav.no + url: http://testnav-organisasjon-service.dolly.svc.cluster.local testnav-arbeidsforhold-service: - url: https://testnav-arbeidsforhold-service.intern.dev.nav.no + url: http://testnav-arbeidsforhold-service.dolly.svc.cluster.local testnav-helsepersonell-service: - url: https://testnav-helsepersonell-service.intern.dev.nav.no + url: http://testnav-helsepersonell-service.dolly.svc.cluster.local + sykemelding-api: + url: http://testnav-sykemelding-api-dev.dolly.svc.cluster.local + name: testnav-sykemelding-api-dev diff --git a/apps/synt-sykemelding-api/src/main/resources/application-local.yml b/apps/synt-sykemelding-api/src/main/resources/application-local.yml new file mode 100644 index 00000000000..e77e1c2c6af --- /dev/null +++ b/apps/synt-sykemelding-api/src/main/resources/application-local.yml @@ -0,0 +1,13 @@ + +consumers: + synt-sykemelding: + url: https://synthdata-elsam-gcp.intern.dev.nav.no + testnav-organisasjon-service: + url: https://testnav-organisasjon-service.intern.dev.nav.no + testnav-arbeidsforhold-service: + url: https://testnav-arbeidsforhold-service.intern.dev.nav.no + testnav-helsepersonell-service: + url: https://testnav-helsepersonell-service.intern.dev.nav.no + sykemelding-api: + url: https://testnav-sykemelding-api-dev.intern.dev.nav.no + name: testnav-sykemelding-api-dev \ No newline at end of file diff --git a/apps/synt-sykemelding-api/src/main/resources/application-prod.yml b/apps/synt-sykemelding-api/src/main/resources/application-prod.yml new file mode 100644 index 00000000000..0311ce578e3 --- /dev/null +++ b/apps/synt-sykemelding-api/src/main/resources/application-prod.yml @@ -0,0 +1,8 @@ +spring: + security: + oauth2: + resourceserver: + tokenx: + issuer-uri: ${TOKEN_X_ISSUER} + jwk-set-uri: ${TOKEN_X_JWKS_URI} + accepted-audience: ${TOKEN_X_CLIENT_ID} \ No newline at end of file diff --git a/apps/synt-sykemelding-api/src/main/resources/application.yml b/apps/synt-sykemelding-api/src/main/resources/application.yml index 11992aca432..424f21bfb59 100644 --- a/apps/synt-sykemelding-api/src/main/resources/application.yml +++ b/apps/synt-sykemelding-api/src/main/resources/application.yml @@ -12,10 +12,6 @@ spring: issuer-uri: ${AAD_ISSUER_URI}/v2.0 jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys accepted-audience: ${azure.app.client.id}, api://${azure.app.client.id} - tokenx: - issuer-uri: ${TOKEN_X_ISSUER} - jwk-set-uri: ${TOKEN_X_JWKS_URI} - accepted-audience: ${TOKEN_X_CLIENT_ID} cloud: vault: enabled: false diff --git a/apps/synt-sykemelding-api/src/main/resources/logback-spring.xml b/apps/synt-sykemelding-api/src/main/resources/logback-spring.xml index 7309420d4fd..75c5be52d1c 100644 --- a/apps/synt-sykemelding-api/src/main/resources/logback-spring.xml +++ b/apps/synt-sykemelding-api/src/main/resources/logback-spring.xml @@ -1,6 +1,6 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumerTest.java b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumerTest.java index 79c2b3dea2a..9ba6c0c1b47 100644 --- a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumerTest.java +++ b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumerTest.java @@ -8,7 +8,6 @@ import no.nav.testnav.apps.syntsykemeldingapi.domain.Person; import no.nav.testnav.apps.syntsykemeldingapi.domain.Sykemelding; import no.nav.testnav.apps.syntsykemeldingapi.domain.pdl.PdlPerson; -import no.nav.testnav.apps.syntsykemeldingapi.exception.LagreSykemeldingException; import no.nav.testnav.libs.dto.helsepersonell.v1.HelsepersonellListeDTO; import no.nav.testnav.libs.dto.oppsummeringsdokumentservice.v1.ArbeidsforholdDTO; import no.nav.testnav.libs.dto.organisasjon.v1.OrganisasjonDTO; @@ -30,24 +29,25 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.server.ResponseStatusException; import reactor.core.publisher.Mono; import java.time.LocalDate; import java.util.Map; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.ok; import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; -import static com.github.tomakehurst.wiremock.client.WireMock.ok; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestPdlPerson; -import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestHistorikk; import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestArbeidsforholdDTO; +import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestHistorikk; import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestLegeListeDTO; import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestOrganisasjonDTO; +import static no.nav.testnav.apps.syntsykemeldingapi.util.TestUtil.getTestPdlPerson; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.when; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; @ActiveProfiles("test") @RunWith(SpringRunner.class) @@ -126,7 +126,7 @@ public void shouldPostSykemeldingUtenFeil() { @Test public void shouldGetFeil() { stubSykemeldingError(); - assertThrows(LagreSykemeldingException.class, () -> sykemeldingConsumer.opprettSykemelding(sykemeldingRequest)); + assertThrows(ResponseStatusException.class, () -> sykemeldingConsumer.opprettSykemelding(sykemeldingRequest)); } private void stubSykemelding() { diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/SykemeldingResponseDTO.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/SykemeldingResponseDTO.java new file mode 100644 index 00000000000..e299b10962a --- /dev/null +++ b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/SykemeldingResponseDTO.java @@ -0,0 +1,17 @@ +package no.nav.testnav.libs.dto.sykemelding.v1; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.http.HttpStatus; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SykemeldingResponseDTO { + + private HttpStatus status; + private String sykemeldingId; +} diff --git a/libs/reactive-proxy/package-lock.json b/libs/reactive-proxy/package-lock.json new file mode 100644 index 00000000000..34301f6bd76 --- /dev/null +++ b/libs/reactive-proxy/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "reactive-proxy", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/proxies/pdl-proxy/config.yml b/proxies/pdl-proxy/config.yml index b5a88f48086..a685d4fd29e 100644 --- a/proxies/pdl-proxy/config.yml +++ b/proxies/pdl-proxy/config.yml @@ -57,6 +57,8 @@ spec: cluster: dev-gcp - application: testnav-synt-sykemelding-api cluster: dev-gcp + - application: testnav-synt-sykemelding-api-dev + cluster: dev-gcp - application: testnav-helsepersonell-service cluster: dev-gcp - application: testnav-tenor-search-service