Skip to content

Commit

Permalink
Merge pull request #1806 from hapifhir/2024-11-gg-tx-test-metadata
Browse files Browse the repository at this point in the history
Start testing metadata in tx tests, and consequent bugs and library u…
  • Loading branch information
grahamegrieve authored Nov 12, 2024
2 parents 097f493 + 8a831a9 commit 82cbb60
Show file tree
Hide file tree
Showing 27 changed files with 521 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ public CapabilityStatement getCapabilitiesStatementQuick() throws FHIRException
return (CapabilityStatement) VersionConvertorFactory_10_50.convertResource(client.getConformanceStatementQuick());
}

@Override
public CapabilityStatement getCapabilitiesStatement() throws FHIRException {
return (CapabilityStatement) VersionConvertorFactory_10_50.convertResource(client.getConformanceStatement());
}

@Override
public Parameters lookupCode(Map<String, String> params) throws FHIRException {
return (Parameters) VersionConvertorFactory_10_50.convertResource(client.lookupCode(params));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ public CapabilityStatement getCapabilitiesStatementQuick() throws FHIRException
return (CapabilityStatement) VersionConvertorFactory_30_50.convertResource(client.getCapabilitiesStatementQuick());
}

@Override
public CapabilityStatement getCapabilitiesStatement() throws FHIRException {
return (CapabilityStatement) VersionConvertorFactory_30_50.convertResource(client.getCapabilitiesStatement());
}

@Override
public Parameters lookupCode(Map<String, String> params) throws FHIRException {
return (Parameters) VersionConvertorFactory_30_50.convertResource(client.lookupCode(params));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public EnumSet<FhirPublication> getAllowedVersions() {
}

public FhirPublication getActualVersion() {
return FhirPublication.STU3;
return FhirPublication.R4;
}


Expand Down Expand Up @@ -177,6 +177,11 @@ public CapabilityStatement getCapabilitiesStatementQuick() throws FHIRException
return (CapabilityStatement) VersionConvertorFactory_40_50.convertResource(client.getCapabilitiesStatementQuick());
}

@Override
public CapabilityStatement getCapabilitiesStatement() throws FHIRException {
return (CapabilityStatement) VersionConvertorFactory_40_50.convertResource(client.getCapabilitiesStatement());
}

@Override
public Parameters lookupCode(Map<String, String> params) throws FHIRException {
return (Parameters) VersionConvertorFactory_40_50.convertResource(client.lookupCode(params));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public class FHIRToolingClient extends FHIRBaseToolingClient {
@Setter
private ResourceFormat preferredResourceFormat;
private int maxResultSetSize = -1;// _count
private CapabilityStatement capabilities;
@Getter
@Setter
private Client client = new Client();
Expand Down Expand Up @@ -100,13 +99,6 @@ public void initialize(String baseServiceUrl) throws URISyntaxException {
this.maxResultSetSize = -1;
}

private void checkCapabilities() {
try {
capabilities = getCapabilitiesStatementQuick();
} catch (Throwable e) {
}
}

public String getPreferredResourceFormat() {
return preferredResourceFormat.getHeader();
}
Expand All @@ -130,29 +122,26 @@ public TerminologyCapabilities getTerminologyCapabilities() {
return capabilities;
}

public CapabilityStatement getCapabilitiesStatement() {
public CapabilityStatement getCapabilitiesStatementQuick() {
CapabilityStatement conformance = null;
try {
conformance = (CapabilityStatement) client.issueGetResourceRequest(resourceAddress.resolveMetadataUri(false),
conformance = (CapabilityStatement) client.issueGetResourceRequest(resourceAddress.resolveMetadataUri(true),
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(false), "CapabilitiesStatement", timeoutNormal).getReference();
} catch (Exception e) {
throw new FHIRException("Error fetching the server's conformance statement", e);
}
return conformance;
}

public CapabilityStatement getCapabilitiesStatementQuick() throws EFhirClientException {
if (capabilities != null)
return capabilities;
try {
capabilities = (CapabilityStatement) client.issueGetResourceRequest(resourceAddress.resolveMetadataUri(true),
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(false), "CapabilitiesStatement-Quick", timeoutNormal)
.getReference();
} catch (Exception e) {
throw new FHIRException("Error fetching the server's capability statement: " + e.getMessage(), e);
}
return capabilities;
}
public CapabilityStatement getCapabilitiesStatement() throws EFhirClientException {
try {
return (CapabilityStatement) client.issueGetResourceRequest(resourceAddress.resolveMetadataUri(false),
withVer(getPreferredResourceFormat(), "4.0"), generateHeaders(false), "CapabilitiesStatement-Quick", timeoutNormal)
.getReference();
} catch (Exception e) {
throw new FHIRException("Error fetching the server's capability statement: " + e.getMessage(), e);
}
}

public Resource read(String resourceClass, String id) {// TODO Change this to AddressableResource
recordUse();
Expand Down Expand Up @@ -562,8 +551,7 @@ private Iterable<HTTPHeader> generateHeaders(boolean hasBody) {
}

public String getServerVersion() {
checkCapabilities();
return capabilities == null ? null : capabilities.getSoftware().getVersion();
return getCapabilitiesStatementQuick().getSoftware().getVersion();
}

public Bundle search(String type, String criteria) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public void logRequest(String method, String url, List<String> headers, byte[] b
file.println("\r\n--- " + id + " -----------------\r\nRequest: \r\n");
file.println(method + " " + url + " HTTP/1.0");
for (String s : headers)
file.println(Utilities.escapeXml(s));
file.println(s);
if (body != null) {
file.println("");
try {
file.println(Utilities.escapeXml(new String(body, "UTF-8")));
file.println(new String(body, "UTF-8"));
} catch (UnsupportedEncodingException e) {
}
}
Expand All @@ -82,7 +82,7 @@ public void logResponse(String outcome, List<String> headers, byte[] body, long
if (body != null) {
file.println("");
try {
file.println(Utilities.escapeXml(new String(body, "UTF-8")));
file.println(new String(body, "UTF-8"));
} catch (UnsupportedEncodingException e) {
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public interface ITerminologyClient {
ITerminologyClient setLogger(ToolingClientLogger txLog) throws FHIRException;
int getRetryCount() throws FHIRException;
ITerminologyClient setRetryCount(int retryCount) throws FHIRException;
CapabilityStatement getCapabilitiesStatement() throws FHIRException;
CapabilityStatement getCapabilitiesStatementQuick() throws FHIRException;
Parameters lookupCode(Map<String, String> params) throws FHIRException;
Parameters lookupCode(Parameters params) throws FHIRException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ public CapabilityStatement getCapabilitiesStatementQuick() {
return client.getCapabilitiesStatementQuick();
}

@Override
public CapabilityStatement getCapabilitiesStatement() {
return client.getCapabilitiesStatement();
}

@Override
public Parameters lookupCode(Map<String, String> params) {
return client.lookupCode(params);
Expand Down
Loading

0 comments on commit 82cbb60

Please sign in to comment.