Skip to content

Commit ea26d4c

Browse files
authored
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.
1 parent de9bc7e commit ea26d4c

File tree

56 files changed

+563
-338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+563
-338
lines changed

.github/workflows/app.sykemelding-api.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
cluster: "dev-gcp"
1818
working-directory: "apps/sykemelding-api"
1919
deploy-tag: "#deploy-sykemelding-api"
20+
deploy-tag-test: "#deploy-test-sykemelding-api"
2021
permissions:
2122
contents: read
2223
id-token: write

.github/workflows/app.synt-sykemelding-api.yml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
with:
2020
working-directory: "apps/synt-sykemelding-api"
2121
deploy-tag: "#deploy-synt-sykemelding-api"
22+
deploy-tag-test: "#deploy-test-synt-sykemelding-api"
2223
permissions:
2324
contents: read
2425
id-token: write

apps/arbeidsforhold-service/config.yml

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ spec:
2828
cluster: dev-gcp
2929
- application: testnav-synt-sykemelding-api
3030
cluster: dev-gcp
31+
- application: testnav-synt-sykemelding-api-dev
32+
cluster: dev-gcp
3133
outbound:
3234
external:
3335
- host: testnav-aareg-proxy.dev-fss-pub.nais.io

apps/arbeidsforhold-service/src/main/java/no/nav/registre/testnorge/arbeidsforholdservice/ArbeidsforholdApiApplicationStarter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ public class ArbeidsforholdApiApplicationStarter {
99
public static void main(String[] args) {
1010
SpringApplication.run(ArbeidsforholdApiApplicationStarter.class, args);
1111
}
12-
}
12+
}

apps/dolly-backend/config.test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ spec:
3939
- application: testnav-person-service
4040
- application: testnav-skattekort-service
4141
- application: testnav-sykemelding-api
42+
- application: testnav-sykemelding-api-dev
4243
- application: testnav-synt-sykemelding-api
44+
- application: testnav-synt-sykemelding-api-dev
4345
- application: testnav-tps-messaging-service
4446
- application: testnav-yrkesskade-proxy
4547
- application: testnorge-profil-api-dev

apps/dolly-backend/src/main/java/no/nav/dolly/DollyBackendApplicationStarter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ public static void main(String[] args) {
1010

1111
SpringApplication.run(DollyBackendApplicationStarter.class, args);
1212
}
13-
}
13+
}

apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/SykemeldingClient.java

+1
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ private void saveTransaksjonId(SykemeldingResponse sykemelding, Long bestillingI
188188

189189
log.info("Lagrer transaksjon for {} i q1 ", sykemelding.getIdent());
190190

191+
sykemelding.getSykemeldingRequest().setSykemeldingId(sykemelding.getMsgId());
191192
transaksjonMappingService.save(TransaksjonMapping.builder()
192193
.ident(sykemelding.getIdent())
193194
.bestillingId(bestillingId)

apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/command/SykemeldingPostCommand.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package no.nav.dolly.bestilling.sykemelding.command;
22

33
import lombok.RequiredArgsConstructor;
4+
import lombok.extern.slf4j.Slf4j;
45
import no.nav.dolly.bestilling.sykemelding.domain.DetaljertSykemeldingRequest;
56
import no.nav.dolly.bestilling.sykemelding.dto.SykemeldingResponse;
7+
import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingResponseDTO;
68
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter;
79
import no.nav.testnav.libs.securitycore.config.UserConstant;
810
import org.springframework.http.HttpHeaders;
9-
import org.springframework.http.HttpStatus;
1011
import org.springframework.web.reactive.function.client.WebClient;
1112
import reactor.core.publisher.Mono;
1213
import reactor.util.retry.Retry;
@@ -16,6 +17,7 @@
1617

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

20+
@Slf4j
1921
@RequiredArgsConstructor
2022
public class SykemeldingPostCommand implements Callable<Mono<SykemeldingResponse>> {
2123

@@ -35,10 +37,10 @@ public Mono<SykemeldingResponse> call() {
3537
.header(UserConstant.USER_HEADER_JWT, getUserJwt())
3638
.bodyValue(request)
3739
.retrieve()
38-
.toBodilessEntity()
39-
.timeout(Duration.ofMinutes(4))
40+
.bodyToMono(SykemeldingResponseDTO.class)
4041
.map(response -> SykemeldingResponse.builder()
41-
.status(HttpStatus.valueOf(response.getStatusCode().value()))
42+
.status(response.getStatus())
43+
.msgId(response.getSykemeldingId())
4244
.ident(request.getPasient().getIdent())
4345
.sykemeldingRequest(SykemeldingResponse.SykemeldingRequest.builder()
4446
.detaljertSykemeldingRequest(request)

apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/command/SyntSykemeldingPostCommand.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import lombok.RequiredArgsConstructor;
44
import no.nav.dolly.bestilling.sykemelding.domain.SyntSykemeldingRequest;
55
import no.nav.dolly.bestilling.sykemelding.dto.SykemeldingResponse;
6+
import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingResponseDTO;
67
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter;
78
import no.nav.testnav.libs.securitycore.config.UserConstant;
89
import org.springframework.http.HttpHeaders;
9-
import org.springframework.http.HttpStatus;
1010
import org.springframework.web.reactive.function.client.WebClient;
1111
import reactor.core.publisher.Mono;
1212
import reactor.util.retry.Retry;
@@ -34,10 +34,10 @@ public Mono<SykemeldingResponse> call() {
3434
.header(UserConstant.USER_HEADER_JWT, getUserJwt())
3535
.bodyValue(sykemeldingRequest)
3636
.retrieve()
37-
.toBodilessEntity()
38-
.timeout(Duration.ofMinutes(4))
37+
.bodyToMono(SykemeldingResponseDTO.class)
3938
.map(response -> SykemeldingResponse.builder()
40-
.status(HttpStatus.valueOf(response.getStatusCode().value()))
39+
.status(response.getStatus())
40+
.msgId(response.getSykemeldingId())
4141
.ident(sykemeldingRequest.getIdent())
4242
.sykemeldingRequest(SykemeldingResponse.SykemeldingRequest.builder()
4343
.syntSykemeldingRequest(sykemeldingRequest)

apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/sykemelding/dto/SykemeldingResponse.java

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class SykemeldingResponse {
1818
private HttpStatus status;
1919
private String avvik;
2020
private SykemeldingRequest sykemeldingRequest;
21+
private String msgId;
2122
private String ident;
2223

2324
@Data
@@ -27,6 +28,7 @@ public class SykemeldingResponse {
2728
@JsonInclude(JsonInclude.Include.NON_EMPTY)
2829
public static class SykemeldingRequest {
2930

31+
private String sykemeldingId;
3032
private SyntSykemeldingRequest syntSykemeldingRequest;
3133
private DetaljertSykemeldingRequest detaljertSykemeldingRequest;
3234
}

apps/dolly-backend/src/main/java/no/nav/dolly/consumer/kodeverk/command/KodeverkGetCommand.java

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import no.nav.testnav.libs.dto.kodeverkservice.v1.KodeverkDTO;
55
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter;
66
import org.springframework.http.HttpHeaders;
7+
import org.springframework.http.HttpStatus;
78
import org.springframework.web.reactive.function.client.WebClient;
89
import reactor.core.publisher.Mono;
910
import reactor.util.retry.Retry;
@@ -31,6 +32,10 @@ public Mono<KodeverkDTO> call() {
3132
.header(HttpHeaders.AUTHORIZATION, "Bearer " + token)
3233
.retrieve()
3334
.bodyToMono(KodeverkDTO.class)
35+
.map(kodeverket -> {
36+
kodeverket.setStatus(HttpStatus.OK);
37+
return kodeverket;
38+
})
3439
.doOnError(WebClientFilter::logErrorMessage)
3540
.onErrorResume(error -> Mono.just(KodeverkDTO.builder()
3641
.kodeverknavn(kodeverk)

apps/dolly-backend/src/main/java/no/nav/dolly/errorhandling/ErrorStatusDecoder.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ public String getStatusMessage(String json) {
102102
if (json.contains("{")) {
103103
try {
104104
Map<String, Object> status = objectMapper.readValue(json, Map.class);
105-
if (status.containsKey(ERROR) && isNotBlank((String) status.get(ERROR))) {
106-
builder.append("error=").append(status.get(ERROR)).append("; ");
107-
} else if (status.containsKey(MESSAGE) && isNotBlank((String) status.get(MESSAGE))) {
105+
if (status.containsKey(MESSAGE) && isNotBlank((String) status.get(MESSAGE))) {
108106
builder.append("message=").append(encodeStatus((String) status.get(MESSAGE))).append("; ");
107+
} else if (status.containsKey(ERROR) && isNotBlank((String) status.get(ERROR))) {
108+
builder.append("error=").append(status.get(ERROR)).append("; ");
109109
} else if (status.containsKey(MELDING) && isNotBlank((String) status.get(MELDING))) {
110110
builder.append(encodeStatus((String) status.get(MELDING)));
111111
} else if (status.containsKey(DETAILS) && status.get(DETAILS) instanceof List) {

apps/dolly-backend/src/main/resources/application-dev.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ consumers:
2222
testnav-pdl-forvalter:
2323
name: testnav-pdl-forvalter-dev
2424
url: http://testnav-pdl-forvalter-dev.dolly.svc.cluster.local
25+
testnav-sykemelding-api:
26+
name: testnav-sykemelding-api-dev
27+
url: http://testnav-sykemelding-api-dev.dolly.svc.cluster.local
28+
testnav-synt-sykemelding-api:
29+
name: testnav-synt-sykemelding-api-dev
30+
url: http://testnav-synt-sykemelding-api-dev.dolly.svc.cluster.local

apps/dolly-backend/src/main/resources/application-local.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ consumers:
5454
testnav-organisasjon-service:
5555
url: https://testnav-organisasjon-service.intern.dev.nav.no
5656
testnav-synt-sykemelding-api:
57-
url: https://testnav-synt-sykemelding-api.intern.dev.nav.no
57+
name: testnav-synt-sykemelding-api-dev
58+
url: https://testnav-synt-sykemelding-api-dev.intern.dev.nav.no
5859
testnav-sykemelding-api:
59-
url: http://testnav-sykemelding-api.intern.dev.nav.no
60+
name: testnav-sykemelding-api-dev
61+
url: https://testnav-sykemelding-api-dev.intern.dev.nav.no
6062
testnav-miljoer-service:
6163
url: https://testnav-miljoer-service.intern.dev.nav.no
6264
testnav-arbeidsplassencv-proxy:

0 commit comments

Comments
 (0)