#1723 fix R3 Quantity.copyValues()
This commit is contained in:
parent
f3bd5b9be8
commit
69525144f3
|
@ -1,6 +1,7 @@
|
|||
package org.hl7.fhir.dstu3.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
|
@ -668,12 +669,16 @@ public class Quantity extends Type implements ICompositeType {
|
|||
public Quantity copy() {
|
||||
Quantity dst = new Quantity();
|
||||
copyValues(dst);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public void copyValues(Quantity dst) {
|
||||
super.copyValues(dst);
|
||||
dst.value = value == null ? null : value.copy();
|
||||
dst.comparator = comparator == null ? null : comparator.copy();
|
||||
dst.unit = unit == null ? null : unit.copy();
|
||||
dst.system = system == null ? null : system.copy();
|
||||
dst.code = code == null ? null : code.copy();
|
||||
return dst;
|
||||
}
|
||||
|
||||
protected Quantity typedCopy() {
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package org.hl7.fhir.dstu3.model;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.hl7.fhir.dstu3.formats.JsonParser;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MedicationAdministrationCopyTest {
|
||||
|
||||
@DisplayName("Test MedicationAdministration copy")
|
||||
@Test
|
||||
public void test() throws IOException {
|
||||
MedicationAdministration beforeCopy = createMedAdminWithDosageDurationExtension();
|
||||
MedicationAdministration afterCopy = beforeCopy.copy();
|
||||
|
||||
System.out.println("---- BEFORE COPY (BEGIN)");
|
||||
System.out.println(new JsonParser().composeString(beforeCopy));
|
||||
System.out.println("---- BEFORE COPY (END)");
|
||||
System.out.println();
|
||||
System.out.println("---- AFTER COPY (BEGIN)");
|
||||
System.out.println(new JsonParser().composeString(afterCopy));
|
||||
System.out.println("---- AFTER COPY (END)");
|
||||
assertTrue(beforeCopy.equalsDeep(afterCopy));
|
||||
}
|
||||
|
||||
private static MedicationAdministration createMedAdminWithDosageDurationExtension() {
|
||||
MedicationAdministration resource = new MedicationAdministration();
|
||||
resource.setId("12345");
|
||||
var dosage = new MedicationAdministration.MedicationAdministrationDosageComponent();
|
||||
dosage.setDose((SimpleQuantity) new SimpleQuantity().setValue(40))
|
||||
.addExtension(new Extension()
|
||||
.setUrl("http://duration")
|
||||
.setValue(new Duration().setValue(5340000)));
|
||||
resource.setDosage(dosage);
|
||||
return resource;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue