use of ca.uhn.fhir.model.dstu2.resource.Patient in project camel-quarkus by apache.
the class FhirDstu2Resource method updateResourceWithStringId.
@Path("/update/resource/withStringId")
@POST
public void updateResourceWithStringId(@QueryParam("id") String id) throws ParseException {
Patient patient = getFhirClient().read().resource(Patient.class).withId(id).preferResponseType(Patient.class).execute();
Date date = new SimpleDateFormat("yyyy-MM-dd").parse("1998-04-29");
patient.setBirthDate(new DateDt(date));
Map<String, Object> headers = new HashMap<>();
headers.put("CamelFhir.resource", patient);
headers.put("CamelFhir.stringId", patient.getIdElement().getIdPart());
headers.put("CamelFhir.preferReturn", PreferReturnEnum.REPRESENTATION);
producerTemplate.sendBodyAndHeaders("direct:updateResourceWithStringId-dstu2", null, headers);
}
use of ca.uhn.fhir.model.dstu2.resource.Patient in project camel-quarkus by apache.
the class FhirDstu2Resource method readPatientByLongIdAndStringResource.
@Path("/readPatient/byLongIdAndStringResource")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response readPatientByLongIdAndStringResource(@QueryParam("id") String id) {
Map<String, Object> headers = new HashMap<>();
headers.put("CamelFhir.resourceClass", "Patient");
headers.put("CamelFhir.longId", Long.valueOf(id));
try {
Patient result = producerTemplate.requestBodyAndHeaders("direct:readByLongIdAndStringResource-dstu2", null, headers, Patient.class);
return Response.ok().entity(patientToJsonObject(result)).build();
} catch (CamelExecutionException e) {
Throwable cause = e.getExchange().getException().getCause();
if (cause instanceof ResourceGoneException) {
return Response.status(404).build();
}
}
return Response.noContent().build();
}
use of ca.uhn.fhir.model.dstu2.resource.Patient in project camel-quarkus by apache.
the class FhirDstu2Resource method updateResourceBySearchUrl.
@Path("/update/resource/bySearchUrl")
@POST
@Produces(MediaType.TEXT_PLAIN)
public String updateResourceBySearchUrl(@QueryParam("id") String id) throws Exception {
Patient patient = getFhirClient().read().resource(Patient.class).withId(id).preferResponseType(Patient.class).execute();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = dateFormat.parse("1998-04-29");
patient.setBirthDate(new DateDt(date));
String url = "Patient?" + Patient.SP_IDENTIFIER + '=' + URLEncoder.encode(patient.getIdElement().getIdPart(), "UTF-8");
Map<String, Object> headers = new HashMap<>();
headers.put("CamelFhir.resource", patient);
headers.put("CamelFhir.url", url);
headers.put("CamelFhir.preferReturn", PreferReturnEnum.REPRESENTATION);
MethodOutcome result = producerTemplate.requestBodyAndHeaders("direct:updateResourceBySearchUrl-dstu2", null, headers, MethodOutcome.class);
Patient updated = (Patient) result.getResource();
return dateFormat.format(updated.getBirthDate());
}
use of ca.uhn.fhir.model.dstu2.resource.Patient in project camel-quarkus by apache.
the class FhirDstu2Resource method transactionWithResources.
@Path("/transaction/withResources")
@GET
@Produces(MediaType.TEXT_PLAIN)
@SuppressWarnings("unchecked")
public int transactionWithResources(@QueryParam("summaryEnum") boolean summaryEnum) {
Patient oscar = new Patient().addName(new HumanNameDt().addGiven("Oscar").setFamily(Arrays.asList(new StringDt("Peterson"))));
Patient bobbyHebb = new Patient().addName(new HumanNameDt().addGiven("Bobby").setFamily(Arrays.asList(new StringDt("Hebb"))));
List<IBaseResource> patients = new ArrayList<>(2);
patients.add(oscar);
patients.add(bobbyHebb);
Map<String, Object> headers = new HashMap<>();
if (summaryEnum) {
headers.put(ExtraParameters.SUMMARY_ENUM.getHeaderName(), SummaryEnum.DATA);
}
List<IBaseResource> result = producerTemplate.requestBodyAndHeaders("direct:transactionWithResources-dstu2", patients, headers, List.class);
return result.size();
}
use of ca.uhn.fhir.model.dstu2.resource.Patient in project camel-quarkus by apache.
the class FhirDstu2Resource method createTransactionBundle.
private Bundle createTransactionBundle() {
Bundle input = new Bundle();
input.setType(BundleTypeEnum.TRANSACTION);
input.addEntry().setResource(new Patient().addName(new HumanNameDt().addGiven("Art").setFamily(Arrays.asList(new StringDt("Tatum"))))).getRequest().setMethod(HTTPVerbEnum.POST);
return input;
}
Aggregations