Skip to content

Commit

Permalink
Feature/sykemelding forbedre status tilbakemelding (#3681)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
krharum authored Nov 28, 2024
1 parent de9bc7e commit ea26d4c
Show file tree
Hide file tree
Showing 56 changed files with 563 additions and 338 deletions.
1 change: 1 addition & 0 deletions .github/workflows/app.sykemelding-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/app.synt-sykemelding-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions apps/arbeidsforhold-service/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ public class ArbeidsforholdApiApplicationStarter {
public static void main(String[] args) {
SpringApplication.run(ArbeidsforholdApiApplicationStarter.class, args);
}
}
}
2 changes: 2 additions & 0 deletions apps/dolly-backend/config.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public static void main(String[] args) {

SpringApplication.run(DollyBackendApplicationStarter.class, args);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,6 +17,7 @@

import static no.nav.dolly.util.TokenXUtil.getUserJwt;

@Slf4j
@RequiredArgsConstructor
public class SykemeldingPostCommand implements Callable<Mono<SykemeldingResponse>> {

Expand All @@ -35,10 +37,10 @@ public Mono<SykemeldingResponse> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -34,10 +34,10 @@ public Mono<SykemeldingResponse> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class SykemeldingResponse {
private HttpStatus status;
private String avvik;
private SykemeldingRequest sykemeldingRequest;
private String msgId;
private String ident;

@Data
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -31,6 +32,10 @@ public Mono<KodeverkDTO> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ public String getStatusMessage(String json) {
if (json.contains("{")) {
try {
Map<String, Object> 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) {
Expand Down
6 changes: 6 additions & 0 deletions apps/dolly-backend/src/main/resources/application-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions apps/dolly-backend/src/main/resources/application-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading

0 comments on commit ea26d4c

Please sign in to comment.