use of ca.uhn.fhir.model.dstu2.resource.Bundle 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;
}
use of ca.uhn.fhir.model.dstu2.resource.Bundle in project camel-quarkus by apache.
the class FhirDstu2Resource method operationOnType.
@Path("/operation/onType")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String operationOnType() {
Map<String, Object> headers = new HashMap<>();
headers.put("CamelFhir.resourceType", Patient.class);
headers.put("CamelFhir.name", "everything");
headers.put("CamelFhir.parameters", null);
headers.put("CamelFhir.outputParameterType", Parameters.class);
headers.put("CamelFhir.useHttpGet", Boolean.FALSE);
headers.put("CamelFhir.returnType", null);
headers.put("CamelFhir.extraParameters", null);
Parameters result = producerTemplate.requestBodyAndHeaders("direct:operationOnType-dstu2", null, headers, Parameters.class);
Parameters.Parameter parameter = result.getParameter().get(0);
Bundle bundle = (Bundle) parameter.getResource();
IdDt patientId = bundle.getEntry().get(0).getResource().getId();
return patientId.toUnqualifiedVersionless().getValue();
}
use of ca.uhn.fhir.model.dstu2.resource.Bundle in project camel-quarkus by apache.
the class FhirDstu2Resource method transactionWithStringBundle.
@Path("/transaction/withStringBundle")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String transactionWithStringBundle() {
Bundle transactionBundle = createTransactionBundle();
String stringBundle = fhirContextInstance.get().newJsonParser().encodeResourceToString(transactionBundle);
return producerTemplate.requestBody("direct:transactionWithStringBundle-dstu2", stringBundle, String.class);
}
use of ca.uhn.fhir.model.dstu2.resource.Bundle in project camel-quarkus by apache.
the class FhirDstu2Resource method loadPagePrevious.
@Path("/load/page/previous")
@GET
@Produces(MediaType.TEXT_PLAIN)
public int loadPagePrevious(@QueryParam("encodeAsXml") boolean encodeAsXml) {
String url = "Patient?_count=2";
Bundle bundle = getFhirClient().search().byUrl(url).returnBundle(Bundle.class).execute();
String nextPageLink = bundle.getLink("next").getUrl();
bundle = getFhirClient().loadPage().byUrl(nextPageLink).andReturnBundle(Bundle.class).execute();
Map<String, Object> headers = new HashMap<>();
if (encodeAsXml) {
headers.put(ExtraParameters.ENCODING_ENUM.getHeaderName(), EncodingEnum.XML);
}
Bundle result = producerTemplate.requestBodyAndHeaders("direct:loadPagePrevious-dstu2", bundle, headers, Bundle.class);
return result.getEntry().size();
}
use of ca.uhn.fhir.model.dstu2.resource.Bundle in project synthea by synthetichealth.
the class FhirDstu2 method procedure.
/**
* Map the given Procedure into a FHIR Procedure resource, and add it to the given Bundle.
*
* @param rand
* Source of randomness to use when generating ids etc
* @param personEntry
* The Person entry
* @param bundle
* Bundle to add to
* @param encounterEntry
* The current Encounter entry
* @param procedure
* The Procedure
* @return The added Entry
*/
private static Entry procedure(RandomNumberGenerator rand, Entry personEntry, Bundle bundle, Entry encounterEntry, Procedure procedure) {
ca.uhn.fhir.model.dstu2.resource.Procedure procedureResource = new ca.uhn.fhir.model.dstu2.resource.Procedure();
procedureResource.setStatus(ProcedureStatusEnum.COMPLETED);
procedureResource.setSubject(new ResourceReferenceDt(personEntry.getFullUrl()));
procedureResource.setEncounter(new ResourceReferenceDt(encounterEntry.getFullUrl()));
Code code = procedure.codes.get(0);
procedureResource.setCode(mapCodeToCodeableConcept(code, SNOMED_URI));
if (procedure.stop != 0L) {
Date startDate = new Date(procedure.start);
Date endDate = new Date(procedure.stop);
procedureResource.setPerformed(new PeriodDt().setStart(new DateTimeDt(startDate)).setEnd(new DateTimeDt(endDate)));
} else {
procedureResource.setPerformed(convertFhirDateTime(procedure.start, true));
}
if (!procedure.reasons.isEmpty()) {
// Only one element in list
Code reason = procedure.reasons.get(0);
for (Entry entry : bundle.getEntry()) {
if (entry.getResource().getResourceName().equals("Condition")) {
Condition condition = (Condition) entry.getResource();
// Only one element in list
CodingDt coding = condition.getCode().getCoding().get(0);
if (reason.code.equals(coding.getCode())) {
procedureResource.setReason(new ResourceReferenceDt(entry.getFullUrl()));
}
}
}
}
Entry procedureEntry = newEntry(rand, bundle, procedureResource);
procedure.fullUrl = procedureEntry.getFullUrl();
return procedureEntry;
}
Aggregations