Clean code

This commit is contained in:
dotasek 2022-01-04 13:57:39 -05:00
parent 9fb60f4fed
commit 2d4bbe3749
8 changed files with 3 additions and 29 deletions

View File

@ -165,7 +165,6 @@ public class FhirRequestBuilder {
OkHttpClient.Builder builder = okHttpClient.newBuilder();
if (logger != null) builder.addInterceptor(logger);
builder.addInterceptor(new RetryInterceptor(retryCount));
builder.addInterceptor(TxInterceptor.getInstance());
return builder.connectTimeout(timeout, timeoutUnit)

View File

@ -841,7 +841,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
for (CodingValidationRequest t : codes) {
t.setCacheToken(txCache != null ? txCache.generateValidationToken(options, t.getCoding(), vs) : null);
if (t.getCoding().hasSystem()) {
codeSystemsUsed.add(t.getCoding().getSystem());
codeSystemsUsed.add(t.getCoding().getSystem());
}
if (txCache != null) {
t.setResult(txCache.getValidation(t.getCacheToken()));
@ -962,8 +962,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
updateUnsupportedCodeSystems(res, code, getCodeKey(code));
return res;
}
//FIXME
System.out.print("");
if (options.isUseClient()) {
// ok, first we try to validate locally
try {

View File

@ -164,16 +164,10 @@ public class TerminologyCache {
return ct;
}
private String getValueSetHash(ValueSet vsc) {
final String expansionKey = vsc.getExpansion().getContains().stream().map(x -> x.getCode()).collect(Collectors.joining(","));
final String composeKey = vsc.getCompose().getIncludeFirstRep().getConcept().stream().map(x -> x.getCode()).collect(Collectors.joining(","));
return Integer.toString((expansionKey + "\t" + composeKey).hashCode());
}
public String extracted(JsonParser json, ValueSet vsc) throws IOException {
String s = null;
if (vsc.getExpansion().getContains().size() > 1000 || vsc.getCompose().getIncludeFirstRep().getConcept().size() > 1000) {
s = vsc.getUrl();//getValueSetHash(vsc); // save a hash representation instead of a complete valueset
s = vsc.getUrl();
} else {
s = json.composeString(vsc);
}
@ -187,7 +181,6 @@ public class TerminologyCache {
ct.setName(getNameForSystem(c.getSystem()));
ct.hasVersion = c.hasVersion();
}
JsonParser json = new JsonParser();
json.setOutputStyle(OutputStyle.PRETTY);
ValueSet vsc = getVSEssense(vs);
@ -317,7 +310,6 @@ public class TerminologyCache {
return;
}
boolean n = nc.map.containsKey(cacheToken.key);
nc.map.put(cacheToken.key, e);
if (persistent) {
@ -334,11 +326,9 @@ public class TerminologyCache {
}
public ValidationResult getValidation(CacheToken cacheToken) {
if (cacheToken.key == null) {
return null;
}
synchronized (lock) {
requestCount++;
NamedCache nc = getNamedCache(cacheToken);

View File

@ -23,7 +23,6 @@ import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.npm.IPackageCacheManager;
import org.hl7.fhir.utilities.npm.NpmPackage;
import org.hl7.fhir.utilities.npm.ToolsVersion;
import org.hl7.fhir.utilities.tests.BaseTestingUtilities;

View File

@ -11,12 +11,9 @@ import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.utils.ResourceUtilities;
import org.hl7.fhir.r5.utils.client.EFhirClientException;
import org.hl7.fhir.r5.utils.client.ResourceFormat;
import org.hl7.fhir.utilities.ToolingClientLogger;
import org.hl7.fhir.utilities.TxInterceptor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

View File

@ -5,7 +5,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.context.SimpleWorkerContext;
import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.elementmodel.Manager;

View File

@ -1,8 +1,6 @@
package org.hl7.fhir.utilities;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;

View File

@ -28,7 +28,6 @@ public class ValidationEngineTests {
if (!TestUtilities.silent)
System.out.println("TestCurrentXml: Validate patient-example.xml in Current version");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r4.core#4.0.1", DEF_TX, null, FhirPublication.R4, "4.0.1", "fhir/test-cases");
OperationOutcome op = ve.validate(FhirFormat.XML, TestingUtilities.loadTestResourceStream("validator", "patient-example.xml"), null);
int e = errors(op);
int w = warnings(op);
@ -49,7 +48,6 @@ public class ValidationEngineTests {
if (!TestUtilities.silent)
System.out.println("TestCurrentJson: Validate patient-example.json in Current version");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r4.core#4.0.1", DEF_TX, null, FhirPublication.R4, "4.0.1", "fhir/test-cases");
OperationOutcome op = ve.validate(FhirFormat.JSON, TestingUtilities.loadTestResourceStream("validator", "patient-example.json"), null);
int e = errors(op);
int w = warnings(op);
@ -70,7 +68,6 @@ public class ValidationEngineTests {
if (!TestUtilities.silent)
System.out.println("Test140: Validate patient-example.xml in v1.4.0 version");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r2b.core#1.4.0", DEF_TX, null, FhirPublication.DSTU2016May, "1.4.0", "fhir/test-cases");
ve.getContext().initTS(TestConstants.TX_CACHE);
ve.getContext().setUserAgent("fhir/test-cases");
OperationOutcome op = ve.validate(FhirFormat.XML, TestingUtilities.loadTestResourceStream("validator", "patient140.xml"), null);
if (!TestUtilities.silent)
@ -96,7 +93,6 @@ public class ValidationEngineTests {
if (!org.hl7.fhir.validation.tests.utilities.TestUtilities.silent)
System.out.println("Test102: Validate patient-example.xml in v1.0.2 version");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r2.core#1.0.2", DEF_TX, null, FhirPublication.DSTU2, "1.0.2", "fhir/test-cases");
ve.setNoInvariantChecks(true);
OperationOutcome op = ve.validate(FhirFormat.XML, TestingUtilities.loadTestResourceStream("validator", "patient102.xml"), null);
if (!TestUtilities.silent)
@ -122,7 +118,6 @@ public class ValidationEngineTests {
if (!TestUtilities.silent)
System.out.println("TestObs102: Validate patient-example.xml in v1.0.2 version");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r2.core#1.0.2", DEF_TX, null, FhirPublication.DSTU2, "1.0.2", "fhir/test-cases");
ve.setNoInvariantChecks(true);
OperationOutcome op = ve.validate(FhirFormat.JSON, TestingUtilities.loadTestResourceStream("validator", "observation102.json"), null);
if (!TestUtilities.silent)
@ -145,7 +140,6 @@ public class ValidationEngineTests {
if (!TestUtilities.silent)
System.out.println("Test301: Validate observation301.xml against Core");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r3.core#3.0.2", DEF_TX, null, FhirPublication.STU3, "3.0.2", "fhir/test-cases");
if (!TestUtilities.silent)
System.out.println(" .. load USCore");
OperationOutcome op = ve.validate(FhirFormat.XML, TestingUtilities.loadTestResourceStream("validator", "observation301.xml"), null);
@ -165,7 +159,6 @@ public class ValidationEngineTests {
if (!TestUtilities.silent)
System.out.println("Test301USCore: Validate patient300.xml against US-Core");
ValidationEngine ve = TestUtilities.getValidationEngine("hl7.fhir.r3.core#3.0.2", DEF_TX, null, FhirPublication.STU3, "3.0.2", "fhir/test-cases");
IgLoader igLoader = new IgLoader(ve.getPcm(), ve.getContext(), ve.getVersion(), true);
if (!TestUtilities.silent)
System.out.println(" .. load USCore");