use of org.hl7.fhir.r5.model in project cqf-ruler by DBCG.
the class DataRequirements method getModuleDefinitionLibraryDstu3.
public static org.hl7.fhir.dstu3.model.Library getModuleDefinitionLibraryDstu3(LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options) {
org.hl7.fhir.r5.model.Library libraryR5 = getModuleDefinitionLibraryR5(libraryManager, translatedLibrary, options);
BaseAdvisor_30_50 baseAdvisor_30_50 = new BaseAdvisor_30_50();
VersionConvertor_30_50 versionConvertor_30_50 = new VersionConvertor_30_50(baseAdvisor_30_50);
org.hl7.fhir.dstu3.model.Library libraryDstu3 = null;
libraryDstu3 = (org.hl7.fhir.dstu3.model.Library) versionConvertor_30_50.convertResource(libraryR5);
// There is no DSTU3 extension to support FHIRQueryPattern representation on a DataRequirement
return libraryDstu3;
}
use of org.hl7.fhir.r5.model in project cqf-ruler by DBCG.
the class JpaTerminologyProvider method expand.
@Override
public Iterable<Code> expand(ValueSetInfo valueSet) throws ResourceNotFoundException {
// This could possibly be refactored into a single call to the underlying HAPI
// Terminology service. Need to think through that..,
IBaseResource vs;
if (hasUrlId(valueSet)) {
if (hasVersion(valueSet) || hasVersionedCodeSystem(valueSet)) {
throw new UnsupportedOperationException(String.format("Could not expand value set %s; version and code system bindings are not supported at this time.", valueSet.getId()));
}
IBundleProvider bundleProvider = search(getClass("ValueSet"), Searches.byUrl(valueSet.getId()), myRequestDetails);
List<IBaseResource> valueSets = bundleProvider.getAllResources();
if (valueSets.isEmpty()) {
throw new IllegalArgumentException(String.format("Could not resolve value set %s.", valueSet.getId()));
} else if (valueSets.size() == 1) {
vs = valueSets.get(0);
} else {
throw new IllegalArgumentException("Found more than 1 ValueSet with url: " + valueSet.getId());
}
} else {
vs = read(Ids.newId(this.myTerminologySvc.getFhirContext(), "ValueSet", valueSet.getId()), myRequestDetails);
if (vs == null) {
throw new IllegalArgumentException(String.format("Could not resolve value set %s.", valueSet.getId()));
}
}
// relies heavily on reflection.
switch(vs.getStructureFhirVersionEnum()) {
case DSTU3:
return getCodes((org.hl7.fhir.dstu3.model.ValueSet) vs);
case R4:
return getCodes((org.hl7.fhir.r4.model.ValueSet) vs);
case R5:
return getCodes((org.hl7.fhir.r5.model.ValueSet) vs);
default:
throw new IllegalArgumentException(String.format("expand does not support FHIR version %s", vs.getStructureFhirVersionEnum().getFhirVersionString()));
}
}
use of org.hl7.fhir.r5.model in project quality-measure-and-cohort-service by Alvearie.
the class CQLToFHIRMeasureReportHelperTest method testRatio.
@Test
public void testRatio() {
String unit = "ml";
BigDecimal amount1 = new BigDecimal("4.0");
Quantity quantity1 = new Quantity().withUnit(unit).withValue(amount1);
BigDecimal amount2 = new BigDecimal("7.0");
Quantity quantity2 = new Quantity().withUnit(unit).withValue(amount2);
Ratio ratio = new Ratio().setNumerator(quantity1).setDenominator(quantity2);
IBaseDatatype fhirTypeValue = CQLToFHIRMeasureReportHelper.getFhirTypeValue(ratio);
assertTrue(fhirTypeValue instanceof org.hl7.fhir.r4.model.Ratio);
org.hl7.fhir.r4.model.Ratio castResult = (org.hl7.fhir.r4.model.Ratio) fhirTypeValue;
verifyBaseTypeAsQuantity(castResult.getNumerator(), amount1, unit);
verifyBaseTypeAsQuantity(castResult.getDenominator(), amount2, unit);
}
use of org.hl7.fhir.r5.model in project quality-measure-and-cohort-service by Alvearie.
the class MeasureHelperTest method testResolveByIdentifier_getLatestMeasure.
@Test
public void testResolveByIdentifier_getLatestMeasure() throws Exception {
String identifierSystem = "system1";
String identifierValue = "val1";
Measure measure1 = getCohortMeasure("Test", getLibrary("123", DEFAULT_VERSION, "cql/basic/Test-1.0.0.xml"), "Female");
Measure measure2 = getCohortMeasure("Test", getLibrary("123", DEFAULT_VERSION, "cql/basic/Test-1.0.0.xml"), "Female");
Measure measure3 = getCohortMeasure("Test", getLibrary("123", DEFAULT_VERSION, "cql/basic/Test-1.0.0.xml"), "Female");
measure1.setVersion("1.0.0");
measure2.setVersion("2.0.0");
org.hl7.fhir.r4.model.Identifier identifier = new IdentifierBuilder().buildValue(identifierValue).buildSystem(identifierSystem).build();
measure1.setIdentifier(Collections.singletonList(identifier));
measure2.setIdentifier(Collections.singletonList(identifier));
measure3.setIdentifier(Collections.singletonList(identifier));
MappingBuilder builder = get(urlPathEqualTo("/Measure")).withQueryParam("identifier", new EqualToPattern(identifierSystem + '|' + identifierValue)).withQueryParam("_format", new EqualToPattern("json"));
mockFhirResourceRetrieval(builder, getBundle(measure1, measure2, measure3));
Measure actual = MeasureHelper.loadMeasure(new Identifier(identifierSystem, identifierValue), null, resolver);
assertNotNull(actual);
assertEquals("Test", actual.getName());
assertEquals("2.0.0", actual.getVersion());
}
use of org.hl7.fhir.r5.model in project quality-measure-and-cohort-service by Alvearie.
the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testRange__shouldReturnIntervalParameterOfQuantityParameter.
@Test
public void testRange__shouldReturnIntervalParameterOfQuantityParameter() {
ParameterDefinition parameterDefinition = getBaseParameterDefinition("Range");
String lowString = "1.5";
String highString = "2.5";
BigDecimal lowValue = new BigDecimal(lowString);
BigDecimal highValue = new BigDecimal(highString);
String unit = "ml";
Range fhirValue = new Range().setLow(new org.hl7.fhir.r4.model.Quantity().setValue(lowValue).setUnit(unit)).setHigh(new org.hl7.fhir.r4.model.Quantity().setValue(highValue).setUnit(unit));
parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
IntervalParameter expectedParameter = new IntervalParameter(new QuantityParameter().setUnit(unit).setAmount(lowString), true, new QuantityParameter().setUnit(unit).setAmount(highString), true);
assertEquals(expectedParameter, R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
Aggregations