Search in sources :

Example 61 with Meta

use of org.hl7.fhir.r5.model.Meta in project dpc-app by CMSgov.

the class MockBlueButtonClientV2 method requestNextBundleFromServer.

@Override
// Date class is used by FHIR stu3 Meta model
@SuppressWarnings("JdkObsolete")
public Bundle requestNextBundleFromServer(Bundle bundle, Map<String, String> headers) throws ResourceNotFoundException {
    // This is code is very specific to the bb-test-data directory and its contents
    final var nextLink = bundle.getLink(Bundle.LINK_NEXT).getUrl();
    final var nextUrl = URI.create(nextLink);
    final var params = URLEncodedUtils.parse(nextUrl.getQuery(), StandardCharsets.UTF_8);
    final var patient = params.stream().filter(pair -> pair.getName().equals("patient")).findFirst().orElseThrow().getValue();
    final var startIndex = params.stream().filter(pair -> pair.getName().equals("startIndex")).findFirst().orElseThrow().getValue();
    var path = SAMPLE_EOB_PATH_PREFIX + patient + "_" + startIndex + ".xml";
    try (InputStream sampleData = MockBlueButtonClientV2.class.getClassLoader().getResourceAsStream(path)) {
        final var nextBundle = parser.parseResource(Bundle.class, sampleData);
        nextBundle.getMeta().setLastUpdated(Date.from(BFD_TRANSACTION_TIME.toInstant()));
        return nextBundle;
    } catch (IOException ex) {
        throw new ResourceNotFoundException("Missing next bundle");
    }
}
Also used : Date(java.util.Date) IOException(java.io.IOException) Instant(java.time.Instant) StandardCharsets(java.nio.charset.StandardCharsets) FhirContext(ca.uhn.fhir.context.FhirContext) List(java.util.List) OffsetDateTime(java.time.OffsetDateTime) ChronoUnit(java.time.temporal.ChronoUnit) DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) CapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement) URLEncodedUtils(org.apache.http.client.utils.URLEncodedUtils) Map(java.util.Map) Named(com.google.inject.name.Named) Bundle(org.hl7.fhir.r4.model.Bundle) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) URI(java.net.URI) ZoneOffset(java.time.ZoneOffset) PerformanceOptionsEnum(ca.uhn.fhir.context.PerformanceOptionsEnum) IParser(ca.uhn.fhir.parser.IParser) InputStream(java.io.InputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)

Example 62 with Meta

use of org.hl7.fhir.r5.model.Meta in project dpc-app by CMSgov.

the class FHIRBuilders method addOrganizationTag.

/**
 * Add Organization ID to {@link Resource} {@link Meta}
 *
 * @param resource       - {@link Resource} to add (or update) {@link Meta}
 * @param organizationID - {@link UUID} Organization ID
 */
public static void addOrganizationTag(Resource resource, UUID organizationID) {
    Meta meta = resource.getMeta();
    if (meta == null) {
        meta = new Meta();
    }
    // Add the Organization ID
    meta.addTag(DPCIdentifierSystem.DPC.getSystem(), organizationID.toString(), "Organization ID");
    resource.setMeta(meta);
}
Also used : Meta(org.hl7.fhir.dstu3.model.Meta)

Example 63 with Meta

use of org.hl7.fhir.r5.model.Meta 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 64 with Meta

use of org.hl7.fhir.r5.model.Meta 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)

Example 65 with Meta

use of org.hl7.fhir.r5.model.Meta in project camel-quarkus by apache.

the class FhirDstu2Resource method metaAdd.

// ///////////////////
// Meta
// ///////////////////
@Path("/meta")
@POST
@Produces(MediaType.TEXT_PLAIN)
public int metaAdd(@QueryParam("id") String id) {
    IdDt iIdType = new IdDt(id);
    MetaDt inMeta = new MetaDt();
    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-dstu2", null, headers, IBaseMetaType.class);
    return result.getTag().size();
}
Also used : HashMap(java.util.HashMap) IBaseMetaType(org.hl7.fhir.instance.model.api.IBaseMetaType) IdDt(ca.uhn.fhir.model.primitive.IdDt) JsonObject(javax.json.JsonObject) MetaDt(ca.uhn.fhir.model.dstu2.composite.MetaDt) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Aggregations

Meta (org.hl7.fhir.r4.model.Meta)40 HashMap (java.util.HashMap)36 Date (java.util.Date)35 Meta (org.hl7.fhir.dstu3.model.Meta)31 IBaseMetaType (org.hl7.fhir.instance.model.api.IBaseMetaType)28 Reference (org.hl7.fhir.r4.model.Reference)26 JsonObject (javax.json.JsonObject)24 Path (javax.ws.rs.Path)24 Produces (javax.ws.rs.Produces)24 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)20 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)18 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)17 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)17 ArrayList (java.util.ArrayList)16 Coding (org.hl7.fhir.r4.model.Coding)16 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)15 Test (org.junit.jupiter.api.Test)15 Test (org.junit.Test)14 NotImplementedException (org.apache.commons.lang3.NotImplementedException)13 GET (javax.ws.rs.GET)12