diff --git a/CHANGELOG.md b/CHANGELOG.md index 259dde4c06..eb091aff68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -* When mapping `ReferralRequest` supporting info and `DiagnosticReports`m NHS PMIP Report Numbers can also be provided +* When mapping `ReferralRequest` supporting info and `DiagnosticReports` NHS PMIP Report Numbers can also be provided with the code system as a URN (`urn:oid:2.16.840.1.113883.2.1.4.5.5`). +### Fixed +* When mapping physical quantities ("PQ") the produced XML now matches the HL7 XML specifications. + ## [2.0.5] - 2024-07-04 ### Fixed diff --git a/service/src/main/java/uk/nhs/adaptors/gp2gp/ehr/mapper/ObservationValueQuantityMapper.java b/service/src/main/java/uk/nhs/adaptors/gp2gp/ehr/mapper/ObservationValueQuantityMapper.java index a290c66a4c..2cb620e1db 100644 --- a/service/src/main/java/uk/nhs/adaptors/gp2gp/ehr/mapper/ObservationValueQuantityMapper.java +++ b/service/src/main/java/uk/nhs/adaptors/gp2gp/ehr/mapper/ObservationValueQuantityMapper.java @@ -1,113 +1,195 @@ package uk.nhs.adaptors.gp2gp.ehr.mapper; -import java.math.BigDecimal; - import org.apache.commons.lang3.StringUtils; import org.hl7.fhir.dstu3.model.BooleanType; import org.hl7.fhir.dstu3.model.Extension; import org.hl7.fhir.dstu3.model.Quantity; -public final class ObservationValueQuantityMapper { +import static org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_OR_EQUAL; +import static org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_OR_EQUAL; +import static org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_THAN; - private static final String UNITS_OF_MEASURE_SYSTEM = "http://unitsofmeasure.org"; - private static final String UNCERTAINTY_EXTENSION = "https://fhir.hl7.org.uk/STU3/StructureDefinition/Extension-CareConnect-ValueApproximation-1"; - private static final String IVL_PQ_ELEMENT = ""; - - private static final String NO_COMPARATOR_VALUE_TEMPLATE = ""; - private static final String LESS_COMPARATOR_VALUE_TEMPLATE = IVL_PQ_ELEMENT - + ""; - private static final String LESS_OR_EQUAL_COMPARATOR_VALUE_TEMPLATE = IVL_PQ_ELEMENT - + ""; - private static final String GREATER_COMPARATOR_VALUE_TEMPLATE = IVL_PQ_ELEMENT + ""; - private static final String GREATER_OR_EQUAL_COMPARATOR_VALUE_TEMPLATE = ""; - private static final String NO_COMPARATOR_NO_SYSTEM_VALUE_TEMPLATE = "" - + "%s"; - private static final String LESS_COMPARATOR_NO_SYSTEM_VALUE_TEMPLATE = IVL_PQ_ELEMENT - + "" - + "%s"; - private static final String LESS_OR_EQUAL_COMPARATOR_NO_SYSTEM_VALUE_TEMPLATE = "" - + "%s"; - private static final String GREATER_COMPARATOR_NO_SYSTEM_VALUE_TEMPLATE = IVL_PQ_ELEMENT - + "%s" - + ""; - private static final String GREATER_OR_EQUAL_COMPARATOR_NO_SYSTEM_VALUE_TEMPLATE = IVL_PQ_ELEMENT - + "" - + "%s"; - private static final String UNCERTAINTY_CODE = ""; - private static final String QUANTITY_UNIT = "%s"; +public final class ObservationValueQuantityMapper { + private static final String UNITS_OF_MEASURE_SYSTEM = + "http://unitsofmeasure.org"; + public static final String URN_OID_PREFIX = + "urn:oid:"; + public static final String URN_UUID_PREFIX = + "urn:uuid:"; + public static final String OID_REGEX = + "(urn:oid:)?[0-2](\\.[1-9]\\d*)+"; + public static final String UUID_REGEX = + "(urn:uuid:)?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"; + + private static final String UNCERTAINTY_EXTENSION = + "https://fhir.hl7.org.uk/STU3/StructureDefinition/Extension-CareConnect-ValueApproximation-1"; + private static final String UNCERTAINTY_CODE = """ + + """; private ObservationValueQuantityMapper() { } public static String processQuantity(Quantity valueQuantity) { - String result = StringUtils.EMPTY; - if (isUncertaintyCodePresent(valueQuantity)) { - result += UNCERTAINTY_CODE; - } - - if (!valueQuantity.hasComparator()) { - result += prepareQuantityValueWithoutComparator(valueQuantity); - } else { - result += prepareQuantityValueAccordingToComparator(valueQuantity); + if (!valueQuantity.hasValue()) { + return StringUtils.EMPTY; } - return result; - } + var stringBuilder = new StringBuilder(); - private static String prepareQuantityValueWithoutComparator(Quantity valueQuantity) { - BigDecimal value = valueQuantity.getValue(); - if (valueQuantity.hasSystem() && valueQuantity.getSystem().equals(UNITS_OF_MEASURE_SYSTEM)) { - return String.format(NO_COMPARATOR_VALUE_TEMPLATE, value, valueQuantity.getUnit()); - } else { - return String.format(NO_COMPARATOR_NO_SYSTEM_VALUE_TEMPLATE, value, value, prepareUnit(valueQuantity)); + if (isUncertaintyCodePresent(valueQuantity)) { + stringBuilder.append(UNCERTAINTY_CODE); } - } - private static String prepareUnit(Quantity valueQuantity) { - return valueQuantity.hasUnit() ? String.format(QUANTITY_UNIT, valueQuantity.getUnit()) : StringUtils.EMPTY; + var quantityXml = valueQuantity.hasComparator() + ? getPhysicalQuantityIntervalXml(valueQuantity) + : getPhysicalQuantityXml(valueQuantity); + + return stringBuilder + .append(quantityXml) + .toString(); } - private static String prepareQuantityValueAccordingToComparator(Quantity valueQuantity) { - if (valueQuantity.getComparator() == Quantity.QuantityComparator.LESS_THAN) { - return prepareQuantityValueByComparator(valueQuantity, - LESS_COMPARATOR_VALUE_TEMPLATE, - LESS_COMPARATOR_NO_SYSTEM_VALUE_TEMPLATE); - } else if (valueQuantity.getComparator() == Quantity.QuantityComparator.LESS_OR_EQUAL) { - return prepareQuantityValueByComparator(valueQuantity, - LESS_OR_EQUAL_COMPARATOR_VALUE_TEMPLATE, - LESS_OR_EQUAL_COMPARATOR_NO_SYSTEM_VALUE_TEMPLATE); - } else if (valueQuantity.getComparator() == Quantity.QuantityComparator.GREATER_THAN) { - return prepareQuantityValueByComparator(valueQuantity, - GREATER_COMPARATOR_VALUE_TEMPLATE, - GREATER_COMPARATOR_NO_SYSTEM_VALUE_TEMPLATE); - } else if (valueQuantity.getComparator() == Quantity.QuantityComparator.GREATER_OR_EQUAL) { - return prepareQuantityValueByComparator(valueQuantity, - GREATER_OR_EQUAL_COMPARATOR_VALUE_TEMPLATE, - GREATER_OR_EQUAL_COMPARATOR_NO_SYSTEM_VALUE_TEMPLATE); + private static String getPhysicalQuantityXml(Quantity valueQuantity) { + if (UNITS_OF_MEASURE_SYSTEM.equals(valueQuantity.getSystem()) && valueQuantity.hasCode()) { + return """ + """ + .formatted( + valueQuantity.getValue(), + valueQuantity.getCode() + ); + } + if (hasValidSystem(valueQuantity) && valueQuantity.hasCode() && valueQuantity.hasUnit()) { + return """ + %n\ + %n\ + """ + .formatted( + valueQuantity.getValue(), + valueQuantity.getValue(), + valueQuantity.getCode(), + getSystemWithoutPrefix(valueQuantity.getSystem()), + valueQuantity.getUnit() + ); + } + if (hasValidSystem(valueQuantity) && valueQuantity.hasCode()) { + return """ + %n\ + %n\ + """ + .formatted( + valueQuantity.getValue(), + valueQuantity.getValue(), + valueQuantity.getCode(), + getSystemWithoutPrefix(valueQuantity.getSystem()) + ); + } + if (valueQuantity.hasUnit()) { + return """ + %n\ + %n\ + %s%n\ + %n\ + """ + .formatted( + valueQuantity.getValue(), + valueQuantity.getValue(), + valueQuantity.getUnit() + ); } - return StringUtils.EMPTY; + return """ + """ + .formatted(valueQuantity.getValue()); } - private static String prepareQuantityValueByComparator(Quantity valueQuantity, String systemTemplate, String nonSystemTemplate) { - if (valueQuantity.hasSystem() && valueQuantity.getSystem().equals(UNITS_OF_MEASURE_SYSTEM)) { - return formatSystemTemplate(systemTemplate, valueQuantity.getValue(), valueQuantity.getCode()); + private static String getPhysicalQuantityIntervalXml(Quantity valueQuantity) { + if (UNITS_OF_MEASURE_SYSTEM.equals(valueQuantity.getSystem()) && valueQuantity.hasCode()) { + return """ + %n\ + <%s value="%s" unit="%s" inclusive="%s" />%n\ + """ + .formatted( + getHighOrLow(valueQuantity), + valueQuantity.getValue(), + valueQuantity.getCode(), + isInclusive(valueQuantity) + ); + } + if (hasValidSystem(valueQuantity) && valueQuantity.hasCode() && valueQuantity.hasUnit()) { + return """ + %n\ + <%s value="%s" unit="1" inclusive="%s">%n\ + %n\ + %n\ + """ + .formatted( + getHighOrLow(valueQuantity), + valueQuantity.getValue(), + isInclusive(valueQuantity), + valueQuantity.getValue(), + valueQuantity.getCode(), + getSystemWithoutPrefix(valueQuantity.getSystem()), + valueQuantity.getUnit(), + getHighOrLow(valueQuantity) + ); + } + if (hasValidSystem(valueQuantity) && valueQuantity.hasCode()) { + return """ + %n\ + <%s value="%s" unit="1" inclusive="%s">%n\ + %n\ + %n\ + """ + .formatted( + getHighOrLow(valueQuantity), + valueQuantity.getValue(), + isInclusive(valueQuantity), + valueQuantity.getValue(), + valueQuantity.getCode(), + getSystemWithoutPrefix(valueQuantity.getSystem()), + getHighOrLow(valueQuantity) + ); + } + if (valueQuantity.hasUnit()) { + return """ + %n\ + <%s value="%s" unit="1" inclusive="%s">%n\ + %n\ + %s%n\ + %n\ + %n\ + """ + .formatted( + getHighOrLow(valueQuantity), + valueQuantity.getValue(), + isInclusive(valueQuantity), + valueQuantity.getValue(), + valueQuantity.getUnit(), + getHighOrLow(valueQuantity) + ); } - return formatNoSystemTemplate(nonSystemTemplate, valueQuantity.getValue(), prepareUnit(valueQuantity)); + return """ + %n\ + <%s value="%s" unit="1" inclusive="%s" />%n\ + """ + .formatted( + getHighOrLow(valueQuantity), + valueQuantity.getValue(), + isInclusive(valueQuantity) + ); } - private static String formatSystemTemplate(String template, BigDecimal value, String code) { - return String.format(template, value, code); + private static boolean isInclusive(Quantity valueQuantity) { + return valueQuantity.getComparator() == GREATER_OR_EQUAL || valueQuantity.getComparator() == LESS_OR_EQUAL; } - private static String formatNoSystemTemplate(String template, BigDecimal value, String unit) { - return String.format(template, value, value, unit); + private static String getHighOrLow(Quantity valueQuantity) { + return valueQuantity.getComparator() == LESS_THAN || valueQuantity.getComparator() == LESS_OR_EQUAL + ? "high" + : "low"; } private static boolean isUncertaintyCodePresent(Quantity valueQuantity) { @@ -118,7 +200,6 @@ private static boolean isUncertaintyCodePresent(Quantity valueQuantity) { } } } - return false; } @@ -128,4 +209,23 @@ private static boolean isUncertaintyExtension(Extension extension) { && extension.getValue() instanceof BooleanType && ((BooleanType) extension.getValue()).booleanValue(); } + + private static boolean hasValidSystem(Quantity valueQuantity) { + return valueQuantity.hasSystem() && ( + valueQuantity.getSystem().equals(UNITS_OF_MEASURE_SYSTEM) + || valueQuantity.getSystem().matches(OID_REGEX) + || valueQuantity.getSystem().matches(UUID_REGEX) + ); + } + + private static String getSystemWithoutPrefix(String system) { + if (system.startsWith(URN_OID_PREFIX)) { + return StringUtils.removeStart(system, URN_OID_PREFIX); + } + if (system.startsWith(URN_UUID_PREFIX)) { + return StringUtils.removeStart(system, URN_UUID_PREFIX); + } + + return system; + } } diff --git a/service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/BloodPressureMapperTest.java b/service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/BloodPressureMapperTest.java index a145c87573..c8952312e3 100644 --- a/service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/BloodPressureMapperTest.java +++ b/service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/BloodPressureMapperTest.java @@ -109,7 +109,7 @@ public void When_MappingBloodPressureWithNestedTrue_Expect_CompoundStatementXmlR Observation observation = new FhirParseService().parseResource(jsonInput, Observation.class); var outputMessage = bloodPressureMapper.mapBloodPressure(observation, true); - assertThat(outputMessage).isEqualTo(expectedOutput); + assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput); } @ParameterizedTest @@ -126,7 +126,7 @@ public void When_MappingBloodPressure_Expect_CompoundStatementXmlReturned(String assertThat(outputMessage) .describedAs(TestArgumentsLoaderUtil.FAIL_MESSAGE, inputJson, outputXml) - .isEqualTo(expectedOutput); + .isEqualToIgnoringWhitespace(expectedOutput); } private static Stream testArguments() { @@ -160,7 +160,7 @@ messageContext, randomIdGeneratorService, new StructuredObservationValueMapper() Observation observation = new FhirParseService().parseResource(jsonInput, Observation.class); var outputMessage = bloodPressureMapper.mapBloodPressure(observation, true); - assertThat(outputMessage).isEqualTo(expectedOutput); + assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput); } @Test diff --git a/service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/ObservationStatementMapperTest.java b/service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/ObservationStatementMapperTest.java index 6f09d2a6e4..68a8de77f9 100644 --- a/service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/ObservationStatementMapperTest.java +++ b/service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/ObservationStatementMapperTest.java @@ -226,7 +226,7 @@ public void When_MappingObservationJson_Expect_ObservationStatementXmlOutput(Str Observation parsedObservation = new FhirParseService().parseResource(jsonInput, Observation.class); String outputMessage = observationStatementMapper.mapObservationToObservationStatement(parsedObservation, false); - assertThat(outputMessage).isEqualTo(expectedOutputMessage); + assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutputMessage); } @ParameterizedTest diff --git a/service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/ObservationValueQuantityMapperTest.java b/service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/ObservationValueQuantityMapperTest.java index 411102d3c9..2b4a524577 100644 --- a/service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/ObservationValueQuantityMapperTest.java +++ b/service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/ObservationValueQuantityMapperTest.java @@ -1,138 +1,534 @@ package uk.nhs.adaptors.gp2gp.ehr.mapper; -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; +import java.util.List; import java.util.stream.Stream; -import org.hl7.fhir.dstu3.model.Observation; +import org.hl7.fhir.dstu3.model.BooleanType; +import org.hl7.fhir.dstu3.model.Extension; +import org.hl7.fhir.dstu3.model.Quantity; +import org.hl7.fhir.dstu3.model.Quantity.QuantityComparator; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; + import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.NullAndEmptySource; +import org.junit.jupiter.params.provider.ValueSource; -import uk.nhs.adaptors.gp2gp.common.service.FhirParseService; -import uk.nhs.adaptors.gp2gp.utils.ResourceTestFileUtils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_OR_EQUAL; +import static org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.GREATER_THAN; +import static org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_OR_EQUAL; +import static org.hl7.fhir.dstu3.model.Quantity.QuantityComparator.LESS_THAN; public class ObservationValueQuantityMapperTest { - private static final String TEST_FILES_DIRECTORY = "/ehr/mapper/observation/quantity/"; - - private static final String INPUT_JSON_WITH_UNIT_OF_MEASURE_SYSTEM_NO_COMPARATOR = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-1.json"; - private static final String OUTPUT_XML_WITH_UNIT_OF_MEASURE_SYSTEM_NO_COMPARATOR = TEST_FILES_DIRECTORY - + "expected-output-quantity-1.xml"; - private static final String INPUT_JSON_WITH_UNIT_OF_MEASURE_SYSTEM_WITH_LESS_COMPARATOR = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-2.json"; - private static final String OUTPUT_XML_WITH_UNIT_OF_MEASURE_SYSTEM_WITH_LESS_COMPARATOR = TEST_FILES_DIRECTORY - + "expected-output-quantity-2.xml"; - private static final String INPUT_JSON_WITH_UNIT_OF_MEASURE_SYSTEM_WITH_EQUAL_LESS_COMPARATOR = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-3.json"; - private static final String OUTPUT_XML_WITH_UNIT_OF_MEASURE_SYSTEM_WITH_EQUAL_LESS_COMPARATOR = TEST_FILES_DIRECTORY - + "expected-output-quantity-3.xml"; - private static final String INPUT_JSON_WITH_UNIT_OF_MEASURE_SYSTEM_WITH_GREATER_COMPARATOR = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-4.json"; - private static final String OUTPUT_XML_WITH_UNIT_OF_MEASURE_SYSTEM_WITH_GREATER_COMPARATOR = TEST_FILES_DIRECTORY - + "expected-output-quantity-4.xml"; - private static final String INPUT_JSON_WITH_UNIT_OF_MEASURE_SYSTEM_WITH_GREATER_EQUAL_COMPARATOR = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-5.json"; - private static final String OUTPUT_XML_WITH_UNIT_OF_MEASURE_SYSTEM_WITH_GREATER_EQUAL_COMPARATOR = TEST_FILES_DIRECTORY - + "expected-output-quantity-5.xml"; - private static final String INPUT_JSON_WITH_NO_SYSTEM_AND_NO_COMPARATOR = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-6.json"; - private static final String OUTPUT_XML_WITH_NO_SYSTEM_AND_NO_COMPARATOR = TEST_FILES_DIRECTORY - + "expected-output-quantity-6.xml"; - private static final String INPUT_JSON_WITH_NO_SYSTEM_AND_LESS_COMPARATOR = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-7.json"; - private static final String OUTPUT_XML_WITH_NO_SYSTEM_AND_LESS_COMPARATOR = TEST_FILES_DIRECTORY - + "expected-output-quantity-7.xml"; - private static final String INPUT_JSON_WITH_NO_SYSTEM_AND_EQUAL_LESS_COMPARATOR = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-8.json"; - private static final String OUTPUT_XML_WITH_NO_SYSTEM_AND_EQUAL_LESS_COMPARATOR = TEST_FILES_DIRECTORY - + "expected-output-quantity-8.xml"; - private static final String INPUT_JSON_WITH_NO_SYSTEM_AND_GREATER_COMPARATOR = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-9.json"; - private static final String OUTPUT_XML_WITH_NO_SYSTEM_AND_GREATER_COMPARATOR = TEST_FILES_DIRECTORY - + "expected-output-quantity-9.xml"; - private static final String INPUT_JSON_WITH_NO_SYSTEM_AND_EQUAL_GREATER_COMPARATOR = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-10.json"; - private static final String OUTPUT_XML_WITH_NO_SYSTEM_AND_EQUAL_GREATER_COMPARATOR = TEST_FILES_DIRECTORY - + "expected-output-quantity-10.xml"; - private static final String INPUT_JSON_WITH_NO_UNIT = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-11.json"; - private static final String OUTPUT_XML_WITH_NO_UNIT = TEST_FILES_DIRECTORY - + "expected-output-quantity-11.xml"; - private static final String INPUT_JSON_WITH_COMPARATOR_AND_NO_UNIT = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-12.json"; - private static final String OUTPUT_XML_WITH_COMPARATOR_AND_NO_UNIT = TEST_FILES_DIRECTORY - + "expected-output-quantity-12.xml"; - private static final String INPUT_JSON_WITH_NO_SYSTEM_NO_UNIT_AND_LESS_COMPARATOR = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-13.json"; - private static final String OUTPUT_XML_WITH_NO_SYSTEM_NO_UNIT_AND_LESS_COMPARATOR = TEST_FILES_DIRECTORY - + "expected-output-quantity-13.xml"; - private static final String INPUT_JSON_WITH_NO_SYSTEM_NO_UNIT_AND_EQUAL_LESS_COMPARATOR = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-14.json"; - private static final String OUTPUT_XML_WITH_NO_SYSTEM_NO_UNIT_AND_EQUAL_LESS_COMPARATOR = TEST_FILES_DIRECTORY - + "expected-output-quantity-14.xml"; - private static final String INPUT_JSON_WITH_NO_SYSTEM_NO_UNIT_AND_GREATER_COMPARATOR = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-15.json"; - private static final String OUTPUT_XML_WITH_NO_SYSTEM_NO_UNIT_AND_GREATER_COMPARATOR = TEST_FILES_DIRECTORY - + "expected-output-quantity-15.xml"; - private static final String INPUT_JSON_WITH_NO_SYSTEM_NO_UNIT_AND_EQUAL_GREATER_COMPARATOR = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-16.json"; - private static final String OUTPUT_XML_WITH_NO_SYSTEM_NO_UNIT_AND_EQUAL_GREATER_COMPARATOR = TEST_FILES_DIRECTORY - + "expected-output-quantity-16.xml"; - private static final String INPUT_JSON_WITH_UNIT_OF_MEASURE_SYSTEM_NO_COMPARATOR_NO_CODE = TEST_FILES_DIRECTORY - + "example-observation-resource-with-quantity-17.json"; - private static final String OUTPUT_JSON_WITH_UNIT_OF_MEASURE_SYSTEM_NO_COMPARATOR_NO_CODE = TEST_FILES_DIRECTORY - + "expected-output-quantity-17.xml"; + + public static final Extension UNCERTAINTY_EXTENSION = new Extension( + "https://fhir.hl7.org.uk/STU3/StructureDefinition/Extension-CareConnect-ValueApproximation-1", + new BooleanType(true) + ); + + public static final double VALUE_37_1 = 37.1; + public static final String UOM_SYSTEM = "http://unitsofmeasure.org"; + public static final String CODE_CEL = "Cel"; + public static final String UNIT_C = "C"; + public static final String SYSTEM_OID = "1.2.3.4.5"; + public static final String SYSTEM_OID_WITH_PREFIX = "urn:oid:1.2.3.4.5"; + public static final String SYSTEM_UUID = "e1423232-5d4f-472f-8c55-271de1d6f98d"; + public static final String SYSTEM_UUID_WITH_PREFIX = "urn:uuid:e1423232-5d4f-472f-8c55-271de1d6f98d"; + public static final String INVALID_SYSTEM = "not-a-valid-system"; + + @Test + public void When_MappingQuantityWithUncertaintyExtension_Expect_XmlContainsUncertaintyCode() { + var quantity = (Quantity) new Quantity() + .setValue(VALUE_37_1) + .setExtension(List.of(UNCERTAINTY_EXTENSION)); + + var expectedXml = """ + + """; + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + @Test + public void When_MappingIntervalWithUncertaintyExtension_Expect_XmlContainsUncertaintyCode() { + var quantity = (Quantity) new Quantity() + .setValue(VALUE_37_1) + .setComparator(GREATER_THAN) + .setExtension(List.of(UNCERTAINTY_EXTENSION)); + + var expectedXml = """ + + + + """; + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + @Test + public void When_MappingQuantityWithNoValue_Expect_EmptyString() { + var quantity = (Quantity) new Quantity() + .setSystem(UOM_SYSTEM) + .setCode(CODE_CEL); + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEmpty(); + } + + @Test + public void When_MappingQuantityWithUOMSystemAndCode_Expect_PQWithValueAndUnitSet() { + var quantity = new Quantity() + .setSystem(UOM_SYSTEM) + .setValue(VALUE_37_1) + .setCode(CODE_CEL); + + var expectedXml = """ + """; + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + + @ParameterizedTest + @MethodSource("provideComparatorsParameters") + public void When_MappingIntervalWithUOMSystemAndCode_Expect_IVQPQWithValueAndUnitSet( + QuantityComparator comparator, + String label, + boolean inclusive + ) { + var quantity = (Quantity) new Quantity() + .setComparator(comparator) + .setSystem(UOM_SYSTEM) + .setValue(VALUE_37_1) + .setCode(CODE_CEL); + + var expectedXml = """ + %n\ + <%s value="37.1" unit="Cel" inclusive="%s" />%n\ + """ + .formatted(label, inclusive); + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + @Test + public void When_MappingQuantityWithUOMSystemAndUnit_Expect_PQWithValueAndTranslationWithOriginalTextSet() { + var quantity = new Quantity() + .setSystem(UOM_SYSTEM) + .setValue(VALUE_37_1) + .setUnit(UNIT_C); + + var expectedXml = """ + + + C + + """; + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + @ParameterizedTest + @MethodSource("provideComparatorsParameters") + public void When_MappingIntervalWithUOMSystemAndUnit_Expect_IVLPQWithWithValueAndTranslationWithOriginalTextSet( + QuantityComparator comparator, + String label, + boolean inclusive + ) { + var quantity = new Quantity() + .setComparator(comparator) + .setSystem(UOM_SYSTEM) + .setValue(VALUE_37_1) + .setUnit(UNIT_C); + + var expectedXml = """ + %n\ + <%s value="37.1" unit="1" inclusive="%s">%n\ + %n\ + C%n\ + %n\ + %n\ + """ + .formatted(label, inclusive, label); + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + @Test + public void When_MappingQuantityWithUOMSystemWithoutUnitOrCode_Expect_PQWithValueSetAndUnitSetToOne() { + var quantity = new Quantity() + .setSystem(UOM_SYSTEM) + .setValue(VALUE_37_1); + + var expectedXml = """ + """; + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + @ParameterizedTest + @MethodSource("provideComparatorsParameters") + public void When_MappingIntervalWithUOMSystemWithoutUnitOrCode_Expect_IVLPQWithValueSetAndUnitSetToOne( + QuantityComparator comparator, + String label, + boolean inclusive + ) { + var quantity = new Quantity() + .setComparator(comparator) + .setSystem(UOM_SYSTEM) + .setValue(VALUE_37_1); + + var expectedXml = """ + %n\ + <%s value="37.1" unit="1" inclusive="%s" />%n\ + """ + .formatted(label, inclusive); + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + @Test + public void When_MappingQuantityWithInvalidSystemAndWithCodeAndUnit_Expect_PQWithTranslationAndDisplayName() { + var quantity = new Quantity() + .setSystem(INVALID_SYSTEM) + .setValue(VALUE_37_1) + .setCode(CODE_CEL) + .setUnit(UNIT_C); + + var expectedXml = """ + + + C + + """; + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + @ParameterizedTest + @MethodSource("provideComparatorsParameters") + public void When_MappingIntervalWithInvalidSystemAndWithCodeAndUnit_Expect_IVLPQWithTranslationAndDisplayName( + QuantityComparator comparator, + String label, + boolean inclusive + ) { + var quantity = new Quantity() + .setComparator(comparator) + .setSystem(INVALID_SYSTEM) + .setValue(VALUE_37_1) + .setCode(CODE_CEL) + .setUnit(UNIT_C); + + var expectedXml = """ + %n\ + <%s value="37.1" unit="1" inclusive="%s">%n\ + %n\ + C%n\ + %n\ + %n\ + """ + .formatted(label, inclusive, label); + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + @ParameterizedTest + @CsvSource({ + SYSTEM_OID + "," + SYSTEM_OID, + SYSTEM_OID_WITH_PREFIX + "," + SYSTEM_OID, + SYSTEM_UUID + "," + SYSTEM_UUID, + SYSTEM_UUID_WITH_PREFIX + "," + SYSTEM_UUID + }) + public void When_MappingQuantityWithValidNonUOMSystemAndCodeAndUnit_Expect_PQWithTranslationAndDisplayName( + String system, + String expected + ) { + var quantity = new Quantity() + .setSystem(system) + .setValue(VALUE_37_1) + .setCode(CODE_CEL) + .setUnit(UNIT_C); + + var expectedXml = """ + %n\ + %n\ + """ + .formatted(expected); + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + + @ParameterizedTest + @CsvSource({ + SYSTEM_OID + "," + SYSTEM_OID, + SYSTEM_OID_WITH_PREFIX + "," + SYSTEM_OID, + SYSTEM_UUID + "," + SYSTEM_UUID, + SYSTEM_UUID_WITH_PREFIX + "," + SYSTEM_UUID + }) + public void When_MappingIntervalWithValidNonUOMSystemAndCodeAndUnit_Expect_IVLPQWithTranslationAndDisplayName( + String system, + String expected + ) { + var quantity = new Quantity() + .setComparator(LESS_THAN) + .setSystem(system) + .setValue(VALUE_37_1) + .setCode(CODE_CEL) + .setUnit(UNIT_C); + + var expectedXml = """ + %n\ + %n\ + %n\ + %n\ + """ + .formatted(expected); + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + @Test + public void When_MappingQuantityWithInvalidSystemAndCode_Expect_PQValueAndWithUnitSetToOne() { + var quantity = new Quantity() + .setSystem(INVALID_SYSTEM) + .setValue(VALUE_37_1) + .setCode(CODE_CEL); + + var expectedXml = """ + """; + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } @ParameterizedTest - @MethodSource("testFilePaths") - public void When_MappingParsedQuantityJson_Expect_CorrectXmlOutput(String input, String output) throws IOException { - String expectedOutputMessage = ResourceTestFileUtils.getFileContent(output); + @MethodSource("provideComparatorsParameters") + public void When_MappingIntervalWithInvalidSystemAndCode_Expect_IVLPQValueAndWithUnitSetToOne( + QuantityComparator comparator, + String label, + boolean inclusive + ) { + var quantity = new Quantity() + .setComparator(comparator) + .setSystem(INVALID_SYSTEM) + .setValue(VALUE_37_1) + .setCode(CODE_CEL); + + var expectedXml = """ + %n\ + <%s value="37.1" unit="1" inclusive="%s" />%n\ + """ + .formatted(label, inclusive); + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + + @ParameterizedTest + @CsvSource({ + SYSTEM_OID + "," + SYSTEM_OID, + SYSTEM_OID_WITH_PREFIX + "," + SYSTEM_OID, + SYSTEM_UUID + "," + SYSTEM_UUID, + SYSTEM_UUID_WITH_PREFIX + "," + SYSTEM_UUID + }) + public void When_MappingQuantityWithValidNonUOMSystemAndCode_Expect_PQXmlWithTranslation( + String system, + String expected + ) { + var quantity = new Quantity() + .setSystem(system) + .setValue(VALUE_37_1) + .setCode(CODE_CEL); + + var expectedXml = """ + %n\ + %n\ + """ + .formatted(expected); + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + @ParameterizedTest + @CsvSource({ + SYSTEM_OID + "," + SYSTEM_OID, + SYSTEM_OID_WITH_PREFIX + "," + SYSTEM_OID, + SYSTEM_UUID + "," + SYSTEM_UUID, + SYSTEM_UUID_WITH_PREFIX + "," + SYSTEM_UUID + }) + public void When_MappingIntervalWithValidNonUOMSystemAndCode_Expect_IVLPQWithTranslation( + String system, + String expected + ) { + var quantity = new Quantity() + .setComparator(GREATER_OR_EQUAL) + .setSystem(system) + .setValue(VALUE_37_1) + .setCode(CODE_CEL); + + var expectedXml = """ + %n\ + %n\ + %n\ + %n\ + """ + .formatted(expected); + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + @ParameterizedTest + @ValueSource(strings = { + UOM_SYSTEM, + SYSTEM_OID, + SYSTEM_OID_WITH_PREFIX, + SYSTEM_UUID, + SYSTEM_UUID_WITH_PREFIX, + INVALID_SYSTEM + }) + @NullAndEmptySource + public void When_MappingQuantityWithAnyOrInvalidOrNoSystemAndHasUnit_Expect_PQWithTranslationAndOriginalText( + String system + ) { + var quantity = new Quantity() + .setSystem(system) + .setValue(VALUE_37_1) + .setUnit(UNIT_C); + + var expectedXml = """ + + + C + + """; + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + @ParameterizedTest + @ValueSource(strings = { + UOM_SYSTEM, + SYSTEM_OID, + SYSTEM_OID_WITH_PREFIX, + SYSTEM_UUID, + INVALID_SYSTEM + }) + @NullAndEmptySource + public void When_MappingIntervalWithAnyOrInvalidOrNoSystemAndHasUnit_Expect_IVLPQWithTranslationAndOriginalText( + String system + ) { + var quantity = new Quantity() + .setComparator(LESS_OR_EQUAL) + .setSystem(system) + .setValue(VALUE_37_1) + .setUnit(UNIT_C); + + var expectedXml = """ + + + + C + + + """; + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + @ParameterizedTest + @ValueSource(strings = { + UOM_SYSTEM, + SYSTEM_OID, + SYSTEM_OID_WITH_PREFIX, + SYSTEM_UUID, + INVALID_SYSTEM + }) + @NullAndEmptySource + public void When_MappingQuantityWithAnyOrInvalidOrNoSystemWithoutUnitOrCode_Expect_PQWithValueSetAndUnitSetToOne( + String system + ) { + var quantity = new Quantity() + .setSystem(system) + .setValue(VALUE_37_1); + + var expectedXml = """ + """; + + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); + + assertThat(mappedQuantity).isEqualTo(expectedXml); + } + + @ParameterizedTest + @ValueSource(strings = { + UOM_SYSTEM, + SYSTEM_OID, + SYSTEM_OID_WITH_PREFIX, + SYSTEM_UUID, + INVALID_SYSTEM + }) + @NullAndEmptySource + public void When_MappingIntervalWithAnyOrInvalidOrNoSystemWithoutUnitOrCode_Expect_IVLPQWithValueSetAndUnitSetToOne( + String system + ) { + var quantity = new Quantity() + .setComparator(GREATER_THAN) + .setSystem(system) + .setValue(VALUE_37_1); + + var expectedXml = """ + + + """; - var jsonInput = ResourceTestFileUtils.getFileContent(input); - Observation observation = new FhirParseService().parseResource(jsonInput, Observation.class); + var mappedQuantity = ObservationValueQuantityMapper.processQuantity(quantity); - String outputMessage = ObservationValueQuantityMapper.processQuantity(observation.getValueQuantity()); - assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutputMessage); + assertThat(mappedQuantity).isEqualTo(expectedXml); } - private static Stream testFilePaths() { + private static Stream provideComparatorsParameters() { return Stream.of( - Arguments.of(INPUT_JSON_WITH_UNIT_OF_MEASURE_SYSTEM_NO_COMPARATOR, - OUTPUT_XML_WITH_UNIT_OF_MEASURE_SYSTEM_NO_COMPARATOR), - Arguments.of(INPUT_JSON_WITH_UNIT_OF_MEASURE_SYSTEM_WITH_LESS_COMPARATOR, - OUTPUT_XML_WITH_UNIT_OF_MEASURE_SYSTEM_WITH_LESS_COMPARATOR), - Arguments.of(INPUT_JSON_WITH_UNIT_OF_MEASURE_SYSTEM_WITH_EQUAL_LESS_COMPARATOR, - OUTPUT_XML_WITH_UNIT_OF_MEASURE_SYSTEM_WITH_EQUAL_LESS_COMPARATOR), - Arguments.of(INPUT_JSON_WITH_UNIT_OF_MEASURE_SYSTEM_WITH_GREATER_COMPARATOR, - OUTPUT_XML_WITH_UNIT_OF_MEASURE_SYSTEM_WITH_GREATER_COMPARATOR), - Arguments.of(INPUT_JSON_WITH_UNIT_OF_MEASURE_SYSTEM_WITH_GREATER_EQUAL_COMPARATOR, - OUTPUT_XML_WITH_UNIT_OF_MEASURE_SYSTEM_WITH_GREATER_EQUAL_COMPARATOR), - Arguments.of(INPUT_JSON_WITH_NO_SYSTEM_AND_NO_COMPARATOR, - OUTPUT_XML_WITH_NO_SYSTEM_AND_NO_COMPARATOR), - Arguments.of(INPUT_JSON_WITH_NO_SYSTEM_AND_LESS_COMPARATOR, - OUTPUT_XML_WITH_NO_SYSTEM_AND_LESS_COMPARATOR), - Arguments.of(INPUT_JSON_WITH_NO_SYSTEM_AND_EQUAL_LESS_COMPARATOR, - OUTPUT_XML_WITH_NO_SYSTEM_AND_EQUAL_LESS_COMPARATOR), - Arguments.of(INPUT_JSON_WITH_NO_SYSTEM_AND_GREATER_COMPARATOR, - OUTPUT_XML_WITH_NO_SYSTEM_AND_GREATER_COMPARATOR), - Arguments.of(INPUT_JSON_WITH_NO_SYSTEM_AND_EQUAL_GREATER_COMPARATOR, - OUTPUT_XML_WITH_NO_SYSTEM_AND_EQUAL_GREATER_COMPARATOR), - Arguments.of(INPUT_JSON_WITH_NO_UNIT, - OUTPUT_XML_WITH_NO_UNIT), - Arguments.of(INPUT_JSON_WITH_COMPARATOR_AND_NO_UNIT, - OUTPUT_XML_WITH_COMPARATOR_AND_NO_UNIT), - Arguments.of(INPUT_JSON_WITH_NO_SYSTEM_NO_UNIT_AND_LESS_COMPARATOR, - OUTPUT_XML_WITH_NO_SYSTEM_NO_UNIT_AND_LESS_COMPARATOR), - Arguments.of(INPUT_JSON_WITH_NO_SYSTEM_NO_UNIT_AND_EQUAL_LESS_COMPARATOR, - OUTPUT_XML_WITH_NO_SYSTEM_NO_UNIT_AND_EQUAL_LESS_COMPARATOR), - Arguments.of(INPUT_JSON_WITH_NO_SYSTEM_NO_UNIT_AND_GREATER_COMPARATOR, - OUTPUT_XML_WITH_NO_SYSTEM_NO_UNIT_AND_GREATER_COMPARATOR), - Arguments.of(INPUT_JSON_WITH_NO_SYSTEM_NO_UNIT_AND_EQUAL_GREATER_COMPARATOR, - OUTPUT_XML_WITH_NO_SYSTEM_NO_UNIT_AND_EQUAL_GREATER_COMPARATOR), - Arguments.of(INPUT_JSON_WITH_UNIT_OF_MEASURE_SYSTEM_NO_COMPARATOR_NO_CODE, - OUTPUT_JSON_WITH_UNIT_OF_MEASURE_SYSTEM_NO_COMPARATOR_NO_CODE) + Arguments.of(LESS_THAN, "high", false), + Arguments.of(LESS_OR_EQUAL, "high", true), + Arguments.of(GREATER_THAN, "low", false), + Arguments.of(GREATER_OR_EQUAL, "low", true) ); } } diff --git a/service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/diagnosticreport/ObservationMapperTest.java b/service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/diagnosticreport/ObservationMapperTest.java index fbda6ffd34..0bdccc38b9 100644 --- a/service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/diagnosticreport/ObservationMapperTest.java +++ b/service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/diagnosticreport/ObservationMapperTest.java @@ -171,7 +171,7 @@ public void When_MappingObservationJson_Expect_CompoundStatementXmlOutput(String observationAssociatedWithSpecimen ); - assertThat(compoundStatementXml).isEqualTo(expectedXmlOutput); + assertThat(compoundStatementXml).isEqualToIgnoringWhitespace(expectedXmlOutput); } @Test diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-1.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-1.json deleted file mode 100644 index b5b19d8d54..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-1.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "resourceType":"Observation", - "id":"Consultation3-Topic2-Category-Examination-Observation-1", - "effectiveDateTime":"2019-06-01T10:30:00+00:00", - "issued":"2019-06-01T10:30:00+00:00", - "valueQuantity":{ - "value":37.1, - "unit":"C", - "system":"http://unitsofmeasure.org", - "code":"Cel" - } -} \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-10.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-10.json deleted file mode 100644 index 689064e0f4..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-10.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "resourceType":"Observation", - "id":"Consultation3-Topic2-Category-Examination-Observation-1", - "effectiveDateTime":"2019-06-01T10:30:00+00:00", - "issued":"2019-06-01T10:30:00+00:00", - "valueQuantity":{ - "value":37.1, - "unit":"C", - "code":"Cel", - "comparator":">=" - } -} \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-11.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-11.json deleted file mode 100644 index f6815402cc..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-11.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "resourceType":"Observation", - "id":"Consultation3-Topic2-Category-Examination-Observation-1", - "effectiveDateTime":"2019-06-01T10:30:00+00:00", - "issued":"2019-06-01T10:30:00+00:00", - "valueQuantity":{ - "value": 3.000 - } -} \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-12.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-12.json deleted file mode 100644 index 5da9310ecd..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-12.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "resourceType":"Observation", - "id":"Consultation3-Topic2-Category-Examination-Observation-1", - "effectiveDateTime":"2019-06-01T10:30:00+00:00", - "issued":"2019-06-01T10:30:00+00:00", - "valueQuantity":{ - "value": 3.000, - "comparator":"<" - } -} \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-13.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-13.json deleted file mode 100644 index e256a74498..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-13.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "resourceType":"Observation", - "id":"Consultation3-Topic2-Category-Examination-Observation-1", - "effectiveDateTime":"2019-06-01T10:30:00+00:00", - "issued":"2019-06-01T10:30:00+00:00", - "valueQuantity":{ - "value":37.1, - "code":"Cel", - "comparator":"<" - } -} \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-14.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-14.json deleted file mode 100644 index 1f6e39410d..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-14.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "resourceType":"Observation", - "id":"Consultation3-Topic2-Category-Examination-Observation-1", - "effectiveDateTime":"2019-06-01T10:30:00+00:00", - "issued":"2019-06-01T10:30:00+00:00", - "valueQuantity":{ - "value":37.1, - "code":"Cel", - "comparator":"<=" - } -} \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-15.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-15.json deleted file mode 100644 index 7d217b2a52..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-15.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "resourceType":"Observation", - "id":"Consultation3-Topic2-Category-Examination-Observation-1", - "effectiveDateTime":"2019-06-01T10:30:00+00:00", - "issued":"2019-06-01T10:30:00+00:00", - "valueQuantity":{ - "value":37.1, - "code":"Cel", - "comparator":">" - } -} \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-16.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-16.json deleted file mode 100644 index 3e0b0d586d..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-16.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "resourceType":"Observation", - "id":"Consultation3-Topic2-Category-Examination-Observation-1", - "effectiveDateTime":"2019-06-01T10:30:00+00:00", - "issued":"2019-06-01T10:30:00+00:00", - "valueQuantity":{ - "value":37.1, - "code":"Cel", - "comparator":">=" - } -} \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-17.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-17.json deleted file mode 100644 index c2f2d8f967..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-17.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "resourceType": "Observation", - "id": "491ef27b-28d9-11eb-adc1-f07859c314bd", - "meta": { - "profile": [ - "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Observation-1" - ] - }, - "identifier": [ - { - "system": "https://medicus.health", - "value": "491ef27b-28d9-11eb-adc1-f07859c314bd" - } - ], - "status": "final", - "code": { - "coding": [ - { - "system": "http://snomed.info/sct", - "code": "248333004", - "display": "Standing height", - "extension": [ - { - "url": "https://fhir.hl7.org.uk/STU3/StructureDefinition/Extension-coding-sctdescid", - "extension": [ - { - "url": "descriptionId", - "valueId": "370729019" - } - ] - } - ] - } - ] - }, - "subject": { - "reference": "Patient/00d756ae-360d-11ed-95ee-060b232f1aa2" - }, - "effectiveDateTime": "2022-06-30T10:20:00+01:00", - "issued": "2022-09-16T23:29:31+01:00", - "valueQuantity": { - "value": 186, - "unit": "cm", - "system": "http://unitsofmeasure.org" - } -} diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-2.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-2.json deleted file mode 100644 index a5cc76b766..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-2.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "resourceType":"Observation", - "id":"Consultation3-Topic2-Category-Examination-Observation-1", - "effectiveDateTime":"2019-06-01T10:30:00+00:00", - "issued":"2019-06-01T10:30:00+00:00", - "valueQuantity":{ - "value":37.1, - "unit":"C", - "system":"http://unitsofmeasure.org", - "code":"Cel", - "comparator":"<" - } -} \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-3.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-3.json deleted file mode 100644 index 9b56e3345f..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-3.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "resourceType":"Observation", - "id":"Consultation3-Topic2-Category-Examination-Observation-1", - "effectiveDateTime":"2019-06-01T10:30:00+00:00", - "issued":"2019-06-01T10:30:00+00:00", - "valueQuantity":{ - "value":37.1, - "unit":"C", - "system":"http://unitsofmeasure.org", - "code":"Cel", - "comparator":"<=" - } -} \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-4.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-4.json deleted file mode 100644 index 8a7a070cd0..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-4.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "resourceType":"Observation", - "id":"Consultation3-Topic2-Category-Examination-Observation-1", - "effectiveDateTime":"2019-06-01T10:30:00+00:00", - "issued":"2019-06-01T10:30:00+00:00", - "valueQuantity":{ - "value":37.1, - "unit":"C", - "system":"http://unitsofmeasure.org", - "code":"Cel", - "comparator":">" - } -} \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-5.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-5.json deleted file mode 100644 index 96b06bee25..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-5.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "resourceType":"Observation", - "id":"Consultation3-Topic2-Category-Examination-Observation-1", - "effectiveDateTime":"2019-06-01T10:30:00+00:00", - "issued":"2019-06-01T10:30:00+00:00", - "valueQuantity":{ - "value":37.1, - "unit":"C", - "system":"http://unitsofmeasure.org", - "code":"Cel", - "comparator":">=" - } -} \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-6.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-6.json deleted file mode 100644 index 6a899d4d3f..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-6.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "resourceType":"Observation", - "id":"Consultation3-Topic2-Category-Examination-Observation-1", - "effectiveDateTime":"2019-06-01T10:30:00+00:00", - "issued":"2019-06-01T10:30:00+00:00", - "valueQuantity":{ - "value":37.1, - "unit":"C", - "code":"Cel" - } -} \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-7.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-7.json deleted file mode 100644 index eb0e1a27a9..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-7.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "resourceType":"Observation", - "id":"Consultation3-Topic2-Category-Examination-Observation-1", - "effectiveDateTime":"2019-06-01T10:30:00+00:00", - "issued":"2019-06-01T10:30:00+00:00", - "valueQuantity":{ - "value":37.1, - "unit":"C", - "code":"Cel", - "comparator":"<" - } -} \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-8.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-8.json deleted file mode 100644 index ba94b57a23..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-8.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "resourceType":"Observation", - "id":"Consultation3-Topic2-Category-Examination-Observation-1", - "effectiveDateTime":"2019-06-01T10:30:00+00:00", - "issued":"2019-06-01T10:30:00+00:00", - "valueQuantity":{ - "value":37.1, - "unit":"C", - "code":"Cel", - "comparator":"<=" - } -} \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-9.json b/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-9.json deleted file mode 100644 index 600229aaf4..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/example-observation-resource-with-quantity-9.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "resourceType":"Observation", - "id":"Consultation3-Topic2-Category-Examination-Observation-1", - "effectiveDateTime":"2019-06-01T10:30:00+00:00", - "issued":"2019-06-01T10:30:00+00:00", - "valueQuantity":{ - "value":37.1, - "unit":"C", - "code":"Cel", - "comparator":">" - } -} \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-1.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-1.xml deleted file mode 100644 index 2ebea89c87..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-1.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-10.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-10.xml deleted file mode 100644 index 64ba029d1e..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-10.xml +++ /dev/null @@ -1 +0,0 @@ -C \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-11.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-11.xml deleted file mode 100644 index 8bb1ae309f..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-11.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-12.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-12.xml deleted file mode 100644 index dd80d3136d..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-12.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-13.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-13.xml deleted file mode 100644 index 7831eca2e4..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-13.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-14.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-14.xml deleted file mode 100644 index 395eaa6bd2..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-14.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-15.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-15.xml deleted file mode 100644 index af85e751a3..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-15.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-16.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-16.xml deleted file mode 100644 index 59c554c1fd..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-16.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-17.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-17.xml deleted file mode 100644 index 2646b8c194..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-17.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-2.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-2.xml deleted file mode 100644 index f7f62f6a69..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-2.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-3.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-3.xml deleted file mode 100644 index 0e08488e28..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-3.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-4.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-4.xml deleted file mode 100644 index 68c7f18185..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-4.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-5.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-5.xml deleted file mode 100644 index 383ccdbf48..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-5.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-6.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-6.xml deleted file mode 100644 index fa6b891862..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-6.xml +++ /dev/null @@ -1 +0,0 @@ -C \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-7.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-7.xml deleted file mode 100644 index 83e5d6e3a8..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-7.xml +++ /dev/null @@ -1 +0,0 @@ -C \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-8.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-8.xml deleted file mode 100644 index cf94462b52..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-8.xml +++ /dev/null @@ -1 +0,0 @@ -C \ No newline at end of file diff --git a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-9.xml b/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-9.xml deleted file mode 100644 index 228616924c..0000000000 --- a/service/src/test/resources/ehr/mapper/observation/quantity/expected-output-quantity-9.xml +++ /dev/null @@ -1 +0,0 @@ -C \ No newline at end of file