Still not working
This commit is contained in:
parent
8d322c373c
commit
87d4eb7c90
|
@ -1,49 +1,54 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry including="**/*.java" kind="src" path="src/main/java"/>
|
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
|
||||||
<classpathentry kind="src" path="src/test/java"/>
|
<classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
|
||||||
|
<classpathentry kind="src" path="src/main/java" including="**/*.java"/>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
<classpathentry kind="var" path="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar" sourcepath="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2-sources.jar"/>
|
<classpathentry kind="var" path="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar" sourcepath="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/commons-io/commons-io/1.3.2/commons-io-1.3.2.jar" sourcepath="M2_REPO/commons-io/commons-io/1.3.2/commons-io-1.3.2-sources.jar">
|
||||||
|
<attributes>
|
||||||
|
<attribute value="jar:file:/Users/james/.m2/repository/commons-io/commons-io/1.3.2/commons-io-1.3.2-javadoc.jar!/" name="javadoc_location"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1.jar" sourcepath="M2_REPO/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1-sources.jar">
|
<classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1.jar" sourcepath="M2_REPO/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1-sources.jar">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1-javadoc.jar!/"/>
|
<attribute value="jar:file:/Users/james/.m2/repository/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1-javadoc.jar!/" name="javadoc_location"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="var" path="M2_REPO/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar" sourcepath="M2_REPO/com/google/code/gson/gson/2.2.4/gson-2.2.4-sources.jar">
|
<classpathentry kind="var" path="M2_REPO/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar" sourcepath="M2_REPO/com/google/code/gson/gson/2.2.4/gson-2.2.4-sources.jar">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4-javadoc.jar!/"/>
|
<attribute value="jar:file:/Users/james/.m2/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4-javadoc.jar!/" name="javadoc_location"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar">
|
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-javadoc.jar!/"/>
|
<attribute value="jar:file:/Users/james/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-javadoc.jar!/" name="javadoc_location"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="var" path="M2_REPO/junit/junit/4.11/junit-4.11.jar" sourcepath="M2_REPO/junit/junit/4.11/junit-4.11-sources.jar">
|
<classpathentry kind="var" path="M2_REPO/junit/junit/4.11/junit-4.11.jar" sourcepath="M2_REPO/junit/junit/4.11/junit-4.11-sources.jar">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/junit/junit/4.11/junit-4.11-javadoc.jar!/"/>
|
<attribute value="jar:file:/Users/james/.m2/repository/junit/junit/4.11/junit-4.11-javadoc.jar!/" name="javadoc_location"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="var" path="M2_REPO/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1.jar" sourcepath="M2_REPO/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1-sources.jar">
|
<classpathentry kind="var" path="M2_REPO/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1.jar" sourcepath="M2_REPO/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1-sources.jar">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1-javadoc.jar!/"/>
|
<attribute value="jar:file:/Users/james/.m2/repository/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1-javadoc.jar!/" name="javadoc_location"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="var" path="M2_REPO/ch/qos/logback/logback-core/1.1.1/logback-core-1.1.1.jar" sourcepath="M2_REPO/ch/qos/logback/logback-core/1.1.1/logback-core-1.1.1-sources.jar">
|
<classpathentry kind="var" path="M2_REPO/ch/qos/logback/logback-core/1.1.1/logback-core-1.1.1.jar" sourcepath="M2_REPO/ch/qos/logback/logback-core/1.1.1/logback-core-1.1.1-sources.jar">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/ch/qos/logback/logback-core/1.1.1/logback-core-1.1.1-javadoc.jar!/"/>
|
<attribute value="jar:file:/Users/james/.m2/repository/ch/qos/logback/logback-core/1.1.1/logback-core-1.1.1-javadoc.jar!/" name="javadoc_location"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6-sources.jar">
|
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6-sources.jar">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6-javadoc.jar!/"/>
|
<attribute value="jar:file:/Users/james/.m2/repository/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6-javadoc.jar!/" name="javadoc_location"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/stax2-api/3.1.1/stax2-api-3.1.1.jar" sourcepath="M2_REPO/org/codehaus/woodstox/stax2-api/3.1.1/stax2-api-3.1.1-sources.jar"/>
|
<classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/stax2-api/3.1.1/stax2-api-3.1.1.jar" sourcepath="M2_REPO/org/codehaus/woodstox/stax2-api/3.1.1/stax2-api-3.1.1-sources.jar"/>
|
||||||
<classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0.jar" sourcepath="M2_REPO/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0-sources.jar">
|
<classpathentry kind="var" path="M2_REPO/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0.jar" sourcepath="M2_REPO/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0-sources.jar">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0-javadoc.jar!/"/>
|
<attribute value="jar:file:/Users/james/.m2/repository/org/codehaus/woodstox/woodstox-core-asl/4.2.0/woodstox-core-asl-4.2.0-javadoc.jar!/" name="javadoc_location"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
|
||||||
</classpath>
|
</classpath>
|
|
@ -57,6 +57,12 @@
|
||||||
<version>4.11</version>
|
<version>4.11</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>1.3.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.IDatatype;
|
||||||
|
|
||||||
|
public abstract class BaseRuntimeChildDatatypeDefinition extends BaseRuntimeChildDefinition {
|
||||||
|
|
||||||
|
private Class<? extends IDatatype> myDatatype;
|
||||||
|
|
||||||
|
public BaseRuntimeChildDatatypeDefinition(Field theField, String theElementName, int theMin, int theMax, Class<? extends IDatatype> theDatatype) {
|
||||||
|
super(theField, theMin, theMax, theElementName);
|
||||||
|
|
||||||
|
myDatatype = theDatatype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<? extends IDatatype> getDatatype() {
|
||||||
|
return myDatatype;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,33 +3,38 @@ package ca.uhn.fhir.context;
|
||||||
import static org.apache.commons.lang3.StringUtils.*;
|
import static org.apache.commons.lang3.StringUtils.*;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class BaseRuntimeChildDefinition {
|
public abstract class BaseRuntimeChildDefinition {
|
||||||
|
|
||||||
private String myElementName;
|
|
||||||
private Field myField;
|
private Field myField;
|
||||||
private int myMin;
|
private int myMin;
|
||||||
private int myMax;
|
private int myMax;
|
||||||
|
private String myElementName;
|
||||||
|
|
||||||
BaseRuntimeChildDefinition(Field theField, String theElementName, int theMin, int theMax) throws ConfigurationException {
|
BaseRuntimeChildDefinition(Field theField, int theMin, int theMax, String theElementName) throws ConfigurationException {
|
||||||
super();
|
super();
|
||||||
if (theField == null) {
|
if (theField == null) {
|
||||||
throw new IllegalArgumentException("No field speficied");
|
throw new IllegalArgumentException("No field speficied");
|
||||||
}
|
}
|
||||||
if (isBlank(theElementName)) {
|
|
||||||
throw new ConfigurationException("Element name can not be blank");
|
|
||||||
}
|
|
||||||
if (theMin < 0) {
|
if (theMin < 0) {
|
||||||
throw new ConfigurationException("Min must be >= 0");
|
throw new ConfigurationException("Min must be >= 0");
|
||||||
}
|
}
|
||||||
if (theMax != -1 && theMax < theMin) {
|
if (theMax != -1 && theMax < theMin) {
|
||||||
throw new ConfigurationException("Max must be >= Min (unless it is -1 / unlimited)");
|
throw new ConfigurationException("Max must be >= Min (unless it is -1 / unlimited)");
|
||||||
}
|
}
|
||||||
|
if (isBlank(theElementName)) {
|
||||||
|
throw new ConfigurationException("Element name must not be blank");
|
||||||
|
}
|
||||||
|
|
||||||
myField=theField;
|
myField=theField;
|
||||||
myElementName = theElementName;
|
|
||||||
myMin=theMin;
|
myMin=theMin;
|
||||||
myMax=theMax;
|
myMax=theMax;
|
||||||
|
myElementName = theElementName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getElementName() {
|
||||||
|
return myElementName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMin() {
|
public int getMin() {
|
||||||
|
@ -44,8 +49,8 @@ public class BaseRuntimeChildDefinition {
|
||||||
return myField;
|
return myField;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getElementName() {
|
public abstract Set<String> getValidChildNames();
|
||||||
return myElementName;
|
|
||||||
}
|
public abstract BaseRuntimeElementDefinition<?> getChildByName(String theName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
package ca.uhn.fhir.context;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.ICompositeElement;
|
|
||||||
|
|
||||||
public class BaseRuntimeCompositeElementDefinition<T extends ICompositeElement> extends BaseRuntimeElementDefinition<T> {
|
|
||||||
|
|
||||||
private ArrayList<BaseRuntimeChildDefinition> myChildren = new ArrayList<BaseRuntimeChildDefinition>();
|
|
||||||
|
|
||||||
public BaseRuntimeCompositeElementDefinition(String theName, Class<? extends T> theImplementingClass) {
|
|
||||||
super(theName, theImplementingClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addChild(BaseRuntimeChildDefinition theNext) {
|
|
||||||
myChildren.add(theNext);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.ICompositeElement;
|
||||||
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
|
|
||||||
|
public class BaseRuntimeElementCompositeDefinition<T extends ICompositeElement> extends BaseRuntimeElementDefinition<T> {
|
||||||
|
|
||||||
|
private ArrayList<BaseRuntimeChildDefinition> myChildren = new ArrayList<BaseRuntimeChildDefinition>();
|
||||||
|
private Map<String, BaseRuntimeChildDefinition> myNameToChild=new HashMap<String, BaseRuntimeChildDefinition>();
|
||||||
|
|
||||||
|
public BaseRuntimeElementCompositeDefinition(String theName, Class<? extends T> theImplementingClass) {
|
||||||
|
super(theName, theImplementingClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addChild(BaseRuntimeChildDefinition theNext) {
|
||||||
|
myChildren.add(theNext);
|
||||||
|
myNameToChild.put(theNext.getElementName(), theNext);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseRuntimeChildDefinition getChildByNameOrThrowDataFormatException(String theName) throws DataFormatException {
|
||||||
|
BaseRuntimeChildDefinition retVal = myNameToChild.get(theName);
|
||||||
|
if (retVal==null) {
|
||||||
|
throw new DataFormatException("Unknown child name: " + theName);
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,21 @@
|
||||||
package ca.uhn.fhir.context;
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
|
||||||
public class FhirContext {
|
public class FhirContext {
|
||||||
|
|
||||||
private ModelScanner myModelScanner;
|
private final Map<String, BaseRuntimeElementDefinition<?>> myNameToElementDefinition;
|
||||||
|
|
||||||
public FhirContext(Class<? extends IResource>... theResourceTypes) {
|
public FhirContext(Class<? extends IResource>... theResourceTypes) {
|
||||||
|
ModelScanner scanner = new ModelScanner(theResourceTypes);
|
||||||
|
myNameToElementDefinition = Collections.unmodifiableMap(scanner.getNameToElementDefinitions());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, BaseRuntimeElementDefinition<?>> getNameToElementDefinition() {
|
||||||
|
return myNameToElementDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,9 @@ package ca.uhn.fhir.context;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.*;
|
import static org.apache.commons.lang3.StringUtils.*;
|
||||||
|
|
||||||
import java.beans.BeanDescriptor;
|
|
||||||
import java.beans.IntrospectionException;
|
|
||||||
import java.beans.PropertyDescriptor;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -15,13 +12,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import com.ctc.wstx.util.StringUtil;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.CodeableConceptElement;
|
import ca.uhn.fhir.model.api.CodeableConceptElement;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
|
||||||
import ca.uhn.fhir.model.api.ICodeEnum;
|
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||||
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
||||||
import ca.uhn.fhir.model.api.ICompositeElement;
|
import ca.uhn.fhir.model.api.ICompositeElement;
|
||||||
|
@ -29,22 +20,28 @@ import ca.uhn.fhir.model.api.IDatatype;
|
||||||
import ca.uhn.fhir.model.api.IElement;
|
import ca.uhn.fhir.model.api.IElement;
|
||||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.model.api.ResourceChoiceElement;
|
|
||||||
import ca.uhn.fhir.model.api.ResourceElement;
|
|
||||||
import ca.uhn.fhir.model.api.ResourceReference;
|
import ca.uhn.fhir.model.api.ResourceReference;
|
||||||
import ca.uhn.fhir.model.api.ResourceReferenceElement;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.ChildResource;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Choice;
|
||||||
import ca.uhn.fhir.model.resource.ResourceDefinition;
|
import ca.uhn.fhir.model.resource.ResourceDefinition;
|
||||||
|
|
||||||
class ModelScanner {
|
class ModelScanner {
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ModelScanner.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ModelScanner.class);
|
||||||
|
|
||||||
private Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> myClassToResourceDefinitions = new HashMap<Class<? extends IElement>, BaseRuntimeElementDefinition<?>>();
|
private Map<Class<? extends IElement>, BaseRuntimeElementDefinition<?>> myClassToResourceDefinitions = new HashMap<Class<? extends IElement>, BaseRuntimeElementDefinition<?>>();
|
||||||
private Map<String, BaseRuntimeElementDefinition<?>> myNameToResourceDefinitions = new HashMap<String, BaseRuntimeElementDefinition<?>>();
|
private Map<String, RuntimeResourceDefinition> myNameToElementDefinitions = new HashMap<String, RuntimeResourceDefinition>();
|
||||||
|
private Set<Class<? extends IElement>> myScanAlso = new HashSet<Class<? extends IElement>>();
|
||||||
|
|
||||||
// private Map<String, RuntimeResourceDefinition>
|
// private Map<String, RuntimeResourceDefinition>
|
||||||
// myNameToDatatypeDefinitions = new HashMap<String,
|
// myNameToDatatypeDefinitions = new HashMap<String,
|
||||||
// RuntimeDatatypeDefinition>();
|
// RuntimeDatatypeDefinition>();
|
||||||
|
|
||||||
|
public Map<String, RuntimeResourceDefinition> getNameToResourceDefinitions() {
|
||||||
|
return (myNameToElementDefinitions);
|
||||||
|
}
|
||||||
|
|
||||||
ModelScanner(Class<? extends IResource>... theResourceTypes) throws ConfigurationException {
|
ModelScanner(Class<? extends IResource>... theResourceTypes) throws ConfigurationException {
|
||||||
for (Class<? extends IResource> nextClass : theResourceTypes) {
|
for (Class<? extends IResource> nextClass : theResourceTypes) {
|
||||||
scan(nextClass);
|
scan(nextClass);
|
||||||
|
@ -67,7 +64,7 @@ class ModelScanner {
|
||||||
return scanResource(resClass, resourceDefinition);
|
return scanResource(resClass, resourceDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
DatatypeDefinition datatypeDefinition = theClass.getAnnotation(DatatypeDefinition.class);
|
Datatype datatypeDefinition = theClass.getAnnotation(Datatype.class);
|
||||||
if (datatypeDefinition != null) {
|
if (datatypeDefinition != null) {
|
||||||
if (ICompositeDatatype.class.isAssignableFrom(theClass)) {
|
if (ICompositeDatatype.class.isAssignableFrom(theClass)) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -78,14 +75,14 @@ class ModelScanner {
|
||||||
Class<? extends IPrimitiveDatatype> resClass = (Class<? extends IPrimitiveDatatype>) theClass;
|
Class<? extends IPrimitiveDatatype> resClass = (Class<? extends IPrimitiveDatatype>) theClass;
|
||||||
return scanPrimitiveDatatype(resClass, datatypeDefinition);
|
return scanPrimitiveDatatype(resClass, datatypeDefinition);
|
||||||
} else {
|
} else {
|
||||||
throw new ConfigurationException("Resource type contains a @" + DatatypeDefinition.class.getSimpleName() + " annotation but does not implement " + IDatatype.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
throw new ConfigurationException("Resource type contains a @" + Datatype.class.getSimpleName() + " annotation but does not implement " + IDatatype.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ConfigurationException("Resource type does not contain a @" + ResourceDefinition.class.getSimpleName() + " annotation or a @" + DatatypeDefinition.class.getSimpleName() + " annotation: " + theClass.getCanonicalName());
|
throw new ConfigurationException("Resource type does not contain a @" + ResourceDefinition.class.getSimpleName() + " annotation or a @" + Datatype.class.getSimpleName() + " annotation: " + theClass.getCanonicalName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String scanCompositeDatatype(Class<? extends ICompositeDatatype> theClass, DatatypeDefinition theDatatypeDefinition) {
|
private String scanCompositeDatatype(Class<? extends ICompositeDatatype> theClass, Datatype theDatatypeDefinition) {
|
||||||
ourLog.debug("Scanning resource class: {}", theClass.getName());
|
ourLog.debug("Scanning resource class: {}", theClass.getName());
|
||||||
|
|
||||||
String resourceName = theDatatypeDefinition.name();
|
String resourceName = theDatatypeDefinition.name();
|
||||||
|
@ -93,23 +90,23 @@ class ModelScanner {
|
||||||
throw new ConfigurationException("Resource type @" + ResourceDefinition.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
|
throw new ConfigurationException("Resource type @" + ResourceDefinition.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myNameToResourceDefinitions.containsKey(resourceName)) {
|
if (myNameToElementDefinitions.containsKey(resourceName)) {
|
||||||
if (!myNameToResourceDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
|
if (!myNameToElementDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
|
||||||
throw new ConfigurationException("Detected duplicate element name '" + resourceName + "' in types '" + theClass.getCanonicalName() + "' and '" + myNameToResourceDefinitions.get(resourceName).getImplementingClass() + "'");
|
throw new ConfigurationException("Detected duplicate element name '" + resourceName + "' in types '" + theClass.getCanonicalName() + "' and '" + myNameToElementDefinitions.get(resourceName).getImplementingClass() + "'");
|
||||||
}
|
}
|
||||||
return resourceName;
|
return resourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
RuntimeCompositeDatatypeDefinition resourceDef = new RuntimeCompositeDatatypeDefinition(resourceName, theClass);
|
RuntimeCompositeDatatypeDefinition resourceDef = new RuntimeCompositeDatatypeDefinition(resourceName, theClass);
|
||||||
myClassToResourceDefinitions.put(theClass, resourceDef);
|
myClassToResourceDefinitions.put(theClass, resourceDef);
|
||||||
myNameToResourceDefinitions.put(resourceName, resourceDef);
|
myNameToElementDefinitions.put(resourceName, resourceDef);
|
||||||
|
|
||||||
scanCompositeElementForChildren(theClass, resourceDef);
|
scanCompositeElementForChildren(theClass, resourceDef);
|
||||||
|
|
||||||
return resourceName;
|
return resourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String scanPrimitiveDatatype(Class<? extends IPrimitiveDatatype> theClass, DatatypeDefinition theDatatypeDefinition) {
|
private String scanPrimitiveDatatype(Class<? extends IPrimitiveDatatype> theClass, Datatype theDatatypeDefinition) {
|
||||||
ourLog.debug("Scanning resource class: {}", theClass.getName());
|
ourLog.debug("Scanning resource class: {}", theClass.getName());
|
||||||
|
|
||||||
String resourceName = theDatatypeDefinition.name();
|
String resourceName = theDatatypeDefinition.name();
|
||||||
|
@ -117,16 +114,16 @@ class ModelScanner {
|
||||||
throw new ConfigurationException("Resource type @" + ResourceDefinition.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
|
throw new ConfigurationException("Resource type @" + ResourceDefinition.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myNameToResourceDefinitions.containsKey(resourceName)) {
|
if (myNameToElementDefinitions.containsKey(resourceName)) {
|
||||||
if (!myNameToResourceDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
|
if (!myNameToElementDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
|
||||||
throw new ConfigurationException("Detected duplicate element name '" + resourceName + "' in types '" + theClass.getCanonicalName() + "' and '" + myNameToResourceDefinitions.get(resourceName).getImplementingClass() + "'");
|
throw new ConfigurationException("Detected duplicate element name '" + resourceName + "' in types '" + theClass.getCanonicalName() + "' and '" + myNameToElementDefinitions.get(resourceName).getImplementingClass() + "'");
|
||||||
}
|
}
|
||||||
return resourceName;
|
return resourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
RuntimePrimitiveDatatypeDefinition resourceDef = new RuntimePrimitiveDatatypeDefinition(resourceName, theClass);
|
RuntimePrimitiveDatatypeDefinition resourceDef = new RuntimePrimitiveDatatypeDefinition(resourceName, theClass);
|
||||||
myClassToResourceDefinitions.put(theClass, resourceDef);
|
myClassToResourceDefinitions.put(theClass, resourceDef);
|
||||||
myNameToResourceDefinitions.put(resourceName, resourceDef);
|
myNameToElementDefinitions.put(resourceName, resourceDef);
|
||||||
|
|
||||||
return resourceName;
|
return resourceName;
|
||||||
}
|
}
|
||||||
|
@ -139,27 +136,27 @@ class ModelScanner {
|
||||||
throw new ConfigurationException("Resource type @" + ResourceDefinition.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
|
throw new ConfigurationException("Resource type @" + ResourceDefinition.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myNameToResourceDefinitions.containsKey(resourceName)) {
|
if (myNameToElementDefinitions.containsKey(resourceName)) {
|
||||||
if (!myNameToResourceDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
|
if (!myNameToElementDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
|
||||||
throw new ConfigurationException("Detected duplicate element name '" + resourceName + "' in types '" + theClass.getCanonicalName() + "' and '" + myNameToResourceDefinitions.get(resourceName).getImplementingClass() + "'");
|
throw new ConfigurationException("Detected duplicate element name '" + resourceName + "' in types '" + theClass.getCanonicalName() + "' and '" + myNameToElementDefinitions.get(resourceName).getImplementingClass() + "'");
|
||||||
}
|
}
|
||||||
return resourceName;
|
return resourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
RuntimeResourceDefinition resourceDef = new RuntimeResourceDefinition(theClass, resourceName);
|
RuntimeResourceDefinition resourceDef = new RuntimeResourceDefinition(theClass, resourceName);
|
||||||
myClassToResourceDefinitions.put(theClass, resourceDef);
|
myClassToResourceDefinitions.put(theClass, resourceDef);
|
||||||
myNameToResourceDefinitions.put(resourceName, resourceDef);
|
myNameToElementDefinitions.put(resourceName, resourceDef);
|
||||||
|
|
||||||
scanCompositeElementForChildren(theClass, resourceDef);
|
scanCompositeElementForChildren(theClass, resourceDef);
|
||||||
|
|
||||||
return resourceName;
|
return resourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scanCompositeElementForChildren(Class<? extends ICompositeElement> theClass, BaseRuntimeCompositeElementDefinition<?> theDefinition) {
|
private void scanCompositeElementForChildren(Class<? extends ICompositeElement> theClass, BaseRuntimeElementCompositeDefinition<?> theDefinition) {
|
||||||
Set<String> elementNames = new HashSet<String>();
|
Set<String> elementNames = new HashSet<String>();
|
||||||
Map<Integer, BaseRuntimeChildDefinition> orderToElementDef = new HashMap<Integer, BaseRuntimeChildDefinition>();
|
Map<Integer, BaseRuntimeChildDefinition> orderToElementDef = new HashMap<Integer, BaseRuntimeChildDefinition>();
|
||||||
for (Field next : theClass.getFields()) {
|
for (Field next : theClass.getFields()) {
|
||||||
ResourceElement element = next.getAnnotation(ResourceElement.class);
|
Child element = next.getAnnotation(Child.class);
|
||||||
if (element == null) {
|
if (element == null) {
|
||||||
ourLog.debug("Ignoring non-type field: " + next.getName());
|
ourLog.debug("Ignoring non-type field: " + next.getName());
|
||||||
continue;
|
continue;
|
||||||
|
@ -170,7 +167,7 @@ class ModelScanner {
|
||||||
int min = element.min();
|
int min = element.min();
|
||||||
int max = element.max();
|
int max = element.max();
|
||||||
|
|
||||||
ResourceChoiceElement choiceAttr = element.choice();
|
Choice choiceAttr = element.choice();
|
||||||
List<Class<? extends IElement>> choiceTypes = new ArrayList<Class<? extends IElement>>();
|
List<Class<? extends IElement>> choiceTypes = new ArrayList<Class<? extends IElement>>();
|
||||||
for (Class<? extends IElement> nextChoiceType : choiceAttr.types()) {
|
for (Class<? extends IElement> nextChoiceType : choiceAttr.types()) {
|
||||||
choiceTypes.add(nextChoiceType);
|
choiceTypes.add(nextChoiceType);
|
||||||
|
@ -184,54 +181,64 @@ class ModelScanner {
|
||||||
throw new ConfigurationException("Detected duplicate field name '" + elementName + "' in type '" + theClass.getCanonicalName() + "'");
|
throw new ConfigurationException("Detected duplicate field name '" + elementName + "' in type '" + theClass.getCanonicalName() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceReferenceElement resRefAnnotation = next.getAnnotation(ResourceReferenceElement.class);
|
ChildResource resRefAnnotation = next.getAnnotation(ChildResource.class);
|
||||||
if (choiceTypes.isEmpty() == false) {
|
if (choiceTypes.isEmpty() == false) {
|
||||||
|
/*
|
||||||
List<String> choiceNames = new ArrayList<String>();
|
* Child is a choice element
|
||||||
for (Class<? extends IElement> nextChoiceType : choiceTypes) {
|
*/
|
||||||
choiceNames.add(scan(nextChoiceType));
|
myScanAlso.addAll(choiceTypes);
|
||||||
}
|
RuntimeChildChoiceDefinition def = new RuntimeChildChoiceDefinition(next, elementName, min, max, choiceTypes);
|
||||||
|
|
||||||
RuntimeChildChoiceDefinition def = new RuntimeChildChoiceDefinition(next, elementName, min, max, choiceNames);
|
|
||||||
orderToElementDef.put(order, def);
|
orderToElementDef.put(order, def);
|
||||||
|
|
||||||
} else if (ResourceReference.class.isAssignableFrom(next.getType())) {
|
} else if (ResourceReference.class.isAssignableFrom(next.getType())) {
|
||||||
|
/*
|
||||||
|
* Child is a resource reference
|
||||||
|
*/
|
||||||
if (resRefAnnotation == null) {
|
if (resRefAnnotation == null) {
|
||||||
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is a resource reference but does not have a @" + ResourceReferenceElement.class.getSimpleName() + " annotation");
|
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is a resource reference but does not have a @" + ChildResource.class.getSimpleName() + " annotation");
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<? extends IResource> refType = resRefAnnotation.type();
|
Class<? extends IResource>[] refType = resRefAnnotation.types();
|
||||||
String elementResourceName = scan(refType);
|
List<Class<? extends IResource>> refTypesList = Arrays.asList(refType);
|
||||||
|
myScanAlso.addAll(refTypesList);
|
||||||
if (!(myNameToResourceDefinitions.get(elementResourceName) instanceof IResource)) {
|
RuntimeChildResourceDefinition def = new RuntimeChildResourceDefinition(next, elementName, min, max, refTypesList);
|
||||||
throw new ConfigurationException("Resource reference '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is a resource reference but references a non-resource type: "
|
|
||||||
+ myNameToResourceDefinitions.get(elementResourceName).getClass().getCanonicalName());
|
|
||||||
}
|
|
||||||
|
|
||||||
RuntimeChildResourceDefinition def = new RuntimeChildResourceDefinition(next, elementName, elementResourceName, min, max);
|
|
||||||
orderToElementDef.put(order, def);
|
orderToElementDef.put(order, def);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (resRefAnnotation != null) {
|
if (resRefAnnotation != null) {
|
||||||
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is not a resource reference but has a @" + ResourceReferenceElement.class.getSimpleName() + " annotation");
|
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is not a resource reference but has a @" + ChildResource.class.getSimpleName() + " annotation");
|
||||||
}
|
}
|
||||||
if (!IDatatype.class.isAssignableFrom(next.getType())) {
|
if (!IDatatype.class.isAssignableFrom(next.getType())) {
|
||||||
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is not a resource reference and is not an instance of type " + IDatatype.class.getName());
|
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is not a resource reference and is not an instance of type " + IDatatype.class.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeableConceptElement concept = next.getAnnotation(CodeableConceptElement.class);
|
|
||||||
if (concept != null) {
|
|
||||||
Class<? extends ICodeEnum> codeType = concept.type();
|
|
||||||
String codeTableName = scanCodeTable(codeType);
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
String datatypeName = scan((Class<? extends IDatatype>) next.getType());
|
Class<? extends IDatatype> nextDatatype = (Class<? extends IDatatype>) next.getType();
|
||||||
RuntimeChildDatatypeDefinition def = new RuntimeChildCodedDatatypeDefinition(next, elementName, datatypeName, min, max, codeTableName);
|
|
||||||
orderToElementDef.put(order, def);
|
CodeableConceptElement concept = next.getAnnotation(CodeableConceptElement.class);
|
||||||
|
|
||||||
|
if (IPrimitiveDatatype.class.isAssignableFrom(next.getType())) {
|
||||||
|
myScanAlso.add(nextDatatype);
|
||||||
|
RuntimeChildPrimitiveDatatypeDefinition def = new RuntimeChildPrimitiveDatatypeDefinition(next, elementName, datatypeName, min, max);
|
||||||
}else {
|
}else {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
String datatypeName = scan((Class<? extends IDatatype>) next.getType());
|
String datatypeName = scan(nextDatatype);
|
||||||
RuntimeChildDatatypeDefinition def = new RuntimeChildDatatypeDefinition(next, elementName, datatypeName, min, max);
|
RuntimeChildCompositeDatatypeDefinition def = new RuntimeChildCompositeDatatypeDefinition(next, elementName, datatypeName, min, max, datatypeName);
|
||||||
orderToElementDef.put(order, def);
|
orderToElementDef.put(order, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: handle codes
|
||||||
|
// if (concept != null) {
|
||||||
|
// Class<? extends ICodeEnum> codeType = concept.type();
|
||||||
|
// String codeTableName = scanCodeTable(codeType);
|
||||||
|
// @SuppressWarnings("unchecked")
|
||||||
|
// String datatypeName = scan((Class<? extends IDatatype>) next.getType());
|
||||||
|
// RuntimeChildCompositeDatatypeDefinition def = new RuntimeChildCompositeDatatypeDefinition(next, elementName, datatypeName, min, max, codeTableName);
|
||||||
|
// orderToElementDef.put(order, def);
|
||||||
|
// } else {
|
||||||
|
// @SuppressWarnings("unchecked")
|
||||||
|
// orderToElementDef.put(order, def);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
elementNames.add(elementName);
|
elementNames.add(elementName);
|
||||||
|
|
|
@ -3,18 +3,20 @@ package ca.uhn.fhir.context;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.IElement;
|
||||||
|
|
||||||
public class RuntimeChildChoiceDefinition extends BaseRuntimeChildDefinition {
|
public class RuntimeChildChoiceDefinition extends BaseRuntimeChildDefinition {
|
||||||
|
|
||||||
private List<String> myChoices;
|
private List<Class<? extends IElement>> myChoiceTypes;
|
||||||
|
|
||||||
public RuntimeChildChoiceDefinition(Field theField, String theElementName, int theMin, int theMax, List<String> theChoiceNames) {
|
public RuntimeChildChoiceDefinition(Field theField, String theElementName, int theMin, int theMax, List<Class<? extends IElement>> theChoiceTypes) {
|
||||||
super(theField, theElementName,theMin,theMax);
|
super(theField, theMin,theMax, theElementName);
|
||||||
|
|
||||||
myChoices= theChoiceNames;
|
myChoiceTypes= theChoiceTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getChoices() {
|
public List<Class<? extends IElement>> getChoices() {
|
||||||
return myChoices;
|
return myChoiceTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
package ca.uhn.fhir.context;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
public class RuntimeChildCodedDatatypeDefinition extends RuntimeChildDatatypeDefinition {
|
|
||||||
|
|
||||||
private String myTableName;
|
|
||||||
|
|
||||||
public RuntimeChildCodedDatatypeDefinition(Field theField, String theElementName, String theDatatypeName, int theMin, int theMax, String theTableName) {
|
|
||||||
super(theField, theElementName,theDatatypeName, theMin,theMax);
|
|
||||||
|
|
||||||
myTableName = theTableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTableName() {
|
|
||||||
return myTableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.IDatatype;
|
||||||
|
|
||||||
|
public class RuntimeChildCompositeDatatypeDefinition extends BaseRuntimeChildDatatypeDefinition {
|
||||||
|
|
||||||
|
public RuntimeChildCompositeDatatypeDefinition(Field theField, String theElementName, String theDatatypeName, int theMin, int theMax, Class<? extends IDatatype> theDatatype) {
|
||||||
|
super(theField, theElementName, theMin,theMax,theDatatype);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,19 +0,0 @@
|
||||||
package ca.uhn.fhir.context;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
public class RuntimeChildDatatypeDefinition extends BaseRuntimeChildDefinition {
|
|
||||||
|
|
||||||
private String myDatatypeName;
|
|
||||||
|
|
||||||
public RuntimeChildDatatypeDefinition(Field theField, String theElementName, String theDatatypeName, int theMin, int theMax) {
|
|
||||||
super(theField, theElementName,theMin,theMax);
|
|
||||||
|
|
||||||
myDatatypeName = theDatatypeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDatatypeName() {
|
|
||||||
return myDatatypeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.IDatatype;
|
||||||
|
|
||||||
|
public class RuntimeChildPrimitiveDatatypeDefinition extends BaseRuntimeChildDatatypeDefinition {
|
||||||
|
|
||||||
|
public RuntimeChildPrimitiveDatatypeDefinition(Field theField, String theElementName, int theMin, int theMax, Class<? extends IDatatype> theDatatype) {
|
||||||
|
super(theField, theElementName, theMin,theMax, theDatatype);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,19 +1,39 @@
|
||||||
package ca.uhn.fhir.context;
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
|
||||||
public class RuntimeChildResourceDefinition extends BaseRuntimeChildDefinition {
|
public class RuntimeChildResourceDefinition extends BaseRuntimeChildDefinition {
|
||||||
|
|
||||||
private String myResourceName;
|
private String myResourceName;
|
||||||
|
private Set<String> myValidChildNames;
|
||||||
|
private List<Class<? extends IResource>> myChildTypes;
|
||||||
|
|
||||||
public RuntimeChildResourceDefinition(Field theField, String theElementName, String theResourceName, int theMin, int theMax) {
|
public RuntimeChildResourceDefinition(Field theField, String theElementName, int theMin, int theMax, List<Class<? extends IResource>> theChildTypes) {
|
||||||
super(theField, theElementName,theMin,theMax);
|
super(theField, theMin,theMax, theElementName);
|
||||||
|
|
||||||
myResourceName = theResourceName;
|
myChildTypes = theChildTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResourceName() {
|
public String getResourceName() {
|
||||||
return myResourceName;
|
return myResourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getValidChildNames() {
|
||||||
|
return myValidChildNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseRuntimeElementDefinition<?> getChildByName(String theName) {
|
||||||
|
if (myElementName.equals(theName)) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package ca.uhn.fhir.context;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
||||||
|
|
||||||
public class RuntimeCompositeDatatypeDefinition extends BaseRuntimeCompositeElementDefinition<ICompositeDatatype> {
|
public class RuntimeCompositeDatatypeDefinition extends BaseRuntimeElementCompositeDefinition<ICompositeDatatype> {
|
||||||
|
|
||||||
public RuntimeCompositeDatatypeDefinition(String theName, Class<? extends ICompositeDatatype> theImplementingClass) {
|
public RuntimeCompositeDatatypeDefinition(String theName, Class<? extends ICompositeDatatype> theImplementingClass) {
|
||||||
super(theName, theImplementingClass);
|
super(theName, theImplementingClass);
|
||||||
|
|
|
@ -2,10 +2,20 @@ package ca.uhn.fhir.context;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
|
||||||
public class RuntimeResourceDefinition extends BaseRuntimeCompositeElementDefinition<IResource> {
|
public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefinition<IResource> {
|
||||||
|
|
||||||
public RuntimeResourceDefinition(Class<? extends IResource> theClass, String theName) {
|
public RuntimeResourceDefinition(Class<? extends IResource> theClass, String theName) {
|
||||||
super(theName, theClass);
|
super(theName, theClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IResource newInstance() {
|
||||||
|
try {
|
||||||
|
return getImplementingClass().newInstance();
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
throw new ConfigurationException("Failed to instantiate type:"+getImplementingClass().getName(), e);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new ConfigurationException("Failed to instantiate type:"+getImplementingClass().getName(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package ca.uhn.fhir.model.api;
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.resource.BaseResource;
|
|
||||||
|
|
||||||
public class ResourceReference<T extends BaseResource> {
|
public class ResourceReference /*<T extends BaseResource>*/ {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package ca.uhn.fhir.model.api;
|
package ca.uhn.fhir.model.api.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
|
@ -7,7 +7,7 @@ import java.lang.annotation.Target;
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(value= {ElementType.FIELD})
|
@Target(value= {ElementType.FIELD})
|
||||||
public @interface ResourceElement {
|
public @interface Child {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant value to supply for {@link #order()} when the order is defined
|
* Constant value to supply for {@link #order()} when the order is defined
|
||||||
|
@ -23,6 +23,6 @@ public @interface ResourceElement {
|
||||||
|
|
||||||
int max() default 1;
|
int max() default 1;
|
||||||
|
|
||||||
ResourceChoiceElement choice() default @ResourceChoiceElement();
|
Choice choice() default @Choice();
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,14 +1,16 @@
|
||||||
package ca.uhn.fhir.model.api;
|
package ca.uhn.fhir.model.api.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(value= {ElementType.FIELD})
|
@Target(value= {ElementType.FIELD})
|
||||||
public @interface ResourceReferenceElement {
|
public @interface ChildResource {
|
||||||
|
|
||||||
Class<? extends IResource> type();
|
Class<? extends IResource>[] types();
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,13 +1,15 @@
|
||||||
package ca.uhn.fhir.model.api;
|
package ca.uhn.fhir.model.api.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.IDatatype;
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(value= {ElementType.FIELD})
|
@Target(value= {ElementType.FIELD})
|
||||||
public @interface ResourceChoiceElement {
|
public @interface Choice {
|
||||||
|
|
||||||
Class<? extends IDatatype>[] types() default {};
|
Class<? extends IDatatype>[] types() default {};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package ca.uhn.fhir.model.api;
|
package ca.uhn.fhir.model.api.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
|
@ -1,4 +1,4 @@
|
||||||
package ca.uhn.fhir.model.api;
|
package ca.uhn.fhir.model.api.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
|
@ -7,7 +7,7 @@ import java.lang.annotation.Target;
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(value= {ElementType.TYPE})
|
@Target(value= {ElementType.TYPE})
|
||||||
public @interface DatatypeDefinition {
|
public @interface Datatype {
|
||||||
|
|
||||||
String name();
|
String name();
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
package ca.uhn.fhir.model.datatype;
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
|
||||||
import ca.uhn.fhir.model.api.Description;
|
import ca.uhn.fhir.model.api.Description;
|
||||||
import ca.uhn.fhir.model.api.ResourceElement;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
|
|
||||||
@DatatypeDefinition(name="Attachment")
|
@Datatype(name="Attachment")
|
||||||
public class AttachmentDt extends BaseCompositeDatatype {
|
public class AttachmentDt extends BaseCompositeDatatype {
|
||||||
|
|
||||||
@ResourceElement(name="contentType", order=0, min=1)
|
@Child(name="contentType", order=0, min=1)
|
||||||
private CodeDt myContentType;
|
private CodeDt myContentType;
|
||||||
|
|
||||||
@ResourceElement(name="language", order=1)
|
@Child(name="language", order=1)
|
||||||
private CodeDt myLanguage;
|
private CodeDt myLanguage;
|
||||||
|
|
||||||
@ResourceElement(name="data", order=2)
|
@Child(name="data", order=2)
|
||||||
private Base64BinaryDt myData;
|
private Base64BinaryDt myData;
|
||||||
|
|
||||||
@ResourceElement(name="url", order=3)
|
@Child(name="url", order=3)
|
||||||
private UriDt myUrl;
|
private UriDt myUrl;
|
||||||
|
|
||||||
@ResourceElement(name="size", order=4)
|
@Child(name="size", order=4)
|
||||||
private IntegerDt mySize;
|
private IntegerDt mySize;
|
||||||
|
|
||||||
@ResourceElement(name="hash", order=5)
|
@Child(name="hash", order=5)
|
||||||
@Description("Hash of the data (sha-1, base64ed )")
|
@Description("Hash of the data (sha-1, base64ed )")
|
||||||
private Base64BinaryDt myHash;
|
private Base64BinaryDt myHash;
|
||||||
|
|
||||||
@ResourceElement(name="title", order=5)
|
@Child(name="title", order=5)
|
||||||
@Description("Label to display in place of the data")
|
@Description("Label to display in place of the data")
|
||||||
private StringDt myLabel;
|
private StringDt myLabel;
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package ca.uhn.fhir.model.datatype;
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
|
|
||||||
@DatatypeDefinition(name="base64Binary")
|
@Datatype(name="base64Binary")
|
||||||
public class Base64BinaryDt extends BasePrimitiveDatatype {
|
public class Base64BinaryDt extends BasePrimitiveDatatype {
|
||||||
|
|
||||||
private byte[] myValue;
|
private byte[] myValue;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package ca.uhn.fhir.model.datatype;
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
|
|
||||||
@DatatypeDefinition(name="boolean")
|
@Datatype(name="boolean")
|
||||||
public class BooleanDt extends BasePrimitiveDatatype {
|
public class BooleanDt extends BasePrimitiveDatatype {
|
||||||
|
|
||||||
private boolean myValue;
|
private boolean myValue;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package ca.uhn.fhir.model.datatype;
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
|
||||||
import ca.uhn.fhir.model.api.ICodeEnum;
|
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
|
|
||||||
@DatatypeDefinition(name="code")
|
@Datatype(name="code")
|
||||||
public class CodeDt<T extends ICodeEnum> extends BasePrimitiveDatatype {
|
public class CodeDt<T extends ICodeEnum> extends BasePrimitiveDatatype {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,16 +3,16 @@ package ca.uhn.fhir.model.datatype;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
|
||||||
import ca.uhn.fhir.model.api.ResourceElement;
|
|
||||||
import ca.uhn.fhir.model.api.ICodeEnum;
|
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
|
|
||||||
@DatatypeDefinition(name="CodeableConcept")
|
@Datatype(name="CodeableConcept")
|
||||||
public class CodeableConceptDt<T extends ICodeEnum> extends BaseCompositeDatatype {
|
public class CodeableConceptDt<T extends ICodeEnum> extends BaseCompositeDatatype {
|
||||||
|
|
||||||
@ResourceElement(name="coding", order=0)
|
@Child(name="coding", order=0)
|
||||||
private List<CodingDt> myCoding;
|
private List<CodingDt> myCoding;
|
||||||
|
|
||||||
@ResourceElement(name="text",order=1)
|
@Child(name="text",order=1)
|
||||||
private StringDt myText;
|
private StringDt myText;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
package ca.uhn.fhir.model.datatype;
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
|
||||||
import ca.uhn.fhir.model.api.ResourceElement;
|
|
||||||
import ca.uhn.fhir.model.api.ResourceReference;
|
import ca.uhn.fhir.model.api.ResourceReference;
|
||||||
import ca.uhn.fhir.model.api.ResourceReferenceElement;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.ChildResource;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
import ca.uhn.fhir.model.resource.ValueSet;
|
import ca.uhn.fhir.model.resource.ValueSet;
|
||||||
|
|
||||||
|
|
||||||
@DatatypeDefinition(name="Coding")
|
@Datatype(name="Coding")
|
||||||
public class CodingDt extends BaseCompositeDatatype {
|
public class CodingDt extends BaseCompositeDatatype {
|
||||||
|
|
||||||
@ResourceElement(name="system", order=0)
|
@Child(name="system", order=0)
|
||||||
private UriDt mySystem;
|
private UriDt mySystem;
|
||||||
|
|
||||||
@ResourceElement(name="version", order=1)
|
@Child(name="version", order=1)
|
||||||
private StringDt myVersion;
|
private StringDt myVersion;
|
||||||
|
|
||||||
@ResourceElement(name="code", order=2)
|
@Child(name="code", order=2)
|
||||||
private CodeDt<?> myCode;
|
private CodeDt<?> myCode;
|
||||||
|
|
||||||
@ResourceElement(name="display", order=3)
|
@Child(name="display", order=3)
|
||||||
private StringDt myDisplay;
|
private StringDt myDisplay;
|
||||||
|
|
||||||
@ResourceElement(name="primary", order=4)
|
@Child(name="primary", order=4)
|
||||||
private BooleanDt myPrimary;
|
private BooleanDt myPrimary;
|
||||||
|
|
||||||
@ResourceElement(name="valueSet", order=5)
|
@Child(name="valueSet", order=5)
|
||||||
@ResourceReferenceElement(type=ValueSet.class)
|
@ChildResource(types= {ValueSet.class})
|
||||||
private ResourceReference<ValueSet> myAssigner;
|
private ResourceReference myAssigner;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,10 @@ package ca.uhn.fhir.model.datatype;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BaseDatatype;
|
import ca.uhn.fhir.model.api.BaseDatatype;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
|
||||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
|
|
||||||
@DatatypeDefinition(name="date")
|
@Datatype(name="date")
|
||||||
public class DateDt extends BaseDatatype implements IPrimitiveDatatype {
|
public class DateDt extends BaseDatatype implements IPrimitiveDatatype {
|
||||||
|
|
||||||
private GregorianCalendar myValue;
|
private GregorianCalendar myValue;
|
||||||
|
|
|
@ -3,9 +3,9 @@ package ca.uhn.fhir.model.datatype;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
|
|
||||||
@DatatypeDefinition(name="dateTime")
|
@Datatype(name="dateTime")
|
||||||
public class DateTimeDt extends BasePrimitiveDatatype {
|
public class DateTimeDt extends BasePrimitiveDatatype {
|
||||||
|
|
||||||
private GregorianCalendar myValue;
|
private GregorianCalendar myValue;
|
||||||
|
|
|
@ -3,9 +3,9 @@ package ca.uhn.fhir.model.datatype;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
|
|
||||||
@DatatypeDefinition(name="decimal")
|
@Datatype(name="decimal")
|
||||||
public class DecimalDt extends BasePrimitiveDatatype {
|
public class DecimalDt extends BasePrimitiveDatatype {
|
||||||
|
|
||||||
private BigDecimal myValue;
|
private BigDecimal myValue;
|
||||||
|
|
|
@ -2,34 +2,34 @@ package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
||||||
import ca.uhn.fhir.model.api.CodeableConceptElement;
|
import ca.uhn.fhir.model.api.CodeableConceptElement;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
|
||||||
import ca.uhn.fhir.model.api.ResourceElement;
|
|
||||||
import ca.uhn.fhir.model.api.ResourceReference;
|
import ca.uhn.fhir.model.api.ResourceReference;
|
||||||
import ca.uhn.fhir.model.api.ResourceReferenceElement;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.ChildResource;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
import ca.uhn.fhir.model.enm.IdentifierUseEnum;
|
import ca.uhn.fhir.model.enm.IdentifierUseEnum;
|
||||||
import ca.uhn.fhir.model.resource.Organization;
|
import ca.uhn.fhir.model.resource.Organization;
|
||||||
|
|
||||||
@DatatypeDefinition(name="identifier")
|
@Datatype(name="identifier")
|
||||||
public class IdentifierDt extends BaseCompositeDatatype {
|
public class IdentifierDt extends BaseCompositeDatatype {
|
||||||
|
|
||||||
@ResourceElement(name="use", order=0)
|
@Child(name="use", order=0)
|
||||||
@CodeableConceptElement(type=IdentifierUseEnum.class)
|
@CodeableConceptElement(type=IdentifierUseEnum.class)
|
||||||
private CodeDt<IdentifierUseEnum> myUse;
|
private CodeDt<IdentifierUseEnum> myUse;
|
||||||
|
|
||||||
@ResourceElement(name="label", order=1)
|
@Child(name="label", order=1)
|
||||||
private StringDt myLabel;
|
private StringDt myLabel;
|
||||||
|
|
||||||
@ResourceElement(name="system", order=2)
|
@Child(name="system", order=2)
|
||||||
private UriDt mySystem;
|
private UriDt mySystem;
|
||||||
|
|
||||||
@ResourceElement(name="value", order=3)
|
@Child(name="value", order=3)
|
||||||
private StringDt myValue;
|
private StringDt myValue;
|
||||||
|
|
||||||
@ResourceElement(name="period", order=4)
|
@Child(name="period", order=4)
|
||||||
private PeriodDt myPeriod;
|
private PeriodDt myPeriod;
|
||||||
|
|
||||||
@ResourceElement(name="assigner", order=5)
|
@Child(name="assigner", order=5)
|
||||||
@ResourceReferenceElement(type=Organization.class)
|
@ChildResource(types= {Organization.class})
|
||||||
private ResourceReference<Organization> myAssigner;
|
private ResourceReference myAssigner;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ package ca.uhn.fhir.model.datatype;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
|
|
||||||
@DatatypeDefinition(name="instant")
|
@Datatype(name="instant")
|
||||||
public class InstantDt extends BasePrimitiveDatatype {
|
public class InstantDt extends BasePrimitiveDatatype {
|
||||||
|
|
||||||
private Date myValue;
|
private Date myValue;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package ca.uhn.fhir.model.datatype;
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
|
|
||||||
@DatatypeDefinition(name="integer")
|
@Datatype(name="integer")
|
||||||
public class IntegerDt extends BasePrimitiveDatatype {
|
public class IntegerDt extends BasePrimitiveDatatype {
|
||||||
|
|
||||||
private int myValue;
|
private int myValue;
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
package ca.uhn.fhir.model.datatype;
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
||||||
import ca.uhn.fhir.model.api.Constraint;
|
import ca.uhn.fhir.model.api.annotation.Constraint;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.ResourceElement;
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
|
|
||||||
@DatatypeDefinition(name="Period")
|
@Datatype(name="Period")
|
||||||
public class PeriodDt extends BaseCompositeDatatype {
|
public class PeriodDt extends BaseCompositeDatatype {
|
||||||
|
|
||||||
@ResourceElement(name="start", order=0)
|
@Child(name="start", order=0)
|
||||||
@Constraint(lessThan= {"end"})
|
@Constraint(lessThan= {"end"})
|
||||||
private DateTimeDt myStart;
|
private DateTimeDt myStart;
|
||||||
|
|
||||||
@ResourceElement(name="end", order=1)
|
@Child(name="end", order=1)
|
||||||
@Constraint(greaterThan= {"start"})
|
@Constraint(greaterThan= {"start"})
|
||||||
private DateTimeDt myEnd;
|
private DateTimeDt myEnd;
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
package ca.uhn.fhir.model.datatype;
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
||||||
import ca.uhn.fhir.model.api.Constraint;
|
import ca.uhn.fhir.model.api.annotation.Constraint;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.ResourceElement;
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
import ca.uhn.fhir.model.enm.QuantityComparator;
|
import ca.uhn.fhir.model.enm.QuantityComparator;
|
||||||
|
|
||||||
@DatatypeDefinition(name="Quantity")
|
@Datatype(name="Quantity")
|
||||||
public class QuantityDt extends BaseCompositeDatatype {
|
public class QuantityDt extends BaseCompositeDatatype {
|
||||||
|
|
||||||
@ResourceElement(name="value",order=0, min=0, max=1)
|
@Child(name="value",order=0, min=0, max=1)
|
||||||
private DecimalDt myValue;
|
private DecimalDt myValue;
|
||||||
|
|
||||||
@ResourceElement(name="comparator",order=1, min=0, max=1)
|
@Child(name="comparator",order=1, min=0, max=1)
|
||||||
private QuantityComparator myComparator;
|
private QuantityComparator myComparator;
|
||||||
|
|
||||||
@ResourceElement(name="units",order=2, min=0, max=1)
|
@Child(name="units",order=2, min=0, max=1)
|
||||||
private StringDt myUnits;
|
private StringDt myUnits;
|
||||||
|
|
||||||
@ResourceElement(name="system",order=3, min=0, max=1)
|
@Child(name="system",order=3, min=0, max=1)
|
||||||
@Constraint(coRequirements= {"code"})
|
@Constraint(coRequirements= {"code"})
|
||||||
private UriDt mySystem;
|
private UriDt mySystem;
|
||||||
|
|
||||||
@ResourceElement(name="code",order=4, min=0, max=1)
|
@Child(name="code",order=4, min=0, max=1)
|
||||||
@Constraint(coRequirements= {"system"})
|
@Constraint(coRequirements= {"system"})
|
||||||
private CodeDt myCode;
|
private CodeDt myCode;
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
package ca.uhn.fhir.model.datatype;
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
||||||
import ca.uhn.fhir.model.api.Constraint;
|
import ca.uhn.fhir.model.api.annotation.Constraint;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.api.ResourceElement;
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
|
|
||||||
@DatatypeDefinition(name="Ratio")
|
@Datatype(name="Ratio")
|
||||||
public class RatioDt extends BaseCompositeDatatype {
|
public class RatioDt extends BaseCompositeDatatype {
|
||||||
|
|
||||||
@ResourceElement(name="numerator", order=0)
|
@Child(name="numerator", order=0)
|
||||||
@Constraint(coRequirements= {"denominator"})
|
@Constraint(coRequirements= {"denominator"})
|
||||||
private QuantityDt myNumerator;
|
private QuantityDt myNumerator;
|
||||||
|
|
||||||
@ResourceElement(name="denominator", order=1)
|
@Child(name="denominator", order=1)
|
||||||
@Constraint(coRequirements= {"numerator"})
|
@Constraint(coRequirements= {"numerator"})
|
||||||
private QuantityDt myDenominator;
|
private QuantityDt myDenominator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
package ca.uhn.fhir.model.datatype;
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
|
||||||
import ca.uhn.fhir.model.api.ResourceElement;
|
|
||||||
import ca.uhn.fhir.model.api.Description;
|
import ca.uhn.fhir.model.api.Description;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
|
|
||||||
@DatatypeDefinition(name="SampledData")
|
@Datatype(name="SampledData")
|
||||||
public class SampledDataDt extends BaseCompositeDatatype {
|
public class SampledDataDt extends BaseCompositeDatatype {
|
||||||
|
|
||||||
@ResourceElement(name="origin", order=0, min=1)
|
@Child(name="origin", order=0, min=1)
|
||||||
private QuantityDt myOrigin;
|
private QuantityDt myOrigin;
|
||||||
|
|
||||||
@ResourceElement(name="period", order=1, min=1)
|
@Child(name="period", order=1, min=1)
|
||||||
private DecimalDt myPeriod;
|
private DecimalDt myPeriod;
|
||||||
|
|
||||||
@ResourceElement(name="factor", order=2)
|
@Child(name="factor", order=2)
|
||||||
private DecimalDt myFactor;
|
private DecimalDt myFactor;
|
||||||
|
|
||||||
@ResourceElement(name="lowerLimit", order=3)
|
@Child(name="lowerLimit", order=3)
|
||||||
private DecimalDt myLowerLimit;
|
private DecimalDt myLowerLimit;
|
||||||
|
|
||||||
@ResourceElement(name="upperLimit", order=4)
|
@Child(name="upperLimit", order=4)
|
||||||
private DecimalDt myUpperLimit;
|
private DecimalDt myUpperLimit;
|
||||||
|
|
||||||
@ResourceElement(name="dimensions", order=5, min=1)
|
@Child(name="dimensions", order=5, min=1)
|
||||||
private IntegerDt myDimensions;
|
private IntegerDt myDimensions;
|
||||||
|
|
||||||
@ResourceElement(name="data", order=6, min=1)
|
@Child(name="data", order=6, min=1)
|
||||||
@Description("Decimal values with spaces, or \"E\" | \"U\" | \"L\"")
|
@Description("Decimal values with spaces, or \"E\" | \"U\" | \"L\"")
|
||||||
private StringDt myData;
|
private StringDt myData;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package ca.uhn.fhir.model.datatype;
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
|
|
||||||
@DatatypeDefinition(name="string")
|
@Datatype(name="string")
|
||||||
public class StringDt extends BasePrimitiveDatatype {
|
public class StringDt extends BasePrimitiveDatatype {
|
||||||
|
|
||||||
private String myValue;
|
private String myValue;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package ca.uhn.fhir.model.datatype;
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.BaseDatatype;
|
import ca.uhn.fhir.model.api.BaseDatatype;
|
||||||
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
|
||||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Datatype;
|
||||||
|
|
||||||
@DatatypeDefinition(name="uri")
|
@Datatype(name="uri")
|
||||||
public class UriDt extends BaseDatatype implements IPrimitiveDatatype {
|
public class UriDt extends BaseDatatype implements IPrimitiveDatatype {
|
||||||
|
|
||||||
private String myValue;
|
private String myValue;
|
||||||
|
|
|
@ -3,6 +3,9 @@ package ca.uhn.fhir.model.resource;
|
||||||
import ca.uhn.fhir.model.api.BaseElement;
|
import ca.uhn.fhir.model.api.BaseElement;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
|
||||||
public class BaseResource extends BaseElement implements IResource {
|
public abstract class BaseResource extends BaseElement implements IResource {
|
||||||
|
|
||||||
|
// public abstract void setAllChildValues(List<IElement> theChildren);
|
||||||
|
//
|
||||||
|
// public abstract List<IElement> getAllChildValues();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package ca.uhn.fhir.model.resource;
|
package ca.uhn.fhir.model.resource;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.ResourceElement;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
import ca.uhn.fhir.model.datatype.IdentifierDt;
|
import ca.uhn.fhir.model.datatype.IdentifierDt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classes extending this class must be annotated with
|
* Classes extending this class must be annotated with
|
||||||
*/
|
*/
|
||||||
public class BaseResourceWithIdentifier extends BaseResource {
|
public abstract class BaseResourceWithIdentifier extends BaseResource {
|
||||||
|
|
||||||
@ResourceElement(name="identifier", order=ResourceElement.ORDER_UNKNOWN)
|
@Child(name="identifier", order=Child.ORDER_UNKNOWN)
|
||||||
private IdentifierDt myIdentifier;
|
private IdentifierDt myIdentifier;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package ca.uhn.fhir.model.resource;
|
||||||
|
|
||||||
|
public class Group extends BaseResource {
|
||||||
|
|
||||||
|
}
|
|
@ -2,8 +2,10 @@ package ca.uhn.fhir.model.resource;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.api.CodeableConceptElement;
|
import ca.uhn.fhir.model.api.CodeableConceptElement;
|
||||||
import ca.uhn.fhir.model.api.IDatatype;
|
import ca.uhn.fhir.model.api.IDatatype;
|
||||||
import ca.uhn.fhir.model.api.ResourceChoiceElement;
|
import ca.uhn.fhir.model.api.ResourceReference;
|
||||||
import ca.uhn.fhir.model.api.ResourceElement;
|
import ca.uhn.fhir.model.api.annotation.Child;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.ChildResource;
|
||||||
|
import ca.uhn.fhir.model.api.annotation.Choice;
|
||||||
import ca.uhn.fhir.model.datatype.AttachmentDt;
|
import ca.uhn.fhir.model.datatype.AttachmentDt;
|
||||||
import ca.uhn.fhir.model.datatype.CodeableConceptDt;
|
import ca.uhn.fhir.model.datatype.CodeableConceptDt;
|
||||||
import ca.uhn.fhir.model.datatype.DateTimeDt;
|
import ca.uhn.fhir.model.datatype.DateTimeDt;
|
||||||
|
@ -22,11 +24,11 @@ import ca.uhn.fhir.model.enm.ObservationStatusEnum;
|
||||||
@ResourceDefinition(name="Observation", identifierOrder=10)
|
@ResourceDefinition(name="Observation", identifierOrder=10)
|
||||||
public class Observation extends BaseResourceWithIdentifier {
|
public class Observation extends BaseResourceWithIdentifier {
|
||||||
|
|
||||||
@ResourceElement(name="name", order=0, min=1, max=1)
|
@Child(name="name", order=0, min=1, max=1)
|
||||||
@CodeableConceptElement(type=ObservationCodesEnum.class)
|
@CodeableConceptElement(type=ObservationCodesEnum.class)
|
||||||
private CodeableConceptDt<ObservationCodesEnum> myName;
|
private CodeableConceptDt<ObservationCodesEnum> myName;
|
||||||
|
|
||||||
@ResourceElement(name="value", order=1, min=0, max=1, choice=@ResourceChoiceElement(types= {
|
@Child(name="value", order=1, min=0, max=1, choice=@Choice(types= {
|
||||||
QuantityDt.class,
|
QuantityDt.class,
|
||||||
CodeableConceptDt.class,
|
CodeableConceptDt.class,
|
||||||
AttachmentDt.class,
|
AttachmentDt.class,
|
||||||
|
@ -37,37 +39,43 @@ public class Observation extends BaseResourceWithIdentifier {
|
||||||
}))
|
}))
|
||||||
private IDatatype myValue;
|
private IDatatype myValue;
|
||||||
|
|
||||||
@ResourceElement(name="interpretation", order=2)
|
@Child(name="interpretation", order=2)
|
||||||
@CodeableConceptElement(type=ObservationInterpretationEnum.class)
|
@CodeableConceptElement(type=ObservationInterpretationEnum.class)
|
||||||
private CodeableConceptDt<ObservationInterpretationEnum> myInterpretation;
|
private CodeableConceptDt<ObservationInterpretationEnum> myInterpretation;
|
||||||
|
|
||||||
@ResourceElement(name="comments", order=3)
|
@Child(name="comments", order=3)
|
||||||
private StringDt myComments;
|
private StringDt myComments;
|
||||||
|
|
||||||
@ResourceElement(name="applies", order=4, choice=@ResourceChoiceElement(types={
|
@Child(name="applies", order=4, choice=@Choice(types={
|
||||||
DateTimeDt.class,
|
DateTimeDt.class,
|
||||||
PeriodDt.class
|
PeriodDt.class
|
||||||
}))
|
}))
|
||||||
private IDatatype myApplies;
|
private IDatatype myApplies;
|
||||||
|
|
||||||
@ResourceElement(name="issued", order=5)
|
@Child(name="issued", order=5)
|
||||||
private InstantDt myIssued;
|
private InstantDt myIssued;
|
||||||
|
|
||||||
@ResourceElement(name="status", order=6, min=1)
|
@Child(name="status", order=6, min=1)
|
||||||
@CodeableConceptElement(type=ObservationStatusEnum.class)
|
@CodeableConceptElement(type=ObservationStatusEnum.class)
|
||||||
private CodeableConceptDt<ObservationStatusEnum> myStatus;
|
private CodeableConceptDt<ObservationStatusEnum> myStatus;
|
||||||
|
|
||||||
@ResourceElement(name="reliability", order=7, min=1)
|
@Child(name="reliability", order=7, min=1)
|
||||||
@CodeableConceptElement(type=ObservationStatusEnum.class)
|
@CodeableConceptElement(type=ObservationStatusEnum.class)
|
||||||
private CodeableConceptDt<ObservationStatusEnum> myReliability;
|
private CodeableConceptDt<ObservationStatusEnum> myReliability;
|
||||||
|
|
||||||
@ResourceElement(name="bodySite", order=8)
|
@Child(name="bodySite", order=8)
|
||||||
@CodeableConceptElement(type=BodySiteEnum.class)
|
@CodeableConceptElement(type=BodySiteEnum.class)
|
||||||
private CodeableConceptDt<BodySiteEnum> myBodySite;
|
private CodeableConceptDt<BodySiteEnum> myBodySite;
|
||||||
|
|
||||||
@ResourceElement(name="method", order=9)
|
@Child(name="method", order=9)
|
||||||
@CodeableConceptElement(type=ObservationMethodEnum.class)
|
@CodeableConceptElement(type=ObservationMethodEnum.class)
|
||||||
private CodeableConceptDt<ObservationMethodEnum> myMethod;
|
private CodeableConceptDt<ObservationMethodEnum> myMethod;
|
||||||
|
|
||||||
|
@Child(name="subject", order=11)
|
||||||
|
@ChildResource(types= {
|
||||||
|
Patient.class, Group.class // TODO: add device, location
|
||||||
|
})
|
||||||
|
private ResourceReference mySubject;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package ca.uhn.fhir.model.resource;
|
||||||
|
|
||||||
|
public class Patient extends BaseResource {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package ca.uhn.fhir.parser;
|
||||||
|
|
||||||
|
public class DataFormatException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public DataFormatException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataFormatException(String theMessage) {
|
||||||
|
super(theMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataFormatException(String theMessage, Throwable theCause) {
|
||||||
|
super(theMessage, theCause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataFormatException(Throwable theCause) {
|
||||||
|
super(theCause);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
package ca.uhn.fhir.parser;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||||
|
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
|
||||||
|
class ParserState {
|
||||||
|
|
||||||
|
private FhirContext myContext;
|
||||||
|
private BaseState myState;
|
||||||
|
|
||||||
|
public ParserState(FhirContext theContext) {
|
||||||
|
myContext=theContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ParserState getResourceInstance(FhirContext theContext, String theLocalPart) throws DataFormatException {
|
||||||
|
BaseRuntimeElementDefinition<?> definition = theContext.getNameToElementDefinition().get(theLocalPart);
|
||||||
|
if (!(definition instanceof RuntimeResourceDefinition)) {
|
||||||
|
throw new DataFormatException("Element '" + theLocalPart + "' is not a resource, expected a resource at this position");
|
||||||
|
}
|
||||||
|
|
||||||
|
RuntimeResourceDefinition def = (RuntimeResourceDefinition) definition;
|
||||||
|
IResource instance = def.newInstance();
|
||||||
|
|
||||||
|
ParserState retVal = new ParserState(theContext);
|
||||||
|
retVal.setState(retVal.new ResourceParserState(def, instance));
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setState(BaseState theState) {
|
||||||
|
myState = theState;
|
||||||
|
}
|
||||||
|
|
||||||
|
private abstract class BaseState
|
||||||
|
{
|
||||||
|
private BaseState myStack;
|
||||||
|
|
||||||
|
public abstract void enteringNewElement(String theLocalPart) throws DataFormatException;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ResourceParserState extends BaseState
|
||||||
|
{
|
||||||
|
|
||||||
|
private RuntimeResourceDefinition myResourceDefinition;
|
||||||
|
private IResource myInstance;
|
||||||
|
|
||||||
|
public ResourceParserState(RuntimeResourceDefinition theDef, IResource theInstance) {
|
||||||
|
myResourceDefinition = theDef;
|
||||||
|
myInstance = theInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enteringNewElement(String theChildName) throws DataFormatException {
|
||||||
|
// BaseRuntimeChildDefinition child = myResourceDefinition.getChildByNameOrThrowDataFormatException(theChildName);
|
||||||
|
// switch (child.getChildType()) {
|
||||||
|
// case CHOICE:
|
||||||
|
// break;
|
||||||
|
// case COMPOSITE:
|
||||||
|
// break;
|
||||||
|
// case PRIMITIVE:
|
||||||
|
// break;
|
||||||
|
// case RESOURCE:
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enteringNewElement(String theLocalPart) throws DataFormatException {
|
||||||
|
myState.enteringNewElement(theLocalPart);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
package ca.uhn.fhir.parser;
|
||||||
|
|
||||||
|
import java.io.StringReader;
|
||||||
|
|
||||||
|
import javax.xml.stream.FactoryConfigurationError;
|
||||||
|
import javax.xml.stream.XMLEventFactory;
|
||||||
|
import javax.xml.stream.XMLEventReader;
|
||||||
|
import javax.xml.stream.XMLInputFactory;
|
||||||
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
import javax.xml.stream.events.StartElement;
|
||||||
|
import javax.xml.stream.events.XMLEvent;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
|
||||||
|
public class XmlParser {
|
||||||
|
private static final String FHIR_NS = "http://hl7.org/fhir";
|
||||||
|
|
||||||
|
private FhirContext myContext;
|
||||||
|
private XMLInputFactory myXmlInputFactory;
|
||||||
|
private XMLEventFactory myEventFactory;
|
||||||
|
|
||||||
|
public XmlParser(FhirContext theContext) {
|
||||||
|
myContext = theContext;
|
||||||
|
myXmlInputFactory = XMLInputFactory.newInstance();
|
||||||
|
myEventFactory = XMLEventFactory.newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IResource parseResource(String theXml) throws ConfigurationException, DataFormatException {
|
||||||
|
XMLEventReader streamReader;
|
||||||
|
try {
|
||||||
|
streamReader = myXmlInputFactory.createXMLEventReader(new StringReader(theXml));
|
||||||
|
} catch (XMLStreamException e) {
|
||||||
|
throw new DataFormatException(e);
|
||||||
|
} catch (FactoryConfigurationError e) {
|
||||||
|
throw new ConfigurationException("Failed to initialize STaX event factory", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ParserState parserState = null;
|
||||||
|
while (streamReader.hasNext()) {
|
||||||
|
XMLEvent nextEvent = streamReader.nextEvent();
|
||||||
|
if (nextEvent.isStartElement()) {
|
||||||
|
StartElement elem = nextEvent.asStartElement();
|
||||||
|
if (!FHIR_NS.equals(elem.getName().getNamespaceURI())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parserState == null) {
|
||||||
|
parserState = ParserState.getResourceInstance(myContext, elem.getName().getLocalPart());
|
||||||
|
} else {
|
||||||
|
parserState.enteringNewElement(elem.getName().getLocalPart());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} catch (XMLStreamException e) {
|
||||||
|
throw new DataFormatException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package ca.uhn.fhir.parser;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.ConfigurationException;
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.model.resource.Observation;
|
||||||
|
|
||||||
|
public class XmlParserTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLoadObservation() throws ConfigurationException, DataFormatException, IOException {
|
||||||
|
|
||||||
|
FhirContext ctx = new FhirContext(Observation.class);
|
||||||
|
XmlParser p = new XmlParser(ctx);
|
||||||
|
|
||||||
|
p.parseResource(IOUtils.toString(XmlParserTest.class.getResourceAsStream("/observation-example-eeg.xml")));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
This example is taken from the v3 data types (SLIST)
|
||||||
|
-->
|
||||||
|
|
||||||
|
<Observation xmlns="http://hl7.org/fhir" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hl7.org/fhir ..\..\schema\observation.xsd">
|
||||||
|
<text>
|
||||||
|
<status value="generated"/>
|
||||||
|
<div xmlns="http://www.w3.org/1999/xhtml">Sept 17, 2012: Systolic Blood pressure 107 mmHg (normal)</div>
|
||||||
|
</text>
|
||||||
|
<name>
|
||||||
|
<!-- Actually, this is not a vull EEG. A todo is to turn it into one -->
|
||||||
|
<coding>
|
||||||
|
<system value="http://loinc.org"/>
|
||||||
|
<code value="11523-8"/>
|
||||||
|
<display value="EEG study"/>
|
||||||
|
</coding>
|
||||||
|
</name>
|
||||||
|
<valueSampledData>
|
||||||
|
<origin>
|
||||||
|
<value value="0"/>
|
||||||
|
<units value="μV"/>
|
||||||
|
<system value="http://unitsofmeasure.org"/>
|
||||||
|
<code value="uV"/>
|
||||||
|
</origin>
|
||||||
|
<period value="100"/>
|
||||||
|
<factor value="2.5"/>
|
||||||
|
<dimensions value="1"/>
|
||||||
|
<data value="-4 -13 -18 -18 -18 -17 -16 -16 -16 -16 -16 -17 -18 -18 -1 -17 -16 -16 -16 -15 -13 -11 -10 -10 -9 -6 -4 -5 -5 -3 -2 -2 -1 1 2 7 8 9 10 11 12 13 15 17 19 21 23 25 27 29 30 30 31 34 37 40 43 45 4 46 46 46 46 47 49 51 53 55 57 59 60 59 58 58 58 57 56 56 56 57 57 5 53 50 47 45 74 51 38 33 31 2 25 21 16 14 15 13 9 7 4 1 -1 -3 -4 -6 -10 -12 -13 -12 -12 -17 -18 -18 -18 -19 -20 -21 -20 -20 -20 -20 -2 2 1 0 0 0 1 2 2 1 1 1 0 -1 0 1 1 1 1 2 E"/>
|
||||||
|
</valueSampledData>
|
||||||
|
|
||||||
|
<status value="final"/>
|
||||||
|
<reliability value="ok"/>
|
||||||
|
|
||||||
|
|
||||||
|
<subject>
|
||||||
|
<reference value="Patient/example"/>
|
||||||
|
</subject>
|
||||||
|
</Observation>
|
|
@ -0,0 +1 @@
|
||||||
|
{"resourceType":"Observation","text":{"status":"generated","div":"<div>\n <p>\n <b>Generated Narrative</b>\n </p>\n <p>\n <b>name</b>: \n <span title=\"Codes: {http://loinc.org 2339-0}\">Glucose [Mass/volume] in Blood</span>\n </p>\n <p>\n <b>value</b>: 6.3 mmol/l\n </p>\n <p>\n <b>interpretation</b>: \n <span title=\"Codes: {http://hl7.org/fhir/v2/0078 A}\">abnormal</span>\n </p>\n <p>\n <b>applies</b>: 2-Apr 2013 9:30 --> 5-Apr 2013 9:30\n </p>\n <p>\n <b>issued</b>: 3-Apr 2013 15:30\n </p>\n <p>\n <b>status</b>: final_\n </p>\n <p>\n <b>reliability</b>: ok\n </p>\n <p>\n <b>bodySite</b>: \n <span title=\"Codes: {http://snomed.info/sct 308046002}\">Superficial forearm vein</span>\n </p>\n <p>\n <b>method</b>: \n <span title=\"Codes: {http://snomed.info/sct 120220003}\">Injection to forearm</span>\n </p>\n <p>\n <b>identifier</b>: 6323 (official)\n </p>\n <p>\n <b>subject</b>: P. van de Heuvel\n </p>\n <p>\n <b>performer</b>: A. Langeveld\n </p>\n <h3>ReferenceRanges</h3>\n <table class=\"grid\">\n <tr>\n <td>\n <b>Low</b>\n </td>\n <td>\n <b>High</b>\n </td>\n <td>\n <b>Meaning</b>\n </td>\n <td>\n <b>Age</b>\n </td>\n </tr>\n <tr>\n <td>3.1 mmol/l</td>\n <td>6.2 mmol/l</td>\n <td> </td>\n <td> </td>\n </tr>\n </table>\n </div>"},"name":{"coding":[{"system":"http://loinc.org","code":"2339-0","display":"Glucose [Mass/volume] in Blood"}]},"valueQuantity":{"value":6.3,"units":"mmol/l","system":"http://unitsofmeasure.org","code":"mmol/l"},"interpretation":{"coding":[{"system":"http://hl7.org/fhir/v2/0078","code":"A","display":"abnormal"}]},"appliesPeriod":{"start":"2013-04-02T09:30:10+01:00","end":"2013-04-05T09:30:10+01:00"},"issued":"2013-04-03T15:30:10+01:00","status":"final","reliability":"ok","bodySite":{"coding":[{"system":"http://snomed.info/sct","code":"308046002","display":"Superficial forearm vein"}]},"method":{"coding":[{"system":"http://snomed.info/sct","code":"120220003","display":"Injection to forearm"}]},"identifier":{"use":"official","system":"http://www.bmc.nl/zorgportal/identifiers/observations","value":"6323"},"subject":{"reference":"Patient/f001","display":"P. van de Heuvel"},"performer":[{"reference":"Practitioner/f005","display":"A. Langeveld"}],"referenceRange":[{"low":{"value":3.1,"units":"mmol/l","system":"http://unitsofmeasure.org","code":"mmol/l"},"high":{"value":6.2,"units":"mmol/l","system":"http://unitsofmeasure.org","code":"mmol/l"}}]}
|
|
@ -0,0 +1 @@
|
||||||
|
{"resourceType":"Observation","text":{"status":"generated","div":"<div>\n <p>\n <b>Generated Narrative</b>\n </p>\n <p>\n <b>name</b>: \n <span title=\"Codes: {http://snomed.info/sct 365756002}\">Creatinine level</span>\n </p>\n <p>\n <b>value</b>: 122 umol/L\n </p>\n <p>\n <b>interpretation</b>: \n <span title=\"Codes: {http://snomed.info/sct 166717003}, {http://hl7.org/fhir/v2/0078 H}\">Serum creatinine raised</span>\n </p>\n <p>\n <b>issued</b>: 4-Apr 2013 14:34\n </p>\n <p>\n <b>status</b>: final_\n </p>\n <p>\n <b>reliability</b>: ok\n </p>\n <p>\n <b>method</b>: \n <span title=\"Codes: {http://snomed.info/sct 113075003}\">Creatinine measurement, serum</span>\n </p>\n <p>\n <b>identifier</b>: Creatinine value of Roel on April 2013 - 03720 = 1304-03720-Creatinine\n </p>\n <p>\n <b>subject</b>: Roel\n </p>\n <p>\n <b>performer</b>: Luigi Maas\n </p>\n <h3>ReferenceRanges</h3>\n <table class=\"grid\">\n <tr>\n <td>\n <b>Low</b>\n </td>\n <td>\n <b>High</b>\n </td>\n <td>\n <b>Meaning</b>\n </td>\n <td>\n <b>Age</b>\n </td>\n </tr>\n <tr>\n <td>64 null</td>\n <td>104 null</td>\n <td>\n <span title=\"Codes: {http://hl7.org/fhir/referencerange-meaning normal}\">Normal Range</span>\n </td>\n <td> </td>\n </tr>\n </table>\n </div>"},"name":{"coding":[{"system":"http://snomed.info/sct","code":"365756002","display":"Creatinine level"}]},"valueQuantity":{"value":122,"units":"umol/L","system":"http://snomed.info/sct","code":"258814008"},"interpretation":{"coding":[{"system":"http://snomed.info/sct","code":"166717003","display":"Serum creatinine raised"},{"system":"http://hl7.org/fhir/v2/0078","code":"H"}]},"issued":"2013-04-04T14:34:00+01:00","status":"final","reliability":"ok","method":{"coding":[{"system":"http://snomed.info/sct","code":"113075003","display":"Creatinine measurement, serum"}]},"identifier":{"label":"Creatinine value of Roel on April 2013 - 03720","system":"https://intranet.aumc.nl/labvalues","value":"1304-03720-Creatinine"},"subject":{"reference":"Patient/f201","display":"Roel"},"performer":[{"reference":"Practitioner/f202","display":"Luigi Maas"}],"referenceRange":[{"low":{"value":64},"high":{"value":104},"meaning":{"coding":[{"system":"http://hl7.org/fhir/referencerange-meaning","code":"normal","display":"Normal Range"}]}}]}
|
Loading…
Reference in New Issue