Search in sources :

Example 41 with Attachment

use of com.ibm.cloud.cloudant.v1.model.Attachment in project fhir-bridge by ehrbase.

the class DocumentReferenceToHipDocumentConverter method getMultimedia.

private MediendateiCluster getMultimedia(DocumentReference documentReference) {
    Attachment attachment = documentReference.getContentFirstRep().getAttachment();
    DvMultimedia multimedia = new DvMultimedia();
    multimedia.setUri(new DvURI(attachment.getUrl()));
    multimedia.setMediaType(new CodePhrase(new TerminologyId("IANA_media-types"), attachment.getContentType()));
    multimedia.setSize(attachment.getSize());
    MediendateiCluster result = new MediendateiCluster();
    result.setMediendateiInhalt(multimedia);
    result.setMediendateiInhaltValue(attachment.getTitle());
    result.setBeschreibungValue(documentReference.getDescription());
    getCreation(attachment).ifPresent(result::setErstelltValue);
    return result;
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) Attachment(org.hl7.fhir.r4.model.Attachment) DvMultimedia(com.nedap.archie.rm.datavalues.encapsulated.DvMultimedia) MediendateiCluster(org.ehrbase.fhirbridge.ehr.opt.hipdocumentcomposition.definition.MediendateiCluster) DvURI(com.nedap.archie.rm.datavalues.DvURI)

Example 42 with Attachment

use of com.ibm.cloud.cloudant.v1.model.Attachment in project geoprism-registry by terraframe.

the class AbstractFhirResourceProcessor method getGeometry.

