Skip to content

Commit

Permalink
feat: check if value matches ICD10GM pattern
Browse files Browse the repository at this point in the history
This will do a more concise value check and not only checks if value is null.
  • Loading branch information
pcvolkmer committed Sep 1, 2024
1 parent b89f7fd commit 3aff1e7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public Bundle mapOnkoResourcesToCondition(
// 'Tumorzuordung'
// It's possible that 'Meldung.Diagnose' is set but 'Meldung.Diagnose.Primaertumor_*' is not,
// in that case also use the TumorZuordnung to construct the Condition.
if (primDia == null || primDia.getPrimaertumor_ICD_Code() == null) {
if (primDia == null || !isIcd10GmCode(primDia.getPrimaertumor_ICD_Code())) {
primDia = meldung.getTumorzuordnung();

if (primDia == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,8 @@ public static DateTimeType convertObdsDateToDateTimeType(String obdsDate) {
throw e;
}
}

public static boolean isIcd10GmCode(String value) {
return null != value && value.matches("[A-Z][0-9]{2}(\\.[0-9]{1,2})?");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

import java.time.DateTimeException;
import java.util.Arrays;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.MethodSource;
import org.miracum.streams.ume.obdstofhir.model.ADT_GEKID;
import org.miracum.streams.ume.obdstofhir.model.Meldeanlass;
import org.miracum.streams.ume.obdstofhir.model.MeldungExport;
Expand Down Expand Up @@ -115,4 +118,25 @@ void convertPatientIdWithDefaultPattern(String input, String output) {
var actual = ObdsToFhirMapper.convertId(input);
assertThat(actual).isEqualTo(output);
}

@ParameterizedTest
@MethodSource("icd10GmCodeValidationData")
void checkValueToMatchIcd10Pattern(String input, boolean valid) {
var actual = ObdsToFhirMapper.isIcd10GmCode(input);
assertThat(actual).isEqualTo(valid);
}

private static Stream<Arguments> icd10GmCodeValidationData() {
return Stream.of(
Arguments.of("C00.0", true),
Arguments.of("C37", true),
Arguments.of("C79.88", true),
Arguments.of("C88.20", true),
Arguments.of("C30.0", true),
Arguments.of("D00.0", true),
Arguments.of("D00.000", false),
Arguments.of("CC0.0", false),
Arguments.of("", false),
Arguments.of(null, false));
}
}

0 comments on commit 3aff1e7

Please sign in to comment.