-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: check if Pat-ID is reasonable value (#90)
* test: add test for existing method This includes simple refac by returning early if match has been found * feat: add configuration for patient id pattern * test: default pattern is used w/o config * docs: use config entry as usage example * test: add test data for old PatIDs in Erlangen with first digit "G" * chore: update logging message This updates the logging message shown if the input does not match the pattern. Co-authored-by: chgl <[email protected]> * config: update config entry to lowercase kebab-case This also re enables this config option with a default value. Co-authored-by: chgl <[email protected]> * chore: change @value to match lowercase kebab case Co-authored-by: chgl <[email protected]> * docs: change inline comments in unit tests Co-authored-by: chgl <[email protected]> --------- Co-authored-by: chgl <[email protected]>
- Loading branch information
Showing
4 changed files
with
98 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/test/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsToFhirIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.miracum.streams.ume.obdstofhir.mapper; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvSource; | ||
import org.miracum.streams.ume.obdstofhir.FhirProperties; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.test.context.TestPropertySource; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
|
||
@ExtendWith(SpringExtension.class) | ||
@Import({ObdsTestMapper.class}) | ||
@MockBean(FhirProperties.class) | ||
public class ObdsToFhirIntegrationTest { | ||
|
||
@Autowired ObdsTestMapper mapper; | ||
|
||
@Nested | ||
@TestPropertySource(properties = {"app.patient-id-pattern=\\\\w*"}) | ||
class AllWordCharactersAllowedPattern { | ||
|
||
@ParameterizedTest | ||
@CsvSource({ | ||
"12345,12345", | ||
"123456789,123456789", | ||
"1234567890,1234567890", | ||
"1234567891,1234567891", | ||
"0000012345,0000012345" | ||
}) | ||
void applyLocalPatientIdPattern(String input, String output) { | ||
var actual = ObdsToFhirMapper.convertId(input); | ||
assertThat(actual).isEqualTo(output); | ||
} | ||
} | ||
|
||
@Nested | ||
class UseDefaultPatternWithoutConfig { | ||
|
||
@ParameterizedTest | ||
@CsvSource({ | ||
"12345,12345", | ||
"123456789,123456789", | ||
"1234567890,123456789", // Max 9 digits, remove last digit '0' | ||
"1234567891,123456789", // Max 9 digits, remove last digit '1' | ||
"0000012345,0000012345", // Not mathching pattern - keep as is | ||
}) | ||
void applyDefaultPattern(String input, String output) { | ||
var actual = ObdsToFhirMapper.convertId(input); | ||
assertThat(actual).isEqualTo(output); | ||
} | ||
} | ||
} | ||
|
||
@Component | ||
class ObdsTestMapper extends ObdsToFhirMapper { | ||
|
||
protected ObdsTestMapper(FhirProperties fhirProperties) { | ||
super(fhirProperties); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters