Just starting
This commit is contained in:
commit
8d322c373c
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<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="bin"/>
|
||||||
|
</classpath>
|
|
@ -0,0 +1,2 @@
|
||||||
|
/bin
|
||||||
|
/target
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>hapi-fhir</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
|
@ -0,0 +1,11 @@
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry including="**/*.java" kind="src" path="src/main/java"/>
|
||||||
|
<classpathentry kind="src" path="src/test/java"/>
|
||||||
|
<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/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>
|
||||||
|
<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!/"/>
|
||||||
|
</attributes>
|
||||||
|
</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">
|
||||||
|
<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!/"/>
|
||||||
|
</attributes>
|
||||||
|
</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">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-javadoc.jar!/"/>
|
||||||
|
</attributes>
|
||||||
|
</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">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="javadoc_location" value="jar:file:/Users/james/.m2/repository/junit/junit/4.11/junit-4.11-javadoc.jar!/"/>
|
||||||
|
</attributes>
|
||||||
|
</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">
|
||||||
|
<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!/"/>
|
||||||
|
</attributes>
|
||||||
|
</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">
|
||||||
|
<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!/"/>
|
||||||
|
</attributes>
|
||||||
|
</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">
|
||||||
|
<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!/"/>
|
||||||
|
</attributes>
|
||||||
|
</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/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>
|
||||||
|
<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!/"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<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>
|
|
@ -0,0 +1,2 @@
|
||||||
|
/target
|
||||||
|
/bin
|
|
@ -0,0 +1,13 @@
|
||||||
|
<projectDescription>
|
||||||
|
<name>hapi-fhir-base</name>
|
||||||
|
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
|
||||||
|
<projects/>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
|
@ -0,0 +1,5 @@
|
||||||
|
#Sun Feb 16 17:15:18 EST 2014
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.6
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.6
|
|
@ -0,0 +1,68 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
|
<artifactId>hapi-fhir</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
|
<artifactId>hapi-fhir-base</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>HAPI FHIR Base Library</name>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- JSON -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>2.2.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- XML -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.woodstox</groupId>
|
||||||
|
<artifactId>woodstox-core-asl</artifactId>
|
||||||
|
<version>4.2.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- General -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.2.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Logging -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
<version>1.7.6</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
|
<version>1.1.1</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Testing -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.11</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,51 @@
|
||||||
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.StringUtils.*;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
public class BaseRuntimeChildDefinition {
|
||||||
|
|
||||||
|
private String myElementName;
|
||||||
|
private Field myField;
|
||||||
|
private int myMin;
|
||||||
|
private int myMax;
|
||||||
|
|
||||||
|
BaseRuntimeChildDefinition(Field theField, String theElementName, int theMin, int theMax) throws ConfigurationException {
|
||||||
|
super();
|
||||||
|
if (theField == null) {
|
||||||
|
throw new IllegalArgumentException("No field speficied");
|
||||||
|
}
|
||||||
|
if (isBlank(theElementName)) {
|
||||||
|
throw new ConfigurationException("Element name can not be blank");
|
||||||
|
}
|
||||||
|
if (theMin < 0) {
|
||||||
|
throw new ConfigurationException("Min must be >= 0");
|
||||||
|
}
|
||||||
|
if (theMax != -1 && theMax < theMin) {
|
||||||
|
throw new ConfigurationException("Max must be >= Min (unless it is -1 / unlimited)");
|
||||||
|
}
|
||||||
|
|
||||||
|
myField=theField;
|
||||||
|
myElementName = theElementName;
|
||||||
|
myMin=theMin;
|
||||||
|
myMax=theMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMin() {
|
||||||
|
return myMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMax() {
|
||||||
|
return myMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Field getField() {
|
||||||
|
return myField;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getElementName() {
|
||||||
|
return myElementName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
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,27 @@
|
||||||
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.IElement;
|
||||||
|
|
||||||
|
public abstract class BaseRuntimeElementDefinition<T extends IElement> {
|
||||||
|
|
||||||
|
private String myName;
|
||||||
|
private Class<? extends T> myImplementingClass;
|
||||||
|
|
||||||
|
public BaseRuntimeElementDefinition(String theName, Class<? extends T> theImplementingClass) {
|
||||||
|
myName = theName;
|
||||||
|
myImplementingClass=theImplementingClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the runtime name for this resource (i.e. the name that
|
||||||
|
* will be used in encoded messages)
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return myName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<? extends T> getImplementingClass() {
|
||||||
|
return myImplementingClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Non-checked exception indicating that HAPI was unable to initialize due to
|
||||||
|
* a detected configuration problem
|
||||||
|
*/
|
||||||
|
public class ConfigurationException extends RuntimeException {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public ConfigurationException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigurationException(String theMessage, Throwable theCause) {
|
||||||
|
super(theMessage, theCause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigurationException(String theMessage) {
|
||||||
|
super(theMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigurationException(Throwable theCause) {
|
||||||
|
super(theCause);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
|
||||||
|
public class FhirContext {
|
||||||
|
|
||||||
|
private ModelScanner myModelScanner;
|
||||||
|
|
||||||
|
public FhirContext(Class<? extends IResource>... theResourceTypes) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,255 @@
|
||||||
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
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.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
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.DatatypeDefinition;
|
||||||
|
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||||
|
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.ICompositeElement;
|
||||||
|
import ca.uhn.fhir.model.api.IDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.IElement;
|
||||||
|
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||||
|
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.ResourceReferenceElement;
|
||||||
|
import ca.uhn.fhir.model.resource.ResourceDefinition;
|
||||||
|
|
||||||
|
class ModelScanner {
|
||||||
|
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<String, BaseRuntimeElementDefinition<?>> myNameToResourceDefinitions = new HashMap<String, BaseRuntimeElementDefinition<?>>();
|
||||||
|
|
||||||
|
// private Map<String, RuntimeResourceDefinition>
|
||||||
|
// myNameToDatatypeDefinitions = new HashMap<String,
|
||||||
|
// RuntimeDatatypeDefinition>();
|
||||||
|
|
||||||
|
ModelScanner(Class<? extends IResource>... theResourceTypes) throws ConfigurationException {
|
||||||
|
for (Class<? extends IResource> nextClass : theResourceTypes) {
|
||||||
|
scan(nextClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String scan(Class<? extends IElement> theClass) throws ConfigurationException {
|
||||||
|
BaseRuntimeElementDefinition<?> existingDef = myClassToResourceDefinitions.get(theClass);
|
||||||
|
if (existingDef != null) {
|
||||||
|
return existingDef.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
ResourceDefinition resourceDefinition = theClass.getAnnotation(ResourceDefinition.class);
|
||||||
|
if (resourceDefinition != null) {
|
||||||
|
if (!IResource.class.isAssignableFrom(theClass)) {
|
||||||
|
throw new ConfigurationException("Resource type contains a @" + ResourceDefinition.class.getSimpleName() + " annotation but does not implement " + IResource.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
||||||
|
}
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Class<? extends IResource> resClass = (Class<? extends IResource>) theClass;
|
||||||
|
return scanResource(resClass, resourceDefinition);
|
||||||
|
}
|
||||||
|
|
||||||
|
DatatypeDefinition datatypeDefinition = theClass.getAnnotation(DatatypeDefinition.class);
|
||||||
|
if (datatypeDefinition != null) {
|
||||||
|
if (ICompositeDatatype.class.isAssignableFrom(theClass)) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Class<? extends ICompositeDatatype> resClass = (Class<? extends ICompositeDatatype>) theClass;
|
||||||
|
return scanCompositeDatatype(resClass, datatypeDefinition);
|
||||||
|
} else if (IPrimitiveDatatype.class.isAssignableFrom(theClass)) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Class<? extends IPrimitiveDatatype> resClass = (Class<? extends IPrimitiveDatatype>) theClass;
|
||||||
|
return scanPrimitiveDatatype(resClass, datatypeDefinition);
|
||||||
|
} 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 does not contain a @" + ResourceDefinition.class.getSimpleName() + " annotation or a @" + DatatypeDefinition.class.getSimpleName() + " annotation: " + theClass.getCanonicalName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String scanCompositeDatatype(Class<? extends ICompositeDatatype> theClass, DatatypeDefinition theDatatypeDefinition) {
|
||||||
|
ourLog.debug("Scanning resource class: {}", theClass.getName());
|
||||||
|
|
||||||
|
String resourceName = theDatatypeDefinition.name();
|
||||||
|
if (isBlank(resourceName)) {
|
||||||
|
throw new ConfigurationException("Resource type @" + ResourceDefinition.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myNameToResourceDefinitions.containsKey(resourceName)) {
|
||||||
|
if (!myNameToResourceDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
|
||||||
|
throw new ConfigurationException("Detected duplicate element name '" + resourceName + "' in types '" + theClass.getCanonicalName() + "' and '" + myNameToResourceDefinitions.get(resourceName).getImplementingClass() + "'");
|
||||||
|
}
|
||||||
|
return resourceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
RuntimeCompositeDatatypeDefinition resourceDef = new RuntimeCompositeDatatypeDefinition(resourceName, theClass);
|
||||||
|
myClassToResourceDefinitions.put(theClass, resourceDef);
|
||||||
|
myNameToResourceDefinitions.put(resourceName, resourceDef);
|
||||||
|
|
||||||
|
scanCompositeElementForChildren(theClass, resourceDef);
|
||||||
|
|
||||||
|
return resourceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String scanPrimitiveDatatype(Class<? extends IPrimitiveDatatype> theClass, DatatypeDefinition theDatatypeDefinition) {
|
||||||
|
ourLog.debug("Scanning resource class: {}", theClass.getName());
|
||||||
|
|
||||||
|
String resourceName = theDatatypeDefinition.name();
|
||||||
|
if (isBlank(resourceName)) {
|
||||||
|
throw new ConfigurationException("Resource type @" + ResourceDefinition.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myNameToResourceDefinitions.containsKey(resourceName)) {
|
||||||
|
if (!myNameToResourceDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
|
||||||
|
throw new ConfigurationException("Detected duplicate element name '" + resourceName + "' in types '" + theClass.getCanonicalName() + "' and '" + myNameToResourceDefinitions.get(resourceName).getImplementingClass() + "'");
|
||||||
|
}
|
||||||
|
return resourceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
RuntimePrimitiveDatatypeDefinition resourceDef = new RuntimePrimitiveDatatypeDefinition(resourceName, theClass);
|
||||||
|
myClassToResourceDefinitions.put(theClass, resourceDef);
|
||||||
|
myNameToResourceDefinitions.put(resourceName, resourceDef);
|
||||||
|
|
||||||
|
return resourceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String scanResource(Class<? extends IResource> theClass, ResourceDefinition resourceDefinition) {
|
||||||
|
ourLog.debug("Scanning resource class: {}", theClass.getName());
|
||||||
|
|
||||||
|
String resourceName = resourceDefinition.name();
|
||||||
|
if (isBlank(resourceName)) {
|
||||||
|
throw new ConfigurationException("Resource type @" + ResourceDefinition.class.getSimpleName() + " annotation contains no resource name: " + theClass.getCanonicalName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myNameToResourceDefinitions.containsKey(resourceName)) {
|
||||||
|
if (!myNameToResourceDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
|
||||||
|
throw new ConfigurationException("Detected duplicate element name '" + resourceName + "' in types '" + theClass.getCanonicalName() + "' and '" + myNameToResourceDefinitions.get(resourceName).getImplementingClass() + "'");
|
||||||
|
}
|
||||||
|
return resourceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
RuntimeResourceDefinition resourceDef = new RuntimeResourceDefinition(theClass, resourceName);
|
||||||
|
myClassToResourceDefinitions.put(theClass, resourceDef);
|
||||||
|
myNameToResourceDefinitions.put(resourceName, resourceDef);
|
||||||
|
|
||||||
|
scanCompositeElementForChildren(theClass, resourceDef);
|
||||||
|
|
||||||
|
return resourceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scanCompositeElementForChildren(Class<? extends ICompositeElement> theClass, BaseRuntimeCompositeElementDefinition<?> theDefinition) {
|
||||||
|
Set<String> elementNames = new HashSet<String>();
|
||||||
|
Map<Integer, BaseRuntimeChildDefinition> orderToElementDef = new HashMap<Integer, BaseRuntimeChildDefinition>();
|
||||||
|
for (Field next : theClass.getFields()) {
|
||||||
|
ResourceElement element = next.getAnnotation(ResourceElement.class);
|
||||||
|
if (element == null) {
|
||||||
|
ourLog.debug("Ignoring non-type field: " + next.getName());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String elementName = element.name();
|
||||||
|
int order = element.order();
|
||||||
|
int min = element.min();
|
||||||
|
int max = element.max();
|
||||||
|
|
||||||
|
ResourceChoiceElement choiceAttr = element.choice();
|
||||||
|
List<Class<? extends IElement>> choiceTypes = new ArrayList<Class<? extends IElement>>();
|
||||||
|
for (Class<? extends IElement> nextChoiceType : choiceAttr.types()) {
|
||||||
|
choiceTypes.add(nextChoiceType);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (orderToElementDef.containsKey(order)) {
|
||||||
|
throw new ConfigurationException("Detected duplicate field order '" + order + "' in type '" + theClass.getCanonicalName() + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elementNames.contains(elementName)) {
|
||||||
|
throw new ConfigurationException("Detected duplicate field name '" + elementName + "' in type '" + theClass.getCanonicalName() + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
ResourceReferenceElement resRefAnnotation = next.getAnnotation(ResourceReferenceElement.class);
|
||||||
|
if (choiceTypes.isEmpty() == false) {
|
||||||
|
|
||||||
|
List<String> choiceNames = new ArrayList<String>();
|
||||||
|
for (Class<? extends IElement> nextChoiceType : choiceTypes) {
|
||||||
|
choiceNames.add(scan(nextChoiceType));
|
||||||
|
}
|
||||||
|
|
||||||
|
RuntimeChildChoiceDefinition def = new RuntimeChildChoiceDefinition(next, elementName, min, max, choiceNames);
|
||||||
|
orderToElementDef.put(order, def);
|
||||||
|
|
||||||
|
} else if (ResourceReference.class.isAssignableFrom(next.getType())) {
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
Class<? extends IResource> refType = resRefAnnotation.type();
|
||||||
|
String elementResourceName = scan(refType);
|
||||||
|
|
||||||
|
if (!(myNameToResourceDefinitions.get(elementResourceName) instanceof IResource)) {
|
||||||
|
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);
|
||||||
|
} else {
|
||||||
|
if (resRefAnnotation != null) {
|
||||||
|
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is not a resource reference but has a @" + ResourceReferenceElement.class.getSimpleName() + " annotation");
|
||||||
|
}
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeableConceptElement concept = next.getAnnotation(CodeableConceptElement.class);
|
||||||
|
if (concept != null) {
|
||||||
|
Class<? extends ICodeEnum> codeType = concept.type();
|
||||||
|
String codeTableName = scanCodeTable(codeType);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
String datatypeName = scan((Class<? extends IDatatype>) next.getType());
|
||||||
|
RuntimeChildDatatypeDefinition def = new RuntimeChildCodedDatatypeDefinition(next, elementName, datatypeName, min, max, codeTableName);
|
||||||
|
orderToElementDef.put(order, def);
|
||||||
|
} else {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
String datatypeName = scan((Class<? extends IDatatype>) next.getType());
|
||||||
|
RuntimeChildDatatypeDefinition def = new RuntimeChildDatatypeDefinition(next, elementName, datatypeName, min, max);
|
||||||
|
orderToElementDef.put(order, def);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
elementNames.add(elementName);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < orderToElementDef.size(); i++) {
|
||||||
|
if (!orderToElementDef.containsKey(i)) {
|
||||||
|
throw new ConfigurationException("Type '" + theClass.getCanonicalName() + "' does not have a child with order " + i + " (in other words, there are gaps between specified child orders)");
|
||||||
|
}
|
||||||
|
BaseRuntimeChildDefinition next = orderToElementDef.get(i);
|
||||||
|
theDefinition.addChild(next);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private String scanCodeTable(Class<? extends ICodeEnum> theCodeType) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class RuntimeChildChoiceDefinition extends BaseRuntimeChildDefinition {
|
||||||
|
|
||||||
|
private List<String> myChoices;
|
||||||
|
|
||||||
|
public RuntimeChildChoiceDefinition(Field theField, String theElementName, int theMin, int theMax, List<String> theChoiceNames) {
|
||||||
|
super(theField, theElementName,theMin,theMax);
|
||||||
|
|
||||||
|
myChoices= theChoiceNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getChoices() {
|
||||||
|
return myChoices;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
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,19 @@
|
||||||
|
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,19 @@
|
||||||
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
public class RuntimeChildResourceDefinition extends BaseRuntimeChildDefinition {
|
||||||
|
|
||||||
|
private String myResourceName;
|
||||||
|
|
||||||
|
public RuntimeChildResourceDefinition(Field theField, String theElementName, String theResourceName, int theMin, int theMax) {
|
||||||
|
super(theField, theElementName,theMin,theMax);
|
||||||
|
|
||||||
|
myResourceName = theResourceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResourceName() {
|
||||||
|
return myResourceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
||||||
|
|
||||||
|
public class RuntimeCompositeDatatypeDefinition extends BaseRuntimeCompositeElementDefinition<ICompositeDatatype> {
|
||||||
|
|
||||||
|
public RuntimeCompositeDatatypeDefinition(String theName, Class<? extends ICompositeDatatype> theImplementingClass) {
|
||||||
|
super(theName, theImplementingClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||||
|
|
||||||
|
public class RuntimePrimitiveDatatypeDefinition extends BaseRuntimeElementDefinition<IPrimitiveDatatype>{
|
||||||
|
|
||||||
|
public RuntimePrimitiveDatatypeDefinition(String theName, Class<? extends IPrimitiveDatatype> theImplementingClass) {
|
||||||
|
super(theName, theImplementingClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
|
||||||
|
public class RuntimeResourceDefinition extends BaseRuntimeCompositeElementDefinition<IResource> {
|
||||||
|
|
||||||
|
public RuntimeResourceDefinition(Class<? extends IResource> theClass, String theName) {
|
||||||
|
super(theName, theClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
|
||||||
|
public class BaseCompositeDatatype extends BaseDatatype implements ICompositeDatatype {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
|
||||||
|
public abstract class BaseDatatype implements IDatatype {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
public abstract class BaseElement implements IElement {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
|
||||||
|
public class BasePrimitiveDatatype extends BaseDatatype implements IPrimitiveDatatype {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value= {ElementType.FIELD})
|
||||||
|
public @interface CodeableConceptElement {
|
||||||
|
|
||||||
|
Class<? extends ICodeEnum> type();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value= {ElementType.FIELD})
|
||||||
|
public @interface Constraint {
|
||||||
|
|
||||||
|
String[] coRequirements() default {};
|
||||||
|
|
||||||
|
String[] lessThan() default {};
|
||||||
|
|
||||||
|
String[] greaterThan() default {};
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value= {ElementType.TYPE})
|
||||||
|
public @interface DatatypeDefinition {
|
||||||
|
|
||||||
|
String name();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value= {ElementType.FIELD, ElementType.TYPE})
|
||||||
|
public @interface Description {
|
||||||
|
|
||||||
|
String value();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value= {ElementType.FIELD})
|
||||||
|
public @interface EnumeratedCodeValue {
|
||||||
|
|
||||||
|
String value();
|
||||||
|
|
||||||
|
String system() default "";
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value= {ElementType.TYPE})
|
||||||
|
public @interface EnumeratedValueSet {
|
||||||
|
|
||||||
|
int tableId();
|
||||||
|
|
||||||
|
String name();
|
||||||
|
|
||||||
|
int[] restrictedToSnomedIsA() default {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
public interface ICodeEnum extends IPrimitiveDatatype {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
|
||||||
|
public interface ICompositeDatatype extends IDatatype, ICompositeElement {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
public interface ICompositeElement extends IElement {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
public interface IDatatype extends IElement {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
public interface IElement {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
public interface IPrimitiveDatatype extends IDatatype {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
|
||||||
|
public interface IResource extends ICompositeElement {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value= {ElementType.FIELD})
|
||||||
|
public @interface ResourceChoiceElement {
|
||||||
|
|
||||||
|
Class<? extends IDatatype>[] types() default {};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value= {ElementType.FIELD})
|
||||||
|
public @interface ResourceElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constant value to supply for {@link #order()} when the order is defined
|
||||||
|
* elsewhere
|
||||||
|
*/
|
||||||
|
int ORDER_UNKNOWN = -1;
|
||||||
|
|
||||||
|
String name();
|
||||||
|
|
||||||
|
int order();
|
||||||
|
|
||||||
|
int min() default 0;
|
||||||
|
|
||||||
|
int max() default 1;
|
||||||
|
|
||||||
|
ResourceChoiceElement choice() default @ResourceChoiceElement();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.resource.BaseResource;
|
||||||
|
|
||||||
|
public class ResourceReference<T extends BaseResource> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package ca.uhn.fhir.model.api;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value= {ElementType.FIELD})
|
||||||
|
public @interface ResourceReferenceElement {
|
||||||
|
|
||||||
|
Class<? extends IResource> type();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
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.ResourceElement;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="Attachment")
|
||||||
|
public class AttachmentDt extends BaseCompositeDatatype {
|
||||||
|
|
||||||
|
@ResourceElement(name="contentType", order=0, min=1)
|
||||||
|
private CodeDt myContentType;
|
||||||
|
|
||||||
|
@ResourceElement(name="language", order=1)
|
||||||
|
private CodeDt myLanguage;
|
||||||
|
|
||||||
|
@ResourceElement(name="data", order=2)
|
||||||
|
private Base64BinaryDt myData;
|
||||||
|
|
||||||
|
@ResourceElement(name="url", order=3)
|
||||||
|
private UriDt myUrl;
|
||||||
|
|
||||||
|
@ResourceElement(name="size", order=4)
|
||||||
|
private IntegerDt mySize;
|
||||||
|
|
||||||
|
@ResourceElement(name="hash", order=5)
|
||||||
|
@Description("Hash of the data (sha-1, base64ed )")
|
||||||
|
private Base64BinaryDt myHash;
|
||||||
|
|
||||||
|
@ResourceElement(name="title", order=5)
|
||||||
|
@Description("Label to display in place of the data")
|
||||||
|
private StringDt myLabel;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="base64Binary")
|
||||||
|
public class Base64BinaryDt extends BasePrimitiveDatatype {
|
||||||
|
|
||||||
|
private byte[] myValue;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="boolean")
|
||||||
|
public class BooleanDt extends BasePrimitiveDatatype {
|
||||||
|
|
||||||
|
private boolean myValue;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
||||||
|
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="code")
|
||||||
|
public class CodeDt<T extends ICodeEnum> extends BasePrimitiveDatatype {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="CodeableConcept")
|
||||||
|
public class CodeableConceptDt<T extends ICodeEnum> extends BaseCompositeDatatype {
|
||||||
|
|
||||||
|
@ResourceElement(name="coding", order=0)
|
||||||
|
private List<CodingDt> myCoding;
|
||||||
|
|
||||||
|
@ResourceElement(name="text",order=1)
|
||||||
|
private StringDt myText;
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
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.ResourceReferenceElement;
|
||||||
|
import ca.uhn.fhir.model.resource.ValueSet;
|
||||||
|
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="Coding")
|
||||||
|
public class CodingDt extends BaseCompositeDatatype {
|
||||||
|
|
||||||
|
@ResourceElement(name="system", order=0)
|
||||||
|
private UriDt mySystem;
|
||||||
|
|
||||||
|
@ResourceElement(name="version", order=1)
|
||||||
|
private StringDt myVersion;
|
||||||
|
|
||||||
|
@ResourceElement(name="code", order=2)
|
||||||
|
private CodeDt<?> myCode;
|
||||||
|
|
||||||
|
@ResourceElement(name="display", order=3)
|
||||||
|
private StringDt myDisplay;
|
||||||
|
|
||||||
|
@ResourceElement(name="primary", order=4)
|
||||||
|
private BooleanDt myPrimary;
|
||||||
|
|
||||||
|
@ResourceElement(name="valueSet", order=5)
|
||||||
|
@ResourceReferenceElement(type=ValueSet.class)
|
||||||
|
private ResourceReference<ValueSet> myAssigner;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.BaseDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
||||||
|
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="date")
|
||||||
|
public class DateDt extends BaseDatatype implements IPrimitiveDatatype {
|
||||||
|
|
||||||
|
private GregorianCalendar myValue;
|
||||||
|
private int myPrecision;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="dateTime")
|
||||||
|
public class DateTimeDt extends BasePrimitiveDatatype {
|
||||||
|
|
||||||
|
private GregorianCalendar myValue;
|
||||||
|
|
||||||
|
private int myPrecision;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="decimal")
|
||||||
|
public class DecimalDt extends BasePrimitiveDatatype {
|
||||||
|
|
||||||
|
private BigDecimal myValue;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
||||||
|
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.ResourceReferenceElement;
|
||||||
|
import ca.uhn.fhir.model.enm.IdentifierUseEnum;
|
||||||
|
import ca.uhn.fhir.model.resource.Organization;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="identifier")
|
||||||
|
public class IdentifierDt extends BaseCompositeDatatype {
|
||||||
|
|
||||||
|
@ResourceElement(name="use", order=0)
|
||||||
|
@CodeableConceptElement(type=IdentifierUseEnum.class)
|
||||||
|
private CodeDt<IdentifierUseEnum> myUse;
|
||||||
|
|
||||||
|
@ResourceElement(name="label", order=1)
|
||||||
|
private StringDt myLabel;
|
||||||
|
|
||||||
|
@ResourceElement(name="system", order=2)
|
||||||
|
private UriDt mySystem;
|
||||||
|
|
||||||
|
@ResourceElement(name="value", order=3)
|
||||||
|
private StringDt myValue;
|
||||||
|
|
||||||
|
@ResourceElement(name="period", order=4)
|
||||||
|
private PeriodDt myPeriod;
|
||||||
|
|
||||||
|
@ResourceElement(name="assigner", order=5)
|
||||||
|
@ResourceReferenceElement(type=Organization.class)
|
||||||
|
private ResourceReference<Organization> myAssigner;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="instant")
|
||||||
|
public class InstantDt extends BasePrimitiveDatatype {
|
||||||
|
|
||||||
|
private Date myValue;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="integer")
|
||||||
|
public class IntegerDt extends BasePrimitiveDatatype {
|
||||||
|
|
||||||
|
private int myValue;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.Constraint;
|
||||||
|
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
||||||
|
import ca.uhn.fhir.model.api.ResourceElement;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="Period")
|
||||||
|
public class PeriodDt extends BaseCompositeDatatype {
|
||||||
|
|
||||||
|
@ResourceElement(name="start", order=0)
|
||||||
|
@Constraint(lessThan= {"end"})
|
||||||
|
private DateTimeDt myStart;
|
||||||
|
|
||||||
|
@ResourceElement(name="end", order=1)
|
||||||
|
@Constraint(greaterThan= {"start"})
|
||||||
|
private DateTimeDt myEnd;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.Constraint;
|
||||||
|
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
||||||
|
import ca.uhn.fhir.model.api.ResourceElement;
|
||||||
|
import ca.uhn.fhir.model.enm.QuantityComparator;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="Quantity")
|
||||||
|
public class QuantityDt extends BaseCompositeDatatype {
|
||||||
|
|
||||||
|
@ResourceElement(name="value",order=0, min=0, max=1)
|
||||||
|
private DecimalDt myValue;
|
||||||
|
|
||||||
|
@ResourceElement(name="comparator",order=1, min=0, max=1)
|
||||||
|
private QuantityComparator myComparator;
|
||||||
|
|
||||||
|
@ResourceElement(name="units",order=2, min=0, max=1)
|
||||||
|
private StringDt myUnits;
|
||||||
|
|
||||||
|
@ResourceElement(name="system",order=3, min=0, max=1)
|
||||||
|
@Constraint(coRequirements= {"code"})
|
||||||
|
private UriDt mySystem;
|
||||||
|
|
||||||
|
@ResourceElement(name="code",order=4, min=0, max=1)
|
||||||
|
@Constraint(coRequirements= {"system"})
|
||||||
|
private CodeDt myCode;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.BaseCompositeDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.Constraint;
|
||||||
|
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
||||||
|
import ca.uhn.fhir.model.api.ResourceElement;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="Ratio")
|
||||||
|
public class RatioDt extends BaseCompositeDatatype {
|
||||||
|
|
||||||
|
@ResourceElement(name="numerator", order=0)
|
||||||
|
@Constraint(coRequirements= {"denominator"})
|
||||||
|
private QuantityDt myNumerator;
|
||||||
|
|
||||||
|
@ResourceElement(name="denominator", order=1)
|
||||||
|
@Constraint(coRequirements= {"numerator"})
|
||||||
|
private QuantityDt myDenominator;
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="SampledData")
|
||||||
|
public class SampledDataDt extends BaseCompositeDatatype {
|
||||||
|
|
||||||
|
@ResourceElement(name="origin", order=0, min=1)
|
||||||
|
private QuantityDt myOrigin;
|
||||||
|
|
||||||
|
@ResourceElement(name="period", order=1, min=1)
|
||||||
|
private DecimalDt myPeriod;
|
||||||
|
|
||||||
|
@ResourceElement(name="factor", order=2)
|
||||||
|
private DecimalDt myFactor;
|
||||||
|
|
||||||
|
@ResourceElement(name="lowerLimit", order=3)
|
||||||
|
private DecimalDt myLowerLimit;
|
||||||
|
|
||||||
|
@ResourceElement(name="upperLimit", order=4)
|
||||||
|
private DecimalDt myUpperLimit;
|
||||||
|
|
||||||
|
@ResourceElement(name="dimensions", order=5, min=1)
|
||||||
|
private IntegerDt myDimensions;
|
||||||
|
|
||||||
|
@ResourceElement(name="data", order=6, min=1)
|
||||||
|
@Description("Decimal values with spaces, or \"E\" | \"U\" | \"L\"")
|
||||||
|
private StringDt myData;
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.BasePrimitiveDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="string")
|
||||||
|
public class StringDt extends BasePrimitiveDatatype {
|
||||||
|
|
||||||
|
private String myValue;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package ca.uhn.fhir.model.datatype;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.BaseDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.DatatypeDefinition;
|
||||||
|
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||||
|
|
||||||
|
@DatatypeDefinition(name="uri")
|
||||||
|
public class UriDt extends BaseDatatype implements IPrimitiveDatatype {
|
||||||
|
|
||||||
|
private String myValue;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package ca.uhn.fhir.model.enm;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.EnumeratedValueSet;
|
||||||
|
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||||
|
|
||||||
|
@EnumeratedValueSet(name="body-site", tableId=62, restrictedToSnomedIsA= {91723000})
|
||||||
|
public enum BodySiteEnum implements ICodeEnum {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package ca.uhn.fhir.model.enm;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.Description;
|
||||||
|
import ca.uhn.fhir.model.api.EnumeratedCodeValue;
|
||||||
|
import ca.uhn.fhir.model.api.EnumeratedValueSet;
|
||||||
|
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||||
|
|
||||||
|
@EnumeratedValueSet(name="identifier-use", tableId=13)
|
||||||
|
public enum IdentifierUseEnum implements ICodeEnum {
|
||||||
|
@EnumeratedCodeValue("usual")
|
||||||
|
@Description("the identifier recommended for display and use in real-world interactions.")
|
||||||
|
USUAL,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue("official")
|
||||||
|
@Description("the identifier considered to be most trusted for the identification of this item.")
|
||||||
|
OFFICIAL,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue("temp")
|
||||||
|
@Description("A temporary identifier.")
|
||||||
|
TEMP,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue("secondary")
|
||||||
|
@Description("An identifier that was assigned in secondary use - it serves to identify the object in a relative context, but cannot be consistently assigned to the same object again in a different context.")
|
||||||
|
SECONDARY
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package ca.uhn.fhir.model.enm;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.EnumeratedValueSet;
|
||||||
|
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||||
|
|
||||||
|
@EnumeratedValueSet(name="observation-codes", tableId=115)
|
||||||
|
public enum ObservationCodesEnum implements ICodeEnum {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,126 @@
|
||||||
|
package ca.uhn.fhir.model.enm;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.Description;
|
||||||
|
import ca.uhn.fhir.model.api.EnumeratedCodeValue;
|
||||||
|
import ca.uhn.fhir.model.api.EnumeratedValueSet;
|
||||||
|
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||||
|
|
||||||
|
@EnumeratedValueSet(tableId = 117, name = "observation-interpretation")
|
||||||
|
public enum ObservationInterpretationEnum implements ICodeEnum {
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "<", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Below absolute low-off instrument scale")
|
||||||
|
BELOW_ABSOLUTE_LOW,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = ">", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Above absolute high-off instrument scale")
|
||||||
|
ABOVE_ABSOLUTE_HIGH,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "A", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Abnormal (applies to non-numeric results)")
|
||||||
|
A,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "AA", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Very abnormal (applies to non-numeric units, analogous to panic limits for numeric units)")
|
||||||
|
AA,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "AC", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Anti-complementary substances present")
|
||||||
|
AC,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "B", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Better-use when direction not relevant")
|
||||||
|
B,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "D", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Significant change down")
|
||||||
|
D,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "DET", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Detected")
|
||||||
|
DET,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "H", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Above high normal")
|
||||||
|
H,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "HH", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Above upper panic limits")
|
||||||
|
HH,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "I", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Intermediate. Indicates for microbiology susceptibilities only.")
|
||||||
|
I,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "IND", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Indeterminate")
|
||||||
|
IND,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "L", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Below low normal")
|
||||||
|
L,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "LL", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Below lower panic limits")
|
||||||
|
LL, @EnumeratedCodeValue(value = "MS", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Moderately susceptible. Indicates for microbiology susceptibilities only.")
|
||||||
|
MS,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "N", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Normal (applies to non-numeric results)")
|
||||||
|
N,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "ND", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Not Detected")
|
||||||
|
ND,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "NEG", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Negative")
|
||||||
|
NEG, @EnumeratedCodeValue(value = "NR", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Non-reactive")
|
||||||
|
NR,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "POS", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Positive")
|
||||||
|
POS,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "QCF", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Quality Control Failure")
|
||||||
|
QCF,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "R", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Resistant. Indicates for microbiology susceptibilities only.")
|
||||||
|
R,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "RR", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Reactive")
|
||||||
|
RR,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "S", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Susceptible. Indicates for microbiology susceptibilities only.")
|
||||||
|
S,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "TOX", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Cytotoxic substance present")
|
||||||
|
TOX,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "U", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Significant change up")
|
||||||
|
U,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "VS", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Very susceptible. Indicates for microbiology susceptibilities only.")
|
||||||
|
VS,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "W", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Worse-use when direction not relevant")
|
||||||
|
W,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "WR", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("Weakly reactive")
|
||||||
|
WR,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(value = "null", system = "http://hl7.org/fhir/v2/0078")
|
||||||
|
@Description("No range defined, or normal ranges don't apply")
|
||||||
|
NULL
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package ca.uhn.fhir.model.enm;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.EnumeratedValueSet;
|
||||||
|
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||||
|
|
||||||
|
@EnumeratedValueSet(tableId=114, name="observation-method")
|
||||||
|
public enum ObservationMethodEnum implements ICodeEnum {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package ca.uhn.fhir.model.enm;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.Description;
|
||||||
|
import ca.uhn.fhir.model.api.EnumeratedCodeValue;
|
||||||
|
import ca.uhn.fhir.model.api.EnumeratedValueSet;
|
||||||
|
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||||
|
|
||||||
|
@EnumeratedValueSet(tableId=118, name="observation-reliability")
|
||||||
|
public enum ObservationReliabilityEnum implements ICodeEnum {
|
||||||
|
|
||||||
|
@Description("The result has no reliability concerns.")
|
||||||
|
@EnumeratedCodeValue("ok")
|
||||||
|
OK,
|
||||||
|
|
||||||
|
@Description("An early estimate of value; measurement is still occurring.")
|
||||||
|
@EnumeratedCodeValue("ongoing")
|
||||||
|
ONGOING,
|
||||||
|
|
||||||
|
@Description("An early estimate of value; processing is still occurring.")
|
||||||
|
@EnumeratedCodeValue("early")
|
||||||
|
EARLY,
|
||||||
|
|
||||||
|
@Description("The observation value should be treated with care.")
|
||||||
|
@EnumeratedCodeValue("questionable")
|
||||||
|
QUESTIONABLE,
|
||||||
|
|
||||||
|
@Description("The result has been generated while calibration is occurring.")
|
||||||
|
@EnumeratedCodeValue("calibrating")
|
||||||
|
CALIBRATING,
|
||||||
|
|
||||||
|
@Description("The observation could not be completed because of an error.")
|
||||||
|
@EnumeratedCodeValue("error")
|
||||||
|
ERROR,
|
||||||
|
|
||||||
|
@Description("No observation value was available.")
|
||||||
|
@EnumeratedCodeValue("unknown")
|
||||||
|
UNKNOWN
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package ca.uhn.fhir.model.enm;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.Description;
|
||||||
|
import ca.uhn.fhir.model.api.EnumeratedCodeValue;
|
||||||
|
import ca.uhn.fhir.model.api.EnumeratedValueSet;
|
||||||
|
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||||
|
|
||||||
|
@EnumeratedValueSet(tableId=7, name="observation-status")
|
||||||
|
public enum ObservationStatusEnum implements ICodeEnum {
|
||||||
|
|
||||||
|
@Description("The existence of the observation is registered, but there is no result yet available")
|
||||||
|
@EnumeratedCodeValue("registered")
|
||||||
|
REGISTERED,
|
||||||
|
|
||||||
|
@Description("This is an initial or interim observation: data may be incomplete or unverified")
|
||||||
|
@EnumeratedCodeValue("interim")
|
||||||
|
INTERIM,
|
||||||
|
|
||||||
|
@Description("The observation is complete and verified by an authorised person")
|
||||||
|
@EnumeratedCodeValue("final")
|
||||||
|
FINAL,
|
||||||
|
|
||||||
|
@Description("The observation has been modified subsequent to being Final, and is complete and verified by an authorised person")
|
||||||
|
@EnumeratedCodeValue("amended")
|
||||||
|
AMENDED,
|
||||||
|
|
||||||
|
@Description("The observation is unavailable because the measurement was not started or not completed (also sometimes called \"aborted\")")
|
||||||
|
@EnumeratedCodeValue("cancelled")
|
||||||
|
CANCELLED,
|
||||||
|
|
||||||
|
@Description("The observation has been withdrawn following previous Final release")
|
||||||
|
@EnumeratedCodeValue("withdrawn")
|
||||||
|
WITHDRAWN
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package ca.uhn.fhir.model.enm;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.Description;
|
||||||
|
import ca.uhn.fhir.model.api.EnumeratedCodeValue;
|
||||||
|
import ca.uhn.fhir.model.api.EnumeratedValueSet;
|
||||||
|
import ca.uhn.fhir.model.api.ICodeEnum;
|
||||||
|
|
||||||
|
@EnumeratedValueSet(tableId=14, name="quantity-comparator")
|
||||||
|
public enum QuantityComparator implements ICodeEnum {
|
||||||
|
|
||||||
|
@EnumeratedCodeValue("<")
|
||||||
|
@Description("The actual value is less than the given value.")
|
||||||
|
LESSTHAN,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue("<=")
|
||||||
|
@Description("The actual value is less than or equal to the given value.")
|
||||||
|
LESSTHAN_OR_EQUAL,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(">=")
|
||||||
|
@Description("The actual value is greater than or equal to the given value.")
|
||||||
|
GREATERTHAN_OR_EQUAL,
|
||||||
|
|
||||||
|
@EnumeratedCodeValue(">")
|
||||||
|
@Description("The actual value is greater than the given value.")
|
||||||
|
GREATERTHAN;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package ca.uhn.fhir.model.resource;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.BaseElement;
|
||||||
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
|
|
||||||
|
public class BaseResource extends BaseElement implements IResource {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package ca.uhn.fhir.model.resource;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.ResourceElement;
|
||||||
|
import ca.uhn.fhir.model.datatype.IdentifierDt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classes extending this class must be annotated with
|
||||||
|
*/
|
||||||
|
public class BaseResourceWithIdentifier extends BaseResource {
|
||||||
|
|
||||||
|
@ResourceElement(name="identifier", order=ResourceElement.ORDER_UNKNOWN)
|
||||||
|
private IdentifierDt myIdentifier;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package ca.uhn.fhir.model.resource;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.CodeableConceptElement;
|
||||||
|
import ca.uhn.fhir.model.api.IDatatype;
|
||||||
|
import ca.uhn.fhir.model.api.ResourceChoiceElement;
|
||||||
|
import ca.uhn.fhir.model.api.ResourceElement;
|
||||||
|
import ca.uhn.fhir.model.datatype.AttachmentDt;
|
||||||
|
import ca.uhn.fhir.model.datatype.CodeableConceptDt;
|
||||||
|
import ca.uhn.fhir.model.datatype.DateTimeDt;
|
||||||
|
import ca.uhn.fhir.model.datatype.InstantDt;
|
||||||
|
import ca.uhn.fhir.model.datatype.PeriodDt;
|
||||||
|
import ca.uhn.fhir.model.datatype.QuantityDt;
|
||||||
|
import ca.uhn.fhir.model.datatype.RatioDt;
|
||||||
|
import ca.uhn.fhir.model.datatype.SampledDataDt;
|
||||||
|
import ca.uhn.fhir.model.datatype.StringDt;
|
||||||
|
import ca.uhn.fhir.model.enm.BodySiteEnum;
|
||||||
|
import ca.uhn.fhir.model.enm.ObservationCodesEnum;
|
||||||
|
import ca.uhn.fhir.model.enm.ObservationInterpretationEnum;
|
||||||
|
import ca.uhn.fhir.model.enm.ObservationMethodEnum;
|
||||||
|
import ca.uhn.fhir.model.enm.ObservationStatusEnum;
|
||||||
|
|
||||||
|
@ResourceDefinition(name="Observation", identifierOrder=10)
|
||||||
|
public class Observation extends BaseResourceWithIdentifier {
|
||||||
|
|
||||||
|
@ResourceElement(name="name", order=0, min=1, max=1)
|
||||||
|
@CodeableConceptElement(type=ObservationCodesEnum.class)
|
||||||
|
private CodeableConceptDt<ObservationCodesEnum> myName;
|
||||||
|
|
||||||
|
@ResourceElement(name="value", order=1, min=0, max=1, choice=@ResourceChoiceElement(types= {
|
||||||
|
QuantityDt.class,
|
||||||
|
CodeableConceptDt.class,
|
||||||
|
AttachmentDt.class,
|
||||||
|
RatioDt.class,
|
||||||
|
PeriodDt.class,
|
||||||
|
SampledDataDt.class,
|
||||||
|
StringDt.class
|
||||||
|
}))
|
||||||
|
private IDatatype myValue;
|
||||||
|
|
||||||
|
@ResourceElement(name="interpretation", order=2)
|
||||||
|
@CodeableConceptElement(type=ObservationInterpretationEnum.class)
|
||||||
|
private CodeableConceptDt<ObservationInterpretationEnum> myInterpretation;
|
||||||
|
|
||||||
|
@ResourceElement(name="comments", order=3)
|
||||||
|
private StringDt myComments;
|
||||||
|
|
||||||
|
@ResourceElement(name="applies", order=4, choice=@ResourceChoiceElement(types={
|
||||||
|
DateTimeDt.class,
|
||||||
|
PeriodDt.class
|
||||||
|
}))
|
||||||
|
private IDatatype myApplies;
|
||||||
|
|
||||||
|
@ResourceElement(name="issued", order=5)
|
||||||
|
private InstantDt myIssued;
|
||||||
|
|
||||||
|
@ResourceElement(name="status", order=6, min=1)
|
||||||
|
@CodeableConceptElement(type=ObservationStatusEnum.class)
|
||||||
|
private CodeableConceptDt<ObservationStatusEnum> myStatus;
|
||||||
|
|
||||||
|
@ResourceElement(name="reliability", order=7, min=1)
|
||||||
|
@CodeableConceptElement(type=ObservationStatusEnum.class)
|
||||||
|
private CodeableConceptDt<ObservationStatusEnum> myReliability;
|
||||||
|
|
||||||
|
@ResourceElement(name="bodySite", order=8)
|
||||||
|
@CodeableConceptElement(type=BodySiteEnum.class)
|
||||||
|
private CodeableConceptDt<BodySiteEnum> myBodySite;
|
||||||
|
|
||||||
|
@ResourceElement(name="method", order=9)
|
||||||
|
@CodeableConceptElement(type=ObservationMethodEnum.class)
|
||||||
|
private CodeableConceptDt<ObservationMethodEnum> myMethod;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package ca.uhn.fhir.model.resource;
|
||||||
|
|
||||||
|
public class Organization extends BaseResource {
|
||||||
|
//TODO: fill in
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package ca.uhn.fhir.model.resource;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value= {ElementType.TYPE})
|
||||||
|
public @interface ResourceDefinition {
|
||||||
|
|
||||||
|
int ORDER_NOT_SPECIFIED = -1;
|
||||||
|
|
||||||
|
String name();
|
||||||
|
|
||||||
|
int identifierOrder() default ORDER_NOT_SPECIFIED;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package ca.uhn.fhir.model.resource;
|
||||||
|
|
||||||
|
public class ValueSet extends BaseResource {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package ca.uhn.fhir.context;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.resource.Observation;
|
||||||
|
|
||||||
|
public class ModelScannerTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testScanner() {
|
||||||
|
|
||||||
|
ModelScanner scanner = new ModelScanner(Observation.class);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.sonatype.oss</groupId>
|
||||||
|
<artifactId>oss-parent</artifactId>
|
||||||
|
<version>6</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
|
<artifactId>hapi-fhir</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>HAPI</name>
|
||||||
|
<url>http://hl7api.sourceforge.net/</url>
|
||||||
|
<description>
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>hapi-fhir-base</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|
||||||
|
<slf4j_version>1.6.6</slf4j_version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.6</source>
|
||||||
|
<target>1.6</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
</project>
|
Loading…
Reference in New Issue