use of org.hl7.fhir.r4b.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);
}
use of org.hl7.fhir.r4b.model.Attachment in project quality-measure-and-cohort-service by Alvearie.
the class R4TranslatingLibraryLoaderTest method load_invalidCqlContent.
@Test
public void load_invalidCqlContent() throws IOException {
Library library = new Library();
withIdentifiers(library, NAME, VERSION);
withContent(library, "/cql/basic/Test-1.0.0.xml", "text/cql");
R4TranslatingLibraryLoader loader = getLoader(getLibraryResolver(NAME, VERSION, library));
VersionedIdentifier identifier = new VersionedIdentifier().withId(NAME).withVersion(VERSION);
String expectedPrefix = String.format("Library %s-%s cql attachment", NAME, VERSION);
assertIllegalArgumentException(() -> loader.load(identifier), expectedPrefix);
}
use of org.hl7.fhir.r4b.model.Attachment in project quality-measure-and-cohort-service by Alvearie.
the class R4TranslatingLibraryLoaderTest method load_invalidXmlContent.
@Test
public void load_invalidXmlContent() throws IOException {
Library library = new Library();
withIdentifiers(library, NAME, VERSION);
withContent(library, "/cql/basic/Test-1.0.0.cql", "application/elm+xml");
R4TranslatingLibraryLoader loader = getLoader(getLibraryResolver(NAME, VERSION, library));
VersionedIdentifier identifier = new VersionedIdentifier().withId(NAME).withVersion(VERSION);
String expectedPrefix = String.format("Library %s-%s elm attachment", NAME, VERSION);
assertIllegalArgumentException(() -> loader.load(identifier), expectedPrefix);
}
use of org.hl7.fhir.r4b.model.Attachment in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluationSeederTest method createLibrary.
private Library createLibrary(String elmFile) throws IOException {
Coding libraryCoding = new Coding();
libraryCoding.setSystem(LibraryType.LOGICLIBRARY.getSystem());
libraryCoding.setCode(LibraryType.LOGICLIBRARY.toCode());
CodeableConcept libraryType = new CodeableConcept();
libraryType.setCoding(Collections.singletonList(libraryCoding));
Library library = new Library();
library.setId(libraryName + "-id");
library.setType(libraryType);
library.setName(libraryName);
library.setVersion(libraryVersion);
Attachment attachment = new Attachment();
attachment.setData(IOUtils.resourceToByteArray(elmFile));
attachment.setContentType("application/elm+xml");
library.setContent(Collections.singletonList(attachment));
return library;
}
use of org.hl7.fhir.r4b.model.Attachment in project quality-measure-and-cohort-service by Alvearie.
the class R4TranslatingLibraryLoader method translateLibrary.
private String translateLibrary(String content, VersionedIdentifier libraryIdentifier) {
LibraryResolutionProvider<org.hl7.fhir.r4.model.Library> libraryResolutionProvider = new ResolverLibraryResolutionProvider<>(resolver);
LibrarySourceProvider<org.hl7.fhir.r4.model.Library, Attachment> librarySourceProvider = new LibrarySourceProvider<>(libraryResolutionProvider, org.hl7.fhir.r4.model.Library::getContent, Attachment::getContentType, Attachment::getData);
CqlLibrarySourceProvider cqlLibrarySourceProvider = new SourceProviderBasedCqlLibrarySourceProvider(librarySourceProvider);
CqlLibraryDescriptor descriptor = new CqlLibraryDescriptor().setFormat(Format.CQL).setLibraryId(libraryIdentifier.getId()).setVersion(libraryIdentifier.getVersion());
CqlLibrary library = new CqlLibrary().setDescriptor(descriptor).setContent(content);
return translator.translate(library, cqlLibrarySourceProvider).getMainLibrary().getContent();
}
Aggregations