Completed work on FhirTerser.getValues(...) enhancements.
This commit is contained in:
parent
b0d9580530
commit
225007d681
|
@ -230,72 +230,100 @@ public class FhirTerser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DSTU2
|
// DSTU2
|
||||||
List<ExtensionDt> extensionDts = Collections.emptyList();
|
if (myContext.getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) {
|
||||||
if (theCurrentObj instanceof ISupportsUndeclaredExtensions) {
|
List<ExtensionDt> extensionDts = Collections.emptyList();
|
||||||
extensionDts = ((ISupportsUndeclaredExtensions) theCurrentObj).getUndeclaredExtensionsByUrl(extensionUrl);
|
if (theCurrentObj instanceof ISupportsUndeclaredExtensions) {
|
||||||
|
extensionDts = ((ISupportsUndeclaredExtensions) theCurrentObj).getUndeclaredExtensionsByUrl(extensionUrl);
|
||||||
|
|
||||||
if (extensionDts.isEmpty() && theCreate) {
|
if (extensionDts.isEmpty() && theCreate) {
|
||||||
// FIXME: Add a new extension with extensionUrl and null value.
|
// We assume the extension is not a modifier extension.
|
||||||
// FIXME: Discern between extensions and modifier extensions.
|
extensionDts = new ArrayList<>(); // Implementation of ISupportsUndeclaredExtensions.getUndeclaredExtensionsByUrl(...) returns unmodifiable list.
|
||||||
|
ExtensionDt extensionDt = ((ISupportsUndeclaredExtensions) theCurrentObj).addUndeclaredExtension(false, extensionUrl);
|
||||||
|
extensionDts.add(extensionDt);
|
||||||
|
}
|
||||||
|
} else if (theCurrentObj instanceof IBaseExtension) {
|
||||||
|
extensionDts = ((IBaseExtension) theCurrentObj).getExtension();
|
||||||
|
|
||||||
|
if (extensionDts.isEmpty() && theCreate) {
|
||||||
|
// We assume the extension is not a modifier extension.
|
||||||
|
ExtensionDt extensionDt = new ExtensionDt();
|
||||||
|
extensionDt.setUrl(extensionUrl);
|
||||||
|
((IBaseExtension) theCurrentObj).getExtension().add(extensionDt);
|
||||||
|
extensionDts.add(extensionDt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (theCurrentObj instanceof IBaseExtension) {
|
|
||||||
extensionDts = ((IBaseExtension) theCurrentObj).getExtension();
|
|
||||||
|
|
||||||
if (extensionDts.isEmpty() && theCreate) {
|
for (ExtensionDt next : extensionDts) {
|
||||||
// FIXME: Add a new extension with extensionUrl and null value.
|
if (theWantedClass.isAssignableFrom(next.getClass())) {
|
||||||
|
retVal.add((T) next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// DSTU3+
|
||||||
|
final String extensionUrlForLambda = extensionUrl;
|
||||||
|
List<IBaseExtension> extensions = Collections.emptyList();
|
||||||
|
if (theCurrentObj instanceof IBaseHasExtensions) {
|
||||||
|
extensions = ((IBaseHasExtensions) theCurrentObj).getExtension()
|
||||||
|
.stream()
|
||||||
|
.filter(t -> t.getUrl().equals(extensionUrlForLambda))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (extensions.isEmpty() && theCreate) {
|
||||||
|
IBaseExtension extension = ((IBaseHasExtensions) theCurrentObj).addExtension();
|
||||||
|
extension.setUrl(extensionUrl);
|
||||||
|
extensions.add(extension);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (IBaseExtension next : extensions) {
|
||||||
|
if (theWantedClass.isAssignableFrom(next.getClass())) {
|
||||||
|
retVal.add((T) next);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ExtensionDt next : extensionDts) {
|
if (theSubList.size() > 1) {
|
||||||
if (theWantedClass.isAssignableFrom(next.getClass())) {
|
List<T> values = retVal;
|
||||||
retVal.add((T) next);
|
retVal = new ArrayList<>();
|
||||||
|
for (T nextElement : values) {
|
||||||
|
BaseRuntimeElementCompositeDefinition<?> nextChildDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition((Class<? extends IBase>) nextElement.getClass());
|
||||||
|
List<T> foundValues = getValues(nextChildDef, nextElement, theSubList.subList(1, theSubList.size()), theWantedClass);
|
||||||
|
retVal.addAll(foundValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name.startsWith("modifierExtension('")) {
|
||||||
|
String extensionUrl = name.substring("modifierExtension('".length());
|
||||||
|
int endIndex = extensionUrl.indexOf('\'');
|
||||||
|
if (endIndex != -1) {
|
||||||
|
extensionUrl = extensionUrl.substring(0, endIndex);
|
||||||
|
}
|
||||||
|
|
||||||
// DSTU3+
|
// DSTU3+
|
||||||
final String extensionUrlForLambda = extensionUrl;
|
if (myContext.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.DSTU3)) {
|
||||||
List<IBaseExtension> extensions = Collections.emptyList();
|
final String extensionUrlForLambda = extensionUrl;
|
||||||
if (theCurrentObj instanceof IBaseHasExtensions) {
|
List<IBaseExtension> extensions = Collections.emptyList();
|
||||||
extensions = ((IBaseHasExtensions) theCurrentObj).getExtension()
|
|
||||||
.stream()
|
|
||||||
.filter(t -> t.getUrl().equals(extensionUrlForLambda))
|
|
||||||
.distinct()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (extensions.isEmpty() && theCreate) {
|
if (theCurrentObj instanceof IBaseHasModifierExtensions) {
|
||||||
IBaseExtension extension = ((IBaseHasExtensions) theCurrentObj).addExtension();
|
extensions = ((IBaseHasModifierExtensions) theCurrentObj).getModifierExtension()
|
||||||
extension.setUrl(extensionUrl);
|
.stream()
|
||||||
extensions.add(extension);
|
.filter(t -> t.getUrl().equals(extensionUrlForLambda))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (extensions.isEmpty() && theCreate) {
|
||||||
|
IBaseExtension modifierExtension = ((IBaseHasModifierExtensions) theCurrentObj).addModifierExtension();
|
||||||
|
modifierExtension.setUrl(extensionUrl);
|
||||||
|
extensions.add(modifierExtension);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// List<IBaseExtension> modifierExtensions = Collections.emptyList();
|
|
||||||
// if (theCurrentObj instanceof IBaseHasModifierExtensions) {
|
|
||||||
// modifierExtensions = ((IBaseHasModifierExtensions) theCurrentObj).getModifierExtension()
|
|
||||||
// .stream()
|
|
||||||
// .filter(t -> t.getUrl().equals(extensionUrlForLambda))
|
|
||||||
// .collect(Collectors.toList());
|
|
||||||
//
|
|
||||||
// if (modifierExtensions.isEmpty() && theCreate) {
|
|
||||||
// IBaseExtension modifierExtension = ((IBaseHasModifierExtensions) theCurrentObj).addModifierExtension();
|
|
||||||
// modifierExtension.setUrl(extensionUrl);
|
|
||||||
// modifierExtensions.add(modifierExtension);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// List<IBaseExtension> allExtensions = Stream.of(extensions, modifierExtensions)
|
|
||||||
// .flatMap(Collection::stream)
|
|
||||||
// .distinct()
|
|
||||||
// .collect(Collectors.toList());
|
|
||||||
//
|
|
||||||
// for (IBaseExtension next : allExtensions) {
|
|
||||||
// if (theWantedClass.isAssignableFrom(next.getClass())) {
|
|
||||||
// retVal.add((T) next);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
for (IBaseExtension next : extensions) {
|
for (IBaseExtension next : extensions) {
|
||||||
if (theWantedClass.isAssignableFrom(next.getClass())) {
|
if (theWantedClass.isAssignableFrom(next.getClass())) {
|
||||||
retVal.add((T) next);
|
retVal.add((T) next);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,24 +388,74 @@ public class FhirTerser {
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns values stored in an element identified by its path. The list of values is of
|
||||||
|
* type {@link Object}.
|
||||||
|
*
|
||||||
|
* <p>Note: this method does not support creation of null-valued modifier extensions for
|
||||||
|
* versions of FHIR prior to DSTU3.</p>
|
||||||
|
*
|
||||||
|
* @param theResource The resource instance to be accessed. Must not be null.
|
||||||
|
* @param thePath The path for the element to be accessed.
|
||||||
|
* @return A list of values of type {@link Object}.
|
||||||
|
*/
|
||||||
public List<Object> getValues(IBaseResource theResource, String thePath) {
|
public List<Object> getValues(IBaseResource theResource, String thePath) {
|
||||||
Class<Object> wantedClass = Object.class;
|
Class<Object> wantedClass = Object.class;
|
||||||
|
|
||||||
return getValues(theResource, thePath, wantedClass);
|
return getValues(theResource, thePath, wantedClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns values stored in an element identified by its path. The list of values is of
|
||||||
|
* type {@link Object}.
|
||||||
|
*
|
||||||
|
* <p>Note: this method does not support creation of null-valued modifier extensions for
|
||||||
|
* versions of FHIR prior to DSTU3.</p>
|
||||||
|
*
|
||||||
|
* @param theResource The resource instance to be accessed. Must not be null.
|
||||||
|
* @param thePath The path for the element to be accessed.
|
||||||
|
* @param theCreate When set to <code>true</code>, the terser will create a null-valued element where none exists.
|
||||||
|
* @return A list of values of type {@link Object}.
|
||||||
|
*/
|
||||||
public List<Object> getValues(IBaseResource theResource, String thePath, boolean theCreate) {
|
public List<Object> getValues(IBaseResource theResource, String thePath, boolean theCreate) {
|
||||||
Class<Object> wantedClass = Object.class;
|
Class<Object> wantedClass = Object.class;
|
||||||
|
|
||||||
return getValues(theResource, thePath, wantedClass, theCreate);
|
return getValues(theResource, thePath, wantedClass, theCreate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns values stored in an element identified by its path. The list of values is of
|
||||||
|
* type <code>theWantedClass</code>.
|
||||||
|
*
|
||||||
|
* <p>Note: this method does not support creation of null-valued modifier extensions for
|
||||||
|
* versions of FHIR prior to DSTU3.</p>
|
||||||
|
*
|
||||||
|
* @param theResource The resource instance to be accessed. Must not be null.
|
||||||
|
* @param thePath The path for the element to be accessed.
|
||||||
|
* @param theWantedClass The desired class to be returned in a list.
|
||||||
|
* @param <T> Type declared by <code>theWantedClass</code>
|
||||||
|
* @return A list of values of type <code>theWantedClass</code>.
|
||||||
|
*/
|
||||||
public <T> List<T> getValues(IBaseResource theResource, String thePath, Class<T> theWantedClass) {
|
public <T> List<T> getValues(IBaseResource theResource, String thePath, Class<T> theWantedClass) {
|
||||||
RuntimeResourceDefinition def = myContext.getResourceDefinition(theResource);
|
RuntimeResourceDefinition def = myContext.getResourceDefinition(theResource);
|
||||||
List<String> parts = parsePath(def, thePath);
|
List<String> parts = parsePath(def, thePath);
|
||||||
return getValues(def, theResource, parts, theWantedClass);
|
return getValues(def, theResource, parts, theWantedClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns values stored in an element identified by its path. The list of values is of
|
||||||
|
* type <code>theWantedClass</code>.
|
||||||
|
*
|
||||||
|
* <p>Note: this method does not support creation of null-valued modifier extensions for
|
||||||
|
* versions of FHIR prior to DSTU3.</p>
|
||||||
|
*
|
||||||
|
* @param theResource The resource instance to be accessed. Must not be null.
|
||||||
|
* @param thePath The path for the element to be accessed.
|
||||||
|
* @param theWantedClass The desired class to be returned in a list.
|
||||||
|
* @param theCreate When set to <code>true</code>, the terser will create a null-valued element where none exists.
|
||||||
|
* @param <T> Type declared by <code>theWantedClass</code>
|
||||||
|
* @return A list of values of type <code>theWantedClass</code>.
|
||||||
|
*/
|
||||||
public <T> List<T> getValues(IBaseResource theResource, String thePath, Class<T> theWantedClass, boolean theCreate) {
|
public <T> List<T> getValues(IBaseResource theResource, String thePath, Class<T> theWantedClass, boolean theCreate) {
|
||||||
RuntimeResourceDefinition def = myContext.getResourceDefinition(theResource);
|
RuntimeResourceDefinition def = myContext.getResourceDefinition(theResource);
|
||||||
List<String> parts = parsePath(def, thePath);
|
List<String> parts = parsePath(def, thePath);
|
||||||
|
|
|
@ -1,24 +1,5 @@
|
||||||
package ca.uhn.fhir.util;
|
package ca.uhn.fhir.util;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertSame;
|
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
|
||||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.mockito.ArgumentCaptor;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||||
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
@ -31,9 +12,26 @@ import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Organization;
|
import ca.uhn.fhir.model.dstu2.resource.Organization;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||||
|
import ca.uhn.fhir.model.primitive.BooleanDt;
|
||||||
import ca.uhn.fhir.model.primitive.MarkdownDt;
|
import ca.uhn.fhir.model.primitive.MarkdownDt;
|
||||||
import ca.uhn.fhir.model.primitive.StringDt;
|
import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBase;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||||
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class FhirTerserDstu2Test {
|
public class FhirTerserDstu2Test {
|
||||||
|
|
||||||
|
@ -181,6 +179,215 @@ public class FhirTerserDstu2Test {
|
||||||
assertSame(ref, refs.get(0));
|
assertSame(ref, refs.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetValues() {
|
||||||
|
Patient p = new Patient();
|
||||||
|
p.setActive(true);
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value"));
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
List<Object> values = ourCtx.newTerser().getValues(p, "Patient.active");
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IPrimitiveType);
|
||||||
|
assertTrue(values.get(0) instanceof BooleanDt);
|
||||||
|
assertTrue(((BooleanDt) values.get(0)).getValue());
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/extension')");
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof ExtensionDt);
|
||||||
|
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(0)).getUrl());
|
||||||
|
assertEquals("value", ((StringDt) ((ExtensionDt) values.get(0)).getValue()).getValueAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetValuesAndModify() {
|
||||||
|
Patient p = new Patient();
|
||||||
|
p.setActive(true);
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value"));
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
List<Object> values = ourCtx.newTerser().getValues(p, "Patient.active");
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IPrimitiveType);
|
||||||
|
assertTrue(values.get(0) instanceof BooleanDt);
|
||||||
|
assertTrue(((BooleanDt) values.get(0)).getValue());
|
||||||
|
|
||||||
|
((BooleanDt) values.get(0)).setValue(Boolean.FALSE);
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.active");
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IPrimitiveType);
|
||||||
|
assertTrue(values.get(0) instanceof BooleanDt);
|
||||||
|
assertFalse(((BooleanDt) values.get(0)).getValue());
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/extension')");
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof ExtensionDt);
|
||||||
|
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(0)).getUrl());
|
||||||
|
assertEquals("value", ((StringDt) ((ExtensionDt) values.get(0)).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
((ExtensionDt) values.get(0)).setValue(new StringDt("modifiedValue"));
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/extension')");
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof ExtensionDt);
|
||||||
|
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(0)).getUrl());
|
||||||
|
assertEquals("modifiedValue", ((StringDt) ((ExtensionDt) values.get(0)).getValue()).getValueAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetValuesMultiple() {
|
||||||
|
Patient p = new Patient();
|
||||||
|
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/otherExtension", new StringDt("otherValue"));
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
List<Object> values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/extension')");
|
||||||
|
assertEquals(2, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof ExtensionDt);
|
||||||
|
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(0)).getUrl());
|
||||||
|
assertEquals("value1", ((StringDt) ((ExtensionDt) values.get(0)).getValue()).getValueAsString());
|
||||||
|
assertTrue(values.get(1) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(1) instanceof ExtensionDt);
|
||||||
|
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(1)).getUrl());
|
||||||
|
assertEquals("value2", ((StringDt) ((ExtensionDt) values.get(1)).getValue()).getValueAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetValuesWithWantedClass() {
|
||||||
|
Patient p = new Patient();
|
||||||
|
p.setActive(true);
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value"));
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
List<IPrimitiveType> values = ourCtx.newTerser().getValues(p, "Patient.active", IPrimitiveType.class);
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof BooleanDt);
|
||||||
|
assertTrue(((BooleanDt) values.get(0)).getValue());
|
||||||
|
|
||||||
|
List<ExtensionDt> extValues = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/extension')", ExtensionDt.class);
|
||||||
|
assertEquals(1, extValues.size());
|
||||||
|
assertTrue(extValues.get(0).getValue() instanceof StringDt);
|
||||||
|
assertEquals("http://acme.org/extension", extValues.get(0).getUrl());
|
||||||
|
assertEquals("value", ((StringDt) (extValues.get(0).getValue())).getValueAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetValuesWithWantedClassAndModify() {
|
||||||
|
Patient p = new Patient();
|
||||||
|
p.setActive(true);
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value"));
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
List<IPrimitiveType> values = ourCtx.newTerser().getValues(p, "Patient.active", IPrimitiveType.class);
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof BooleanDt);
|
||||||
|
assertTrue(((BooleanDt) values.get(0)).getValue());
|
||||||
|
|
||||||
|
((BooleanDt) values.get(0)).setValue(Boolean.FALSE);
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.active", IPrimitiveType.class);
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof BooleanDt);
|
||||||
|
assertFalse(((BooleanDt) values.get(0)).getValue());
|
||||||
|
|
||||||
|
List<ExtensionDt> extValues = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/extension')", ExtensionDt.class);
|
||||||
|
assertEquals(1, extValues.size());
|
||||||
|
assertTrue(extValues.get(0).getValue() instanceof StringDt);
|
||||||
|
assertEquals("http://acme.org/extension", extValues.get(0).getUrl());
|
||||||
|
assertEquals("value", ((StringDt) (extValues.get(0).getValue())).getValueAsString());
|
||||||
|
|
||||||
|
extValues.get(0).setValue(new StringDt("modifiedValue"));
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
extValues = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/extension')", ExtensionDt.class);
|
||||||
|
assertEquals(1, extValues.size());
|
||||||
|
assertTrue(extValues.get(0).getValue() instanceof StringDt);
|
||||||
|
assertEquals("http://acme.org/extension", extValues.get(0).getUrl());
|
||||||
|
assertEquals("modifiedValue", ((StringDt) (extValues.get(0).getValue())).getValueAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetValuesWithWantedClassAndTheCreate() {
|
||||||
|
Patient p = new Patient();
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
List<IPrimitiveType> values = ourCtx.newTerser().getValues(p, "Patient.active", IPrimitiveType.class, true);
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof BooleanDt);
|
||||||
|
assertNull(((BooleanDt) values.get(0)).getValue());
|
||||||
|
|
||||||
|
List<ExtensionDt> extValues = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/extension')", ExtensionDt.class, true);
|
||||||
|
assertEquals(1, extValues.size());
|
||||||
|
assertEquals("http://acme.org/extension", extValues.get(0).getUrl());
|
||||||
|
assertNull(extValues.get(0).getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetValuesWithTheCreate() {
|
||||||
|
Patient p = new Patient();
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
List<Object> values = ourCtx.newTerser().getValues(p, "Patient.active", true);
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IPrimitiveType);
|
||||||
|
assertTrue(values.get(0) instanceof BooleanDt);
|
||||||
|
assertNull(((BooleanDt) values.get(0)).getValue());
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/extension')", true);
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof ExtensionDt);
|
||||||
|
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(0)).getUrl());
|
||||||
|
assertNull(((ExtensionDt) values.get(0)).getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetValuesWithTheCreateAndNoOverwrite() {
|
||||||
|
Patient p = new Patient();
|
||||||
|
p.setActive(true);
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/extension", new StringDt("value"));
|
||||||
|
p.addUndeclaredExtension(false, "http://acme.org/otherExtension", new StringDt("otherValue"));
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
List<Object> values = ourCtx.newTerser().getValues(p, "Patient.active", true);
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IPrimitiveType);
|
||||||
|
assertTrue(values.get(0) instanceof BooleanDt);
|
||||||
|
assertTrue(((BooleanDt) values.get(0)).getValue());
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/extension')");
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof ExtensionDt);
|
||||||
|
assertEquals("http://acme.org/extension", ((ExtensionDt) values.get(0)).getUrl());
|
||||||
|
assertEquals("value", ((StringDt) ((ExtensionDt) values.get(0)).getValue()).getValueAsString());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testVisitWithModelVisitor2() {
|
public void testVisitWithModelVisitor2() {
|
||||||
IModelVisitor2 visitor = mock(IModelVisitor2.class);
|
IModelVisitor2 visitor = mock(IModelVisitor2.class);
|
||||||
|
|
|
@ -179,9 +179,9 @@ public class FhirTerserDstu3Test {
|
||||||
p.addExtension()
|
p.addExtension()
|
||||||
.setUrl("http://acme.org/otherExtension")
|
.setUrl("http://acme.org/otherExtension")
|
||||||
.setValue(new StringType("otherValue"));
|
.setValue(new StringType("otherValue"));
|
||||||
// p.addModifierExtension()
|
p.addModifierExtension()
|
||||||
// .setUrl("http://acme.org/extension")
|
.setUrl("http://acme.org/modifierExtension")
|
||||||
// .setValue(new StringType("modifierValue"));
|
.setValue(new StringType("modifierValue"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -198,12 +198,12 @@ public class FhirTerserDstu3Test {
|
||||||
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/extension')");
|
values = ourCtx.newTerser().getValues(p, "Patient.modifierExtension('http://acme.org/modifierExtension')");
|
||||||
// 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/modifierExtension", ((Extension) values.get(0)).getUrl());
|
||||||
// assertEquals("value", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
assertEquals("modifierValue", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -216,6 +216,9 @@ public class FhirTerserDstu3Test {
|
||||||
p.addExtension()
|
p.addExtension()
|
||||||
.setUrl("http://acme.org/otherExtension")
|
.setUrl("http://acme.org/otherExtension")
|
||||||
.setValue(new StringType("otherValue"));
|
.setValue(new StringType("otherValue"));
|
||||||
|
p.addModifierExtension()
|
||||||
|
.setUrl("http://acme.org/modifierExtension")
|
||||||
|
.setValue(new StringType("modifierValue"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -252,6 +255,68 @@ public class FhirTerserDstu3Test {
|
||||||
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("modifiedValue", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
assertEquals("modifiedValue", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.modifierExtension('http://acme.org/modifierExtension')");
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
|
assertEquals("http://acme.org/modifierExtension", ((Extension) values.get(0)).getUrl());
|
||||||
|
assertEquals("modifierValue", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
((Extension) values.get(0)).setValue(new StringType("modifiedModifierValue"));
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.modifierExtension('http://acme.org/modifierExtension')");
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
|
assertEquals("http://acme.org/modifierExtension", ((Extension) values.get(0)).getUrl());
|
||||||
|
assertEquals("modifiedModifierValue", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetValuesMultiple() {
|
||||||
|
Patient p = new Patient();
|
||||||
|
p.addExtension()
|
||||||
|
.setUrl("http://acme.org/extension")
|
||||||
|
.setValue(new StringType("value1"));
|
||||||
|
p.addExtension()
|
||||||
|
.setUrl("http://acme.org/extension")
|
||||||
|
.setValue(new StringType("value2"));
|
||||||
|
p.addExtension()
|
||||||
|
.setUrl("http://acme.org/otherExtension")
|
||||||
|
.setValue(new StringType("otherValue"));
|
||||||
|
p.addModifierExtension()
|
||||||
|
.setUrl("http://acme.org/modifierExtension")
|
||||||
|
.setValue(new StringType("modifierValue1"));
|
||||||
|
p.addModifierExtension()
|
||||||
|
.setUrl("http://acme.org/modifierExtension")
|
||||||
|
.setValue(new StringType("modifierValue2"));
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
List<Object> values = ourCtx.newTerser().getValues(p, "Patient.extension('http://acme.org/extension')");
|
||||||
|
assertEquals(2, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
|
assertEquals("http://acme.org/extension", ((Extension) values.get(0)).getUrl());
|
||||||
|
assertEquals("value1", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
||||||
|
assertTrue(values.get(1) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(1) instanceof Extension);
|
||||||
|
assertEquals("http://acme.org/extension", ((Extension) values.get(1)).getUrl());
|
||||||
|
assertEquals("value2", ((StringType) ((Extension) values.get(1)).getValue()).getValueAsString());
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.modifierExtension('http://acme.org/modifierExtension')");
|
||||||
|
assertEquals(2, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
|
assertEquals("http://acme.org/modifierExtension", ((Extension) values.get(0)).getUrl());
|
||||||
|
assertEquals("modifierValue1", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
||||||
|
assertTrue(values.get(1) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(1) instanceof Extension);
|
||||||
|
assertEquals("http://acme.org/modifierExtension", ((Extension) values.get(1)).getUrl());
|
||||||
|
assertEquals("modifierValue2", ((StringType) ((Extension) values.get(1)).getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -264,6 +329,9 @@ public class FhirTerserDstu3Test {
|
||||||
p.addExtension()
|
p.addExtension()
|
||||||
.setUrl("http://acme.org/otherExtension")
|
.setUrl("http://acme.org/otherExtension")
|
||||||
.setValue(new StringType("otherValue"));
|
.setValue(new StringType("otherValue"));
|
||||||
|
p.addModifierExtension()
|
||||||
|
.setUrl("http://acme.org/modifierExtension")
|
||||||
|
.setValue(new StringType("modifierValue"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -277,6 +345,12 @@ public class FhirTerserDstu3Test {
|
||||||
assertTrue(extValues.get(0).getValue() instanceof StringType);
|
assertTrue(extValues.get(0).getValue() instanceof StringType);
|
||||||
assertEquals("http://acme.org/extension", extValues.get(0).getUrl());
|
assertEquals("http://acme.org/extension", extValues.get(0).getUrl());
|
||||||
assertEquals("value", ((StringType) (extValues.get(0).getValue())).getValueAsString());
|
assertEquals("value", ((StringType) (extValues.get(0).getValue())).getValueAsString());
|
||||||
|
|
||||||
|
extValues = ourCtx.newTerser().getValues(p, "Patient.modifierExtension('http://acme.org/modifierExtension')", Extension.class);
|
||||||
|
assertEquals(1, extValues.size());
|
||||||
|
assertTrue(extValues.get(0).getValue() instanceof StringType);
|
||||||
|
assertEquals("http://acme.org/modifierExtension", extValues.get(0).getUrl());
|
||||||
|
assertEquals("modifierValue", ((StringType) (extValues.get(0).getValue())).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -289,6 +363,9 @@ public class FhirTerserDstu3Test {
|
||||||
p.addExtension()
|
p.addExtension()
|
||||||
.setUrl("http://acme.org/otherExtension")
|
.setUrl("http://acme.org/otherExtension")
|
||||||
.setValue(new StringType("otherValue"));
|
.setValue(new StringType("otherValue"));
|
||||||
|
p.addModifierExtension()
|
||||||
|
.setUrl("http://acme.org/modifierExtension")
|
||||||
|
.setValue(new StringType("modifierValue"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -321,6 +398,22 @@ public class FhirTerserDstu3Test {
|
||||||
assertTrue(extValues.get(0).getValue() instanceof StringType);
|
assertTrue(extValues.get(0).getValue() instanceof StringType);
|
||||||
assertEquals("http://acme.org/extension", extValues.get(0).getUrl());
|
assertEquals("http://acme.org/extension", extValues.get(0).getUrl());
|
||||||
assertEquals("modifiedValue", ((StringType) (extValues.get(0).getValue())).getValueAsString());
|
assertEquals("modifiedValue", ((StringType) (extValues.get(0).getValue())).getValueAsString());
|
||||||
|
|
||||||
|
extValues = ourCtx.newTerser().getValues(p, "Patient.modifierExtension('http://acme.org/modifierExtension')", Extension.class);
|
||||||
|
assertEquals(1, extValues.size());
|
||||||
|
assertTrue(extValues.get(0).getValue() instanceof StringType);
|
||||||
|
assertEquals("http://acme.org/modifierExtension", extValues.get(0).getUrl());
|
||||||
|
assertEquals("modifierValue", ((StringType) (extValues.get(0).getValue())).getValueAsString());
|
||||||
|
|
||||||
|
extValues.get(0).setValue(new StringType("modifiedModifierValue"));
|
||||||
|
|
||||||
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
extValues = ourCtx.newTerser().getValues(p, "Patient.modifierExtension('http://acme.org/modifierExtension')", Extension.class);
|
||||||
|
assertEquals(1, extValues.size());
|
||||||
|
assertTrue(extValues.get(0).getValue() instanceof StringType);
|
||||||
|
assertEquals("http://acme.org/modifierExtension", extValues.get(0).getUrl());
|
||||||
|
assertEquals("modifiedModifierValue", ((StringType) (extValues.get(0).getValue())).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -338,6 +431,11 @@ public class FhirTerserDstu3Test {
|
||||||
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.modifierExtension('http://acme.org/modifierExtension')", Extension.class, true);
|
||||||
|
assertEquals(1, extValues.size());
|
||||||
|
assertEquals("http://acme.org/modifierExtension", extValues.get(0).getUrl());
|
||||||
|
assertNull(extValues.get(0).getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -358,6 +456,13 @@ public class FhirTerserDstu3Test {
|
||||||
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());
|
||||||
assertNull(((Extension) values.get(0)).getValue());
|
assertNull(((Extension) values.get(0)).getValue());
|
||||||
|
|
||||||
|
values = ourCtx.newTerser().getValues(p, "Patient.modifierExtension('http://acme.org/modifierExtension')", true);
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
|
assertEquals("http://acme.org/modifierExtension", ((Extension) values.get(0)).getUrl());
|
||||||
|
assertNull(((Extension) values.get(0)).getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -370,6 +475,9 @@ public class FhirTerserDstu3Test {
|
||||||
p.addExtension()
|
p.addExtension()
|
||||||
.setUrl("http://acme.org/otherExtension")
|
.setUrl("http://acme.org/otherExtension")
|
||||||
.setValue(new StringType("otherValue"));
|
.setValue(new StringType("otherValue"));
|
||||||
|
p.addModifierExtension()
|
||||||
|
.setUrl("http://acme.org/modifierExtension")
|
||||||
|
.setValue(new StringType("modifierValue"));
|
||||||
|
|
||||||
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
System.out.println(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p));
|
||||||
|
|
||||||
|
@ -385,6 +493,13 @@ public class FhirTerserDstu3Test {
|
||||||
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')");
|
||||||
|
assertEquals(1, values.size());
|
||||||
|
assertTrue(values.get(0) instanceof IBaseExtension);
|
||||||
|
assertTrue(values.get(0) instanceof Extension);
|
||||||
|
assertEquals("http://acme.org/modifierExtension", ((Extension) values.get(0)).getUrl());
|
||||||
|
assertEquals("modifierValue", ((StringType) ((Extension) values.get(0)).getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue