mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-02-13 16:24:44 +00:00
Look up support in Tx Tests
This commit is contained in:
parent
6e4c620515
commit
4ceac5012b
@ -2,6 +2,7 @@ package org.hl7.fhir.convertors.txClient;
|
|||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -36,6 +37,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.hl7.fhir.convertors.conv10_50.resources10_50.TerminologyCapabilities10_50;
|
import org.hl7.fhir.convertors.conv10_50.resources10_50.TerminologyCapabilities10_50;
|
||||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;
|
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;
|
||||||
|
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
|
||||||
import org.hl7.fhir.dstu2.model.Resource;
|
import org.hl7.fhir.dstu2.model.Resource;
|
||||||
import org.hl7.fhir.dstu2.utils.client.FHIRToolingClient;
|
import org.hl7.fhir.dstu2.utils.client.FHIRToolingClient;
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
@ -45,6 +47,7 @@ import org.hl7.fhir.r5.model.CapabilityStatement;
|
|||||||
import org.hl7.fhir.r5.model.Parameters;
|
import org.hl7.fhir.r5.model.Parameters;
|
||||||
import org.hl7.fhir.r5.model.TerminologyCapabilities;
|
import org.hl7.fhir.r5.model.TerminologyCapabilities;
|
||||||
import org.hl7.fhir.r5.model.ValueSet;
|
import org.hl7.fhir.r5.model.ValueSet;
|
||||||
|
import org.hl7.fhir.r5.model.Parameters.ParametersParameterComponent;
|
||||||
import org.hl7.fhir.r5.terminologies.client.ITerminologyClient;
|
import org.hl7.fhir.r5.terminologies.client.ITerminologyClient;
|
||||||
import org.hl7.fhir.r5.utils.client.network.ClientHeaders;
|
import org.hl7.fhir.r5.utils.client.network.ClientHeaders;
|
||||||
import org.hl7.fhir.utilities.FhirPublication;
|
import org.hl7.fhir.utilities.FhirPublication;
|
||||||
@ -165,6 +168,11 @@ public class TerminologyClientR2 implements ITerminologyClient {
|
|||||||
return (Parameters) VersionConvertorFactory_10_50.convertResource(client.lookupCode(params));
|
return (Parameters) VersionConvertorFactory_10_50.convertResource(client.lookupCode(params));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Parameters lookupCode(Parameters params) throws FHIRException {
|
||||||
|
return (Parameters) VersionConvertorFactory_10_50.convertResource(client.lookupCode((org.hl7.fhir.dstu2.model.Parameters) VersionConvertorFactory_10_50.convertResource(params)));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRetryCount() throws FHIRException {
|
public int getRetryCount() throws FHIRException {
|
||||||
return client.getRetryCount();
|
return client.getRetryCount();
|
||||||
|
@ -2,6 +2,7 @@ package org.hl7.fhir.convertors.txClient;
|
|||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -36,6 +37,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.hl7.fhir.convertors.conv30_50.resources30_50.TerminologyCapabilities30_50;
|
import org.hl7.fhir.convertors.conv30_50.resources30_50.TerminologyCapabilities30_50;
|
||||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
|
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
|
||||||
|
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
|
||||||
import org.hl7.fhir.dstu3.model.Resource;
|
import org.hl7.fhir.dstu3.model.Resource;
|
||||||
import org.hl7.fhir.dstu3.utils.client.FHIRToolingClient;
|
import org.hl7.fhir.dstu3.utils.client.FHIRToolingClient;
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
@ -45,6 +47,7 @@ import org.hl7.fhir.r5.model.CapabilityStatement;
|
|||||||
import org.hl7.fhir.r5.model.Parameters;
|
import org.hl7.fhir.r5.model.Parameters;
|
||||||
import org.hl7.fhir.r5.model.TerminologyCapabilities;
|
import org.hl7.fhir.r5.model.TerminologyCapabilities;
|
||||||
import org.hl7.fhir.r5.model.ValueSet;
|
import org.hl7.fhir.r5.model.ValueSet;
|
||||||
|
import org.hl7.fhir.r5.model.Parameters.ParametersParameterComponent;
|
||||||
import org.hl7.fhir.r5.terminologies.client.ITerminologyClient;
|
import org.hl7.fhir.r5.terminologies.client.ITerminologyClient;
|
||||||
import org.hl7.fhir.r5.utils.client.network.ClientHeaders;
|
import org.hl7.fhir.r5.utils.client.network.ClientHeaders;
|
||||||
import org.hl7.fhir.utilities.FhirPublication;
|
import org.hl7.fhir.utilities.FhirPublication;
|
||||||
@ -155,6 +158,11 @@ public class TerminologyClientR3 implements ITerminologyClient {
|
|||||||
return (Parameters) VersionConvertorFactory_30_50.convertResource(client.lookupCode(params));
|
return (Parameters) VersionConvertorFactory_30_50.convertResource(client.lookupCode(params));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Parameters lookupCode(Parameters params) throws FHIRException {
|
||||||
|
return (Parameters) VersionConvertorFactory_30_50.convertResource(client.lookupCode((org.hl7.fhir.dstu3.model.Parameters) VersionConvertorFactory_30_50.convertResource(params)));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRetryCount() throws FHIRException {
|
public int getRetryCount() throws FHIRException {
|
||||||
return client.getRetryCount();
|
return client.getRetryCount();
|
||||||
|
@ -18,6 +18,7 @@ import org.hl7.fhir.r5.model.OperationOutcome;
|
|||||||
import org.hl7.fhir.r5.model.Parameters;
|
import org.hl7.fhir.r5.model.Parameters;
|
||||||
import org.hl7.fhir.r5.model.TerminologyCapabilities;
|
import org.hl7.fhir.r5.model.TerminologyCapabilities;
|
||||||
import org.hl7.fhir.r5.model.ValueSet;
|
import org.hl7.fhir.r5.model.ValueSet;
|
||||||
|
import org.hl7.fhir.r5.model.Parameters.ParametersParameterComponent;
|
||||||
import org.hl7.fhir.r5.terminologies.client.ITerminologyClient;
|
import org.hl7.fhir.r5.terminologies.client.ITerminologyClient;
|
||||||
import org.hl7.fhir.r5.utils.client.network.ClientHeaders;
|
import org.hl7.fhir.r5.utils.client.network.ClientHeaders;
|
||||||
import org.hl7.fhir.utilities.FhirPublication;
|
import org.hl7.fhir.utilities.FhirPublication;
|
||||||
@ -181,6 +182,11 @@ public class TerminologyClientR4 implements ITerminologyClient {
|
|||||||
return (Parameters) VersionConvertorFactory_40_50.convertResource(client.lookupCode(params));
|
return (Parameters) VersionConvertorFactory_40_50.convertResource(client.lookupCode(params));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Parameters lookupCode(Parameters params) throws FHIRException {
|
||||||
|
return (Parameters) VersionConvertorFactory_40_50.convertResource(client.lookupCode((org.hl7.fhir.r4.model.Parameters) VersionConvertorFactory_40_50.convertResource(params)));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRetryCount() throws FHIRException {
|
public int getRetryCount() throws FHIRException {
|
||||||
return client.getRetryCount();
|
return client.getRetryCount();
|
||||||
|
@ -742,6 +742,26 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
|||||||
return (Parameters) result.getPayload();
|
return (Parameters) result.getPayload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Parameters lookupCode(Parameters p) {
|
||||||
|
recordUse();
|
||||||
|
ResourceRequest<Resource> result = utils.issuePostRequest(
|
||||||
|
resourceAddress.resolveOperationUri(ValueSet.class, "lookup"),
|
||||||
|
utils.getResourceAsByteArray(p, false, isJson(getPreferredResourceFormat())),
|
||||||
|
withVer(getPreferredResourceFormat(), "1.0"),
|
||||||
|
timeoutNormal);
|
||||||
|
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 (Parameters) result.getPayload();
|
||||||
|
}
|
||||||
|
|
||||||
public ValueSet expandValueset(ValueSet source, Parameters expParams) {
|
public ValueSet expandValueset(ValueSet source, Parameters expParams) {
|
||||||
recordUse();
|
recordUse();
|
||||||
List<Header> headers = null;
|
List<Header> headers = null;
|
||||||
|
@ -432,6 +432,24 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
|||||||
return (Parameters) result.getPayload();
|
return (Parameters) result.getPayload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Parameters lookupCode(Parameters p) {
|
||||||
|
recordUse();
|
||||||
|
org.hl7.fhir.dstu3.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
|
try {
|
||||||
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(CodeSystem.class, "lookup"),
|
||||||
|
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())),
|
||||||
|
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) {
|
public ValueSet expandValueset(ValueSet source, Parameters expParams) {
|
||||||
recordUse();
|
recordUse();
|
||||||
|
@ -419,6 +419,23 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
|||||||
return (Parameters) result.getPayload();
|
return (Parameters) result.getPayload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Parameters lookupCode(Parameters p) {
|
||||||
|
recordUse();
|
||||||
|
org.hl7.fhir.r4.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
|
try {
|
||||||
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(CodeSystem.class, "lookup"),
|
||||||
|
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())),
|
||||||
|
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(), "CodeSystem/$lookup", timeoutNormal);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new FHIRException(e);
|
||||||
|
}
|
||||||
|
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) {
|
public ValueSet expandValueset(ValueSet source, Parameters expParams) {
|
||||||
recordUse();
|
recordUse();
|
||||||
Parameters p = expParams == null ? new Parameters() : expParams.copy();
|
Parameters p = expParams == null ? new Parameters() : expParams.copy();
|
||||||
|
@ -62,6 +62,7 @@ public interface ITerminologyClient {
|
|||||||
ITerminologyClient setRetryCount(int retryCount) throws FHIRException;
|
ITerminologyClient setRetryCount(int retryCount) throws FHIRException;
|
||||||
CapabilityStatement getCapabilitiesStatementQuick() throws FHIRException;
|
CapabilityStatement getCapabilitiesStatementQuick() throws FHIRException;
|
||||||
Parameters lookupCode(Map<String, String> params) throws FHIRException;
|
Parameters lookupCode(Map<String, String> params) throws FHIRException;
|
||||||
|
Parameters lookupCode(Parameters params) throws FHIRException;
|
||||||
Bundle validateBatch(Bundle batch);
|
Bundle validateBatch(Bundle batch);
|
||||||
CanonicalResource read(String type, String id);
|
CanonicalResource read(String type, String id);
|
||||||
ClientHeaders getClientHeaders();
|
ClientHeaders getClientHeaders();
|
||||||
|
@ -2,6 +2,7 @@ package org.hl7.fhir.r5.terminologies.client;
|
|||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -40,6 +41,7 @@ import org.hl7.fhir.r5.model.CanonicalResource;
|
|||||||
import org.hl7.fhir.r5.model.CapabilityStatement;
|
import org.hl7.fhir.r5.model.CapabilityStatement;
|
||||||
import org.hl7.fhir.r5.model.CodeSystem;
|
import org.hl7.fhir.r5.model.CodeSystem;
|
||||||
import org.hl7.fhir.r5.model.Parameters;
|
import org.hl7.fhir.r5.model.Parameters;
|
||||||
|
import org.hl7.fhir.r5.model.Parameters.ParametersParameterComponent;
|
||||||
import org.hl7.fhir.r5.model.Resource;
|
import org.hl7.fhir.r5.model.Resource;
|
||||||
import org.hl7.fhir.r5.model.TerminologyCapabilities;
|
import org.hl7.fhir.r5.model.TerminologyCapabilities;
|
||||||
import org.hl7.fhir.r5.model.ValueSet;
|
import org.hl7.fhir.r5.model.ValueSet;
|
||||||
@ -172,6 +174,11 @@ public class TerminologyClientR5 implements ITerminologyClient {
|
|||||||
return client.lookupCode(params);
|
return client.lookupCode(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Parameters lookupCode(Parameters params) {
|
||||||
|
return client.lookupCode(params);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITerminologyClient setRetryCount(int retryCount) throws FHIRException {
|
public ITerminologyClient setRetryCount(int retryCount) throws FHIRException {
|
||||||
client.setRetryCount(retryCount);
|
client.setRetryCount(retryCount);
|
||||||
|
@ -488,6 +488,25 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
|
|||||||
return (Parameters) result.getPayload();
|
return (Parameters) result.getPayload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Parameters lookupCode(Parameters p) {
|
||||||
|
recordUse();
|
||||||
|
org.hl7.fhir.r5.utils.client.network.ResourceRequest<Resource> result = null;
|
||||||
|
try {
|
||||||
|
result = client.issuePostRequest(resourceAddress.resolveOperationUri(CodeSystem.class, "lookup"),
|
||||||
|
ByteUtils.resourceToByteArray(p, false, isJson(getPreferredResourceFormat())),
|
||||||
|
withVer(getPreferredResourceFormat(), "4.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 String getAddress() {
|
public String getAddress() {
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
@ -201,6 +201,8 @@ public class TxTester {
|
|||||||
msg = validate(test.str("name"),tx, setup, req, resp, fp, lang, profile, ext);
|
msg = validate(test.str("name"),tx, setup, req, resp, fp, lang, profile, ext);
|
||||||
} else if (test.asString("operation").equals("cs-validate-code")) {
|
} else if (test.asString("operation").equals("cs-validate-code")) {
|
||||||
msg = validateCS(test.str("name"),tx, setup, req, resp, fp, lang, profile, ext);
|
msg = validateCS(test.str("name"),tx, setup, req, resp, fp, lang, profile, ext);
|
||||||
|
} else if (test.asString("operation").equals("lookup")) {
|
||||||
|
msg = lookup(test.str("name"),tx, setup, req, resp, fp, lang, profile, ext);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Unknown Operation "+test.asString("operation"));
|
throw new Exception("Unknown Operation "+test.asString("operation"));
|
||||||
}
|
}
|
||||||
@ -249,6 +251,30 @@ public class TxTester {
|
|||||||
return new URI(server).getHost();
|
return new URI(server).getHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String lookup(String id, ITerminologyClient tx, List<Resource> setup, Parameters p, String resp, String fp, String lang, Parameters profile, JsonObject ext) throws IOException {
|
||||||
|
for (Resource r : setup) {
|
||||||
|
p.addParameter().setName("tx-resource").setResource(r);
|
||||||
|
}
|
||||||
|
tx.setContentLanguage(lang);
|
||||||
|
p.getParameter().addAll(profile.getParameter());
|
||||||
|
String pj;
|
||||||
|
try {
|
||||||
|
Parameters po = tx.lookupCode(p);
|
||||||
|
TxTesterScrubbers.scrubParams(po);
|
||||||
|
TxTesterSorters.sortParameters(po);
|
||||||
|
pj = new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).composeString(po);
|
||||||
|
} catch (EFhirClientException e) {
|
||||||
|
OperationOutcome oo = e.getServerError();
|
||||||
|
TxTesterScrubbers.scrubOO(oo, tight);
|
||||||
|
pj = new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).composeString(oo);
|
||||||
|
}
|
||||||
|
String diff = CompareUtilities.checkJsonSrcIsSame(id, resp, pj, false, ext);
|
||||||
|
if (diff != null) {
|
||||||
|
Utilities.createDirectory(Utilities.getDirectoryForFile(fp));
|
||||||
|
TextFile.stringToFile(pj, fp);
|
||||||
|
}
|
||||||
|
return diff;
|
||||||
|
}
|
||||||
private String expand(String id, ITerminologyClient tx, List<Resource> setup, Parameters p, String resp, String fp, String lang, Parameters profile, JsonObject ext) throws IOException {
|
private String expand(String id, ITerminologyClient tx, List<Resource> setup, Parameters p, String resp, String fp, String lang, Parameters profile, JsonObject ext) throws IOException {
|
||||||
for (Resource r : setup) {
|
for (Resource r : setup) {
|
||||||
p.addParameter().setName("tx-resource").setResource(r);
|
p.addParameter().setName("tx-resource").setResource(r);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user