Search in sources :

Example 6 with Attachment

use of com.ibm.cloud.cloudant.v1.model.Attachment in project cqf-ruler by DBCG.

the class ActivityDefinitionApplyProvider method resolveCommunication.

private Communication resolveCommunication(ActivityDefinition activityDefinition, String patientId) {
    Communication communication = new Communication();
    communication.setStatus(Communication.CommunicationStatus.UNKNOWN);
    communication.setSubject(new Reference(patientId));
    if (activityDefinition.hasCode()) {
        communication.setReasonCode(Collections.singletonList(activityDefinition.getCode()));
    }
    if (activityDefinition.hasRelatedArtifact()) {
        for (RelatedArtifact artifact : activityDefinition.getRelatedArtifact()) {
            if (artifact.hasUrl()) {
                Attachment attachment = new Attachment().setUrl(artifact.getUrl());
                if (artifact.hasDisplay()) {
                    attachment.setTitle(artifact.getDisplay());
                }
                Communication.CommunicationPayloadComponent payload = new Communication.CommunicationPayloadComponent();
                payload.setContent(artifact.hasDisplay() ? attachment.setTitle(artifact.getDisplay()) : attachment);
                communication.setPayload(Collections.singletonList(payload));
            }
        // TODO - other relatedArtifact types
        }
    }
    return communication;
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) Attachment(org.hl7.fhir.dstu3.model.Attachment) RelatedArtifact(org.hl7.fhir.dstu3.model.RelatedArtifact) Communication(org.hl7.fhir.dstu3.model.Communication)

Example 7 with Attachment

use of com.ibm.cloud.cloudant.v1.model.Attachment in project cqf-ruler by DBCG.

the class ActivityDefinitionApplyProvider method resolveCommunication.

private Communication resolveCommunication(ActivityDefinition activityDefinition, String patientId) {
    Communication communication = new Communication();
    communication.setStatus(Communication.CommunicationStatus.UNKNOWN);
    communication.setSubject(new Reference(patientId));
    if (activityDefinition.hasCode()) {
        communication.setReasonCode(Collections.singletonList(activityDefinition.getCode()));
    }
    if (activityDefinition.hasRelatedArtifact()) {
        for (RelatedArtifact artifact : activityDefinition.getRelatedArtifact()) {
            if (artifact.hasUrl()) {
                Attachment attachment = new Attachment().setUrl(artifact.getUrl());
                if (artifact.hasDisplay()) {
                    attachment.setTitle(artifact.getDisplay());
                }
                Communication.CommunicationPayloadComponent payload = new Communication.CommunicationPayloadComponent();
                payload.setContent(artifact.hasDisplay() ? attachment.setTitle(artifact.getDisplay()) : attachment);
                communication.setPayload(Collections.singletonList(payload));
            }
        // TODO - other relatedArtifact types
        }
    }
    return communication;
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) Attachment(org.hl7.fhir.r4.model.Attachment) RelatedArtifact(org.hl7.fhir.r4.model.RelatedArtifact) Communication(org.hl7.fhir.r4.model.Communication)

Example 8 with Attachment

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

the class FhirTestBase method getLibrary.

protected Library getLibrary(String name, String version, String... attachmentData) throws Exception {
    if (attachmentData == null || attachmentData.length == 0 || (attachmentData.length > 2) && ((attachmentData.length % 2) != 0)) {
        fail("Invalid attachment data. Data must consist of one or more pairs of resource path and content-type strings");
    }
    List<String> pairs = new ArrayList<>(Arrays.asList(attachmentData));
    if (pairs.size() == 1) {
        pairs.add("text/cql");
    }
    List<Attachment> attachments = new ArrayList<>();
    for (int i = 0; i < pairs.size(); i += 2) {
        String resource = pairs.get(i);
        String contentType = pairs.get(i + 1);
        try (InputStream is = ClassLoader.getSystemResourceAsStream(resource)) {
            assertNotNull(String.format("No such resource %s found in classpath", resource), is);
            String text = IOUtils.toString(is, StandardCharsets.UTF_8);
            Attachment attachment = new Attachment();
            attachment.setContentType(contentType);
            attachment.setData(text.getBytes());
            attachments.add(attachment);
        }
    }
    Library library = new Library();
    library.setId("library-" + name + "-" + version);
    library.setName(name);
    library.setUrl(IBM_PREFIX + "/Library/" + name);
    library.setVersion(version);
    library.setContent(attachments);
    return library;
}
Also used : InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) Attachment(org.hl7.fhir.r4.model.Attachment) Library(org.hl7.fhir.r4.model.Library)

Example 9 with Attachment

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

the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testAttachment__shouldThrowException.

@Test(expected = UnsupportedFhirTypeException.class)
public void testAttachment__shouldThrowException() {
    ParameterDefinition parameterDefinition = getBaseParameterDefinition("Attachment");
    Attachment fhirValue = new Attachment();
    parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
    R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition);
}
Also used : Attachment(org.hl7.fhir.r4.model.Attachment) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) Test(org.junit.Test)

Example 10 with Attachment

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

the class R4TranslatingLibraryLoaderTest method withContent.

private void withContent(Library library, String resourcePath, String contentType) throws IOException {
    Attachment attachment = new Attachment();
    attachment.setContentType(contentType);
    attachment.setData(IOUtils.resourceToByteArray(resourcePath));
    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