use of org.hl7.fhir.r4b.model.DateType 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.DateType in project quality-measure-and-cohort-service by Alvearie.
the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testDate__shouldReturnDate.
@Test
public void testDate__shouldReturnDate() {
ParameterDefinition parameterDefinition = getBaseParameterDefinition("date");
String dateString = "2020-01-01";
DateType fhirValue = new DateType(dateString);
parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
assertEquals(new DateParameter(dateString), R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
use of org.hl7.fhir.r4b.model.DateType in project openmrs-module-fhir2 by openmrs.
the class FhirImmunizationServiceImplTest method updateImmunization_shouldUpdateImmunizationAccordingly.
@Test
public void updateImmunization_shouldUpdateImmunizationAccordingly() {
// setup
FhirContext ctx = FhirContext.forR4();
IParser parser = ctx.newJsonParser();
Immunization updatedImmunization = parser.parseResource(Immunization.class, "{\n" + " \"resourceType\": \"Immunization\",\n" + " \"id\": \"9353776b-dead-4588-8723-d687197d8438\",\n" + " \"status\": \"completed\",\n" + " \"vaccineCode\": {\n" + " \"coding\": [\n" + " {\n" + " \"code\": \"d144d24f-6913-4b63-9660-a9108c2bebef\",\n" + " \"display\": \"STAVUDINE LAMIVUDINE AND NEVIRAPINE\"\n" + " }\n" + " ]\n" + " },\n" + " \"patient\": {\n" + " \"reference\": \"Patient/a7e04421-525f-442f-8138-05b619d16def\",\n" + " \"type\": \"Patient\"\n" + " },\n" + " \"encounter\": {\n" + " \"reference\": \"Encounter/7d8c1980-6b78-11e0-93c3-18a905e044dc\",\n" + " \"type\": \"Encounter\"\n" + " },\n" + " \"occurrenceDateTime\": \"2020-07-08T20:30:00+02:00\",\n" + " \"manufacturer\": {\n" + " \"display\": \"Pharma Inc.\"\n" + " },\n" + " \"lotNumber\": \"YU765YT-1\",\n" + " \"expirationDate\": \"2020-10-08\",\n" + " \"performer\": [\n" + " {\n" + " \"actor\": {\n" + " \"reference\": \"Practitioner/f9badd80-ab76-11e2-9e96-0800200c9a66\",\n" + " \"type\": \"Practitioner\"\n" + " }\n" + " }\n" + " ],\n" + " \"protocolApplied\": [\n" + " {\n" + " \"doseNumberPositiveInt\": 4\n" + " }\n" + " ]\n" + "}");
// replay
Immunization savedImmunization = service.update("9353776b-dead-4588-8723-d687197d8438", updatedImmunization);
Obs obs = obsService.getObsByUuid(savedImmunization.getId());
// verify
helper.validateImmunizationObsGroup(obs);
assertObsCommons(obs, "a7e04421-525f-442f-8138-05b619d16def", "7d8c1980-6b78-11e0-93c3-18a905e044dc", "f9badd80-ab76-11e2-9e96-0800200c9a66");
obs.getGroupMembers().forEach(o -> {
assertObsCommons(o, "a7e04421-525f-442f-8138-05b619d16def", "7d8c1980-6b78-11e0-93c3-18a905e044dc", "f9badd80-ab76-11e2-9e96-0800200c9a66");
});
Map<String, Obs> members = helper.getObsMembersMap(obs);
assertThat(members.get(CIEL_984).getValueCoded().getUuid(), is("d144d24f-6913-4b63-9660-a9108c2bebef"));
assertThat(members.get(CIEL_1410).getValueDatetime(), equalTo(new DateTimeType("2020-07-08T20:30:00+02:00").getValue()));
assertThat(members.get(CIEL_1418).getValueNumeric(), equalTo(4.0));
assertThat(members.get(CIEL_1419).getValueText(), is("Pharma Inc."));
assertThat(members.get(CIEL_1420).getValueText(), is("YU765YT-1"));
assertThat(members.get(CIEL_165907).getValueDate(), equalTo(new DateType("2020-10-08").getValue()));
}
use of org.hl7.fhir.r4b.model.DateType in project openmrs-module-fhir2 by openmrs.
the class PractitionerTranslatorUserImplTest method shouldTranslateToFhirBirthDate.
@Test
public void shouldTranslateToFhirBirthDate() {
User user = new User();
Calendar calendar = Calendar.getInstance();
DateType dateType = new DateType();
// when birthdate more than 5 year
calendar.set(2000, Calendar.AUGUST, 12);
Person person = new Person();
person.setBirthdateEstimated(true);
person.setBirthdate(calendar.getTime());
user.setPerson(person);
Practitioner result = practitionerTranslatorUser.toFhirResource(user);
assertThat(result, notNullValue());
assertThat(result.getBirthDateElement().getPrecision(), equalTo(TemporalPrecisionEnum.YEAR));
assertThat(result.getBirthDateElement().getYear(), equalTo(2000));
// when birthDate less then 5 year
Date date = new Date();
user.getPerson().setBirthdate(date);
dateType.setValue(date, TemporalPrecisionEnum.MONTH);
result = practitionerTranslatorUser.toFhirResource(user);
assertThat(result, notNullValue());
assertThat(result.getBirthDateElement().getPrecision(), equalTo(TemporalPrecisionEnum.MONTH));
assertThat(result.getBirthDateElement().getYear(), equalTo(dateType.getYear()));
assertThat(result.getBirthDateElement().getMonth(), equalTo(dateType.getMonth()));
}
use of org.hl7.fhir.r4b.model.DateType 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);
}
Aggregations