Search in sources :

Example 11 with IBaseMetaType

use of org.hl7.fhir.instance.model.api.IBaseMetaType in project camel-quarkus by apache.

the class FhirDstu3Resource method metaGetFromType.

@Path("/meta/getFromType")
@GET
@Produces(MediaType.TEXT_PLAIN)
public int metaGetFromType(@QueryParam("preferResponseType") boolean preferResponseType) {
    Map<String, Object> headers = new HashMap<>();
    headers.put("CamelFhir.metaType", Meta.class);
    headers.put("CamelFhir.resourceType", "Patient");
    if (preferResponseType) {
        headers.put(ExtraParameters.PREFER_RESPONSE_TYPE.getHeaderName(), Patient.class);
    }
    IBaseMetaType result = producerTemplate.requestBodyAndHeaders("direct:metaGetFromType-dstu3", null, headers, IBaseMetaType.class);
    return result.getTag().size();
}
Also used : HashMap(java.util.HashMap) IBaseMetaType(org.hl7.fhir.instance.model.api.IBaseMetaType) JsonObject(javax.json.JsonObject) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 12 with IBaseMetaType

use of org.hl7.fhir.instance.model.api.IBaseMetaType in project camel-spring-boot by apache.

the class FhirMetaIT method testAdd.

@Test
public void testAdd() throws Exception {
    // assert no meta
    Meta meta = fhirClient.meta().get(Meta.class).fromResource(this.patient.getIdElement()).execute();
    assertEquals(0, meta.getTag().size());
    Meta inMeta = new Meta();
    inMeta.addTag().setSystem("urn:system1").setCode("urn:code1");
    final Map<String, Object> headers = new HashMap<>();
    // parameter type is org.hl7.fhir.instance.model.api.IBaseMetaType
    headers.put("CamelFhir.meta", inMeta);
    // parameter type is org.hl7.fhir.instance.model.api.IIdType
    headers.put("CamelFhir.id", this.patient.getIdElement());
    IBaseMetaType result = requestBodyAndHeaders("direct://ADD", null, headers);
    LOG.debug("add: " + result);
    assertNotNull(result, "add result");
    assertEquals(1, result.getTag().size());
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) HashMap(java.util.HashMap) IBaseMetaType(org.hl7.fhir.instance.model.api.IBaseMetaType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) CamelSpringBootTest(org.apache.camel.test.spring.junit5.CamelSpringBootTest)

Example 13 with IBaseMetaType

use of org.hl7.fhir.instance.model.api.IBaseMetaType in project camel-spring-boot by apache.

the class FhirMetaIT method testDelete.

@Test
public void testDelete() throws Exception {
    // assert no meta
    Meta meta = fhirClient.meta().get(Meta.class).fromResource(this.patient.getIdElement()).execute();
    assertEquals(0, meta.getTag().size());
    Meta inMeta = new Meta();
    inMeta.addTag().setSystem("urn:system1").setCode("urn:code1");
    // add meta
    meta = fhirClient.meta().add().onResource(this.patient.getIdElement()).meta(inMeta).execute();
    assertEquals(1, meta.getTag().size());
    // delete meta
    final Map<String, Object> headers = new HashMap<>();
    // parameter type is org.hl7.fhir.instance.model.api.IBaseMetaType
    headers.put("CamelFhir.meta", meta);
    // parameter type is org.hl7.fhir.instance.model.api.IIdType
    headers.put("CamelFhir.id", this.patient.getIdElement());
    IBaseMetaType result = requestBodyAndHeaders("direct://DELETE", null, headers);
    LOG.debug("delete: " + result);
    assertNotNull(result, "delete result");
    assertEquals(0, result.getTag().size());
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) HashMap(java.util.HashMap) IBaseMetaType(org.hl7.fhir.instance.model.api.IBaseMetaType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) CamelSpringBootTest(org.apache.camel.test.spring.junit5.CamelSpringBootTest)

Example 14 with IBaseMetaType

use of org.hl7.fhir.instance.model.api.IBaseMetaType in project camel-spring-boot by apache.

the class FhirMetaIT method testGetFromResource.

@Test
public void testGetFromResource() throws Exception {
    final Map<String, Object> headers = new HashMap<>();
    // parameter type is Class
    headers.put("CamelFhir.metaType", Meta.class);
    // parameter type is org.hl7.fhir.instance.model.api.IIdType
    headers.put("CamelFhir.id", this.patient.getIdElement());
    IBaseMetaType result = requestBodyAndHeaders("direct://GET_FROM_RESOURCE", null, headers);
    LOG.debug("getFromResource: " + result);
    assertNotNull(result, "getFromResource result");
    assertEquals(0, result.getTag().size());
}
Also used : HashMap(java.util.HashMap) IBaseMetaType(org.hl7.fhir.instance.model.api.IBaseMetaType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) CamelSpringBootTest(org.apache.camel.test.spring.junit5.CamelSpringBootTest)

Example 15 with IBaseMetaType

use of org.hl7.fhir.instance.model.api.IBaseMetaType in project camel-quarkus by apache.

the class FhirR4Resource method metaAdd.

// ///////////////////
// Meta
// ///////////////////
@Path("/meta")
@POST
@Produces(MediaType.TEXT_PLAIN)
public int metaAdd(@QueryParam("id") String id) {
    IdType iIdType = new IdType(id);
    Meta inMeta = new Meta();
    inMeta.addTag().setSystem("urn:system1").setCode("urn:code1");
    Map<String, Object> headers = new HashMap<>();
    headers.put("CamelFhir.meta", inMeta);
    headers.put("CamelFhir.id", iIdType);
    IBaseMetaType result = producerTemplate.requestBodyAndHeaders("direct:metaAdd-r4", null, headers, IBaseMetaType.class);
    return result.getTag().size();
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) HashMap(java.util.HashMap) IBaseMetaType(org.hl7.fhir.instance.model.api.IBaseMetaType) JsonObject(javax.json.JsonObject) IdType(org.hl7.fhir.r4.model.IdType) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Aggregations

IBaseMetaType (org.hl7.fhir.instance.model.api.IBaseMetaType)34 HashMap (java.util.HashMap)32 JsonObject (javax.json.JsonObject)24 Path (javax.ws.rs.Path)24 Produces (javax.ws.rs.Produces)24 GET (javax.ws.rs.GET)12 CamelSpringBootTest (org.apache.camel.test.spring.junit5.CamelSpringBootTest)10 Test (org.junit.jupiter.api.Test)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)10 DELETE (javax.ws.rs.DELETE)6 POST (javax.ws.rs.POST)6 Meta (org.hl7.fhir.dstu3.model.Meta)4 Meta (org.hl7.fhir.r4.model.Meta)4 IdDt (ca.uhn.fhir.model.primitive.IdDt)3 IdType (org.hl7.fhir.dstu2.model.IdType)3 IdType (org.hl7.fhir.dstu2016may.model.IdType)3 IdType (org.hl7.fhir.dstu3.model.IdType)3 IdType (org.hl7.fhir.r4.model.IdType)3 IdType (org.hl7.fhir.r5.model.IdType)3 MetaDt (ca.uhn.fhir.model.dstu2.composite.MetaDt)2