use of org.hl7.fhir.r4b.model.TimeType in project quality-measure-and-cohort-service by Alvearie.
the class CQLToFHIRMeasureReportHelperTest method testTime.
@Test
public void testTime() {
String timeString = "00:10:00.000";
Time expected = new Time(timeString);
IBaseDatatype fhirTypeValue = CQLToFHIRMeasureReportHelper.getFhirTypeValue(expected);
assertTrue(fhirTypeValue instanceof TimeType);
assertEquals(timeString, ((TimeType) fhirTypeValue).getValueAsString());
}
use of org.hl7.fhir.r4b.model.TimeType in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method measure_report_generated___FHIR_measure_parameters_on_measure_report.
@Test
public void measure_report_generated___FHIR_measure_parameters_on_measure_report() throws Exception {
CapabilityStatement metadata = getCapabilityStatement();
mockFhirResourceRetrieval("/metadata?_format=json", metadata);
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
Library library = mockLibraryRetrieval("TestDummyPopulations", DEFAULT_VERSION, "cql/fhir-measure/test-dummy-populations.xml", ELM_MIME_TYPE);
Measure measure = getCohortMeasure("CohortMeasureName", library, INITIAL_POPULATION);
Map<String, Type> measureParameters = new HashMap<>();
measureParameters.put("base64Param", new Base64BinaryType("AAA"));
measureParameters.put("booleanParam", new BooleanType(false));
measureParameters.put("dateParam", new DateType("2020-01-01"));
measureParameters.put("dateTimeParam", new DateTimeType("2020-01-01T12:00:00"));
measureParameters.put("decimalParam", new DecimalType(12.0));
measureParameters.put("instantParam", new InstantType("2020-01-01T12:00:00-04:00"));
measureParameters.put("integerParam", new IntegerType(1));
measureParameters.put("stringParam", new StringType("str"));
measureParameters.put("timeParam", new TimeType("05:30:00"));
measureParameters.put("uriParam", new UriType("abcde"));
measureParameters.put("codeableConceptParam", new CodeableConcept().setText("display").addCoding(new Coding().setCode("val").setSystem("sys").setDisplay("display")));
measureParameters.put("codingParam", new Coding().setCode("v").setSystem("s").setDisplay("d"));
measureParameters.put("periodParam", new Period().setStart(new Date(1)).setEnd(new Date(2)));
measureParameters.put("quantityParam", new Quantity().setValue(1).setUnit("g"));
measureParameters.put("rangeParam", new Range().setLow(new Quantity().setUnit("g").setValue(1)).setHigh(new Quantity().setUnit("g").setValue(5)));
measureParameters.put("ratioParam", new Ratio().setNumerator(new Quantity().setUnit("g").setValue(1)).setDenominator(new Quantity().setUnit("g").setValue(5)));
List<Extension> parameterExtensions = measureParameters.entrySet().stream().map(x -> createMeasureParameter(x.getKey(), x.getValue())).collect(Collectors.toList());
measure.setExtension(parameterExtensions);
mockFhirResourceRetrieval(measure);
MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), null);
assertNotNull(report);
List<String> parameterNames = report.getExtension().stream().filter(x -> x.getUrl().equals(MEASURE_PARAMETER_VALUE_URL)).map(x -> (ParameterDefinition) x.getValue()).map(ParameterDefinition::getName).collect(Collectors.toList());
// Expected parameters are the ones listed above, plus the special parameters
// measurement period and product line
assertEquals(measureParameters.size() + 2, parameterNames.size());
assertTrue(parameterNames.containsAll(measureParameters.keySet()));
assertTrue(parameterNames.contains(CDMConstants.MEASUREMENT_PERIOD));
assertTrue(parameterNames.contains(CDMConstants.PRODUCT_LINE));
}
use of org.hl7.fhir.r4b.model.TimeType in project quality-measure-and-cohort-service by Alvearie.
the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testTime__shouldReturnTimeParameter.
@Test
public void testTime__shouldReturnTimeParameter() {
ParameterDefinition parameterDefinition = getBaseParameterDefinition("time");
String timeString = "12:30:00";
TimeType fhirValue = new TimeType(timeString);
parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
assertEquals(new TimeParameter(timeString), R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
use of org.hl7.fhir.r4b.model.TimeType in project org.hl7.fhir.core by hapifhir.
the class FHIRPathEngine method processDateConstant.
private Base processDateConstant(Object appInfo, String value) throws PathEngineException {
if (value.startsWith("T"))
return new TimeType(value.substring(1));
String v = value;
if (v.length() > 10) {
int i = v.substring(10).indexOf("-");
if (i == -1)
i = v.substring(10).indexOf("+");
if (i == -1)
i = v.substring(10).indexOf("Z");
v = i == -1 ? value : v.substring(0, 10 + i);
}
if (v.length() > 10)
return new DateTimeType(value);
else
return new DateType(value);
}
use of org.hl7.fhir.r4b.model.TimeType in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeTime.
protected void composeTime(Complex parent, String parentType, String name, TimeType value, int index) {
if (value == null)
return;
Complex t = parent.predicate("fhir:" + parentType + "." + name);
t.predicate("fhir:value", ttlLiteral(value.asStringValue()));
composeElement(t, parentType, name, value, index);
}
Aggregations