Merge commit '3a1946e37d99d43c0f49bd8b75c48209cce44546' into do-20240122-base-engine

This commit is contained in:
dotasek.dev 2024-01-30 10:40:47 -05:00
commit 14f2837b2b
51 changed files with 436 additions and 630 deletions

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>6.2.15-SNAPSHOT</version>
<version>6.2.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -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) {

View File

@ -104,10 +104,10 @@ public class TerminologyClientR2 implements ITerminologyClient {
}
@Override
public ValueSet expandValueset(ValueSet vs, Parameters p, Map<String, String> 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);
}

View File

@ -101,10 +101,10 @@ public class TerminologyClientR3 implements ITerminologyClient {
}
@Override
public ValueSet expandValueset(ValueSet vs, Parameters p, Map<String, String> 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);
}

View File

@ -78,14 +78,11 @@ public class TerminologyClientR4 implements ITerminologyClient {
}
@Override
public ValueSet expandValueset(ValueSet vs, Parameters p, Map<String, String> 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) {

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>6.2.15-SNAPSHOT</version>
<version>6.2.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -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<String, String> params = new HashMap<String, String>();
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());

View File

@ -724,26 +724,6 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
return feed;
}
public ValueSet expandValueset(ValueSet source) {
recordUse();
List<Header> headers = null;
ResourceRequest<Resource> 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<String, String> params) {
recordUse();
ResourceRequest<Resource> result = utils.issueGetResourceRequest(
@ -762,15 +742,13 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
return (Parameters) result.getPayload();
}
public ValueSet expandValueset(ValueSet source, Parameters expParams, Map<String, String> params) {
public ValueSet expandValueset(ValueSet source, Parameters expParams) {
recordUse();
List<Header> 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<Resource> 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<String, String> params) {
// List<Header> headers = null;
// ResourceRequest<Resource> 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;
}

View File

@ -87,7 +87,7 @@ public class ResourceAddress {
}
public <T extends Resource> URI resolveOperationUri(Class<T> resourceClass, String opName) {
return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) + "/" + opName);
return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) + "$" + opName);
}
public <T extends Resource> URI resolveOperationUri(Class<T> resourceClass, String opName,

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>6.2.15-SNAPSHOT</version>
<version>6.2.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -87,7 +87,7 @@ public class ResourceAddress {
}
public <T extends Resource> URI resolveOperationUri(Class<T> resourceClass, String opName) {
return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) + "/" + opName);
return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) + "$" + opName);
}
public <T extends Resource> URI resolveOperationUri(Class<T> resourceClass, String opName,

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>6.2.15-SNAPSHOT</version>
<version>6.2.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -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<String, String> params = new HashMap<String, String>();
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(

View File

@ -414,28 +414,6 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
return feed;
}
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.dstu3.utils.client.network.ResourceRequest<Resource> result = null;
try {
result = client.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand"),
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 Parameters lookupCode(Map<String, String> params) {
recordUse();
org.hl7.fhir.dstu3.utils.client.network.ResourceRequest<Resource> result = null;
@ -454,41 +432,14 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
return (Parameters) result.getPayload();
}
public ValueSet expandValueset(ValueSet source, ExpansionProfile profile, Map<String, String> 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<Resource> 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<String, String> params) {
public ValueSet expandValueset(ValueSet source, Parameters expParams) {
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<Resource> 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(), "3.0"),
generateHeaders(),

View File

@ -93,7 +93,7 @@ public class ResourceAddress {
}
public <T extends Resource> URI resolveOperationUri(Class<T> resourceClass, String opName) {
return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) +"/"+opName);
return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) +"$"+opName);
}
public <T extends Resource> URI resolveOperationUri(Class<T> resourceClass, String opName, Map<String,String> parameters) {

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>6.2.15-SNAPSHOT</version>
<version>6.2.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -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<String, String> params = new HashMap<String, String>();
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<String, String> params = new HashMap<String, String>();
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());

View File

