use of org.cqframework.cql.cql2elm.CqlTranslatorOptions in project cqf-ruler by DBCG.
the class Translators method getTranslatorOptions.
public static CqlTranslatorOptions getTranslatorOptions() {
CqlTranslatorOptions cqlTranslatorOptions = new CqlTranslatorOptions();
cqlTranslatorOptions.getOptions().addAll(generateDefaultTranslatorOptions());
cqlTranslatorOptions.setAnalyzeDataRequirements(true);
cqlTranslatorOptions.setCollapseDataRequirements(true);
return cqlTranslatorOptions;
}
use of org.cqframework.cql.cql2elm.CqlTranslatorOptions in project CRD by HL7-DaVinci.
the class LocalLibraryLoader method loadLibrary.
private Library loadLibrary(VersionedIdentifier libraryIdentifier) {
List<CqlTranslatorException> errors = new ArrayList<>();
org.hl7.elm.r1.VersionedIdentifier identifier = new org.hl7.elm.r1.VersionedIdentifier().withId(libraryIdentifier.getId()).withSystem(libraryIdentifier.getSystem()).withVersion(libraryIdentifier.getVersion());
CqlTranslatorOptions options = new CqlTranslatorOptions();
org.cqframework.cql.cql2elm.model.TranslatedLibrary translatedLibrary = libraryManager.resolveLibrary(identifier, options, errors);
String xml;
try {
JAXBContext jc = JAXBContext.newInstance(org.hl7.elm.r1.Library.class, Annotation.class);
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
StringWriter writer = new StringWriter();
marshaller.marshal(new ObjectFactory().createLibrary(translatedLibrary.getLibrary()), writer);
xml = writer.getBuffer().toString();
} catch (JAXBException e) {
throw new RuntimeException(String.format("Errors encountered while loading library %s: %s", libraryIdentifier.getId(), e.getMessage()));
}
Library library = null;
try {
library = CqlLibraryReader.read(new StringReader(xml));
} catch (IOException | JAXBException e) {
throw new RuntimeException(String.format("Errors encountered while loading library %s: %s", libraryIdentifier.getId(), e.getMessage()));
}
return library;
}
Aggregations