Search in sources :

Example 1 with DvProportion

use of com.nedap.archie.rm.datavalues.quantity.DvProportion in project openEHR_SDK by ehrbase.

the class StatusesTestOverwrite method proportion.

@Override
@Test
public void proportion() throws Exception {
    String template = this.getFileContent("/res/test_statuses.opt");
    Map<String, Object> flatComposition = Map.of("ctx/language", "sl", "ctx/territory", "SI", "ctx/composer_name", "George Orwell", "test_statuses/test_statuses:0/proportion|numerator", 17, "test_statuses/test_statuses:0/proportion|denominator", 33, "test_statuses/test_statuses:0/proportion|normal_status", "L", "test_statuses/test_statuses:0/proportion|magnitude_status", ">=", "test_statuses/test_statuses:0/proportion|accuracy", 10.0, "test_statuses/test_statuses:0/proportion|accuracy_is_percent", true);
    RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
    Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
    DvProportion rmObject = (DvProportion) composition.itemAtPath("/content[openEHR-EHR-OBSERVATION.test_statuses.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0015]/value");
    assertThat(rmObject.getNormalStatus()).isNotNull();
    assertThat(rmObject.getNormalStatus().getTerminologyId().getValue()).isEqualTo("openehr_normal_statuses");
    assertThat(rmObject.getNormalStatus().getCodeString()).isEqualTo("L");
    assertThat(rmObject.getMagnitudeStatus()).isEqualTo(">=");
    assertThat(rmObject.getAccuracy()).isEqualTo(10);
    assertThat(rmObject.getAccuracyIsPercent()).isTrue();
    Map<String, Object> value = OBJECT_MAPPER.readValue(flatJson.marshal(composition), Map.class);
    assertThat(value).containsEntry("test_statuses/test_statuses:0/proportion|normal_status", "L").containsEntry("test_statuses/test_statuses:0/proportion|magnitude_status", ">=").containsEntry("test_statuses/test_statuses:0/proportion|accuracy", 10.0).containsEntry("test_statuses/test_statuses:0/proportion|accuracy_is_percent", true);
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) DvProportion(com.nedap.archie.rm.datavalues.quantity.DvProportion) Test(org.junit.Test) StatusesTest(care.better.platform.web.template.StatusesTest)

Example 2 with DvProportion

use of com.nedap.archie.rm.datavalues.quantity.DvProportion in project openEHR_SDK by ehrbase.

the class DvProportionValidatorTest method testValidate_Range.

@Test
void testValidate_Range() throws Exception {
    var node = parseNode("/webtemplate_nodes/dv_proportion_range.json");
    var result = validator.validate(new DvProportion(50.0, 100.0, 3L), node);
    assertTrue(result.isEmpty());
    result = validator.validate(new DvProportion(200.0, 100.0, 3L), node);
    assertEquals(1, result.size());
    result = validator.validate(new DvProportion(50.0, 120.0, 3L), node);
    assertEquals(1, result.size());
}
Also used : DvProportion(com.nedap.archie.rm.datavalues.quantity.DvProportion) Test(org.junit.jupiter.api.Test)

Example 3 with DvProportion

use of com.nedap.archie.rm.datavalues.quantity.DvProportion in project fhir-bridge by ehrbase.

the class BeobachtungenAmBeatmungsgeraetObservationConverter method mapNumerator.

private Optional<DvProportion> mapNumerator(Observation resource) {
    if (resource.hasValueQuantity()) {
        DvProportion inspiratorischeSauerstofffraktion = new DvProportion();
        inspiratorischeSauerstofffraktion.setNumerator(resource.getValueQuantity().getValue().doubleValue());
        inspiratorischeSauerstofffraktion.setDenominator(100.0);
        // 2=percent (https://specifications.openehr.org/releases/RM/latest/data_types.html#_proportion_kind_class)
        inspiratorischeSauerstofffraktion.setType((long) 2);
        return Optional.of(inspiratorischeSauerstofffraktion);
    }
    return Optional.empty();
}
Also used : DvProportion(com.nedap.archie.rm.datavalues.quantity.DvProportion)

Example 4 with DvProportion

use of com.nedap.archie.rm.datavalues.quantity.DvProportion in project openEHR_SDK by ehrbase.

the class DvProportionValidatorTest method testValidate.

@Test
void testValidate() throws Exception {
    var node = parseNode("/webtemplate_nodes/dv_proportion.json");
    var result = validator.validate(new DvProportion(50.0, 100.0, 3L), node);
    assertTrue(result.isEmpty());
}
Also used : DvProportion(com.nedap.archie.rm.datavalues.quantity.DvProportion) Test(org.junit.jupiter.api.Test)

Aggregations

DvProportion (com.nedap.archie.rm.datavalues.quantity.DvProportion)4 Test (org.junit.jupiter.api.Test)2 StatusesTest (care.better.platform.web.template.StatusesTest)1 Composition (com.nedap.archie.rm.composition.Composition)1 RMDataFormat (org.ehrbase.serialisation.RMDataFormat)1 Test (org.junit.Test)1