mirror of
https://github.com/pcvolkmer/etl-processor.git
synced 2025-04-20 01:36:50 +00:00
Throw PseudonymRequestFailed exception with error message
This will throw an exception with error message describing what the error is instead of having a more generic NoSuchElementException to be thrown if Optional.get() has no value after calling findFirst() on an empty stream.
This commit is contained in:
parent
5bd26b894c
commit
9921e1e684
@ -108,12 +108,19 @@ public class GpasPseudonymGenerator implements Generator {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String unwrapPseudonym(Parameters gPasPseudonymResult) {
|
public static String unwrapPseudonym(Parameters gPasPseudonymResult) {
|
||||||
Identifier pseudonym = (Identifier) gPasPseudonymResult.getParameter().stream().findFirst()
|
final var parameters = gPasPseudonymResult.getParameter().stream().findFirst();
|
||||||
.get().getPart().stream().filter(a -> a.getName().equals("pseudonym")).findFirst()
|
|
||||||
|
if (parameters.isEmpty()) {
|
||||||
|
throw new PseudonymRequestFailed("Empty HL7 parameters, cannot find first one");
|
||||||
|
}
|
||||||
|
|
||||||
|
final var identifier = (Identifier) parameters.get().getPart().stream()
|
||||||
|
.filter(a -> a.getName().equals("pseudonym"))
|
||||||
|
.findFirst()
|
||||||
.orElseGet(ParametersParameterComponent::new).getValue();
|
.orElseGet(ParametersParameterComponent::new).getValue();
|
||||||
|
|
||||||
// pseudonym
|
// pseudonym
|
||||||
return pseudonym.getSystem() + "|" + pseudonym.getValue();
|
return identifier.getSystem() + "|" + identifier.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user