From 84ecec2835ba7f4ee9a98a3ae6bdbbee5d4a117d Mon Sep 17 00:00:00 2001 From: "b.debeaubien" Date: Wed, 10 Dec 2014 10:24:04 -0500 Subject: [PATCH] Added test demonstrating that using the same extension in 2 different resources causes the profile extension scanner to throw up its hands in despair --- .../fhir/context/DuplicateExtensionTest.java | 71 +++++++++++++++++++ pom.xml | 5 ++ 2 files changed, 76 insertions(+) create mode 100644 hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/DuplicateExtensionTest.java diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/DuplicateExtensionTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/DuplicateExtensionTest.java new file mode 100644 index 00000000000..a09371ed927 --- /dev/null +++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/DuplicateExtensionTest.java @@ -0,0 +1,71 @@ +package ca.uhn.fhir.context; + +import ca.uhn.fhir.model.api.annotation.*; +import ca.uhn.fhir.model.dstu.resource.Observation; +import ca.uhn.fhir.model.dstu.resource.Patient; +import ca.uhn.fhir.model.api.annotation.Extension; +import ca.uhn.fhir.model.primitive.StringDt; +import junit.framework.TestCase; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Created by Bill de Beaubien on 12/10/2014. + */ +public class DuplicateExtensionTest extends TestCase { + @Test + public void testScannerShouldAddProvidedResources() { +// FhirContext ctx = new FhirContext(); +// RuntimeResourceDefinition patientDef = ctx.getResourceDefinition(CustomPatient.class); +// patientDef.toProfile(); +// +// RuntimeResourceDefinition observationDef = ctx.getResourceDefinition(CustomObservation.class); +// observationDef.toProfile(); + } + + @ProvidesResources(resources = CustomObservation.class) + class CustomObservationProvider { + } + + @ProvidesResources(resources = CustomPatient.class) + class CustomPatientProvider { + } + + @ResourceDef(name = "Patient", id = "CustomPatient") + class CustomPatient extends Patient { + @Child(name="idExt", order = 0) + @Extension(url= "http://foo.org#id", definedLocally=true, isModifier=false) + @Description(shortDefinition = "Contains the id of the resource") + private StringDt myIdExt; + + public StringDt getIdExt() { + if (myIdExt == null) { + myIdExt = new StringDt(); + } + return myIdExt; + } + + public void setIdExt(StringDt theIdExt) { + myIdExt = theIdExt; + } + } + + @ResourceDef(name = "Observation", id = "CustomObservation") + class CustomObservation extends Observation { + @Child(name="idExt", order = 0) + @Extension(url= "http://foo.org#id", definedLocally=true, isModifier=false) + @Description(shortDefinition = "Contains the id of the resource") + private StringDt myIdExt; + + public StringDt getIdExt() { + if (myIdExt == null) { + myIdExt = new StringDt(); + } + return myIdExt; + } + + public void setIdExt(StringDt theIdExt) { + myIdExt = theIdExt; + } + } +} diff --git a/pom.xml b/pom.xml index c58ee41af83..d2e95572564 100644 --- a/pom.xml +++ b/pom.xml @@ -114,6 +114,11 @@ Tahura Chaudhry University Health Network + + b.debeaubien + Bill de Beaubien + Systems Made Simple +