use of org.cqframework.cql.cql2elm.model.TranslatedLibrary in project quality-measure-and-cohort-service by Alvearie.
the class CqlToElmTranslator method translate.
public CqlTranslationResult translate(CqlLibrary primaryLibrary, CqlLibrarySourceProvider sourceProvider) {
LibraryBuilder.SignatureLevel signatureLevel = LibraryBuilder.SignatureLevel.None;
LibraryManager libraryManager = newLibraryManager(sourceProvider);
Collection<CqlLibrary> dependencies = new ArrayList<>();
CqlTranslator cqlTranslator = CqlTranslator.fromText(primaryLibrary.getContent(), libraryManager.getModelManager(), libraryManager, /* ucumService= */
null, CqlTranslatorException.ErrorSeverity.Info, signatureLevel, getOptionsArray());
if (cqlTranslator.getErrors().size() > 0) {
throw new CqlTranslatorException("There were errors during cql translation: " + formatMsg(cqlTranslator.getErrors()));
} else if (cqlTranslator.getExceptions().size() > 0) {
throw new CqlTranslatorException("There were exceptions during cql translation: " + formatMsg(cqlTranslator.getExceptions()));
} else if (cqlTranslator.getWarnings().size() > 0) {
String msg = "There were warnings during cql translation:\n" + cqlTranslator.getWarnings().stream().map(Object::toString).collect(Collectors.joining("\n"));
LOG.warn(msg);
}
CqlLibrary translatedLibrary = new CqlLibrary().setDescriptor(new CqlLibraryDescriptor().setLibraryId(primaryLibrary.getDescriptor().getLibraryId()).setVersion(primaryLibrary.getDescriptor().getVersion()).setFormat(Format.ELM)).setContent(cqlTranslator.toXml());
try {
for (TranslatedLibrary tl : libraryManager.getTranslatedLibraries().values()) {
CqlLibrary library = new CqlLibrary().setDescriptor(new CqlLibraryDescriptor().setLibraryId(tl.getLibrary().getIdentifier().getId()).setVersion(tl.getLibrary().getIdentifier().getVersion()).setFormat(Format.ELM)).setContent(CqlTranslator.convertToXml(tl.getLibrary()));
dependencies.add(library);
}
} catch (JAXBException ex) {
throw new RuntimeException("ELM serialization failure", ex);
}
return new CqlTranslationResult(translatedLibrary, dependencies);
}
use of org.cqframework.cql.cql2elm.model.TranslatedLibrary in project cqf-ruler by DBCG.
the class DataRequirements method getModuleDefinitionLibraryR4.
public static org.hl7.fhir.r4.model.Library getModuleDefinitionLibraryR4(LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options, SearchParameterResolver searchParameterResolver, TerminologyProvider terminologyProvider, ModelResolver modelResolver, IBaseConformance capStatement) {
org.hl7.fhir.r5.model.Library libraryR5 = getModuleDefinitionLibraryR5(libraryManager, translatedLibrary, options);
VersionConvertor_40_50 versionConvertor_40_50 = new VersionConvertor_40_50(new BaseAdvisor_40_50());
org.hl7.fhir.r4.model.Library libraryR4 = (org.hl7.fhir.r4.model.Library) versionConvertor_40_50.convertResource(libraryR5);
libraryR4 = addDataRequirementFhirQueries(libraryR4, searchParameterResolver, terminologyProvider, modelResolver, capStatement);
return libraryR4;
}
use of org.cqframework.cql.cql2elm.model.TranslatedLibrary in project cqf-ruler by DBCG.
the class DataRequirements method getModuleDefinitionLibraryR4.
public static org.hl7.fhir.r4.model.Library getModuleDefinitionLibraryR4(org.hl7.fhir.r4.model.Measure measureToUse, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options, SearchParameterResolver searchParameterResolver, TerminologyProvider terminologyProvider, ModelResolver modelResolver, IBaseConformance capStatement) {
VersionConvertor_40_50 versionConvertor_40_50 = new VersionConvertor_40_50(new BaseAdvisor_40_50());
org.hl7.fhir.r5.model.Measure r5Measure = (org.hl7.fhir.r5.model.Measure) versionConvertor_40_50.convertResource(measureToUse);
Set<String> expressionList = getExpressions(r5Measure);
DataRequirementsProcessor dqReqTrans = new DataRequirementsProcessor();
org.hl7.fhir.r5.model.Library effectiveDataRequirements = dqReqTrans.gatherDataRequirements(libraryManager, translatedLibrary, options, expressionList, true);
org.hl7.fhir.r4.model.Library r4EffectiveDataRequirements = (org.hl7.fhir.r4.model.Library) versionConvertor_40_50.convertResource(effectiveDataRequirements);
r4EffectiveDataRequirements = addDataRequirementFhirQueries(r4EffectiveDataRequirements, searchParameterResolver, terminologyProvider, modelResolver, capStatement);
return r4EffectiveDataRequirements;
}
use of org.cqframework.cql.cql2elm.model.TranslatedLibrary in project cqf-ruler by DBCG.
the class DataRequirements method getModuleDefinitionLibraryDstu3.
public static org.hl7.fhir.dstu3.model.Library getModuleDefinitionLibraryDstu3(org.hl7.fhir.dstu3.model.Measure measureToUse, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options) {
VersionConvertor_30_50 versionConvertor_30_50 = new VersionConvertor_30_50(new BaseAdvisor_30_50());
org.hl7.fhir.r5.model.Measure r5Measure = (org.hl7.fhir.r5.model.Measure) versionConvertor_30_50.convertResource(measureToUse);
Set<String> expressionList = getExpressions(r5Measure);
DataRequirementsProcessor dqReqTrans = new DataRequirementsProcessor();
org.hl7.fhir.r5.model.Library effectiveDataRequirements = dqReqTrans.gatherDataRequirements(libraryManager, translatedLibrary, options, expressionList, true);
org.hl7.fhir.dstu3.model.Library stu3EffectiveDataRequirements = (org.hl7.fhir.dstu3.model.Library) versionConvertor_30_50.convertResource(effectiveDataRequirements);
// TODO: Support dataRequirementFhirQueries in STU3
return stu3EffectiveDataRequirements;
}
Aggregations