use of org.hl7.fhir.dstu2016may.model.Parameters.ParametersParameterComponent in project org.hl7.fhir.core by hapifhir.
the class FHIRToolingClient method operateType.
public <T extends Resource> Parameters operateType(Class<T> resourceClass, String name, Parameters params) {
boolean complex = false;
for (ParametersParameterComponent p : params.getParameter()) complex = complex || !(p.getValue() instanceof PrimitiveType);
String ps = "";
try {
if (!complex)
for (ParametersParameterComponent p : params.getParameter()) if (p.getValue() instanceof PrimitiveType)
ps += p.getName() + "=" + Utilities.encodeUri(((PrimitiveType) p.getValue()).asStringValue()) + "&";
ResourceRequest<T> result;
URI url = resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps);
if (complex) {
byte[] body = ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()));
result = client.issuePostRequest(url, body, getPreferredResourceFormat(), generateHeaders(), "POST " + resourceClass.getName() + "/$" + name, TIMEOUT_OPERATION_LONG);
} else {
result = client.issueGetResourceRequest(url, getPreferredResourceFormat(), generateHeaders(), "GET " + resourceClass.getName() + "/$" + name, TIMEOUT_OPERATION_LONG);
}
if (result.isUnsuccessfulRequest()) {
throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload());
}
if (result.getPayload() instanceof Parameters) {
return (Parameters) result.getPayload();
} else {
Parameters p_out = new Parameters();
p_out.addParameter().setName("return").setResource(result.getPayload());
return p_out;
}
} catch (Exception e) {
handleException("Error performing tx5 operation '" + name + ": " + e.getMessage() + "' (parameters = \"" + ps + "\")", e);
}
return null;
}
use of org.hl7.fhir.dstu2016may.model.Parameters.ParametersParameterComponent in project org.hl7.fhir.core by hapifhir.
the class BaseWorkerContext method validateOnServer.
private ValidationResult validateOnServer(ValueSet vs, Parameters pin) throws FHIRException {
if (vs != null)
pin.addParameter().setName("valueSet").setResource(vs);
for (ParametersParameterComponent pp : pin.getParameter()) if (pp.getName().equals("profile"))
throw new Error("Can only specify profile in the context");
if (expParameters == null)
throw new Error("No ExpansionProfile provided");
pin.addParameter().setName("profile").setResource(expParameters);
txLog.clearLastId();
Parameters pOut;
if (vs == null)
pOut = txClient.validateCS(pin);
else
pOut = txClient.validateVS(pin);
boolean ok = false;
String message = "No Message returned";
String display = null;
TerminologyServiceErrorClass err = TerminologyServiceErrorClass.UNKNOWN;
for (ParametersParameterComponent p : pOut.getParameter()) {
if (p.getName().equals("result"))
ok = ((BooleanType) p.getValue()).getValue().booleanValue();
else if (p.getName().equals("message"))
message = ((StringType) p.getValue()).getValue();
else if (p.getName().equals("display"))
display = ((StringType) p.getValue()).getValue();
else if (p.getName().equals("cause")) {
try {
IssueType it = IssueType.fromCode(((StringType) p.getValue()).getValue());
if (it == IssueType.UNKNOWN)
err = TerminologyServiceErrorClass.UNKNOWN;
else if (it == IssueType.NOTSUPPORTED)
err = TerminologyServiceErrorClass.VALUESET_UNSUPPORTED;
} catch (FHIRException e) {
}
}
}
if (!ok)
return new ValidationResult(IssueSeverity.ERROR, message, err).setTxLink(txLog.getLastId()).setTxLink(txLog.getLastId());
else if (message != null && !message.equals("No Message returned"))
return new ValidationResult(IssueSeverity.WARNING, message, new ConceptDefinitionComponent().setDisplay(display)).setTxLink(txLog.getLastId()).setTxLink(txLog.getLastId());
else if (display != null)
return new ValidationResult(new ConceptDefinitionComponent().setDisplay(display)).setTxLink(txLog.getLastId()).setTxLink(txLog.getLastId());
else
return new ValidationResult(new ConceptDefinitionComponent()).setTxLink(txLog.getLastId()).setTxLink(txLog.getLastId());
}
use of org.hl7.fhir.dstu2016may.model.Parameters.ParametersParameterComponent in project snowstorm by IHTSDO.
the class AbstractFHIRTest method toString.
protected String toString(ParametersParameterComponent p, String indent) {
StringBuffer sb = new StringBuffer();
sb.append(p.getName() + " (" + p.fhirType() + ")");
if (p.getValue() != null) {
sb.append(": " + toString(p.getValue()));
}
if (p.getResource() != null) {
sb.append(": " + p.getResource());
}
for (ParametersParameterComponent part : p.getPart()) {
sb.append("\n" + toString(part, indent + " "));
}
return sb.toString();
}
use of org.hl7.fhir.dstu2016may.model.Parameters.ParametersParameterComponent in project snowstorm by IHTSDO.
the class AbstractFHIRTest method populatePropertyMap.
private void populatePropertyMap(Map<String, Type> propertyMap, List<ParametersParameterComponent> parts) {
String key = null;
Type value = null;
for (ParametersParameterComponent part : parts) {
if (part.getName().equals("code")) {
key = part.getValue().castToString(part.getValue()).asStringValue();
} else {
value = part.getValue();
}
}
propertyMap.put(key, value);
}
use of org.hl7.fhir.dstu2016may.model.Parameters.ParametersParameterComponent in project snowstorm by IHTSDO.
the class CodeSystemProviderLookupTest method testSinglePropertiesRecovery.
@Test
void testSinglePropertiesRecovery() throws FHIROperationException {
String url = "http://localhost:" + port + "/fhir/CodeSystem/$lookup?system=http://snomed.info/sct&code=" + sampleSCTID + "&property=normalForm&_format=json";
Parameters p = getParameters(url);
/*for (ParametersParameterComponent parameter : p.getParameter()) {
logger.info(toString(parameter, ""));
}*/
String normalFormProperty = toString(getProperty(p, "normalForm"));
assertNotNull(normalFormProperty);
}
Aggregations