Skip to content

NIAD-3070: Quantity encoding behaviour is wrong.#793

Merged
MartinWheelerMT merged 10 commits intomainfrom
niad-3070-quantity-encoding
Jul 25, 2024
Merged

NIAD-3070: Quantity encoding behaviour is wrong.#793
MartinWheelerMT merged 10 commits intomainfrom
niad-3070-quantity-encoding

Conversation

@MartinWheelerMT
Copy link
Copy Markdown
Collaborator

@MartinWheelerMT MartinWheelerMT commented Jul 16, 2024

What

ObservationQuantityValueMapper has been updated to produce the correct output as specified in the MIM.

If valueQuantity.value is missing then the element will not be mapped.

If the system value is invalid, it should be handled in the same way as below, but as if the system value was not set.

Valid system values are:

  • "http://unitsofmeasure.org"
  • An OID (i.e. "1.2.3.4.5")
  • An OID presented as a URN (i.e. "urn:oid:1.2.3.4.5")
  • A UUID (i.e. "35bce269-2660-45bd-855a-721807185995")

Otherwise the mapping mapping will now be as follows, mapping to interval if valueQuantity.comparator is present, or to a standard Quantity

Quantity (Physical Quantity: PQ)

Given a FHIR Quantity containing both a system and code where system is equal to “http://unitsofmeasure.org" then the value should be converted to XML as:

<value xsi:type="PQ" value="${quantity.value}" unit="${quantity.code}" />

Otherwise, given a FHIR Quantity containing a system, code and unit where the system is anything else then the value should be converted to XML as:

<value xsi:type="PQ" value="${quantity.value}" unit="1">
      <translation value="${quantity.value}" code="${quantity.code}" codeSystem="${quantity.system}" displayName="${quantity.unit}"/>
</value>

Otherwise, given a FHIR Quantity containing a system and code where the system is anything else then the value should be converted to XML as:

<value xsi:type="PQ" value="${quantity.value}" unit="1">
      <translation value="${quantity.value}" code="${quantity.code}" codeSystem="${quantity.system}" />
</value>

Otherwise, given a FHIR Quantity containing a unit then the value should be converted to XML as:

<value xsi:type="PQ" value="${quantity.value}" unit="1">
     <translation value="${quantity.value}">
          <originalText>${quantity.unit}</originalText>
     </translation>
</value>

Otherwise, given a FHIR Quantity containing just a value (no unit, no code, no system), then the value should be converted to XML as:

<value xsi:type="PQ" value="${quantity.value}" unit="1" />

Interval (Physical Quantity Interval (IVL_PQ)

Given a FHIR Quantity described as an interval, then the same rules as above apply, but with value element being named high or low according to the existing behaviour, wrapped in a value element.

Why

It was identified during testing that the mapping of Observation.valueQuantity was not producing the correct XML in certain circumstances.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the Changelog with details of my change in the UNRELEASED section if this change will affect end users

…ValueQuantityMapper

Update Tests for these changes.
Remove the source XML files no longer required
…essureMapperTest to ignore the whitespace changes in XML formatting for Quantities.

Update ObservationValueQuantityMapper to ensure correct mapping of interval physical quantities
Add Unit tests for uncertainty
Update unit tests to check for any system or none.
Update tests files for interval tests to reflect new mapping.
@MartinWheelerMT MartinWheelerMT force-pushed the niad-3070-quantity-encoding branch from 49c2a6a to 9d7aaba Compare July 18, 2024 14:49
…ot generate a quantity if the value is not present in the valueQuantity

Remove duplicate unit test
@MartinWheelerMT MartinWheelerMT force-pushed the niad-3070-quantity-encoding branch from ffa9c3c to 8d64c02 Compare July 22, 2024 14:05
@MartinWheelerMT MartinWheelerMT force-pushed the niad-3070-quantity-encoding branch from 6362b13 to aed5937 Compare July 23, 2024 09:45
Add tests to cover all permutations of ObservationValueQuantityMapper
Update ObservationValueQuantityMapper to properly handle system values
… `urn:uuid:`

Update existing tests to support this change
@MartinWheelerMT MartinWheelerMT marked this pull request as ready for review July 25, 2024 14:59
@MartinWheelerMT MartinWheelerMT enabled auto-merge (squash) July 25, 2024 15:00
@MartinWheelerMT MartinWheelerMT merged commit 7abfd32 into main Jul 25, 2024
@MartinWheelerMT MartinWheelerMT deleted the niad-3070-quantity-encoding branch July 25, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants