Issue 383 (#384)

* added null hasWhen check for all version conversions

* updated release notes

* error message updated for clarity
This commit is contained in:
Mark Iantorno 2020-11-24 15:08:44 -05:00 committed by GitHub
parent 7adfefa635
commit bdf3e025d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 40 additions and 29 deletions

View File

@ -0,0 +1 @@
* fix for issue 383

View File

@ -1678,7 +1678,7 @@ public class VersionConvertor_10_30 {
if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement()));
if (src.hasPeriodMaxElement()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement()));
if (src.hasPeriodUnits()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitsElement()));
tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement())));
if (src.hasWhen()) tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement())));
return tgt;
}

View File

@ -1779,9 +1779,7 @@ public class VersionConvertor_10_40 {
if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement()));
if (src.hasPeriodMaxElement()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement()));
if (src.hasPeriodUnits()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitsElement()));
if (src.hasWhen()) {
tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement())));
}
if (src.hasWhen()) tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement())));
return tgt;
}
@ -1799,9 +1797,7 @@ public class VersionConvertor_10_40 {
if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement()));
if (src.hasPeriodMaxElement()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement()));
if (src.hasPeriodUnit()) tgt.setPeriodUnitsElement(convertUnitsOfTime(src.getPeriodUnitElement()));
if (src.hasWhen()) {
tgt.setWhenElement(convertEventTiming(src.getWhen().get(0)));
}
if (src.hasWhen()) tgt.setWhenElement(convertEventTiming(src.getWhen().get(0)));
return tgt;
}

View File

@ -1796,7 +1796,7 @@ public class VersionConvertor_10_50 {
if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement()));
if (src.hasPeriodMaxElement()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement()));
if (src.hasPeriodUnits()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitsElement()));
tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement())));
if (src.hasWhen()) tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement())));
return tgt;
}
@ -1814,9 +1814,7 @@ public class VersionConvertor_10_50 {
if (src.hasPeriodElement()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement()));
if (src.hasPeriodMaxElement()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement()));
if (src.hasPeriodUnit()) tgt.setPeriodUnitsElement(convertUnitsOfTime(src.getPeriodUnitElement()));
if (src.hasWhen()) {
tgt.setWhenElement(convertEventTiming(src.getWhen().get(0)));
}
if (src.hasWhen()) tgt.setWhenElement(convertEventTiming(src.getWhen().get(0)));
return tgt;
}

View File

@ -1889,9 +1889,7 @@ public class VersionConvertor_14_30 {
if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement()));
if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement()));
if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement()));
if (src.hasWhen()) {
tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement())));
}
if (src.hasWhen()) tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement())));
if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement()));
return tgt;
}
@ -1911,9 +1909,7 @@ public class VersionConvertor_14_30 {
if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement()));
if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement()));
if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement()));
if (src.hasWhen()) {
tgt.setWhenElement(convertEventTiming(src.getWhen().get(0)));
}
if (src.hasWhen()) tgt.setWhenElement(convertEventTiming(src.getWhen().get(0)));
if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement()));
return tgt;
}

View File

@ -2002,9 +2002,7 @@ public class VersionConvertor_14_40 {
if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement()));
if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement()));
if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement()));
if (src.hasWhen()) {
tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement())));
}
if (src.hasWhen()) tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement())));
if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement()));
return tgt;
}
@ -2024,9 +2022,7 @@ public class VersionConvertor_14_40 {
if (src.hasPeriod()) tgt.setPeriodElement(convertDecimal(src.getPeriodElement()));
if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement()));
if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement()));
if (src.hasWhen()) {
tgt.setWhenElement(convertEventTiming(src.getWhen().get(0)));
}
if (src.hasWhen()) tgt.setWhenElement(convertEventTiming(src.getWhen().get(0)));
if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement()));
return tgt;
}

View File

