Search in sources :

Example 71 with Attachment

use of org.hl7.fhir.dstu2016may.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)

Example 72 with Attachment

use of org.hl7.fhir.dstu2016may.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);
}
Also used : VersionedIdentifier(org.cqframework.cql.elm.execution.VersionedIdentifier) Library(org.hl7.fhir.r4.model.Library) Test(org.junit.Test)

Example 73 with Attachment

use of org.hl7.fhir.dstu2016may.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);
}
Also used : VersionedIdentifier(org.cqframework.cql.elm.execution.VersionedIdentifier) Library(org.hl7.fhir.r4.model.Library) Test(org.junit.Test)

Example 74 with Attachment

use of org.hl7.fhir.dstu2016may.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;
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) Attachment(org.hl7.fhir.r4.model.Attachment) Library(org.hl7.fhir.r4.model.Library) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 75 with Attachment

use of org.hl7.fhir.dstu2016may.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();
}
Also used : CqlLibrary(com.ibm.cohort.cql.library.CqlLibrary) CqlLibrarySourceProvider(com.ibm.cohort.cql.provider.CqlLibrarySourceProvider) LibrarySourceProvider(org.opencds.cqf.common.providers.LibrarySourceProvider) SourceProviderBasedCqlLibrarySourceProvider(com.ibm.cohort.cql.provider.SourceProviderBasedCqlLibrarySourceProvider) SourceProviderBasedCqlLibrarySourceProvider(com.ibm.cohort.cql.provider.SourceProviderBasedCqlLibrarySourceProvider) CqlLibrarySourceProvider(com.ibm.cohort.cql.provider.CqlLibrarySourceProvider) SourceProviderBasedCqlLibrarySourceProvider(com.ibm.cohort.cql.provider.SourceProviderBasedCqlLibrarySourceProvider) Attachment(org.hl7.fhir.r4.model.Attachment) CqlLibrary(com.ibm.cohort.cql.library.CqlLibrary) Library(org.cqframework.cql.elm.execution.Library) CqlLibraryDescriptor(com.ibm.cohort.cql.library.CqlLibraryDescriptor) ResolverLibraryResolutionProvider(com.ibm.cohort.cql.hapi.provider.ResolverLibraryResolutionProvider)

Aggregations

Attachment (org.hl7.fhir.r4.model.Attachment)33 Reference (org.hl7.fhir.r4.model.Reference)17 ArrayList (java.util.ArrayList)16 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)16 NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 Coding (org.hl7.fhir.r4.model.Coding)11 DiagnosticReport (org.hl7.fhir.r4.model.DiagnosticReport)10 List (java.util.List)9 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)9 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)9 Observation (org.hl7.fhir.r4.model.Observation)9 Test (org.junit.jupiter.api.Test)9 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)8 Resource (org.hl7.fhir.r4.model.Resource)8 FhirContext (ca.uhn.fhir.context.FhirContext)5 HashMap (java.util.HashMap)5 Base64 (org.apache.commons.codec.binary.Base64)5 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)5 Extension (org.hl7.fhir.r4.model.Extension)5 Library (org.hl7.fhir.r4.model.Library)5