Additional work on FhirTerser.getValues(...) enhancements.
This commit is contained in:
parent
225007d681
commit
688e159493
|
@ -287,7 +287,7 @@ public class FhirTerser {
|
||||||
retVal = new ArrayList<>();
|
retVal = new ArrayList<>();
|
||||||
for (T nextElement : values) {
|
for (T nextElement : values) {
|
||||||
BaseRuntimeElementCompositeDefinition<?> nextChildDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition((Class<? extends IBase>) nextElement.getClass());
|
BaseRuntimeElementCompositeDefinition<?> nextChildDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition((Class<? extends IBase>) nextElement.getClass());
|
||||||
List<T> foundValues = getValues(nextChildDef, nextElement, theSubList.subList(1, theSubList.size()), theWantedClass);
|
List<T> foundValues = getValues(nextChildDef, nextElement, theSubList.subList(1, theSubList.size()), theWantedClass, theCreate);
|
||||||
retVal.addAll(foundValues);
|
retVal.addAll(foundValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ public class FhirTerser {
|
||||||
retVal = new ArrayList<>();
|
retVal = new ArrayList<>();
|
||||||
for (T nextElement : values) {
|
for (T nextElement : values) {
|
||||||
BaseRuntimeElementCompositeDefinition<?> nextChildDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition((Class<? extends IBase>) nextElement.getClass());
|
BaseRuntimeElementCompositeDefinition<?> nextChildDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition((Class<? extends IBase>) nextElement.getClass());
|
||||||
List<T> foundValues = getValues(nextChildDef, nextElement, theSubList.subList(1, theSubList.size()), theWantedClass);
|
List<T> foundValues = getValues(nextChildDef, nextElement, theSubList.subList(1, theSubList.size()), theWantedClass, theCreate);
|
||||||
retVal.addAll(foundValues);
|
retVal.addAll(foundValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,7 +381,7 @@ public class FhirTerser {
|
||||||
} else {
|
} else {
|
||||||
for (IBase nextElement : values) {
|
for (IBase nextElement : values) {
|
||||||
BaseRuntimeElementCompositeDefinition<?> nextChildDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition(nextElement.getClass());
|
BaseRuntimeElementCompositeDefinition<?> nextChildDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition(nextElement.getClass());
|
||||||
List<T> foundValues = getValues(nextChildDef, nextElement, theSubList.subList(1, theSubList.size()), theWantedClass);
|
List<T> foundValues = getValues(nextChildDef, nextElement, theSubList.subList(1, theSubList.size()), theWantedClass, theCreate);
|
||||||
retVal.addAll(foundValues);
|
retVal.addAll(foundValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,6 +185,7 @@ public class FhirTerserDstu2Test {
|
||||||
p.setActive(true);
|
p.setActive(true);
|
||||||
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value"));
|
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value"));
|
||||||
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/parentExtension").addUndeclaredExtension(false, "http://acme.org/childExtension", new StringDt("nestedValue"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -200,6 +201,13 @@ public class FhirTerserDstu2Test {
|
||||||
assertTrue(values.get(0) instanceof ExtensionDt);
|
assertTrue(values.get(0) instanceof ExtensionDt);
|
||||||
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(0)).getUrl());
|
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(0)).getUrl());
|
||||||
assertEquals("value", ((StringDt) ((ExtensionDt) values.get(0)).getValue()).getValueAsString());
|
assertEquals("value", ((StringDt) ((ExtensionDt) values.get(0)).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')");
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof ExtensionDt);
|
||||||
|
assertEquals("http://acme.org/childExtension", ((ExtensionDt) values.get(0)).getUrl());
|
||||||
|
assertEquals("nestedValue", ((StringDt) ((ExtensionDt) values.get(0)).getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -208,6 +216,7 @@ public class FhirTerserDstu2Test {
|
||||||
p.setActive(true);
|
p.setActive(true);
|
||||||
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value"));
|
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value"));
|
||||||
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/parentExtension").addUndeclaredExtension(false, "http://acme.org/childExtension", new StringDt("nestedValue"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -244,6 +253,24 @@ public class FhirTerserDstu2Test {
|
||||||
assertTrue(values.get(0) instanceof ExtensionDt);
|
assertTrue(values.get(0) instanceof ExtensionDt);
|
||||||
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(0)).getUrl());
|
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(0)).getUrl());
|
||||||
assertEquals("modifiedValue", ((StringDt) ((ExtensionDt) values.get(0)).getValue()).getValueAsString());
|
assertEquals("modifiedValue", ((StringDt) ((ExtensionDt) values.get(0)).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')");
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof ExtensionDt);
|
||||||
|
assertEquals("http://acme.org/childExtension", ((ExtensionDt) values.get(0)).getUrl());
|
||||||
|
assertEquals("nestedValue", ((StringDt) ((ExtensionDt) values.get(0)).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
((ExtensionDt) values.get(0)).setValue(new StringDt("modifiedNestedValue"));
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')");
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof ExtensionDt);
|
||||||
|
assertEquals("http://acme.org/childExtension", ((ExtensionDt) values.get(0)).getUrl());
|
||||||
|
assertEquals("modifiedNestedValue", ((StringDt) ((ExtensionDt) values.get(0)).getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -252,6 +279,8 @@ public class FhirTerserDstu2Test {
|
||||||
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value1"));
|
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value1"));
|
||||||
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value2"));
|
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value2"));
|
||||||
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/parentExtension").addUndeclaredExtension(false, "http://acme.org/childExtension", new StringDt("nestedValue1"));
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/parentExtension").addUndeclaredExtension(false, "http://acme.org/childExtension", new StringDt("nestedValue2"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -265,6 +294,17 @@ public class FhirTerserDstu2Test {
|
||||||
assertTrue(values.get(1) instanceof ExtensionDt);
|
assertTrue(values.get(1) instanceof ExtensionDt);
|
||||||
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(1)).getUrl());
|
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(1)).getUrl());
|
||||||
assertEquals("value2", ((StringDt) ((ExtensionDt) values.get(1)).getValue()).getValueAsString());
|
assertEquals("value2", ((StringDt) ((ExtensionDt) values.get(1)).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')");
|
||||||
|
assertEquals(2, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof ExtensionDt);
|
||||||
|
assertEquals("http://acme.org/childExtension", ((ExtensionDt) values.get(0)).getUrl());
|
||||||
|
assertEquals("nestedValue1", ((StringDt) ((ExtensionDt) values.get(0)).getValue()).getValueAsString());
|
||||||
|
assertTrue(values.get(1) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(1) instanceof ExtensionDt);
|
||||||
|
assertEquals("http://acme.org/childExtension", ((ExtensionDt) values.get(1)).getUrl());
|
||||||
|
assertEquals("nestedValue2", ((StringDt) ((ExtensionDt) values.get(1)).getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -273,6 +313,7 @@ public class FhirTerserDstu2Test {
|
||||||
p.setActive(true);
|
p.setActive(true);
|
||||||
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value"));
|
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value"));
|
||||||
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/parentExtension").addUndeclaredExtension(false, "http://acme.org/childExtension", new StringDt("nestedValue"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -285,7 +326,13 @@ public class FhirTerserDstu2Test {
|
||||||
assertEquals(1, extValues.size());
|
assertEquals(1, extValues.size());
|
||||||
assertTrue(extValues.get(0).getValue() instanceof StringDt);
|
assertTrue(extValues.get(0).getValue() instanceof StringDt);
|
||||||
assertEquals("http://acme.org/extension", extValues.get(0).getUrl());
|
assertEquals("http://acme.org/extension", extValues.get(0).getUrl());
|
||||||
assertEquals("value", ((StringDt) (extValues.get(0).getValue())).getValueAsString());
|
assertEquals("value", ((StringDt) extValues.get(0).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
extValues = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')", ExtensionDt.class);
|
||||||
|
assertEquals(1, extValues.size());
|
||||||
|
assertTrue(extValues.get(0).getValue() instanceof StringDt);
|
||||||
|
assertEquals("http://acme.org/childExtension", extValues.get(0).getUrl());
|
||||||
|
assertEquals("nestedValue", ((StringDt) extValues.get(0).getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -294,6 +341,7 @@ public class FhirTerserDstu2Test {
|
||||||
p.setActive(true);
|
p.setActive(true);
|
||||||
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value"));
|
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value"));
|
||||||
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/parentExtension").addUndeclaredExtension(false, "http://acme.org/childExtension", new StringDt("nestedValue"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -326,6 +374,22 @@ public class FhirTerserDstu2Test {
|
||||||
assertTrue(extValues.get(0).getValue() instanceof StringDt);
|
assertTrue(extValues.get(0).getValue() instanceof StringDt);
|
||||||
assertEquals("http://acme.org/extension", extValues.get(0).getUrl());
|
assertEquals("http://acme.org/extension", extValues.get(0).getUrl());
|
||||||
assertEquals("modifiedValue", ((StringDt) (extValues.get(0).getValue())).getValueAsString());
|
assertEquals("modifiedValue", ((StringDt) (extValues.get(0).getValue())).getValueAsString());
|
||||||
|
|
||||||
|
extValues = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')", ExtensionDt.class);
|
||||||
|
assertEquals(1, extValues.size());
|
||||||
|
assertTrue(extValues.get(0).getValue() instanceof StringDt);
|
||||||
|
assertEquals("http://acme.org/childExtension", extValues.get(0).getUrl());
|
||||||
|
assertEquals("nestedValue", ((StringDt) extValues.get(0).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
extValues.get(0).setValue(new StringDt("modifiedNestedValue"));
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
extValues = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')", ExtensionDt.class);
|
||||||
|
assertEquals(1, extValues.size());
|
||||||
|
assertTrue(extValues.get(0).getValue() instanceof StringDt);
|
||||||
|
assertEquals("http://acme.org/childExtension", extValues.get(0).getUrl());
|
||||||
|
assertEquals("modifiedNestedValue", ((StringDt) extValues.get(0).getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -343,6 +407,11 @@ public class FhirTerserDstu2Test {
|
||||||
assertEquals(1, extValues.size());
|
assertEquals(1, extValues.size());
|
||||||
assertEquals("http://acme.org/extension", extValues.get(0).getUrl());
|
assertEquals("http://acme.org/extension", extValues.get(0).getUrl());
|
||||||
assertNull(extValues.get(0).getValue());
|
assertNull(extValues.get(0).getValue());
|
||||||
|
|
||||||
|
extValues = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')", ExtensionDt.class, true);
|
||||||
|
assertEquals(1, extValues.size());
|
||||||
|
assertEquals("http://acme.org/childExtension", extValues.get(0).getUrl());
|
||||||
|
assertNull(extValues.get(0).getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -363,6 +432,13 @@ public class FhirTerserDstu2Test {
|
||||||
assertTrue(values.get(0) instanceof ExtensionDt);
|
assertTrue(values.get(0) instanceof ExtensionDt);
|
||||||
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(0)).getUrl());
|
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(0)).getUrl());
|
||||||
assertNull(((ExtensionDt) values.get(0)).getValue());
|
assertNull(((ExtensionDt) values.get(0)).getValue());
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')", true);
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof ExtensionDt);
|
||||||
|
assertEquals("http://acme.org/childExtension", ((ExtensionDt) values.get(0)).getUrl());
|
||||||
|
assertNull(((ExtensionDt) values.get(0)).getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -371,6 +447,7 @@ public class FhirTerserDstu2Test {
|
||||||
p.setActive(true);
|
p.setActive(true);
|
||||||
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value"));
|
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value"));
|
||||||
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/parentExtension").addUndeclaredExtension(false, "http://acme.org/childExtension", new StringDt("nestedValue"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -380,12 +457,19 @@ public class FhirTerserDstu2Test {
|
||||||
assertTrue(values.get(0) instanceof BooleanDt);
|
assertTrue(values.get(0) instanceof BooleanDt);
|
||||||
assertTrue(((BooleanDt) values.get(0)).getValue());
|
assertTrue(((BooleanDt) values.get(0)).getValue());
|
||||||
|
|
||||||
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/extension')");
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/extension')", true);
|
||||||
assertEquals(1, values.size());
|
assertEquals(1, values.size());
|
||||||
assertTrue(values.get(0) instanceof IBaseExtension);
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
assertTrue(values.get(0) instanceof ExtensionDt);
|
assertTrue(values.get(0) instanceof ExtensionDt);
|
||||||
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(0)).getUrl());
|
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(0)).getUrl());
|
||||||
assertEquals("value", ((StringDt) ((ExtensionDt) values.get(0)).getValue()).getValueAsString());
|
assertEquals("value", ((StringDt) ((ExtensionDt) values.get(0)).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')", true);
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof ExtensionDt);
|
||||||
|
assertEquals("http://acme.org/childExtension", ((ExtensionDt) values.get(0)).getUrl());
|
||||||
|
assertEquals("nestedValue", ((StringDt) ((ExtensionDt) values.get(0)).getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -182,6 +182,11 @@ public class FhirTerserDstu3Test {
|
||||||
p.addModifierExtension()
|
p.addModifierExtension()
|
||||||
.setUrl("http://acme.org/modifierExtension")
|
.setUrl("http://acme.org/modifierExtension")
|
||||||
.setValue(new StringType("modifierValue"));
|
.setValue(new StringType("modifierValue"));
|
||||||
|
p.addExtension()
|
||||||
|
.setUrl("http://acme.org/parentExtension")
|
||||||
|
.addExtension()
|
||||||
|
.setUrl("http://acme.org/childExtension")
|
||||||
|
.setValue(new StringType("nestedValue"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -204,6 +209,13 @@ public class FhirTerserDstu3Test {
|
||||||
assertTrue(values.get(0) instanceof Extension);
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
assertEquals("http://acme.org/modifierExtension", ((Extension) values.get(0)).getUrl());
|
assertEquals("http://acme.org/modifierExtension", ((Extension) values.get(0)).getUrl());
|
||||||
assertEquals("modifierValue", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
assertEquals("modifierValue", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')");
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
|
assertEquals("http://acme.org/childExtension", ((Extension) values.get(0)).getUrl());
|
||||||
|
assertEquals("nestedValue", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -219,6 +231,11 @@ public class FhirTerserDstu3Test {
|
||||||
p.addModifierExtension()
|
p.addModifierExtension()
|
||||||
.setUrl("http://acme.org/modifierExtension")
|
.setUrl("http://acme.org/modifierExtension")
|
||||||
.setValue(new StringType("modifierValue"));
|
.setValue(new StringType("modifierValue"));
|
||||||
|
p.addExtension()
|
||||||
|
.setUrl("http://acme.org/parentExtension")
|
||||||
|
.addExtension()
|
||||||
|
.setUrl("http://acme.org/childExtension")
|
||||||
|
.setValue(new StringType("nestedValue"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -273,6 +290,24 @@ public class FhirTerserDstu3Test {
|
||||||
assertTrue(values.get(0) instanceof Extension);
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
assertEquals("http://acme.org/modifierExtension", ((Extension) values.get(0)).getUrl());
|
assertEquals("http://acme.org/modifierExtension", ((Extension) values.get(0)).getUrl());
|
||||||
assertEquals("modifiedModifierValue", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
assertEquals("modifiedModifierValue", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')");
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
|
assertEquals("http://acme.org/childExtension", ((Extension) values.get(0)).getUrl());
|
||||||
|
assertEquals("nestedValue", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
((Extension) values.get(0)).setValue(new StringType("modifiedNestedValue"));
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')");
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
|
assertEquals("http://acme.org/childExtension", ((Extension) values.get(0)).getUrl());
|
||||||
|
assertEquals("modifiedNestedValue", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -293,6 +328,16 @@ public class FhirTerserDstu3Test {
|
||||||
p.addModifierExtension()
|
p.addModifierExtension()
|
||||||
.setUrl("http://acme.org/modifierExtension")
|
.setUrl("http://acme.org/modifierExtension")
|
||||||
.setValue(new StringType("modifierValue2"));
|
.setValue(new StringType("modifierValue2"));
|
||||||
|
p.addExtension()
|
||||||
|
.setUrl("http://acme.org/parentExtension")
|
||||||
|
.addExtension()
|
||||||
|
.setUrl("http://acme.org/childExtension")
|
||||||
|
.setValue(new StringType("nestedValue1"));
|
||||||
|
p.addExtension()
|
||||||
|
.setUrl("http://acme.org/parentExtension")
|
||||||
|
.addExtension()
|
||||||
|
.setUrl("http://acme.org/childExtension")
|
||||||
|
.setValue(new StringType("nestedValue2"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -317,6 +362,17 @@ public class FhirTerserDstu3Test {
|
||||||
assertTrue(values.get(1) instanceof Extension);
|
assertTrue(values.get(1) instanceof Extension);
|
||||||
assertEquals("http://acme.org/modifierExtension", ((Extension) values.get(1)).getUrl());
|
assertEquals("http://acme.org/modifierExtension", ((Extension) values.get(1)).getUrl());
|
||||||
assertEquals("modifierValue2", ((StringType) ((Extension) values.get(1)).getValue()).getValueAsString());
|
assertEquals("modifierValue2", ((StringType) ((Extension) values.get(1)).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')");
|
||||||
|
assertEquals(2, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
|
assertEquals("http://acme.org/childExtension", ((Extension) values.get(0)).getUrl());
|
||||||
|
assertEquals("nestedValue1", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
||||||
|
assertTrue(values.get(1) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(1) instanceof Extension);
|
||||||
|
assertEquals("http://acme.org/childExtension", ((Extension) values.get(1)).getUrl());
|
||||||
|
assertEquals("nestedValue2", ((StringType) ((Extension) values.get(1)).getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -332,6 +388,11 @@ public class FhirTerserDstu3Test {
|
||||||
p.addModifierExtension()
|
p.addModifierExtension()
|
||||||
.setUrl("http://acme.org/modifierExtension")
|
.setUrl("http://acme.org/modifierExtension")
|
||||||
.setValue(new StringType("modifierValue"));
|
.setValue(new StringType("modifierValue"));
|
||||||
|
p.addExtension()
|
||||||
|
.setUrl("http://acme.org/parentExtension")
|
||||||
|
.addExtension()
|
||||||
|
.setUrl("http://acme.org/childExtension")
|
||||||
|
.setValue(new StringType("nestedValue"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -351,6 +412,12 @@ public class FhirTerserDstu3Test {
|
||||||
assertTrue(extValues.get(0).getValue() instanceof StringType);
|
assertTrue(extValues.get(0).getValue() instanceof StringType);
|
||||||
assertEquals("http://acme.org/modifierExtension", extValues.get(0).getUrl());
|
assertEquals("http://acme.org/modifierExtension", extValues.get(0).getUrl());
|
||||||
assertEquals("modifierValue", ((StringType) (extValues.get(0).getValue())).getValueAsString());
|
assertEquals("modifierValue", ((StringType) (extValues.get(0).getValue())).getValueAsString());
|
||||||
|
|
||||||
|
extValues = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')", Extension.class);
|
||||||
|
assertEquals(1, extValues.size());
|
||||||
|
assertTrue(extValues.get(0).getValue() instanceof StringType);
|
||||||
|
assertEquals("http://acme.org/childExtension", extValues.get(0).getUrl());
|
||||||
|
assertEquals("nestedValue", ((StringType) extValues.get(0).getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -366,6 +433,11 @@ public class FhirTerserDstu3Test {
|
||||||
p.addModifierExtension()
|
p.addModifierExtension()
|
||||||
.setUrl("http://acme.org/modifierExtension")
|
.setUrl("http://acme.org/modifierExtension")
|
||||||
.setValue(new StringType("modifierValue"));
|
.setValue(new StringType("modifierValue"));
|
||||||
|
p.addExtension()
|
||||||
|
.setUrl("http://acme.org/parentExtension")
|
||||||
|
.addExtension()
|
||||||
|
.setUrl("http://acme.org/childExtension")
|
||||||
|
.setValue(new StringType("nestedValue"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -414,6 +486,22 @@ public class FhirTerserDstu3Test {
|
||||||
assertTrue(extValues.get(0).getValue() instanceof StringType);
|
assertTrue(extValues.get(0).getValue() instanceof StringType);
|
||||||
assertEquals("http://acme.org/modifierExtension", extValues.get(0).getUrl());
|
assertEquals("http://acme.org/modifierExtension", extValues.get(0).getUrl());
|
||||||
assertEquals("modifiedModifierValue", ((StringType) (extValues.get(0).getValue())).getValueAsString());
|
assertEquals("modifiedModifierValue", ((StringType) (extValues.get(0).getValue())).getValueAsString());
|
||||||
|
|
||||||
|
extValues = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')", Extension.class);
|
||||||
|
assertEquals(1, extValues.size());
|
||||||
|
assertTrue(extValues.get(0).getValue() instanceof StringType);
|
||||||
|
assertEquals("http://acme.org/childExtension", extValues.get(0).getUrl());
|
||||||
|
assertEquals("nestedValue", ((StringType) extValues.get(0).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
extValues.get(0).setValue(new StringType("modifiedNestedValue"));
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
extValues = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')", Extension.class);
|
||||||
|
assertEquals(1, extValues.size());
|
||||||
|
assertTrue(extValues.get(0).getValue() instanceof StringType);
|
||||||
|
assertEquals("http://acme.org/childExtension", extValues.get(0).getUrl());
|
||||||
|
assertEquals("modifiedNestedValue", ((StringType) extValues.get(0).getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -436,6 +524,11 @@ public class FhirTerserDstu3Test {
|
||||||
assertEquals(1, extValues.size());
|
assertEquals(1, extValues.size());
|
||||||
assertEquals("http://acme.org/modifierExtension", extValues.get(0).getUrl());
|
assertEquals("http://acme.org/modifierExtension", extValues.get(0).getUrl());
|
||||||
assertNull(extValues.get(0).getValue());
|
assertNull(extValues.get(0).getValue());
|
||||||
|
|
||||||
|
extValues = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')", Extension.class, true);
|
||||||
|
assertEquals(1, extValues.size());
|
||||||
|
assertEquals("http://acme.org/childExtension", extValues.get(0).getUrl());
|
||||||
|
assertNull(extValues.get(0).getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -463,6 +556,18 @@ public class FhirTerserDstu3Test {
|
||||||
assertTrue(values.get(0) instanceof Extension);
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
assertEquals("http://acme.org/modifierExtension", ((Extension) values.get(0)).getUrl());
|
assertEquals("http://acme.org/modifierExtension", ((Extension) values.get(0)).getUrl());
|
||||||
assertNull(((Extension) values.get(0)).getValue());
|
assertNull(((Extension) values.get(0)).getValue());
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')", true);
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
|
assertEquals("http://acme.org/childExtension", ((Extension) values.get(0)).getUrl());
|
||||||
|
assertNull(((Extension) values.get(0)).getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -478,6 +583,11 @@ public class FhirTerserDstu3Test {
|
||||||
p.addModifierExtension()
|
p.addModifierExtension()
|
||||||
.setUrl("http://acme.org/modifierExtension")
|
.setUrl("http://acme.org/modifierExtension")
|
||||||
.setValue(new StringType("modifierValue"));
|
.setValue(new StringType("modifierValue"));
|
||||||
|
p.addExtension()
|
||||||
|
.setUrl("http://acme.org/parentExtension")
|
||||||
|
.addExtension()
|
||||||
|
.setUrl("http://acme.org/childExtension")
|
||||||
|
.setValue(new StringType("nestedValue"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -487,19 +597,26 @@ public class FhirTerserDstu3Test {
|
||||||
assertTrue(values.get(0) instanceof BooleanType);
|
assertTrue(values.get(0) instanceof BooleanType);
|
||||||
assertTrue(((BooleanType) values.get(0)).booleanValue());
|
assertTrue(((BooleanType) values.get(0)).booleanValue());
|
||||||
|
|
||||||
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/extension')");
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/extension')", true);
|
||||||
assertEquals(1, values.size());
|
assertEquals(1, values.size());
|
||||||
assertTrue(values.get(0) instanceof IBaseExtension);
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
assertTrue(values.get(0) instanceof Extension);
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
assertEquals("http://acme.org/extension", ((Extension) values.get(0)).getUrl());
|
assertEquals("http://acme.org/extension", ((Extension) values.get(0)).getUrl());
|
||||||
assertEquals("value", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
assertEquals("value", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
||||||
|
|
||||||
values = ourCtx.newTerser().getValues(p, "Patient.modifierExtension('http://acme.org/modifierExtension')");
|
values = ourCtx.newTerser().getValues(p, "Patient.modifierExtension('http://acme.org/modifierExtension')", true);
|
||||||
assertEquals(1, values.size());
|
assertEquals(1, values.size());
|
||||||
assertTrue(values.get(0) instanceof IBaseExtension);
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
assertTrue(values.get(0) instanceof Extension);
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
assertEquals("http://acme.org/modifierExtension", ((Extension) values.get(0)).getUrl());
|
assertEquals("http://acme.org/modifierExtension", ((Extension) values.get(0)).getUrl());
|
||||||
assertEquals("modifierValue", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
assertEquals("modifierValue", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/parentExtension').extension('http://acme.org/childExtension')", true);
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
|
assertEquals("http://acme.org/childExtension", ((Extension) values.get(0)).getUrl());
|
||||||
|
assertEquals("nestedValue", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue