Repository: Sundsvallskommun/api-service-case-status
Pull request #160: UF-15151 SupportManagement mapping
Author: login: AndreSoderlund
Created: 2025-03-24T15:17:41Z | Merged: 2025-03-25T07:22:58Z

* Updated mapping for SupportManagment. 
* Refactored parts of the CaseStatusService for easier readability and testability.

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] Bug fix
- [x] New feature
- [ ] Removed feature
- [x] Code style update (formatting etc.)
- [x] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] Documentation content changes
- [ ] Content/Data

## Does this PR introduce a breaking change?
- [ ] Yes (I have stepped the version number accordingly)
- [x] No
      
## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [x] My code follows the code style of this project.
- [x] I have updated the documentation accordingly (if applicable).
- [x] I have added/updated tests to cover my changes (if applicable).



Diff:
diff --git a/src/integration-test/resources/GetPartyStatusesIT/__files/test1_successful/expected-response.json b/src/integration-test/resources/GetPartyStatusesIT/__files/test1_successful/expected-response.json
index bbf79185..bc1d4080 100644
--- a/src/integration-test/resources/GetPartyStatusesIT/__files/test1_successful/expected-response.json
+++ b/src/integration-test/resources/GetPartyStatusesIT/__files/test1_successful/expected-response.json
@@ -5,6 +5,9 @@
 		"status": "SOLVED",
 		"firstSubmitted": "2023-03-20 20:49",
 		"lastStatusChange": "2023-03-23 07:34",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23030203",
 		"openEErrand": false
 	},
 	{
@@ -13,6 +16,9 @@
 		"status": "ONGOING",
 		"firstSubmitted": "2023-05-17 09:10",
 		"lastStatusChange": "2023-05-23 08:59",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23050067",
 		"openEErrand": false
 	},
 	{
@@ -21,6 +27,9 @@
 		"status": "SOLVED",
 		"firstSubmitted": "2023-03-28 15:54",
 		"lastStatusChange": "2023-03-29 11:22",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23030293",
 		"openEErrand": false
 	},
 	{
@@ -29,6 +38,9 @@
 		"status": "SOLVED",
 		"firstSubmitted": "2023-03-22 20:12",
 		"lastStatusChange": "2023-03-22 20:13",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23030255",
 		"openEErrand": false
 	},
 	{
@@ -37,6 +49,9 @@
 		"status": "SOLVED",
 		"firstSubmitted": "2023-03-17 09:53",
 		"lastStatusChange": "2023-03-20 14:35",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23030168",
 		"openEErrand": false
 	},
 	{
@@ -45,6 +60,9 @@
 		"status": "SOLVED",
 		"firstSubmitted": "2023-03-16 07:28",
 		"lastStatusChange": "2023-03-16 15:49",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23030112",
 		"openEErrand": false
 	},
 	{
@@ -53,6 +71,9 @@
 		"status": "ONGOING",
 		"firstSubmitted": "2023-04-28 11:00",
 		"lastStatusChange": "2023-05-30 10:58",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23040114",
 		"openEErrand": false
 	},
 	{
@@ -61,6 +82,9 @@
 		"status": "SOLVED",
 		"firstSubmitted": "2023-03-17 14:50",
 		"lastStatusChange": "2023-03-20 14:36",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23030183",
 		"openEErrand": false
 	},
 	{
@@ -69,6 +93,9 @@
 		"status": "ONGOING",
 		"firstSubmitted": "2023-10-03 19:38",
 		"lastStatusChange": "2023-10-27 14:18",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23100010",
 		"openEErrand": false
 	},
 	{
@@ -77,6 +104,9 @@
 		"status": "SOLVED",
 		"firstSubmitted": "2023-08-25 09:24",
 		"lastStatusChange": "2023-08-25 09:27",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23080036",
 		"openEErrand": false
 	},
 	{
@@ -85,6 +115,9 @@
 		"status": "NEW",
 		"firstSubmitted": "2023-03-29 15:31",
 		"lastStatusChange": "2024-04-19 13:44",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23030302",
 		"openEErrand": false
 	},
 	{
@@ -93,6 +126,9 @@
 		"status": "NEW",
 		"firstSubmitted": "2023-03-22 16:58",
 		"lastStatusChange": "2023-03-29 15:07",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23030249",
 		"openEErrand": false
 	},
 	{
@@ -101,6 +137,9 @@
 		"status": "SOLVED",
 		"firstSubmitted": "2023-03-20 10:27",
 		"lastStatusChange": "2023-03-20 14:15",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23030198",
 		"openEErrand": false
 	},
 	{
@@ -109,6 +148,9 @@
 		"status": "SOLVED",
 		"firstSubmitted": "2023-03-17 09:48",
 		"lastStatusChange": "2023-03-17 09:49",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23030167",
 		"openEErrand": false
 	},
 	{
@@ -117,6 +159,9 @@
 		"status": "ONGOING",
 		"firstSubmitted": "2024-04-05 08:08",
 		"lastStatusChange": "2024-04-05 08:09",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-24040011",
 		"openEErrand": false
 	},
 	{
@@ -125,6 +170,9 @@
 		"status": "NEW",
 		"firstSubmitted": "2023-10-03 19:30",
 		"lastStatusChange": "2023-10-03 19:31",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23100009",
 		"openEErrand": false
 	},
 	{
@@ -133,6 +181,9 @@
 		"status": "SOLVED",
 		"firstSubmitted": "2023-03-14 11:21",
 		"lastStatusChange": "2023-03-14 13:27",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23030013",
 		"openEErrand": false
 	},
 	{
@@ -141,6 +192,9 @@
 		"status": "SOLVED",
 		"firstSubmitted": "2024-04-05 15:15",
 		"lastStatusChange": "2024-04-05 15:19",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-24040015",
 		"openEErrand": false
 	},
 	{
@@ -149,6 +203,9 @@
 		"status": "SOLVED",
 		"firstSubmitted": "2023-03-17 14:53",
 		"lastStatusChange": "2023-03-17 15:24",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23030186",
 		"openEErrand": false
 	},
 	{
@@ -157,6 +214,9 @@
 		"status": "SOLVED",
 		"firstSubmitted": "2023-04-28 13:36",
 		"lastStatusChange": "2023-04-28 13:38",
+		"system": "SUPPORT_MANAGEMENT",
+		"namespace": "MYNAMESPACE",
+		"errandNumber": "KC-23040116",
 		"openEErrand": false
 	},
 	{
diff --git a/src/integration-test/resources/GetPartyStatusesIT/__files/test2_not_found_in_casemanagement_but_match_in_opene_and_casestatus_db/expected-response.json b/src/integration-test/resources/GetPartyStatusesIT/__files/test2_not_found_in_casemanagement_but_match_in_opene_and_casestatus_db/expected-response.json
index 16c757f6..2257161f 100644
--- a/src/integration-test/resources/GetPartyStatusesIT/__files/test2_not_found_in_casemanagement_but_match_in_opene_and_casestatus_db/expected-response.json
+++ b/src/integration-test/resources/GetPartyStatusesIT/__files/test2_not_found_in_casemanagement_but_match_in_opene_and_casestatus_db/expected-response.json
@@ -2,9 +2,13 @@
 	{
 		"caseId": "ec677eb3-604c-4935-bff7-f8f0b500c8f4",
 		"caseType": "TYPE-1",
+		"errandNumber": "KC-23020001",
 		"firstSubmitted": "2022-01-01 12:00",
+		"lastStatusChange": "Saknas",
+		"namespace": "MYNAMESPACE",
 		"openEErrand": false,
-		"status": "STATUS-1"
+		"status": "STATUS-1",
+		"system": "SUPPORT_MANAGEMENT"
 	},
 	{
 		"caseType": "Kontakt med SC Lön och Pension - TEST DRAKEN",
diff --git a/src/integration-test/resources/GetPartyStatusesIT/__files/test3_not_found_in_opene_or_casemanagement_but_in_db/expected-response.json b/src/integration-test/resources/GetPartyStatusesIT/__files/test3_not_found_in_opene_or_casemanagement_but_in_db/expected-response.json
index 5f4ecf94..44dfca5f 100644
--- a/src/integration-test/resources/GetPartyStatusesIT/__files/test3_not_found_in_opene_or_casemanagement_but_in_db/expected-response.json
+++ b/src/integration-test/resources/GetPartyStatusesIT/__files/test3_not_found_in_opene_or_casemanagement_but_in_db/expected-response.json
@@ -2,9 +2,13 @@
 	{
 		"caseId": "ec677eb3-604c-4935-bff7-f8f0b500c8f4",
 		"caseType": "TYPE-1",
+		"errandNumber": "KC-23020001",
 		"firstSubmitted": "2022-01-01 12:00",
+		"lastStatusChange": "Saknas",
+		"namespace": "MYNAMESPACE",
 		"openEErrand": false,
-		"status": "STATUS-1"
+		"status": "STATUS-1",
+		"system": "SUPPORT_MANAGEMENT"
 	},
 	{
 		"caseType": "Beställa nybyggnadskarta",
diff --git a/src/main/java/se/sundsvall/casestatus/api/model/CaseStatusResponse.java b/src/main/java/se/sundsvall/casestatus/api/model/CaseStatusResponse.java
index 7514476e..b32e156d 100644
--- a/src/main/java/se/sundsvall/casestatus/api/model/CaseStatusResponse.java
+++ b/src/main/java/se/sundsvall/casestatus/api/model/CaseStatusResponse.java
@@ -18,7 +18,7 @@ public class CaseStatusResponse {
 	private String caseId;
 
 	@Schema(description = "External case id", example = "1234567890")
-	private String externalCaseId; // TODO: Ta bort när samtliga mappningar är uppdaterade
+	private String externalCaseId;
 
 	@Schema(description = "Case type", example = "Building permit")
 	private String caseType;
diff --git a/src/main/java/se/sundsvall/casestatus/integration/opene/soap/OpenECallbackIntegration.java b/src/main/java/se/sundsvall/casestatus/integration/opene/soap/OpenECallbackIntegration.java
index e950c3a8..47f37781 100644
--- a/src/main/java/se/sundsvall/casestatus/integration/opene/soap/OpenECallbackIntegration.java
+++ b/src/main/java/se/sundsvall/casestatus/integration/opene/soap/OpenECallbackIntegration.java
@@ -1,7 +1,7 @@
 package se.sundsvall.casestatus.integration.opene.soap;
 
-import static se.sundsvall.casestatus.utility.Constants.EXTERNAL_CHANNEL_E_SERVICE;
-import static se.sundsvall.casestatus.utility.Constants.INTERNAL_CHANNEL_E_SERVICE;
+import static se.sundsvall.casestatus.util.Constants.EXTERNAL_CHANNEL_E_SERVICE;
+import static se.sundsvall.casestatus.util.Constants.INTERNAL_CHANNEL_E_SERVICE;
 
 import generated.se.sundsvall.opene.SetStatus;
 import generated.se.sundsvall.opene.SetStatusResponse;
diff --git a/src/main/java/se/sundsvall/casestatus/service/CaseStatusService.java b/src/main/java/se/sundsvall/casestatus/service/CaseStatusService.java
index 92b3fee4..b0f29d35 100644
--- a/src/main/java/se/sundsvall/casestatus/service/CaseStatusService.java
+++ b/src/main/java/se/sundsvall/casestatus/service/CaseStatusService.java
@@ -2,16 +2,19 @@
 
 import static generated.se.sundsvall.party.PartyType.ENTERPRISE;
 import static generated.se.sundsvall.party.PartyType.PRIVATE;
+import static java.util.Collections.emptyList;
 import static java.util.stream.Collectors.toList;
 import static se.sundsvall.casestatus.service.Mapper.toCasePdfResponse;
 import static se.sundsvall.casestatus.service.Mapper.toOepStatusResponse;
-import static se.sundsvall.casestatus.utility.Constants.MISSING;
+import static se.sundsvall.casestatus.service.mapper.SupportManagementMapper.toCaseStatusResponse;
+import static se.sundsvall.casestatus.util.Constants.MISSING;
+import static se.sundsvall.casestatus.util.FormattingUtil.getFormattedOrganizationNumber;
 
-import java.time.format.DateTimeFormatter;
+import generated.se.sundsvall.party.PartyType;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
-import java.util.stream.IntStream;
 import org.springframework.stereotype.Service;
 import org.zalando.problem.Problem;
 import org.zalando.problem.Status;
@@ -29,7 +32,6 @@
 @Service
 public class CaseStatusService {
 
-	static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
 	private static final String CASE_NOT_FOUND = "Case with id %s not found";
 	private final CaseManagementIntegration caseManagementIntegration;
 	private final OpenEIntegration openEIntegration;
@@ -97,49 +99,64 @@ public List<CaseStatusResponse> getCaseStatuses(final String organizationNumber,
 	public List<CaseStatusResponse> getCaseStatusesForParty(final String partyId, final String municipalityId) {
 		final var partyResult = partyIntegration.getLegalIdByPartyId(municipalityId, partyId);
 
-		final var result = caseManagementIntegration.getCaseStatusForPartyId(partyId, municipalityId).stream()
-			.map(dto -> caseManagementMapper.toCaseStatusResponse(dto, municipalityId))
-			.collect(toList());
-
 		if (partyResult.containsKey(PRIVATE)) {
+			var statuses = getPrivateCaseStatuses(partyId, partyResult, municipalityId);
+			return filterResponse(statuses);
+		} else if (partyResult.containsKey(ENTERPRISE)) {
+			var statuses = getEnterpriseCaseStatuses(partyId, partyResult, municipalityId);
+			return filterResponse(statuses);
+		}
+		return emptyList();
+	}
 
-			openEIntegration.getCaseStatuses(municipalityId, partyResult.get(PRIVATE)).stream()
-				.map(Mapper::mapToCaseStatusResponse)
-				.forEach(result::add);
+	List<CaseStatusResponse> getPrivateCaseStatuses(final String partyId, final Map<PartyType, String> partyMap, final String municipalityId) {
+		List<CaseStatusResponse> statuses = new ArrayList<>();
+		var legalId = partyMap.get(PRIVATE);
 
-			caseRepository.findByPersonIdAndMunicipalityId(partyId, municipalityId).stream()
-				.map(Mapper::mapToCaseStatusResponse)
-				.forEach(result::add);
+		caseManagementIntegration.getCaseStatusForPartyId(partyId, municipalityId).stream()
+			.map(dto -> caseManagementMapper.toCaseStatusResponse(dto, municipalityId))
+			.forEach(statuses::add);
 
-			final var filterString = "stakeholders.externalId:'%s'".formatted(partyId);
-			supportManagementService.getSupportManagementCases(municipalityId, filterString).stream()
-				.map(Mapper::toCaseStatusResponse)
-				.forEach(result::add);
+		openEIntegration.getCaseStatuses(municipalityId, legalId).stream()
+			.map(Mapper::mapToCaseStatusResponse)
+			.forEach(statuses::add);
 
-			return filterResponse(result);
+		caseRepository.findByPersonIdAndMunicipalityId(partyId, municipalityId).stream()
+			.map(Mapper::mapToCaseStatusResponse)
+			.forEach(statuses::add);
 
-		} else if (partyResult.containsKey(ENTERPRISE)) {
+		final var filterString = "stakeholders.externalId:'%s'".formatted(partyId);
+		supportManagementService.getSupportManagementCases(municipalityId, filterString)
+			.forEach((namespace, errands) -> errands.stream()
+				.map(errand -> toCaseStatusResponse(errand, namespace))
+				.forEach(statuses::add));
+
+		return statuses;
+	}
 
-			// Due to discrepancies in the organization number format in open-E, we need to check both the original and the
-			// formatted number.
-			final var legalId = getFormattedOrganizationNumber(partyResult.get(ENTERPRISE));
+	List<CaseStatusResponse> getEnterpriseCaseStatuses(final String partyId, final Map<PartyType, String> partyMap, final String municipalityId) {
+		List<CaseStatusResponse> statuses = new ArrayList<>();
+		var legalId = partyMap.get(ENTERPRISE);
 
-			final var cachedStatusesUnformatted = caseRepository.findByOrganisationNumberAndMunicipalityId(partyResult.get(ENTERPRISE), municipalityId).stream()
-				.map(Mapper::mapToCaseStatusResponse)
-				.toList();
+		// Fetching statuses from CaseManagement.
+		caseManagementIntegration.getCaseStatusForPartyId(partyId, municipalityId).stream()
+			.map(dto -> caseManagementMapper.toCaseStatusResponse(dto, municipalityId))
+			.forEach(statuses::add);
 
-			final var cachedStatusesFormatted = caseRepository.findByOrganisationNumberAndMunicipalityId(legalId, municipalityId).stream()
-				.map(Mapper::mapToCaseStatusResponse)
-				.toList();
+		// Fetching cached statuses for the given organization number.
+		caseRepository.findByOrganisationNumberAndMunicipalityId(legalId, municipalityId).stream()
+			.map(Mapper::mapToCaseStatusResponse)
+			.forEach(statuses::add);
 
-			result.addAll(cachedStatusesUnformatted);
-			result.addAll(cachedStatusesFormatted);
-		}
+		// Fetching cached statuses for the formatted organization number.
+		caseRepository.findByOrganisationNumberAndMunicipalityId(getFormattedOrganizationNumber(legalId), municipalityId).stream()
+			.map(Mapper::mapToCaseStatusResponse)
+			.forEach(statuses::add);
 
-		return result;
+		return statuses;
 	}
 
-	private List<CaseStatusResponse> filterResponse(final List<CaseStatusResponse> request) {
+	List<CaseStatusResponse> filterResponse(final List<CaseStatusResponse> request) {
 		// Filter out cases without external case id as duplicates will only be appearing in the list with external case id
 		final var casesWithoutExternalCaseId = request.stream()
 			.filter(response -> response.getExternalCaseId() == null)
@@ -167,22 +184,4 @@ private List<CaseStatusResponse> filterResponse(final List<CaseStatusResponse> r
 		return result;
 	}
 
-	private String getFormattedOrganizationNumber(final String organizationNumber) {
-
-		// Control that the organizationNumber is not null and that it is a valid length
-		if (IntStream.of(13, 12, 11, 10).anyMatch(i -> organizationNumber.length() == i)) {
-			// Remove all non-digit characters
-			final String cleanNumber = organizationNumber.replaceAll("\\D", "");
-
-			if (cleanNumber.length() == 12) {
-				// Insert the hyphen at the correct position
-				return cleanNumber.substring(0, 8) + "-" + cleanNumber.substring(8);
-
-			}
-			if (cleanNumber.length() == 10) {
-				return cleanNumber.substring(0, 6) + "-" + cleanNumber.substring(6);
-			}
-		}
-		return organizationNumber;
-	}
 }
diff --git a/src/main/java/se/sundsvall/casestatus/service/Mapper.java b/src/main/java/se/sundsvall/casestatus/service/Mapper.java
index 2a328e55..d66bb005 100644
--- a/src/main/java/se/sundsvall/casestatus/service/Mapper.java
+++ b/src/main/java/se/sundsvall/casestatus/service/Mapper.java
@@ -1,13 +1,8 @@
 package se.sundsvall.casestatus.service;
 
-import static se.sundsvall.casestatus.service.CaseStatusService.DATE_TIME_FORMATTER;
-import static se.sundsvall.casestatus.utility.Constants.MISSING;
+import static se.sundsvall.casestatus.util.Constants.MISSING;
 
 import generated.se.sundsvall.casemanagement.CaseStatusDTO;
-import generated.se.sundsvall.opene.SetStatus;
-import generated.se.sundsvall.supportmanagement.Errand;
-import generated.se.sundsvall.supportmanagement.ExternalTag;
-import java.util.Optional;
 import se.sundsvall.casestatus.api.model.CasePdfResponse;
 import se.sundsvall.casestatus.api.model.CaseStatusResponse;
 import se.sundsvall.casestatus.api.model.OepStatusResponse;
@@ -42,39 +37,6 @@ static CaseStatusResponse toCaseStatusResponse(final CaseStatusDTO caseStatus, f
 			.build();
 	}
 
-	static CaseStatusResponse toCaseStatusResponse(final Errand errand) {
-		final var externalCaseId = getExternalCaseId(errand);
-
-		final var modified = Optional.ofNullable(errand.getModified())
-			.map(modifiedDate -> modifiedDate.format(DATE_TIME_FORMATTER))
-			.orElse(null);
-
-		return CaseStatusResponse.builder()
-			.withCaseId(errand.getId())
-			.withExternalCaseId(externalCaseId.orElse(null))
-			.withCaseType(errand.getClassification().getType())
-			.withStatus(errand.getStatus())
-			.withLastStatusChange(modified)
-			.withFirstSubmitted(errand.getCreated().format(DATE_TIME_FORMATTER))
-			.withIsOpenEErrand(externalCaseId.isPresent())
-			.build();
-	}
-
-	public static CaseEntity toCaseEntity(final Errand errand, final String municipalityId) {
-
-		final var externalCaseId = getExternalCaseId(errand);
-
-		return CaseEntity.builder()
-			.withFlowInstanceId(externalCaseId.orElse(null))
-			.withFamilyId(getFamilyID(errand).orElse(null))
-			.withStatus(errand.getStatus())
-			.withErrandType(errand.getClassification().getType())
-			.withFirstSubmitted(errand.getCreated().format(DATE_TIME_FORMATTER))
-			.withLastStatusChange(errand.getModified().format(DATE_TIME_FORMATTER))
-			.withMunicipalityId(municipalityId)
-			.build();
-	}
-
 	static CasePdfResponse toCasePdfResponse(final String externalCaseId, final String pdf) {
 		return CasePdfResponse.builder()
 			.withExternalCaseId(externalCaseId)
@@ -89,34 +51,4 @@ static OepStatusResponse toOepStatusResponse(final String openEId) {
 			.build();
 	}
 
-	private static Optional<String> getFamilyID(final Errand errand) {
-		return errand.getExternalTags().stream()
-			.filter(tag -> "familyId".equalsIgnoreCase(tag.getKey()))
-			.findFirst()
-			.map(ExternalTag::getValue);
-	}
-
-	private static Optional<String> getExternalCaseId(final Errand errand) {
-		final boolean familyIdExists = errand.getExternalTags().stream()
-			.anyMatch(tag -> "familyId".equalsIgnoreCase(tag.getKey()));
-
-		if (familyIdExists) {
-			return errand.getExternalTags().stream()
-				.filter(tag -> "caseId".equalsIgnoreCase(tag.getKey()))
-				.findFirst()
-				.map(ExternalTag::getValue);
-		}
-
-		return Optional.empty();
-	}
-
-	public static SetStatus toSetStatus(final Errand errand, final String status) {
-
-		final var optionalExternalCaseId = getExternalCaseId(errand);
-
-		return optionalExternalCaseId.map(externalCaseId -> new SetStatus()
-			.withStatusAlias(status)
-			.withFlowInstanceID(Integer.parseInt(externalCaseId)))
-			.orElse(null);
-	}
 }
diff --git a/src/main/java/se/sundsvall/casestatus/service/SupportManagementService.java b/src/main/java/se/sundsvall/casestatus/service/SupportManagementService.java
index b22b1906..458526c4 100644
--- a/src/main/java/se/sundsvall/casestatus/service/SupportManagementService.java
+++ b/src/main/java/se/sundsvall/casestatus/service/SupportManagementService.java
@@ -2,7 +2,9 @@
 
 import generated.se.sundsvall.supportmanagement.Errand;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
@@ -17,21 +19,24 @@ public SupportManagementService(final SupportManagementClient supportManagementC
 		this.supportManagementClient = supportManagementClient;
 	}
 
-	public List<Errand> getSupportManagementCases(final String municipalityId, final String filter) {
+	public Map<String, List<Errand>> getSupportManagementCases(final String municipalityId, final String filter) {
 
-		final var allResponses = new ArrayList<Errand>();
+		var errandMap = new HashMap<String, List<Errand>>();
 
-		supportManagementClient.readAllNamespaceConfigs().forEach(namespace -> {
+		supportManagementClient.readAllNamespaceConfigs().forEach(config -> {
 			int pageNumber = 0;
 			Page<Errand> response;
+			List<Errand> allErrands = new ArrayList<>();
 
 			do {
-				response = supportManagementClient.findErrands(municipalityId, namespace.getNamespace(), filter, PageRequest.of(pageNumber, 100));
-				allResponses.addAll(response.getContent());
+				response = supportManagementClient.findErrands(municipalityId, config.getNamespace(), filter, PageRequest.of(pageNumber, 100));
+				allErrands.addAll(response.getContent());
 				pageNumber++;
 			} while (response.hasNext());
+
+			errandMap.put(config.getNamespace(), allErrands);
 		});
 
-		return allResponses.stream().distinct().toList();
+		return errandMap;
 	}
 }
diff --git a/src/main/java/se/sundsvall/casestatus/service/mapper/CaseManagementMapper.java b/src/main/java/se/sundsvall/casestatus/service/mapper/CaseManagementMapper.java
index e5597129..57d918fe 100644
--- a/src/main/java/se/sundsvall/casestatus/service/mapper/CaseManagementMapper.java
+++ b/src/main/java/se/sundsvall/casestatus/service/mapper/CaseManagementMapper.java
@@ -1,8 +1,8 @@
 package se.sundsvall.casestatus.service.mapper;
 
 import static java.util.Optional.ofNullable;
-import static se.sundsvall.casestatus.utility.Constants.MISSING;
-import static se.sundsvall.casestatus.utility.Constants.UNKNOWN;
+import static se.sundsvall.casestatus.util.Constants.MISSING;
+import static se.sundsvall.casestatus.util.Constants.UNKNOWN;
 
 import generated.se.sundsvall.casemanagement.CaseStatusDTO;
 import java.time.LocalDateTime;
diff --git a/src/main/java/se/sundsvall/casestatus/service/mapper/SupportManagementMapper.java b/src/main/java/se/sundsvall/casestatus/service/mapper/SupportManagementMapper.java
new file mode 100644
index 00000000..100add3a
--- /dev/null
+++ b/src/main/java/se/sundsvall/casestatus/service/mapper/SupportManagementMapper.java
@@ -0,0 +1,64 @@
+package se.sundsvall.casestatus.service.mapper;
+
+import static se.sundsvall.casestatus.util.Constants.DATE_TIME_FORMAT;
+import static se.sundsvall.casestatus.util.Constants.MISSING;
+import static se.sundsvall.casestatus.util.Constants.SUPPORT_MANAGEMENT;
+
+import generated.se.sundsvall.opene.SetStatus;
+import generated.se.sundsvall.supportmanagement.Errand;
+import generated.se.sundsvall.supportmanagement.ExternalTag;
+import java.time.format.DateTimeFormatter;
+import java.util.Optional;
+import se.sundsvall.casestatus.api.model.CaseStatusResponse;
+
+public final class SupportManagementMapper {
+
+	private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(DATE_TIME_FORMAT);
+
+	private SupportManagementMapper() {}
+
+	public static CaseStatusResponse toCaseStatusResponse(final Errand errand, final String namespace) {
+		final var externalCaseId = getExternalCaseId(errand);
+
+		final var modified = Optional.ofNullable(errand.getModified())
+			.map(modifiedDate -> modifiedDate.format(DATE_TIME_FORMATTER))
+			.orElse(MISSING);
+
+		final var firstSubmitted = Optional.ofNullable(errand.getCreated())
+			.map(createdDate -> createdDate.format(DATE_TIME_FORMATTER))
+			.orElse(MISSING);
+
+		return CaseStatusResponse.builder()
+			.withCaseId(errand.getId())
+			.withExternalCaseId(externalCaseId.orElse(null))
+			.withCaseType(errand.getClassification().getType())
+			.withStatus(errand.getStatus())
+			.withLastStatusChange(modified)
+			.withFirstSubmitted(firstSubmitted)
+			.withSystem(SUPPORT_MANAGEMENT)
+			.withErrandNumber(errand.getErrandNumber())
+			.withNamespace(namespace)
+			.build();
+	}
+
+	public static SetStatus toSetStatus(final Errand errand, final String status) {
+		return getExternalCaseId(errand).map(externalCaseId -> new SetStatus()
+			.withStatusAlias(status)
+			.withFlowInstanceID(Integer.parseInt(externalCaseId)))
+			.orElse(null);
+	}
+
+	static Optional<String> getExternalCaseId(final Errand errand) {
+		final boolean familyIdExists = errand.getExternalTags().stream()
+			.anyMatch(tag -> "familyId".equalsIgnoreCase(tag.getKey()));
+
+		if (familyIdExists) {
+			return errand.getExternalTags().stream()
+				.filter(tag -> "caseId".equalsIgnoreCase(tag.getKey()))
+				.findFirst()
+				.map(ExternalTag::getValue);
+		}
+
+		return Optional.empty();
+	}
+}
diff --git a/src/main/java/se/sundsvall/casestatus/service/scheduler/eventlog/EventLogWorker.java b/src/main/java/se/sundsvall/casestatus/service/scheduler/eventlog/EventLogWorker.java
index 6eecba98..8d89785b 100644
--- a/src/main/java/se/sundsvall/casestatus/service/scheduler/eventlog/EventLogWorker.java
+++ b/src/main/java/se/sundsvall/casestatus/service/scheduler/eventlog/EventLogWorker.java
@@ -1,13 +1,15 @@
 package se.sundsvall.casestatus.service.scheduler.eventlog;
 
 import static org.slf4j.LoggerFactory.getLogger;
-import static se.sundsvall.casestatus.utility.Constants.VALID_CHANNELS;
+import static se.sundsvall.casestatus.service.mapper.SupportManagementMapper.toSetStatus;
+import static se.sundsvall.casestatus.util.Constants.VALID_CHANNELS;
 
 import generated.se.sundsvall.eventlog.Event;
 import generated.se.sundsvall.opene.SetStatus;
 import generated.se.sundsvall.supportmanagement.Errand;
 import java.time.Duration;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
@@ -21,7 +23,6 @@
 import se.sundsvall.casestatus.integration.db.model.ExecutionInformationEntity;
 import se.sundsvall.casestatus.integration.eventlog.EventlogClient;
 import se.sundsvall.casestatus.integration.opene.soap.OpenECallbackIntegration;
-import se.sundsvall.casestatus.service.Mapper;
 import se.sundsvall.casestatus.service.SupportManagementService;
 import se.sundsvall.dept44.requestid.RequestId;
 
@@ -35,7 +36,11 @@ public class EventLogWorker {
 	private final CaseManagementOpeneViewRepository caseManagementOpeneViewRepository;
 	private final Duration clockSkew;
 
-	public EventLogWorker(final EventlogClient eventlogClient, final SupportManagementService supportManagementService, final OpenECallbackIntegration openECallbackIntegration, final CaseManagementOpeneViewRepository caseManagementOpeneViewRepository,
+	public EventLogWorker(
+		final EventlogClient eventlogClient,
+		final SupportManagementService supportManagementService,
+		final OpenECallbackIntegration openECallbackIntegration,
+		final CaseManagementOpeneViewRepository caseManagementOpeneViewRepository,
 		@Value("${scheduler.eventlog.clock-skew:PT5S}") final Duration clockSkew) {
 		this.eventlogClient = eventlogClient;
 		this.supportManagementService = supportManagementService;
@@ -55,8 +60,11 @@ void updateStatus(final ExecutionInformationEntity executionInformation) {
 
 		final var filter = createFilterString(logKeys);
 
-		final var result = supportManagementService.getSupportManagementCases(executionInformation.getMunicipalityId(), filter);
-		sortByChannel(result).forEach(this::doOpenECallback);
+		var errands = supportManagementService.getSupportManagementCases(executionInformation.getMunicipalityId(), filter).values().stream()
+			.flatMap(Collection::stream)
+			.toList();
+
+		sortByChannel(errands).forEach(this::doOpenECallback);
 	}
 
 	private void doOpenECallback(final String channel, final List<SetStatus> caseEntities) {
@@ -83,9 +91,8 @@ private Map<String, List<SetStatus>> sortByChannel(final List<Errand> result) {
 			.filter(errand -> errand.getChannel() != null && VALID_CHANNELS.contains(errand.getChannel()))
 			.collect(Collectors.groupingBy(
 				Errand::getChannel,
-				Collectors.mapping(errand -> caseManagementOpeneViewRepository
-					.findByCaseManagementId(errand.getStatus())
-					.map(view -> Mapper.toSetStatus(errand, view.getOpenEId()))
+				Collectors.mapping(errand -> caseManagementOpeneViewRepository.findByCaseManagementId(errand.getStatus())
+					.map(view -> toSetStatus(errand, view.getOpenEId()))
 					.orElse(null),
 					Collectors.filtering(Objects::nonNull, Collectors.toList()))));
 	}
diff --git a/src/main/java/se/sundsvall/casestatus/utility/Constants.java b/src/main/java/se/sundsvall/casestatus/util/Constants.java
similarity index 67%
rename from src/main/java/se/sundsvall/casestatus/utility/Constants.java
rename to src/main/java/se/sundsvall/casestatus/util/Constants.java
index 805be9b3..e613b7e3 100644
--- a/src/main/java/se/sundsvall/casestatus/utility/Constants.java
+++ b/src/main/java/se/sundsvall/casestatus/util/Constants.java
@@ -1,4 +1,4 @@
-package se.sundsvall.casestatus.utility;
+package se.sundsvall.casestatus.util;
 
 import java.util.Set;
 
@@ -8,6 +8,9 @@ public final class Constants {
 	public static final String INTERNAL_CHANNEL_E_SERVICE = "ESERVICE_INTERNAL";
 	public static final String MISSING = "Saknas";
 	public static final String UNKNOWN = "Okänd";
+	public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm";
+	public static final String SUPPORT_MANAGEMENT = "SUPPORT_MANAGEMENT";
+	public static final String OPEN_E_PLATFORM = "OPEN_E_PLATFORM";
 	public static final Set<String> VALID_CHANNELS = Set.of(EXTERNAL_CHANNEL_E_SERVICE, INTERNAL_CHANNEL_E_SERVICE);
 
 	private Constants() {
diff --git a/src/main/java/se/sundsvall/casestatus/util/FormattingUtil.java b/src/main/java/se/sundsvall/casestatus/util/FormattingUtil.java
new file mode 100644
index 00000000..d5d5b2c3
--- /dev/null
+++ b/src/main/java/se/sundsvall/casestatus/util/FormattingUtil.java
@@ -0,0 +1,33 @@
+package se.sundsvall.casestatus.util;
+
+import java.util.stream.IntStream;
+
+public final class FormattingUtil {
+
+	private FormattingUtil() {}
+
+	/**
+	 * Returns the organization number in a formatted way.
+	 *
+	 * @param  organizationNumber The organization number to format
+	 * @return                    The formatted organization number
+	 */
+	public static String getFormattedOrganizationNumber(final String organizationNumber) {
+
+		// Control that the organizationNumber is not null and that it is a valid length
+		if (IntStream.of(13, 12, 11, 10).anyMatch(i -> organizationNumber.length() == i)) {
+			// Remove all non-digit characters
+			final String cleanNumber = organizationNumber.replaceAll("\\D", "");
+
+			if (cleanNumber.length() == 12) {
+				// Insert the hyphen at the correct position
+				return cleanNumber.substring(0, 8) + "-" + cleanNumber.substring(8);
+
+			}
+			if (cleanNumber.length() == 10) {
+				return cleanNumber.substring(0, 6) + "-" + cleanNumber.substring(6);
+			}
+		}
+		return organizationNumber;
+	}
+}
diff --git a/src/test/java/se/sundsvall/TestDataFactory.java b/src/test/java/se/sundsvall/TestDataFactory.java
index 5570837b..306ee281 100644
--- a/src/test/java/se/sundsvall/TestDataFactory.java
+++ b/src/test/java/se/sundsvall/TestDataFactory.java
@@ -2,6 +2,7 @@
 
 import generated.se.sundsvall.casemanagement.CaseStatusDTO;
 import java.time.LocalDateTime;
+import se.sundsvall.casestatus.api.model.CaseStatusResponse;
 
 public final class TestDataFactory {
 
@@ -18,4 +19,18 @@ public static CaseStatusDTO createCaseStatusDTO(final CaseStatusDTO.SystemEnum s
 		caseStatus.setSystem(system);
 		return caseStatus;
 	}
+
+	public static CaseStatusResponse createCaseStatusResponse(final CaseStatusDTO.SystemEnum system) {
+		return CaseStatusResponse.builder()
+			.withSystem(system.getValue())
+			.withCaseId("caseId")
+			.withExternalCaseId("externalCaseId")
+			.withCaseType("caseType")
+			.withStatus("status")
+			.withLastStatusChange("2025-03-24 12:00:00")
+			.withFirstSubmitted("2025-03-24 12:00:00")
+			.withErrandNumber("errandNumber")
+			.withNamespace("namespace")
+			.build();
+	}
 }
diff --git a/src/test/java/se/sundsvall/casestatus/integration/opene/soap/OpenECallbackIntegrationTest.java b/src/test/java/se/sundsvall/casestatus/integration/opene/soap/OpenECallbackIntegrationTest.java
index 6d4549b6..b9a4a685 100644
--- a/src/test/java/se/sundsvall/casestatus/integration/opene/soap/OpenECallbackIntegrationTest.java
+++ b/src/test/java/se/sundsvall/casestatus/integration/opene/soap/OpenECallbackIntegrationTest.java
@@ -3,8 +3,8 @@
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.when;
-import static se.sundsvall.casestatus.utility.Constants.EXTERNAL_CHANNEL_E_SERVICE;
-import static se.sundsvall.casestatus.utility.Constants.INTERNAL_CHANNEL_E_SERVICE;
+import static se.sundsvall.casestatus.util.Constants.EXTERNAL_CHANNEL_E_SERVICE;
+import static se.sundsvall.casestatus.util.Constants.INTERNAL_CHANNEL_E_SERVICE;
 
 import generated.se.sundsvall.opene.SetStatus;
 import generated.se.sundsvall.opene.SetStatusResponse;
diff --git a/src/test/java/se/sundsvall/casestatus/service/CaseStatusServiceTests.java b/src/test/java/se/sundsvall/casestatus/service/CaseStatusServiceTests.java
index c7787e64..5d0cf975 100644
--- a/src/test/java/se/sundsvall/casestatus/service/CaseStatusServiceTests.java
+++ b/src/test/java/se/sundsvall/casestatus/service/CaseStatusServiceTests.java
@@ -8,6 +8,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
+import static se.sundsvall.TestDataFactory.createCaseStatusResponse;
 
 import generated.se.sundsvall.casemanagement.CaseStatusDTO;
 import generated.se.sundsvall.party.PartyType;
@@ -23,6 +24,7 @@
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
+import org.mockito.Mockito;
 import org.mockito.junit.jupiter.MockitoExtension;
 import org.zalando.problem.Problem;
 import se.sundsvall.casestatus.api.model.CaseStatusResponse;
@@ -57,7 +59,7 @@ class CaseStatusServiceTests {
 	@Mock
 	private SupportManagementService supportManagementServiceMock;
 	@Mock
-	private CaseManagementMapper caseManagementMapper;
+	private CaseManagementMapper caseManagementMapperMock;
 	@InjectMocks
 	private CaseStatusService caseStatusService;
 
@@ -106,7 +108,7 @@ void getCaseStatusCaseStatusFoundInCaseManagement() {
 		when(caseManagementIntegrationMock.getCaseStatusForExternalId(any(String.class), any(String.class)))
 			.thenReturn(Optional.of(caseStatus));
 
-		when(caseManagementMapper.toCaseStatusResponse(caseStatus, MUNICIPALITY_ID))
+		when(caseManagementMapperMock.toCaseStatusResponse(caseStatus, MUNICIPALITY_ID))
 			.thenReturn(CaseStatusResponse.builder().withCaseId("someCaseId").withExternalCaseId(EXTERNAL_CASE_ID).withCaseType("PARKING_PERMIT").build());
 
 		final var result = caseStatusService.getCaseStatus(EXTERNAL_CASE_ID, MUNICIPALITY_ID);
@@ -117,7 +119,7 @@ void getCaseStatusCaseStatusFoundInCaseManagement() {
 		assertThat(result.getCaseType()).isEqualTo("PARKING_PERMIT");
 
 		verify(caseManagementIntegrationMock).getCaseStatusForExternalId(any(String.class), any(String.class));
-		verify(caseManagementMapper).toCaseStatusResponse(caseStatus, MUNICIPALITY_ID);
+		verify(caseManagementMapperMock).toCaseStatusResponse(caseStatus, MUNICIPALITY_ID);
 		verifyNoMoreInteractions(caseTypeRepositoryMock, caseManagementIntegrationMock);
 	}
 
@@ -167,7 +169,7 @@ void getCaseStatuses() {
 		when(caseManagementIntegrationMock.getCaseStatusForOrganizationNumber(any(String.class), any(String.class)))
 			.thenReturn(List.of(new CaseStatusDTO().status("someStatus"), new CaseStatusDTO().status("someOtherStatus")));
 
-		when(caseManagementMapper.toCaseStatusResponse(any(CaseStatusDTO.class), eq(MUNICIPALITY_ID)))
+		when(caseManagementMapperMock.toCaseStatusResponse(any(CaseStatusDTO.class), eq(MUNICIPALITY_ID)))
 			.thenReturn(CaseStatusResponse.builder().build());
 
 		when(caseRepositoryMock.findByOrganisationNumberAndMunicipalityId(any(String.class), any(String.class)))
@@ -178,9 +180,9 @@ void getCaseStatuses() {
 		assertThat(result).isNotNull().hasSize(3);
 
 		verify(caseManagementIntegrationMock).getCaseStatusForOrganizationNumber(any(String.class), any(String.class));
-		verify(caseManagementMapper, times(2)).toCaseStatusResponse(any(CaseStatusDTO.class), eq(MUNICIPALITY_ID));
+		verify(caseManagementMapperMock, times(2)).toCaseStatusResponse(any(CaseStatusDTO.class), eq(MUNICIPALITY_ID));
 		verify(caseRepositoryMock).findByOrganisationNumberAndMunicipalityId(any(String.class), any(String.class));
-		verifyNoMoreInteractions(caseManagementIntegrationMock, caseRepositoryMock, caseManagementMapper);
+		verifyNoMoreInteractions(caseManagementIntegrationMock, caseRepositoryMock, caseManagementMapperMock);
 	}
 
 	@Test
@@ -219,7 +221,7 @@ void getCaseStatusCompanyRepositoryNotFound() {
 	void getCaseStatuses_companyRepositoryNotFound() {
 		when(caseManagementIntegrationMock.getCaseStatusForOrganizationNumber(any(String.class), any(String.class)))
 			.thenReturn(List.of(new CaseStatusDTO().status("someStatus")));
-		when(caseManagementMapper.toCaseStatusResponse(any(CaseStatusDTO.class), eq(MUNICIPALITY_ID)))
+		when(caseManagementMapperMock.toCaseStatusResponse(any(CaseStatusDTO.class), eq(MUNICIPALITY_ID)))
 			.thenReturn(CaseStatusResponse.builder().build());
 		when(caseRepositoryMock.findByOrganisationNumberAndMunicipalityId(any(String.class), any(String.class)))
 			.thenReturn(List.of());
@@ -229,9 +231,9 @@ void getCaseStatuses_companyRepositoryNotFound() {
 		assertThat(result).isNotNull().hasSize(1);
 
 		verify(caseManagementIntegrationMock).getCaseStatusForOrganizationNumber(any(String.class), any(String.class));
-		verify(caseManagementMapper).toCaseStatusResponse(any(CaseStatusDTO.class), eq(MUNICIPALITY_ID));
+		verify(caseManagementMapperMock).toCaseStatusResponse(any(CaseStatusDTO.class), eq(MUNICIPALITY_ID));
 		verify(caseRepositoryMock).findByOrganisationNumberAndMunicipalityId(any(String.class), any(String.class));
-		verifyNoMoreInteractions(caseManagementIntegrationMock, caseRepositoryMock, caseManagementMapper);
+		verifyNoMoreInteractions(caseManagementIntegrationMock, caseRepositoryMock, caseManagementMapperMock);
 	}
 
 	@Test
@@ -246,7 +248,7 @@ void getCaseStatusesForPartyPrivate() {
 		when(caseManagementIntegrationMock.getCaseStatusForPartyId(partyId, MUNICIPALITY_ID))
 			.thenReturn(List.of(dto1, dto2));
 
-		when(caseManagementMapper.toCaseStatusResponse(any(CaseStatusDTO.class), eq(MUNICIPALITY_ID)))
+		when(caseManagementMapperMock.toCaseStatusResponse(any(CaseStatusDTO.class), eq(MUNICIPALITY_ID)))
 			.thenReturn(CaseStatusResponse.builder().build())
 			.thenReturn(CaseStatusResponse.builder().build());
 
@@ -257,14 +259,14 @@ void getCaseStatusesForPartyPrivate() {
 			.thenReturn(List.of(CaseEntity.builder().withFlowInstanceId("2").build()));
 
 		when(supportManagementServiceMock.getSupportManagementCases(any(String.class), any(String.class)))
-			.thenReturn(List.of(new Errand()
+			.thenReturn(Map.of("namespace", List.of(new Errand()
 				.id("someErrandId")
 				.modified(OffsetDateTime.now())
 				.created(OffsetDateTime.now().minusDays(1))
 				.classification(new Classification().type("someType"))
 				.addExternalTagsItem(new ExternalTag().key("familyId").value("123"))
 				.addExternalTagsItem(new ExternalTag().key("caseId").value("5"))
-				.status("someStatus")));
+				.status("someStatus"))));
 
 		final var result = caseStatusService.getCaseStatusesForParty(partyId, MUNICIPALITY_ID);
 
@@ -272,11 +274,11 @@ void getCaseStatusesForPartyPrivate() {
 
 		verify(partyIntegrationMock).getLegalIdByPartyId(MUNICIPALITY_ID, partyId);
 		verify(caseManagementIntegrationMock).getCaseStatusForPartyId(partyId, MUNICIPALITY_ID);
-		verify(caseManagementMapper, times(2)).toCaseStatusResponse(any(CaseStatusDTO.class), eq(MUNICIPALITY_ID));
+		verify(caseManagementMapperMock, times(2)).toCaseStatusResponse(any(CaseStatusDTO.class), eq(MUNICIPALITY_ID));
 		verify(caseRepositoryMock).findByPersonIdAndMunicipalityId(partyId, MUNICIPALITY_ID);
 		verify(openEIntegrationMock).getCaseStatuses(MUNICIPALITY_ID, legalId);
 		verify(supportManagementServiceMock).getSupportManagementCases(any(String.class), any(String.class));
-		verifyNoMoreInteractions(partyIntegrationMock, caseManagementIntegrationMock, caseRepositoryMock, openEIntegrationMock, supportManagementServiceMock, caseManagementMapper);
+		verifyNoMoreInteractions(partyIntegrationMock, caseManagementIntegrationMock, caseRepositoryMock, openEIntegrationMock, supportManagementServiceMock, caseManagementMapperMock);
 	}
 
 	@Test
@@ -290,7 +292,7 @@ void getCaseStatusesForPartyPrivate_withFilter() {
 		when(caseManagementIntegrationMock.getCaseStatusForPartyId(partyId, MUNICIPALITY_ID))
 			.thenReturn(List.of(caseStatusDto));
 
-		when(caseManagementMapper.toCaseStatusResponse(caseStatusDto, MUNICIPALITY_ID))
+		when(caseManagementMapperMock.toCaseStatusResponse(caseStatusDto, MUNICIPALITY_ID))
 			.thenReturn(CaseStatusResponse.builder().withExternalCaseId("1").withStatus("someStatus").build());
 
 		when(caseRepositoryMock.findByPersonIdAndMunicipalityId(partyId, MUNICIPALITY_ID))
@@ -304,14 +306,14 @@ void getCaseStatusesForPartyPrivate_withFilter() {
 				CaseEntity.builder().withFlowInstanceId("2").withLastStatusChange("2023-01-01 09:00").build()));
 
 		when(supportManagementServiceMock.getSupportManagementCases(any(String.class), any(String.class)))
-			.thenReturn(List.of(new Errand()
+			.thenReturn(Map.of("namespace", List.of(new Errand()
 				.id("someErrandId")
 				.modified(lastStatusChange)
 				.created(OffsetDateTime.now().minusDays(1))
 				.classification(new Classification().type("someType"))
 				.addExternalTagsItem(new ExternalTag().key("familyId").value("123"))
 				.addExternalTagsItem(new ExternalTag().key("caseId").value("5"))
-				.status("someStatus")));
+				.status("someStatus"))));
 
 		final var result = caseStatusService.getCaseStatusesForParty(partyId, MUNICIPALITY_ID);
 
@@ -324,43 +326,58 @@ void getCaseStatusesForPartyPrivate_withFilter() {
 		verify(caseRepositoryMock).findByPersonIdAndMunicipalityId(partyId, MUNICIPALITY_ID);
 		verify(openEIntegrationMock).getCaseStatuses(MUNICIPALITY_ID, legalId);
 		verify(supportManagementServiceMock).getSupportManagementCases(any(String.class), any(String.class));
-		verifyNoMoreInteractions(partyIntegrationMock, caseManagementIntegrationMock, caseManagementMapper, caseRepositoryMock, openEIntegrationMock, supportManagementServiceMock);
+		verifyNoMoreInteractions(partyIntegrationMock, caseManagementIntegrationMock, caseManagementMapperMock, caseRepositoryMock, openEIntegrationMock, supportManagementServiceMock);
 	}
 
+	/**
+	 * Test scenario where the party id represents an enterprise.
+	 */
 	@Test
-	void getCaseStatusesForPartyEnterprise() {
+	void getCaseStatusesForParty_1() {
 		final var partyId = "somePartyId";
+		final var legalId = "1234567890";
+		final var partyResult = Map.of(PartyType.ENTERPRISE, legalId);
+		final var caseResponses = List.of(createCaseStatusResponse(CaseStatusDTO.SystemEnum.BYGGR));
+		final var spy = Mockito.spy(caseStatusService);
 
-		when(partyIntegrationMock.getLegalIdByPartyId(MUNICIPALITY_ID, partyId)).thenReturn(Map.of(PartyType.ENTERPRISE, "1234567890"));
-		when(caseManagementIntegrationMock.getCaseStatusForPartyId(partyId, MUNICIPALITY_ID))
-			.thenReturn(List.of(new CaseStatusDTO().status("someStatus")));
+		when(partyIntegrationMock.getLegalIdByPartyId(MUNICIPALITY_ID, partyId)).thenReturn(partyResult);
+		when(spy.getEnterpriseCaseStatuses(partyId, partyResult, MUNICIPALITY_ID)).thenReturn(caseResponses);
+		when(spy.filterResponse(caseResponses)).thenReturn(caseResponses);
 
-		final var result = caseStatusService.getCaseStatusesForParty(partyId, MUNICIPALITY_ID);
+		final var result = spy.getCaseStatusesForParty(partyId, MUNICIPALITY_ID);
 
 		assertThat(result).isNotNull().hasSize(1);
 
 		verify(partyIntegrationMock).getLegalIdByPartyId(MUNICIPALITY_ID, partyId);
-		verify(caseManagementIntegrationMock).getCaseStatusForPartyId(partyId, MUNICIPALITY_ID);
-		verify(caseRepositoryMock).findByOrganisationNumberAndMunicipalityId("1234567890", MUNICIPALITY_ID);
-		verify(caseRepositoryMock).findByOrganisationNumberAndMunicipalityId("123456-7890", MUNICIPALITY_ID);
-
-		verifyNoMoreInteractions(partyIntegrationMock, caseManagementIntegrationMock);
+		verify(spy).getEnterpriseCaseStatuses(partyId, partyResult, MUNICIPALITY_ID);
+		verify(spy).filterResponse(caseResponses);
+		verify(spy).getCaseStatusesForParty(partyId, MUNICIPALITY_ID);
+		verifyNoMoreInteractions(partyIntegrationMock, spy);
 	}
 
+	/**
+	 * Test scenario where the party id represents an individual.
+	 */
 	@Test
-	void getCaseStatusesForPartyNoPrivateOrEnterprise() {
+	void getCaseStatusesForParty_2() {
 		final var partyId = "somePartyId";
+		final var legalId = "1234567890";
+		final var partyResult = Map.of(PartyType.PRIVATE, legalId);
+		final var caseResponses = List.of(createCaseStatusResponse(CaseStatusDTO.SystemEnum.BYGGR));
+		final var spy = Mockito.spy(caseStatusService);
 
-		when(partyIntegrationMock.getLegalIdByPartyId(MUNICIPALITY_ID, partyId)).thenReturn(Map.of());
-		when(caseManagementIntegrationMock.getCaseStatusForPartyId(partyId, MUNICIPALITY_ID))
-			.thenReturn(List.of(new CaseStatusDTO().status("someStatus")));
+		when(partyIntegrationMock.getLegalIdByPartyId(MUNICIPALITY_ID, partyId)).thenReturn(partyResult);
+		when(spy.getPrivateCaseStatuses(partyId, partyResult, MUNICIPALITY_ID)).thenReturn(caseResponses);
+		when(spy.filterResponse(caseResponses)).thenReturn(caseResponses);
 
-		final var result = caseStatusService.getCaseStatusesForParty(partyId, MUNICIPALITY_ID);
+		final var result = spy.getCaseStatusesForParty(partyId, MUNICIPALITY_ID);
 
 		assertThat(result).isNotNull().hasSize(1);
 
 		verify(partyIntegrationMock).getLegalIdByPartyId(MUNICIPALITY_ID, partyId);
-		verify(caseManagementIntegrationMock).getCaseStatusForPartyId(partyId, MUNICIPALITY_ID);
-		verifyNoMoreInteractions(partyIntegrationMock, caseManagementIntegrationMock);
+		verify(spy).getPrivateCaseStatuses(partyId, partyResult, MUNICIPALITY_ID);
+		verify(spy).filterResponse(caseResponses);
+		verify(spy).getCaseStatusesForParty(partyId, MUNICIPALITY_ID);
+		verifyNoMoreInteractions(partyIntegrationMock, spy);
 	}
 }
diff --git a/src/test/java/se/sundsvall/casestatus/service/MapperTest.java b/src/test/java/se/sundsvall/casestatus/service/MapperTest.java
index f2fe3823..f2387798 100644
--- a/src/test/java/se/sundsvall/casestatus/service/MapperTest.java
+++ b/src/test/java/se/sundsvall/casestatus/service/MapperTest.java
@@ -1,13 +1,9 @@
 package se.sundsvall.casestatus.service;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static se.sundsvall.casestatus.utility.Constants.MISSING;
+import static se.sundsvall.casestatus.util.Constants.MISSING;
 
 import generated.se.sundsvall.casemanagement.CaseStatusDTO;
-import generated.se.sundsvall.supportmanagement.Classification;
-import generated.se.sundsvall.supportmanagement.Errand;
-import generated.se.sundsvall.supportmanagement.ExternalTag;
-import java.time.OffsetDateTime;
 import org.junit.jupiter.api.Test;
 import se.sundsvall.casestatus.integration.db.model.CaseEntity;
 
@@ -99,132 +95,4 @@ void toOepStatusResponse() {
 		assertThat(response.getValue()).isEqualTo(openEId);
 	}
 
-	@Test
-	void toCaseStatusResponse_withExternalCaseId() {
-		// Arrange
-		final var errand = new Errand()
-			.id("errandId")
-			.classification(new Classification().type("someType"))
-			.status("someStatus")
-			.created(OffsetDateTime.parse("2023-01-01T10:00:00Z"))
-			.modified(OffsetDateTime.parse("2023-01-02T10:00:00Z"))
-			.addExternalTagsItem(new ExternalTag().key("familyId").value("123"))
-			.addExternalTagsItem(new ExternalTag().key("caseId").value("caseId"));
-
-		// Act
-		final var response = Mapper.toCaseStatusResponse(errand);
-
-		// Assert
-		assertThat(response).isNotNull();
-		assertThat(response.getCaseId()).isEqualTo("errandId");
-		assertThat(response.getExternalCaseId()).isEqualTo("caseId");
-		assertThat(response.getCaseType()).isEqualTo("someType");
-		assertThat(response.getStatus()).isEqualTo("someStatus");
-		assertThat(response.getLastStatusChange()).isEqualTo("2023-01-02 10:00");
-		assertThat(response.getFirstSubmitted()).isEqualTo("2023-01-01 10:00");
-		assertThat(response.isOpenEErrand()).isTrue();
-	}
-
-	@Test
-	void toCaseStatusResponse_withoutExternalCaseId() {
-		// Arrange
-		final var errand = new Errand()
-			.id("errandId")
-			.classification(new Classification().type("someType"))
-			.status("someStatus")
-			.created(OffsetDateTime.parse("2023-01-01T10:00:00Z"))
-			.modified(OffsetDateTime.parse("2023-01-02T10:00:00Z"))
-			.addExternalTagsItem(new ExternalTag().key("familyId").value("123"));
-
-		// Act
-		final var response = Mapper.toCaseStatusResponse(errand);
-
-		// Assert
-		assertThat(response).isNotNull();
-		assertThat(response.getCaseId()).isEqualTo("errandId");
-		assertThat(response.getExternalCaseId()).isNull();
-		assertThat(response.getCaseType()).isEqualTo("someType");
-		assertThat(response.getStatus()).isEqualTo("someStatus");
-		assertThat(response.getLastStatusChange()).isEqualTo("2023-01-02 10:00");
-		assertThat(response.getFirstSubmitted()).isEqualTo("2023-01-01 10:00");
-		assertThat(response.isOpenEErrand()).isFalse();
-	}
-
-	@Test
-	void toCaseStatusResponse_withNullModified() {
-		// Arrange
-		final var errand = new Errand()
-			.id("errandId")
-			.classification(new Classification().type("someType"))
-			.status("someStatus")
-			.created(OffsetDateTime.parse("2023-01-01T10:00:00Z"))
-			.addExternalTagsItem(new ExternalTag().key("familyId").value("123"))
-			.addExternalTagsItem(new ExternalTag().key("caseId").value("caseId"));
-
-		// Act
-		final var response = Mapper.toCaseStatusResponse(errand);
-
-		// Assert
-		assertThat(response).isNotNull();
-		assertThat(response.getCaseId()).isEqualTo("errandId");
-		assertThat(response.getExternalCaseId()).isEqualTo("caseId");
-		assertThat(response.getCaseType()).isEqualTo("someType");
-		assertThat(response.getStatus()).isEqualTo("someStatus");
-		assertThat(response.getLastStatusChange()).isNull();
-		assertThat(response.getFirstSubmitted()).isEqualTo("2023-01-01 10:00");
-		assertThat(response.isOpenEErrand()).isTrue();
-	}
-
-	@Test
-	void toCaseEntity_withExternalCaseId() {
-		// Arrange
-		final var municipalityId = "municipalityId";
-		final var errand = new Errand()
-			.id("errandId")
-			.classification(new Classification().type("someType"))
-			.status("someStatus")
-			.created(OffsetDateTime.parse("2023-01-01T10:00:00Z"))
-			.modified(OffsetDateTime.parse("2023-01-02T10:00:00Z"))
-			.addExternalTagsItem(new ExternalTag().key("familyId").value("123"))
-			.addExternalTagsItem(new ExternalTag().key("caseId").value("caseId"));
-
-		// Act
-		final var caseEntity = Mapper.toCaseEntity(errand, municipalityId);
-
-		// Assert
-		assertThat(caseEntity).isNotNull();
-		assertThat(caseEntity.getFlowInstanceId()).isEqualTo("caseId");
-		assertThat(caseEntity.getFamilyId()).isEqualTo("123");
-		assertThat(caseEntity.getStatus()).isEqualTo("someStatus");
-		assertThat(caseEntity.getErrandType()).isEqualTo("someType");
-		assertThat(caseEntity.getFirstSubmitted()).isEqualTo("2023-01-01 10:00");
-		assertThat(caseEntity.getLastStatusChange()).isEqualTo("2023-01-02 10:00");
-		assertThat(caseEntity.getMunicipalityId()).isEqualTo(municipalityId);
-	}
-
-	@Test
-	void toCaseEntity_withoutExternalCaseId() {
-		// Arrange
-		final var municipalityId = "municipalityId";
-		final var errand = new Errand()
-			.id("errandId")
-			.classification(new Classification().type("someType"))
-			.status("someStatus")
-			.created(OffsetDateTime.parse("2023-01-01T10:00:00Z"))
-			.modified(OffsetDateTime.parse("2023-01-02T10:00:00Z"))
-			.addExternalTagsItem(new ExternalTag().key("familyId").value("123"));
-
-		// Act
-		final var caseEntity = Mapper.toCaseEntity(errand, municipalityId);
-
-		// Assert
-		assertThat(caseEntity).isNotNull();
-		assertThat(caseEntity.getFlowInstanceId()).isNull();
-		assertThat(caseEntity.getFamilyId()).isEqualTo("123");
-		assertThat(caseEntity.getStatus()).isEqualTo("someStatus");
-		assertThat(caseEntity.getErrandType()).isEqualTo("someType");
-		assertThat(caseEntity.getFirstSubmitted()).isEqualTo("2023-01-01 10:00");
-		assertThat(caseEntity.getLastStatusChange()).isEqualTo("2023-01-02 10:00");
-		assertThat(caseEntity.getMunicipalityId()).isEqualTo(municipalityId);
-	}
 }
diff --git a/src/test/java/se/sundsvall/casestatus/service/SupportManagementServiceTest.java b/src/test/java/se/sundsvall/casestatus/service/SupportManagementServiceTest.java
index 3377cb57..229de446 100644
--- a/src/test/java/se/sundsvall/casestatus/service/SupportManagementServiceTest.java
+++ b/src/test/java/se/sundsvall/casestatus/service/SupportManagementServiceTest.java
@@ -41,8 +41,8 @@ void getSupportManagementCases() {
 		final var result = supportManagementService.getSupportManagementCases(municipalityId, filter);
 
 		// Assert
-		assertThat(result).isNotNull().hasSize(1);
-		assertThat(result.getFirst().getId()).isEqualTo("errandId");
+		assertThat(result.get(namespace)).isNotNull().hasSize(1);
+		assertThat(result.get(namespace).getFirst().getId()).isEqualTo("errandId");
 	}
 
 	@Test
@@ -61,7 +61,7 @@ void getSupportManagementCasesFilterDuplicates() {
 		final var result = supportManagementService.getSupportManagementCases(municipalityId, filter);
 
 		// Assert
-		assertThat(result).isNotNull().hasSize(1);
-		assertThat(result.getFirst().getId()).isEqualTo("errandId");
+		assertThat(result.get(namespace)).isNotNull().hasSize(2);
+		assertThat(result.get(namespace).getFirst().getId()).isEqualTo("errandId");
 	}
 }
diff --git a/src/test/java/se/sundsvall/casestatus/service/mapper/SupportManagementMapperTest.java b/src/test/java/se/sundsvall/casestatus/service/mapper/SupportManagementMapperTest.java
new file mode 100644
index 00000000..789ea200
--- /dev/null
+++ b/src/test/java/se/sundsvall/casestatus/service/mapper/SupportManagementMapperTest.java
@@ -0,0 +1,88 @@
+package se.sundsvall.casestatus.service.mapper;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import generated.se.sundsvall.supportmanagement.Classification;
+import generated.se.sundsvall.supportmanagement.Errand;
+import generated.se.sundsvall.supportmanagement.ExternalTag;
+import java.time.OffsetDateTime;
+import org.junit.jupiter.api.Test;
+
+class SupportManagementMapperTest {
+
+	@Test
+	void toCaseStatusResponse_withExternalCaseId() {
+		// Arrange
+		final var namespace = "namespace";
+		final var errand = new Errand()
+			.id("errandId")
+			.classification(new Classification().type("someType"))
+			.status("someStatus")
+			.created(OffsetDateTime.parse("2023-01-01T10:00:00Z"))
+			.modified(OffsetDateTime.parse("2023-01-02T10:00:00Z"))
+			.addExternalTagsItem(new ExternalTag().key("familyId").value("123"))
+			.addExternalTagsItem(new ExternalTag().key("caseId").value("caseId"));
+
+		// Act
+		final var response = SupportManagementMapper.toCaseStatusResponse(errand, namespace);
+
+		// Assert
+		assertThat(response).isNotNull();
+		assertThat(response.getCaseId()).isEqualTo("errandId");
+		assertThat(response.getExternalCaseId()).isEqualTo("caseId");
+		assertThat(response.getCaseType()).isEqualTo("someType");
+		assertThat(response.getStatus()).isEqualTo("someStatus");
+		assertThat(response.getLastStatusChange()).isEqualTo("2023-01-02 10:00");
+		assertThat(response.getFirstSubmitted()).isEqualTo("2023-01-01 10:00");
+	}
+
+	@Test
+	void toCaseStatusResponse_withoutExternalCaseId() {
+		// Arrange
+		final var namespace = "namespace";
+		final var errand = new Errand()
+			.id("errandId")
+			.classification(new Classification().type("someType"))
+			.status("someStatus")
+			.created(OffsetDateTime.parse("2023-01-01T10:00:00Z"))
+			.modified(OffsetDateTime.parse("2023-01-02T10:00:00Z"))
+			.addExternalTagsItem(new ExternalTag().key("familyId").value("123"));
+
+		// Act
+		final var response = SupportManagementMapper.toCaseStatusResponse(errand, namespace);
+
+		// Assert
+		assertThat(response).isNotNull();
+		assertThat(response.getCaseId()).isEqualTo("errandId");
+		assertThat(response.getExternalCaseId()).isNull();
+		assertThat(response.getCaseType()).isEqualTo("someType");
+		assertThat(response.getStatus()).isEqualTo("someStatus");
+		assertThat(response.getLastStatusChange()).isEqualTo("2023-01-02 10:00");
+		assertThat(response.getFirstSubmitted()).isEqualTo("2023-01-01 10:00");
+	}
+
+	@Test
+	void toCaseStatusResponse_withNullModified() {
+		// Arrange
+		final var namespace = "namespace";
+		final var errand = new Errand()
+			.id("errandId")
+			.classification(new Classification().type("someType"))
+			.status("someStatus")
+			.created(OffsetDateTime.parse("2023-01-01T10:00:00Z"))
+			.addExternalTagsItem(new ExternalTag().key("familyId").value("123"))
+			.addExternalTagsItem(new ExternalTag().key("caseId").value("caseId"));
+
+		// Act
+		final var response = SupportManagementMapper.toCaseStatusResponse(errand, namespace);
+
+		// Assert
+		assertThat(response).isNotNull();
+		assertThat(response.getCaseId()).isEqualTo("errandId");
+		assertThat(response.getExternalCaseId()).isEqualTo("caseId");
+		assertThat(response.getCaseType()).isEqualTo("someType");
+		assertThat(response.getStatus()).isEqualTo("someStatus");
+		assertThat(response.getLastStatusChange()).isEqualTo("Saknas");
+		assertThat(response.getFirstSubmitted()).isEqualTo("2023-01-01 10:00");
+	}
+}
diff --git a/src/test/java/se/sundsvall/casestatus/service/scheduler/eventlog/EventLogWorkerTest.java b/src/test/java/se/sundsvall/casestatus/service/scheduler/eventlog/EventLogWorkerTest.java
index 711884eb..1351a7ff 100644
--- a/src/test/java/se/sundsvall/casestatus/service/scheduler/eventlog/EventLogWorkerTest.java
+++ b/src/test/java/se/sundsvall/casestatus/service/scheduler/eventlog/EventLogWorkerTest.java
@@ -9,7 +9,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoInteractions;
 import static org.mockito.Mockito.when;
-import static se.sundsvall.casestatus.utility.Constants.EXTERNAL_CHANNEL_E_SERVICE;
+import static se.sundsvall.casestatus.util.Constants.EXTERNAL_CHANNEL_E_SERVICE;
 
 import generated.se.sundsvall.eventlog.Event;
 import generated.se.sundsvall.opene.SetStatus;
@@ -18,6 +18,7 @@
 import java.time.Duration;
 import java.time.OffsetDateTime;
 import java.util.List;
+import java.util.Map;
 import java.util.Optional;
 import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
@@ -91,14 +92,14 @@ void testUpdateStatus() {
 		when(caseManagementOpeneViewRepository.findByCaseManagementId(internalStatus)).thenReturn(Optional.of(caseMapping));
 
 		when(eventlogClient.getEvents(eq(municipalityId), any(PageRequest.class), filterArgumentCaptor.capture())).thenReturn(eventPage);
-		when(supportManagementService.getSupportManagementCases(eq(municipalityId), anyString())).thenReturn(errands);
+		when(supportManagementService.getSupportManagementCases(eq(municipalityId), anyString())).thenReturn(Map.of("namespace", errands));
 
 		// Act
 		eventLogWorker.updateStatus(executionInformationEntity);
 
 		// Assert
-		verify(eventlogClient, times(1)).getEvents(eq(municipalityId), any(PageRequest.class), anyString());
-		verify(supportManagementService, times(1)).getSupportManagementCases(eq(municipalityId), anyString());
+		verify(eventlogClient).getEvents(eq(municipalityId), any(PageRequest.class), anyString());
+		verify(supportManagementService).getSupportManagementCases(eq(municipalityId), anyString());
 		verify(openECallbackIntegration, times(2)).setStatus(anyString(), any(SetStatus.class));
 		verify(caseManagementOpeneViewRepository, times(2)).findByCaseManagementId(internalStatus);
 		assertThat(filterArgumentCaptor.getValue()).isEqualTo("message:'Ärendet har uppdaterats.' and created > '" + executionInformationEntity.getLastSuccessfulExecution().minus(Duration.parse("PT5S")) +
diff --git a/src/test/java/se/sundsvall/casestatus/service/util/FormattingUtilTest.java b/src/test/java/se/sundsvall/casestatus/service/util/FormattingUtilTest.java
new file mode 100644
index 00000000..1cef84f2
--- /dev/null
+++ b/src/test/java/se/sundsvall/casestatus/service/util/FormattingUtilTest.java
@@ -0,0 +1,46 @@
+package se.sundsvall.casestatus.service.util;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import se.sundsvall.casestatus.util.FormattingUtil;
+
+class FormattingUtilTest {
+
+	/**
+	 * Test values with length 12.
+	 */
+	@ParameterizedTest
+	@ValueSource(strings = {
+		"199001010101", "200001010101", "198001010101"
+	})
+	void getFormattedOrganizationNumber_1(final String organizationNumber) {
+		var result = FormattingUtil.getFormattedOrganizationNumber(organizationNumber);
+		assertThat(result).isEqualTo(organizationNumber.substring(0, 8) + "-" + organizationNumber.substring(8));
+	}
+
+	/**
+	 * Test values with length 10.
+	 */
+	@ParameterizedTest
+	@ValueSource(strings = {
+		"9001010101", "0001010101", "8001010101"
+	})
+	void getFormattedOrganizationNumber_2(final String organizationNumber) {
+		var result = FormattingUtil.getFormattedOrganizationNumber(organizationNumber);
+		assertThat(result).isEqualTo(organizationNumber.substring(0, 6) + "-" + organizationNumber.substring(6));
+	}
+
+	/**
+	 * Test values with neither length 10 nor 12.
+	 */
+	@ParameterizedTest
+	@ValueSource(strings = {
+		"123456789", "12345678901", "1234567890123"
+	})
+	void getFormattedOrganizationNumber_3(final String organizationNumber) {
+		var result = FormattingUtil.getFormattedOrganizationNumber(organizationNumber);
+		assertThat(result).isEqualTo(organizationNumber);
+	}
+}


Reviews:
user: login: Cheezi747
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-25T07:08:16Z
user: login: AndreSoderlund
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-25T07:12:16Z
user: login: Cheezi747
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-25T07:19:44Z

Review comments:
diff_hunk: @@ -18,7 +18,7 @@ public class CaseStatusResponse {
 	private String caseId;
 
 	@Schema(description = "External case id", example = "1234567890")
-	private String externalCaseId; // TODO: Ta bort när samtliga mappningar är uppdaterade
path: src/main/java/se/sundsvall/casestatus/api/model/CaseStatusResponse.java
user: login: Cheezi747
body: Is the `isOpenEErrand` boolean still subject for removal?
created_at: 2025-03-25T07:08:15Z
author_association: CONTRIBUTOR
diff_hunk: @@ -18,7 +18,7 @@ public class CaseStatusResponse {
 	private String caseId;
 
 	@Schema(description = "External case id", example = "1234567890")
-	private String externalCaseId; // TODO: Ta bort när samtliga mappningar är uppdaterade
path: src/main/java/se/sundsvall/casestatus/api/model/CaseStatusResponse.java
user: login: AndreSoderlund
body: Yes, it will instead be shown in the "system" string. So a case with system "OPEN_E_PLATFORM" is in fact a open e errand. 
created_at: 2025-03-25T07:12:16Z
author_association: CONTRIBUTOR

PR comments:
user: login: sonarqubecloud[bot]
created_at: 2025-03-24T15:20:01Z
body: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=Sundsvallskommun_api-service-case-status&pullRequest=160) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=Sundsvallskommun_api-service-case-status&pullRequest=160&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=Sundsvallskommun_api-service-case-status&pullRequest=160&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=Sundsvallskommun_api-service-case-status&pullRequest=160&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=Sundsvallskommun_api-service-case-status&pullRequest=160&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=Sundsvallskommun_api-service-case-status&pullRequest=160&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=Sundsvallskommun_api-service-case-status&pullRequest=160)


author_association: NONE