-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Grahame Grieve
committed
Sep 18, 2024
1 parent
f3bd5b9
commit 6952514
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/model/MedicationAdministrationCopyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |