use of ca.uhn.fhir.rest.client.apache.ResourceEntity in project geoprism-registry by terraframe.
the class FhirBulkDataImporter method initiateBulkExport.
private String initiateBulkExport(CloseableHttpClient myClient, FhirContext ctx) {
try {
Parameters params = new Parameters();
params.addParameter().setName("_type").setValue(new StringType("Organization,Location"));
HttpPost post = new HttpPost(system.getUrl() + "/" + "$export");
post.addHeader(Constants.HEADER_PREFER, Constants.HEADER_PREFER_RESPOND_ASYNC);
post.setEntity(new ResourceEntity(ctx, params));
try (CloseableHttpResponse response = myClient.execute(post)) {
if (response.getStatusLine().getStatusCode() == 202) {
return response.getFirstHeader(Constants.HEADER_CONTENT_LOCATION).getValue();
} else {
System.out.println(response.getStatusLine().getStatusCode());
StringWriter writer = new StringWriter();
IOUtils.copy(response.getEntity().getContent(), writer, "utf-8");
String message = writer.toString();
throw new ProgrammingErrorException(message);
}
}
} catch (IOException e) {
throw new ProgrammingErrorException(e);
}
}
Aggregations