Search in sources :

Example 1 with IBaseMetaType

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

the class FhirMetaTest method testGetFromServer.

@Test
public void testGetFromServer() throws Exception {
    // using Class message body for single parameter "metaType"
    IBaseMetaType result = requestBody("direct://GET_FROM_SERVER", Meta.class);
    assertNotNull(result, "getFromServer result");
    LOG.debug("getFromServer: " + result);
}
Also used : 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 2 with IBaseMetaType

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

the class FhirMetaTest 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.dstu3.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 3 with IBaseMetaType

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

the class FhirMetaTest 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.dstu3.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 4 with IBaseMetaType

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

the class FhirDstu2Hl7OrgResource method metaGetFromResource.

@Path("/meta/getFromResource")
@GET
@Produces(MediaType.TEXT_PLAIN)
public int metaGetFromResource(@QueryParam("id") String id) {
    IdType iIdType = new IdType(id);
    final Map<String, Object> headers = new HashMap<>();
    headers.put("CamelFhir.metaType", Meta.class);
    headers.put("CamelFhir.id", iIdType);
    IBaseMetaType result = producerTemplate.requestBodyAndHeaders("direct:metaGetFromResource-dstu2-hl7org", 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) IdType(org.hl7.fhir.dstu2.model.IdType) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with IBaseMetaType

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

the class FhirR5Resource 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-r5", null, headers, IBaseMetaType.class);
    return result.getTag().size();
}
Also used : Meta(org.hl7.fhir.r5.model.Meta) HashMap(java.util.HashMap) IBaseMetaType(org.hl7.fhir.instance.model.api.IBaseMetaType) JsonObject(javax.json.JsonObject) IdType(org.hl7.fhir.r5.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