From 81569a39846a363e35aa42f073e6a900e89e497e Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 26 Jan 2024 06:27:24 +1100 Subject: [PATCH] remove duplicate way of handling parameters on expand value set --- .../fhir/convertors/misc/VSACImporter.java | 8 +- .../txClient/TerminologyClientR2.java | 4 +- .../txClient/TerminologyClientR3.java | 4 +- .../txClient/TerminologyClientR4.java | 7 +- .../fhir/dstu2/utils/BaseWorkerContext.java | 11 +-- .../dstu2/utils/client/FHIRToolingClient.java | 42 +-------- .../fhir/dstu3/context/BaseWorkerContext.java | 10 ++- .../dstu3/utils/client/FHIRToolingClient.java | 89 +++++-------------- .../fhir/r4/context/BaseWorkerContext.java | 19 ++-- .../r4/terminologies/TerminologyClient.java | 2 +- .../r4/terminologies/TerminologyClientR4.java | 4 +- .../r4/utils/client/FHIRToolingClient.java | 60 +------------ .../fhir/r5/context/BaseWorkerContext.java | 4 +- .../client/ITerminologyClient.java | 2 +- .../client/TerminologyClientR5.java | 4 +- .../r5/utils/client/FHIRToolingClient.java | 31 ------- .../r5/context/SimpleWorkerContextTests.java | 16 ++-- .../hl7/fhir/validation/special/TxTester.java | 2 +- 18 files changed, 74 insertions(+), 245 deletions(-) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/VSACImporter.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/VSACImporter.java index 82f80d342..8e58459d3 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/VSACImporter.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/misc/VSACImporter.java @@ -23,6 +23,7 @@ import org.hl7.fhir.r4.model.OperationOutcome; import org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity; import org.hl7.fhir.r4.model.OperationOutcome.IssueType; import org.hl7.fhir.r4.model.Parameters; +import org.hl7.fhir.r4.model.UriType; import org.hl7.fhir.r4.model.ValueSet; import org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent; import org.hl7.fhir.r4.utils.client.FHIRToolingClient; @@ -122,7 +123,9 @@ public class VSACImporter extends OIDBasedValueSetImporter { } t = System.currentTimeMillis(); try { - ValueSet vse = fhirToolingClient.expandValueset(vs.getUrl(), null); + Parameters p = new Parameters(); + p.addParameter("url", new UriType(vs.getUrl())); + ValueSet vse = fhirToolingClient.expandValueset(vs, p); vs.setExpansion(vse.getExpansion()); } catch (Exception e) { errs.put(oid, "Expansion: " +e.getMessage()); @@ -132,9 +135,10 @@ public class VSACImporter extends OIDBasedValueSetImporter { Parameters p = new Parameters(); int offset = vs.getExpansion().getParameter("offset").getValueIntegerType().getValue() + vs.getExpansion().getParameter("count").getValueIntegerType().getValue(); p.addParameter("offset", offset); + p.addParameter("url", new UriType(vs.getUrl())); t = System.currentTimeMillis(); try { - ValueSet vse = fhirToolingClient.expandValueset(vs.getUrl(), p); + ValueSet vse = fhirToolingClient.expandValueset(vs, p); vs.getExpansion().getContains().addAll(vse.getExpansion().getContains()); vs.getExpansion().setParameter(vse.getExpansion().getParameter()); } catch (Exception e2) { diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientR2.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientR2.java index 0fef139d3..31cdb891f 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientR2.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientR2.java @@ -104,10 +104,10 @@ public class TerminologyClientR2 implements ITerminologyClient { } @Override - public ValueSet expandValueset(ValueSet vs, Parameters p, Map params) throws FHIRException { + public ValueSet expandValueset(ValueSet vs, Parameters p) throws FHIRException { org.hl7.fhir.dstu2.model.ValueSet vs2 = (org.hl7.fhir.dstu2.model.ValueSet) VersionConvertorFactory_10_50.convertResource(vs); org.hl7.fhir.dstu2.model.Parameters p2 = (org.hl7.fhir.dstu2.model.Parameters) VersionConvertorFactory_10_50.convertResource(p); - vs2 = client.expandValueset(vs2, p2, params); + vs2 = client.expandValueset(vs2, p2); return (ValueSet) VersionConvertorFactory_10_50.convertResource(vs2); } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientR3.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientR3.java index c874203d0..8aa22c3e5 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientR3.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientR3.java @@ -101,10 +101,10 @@ public class TerminologyClientR3 implements ITerminologyClient { } @Override - public ValueSet expandValueset(ValueSet vs, Parameters p, Map params) throws FHIRException { + public ValueSet expandValueset(ValueSet vs, Parameters p) throws FHIRException { org.hl7.fhir.dstu3.model.ValueSet vs2 = (org.hl7.fhir.dstu3.model.ValueSet) VersionConvertorFactory_30_50.convertResource(vs); org.hl7.fhir.dstu3.model.Parameters p2 = (org.hl7.fhir.dstu3.model.Parameters) VersionConvertorFactory_30_50.convertResource(p); - vs2 = client.expandValueset(vs2, p2, params); // todo: second parameter + vs2 = client.expandValueset(vs2, p2); // todo: second parameter return (ValueSet) VersionConvertorFactory_30_50.convertResource(vs2); } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientR4.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientR4.java index a39c4e138..e0af0a4ff 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientR4.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientR4.java @@ -78,14 +78,11 @@ public class TerminologyClientR4 implements ITerminologyClient { } @Override - public ValueSet expandValueset(ValueSet vs, Parameters p, Map params) throws FHIRException { + public ValueSet expandValueset(ValueSet vs, Parameters p) throws FHIRException { org.hl7.fhir.r4.model.ValueSet vs2 = vs == null ? null : (org.hl7.fhir.r4.model.ValueSet) VersionConvertorFactory_40_50.convertResource(vs); org.hl7.fhir.r4.model.Parameters p2 = p == null ? null : (org.hl7.fhir.r4.model.Parameters) VersionConvertorFactory_40_50.convertResource(p); - if (params == null) { - params = new HashMap<>(); - } try { - vs2 = client.expandValueset(vs2, p2, params); // todo: second parameter + vs2 = client.expandValueset(vs2, p2); // todo: second parameter return (ValueSet) VersionConvertorFactory_40_50.convertResource(vs2); } catch (org.hl7.fhir.r4.utils.client.EFhirClientException e) { if (e.getServerErrors().size() > 0) { diff --git a/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/utils/BaseWorkerContext.java b/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/utils/BaseWorkerContext.java index 4f5a42b0b..fff3d361f 100644 --- a/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/utils/BaseWorkerContext.java +++ b/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/utils/BaseWorkerContext.java @@ -48,6 +48,7 @@ import org.hl7.fhir.dstu2.model.Coding; import org.hl7.fhir.dstu2.model.ConceptMap; import org.hl7.fhir.dstu2.model.Conformance; import org.hl7.fhir.dstu2.model.Extension; +import org.hl7.fhir.dstu2.model.IntegerType; import org.hl7.fhir.dstu2.model.Parameters; import org.hl7.fhir.dstu2.model.Parameters.ParametersParameterComponent; import org.hl7.fhir.dstu2.model.Reference; @@ -115,11 +116,11 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte @Override public ValueSetExpansionOutcome expandVS(ValueSet vs, boolean cacheOk) { try { - Map params = new HashMap(); - params.put("_limit", "10000"); - params.put("_incomplete", "true"); - params.put("profile", "http://www.healthintersections.com.au/fhir/expansion/no-details"); - ValueSet result = txServer.expandValueset(vs, null, params); + Parameters params = new Parameters(); + params.addParameter().setName("_limit").setValue(new IntegerType("10000")); + params.addParameter().setName("_incomplete").setValue(new BooleanType("true")); + params.addParameter().setName("profile").setValue(new UriType("http://www.healthintersections.com.au/fhir/expansion/no-details")); + ValueSet result = txServer.expandValueset(vs, params); return new ValueSetExpansionOutcome(result); } catch (Exception e) { return new ValueSetExpansionOutcome("Error expanding ValueSet \"" + vs.getUrl() + ": " + e.getMessage()); diff --git a/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/utils/client/FHIRToolingClient.java b/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/utils/client/FHIRToolingClient.java index 196c4626b..bf726ea34 100644 --- a/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/utils/client/FHIRToolingClient.java +++ b/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/utils/client/FHIRToolingClient.java @@ -724,26 +724,6 @@ public class FHIRToolingClient extends FHIRBaseToolingClient { return feed; } - public ValueSet expandValueset(ValueSet source) { - recordUse(); - List
headers = null; - ResourceRequest result = utils.issuePostRequest( - resourceAddress.resolveOperationUri(ValueSet.class, "expand"), - utils.getResourceAsByteArray(source, false, isJson(getPreferredResourceFormat())), withVer(getPreferredResourceFormat(), "1.0"), - headers, timeoutLong); - result.addErrorStatus(410);// gone - result.addErrorStatus(404);// unknown - result.addErrorStatus(405); - result.addErrorStatus(422);// Unprocessable Entity - result.addSuccessStatus(200); - result.addSuccessStatus(201); - if (result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), - (OperationOutcome) result.getPayload()); - } - return (ValueSet) result.getPayload(); - } - public Parameters lookupCode(Map params) { recordUse(); ResourceRequest result = utils.issueGetResourceRequest( @@ -762,15 +742,13 @@ public class FHIRToolingClient extends FHIRBaseToolingClient { return (Parameters) result.getPayload(); } - public ValueSet expandValueset(ValueSet source, Parameters expParams, Map params) { + public ValueSet expandValueset(ValueSet source, Parameters expParams) { recordUse(); List
headers = null; Parameters p = expParams == null ? new Parameters() : expParams.copy(); p.addParameter().setName("valueSet").setResource(source); - for (String n : params.keySet()) - p.addParameter().setName(n).setValue(new StringType(params.get(n))); ResourceRequest result = utils.issuePostRequest( - resourceAddress.resolveOperationUri(ValueSet.class, "expand", params), + resourceAddress.resolveOperationUri(ValueSet.class, "expand"), utils.getResourceAsByteArray(p, false, isJson(getPreferredResourceFormat())), withVer(getPreferredResourceFormat(), "1.0"), headers, 4); result.addErrorStatus(410); // gone @@ -786,22 +764,6 @@ public class FHIRToolingClient extends FHIRBaseToolingClient { return (ValueSet) result.getPayload(); } -// public ValueSet expandValueset(ValueSet source, ExpansionProfile profile, Map params) { -// List
headers = null; -// ResourceRequest result = utils.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand", params), -// utils.getResourceAsByteArray(source, false, isJson(getPreferredResourceFormat())), withVer(getPreferredResourceFormat(), "1.0"), headers, proxy); -// result.addErrorStatus(410);//gone -// result.addErrorStatus(404);//unknown -// result.addErrorStatus(405); -// result.addErrorStatus(422);//Unprocessable Entity -// result.addSuccessStatus(200); -// result.addSuccessStatus(201); -// if(result.isUnsuccessfulRequest()) { -// throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome)result.getPayload()); -// } -// return (ValueSet) result.getPayload(); -// } - public String getAddress() { return base; } diff --git a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/context/BaseWorkerContext.java b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/context/BaseWorkerContext.java index 2fa518684..dd9a59f1b 100644 --- a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/context/BaseWorkerContext.java +++ b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/context/BaseWorkerContext.java @@ -60,6 +60,7 @@ import org.hl7.fhir.dstu3.model.Coding; import org.hl7.fhir.dstu3.model.ConceptMap; import org.hl7.fhir.dstu3.model.DataElement; import org.hl7.fhir.dstu3.model.ExpansionProfile; +import org.hl7.fhir.dstu3.model.IntegerType; import org.hl7.fhir.dstu3.model.OperationDefinition; import org.hl7.fhir.dstu3.model.OperationOutcome; import org.hl7.fhir.dstu3.model.Parameters; @@ -448,11 +449,12 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte } try { - Map params = new HashMap(); - params.put("_limit", Integer.toString(expandCodesLimit)); - params.put("_incomplete", "true"); + Parameters params = new Parameters(); + params.addParameter().setName("profile").setResource(expProfile.setIncludeDefinition(false)); + params.addParameter().setName("_limit").setValue(new IntegerType(expandCodesLimit)); + params.addParameter().setName("_incomplete").setValue(new BooleanType("true")); tlog("Terminology Server: $expand on " + getVSSummary(vs)); - ValueSet result = txServer.expandValueset(vs, expProfile.setIncludeDefinition(false), params); + ValueSet result = txServer.expandValueset(vs, params); return new ValueSetExpansionOutcome(result); } catch (Exception e) { return new ValueSetExpansionOutcome( diff --git a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/client/FHIRToolingClient.java b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/client/FHIRToolingClient.java index 36ddba865..1b13b9947 100644 --- a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/client/FHIRToolingClient.java +++ b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/client/FHIRToolingClient.java @@ -414,6 +414,25 @@ public class FHIRToolingClient extends FHIRBaseToolingClient { return feed; } + public Parameters lookupCode(Map params) { + recordUse(); + org.hl7.fhir.dstu3.utils.client.network.ResourceRequest result = null; + try { + result = client.issueGetResourceRequest(resourceAddress.resolveOperationUri(CodeSystem.class, "lookup", params), + withVer(getPreferredResourceFormat(), "3.0"), + generateHeaders(), + "CodeSystem/$lookup", + timeoutNormal); + } catch (IOException e) { + e.printStackTrace(); + } + if (result.isUnsuccessfulRequest()) { + throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); + } + return (Parameters) result.getPayload(); + } + + public ValueSet expandValueset(ValueSet source, Parameters expParams) { recordUse(); Parameters p = expParams == null ? new Parameters() : expParams.copy(); @@ -434,75 +453,7 @@ public class FHIRToolingClient extends FHIRBaseToolingClient { } return result == null ? null : (ValueSet) result.getPayload(); } - - - public Parameters lookupCode(Map params) { - recordUse(); - org.hl7.fhir.dstu3.utils.client.network.ResourceRequest result = null; - try { - result = client.issueGetResourceRequest(resourceAddress.resolveOperationUri(CodeSystem.class, "lookup", params), - withVer(getPreferredResourceFormat(), "3.0"), - generateHeaders(), - "CodeSystem/$lookup", - timeoutNormal); - } catch (IOException e) { - e.printStackTrace(); - } - if (result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); - } - return (Parameters) result.getPayload(); - } - - public ValueSet expandValueset(ValueSet source, ExpansionProfile profile, Map params) { - recordUse(); - Parameters p = new Parameters(); - p.addParameter().setName("valueSet").setResource(source); - if (profile != null) - p.addParameter().setName("profile").setResource(profile); - - org.hl7.fhir.dstu3.utils.client.network.ResourceRequest result = null; - try { - result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand", params), - ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())), - withVer(getPreferredResourceFormat(), "3.0"), - generateHeaders(), - "ValueSet/$expand?url=" + source.getUrl(), - timeoutExpand); - if (result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); - } - } catch (IOException e) { - e.printStackTrace(); - } - return result == null ? null : (ValueSet) result.getPayload(); - } - - public ValueSet expandValueset(ValueSet source, Parameters expParams, Map params) { - recordUse(); - Parameters p = expParams == null ? new Parameters() : expParams.copy(); - p.addParameter().setName("valueSet").setResource(source); - for (String n : params.keySet()) { - p.addParameter().setName(n).setValue(new StringType(params.get(n))); - } - org.hl7.fhir.dstu3.utils.client.network.ResourceRequest result = null; - try { - - result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand", params), - ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())), - withVer(getPreferredResourceFormat(), "3.0"), - generateHeaders(), - "ValueSet/$expand?url=" + source.getUrl(), - timeoutExpand); - if (result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); - } - } catch (IOException e) { - e.printStackTrace(); - } - return result == null ? null : (ValueSet) result.getPayload(); - } - + public String getAddress() { return base; } diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/BaseWorkerContext.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/BaseWorkerContext.java index 46c29efac..4b22b4cc9 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/BaseWorkerContext.java @@ -30,6 +30,7 @@ import org.hl7.fhir.r4.model.ConceptMap; import org.hl7.fhir.r4.model.Constants; import org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent; import org.hl7.fhir.r4.model.ImplementationGuide; +import org.hl7.fhir.r4.model.IntegerType; import org.hl7.fhir.r4.model.MetadataResource; import org.hl7.fhir.r4.model.NamingSystem; import org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType; @@ -403,12 +404,13 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte if (noTerminologyServer) return new ValueSetExpansionOutcome("Error expanding ValueSet: running without terminology services", TerminologyServiceErrorClass.NOSERVICE); - Map params = new HashMap(); - params.put("_limit", Integer.toString(expandCodesLimit)); - params.put("_incomplete", "true"); + + p.addParameter().setName("_limit").setValue(new IntegerType(expandCodesLimit)); + p.addParameter().setName("_incomplete").setValue(new BooleanType("true")); + tlog("$expand on " + txCache.summary(vs)); try { - ValueSet result = txClient.expandValueset(vs, p, params); + ValueSet result = txClient.expandValueset(vs, p); res = new ValueSetExpansionOutcome(result).setTxLink(txLog.getLastId()); } catch (Exception e) { res = new ValueSetExpansionOutcome(e.getMessage() == null ? e.getClass().getName() : e.getMessage(), @@ -463,12 +465,13 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte if (noTerminologyServer) return new ValueSetExpansionOutcome("Error expanding ValueSet: running without terminology services", TerminologyServiceErrorClass.NOSERVICE); - Map params = new HashMap(); - params.put("_limit", Integer.toString(expandCodesLimit)); - params.put("_incomplete", "true"); + + p.addParameter().setName("_limit").setValue(new IntegerType(expandCodesLimit)); + p.addParameter().setName("_incomplete").setValue(new BooleanType("true")); + tlog("$expand on " + txCache.summary(vs)); try { - ValueSet result = txClient.expandValueset(vs, p, params); + ValueSet result = txClient.expandValueset(vs, p); if (result != null) { if (!result.hasUrl()) result.setUrl(vs.getUrl()); diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/terminologies/TerminologyClient.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/terminologies/TerminologyClient.java index 73f176c6e..e99656ddc 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/terminologies/TerminologyClient.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/terminologies/TerminologyClient.java @@ -43,7 +43,7 @@ public interface TerminologyClient { public TerminologyCapabilities getTerminologyCapabilities() throws FHIRException; - public ValueSet expandValueset(ValueSet vs, Parameters p, Map params) throws FHIRException; + public ValueSet expandValueset(ValueSet vs, Parameters p) throws FHIRException; public Parameters validateCS(Parameters pin) throws FHIRException; diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/terminologies/TerminologyClientR4.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/terminologies/TerminologyClientR4.java index 038b2eda8..2b1e53ac2 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/terminologies/TerminologyClientR4.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/terminologies/TerminologyClientR4.java @@ -63,8 +63,8 @@ public class TerminologyClientR4 implements TerminologyClient { } @Override - public ValueSet expandValueset(ValueSet vs, Parameters p, Map params) { - return client.expandValueset(vs, p, params); + public ValueSet expandValueset(ValueSet vs, Parameters p) { + return client.expandValueset(vs, p); } @Override diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/client/FHIRToolingClient.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/client/FHIRToolingClient.java index f41c8c6fb..0bf34c779 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/client/FHIRToolingClient.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/client/FHIRToolingClient.java @@ -403,55 +403,6 @@ public class FHIRToolingClient extends FHIRBaseToolingClient { return feed; } - public ValueSet expandValueset(String vsUrl, Parameters expParams) { - recordUse(); - Map parameters = new HashMap<>(); - parameters.put("url", vsUrl); - if (expParams != null) { - for (ParametersParameterComponent p : expParams.getParameter()) { - if (p.getValue() == null) { - throw new FHIRException("Non-value Parameters are not supported for parameter '"+p.getName()+"'"); - } else if (p.getValue() instanceof PrimitiveType) { - parameters.put(p.getName(), p.getValue().primitiveValue()); - } else { - throw new FHIRException("Complex Parameters are not supported for parameter '"+p.getName()+"'"); - } - } - } - - org.hl7.fhir.r4.utils.client.network.ResourceRequest result = null; - try { - result = client.issueGetResourceRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand", parameters), - withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(), "ValueSet/$expand?url=" + vsUrl, timeoutExpand); - } catch (IOException e) { - throw new FHIRException(e); - } - if (result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), - (OperationOutcome) result.getPayload()); - } - return result == null ? null : (ValueSet) result.getPayload(); - } - - public ValueSet expandValueset(ValueSet source, Parameters expParams) { - recordUse(); - Parameters p = expParams == null ? new Parameters() : expParams.copy(); - p.addParameter().setName("valueSet").setResource(source); - org.hl7.fhir.r4.utils.client.network.ResourceRequest result = null; - try { - result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand"), - ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())), withVer(getPreferredResourceFormat(), "4.0"), - generateHeaders(), "ValueSet/$expand?url=" + source.getUrl(), timeoutExpand); - if (result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), - (OperationOutcome) result.getPayload()); - } - } catch (IOException e) { - throw new FHIRException(e); - } - return result == null ? null : (ValueSet) result.getPayload(); - } - public Parameters lookupCode(Map params) { recordUse(); org.hl7.fhir.r4.utils.client.network.ResourceRequest result = null; @@ -467,19 +418,14 @@ public class FHIRToolingClient extends FHIRBaseToolingClient { } return (Parameters) result.getPayload(); } - - public ValueSet expandValueset(ValueSet source, Parameters expParams, Map params) { + + public ValueSet expandValueset(ValueSet source, Parameters expParams) { recordUse(); Parameters p = expParams == null ? new Parameters() : expParams.copy(); p.addParameter().setName("valueSet").setResource(source); - if (params != null) { - for (String n : params.keySet()) { - p.addParameter().setName(n).setValue(new StringType(params.get(n))); - } - } org.hl7.fhir.r4.utils.client.network.ResourceRequest result = null; try { - result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand", params), + result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand"), ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())), withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(), source == null ? "ValueSet/$expand" : "ValueSet/$expand?url=" + source.getUrl(), timeoutExpand); 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 cadbb5429..d42510ef1 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 @@ -874,7 +874,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte } try { - ValueSet result = tc.getClient().expandValueset(vs, p, null); + ValueSet result = tc.getClient().expandValueset(vs, p); res = new ValueSetExpansionOutcome(result).setTxLink(txLog.getLastId()); } catch (Exception e) { res = new ValueSetExpansionOutcome(e.getMessage() == null ? e.getClass().getName() : e.getMessage(), TerminologyServiceErrorClass.UNKNOWN, true); @@ -985,7 +985,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte txLog("$expand on "+txCache.summary(vs)+" on "+tc.getAddress()); try { - ValueSet result = tc.getClient().expandValueset(vs, p, null); + ValueSet result = tc.getClient().expandValueset(vs, p); if (result != null) { if (!result.hasUrl()) { result.setUrl(vs.getUrl()); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/client/ITerminologyClient.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/client/ITerminologyClient.java index b6f23c248..e5bbf0a2b 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/client/ITerminologyClient.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/client/ITerminologyClient.java @@ -51,7 +51,7 @@ public interface ITerminologyClient { String getAddress(); String getServerVersion(); TerminologyCapabilities getTerminologyCapabilities() throws FHIRException; - ValueSet expandValueset(ValueSet vs, Parameters p, Map params) throws FHIRException; + ValueSet expandValueset(ValueSet vs, Parameters p) throws FHIRException; Parameters validateCS(Parameters pin) throws FHIRException; Parameters validateVS(Parameters pin) throws FHIRException; ITerminologyClient setTimeoutFactor(int i) throws FHIRException; diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/client/TerminologyClientR5.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/client/TerminologyClientR5.java index 27d90c705..002be62a3 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/client/TerminologyClientR5.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/client/TerminologyClientR5.java @@ -126,8 +126,8 @@ public class TerminologyClientR5 implements ITerminologyClient { } @Override - public ValueSet expandValueset(ValueSet vs, Parameters p, Map params) { - return client.expandValueset(vs, p, params); + public ValueSet expandValueset(ValueSet vs, Parameters p) { + return client.expandValueset(vs, p); } @Override diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/FHIRToolingClient.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/FHIRToolingClient.java index ca08d72a6..543053f3f 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/FHIRToolingClient.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/client/FHIRToolingClient.java @@ -470,7 +470,6 @@ public class FHIRToolingClient extends FHIRBaseToolingClient { return result == null ? null : (ValueSet) result.getPayload(); } - public Parameters lookupCode(Map params) { recordUse(); org.hl7.fhir.r5.utils.client.network.ResourceRequest result = null; @@ -489,36 +488,6 @@ public class FHIRToolingClient extends FHIRBaseToolingClient { return (Parameters) result.getPayload(); } - public ValueSet expandValueset(ValueSet source, Parameters expParams, Map params) { - recordUse(); - Parameters p = expParams == null ? new Parameters() : expParams.copy(); - if (source != null) { - p.addParameter().setName("valueSet").setResource(source); - } - if (params == null) { - params = new HashMap<>(); - } - for (String n : params.keySet()) { - p.addParameter().setName(n).setValue(new StringType(params.get(n))); - } - org.hl7.fhir.r5.utils.client.network.ResourceRequest result = null; - try { - - result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand", params), - ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())), - withVer(getPreferredResourceFormat(), "4.0"), - generateHeaders(), - source == null ? "ValueSet/$expand" : "ValueSet/$expand?url=" + source.getUrl(), - timeoutExpand); - if (result.isUnsuccessfulRequest()) { - throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload()); - } - } catch (IOException e) { - e.printStackTrace(); - } - return result == null ? null : (ValueSet) result.getPayload(); - } - public String getAddress() { return base; } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java index e355da54e..1170718e0 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java @@ -101,12 +101,6 @@ public class SimpleWorkerContextTests { context.txLog = txLog; } - private final static Map params = new HashMap<>(); - static { - params.put("_limit", Integer.toString(1000)); - params.put("_incomplete", "true"); - } - private final static Parameters pInWithDependentResources = new Parameters(); static { pInWithDependentResources.addParameter("includeDefinition", false); @@ -302,7 +296,7 @@ public class SimpleWorkerContextTests { Mockito.verify(terminologyCache).getExpansion(cacheToken); Mockito.verify(terminologyCache, times(0)).cacheExpansion(any(), any(), anyBoolean()); - Mockito.verify(terminologyClient, times(0)).expandValueset(any(), any(), any()); + Mockito.verify(terminologyClient, times(0)).expandValueset(any(), any()); } @Test @@ -327,7 +321,7 @@ public class SimpleWorkerContextTests { Mockito.doReturn(expectedValueSet).when(terminologyClient).expandValueset(argThat(new ValueSetMatcher(vs)), - argThat(new ParametersMatcher(pInWithDependentResources)), eq(params)); + argThat(new ParametersMatcher(pInWithDependentResources))); ValueSetExpansionOutcome actualExpansionResult = context.expandVS(inc, true, false); @@ -354,7 +348,7 @@ public class SimpleWorkerContextTests { Mockito.verify(terminologyCache).getExpansion(cacheToken); Mockito.verify(terminologyCache, times(0)).cacheExpansion(any(), any(), anyBoolean()); - Mockito.verify(terminologyClient, times(0)).expandValueset(any(), any(), any()); + Mockito.verify(terminologyClient, times(0)).expandValueset(any(), any()); } private class ValidationOptionsFhirPublicationMatcher implements ArgumentMatcher { @@ -393,7 +387,7 @@ public class SimpleWorkerContextTests { Mockito.verify(terminologyCache).getExpansion(cacheToken); Mockito.verify(terminologyCache).cacheExpansion(cacheToken, actualExpansionResult, false); - Mockito.verify(terminologyClient, times(0)).expandValueset(any(), any(), any()); + Mockito.verify(terminologyClient, times(0)).expandValueset(any(), any()); } @Test @@ -414,7 +408,7 @@ public class SimpleWorkerContextTests { Mockito.doReturn(valueSetExpanderSimple).when(context).constructValueSetExpanderSimple(argThat(new ValidationOptionsFhirPublicationMatcher(vs.getFHIRPublicationVersion()))); - Mockito.doReturn(expectedValueSet).when(terminologyClient).expandValueset(eq(vs), argThat(new ParametersMatcher(pInWithDependentResources)), eq(params)); + Mockito.doReturn(expectedValueSet).when(terminologyClient).expandValueset(eq(vs), argThat(new ParametersMatcher(pInWithDependentResources))); ValueSetExpansionOutcome actualExpansionResult = context.expandVS(vs, true, true, true, pIn, false); diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/special/TxTester.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/special/TxTester.java index 5be5a1237..3a5b89e3a 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/special/TxTester.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/special/TxTester.java @@ -256,7 +256,7 @@ public class TxTester { p.getParameter().addAll(profile.getParameter()); String vsj; try { - ValueSet vs = tx.expandValueset(null, p, null); + ValueSet vs = tx.expandValueset(null, p); TxTesterScrubbers.scrubVS(vs, tight); TxTesterSorters.sortValueSet(vs); vsj = new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).composeString(vs);