@ -43,7 +43,7 @@ public interface TerminologyClient {
public TerminologyCapabilities getTerminologyCapabilities() throws FHIRException;
public ValueSet expandValueset(ValueSet vs, Parameters p, Map<String, String> params) throws FHIRException;
public ValueSet expandValueset(ValueSet vs, Parameters p) throws FHIRException;
public Parameters validateCS(Parameters pin) throws FHIRException;

View File

@ -63,8 +63,8 @@ public class TerminologyClientR4 implements TerminologyClient {
}
@Override
public ValueSet expandValueset(ValueSet vs, Parameters p, Map<String, String> params) {
return client.expandValueset(vs, p, params);
public ValueSet expandValueset(ValueSet vs, Parameters p) {
return client.expandValueset(vs, p);
}
@Override

View File

@ -403,55 +403,6 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
return feed;
}
public ValueSet expandValueset(String vsUrl, Parameters expParams) {
recordUse();
Map<String, String> 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<Resource> 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<Resource> 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<String, String> params) {
recordUse();
org.hl7.fhir.r4.utils.client.network.ResourceRequest<Resource> result = null;
@ -468,18 +419,13 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
return (Parameters) result.getPayload();
}
public ValueSet expandValueset(ValueSet source, Parameters expParams, Map<String, String> 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<Resource> 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);

View File

@ -88,7 +88,7 @@ public class ResourceAddress {
}
public <T extends Resource> URI resolveOperationUri(Class<T> resourceClass, String opName) {
return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) + "/" + opName);
return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) + "$" + opName);
}
public <T extends Resource> URI resolveGetResource(Class<T> resourceClass, String id) {

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>6.2.15-SNAPSHOT</version>
<version>6.2.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -87,7 +87,7 @@ public class ResourceAddress {
}
public <T extends Resource> URI resolveOperationUri(Class<T> resourceClass, String opName) {
return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) + "/" + opName);
return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) + "$" + opName);
}
public <T extends Resource> URI resolveOperationUri(Class<T> resourceClass, String opName,

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>6.2.15-SNAPSHOT</version>
<version>6.2.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -78,6 +78,7 @@ import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent
import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
import org.hl7.fhir.r5.model.IdType;
import org.hl7.fhir.r5.model.Identifier;
import org.hl7.fhir.r5.model.IntegerType;
import org.hl7.fhir.r5.model.ImplementationGuide;
import org.hl7.fhir.r5.model.Library;
import org.hl7.fhir.r5.model.Measure;
@ -101,9 +102,7 @@ import org.hl7.fhir.r5.model.StringType;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
import org.hl7.fhir.r5.model.StructureMap;
import org.hl7.fhir.r5.model.TerminologyCapabilities;
import org.hl7.fhir.r5.model.TerminologyCapabilities.TerminologyCapabilitiesCodeSystemComponent;
import org.hl7.fhir.r5.model.TerminologyCapabilities.TerminologyCapabilitiesExpansionParameterComponent;
import org.hl7.fhir.r5.model.UriType;
import org.hl7.fhir.r5.model.UrlType;
import org.hl7.fhir.r5.model.ValueSet;
@ -129,8 +128,8 @@ import org.hl7.fhir.r5.terminologies.utilities.TerminologyCache.SourcedValueSet;
import org.hl7.fhir.r5.terminologies.validation.VSCheckerException;
import org.hl7.fhir.r5.terminologies.validation.ValueSetValidator;
import org.hl7.fhir.r5.terminologies.ValueSetUtilities;
import org.hl7.fhir.r5.terminologies.client.TerminologyClientR5.TerminologyClientR5Factory;
import org.hl7.fhir.r5.terminologies.client.TerminologyClientManager;
import org.hl7.fhir.r5.terminologies.client.TerminologyClientR5;
import org.hl7.fhir.r5.terminologies.client.TerminologyClientContext;
import org.hl7.fhir.r5.utils.PackageHackerR5;
import org.hl7.fhir.r5.utils.ResourceUtilities;
@ -138,7 +137,6 @@ import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.r5.utils.client.EFhirClientException;
import org.hl7.fhir.r5.utils.validation.ValidationContextCarrier;
import org.hl7.fhir.utilities.FhirPublication;
import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.TimeTracker;
import org.hl7.fhir.utilities.ToolingClientLogger;
import org.hl7.fhir.utilities.TranslationServices;
@ -234,7 +232,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
private Object lock = new Object(); // used as a lock for the data that follows
protected String version; // although the internal resources are all R5, the version of FHIR they describe may not be
protected final TerminologyClientManager terminologyClientManager = new TerminologyClientManager(null, UUID.randomUUID().toString());
protected final TerminologyClientManager terminologyClientManager = new TerminologyClientManager(new TerminologyClientR5.TerminologyClientR5Factory(), UUID.randomUUID().toString());
private boolean minimalMemory = false;
private Map<String, Map<String, ResourceProxy>> allResourcesById = new HashMap<String, Map<String, ResourceProxy>>();
@ -851,7 +849,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
return res;
}
Set<String> systems = findRelevantSystems(vs);
TerminologyClientContext tc = terminologyClientManager.chooseServer(systems, true);
TerminologyClientContext tc = terminologyClientManager.chooseServer(vs, systems, true);
if (tc == null) {
return new ValueSetExpansionOutcome("No server available", TerminologyServiceErrorClass.INTERNAL_ERROR, true);
}
@ -874,7 +872,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);
@ -915,7 +913,8 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
}
Parameters p = pIn.copy();
p.setParameter("_limit",new IntegerType("10000"));
p.setParameter("_incomplete", new BooleanType("true"));
if (vs.hasExpansion()) {
return new ValueSetExpansionOutcome(vs.copy());
}
@ -978,14 +977,14 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
p.addParameter().setName("cache-id").setValue(new IdType(terminologyClientManager.getCacheId()));
Set<String> systems = findRelevantSystems(vs);
TerminologyClientContext tc = terminologyClientManager.chooseServer(systems, true);
TerminologyClientContext tc = terminologyClientManager.chooseServer(vs, systems, true);
addDependentResources(tc, p, vs);
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());
@ -1108,7 +1107,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
}
if (batch.getEntry().size() > 0) {
TerminologyClientContext tc = terminologyClientManager.chooseServer(systems, false);
TerminologyClientContext tc = terminologyClientManager.chooseServer(vs, systems, false);
Bundle resp = processBatch(tc, batch, systems);
for (int i = 0; i < batch.getEntry().size(); i++) {
CodingValidationRequest t = (CodingValidationRequest) batch.getEntry().get(i).getUserData("source");
@ -1213,7 +1212,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
systems.add(codingValidationRequest.getCoding().getSystem());
}
}
TerminologyClientContext tc = terminologyClientManager.chooseServer(systems, false);
TerminologyClientContext tc = terminologyClientManager.chooseServer(vs, systems, false);
if (batch.getEntry().size() > 0) {
Bundle resp = processBatch(tc, batch, systems);
@ -1346,7 +1345,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
}
Set<String> systems = findRelevantSystems(code, vs);
TerminologyClientContext tc = terminologyClientManager.chooseServer(systems, false);
TerminologyClientContext tc = terminologyClientManager.chooseServer(vs, systems, false);
String csumm =cachingAllowed && txCache != null ? txCache.summary(code) : null;
if (cachingAllowed && txCache != null) {
@ -1365,7 +1364,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
}
if (!res.isOk() && localError != null) {
res.setDiagnostics("Local Error: "+localError.trim()+". Server Error: "+res.getMessage());
} else if (!res.isOk() && res.getUnknownSystems() != null && res.getUnknownSystems().contains(codeKey) && localWarning != null) {
} else if (!res.isOk() && res.getErrorClass() == TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED && res.getUnknownSystems() != null && res.getUnknownSystems().contains(codeKey) && localWarning != null) {
// we had some problem evaluating locally, but the server doesn't know the code system, so we'll just go with the local error
res = new ValidationResult(IssueSeverity.WARNING, localWarning, null);
res.setDiagnostics("Local Warning: "+localWarning.trim()+". Server Error: "+res.getMessage());
@ -1538,7 +1537,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
return new ValidationResult(IssueSeverity.ERROR, "Error validating code: running without terminology services", TerminologyServiceErrorClass.NOSERVICE, null);
}
Set<String> systems = findRelevantSystems(code, vs);
TerminologyClientContext tc = terminologyClientManager.chooseServer(systems, false);
TerminologyClientContext tc = terminologyClientManager.chooseServer(vs, systems, false);
txLog("$validate "+txCache.summary(code)+" for "+ txCache.summary(vs)+" on "+tc.getAddress());
try {
@ -1780,6 +1779,8 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
} else if (p.getName().equals("x-caused-by-unknown-system")) {
err = TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED;
unknownSystems.add(((PrimitiveType<?>) p.getValue()).asStringValue());
} else if (p.getName().equals("x-unknown-system")) {
unknownSystems.add(((PrimitiveType<?>) p.getValue()).asStringValue());
} else if (p.getName().equals("warning-withdrawn")) {
String msg = ((PrimitiveType<?>) p.getValue()).asStringValue();
OperationOutcomeIssueComponent iss = new OperationOutcomeIssueComponent(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.INFORMATION, org.hl7.fhir.r5.model.OperationOutcome.IssueType.BUSINESSRULE);

View File

@ -1212,8 +1212,8 @@ public class DataRenderer extends Renderer implements CodeResolver {
s = ii.getType().getCoding().get(0).getDisplay()+": "+s;
else if (ii.getType().hasCoding() && ii.getType().getCoding().get(0).hasCode())
s = lookupCode(ii.getType().getCoding().get(0).getSystem(), ii.getType().getCoding().get(0).getVersion(), ii.getType().getCoding().get(0).getCode())+": "+s;
} else {
s = "id:\u00A0"+s;
} else if (ii.hasSystem()) {
s = ii.getSystem()+"#"+s;
}
if (ii.hasUse() || ii.hasPeriod()) {
@ -1234,24 +1234,32 @@ public class DataRenderer extends Renderer implements CodeResolver {
protected void renderIdentifier(XhtmlNode x, Identifier ii) {
if (ii.hasType()) {
if (ii.getType().hasText())
x.tx(ii.getType().getText()+":");
else if (ii.getType().hasCoding() && ii.getType().getCoding().get(0).hasDisplay())
x.tx(ii.getType().getCoding().get(0).getDisplay()+":");
else if (ii.getType().hasCoding() && ii.getType().getCoding().get(0).hasCode())
x.tx(lookupCode(ii.getType().getCoding().get(0).getSystem(), ii.getType().getCoding().get(0).getVersion(), ii.getType().getCoding().get(0).getCode())+":");
} else {
x.tx("id:");
if (ii.getType().hasText()) {
x.tx(ii.getType().getText());
} else if (ii.getType().hasCoding() && ii.getType().getCoding().get(0).hasDisplay()) {
x.tx(ii.getType().getCoding().get(0).getDisplay());
} else if (ii.getType().hasCoding() && ii.getType().getCoding().get(0).hasCode()) {
x.tx(lookupCode(ii.getType().getCoding().get(0).getSystem(), ii.getType().getCoding().get(0).getVersion(), ii.getType().getCoding().get(0).getCode()));
}
x.nbsp();
x.tx("/");
} else if (ii.hasSystem()) {
NamingSystem ns = context.getContext().getNSUrlMap().get(ii.getSystem());
if (ns != null) {
if (ns.hasWebPath()) {
x.ah(ns.getWebPath()).tx("#");
x.ah(ns.getWebPath(), ns.getDescription()).tx(ns.present());
} else {
x.tx(ns.present()+"#");
x.tx(ns.present());
}
} else {
switch (ii.getSystem()) {
case "urn:oid:2.51.1.3":
x.ah("https://www.gs1.org/standards/id-keys/gln", "Global Location Number").tx("GLN");
break;
default:
x.code(ii.getSystem());
}
}
x.tx("/");
}
x.tx(Utilities.noString(ii.getValue()) ? "?ngen-9?" : ii.getValue());

View File

@ -51,7 +51,7 @@ public interface ITerminologyClient {
String getAddress();
String getServerVersion();
TerminologyCapabilities getTerminologyCapabilities() throws FHIRException;
ValueSet expandValueset(ValueSet vs, Parameters p, Map<String, String> 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;

View File

@ -75,6 +75,12 @@ public class TerminologyClientContext {
return client;
}
public void seeUse(Set<String> systems, TerminologyClientContextUseType useType) {
for (String s : systems) {
seeUse(s, useType);
}
}
public void seeUse(String s, TerminologyClientContextUseType useType) {
TerminologyClientContextUseCount uc = useCounts.get(s);
if (uc == null) {
@ -185,4 +191,11 @@ public class TerminologyClientContext {
}
return false;
}
@Override
public String toString() {
return client.getAddress();
}
}

View File

@ -24,15 +24,53 @@ import org.hl7.fhir.r5.model.TerminologyCapabilities;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.terminologies.ValueSetUtilities;
import org.hl7.fhir.r5.terminologies.client.TerminologyClientContext.TerminologyClientContextUseType;
import org.hl7.fhir.r5.terminologies.client.TerminologyClientManager.ServerOptionList;
import org.hl7.fhir.r5.terminologies.utilities.TerminologyCache;
import org.hl7.fhir.r5.terminologies.utilities.TerminologyCache.SourcedValueSet;
import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
import org.hl7.fhir.utilities.ToolingClientLogger;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.json.model.JsonObject;
import org.hl7.fhir.utilities.json.parser.JsonParser;
public class TerminologyClientManager {
public class ServerOptionList {
private List<String> authoritative = new ArrayList<String>();
private List<String> candidates = new ArrayList<String>();
public ServerOptionList(String address) {
candidates.add(address);
}
public ServerOptionList() {
}
public ServerOptionList(List<String> auth, List<String> cand) {
authoritative.addAll(auth);
candidates.addAll(cand);
}
public void replace(String src, String dst) {
for (int i = 0; i < candidates.size(); i++) {
if (candidates.get(i).contains("://"+src)) {
candidates.set(i, candidates.get(i).replace("://"+src, "://"+dst));
}
}
for (int i = 0; i < authoritative.size(); i++) {
if (authoritative.get(i).contains("://"+src)) {
authoritative.set(i, authoritative.get(i).replace("://"+src, "://"+dst));
}
}
}
@Override
public String toString() {
return "auth = " + CommaSeparatedStringBuilder.join("|", authoritative)+ ", candidates=" + CommaSeparatedStringBuilder.join("|", candidates);
}
}
public ITerminologyClientFactory getFactory() {
return factory;
}
@ -50,8 +88,8 @@ public class TerminologyClientManager {
private String cacheId;
private List<TerminologyClientContext> serverList = new ArrayList<>(); // clients by server address
private Map<String, TerminologyClientContext> serverMap = new HashMap<>(); // clients by server address
private Map<String, String> resMap = new HashMap<>(); // client resolution list
private List<String> internalErrors = new ArrayList<>();
private Map<String, ServerOptionList> resMap = new HashMap<>(); // client resolution list
private List<String> internalLog = new ArrayList<>();
protected Parameters expParameters;
private TerminologyCache cache;
@ -82,40 +120,92 @@ public class TerminologyClientManager {
}
public TerminologyClientContext chooseServer(Set<String> systems, boolean expand) throws TerminologyServiceException {
public TerminologyClientContext chooseServer(ValueSet vs, Set<String> systems, boolean expand) throws TerminologyServiceException {
if (serverList.isEmpty()) {
return null;
}
if (systems.contains(UNRESOLVED_VALUESET)) {
if (systems.contains(UNRESOLVED_VALUESET) || systems.isEmpty()) {
return serverList.get(0);
}
Set<TerminologyClientContext> clients = new HashSet<>();
List<ServerOptionList> choices = new ArrayList<>();
for (String s : systems) {
clients.add(findServerForSystem(s, expand));
choices.add(findServerForSystem(s, expand));
}
// first we look for a server that's authoritative for all of them
for (ServerOptionList ol : choices) {
for (String s : ol.authoritative) {
boolean ok = true;
for (ServerOptionList t : choices) {
if (!t.authoritative.contains(s)) {
ok = false;
}
}
if (ok) {
return findClient(s, systems, expand);
}
if (clients.size() == 1) {
return clients.iterator().next();
} else {
System.out.println("systems: "+systems.toString());
return serverList.get(0);
}
}
private TerminologyClientContext findServerForSystem(String s, boolean expand) throws TerminologyServiceException {
String server = resMap.get(s);
if (server == null) {
server = decideWhichServer(s);
// testing support
if (server != null && server.contains("://tx.fhir.org")) {
try {
server = server.replace("tx.fhir.org", new URL(getMasterClient().getAddress()).getHost());
} catch (MalformedURLException e) {
// now we look for a server that's authoritative for one of them and a candidate for the others
for (ServerOptionList ol : choices) {
for (String s : ol.authoritative) {
boolean ok = true;
for (ServerOptionList t : choices) {
if (!t.candidates.contains(s)) {
ok = false;
}
}
resMap.put(s, server);
save();
if (ok) {
return findClient(s, systems, expand);
}
}
}
// now we look for a server that's a candidate for all of them
for (ServerOptionList ol : choices) {
for (String s : ol.candidates) {
boolean ok = true;
for (ServerOptionList t : choices) {
if (!t.candidates.contains(s)) {
ok = false;
}
}
if (ok) {
return findClient(s, systems, expand);
}
}
}
// no agreement? Then what we do depends
if (vs != null) {
if (vs.hasUserData("External.Link")) {
if (systems.size() == 1) {
internalLog.add(vs.getVersionedUrl()+" uses the system "+systems.toString()+" not handled by any servers. Using source @ '"+vs.getUserString("External.Link")+"'");
} else {
internalLog.add(vs.getVersionedUrl()+" includes multiple systems "+systems.toString()+" best handled by multiple servers: "+choices.toString()+". Using source @ '"+vs.getUserString("External.Link")+"'");
}
return findClient(vs.getUserString("External.Link"), systems, expand);
} else {
if (systems.size() == 1) {
internalLog.add(vs.getVersionedUrl()+" uses the system "+systems.toString()+" not handled by any servers. Using master @ '"+serverList.get(0)+"'");
} else {
internalLog.add(vs.getVersionedUrl()+" includes multiple systems "+systems.toString()+" best handled by multiple servers: "+choices.toString()+". Using master @ '"+serverList.get(0)+"'");
}
return findClient(serverList.get(0).getAddress(), systems, expand);
}
} else {
if (systems.size() == 1) {
internalLog.add("Request for system "+systems.toString()+" not handled by any servers. Using master @ '"+serverList.get(0)+"'");
} else {
internalLog.add("Request for multiple systems "+systems.toString()+" best handled by multiple servers: "+choices.toString()+". Using master @ '"+serverList.get(0)+"'");
}
return findClient(serverList.get(0).getAddress(), systems, expand);
}
}
private TerminologyClientContext findClient(String server, Set<String> systems, boolean expand) {
TerminologyClientContext client = serverMap.get(server);
if (client == null) {
try {
@ -127,13 +217,28 @@ public class TerminologyClientManager {
serverList.add(client);
serverMap.put(server, client);
}
client.seeUse(s, expand ? TerminologyClientContextUseType.expand : TerminologyClientContextUseType.validate);
client.seeUse(systems, expand ? TerminologyClientContextUseType.expand : TerminologyClientContextUseType.validate);
return client;
}
private String decideWhichServer(String url) {
private ServerOptionList findServerForSystem(String s, boolean expand) throws TerminologyServiceException {
ServerOptionList serverList = resMap.get(s);
if (serverList == null) {
serverList = decideWhichServer(s);
// testing support
try {
serverList.replace("tx.fhir.org", new URL(getMasterClient().getAddress()).getHost());
} catch (MalformedURLException e) {
}
resMap.put(s, serverList);
save();
}
return serverList;
}
private ServerOptionList decideWhichServer(String url) {
if (IGNORE_TX_REGISTRY) {
return getMasterClient().getAddress();
return new ServerOptionList(getMasterClient().getAddress());
}
if (expParameters != null) {
if (!url.contains("|")) {
@ -157,23 +262,25 @@ public class TerminologyClientManager {
request = request + "&usage="+usage;
}
try {
ServerOptionList ret = new ServerOptionList();
JsonObject json = JsonParser.parseObjectFromUrl(request);
for (JsonObject item : json.getJsonObjects("authoritative")) {
return item.asString("url");
ret.authoritative.add(item.asString("url"));
}
for (JsonObject item : json.getJsonObjects("candidates")) {
return item.asString("url");
ret.candidates.add(item.asString("url"));
}
return ret;
} catch (Exception e) {
String msg = "Error resolving system "+url+": "+e.getMessage()+" ("+request+")";
if (!internalErrors.contains(msg)) {
internalErrors.add(msg);
if (!internalLog.contains(msg)) {
internalLog.add(msg);
}
if (!monitorServiceURL.contains("tx.fhir.org")) {
e.printStackTrace();
}
}
return getMasterClient().getAddress();
return new ServerOptionList( getMasterClient().getAddress());
}
@ -248,7 +355,11 @@ public class TerminologyClientManager {
if (cacheFile.exists()) {
JsonObject json = JsonParser.parseObject(cacheFile);
for (JsonObject pair : json.getJsonObjects("systems")) {
resMap.put(pair.asString("system"), pair.asString("server"));
if (pair.has("server")) {
resMap.put(pair.asString("system"), new ServerOptionList(pair.asString("server")));
} else {
resMap.put(pair.asString("system"), new ServerOptionList(pair.getStrings("authoritative"), pair.getStrings("candidates")));
}
}
}
} catch (Exception e) {
@ -264,7 +375,8 @@ public class TerminologyClientManager {
JsonObject si = new JsonObject();
json.forceArray("systems").add(si);
si.add("system", s);
si.add("server", resMap.get(s));
si.add("authoritative", resMap.get(s).authoritative);
si.add("candidates", resMap.get(s).candidates);
}
try {
JsonParser.compose(json, cacheFile, true);
@ -273,8 +385,8 @@ public class TerminologyClientManager {
}
}
public List<String> getInternalErrors() {
return internalErrors;
public List<String> getInternalLog() {
return internalLog;
}
public List<TerminologyClientContext> getServerList() {
@ -377,8 +489,8 @@ public class TerminologyClientManager {
} catch (Exception e) {
e.printStackTrace();
String msg = "Error resolving valueSet "+canonical+": "+e.getMessage()+" ("+request+")";
if (!internalErrors.contains(msg)) {
internalErrors.add(msg);
if (!internalLog.contains(msg)) {
internalLog.add(msg);
}
e.printStackTrace();
return null;

View File

@ -126,8 +126,8 @@ public class TerminologyClientR5 implements ITerminologyClient {
}
@Override
public ValueSet expandValueset(ValueSet vs, Parameters p, Map<String, String> params) {
return client.expandValueset(vs, p, params);
public ValueSet expandValueset(ValueSet vs, Parameters p) {
return client.expandValueset(vs, p);
}
@Override

View File

@ -255,7 +255,7 @@ public class ValueSetExpander extends ValueSetProcessBase {
}
}
if (expParams.getParameterBool("includeDesignations")) {
if (expParams.getParameterBool("includeDesignations") && designations != null) {
for (ConceptDefinitionDesignationComponent t : designations) {
if (t != pref && (t.hasLanguage() || t.hasUse()) && t.getValue() != null && passesDesignationFilter(t)) {
@ -882,6 +882,8 @@ public class ValueSetExpander extends ValueSetProcessBase {
if (vso.getError() != null) {
addErrors(vso.getAllErrors());
throw fail("Unable to expand imported value set "+vs.getUrl()+": " + vso.getError());
} else if (vso.getValueset() == null) {
throw fail("Unable to expand imported value set "+vs.getUrl()+" but no error");
}
if (vs.hasVersion() || REPORT_VERSION_ANYWAY) {
UriType u = new UriType(vs.getUrl() + (vs.hasVersion() ? "|"+vs.getVersion() : ""));

View File

@ -356,6 +356,9 @@ public class ValueSetValidator extends ValueSetProcessBase {
res.setVersion(foundCoding.hasVersion() ? foundCoding.getVersion() : foundCoding.hasUserData("cs") ? ((CodeSystem) foundCoding.getUserData("cs")).getVersion() : null);
res.setDisplay(cd.getDisplay());
}
if (info.getErr() != null) {
res.setErrorClass(info.getErr());
}
res.setUnknownSystems(unknownSystems);
res.addCodeableConcept(vcc);
return res;
@ -1309,6 +1312,7 @@ public class ValueSetValidator extends ValueSetProcessBase {
}
return res.isOk();
} else {
info.setErr(TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED);
if (unknownSystems != null) {
if (version == null) {
unknownSystems.add(system);

View File

@ -470,7 +470,6 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
return result == null ? null : (ValueSet) result.getPayload();
}
public Parameters lookupCode(Map<String, String> params) {
recordUse();
org.hl7.fhir.r5.utils.client.network.ResourceRequest<Resource> result = null;
@ -489,36 +488,6 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
return (Parameters) result.getPayload();
}
public ValueSet expandValueset(ValueSet source, Parameters expParams, Map<String, String> 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<Resource> 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;
}

View File

@ -101,7 +101,7 @@ public class ResourceAddress {
}
public <T extends Resource> URI resolveOperationUri(Class<T> resourceClass, String opName) {
return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) +"/"+opName);
return baseServiceUri.resolve(nameForClassWithSlash(resourceClass) +"$"+opName);
}
public <T extends Resource> URI resolveOperationUri(Class<T> resourceClass, String opName, Map<String,String> parameters) {

View File

@ -101,12 +101,6 @@ public class SimpleWorkerContextTests {
context.txLog = txLog;
}
private final static Map<String, String> 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<ValidationOptions> {
@ -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);

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>6.2.15-SNAPSHOT</version>
<version>6.2.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>6.2.15-SNAPSHOT</version>
<version>6.2.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -68,6 +68,16 @@ public class JsonObject extends JsonElement {
return add(name, value == null ? new JsonNull() : new JsonString(value));
}
public JsonObject add(String name, List<String> values) throws JsonException {
check(name != null, "Name is null");
JsonArray arr = new JsonArray();
add(name, arr);
for (String v : values) {
arr.add(v);
}
return this;
}
public JsonObject addIfNotNull(String name, String value) throws JsonException {
check(name != null, "Name is null");
if (value == null) {

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>6.2.15-SNAPSHOT</version>
<version>6.2.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId>
<version>6.2.15-SNAPSHOT</version>
<version>6.2.16-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -45,6 +45,7 @@ import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.Bundle;
import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.CanonicalType;
import org.hl7.fhir.r5.model.Coding;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.ElementDefinition;
@ -1052,7 +1053,7 @@ public class ValidationEngine implements IValidatorResourceFetcher, IValidationP
}
public ValidationEngine setSnomedExtension(String sct) {
getContext().getExpansionParameters().addParameter("system-version", "http://snomed.info/sct|http://snomed.info/sct/" + sct);
getContext().getExpansionParameters().addParameter("system-version", new CanonicalType("http://snomed.info/sct|http://snomed.info/sct/" + sct));
return this;
}

View File

@ -128,14 +128,38 @@ public class ValidationService {
fileToValidate.getFileContent().getBytes(),
fileToValidate.getFileName(),
false);
if (format != null) {
fileToValidate.setFileType(format.getExtension());
}
}
List<ValidationMessage> messages = new ArrayList<>();
if (fileToValidate.getFileType() == null) {
ValidationOutcome outcome = getValidationOutcomeForUnknownFileFormat(
new FileInfo(fileToValidate.getFileName(), fileToValidate.getFileContent(), null));
response.addOutcome(outcome);
} else {
ValidatedFragments validatedFragments = validator.validateAsFragments(fileToValidate.getFileContent().getBytes(), Manager.FhirFormat.getFhirFormat(fileToValidate.getFileType()),
request.getCliContext().getProfiles(), messages);
List<ValidationOutcome> validationOutcomes = getValidationOutcomesFromValidatedFragments(fileToValidate, validatedFragments);
for (ValidationOutcome validationOutcome : validationOutcomes) {
response.addOutcome(validationOutcome);
}
if (request.getCliContext().isShowTimes()) {
response.getValidationTimes().put(fileToValidate.getFileName(), validatedFragments.getValidationTime());
}
}
}
System.out.println(" Max Memory: "+Runtime.getRuntime().maxMemory());
return response;
}
private List<ValidationOutcome> getValidationOutcomesFromValidatedFragments(FileInfo fileToValidate, ValidatedFragments validatedFragments) {
List<ValidationOutcome> outcomes = new LinkedList<>();
if (validatedFragments.getValidatedFragments().size() == 1 && !validatedFragments.getValidatedFragments().get(0).isDerivedContent()) {
ValidatedFragment validatedFragment = validatedFragments.getValidatedFragments().get(0);
ValidationOutcome outcome = new ValidationOutcome();
@ -145,7 +169,7 @@ public class ValidationService {
validatedFragment.getExtension());
outcome.setMessages(validatedFragment.getErrors());
outcome.setFileInfo(fileInfo);
response.addOutcome(outcome);
outcomes.add(outcome);
} else {
for (ValidatedFragment validatedFragment : validatedFragments.getValidatedFragments()) {
ValidationOutcome outcome = new ValidationOutcome();
@ -155,17 +179,22 @@ public class ValidationService {
validatedFragment.getExtension());
outcome.setMessages(validatedFragment.getErrors());
outcome.setFileInfo(fileInfo);
response.addOutcome(outcome);
outcomes.add(outcome);
}
}
return outcomes;
}
if (request.getCliContext().isShowTimes()) {
response.getValidationTimes().put(fileToValidate.getFileName(), validatedFragments.getValidationTime());
}
}
private ValidationOutcome getValidationOutcomeForUnknownFileFormat(FileInfo fileInfo) {
ValidationOutcome outcome = new ValidationOutcome();
System.out.println(" Max Memory: "+Runtime.getRuntime().maxMemory());
return response;
List<ValidationMessage> errorList = new ArrayList<>() {{
add(new ValidationMessage().setType(ValidationMessage.IssueType.EXCEPTION).setLevel(ValidationMessage.IssueSeverity.FATAL).setMessage("Unable to infer format from file. Please check that your file is in a valid FHIR format."));
} };
outcome.setMessages(errorList);
outcome.setFileInfo(fileInfo);
return outcome;
}
public VersionSourceInformation scanForVersions(CliContext cliContext) throws Exception {

View File

@ -910,7 +910,7 @@ public class StructureDefinitionValidator extends BaseValidator {
}
private boolean serverSupportsValueSet(String ref) {
ValidationResult vr = context.validateCode(new ValidationOptions(FhirPublication.R5).withCheckValueSetOnly().withVsAsUrl().withNoClient(), new Coding("http://loinc.org", "5792-7", null), new ValueSet().setUrl(ref));
ValidationResult vr = context.validateCode(new ValidationOptions(FhirPublication.R5).withCheckValueSetOnly().withNoClient(), new Coding("http://loinc.org", "5792-7", null), new ValueSet().setUrl(ref));
return vr.getErrorClass() == null || vr.getErrorClass() == TerminologyServiceErrorClass.UNKNOWN;
}

View File

@ -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);

View File

@ -37,6 +37,7 @@ import org.hl7.fhir.r5.model.UriType;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent;
import org.hl7.fhir.r5.terminologies.expansion.ValueSetExpansionOutcome;
import org.hl7.fhir.r5.terminologies.utilities.TerminologyServiceErrorClass;
import org.hl7.fhir.r5.terminologies.utilities.ValidationResult;
import org.hl7.fhir.r5.test.utils.CompareUtilities;
import org.hl7.fhir.r5.test.utils.TestingUtilities;
@ -375,7 +376,7 @@ public class TerminologyServiceTests {
}
if (vm.getUnknownSystems() != null) {
for (String s : vm.getUnknownSystems()) {
res.addParameter("x-caused-by-unknown-system", new CanonicalType(s));
res.addParameter(vm.getErrorClass() == TerminologyServiceErrorClass.CODESYSTEM_UNSUPPORTED ? "x-caused-by-unknown-system" : "x-unknown-system", new CanonicalType(s));
}
}
if (vm.getIssues().size() > 0) {

View File

@ -14,13 +14,13 @@
HAPI FHIR
-->
<artifactId>org.hl7.fhir.core</artifactId>
<version>6.2.15-SNAPSHOT</version>
<version>6.2.16-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<guava_version>32.0.1-jre</guava_version>
<hapi_fhir_version>6.4.1</hapi_fhir_version>
<validator_test_case_version>1.4.27</validator_test_case_version>
<validator_test_case_version>1.4.28</validator_test_case_version>
<jackson_version>2.16.0</jackson_version>
<junit_jupiter_version>5.9.2</junit_jupiter_version>
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>