diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java index 443af27a1..324ec0546 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java @@ -1013,17 +1013,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte } } if (batch.getEntry().size() > 0) { - txLog("$batch validate for "+batch.getEntry().size()+" codes on systems "+systems.toString()); - if (tcc.getClient() == null) { - throw new FHIRException(formatMessage(I18nConstants.ATTEMPT_TO_USE_TERMINOLOGY_SERVER_WHEN_NO_TERMINOLOGY_SERVER_IS_AVAILABLE)); - } - if (txLog != null) { - txLog.clearLastId(); - } - Bundle resp = tcc.getClient().validateBatch(batch); - if (resp == null) { - throw new FHIRException(formatMessage(I18nConstants.TX_SERVER_NO_BATCH_RESPONSE)); - } + Bundle resp = processBatch(batch, systems); for (int i = 0; i < batch.getEntry().size(); i++) { CodingValidationRequest t = (CodingValidationRequest) batch.getEntry().get(i).getUserData("source"); BundleEntryComponent r = resp.getEntry().get(i); @@ -1039,6 +1029,21 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte } } } + + private Bundle processBatch(Bundle batch, Set systems) { + txLog("$batch validate for "+batch.getEntry().size()+" codes on systems "+systems.toString()); + if (tcc.getClient() == null) { + throw new FHIRException(formatMessage(I18nConstants.ATTEMPT_TO_USE_TERMINOLOGY_SERVER_WHEN_NO_TERMINOLOGY_SERVER_IS_AVAILABLE)); + } + if (txLog != null) { + txLog.clearLastId(); + } + Bundle resp = tcc.getClient().validateBatch(batch); + if (resp == null) { + throw new FHIRException(formatMessage(I18nConstants.TX_SERVER_NO_BATCH_RESPONSE)); + } + return resp; + } @Override public void validateCodeBatchByRef(ValidationOptions options, List codes, String vsUrl) { @@ -1113,17 +1118,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte } } if (batch.getEntry().size() > 0) { - txLog("$batch validate for "+batch.getEntry().size()+" codes on systems "+systems.toString()); - if (tcc.getClient() == null) { - throw new FHIRException(formatMessage(I18nConstants.ATTEMPT_TO_USE_TERMINOLOGY_SERVER_WHEN_NO_TERMINOLOGY_SERVER_IS_AVAILABLE)); - } - if (txLog != null) { - txLog.clearLastId(); - } - Bundle resp = tcc.getClient().validateBatch(batch); - if (resp == null) { - throw new FHIRException(formatMessage(I18nConstants.TX_SERVER_NO_BATCH_RESPONSE)); - } + Bundle resp = processBatch(batch, systems); for (int i = 0; i < batch.getEntry().size(); i++) { CodingValidationRequest t = (CodingValidationRequest) batch.getEntry().get(i).getUserData("source"); BundleEntryComponent r = resp.getEntry().get(i);