protected Geometry getGeometry(Location location, ServerGeoObjectType type) {
    Extension extension = location.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/location-boundary-geojson");
    if (extension != null) {
        Attachment value = (Attachment) extension.getValue();
        if (value.hasData()) {
            Decoder decoder = Base64.getDecoder();
            byte[] binary = decoder.decode(value.getDataElement().getValueAsString());
            String geojson = new String(binary);
            GeoJsonReader reader = new GeoJsonReader();
            try {
                return reader.read(geojson);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
    }
    return null;
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) GeoJsonReader(com.vividsolutions.jts.io.geojson.GeoJsonReader) Attachment(org.hl7.fhir.r4.model.Attachment) ParseException(com.vividsolutions.jts.io.ParseException) Decoder(java.util.Base64.Decoder)

Example 43 with Attachment

use of com.ibm.cloud.cloudant.v1.model.Attachment in project geoprism-registry by terraframe.

the class ListTypeFhirExporter method createFacility.

private Facility createFacility(Business row, Identifier identifier) {
    String code = row.getValue(DefaultAttribute.CODE.getName());
    Organization org = new Organization();
    org.setId(new IdType(org.getResourceType().name(), code));
    org.setName(row.getValue(DefaultAttribute.DISPLAY_LABEL.getName() + ListTypeVersion.DEFAULT_LOCALE));
    org.addIdentifier(identifier);
    Location location = new Location();
    location.setId(new IdType(location.getResourceType().name(), code));
    location.setName(row.getValue(DefaultAttribute.DISPLAY_LABEL.getName() + ListTypeVersion.DEFAULT_LOCALE));
    location.setManagingOrganization(new Reference(org.getIdElement()));
    location.addIdentifier(identifier);
    Geometry geometry = row.getObjectValue(RegistryConstants.GEOMETRY_ATTRIBUTE_NAME);
    if (geometry != null) {
        Point centroid = geometry.getCentroid();
        GeoJsonWriter writer = new GeoJsonWriter();
        String geojson = writer.write(geometry);
        Encoder encoder = Base64.getEncoder();
        // Create a location
        Attachment attachment = new Attachment();
        attachment.setContentType("application/json");
        attachment.setDataElement(new Base64BinaryType(encoder.encodeToString(geojson.getBytes())));
        attachment.setTitle("Geojson");
        Extension extension = new Extension("http://hl7.org/fhir/StructureDefinition/location-boundary-geojson");
        extension.setValue(attachment);
        location.setPosition(new LocationPositionComponent(new DecimalType(centroid.getX()), new DecimalType(centroid.getY())));
        location.addExtension(extension);
    }
    return new Facility(org, location);
}
Also used : GeoJsonWriter(com.vividsolutions.jts.io.geojson.GeoJsonWriter) Organization(org.hl7.fhir.r4.model.Organization) Reference(org.hl7.fhir.r4.model.Reference) Attachment(org.hl7.fhir.r4.model.Attachment) Point(com.vividsolutions.jts.geom.Point) IdType(org.hl7.fhir.r4.model.IdType) Geometry(com.vividsolutions.jts.geom.Geometry) Extension(org.hl7.fhir.r4.model.Extension) LocationPositionComponent(org.hl7.fhir.r4.model.Location.LocationPositionComponent) Encoder(java.util.Base64.Encoder) DecimalType(org.hl7.fhir.r4.model.DecimalType) Base64BinaryType(org.hl7.fhir.r4.model.Base64BinaryType) Location(org.hl7.fhir.r4.model.Location)

Example 44 with Attachment

use of com.ibm.cloud.cloudant.v1.model.Attachment in project quality-measure-and-cohort-service by Alvearie.

the class CohortCLI method toCqlLibraryMap.

private Map<CqlLibraryDescriptor, CqlLibrary> toCqlLibraryMap(List<Library> libraries) {
    Map<CqlLibraryDescriptor, CqlLibrary> retVal = new HashMap<>();
    for (Library library : libraries) {
        String libraryId = library.getName();
        String version = library.getVersion();
        for (Attachment attachment : library.getContent()) {
            Format libraryFormat = Format.lookupByName(attachment.getContentType());
            if (libraryFormat != null) {
                CqlLibraryDescriptor key = new CqlLibraryDescriptor().setLibraryId(libraryId).setVersion(version).setFormat(libraryFormat);
                CqlLibrary value = new CqlLibrary().setContent(new String(attachment.getData())).setDescriptor(key);
                retVal.put(key, value);
            }
        }
    }
    return retVal;
}
Also used : CqlLibrary(com.ibm.cohort.cql.library.CqlLibrary) Format(com.ibm.cohort.cql.library.Format) HashMap(java.util.HashMap) Attachment(org.hl7.fhir.r4.model.Attachment) Library(org.hl7.fhir.r4.model.Library) CqlLibrary(com.ibm.cohort.cql.library.CqlLibrary) CqlLibraryDescriptor(com.ibm.cohort.cql.library.CqlLibraryDescriptor)

Example 45 with Attachment

use of com.ibm.cloud.cloudant.v1.model.Attachment in project quality-measure-and-cohort-service by Alvearie.

the class R4LibraryDependencyGathererTest method withContent.

private void withContent(Library library, String contentType) {
    Attachment attachment = new Attachment();
    attachment.setContentType(contentType);
    library.addContent(attachment);
}
Also used : Attachment(org.hl7.fhir.r4.model.Attachment)

Aggregations

Attachment (org.hl7.fhir.r4.model.Attachment)33 ArrayList (java.util.ArrayList)23 Test (org.testng.annotations.Test)19 Attachment (com.ibm.cloud.cloudant.v1.model.Attachment)17 DocumentRevisionStatus (com.ibm.cloud.cloudant.v1.model.DocumentRevisionStatus)16 Revisions (com.ibm.cloud.cloudant.v1.model.Revisions)16 Reference (org.hl7.fhir.r4.model.Reference)15 HashMap (java.util.HashMap)11 Document (com.ibm.cloud.cloudant.v1.model.Document)10 DocumentResult (com.ibm.cloud.cloudant.v1.model.DocumentResult)9 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)8 Observation (org.hl7.fhir.r4.model.Observation)8 DesignDocument (com.ibm.cloud.cloudant.v1.model.DesignDocument)7 ReplicationDocument (com.ibm.cloud.cloudant.v1.model.ReplicationDocument)7 MockResponse (okhttp3.mockwebserver.MockResponse)7 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)7 Coding (org.hl7.fhir.r4.model.Coding)7 Resource (org.hl7.fhir.r4.model.Resource)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 NotImplementedException (org.apache.commons.lang3.NotImplementedException)6