mirror of
https://github.com/pcvolkmer/etl-processor.git
synced 2025-04-19 17:26:51 +00:00
fix: removed gaps system from GPAS pseudonym value. Also added clean up method, which will replace filename invalid characters witch '_'. (#11)
This commit is contained in:
parent
2f32834de0
commit
bf8f87b261
@ -127,7 +127,21 @@ public class GpasPseudonymGenerator implements Generator {
|
||||
.orElseGet(ParametersParameterComponent::new).getValue();
|
||||
|
||||
// pseudonym
|
||||
return identifier.getSystem() + "|" + identifier.getValue();
|
||||
return sanitizeValue(identifier.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow only filename friendly values
|
||||
*
|
||||
* @param psnValue GAPS pseudonym value
|
||||
* @return cleaned up value
|
||||
*/
|
||||
public static String sanitizeValue(String psnValue) {
|
||||
// pattern to match forbidden characters
|
||||
String forbiddenCharsRegex = "[\\\\/:*?\"<>|;]";
|
||||
|
||||
// Replace all forbidden characters with underscores
|
||||
return psnValue.replaceAll(forbiddenCharsRegex, "_");
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,6 +70,13 @@ class PseudonymizeServiceTest {
|
||||
assertThat(mtbFile.patient.id).isEqualTo("123")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sanitizeFileName(@Mock generator: GpasPseudonymGenerator) {
|
||||
val result= GpasPseudonymGenerator.sanitizeValue("l://a\\bs;1*2?3>")
|
||||
|
||||
assertThat(result).isEqualTo("l___a_bs_1_2_3_")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldUsePseudonymPrefixForBuiltin(@Mock generator: AnonymizingGenerator) {
|
||||
doAnswer {
|
||||
|
Loading…
x
Reference in New Issue
Block a user