@ -2425,7 +2425,7 @@ public class VersionConvertor_30_40 {
if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement()));
tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_30_40::convertDayOfWeek).collect(Collectors.toList()));
for (org.hl7.fhir.dstu3.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue());
tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_40::convertEventTiming).collect(Collectors.toList()));
if (src.hasWhen()) tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_40::convertEventTiming).collect(Collectors.toList()));
if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement()));
return tgt;
}
@ -2447,7 +2447,7 @@ public class VersionConvertor_30_40 {
if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement()));
tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_30_40::convertDayOfWeek).collect(Collectors.toList()));
for (org.hl7.fhir.r4.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue());
tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_40::convertEventTiming).collect(Collectors.toList()));
if (src.hasWhen()) tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_40::convertEventTiming).collect(Collectors.toList()));
if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement()));
return tgt;
}

View File

@ -2481,7 +2481,7 @@ public class VersionConvertor_30_50 {
if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement()));
if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement()));
tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_30_50::convertDayOfWeek).collect(Collectors.toList()));
tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_50::convertEventTiming).collect(Collectors.toList()));
if (src.hasWhen()) tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_50::convertEventTiming).collect(Collectors.toList()));
for (org.hl7.fhir.dstu3.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue());
if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement()));
return tgt;
@ -2503,7 +2503,7 @@ public class VersionConvertor_30_50 {
if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement()));
if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement()));
tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_30_50::convertDayOfWeek).collect(Collectors.toList()));
tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_50::convertEventTiming).collect(Collectors.toList()));
if (src.hasWhen()) tgt.setWhen(src.getWhen().stream().map(VersionConvertor_30_50::convertEventTiming).collect(Collectors.toList()));
for (org.hl7.fhir.r5.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue());
if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement()));
return tgt;

View File

@ -2053,7 +2053,7 @@ public class VersionConvertor_40_50 {
if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement()));
if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement()));
tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_40_50::convertDayOfWeek).collect(Collectors.toList()));
tgt.setWhen(src.getWhen().stream().map(VersionConvertor_40_50::convertEventTiming).collect(Collectors.toList()));
if (src.hasWhen()) tgt.setWhen(src.getWhen().stream().map(VersionConvertor_40_50::convertEventTiming).collect(Collectors.toList()));
for (org.hl7.fhir.r4.model.TimeType t : src.getTimeOfDay()) tgt.getTimeOfDay().add(convertTime(t));
if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement()));
return tgt;
@ -2075,7 +2075,7 @@ public class VersionConvertor_40_50 {
if (src.hasPeriodMax()) tgt.setPeriodMaxElement(convertDecimal(src.getPeriodMaxElement()));
if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement()));
tgt.setDayOfWeek(src.getDayOfWeek().stream().map(VersionConvertor_40_50::convertDayOfWeek).collect(Collectors.toList()));
tgt.setWhen(src.getWhen().stream().map(VersionConvertor_40_50::convertEventTiming).collect(Collectors.toList()));
if (src.hasWhen()) tgt.setWhen(src.getWhen().stream().map(VersionConvertor_40_50::convertEventTiming).collect(Collectors.toList()));
for (org.hl7.fhir.r5.model.TimeType t : src.getTimeOfDay()) tgt.getTimeOfDay().add(convertTime(t));
if (src.hasOffset()) tgt.setOffsetElement(convertUnsignedInt(src.getOffsetElement()));
return tgt;

View File

@ -0,0 +1,24 @@
package org.hl7.fhir.convertors.conv10_30;
import org.hl7.fhir.convertors.VersionConvertor_10_30;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class TimingRepeatComponent10_30Test {
@Test
@DisplayName("Issue #383 - Test 10_30 TimingRepeatComponent with Timing.when as null")
public void testMedicationRequestConversion() {
final int SET_COUNT = 11;
org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent src = new org.hl7.fhir.dstu2.model.Timing.TimingRepeatComponent();
src.setCount(SET_COUNT);
org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent tgt = VersionConvertor_10_30.convertTimingRepeatComponent(src);
Assertions.assertEquals(SET_COUNT, tgt.getCount(), "Count field not preserved through version conversion.");
Assertions.assertFalse(tgt.hasWhen(), "hasWhen() should return false for this conversion.");
Assertions.assertTrue(tgt.getWhen().isEmpty(), "When no _when time_ is provided, getWhen() should return an empty list.");
}
}