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;
}
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;
}
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;
}
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);
}
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);
}
Aggregations