commit 8d322c373cbf33086afdb32a3d966e1fc8bee2b2 Author: jamesagnew Date: Mon Feb 17 17:58:32 2014 -0500 Just starting diff --git a/.classpath b/.classpath new file mode 100644 index 00000000000..8778ddd58a3 --- /dev/null +++ b/.classpath @@ -0,0 +1,5 @@ + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..934e0e06ffa --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/bin +/target diff --git a/.project b/.project new file mode 100644 index 00000000000..afaf82e1907 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + hapi-fhir + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..8000cd6ca61 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/hapi-fhir-base/.classpath b/hapi-fhir-base/.classpath new file mode 100644 index 00000000000..a643a2eb930 --- /dev/null +++ b/hapi-fhir-base/.classpath @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hapi-fhir-base/.gitignore b/hapi-fhir-base/.gitignore new file mode 100644 index 00000000000..4dc009173e3 --- /dev/null +++ b/hapi-fhir-base/.gitignore @@ -0,0 +1,2 @@ +/target +/bin diff --git a/hapi-fhir-base/.project b/hapi-fhir-base/.project new file mode 100644 index 00000000000..22f076c3eef --- /dev/null +++ b/hapi-fhir-base/.project @@ -0,0 +1,13 @@ + + hapi-fhir-base + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + + + org.eclipse.jdt.core.javabuilder + + + + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/hapi-fhir-base/.settings/org.eclipse.jdt.core.prefs b/hapi-fhir-base/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..fac709e2f3f --- /dev/null +++ b/hapi-fhir-base/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/hapi-fhir-base/pom.xml b/hapi-fhir-base/pom.xml new file mode 100644 index 00000000000..dfb3961887b --- /dev/null +++ b/hapi-fhir-base/pom.xml @@ -0,0 +1,68 @@ + + 4.0.0 + + + ca.uhn.hapi.fhir + hapi-fhir + 1.0-SNAPSHOT + ../pom.xml + + + ca.uhn.hapi.fhir + hapi-fhir-base + jar + + HAPI FHIR Base Library + + + + + + com.google.code.gson + gson + 2.2.4 + + + + + org.codehaus.woodstox + woodstox-core-asl + 4.2.0 + + + + + org.apache.commons + commons-lang3 + 3.2.1 + + + + + org.slf4j + slf4j-api + 1.7.6 + + + ch.qos.logback + logback-classic + 1.1.1 + true + + + + + junit + junit + 4.11 + test + + + + + + + + + + diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeChildDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeChildDefinition.java new file mode 100644 index 00000000000..94edccf85f4 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeChildDefinition.java @@ -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; + } + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeCompositeElementDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeCompositeElementDefinition.java new file mode 100644 index 00000000000..213903658d2 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeCompositeElementDefinition.java @@ -0,0 +1,19 @@ +package ca.uhn.fhir.context; + +import java.util.ArrayList; + +import ca.uhn.fhir.model.api.ICompositeElement; + +public class BaseRuntimeCompositeElementDefinition extends BaseRuntimeElementDefinition { + + private ArrayList myChildren = new ArrayList(); + + public BaseRuntimeCompositeElementDefinition(String theName, Class theImplementingClass) { + super(theName, theImplementingClass); + } + + public void addChild(BaseRuntimeChildDefinition theNext) { + myChildren.add(theNext); + } + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementDefinition.java new file mode 100644 index 00000000000..da450eb431e --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementDefinition.java @@ -0,0 +1,27 @@ +package ca.uhn.fhir.context; + +import ca.uhn.fhir.model.api.IElement; + +public abstract class BaseRuntimeElementDefinition { + + private String myName; + private Class myImplementingClass; + + public BaseRuntimeElementDefinition(String theName, Class 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 getImplementingClass() { + return myImplementingClass; + } + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ConfigurationException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ConfigurationException.java new file mode 100644 index 00000000000..e121772dcc4 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ConfigurationException.java @@ -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); + } + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java new file mode 100644 index 00000000000..829ed9b7d5a --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java @@ -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... theResourceTypes) { + + } + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java new file mode 100644 index 00000000000..3fb89e23bac --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java @@ -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, BaseRuntimeElementDefinition> myClassToResourceDefinitions = new HashMap, BaseRuntimeElementDefinition>(); + private Map> myNameToResourceDefinitions = new HashMap>(); + + // private Map + // myNameToDatatypeDefinitions = new HashMap(); + + ModelScanner(Class... theResourceTypes) throws ConfigurationException { + for (Class nextClass : theResourceTypes) { + scan(nextClass); + } + } + + private String scan(Class 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 resClass = (Class) theClass; + return scanResource(resClass, resourceDefinition); + } + + DatatypeDefinition datatypeDefinition = theClass.getAnnotation(DatatypeDefinition.class); + if (datatypeDefinition != null) { + if (ICompositeDatatype.class.isAssignableFrom(theClass)) { + @SuppressWarnings("unchecked") + Class resClass = (Class) theClass; + return scanCompositeDatatype(resClass, datatypeDefinition); + } else if (IPrimitiveDatatype.class.isAssignableFrom(theClass)) { + @SuppressWarnings("unchecked") + Class resClass = (Class) 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 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 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 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 theClass, BaseRuntimeCompositeElementDefinition theDefinition) { + Set elementNames = new HashSet(); + Map orderToElementDef = new HashMap(); + 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> choiceTypes = new ArrayList>(); + for (Class 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 choiceNames = new ArrayList(); + for (Class 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 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 codeType = concept.type(); + String codeTableName = scanCodeTable(codeType); + @SuppressWarnings("unchecked") + String datatypeName = scan((Class) next.getType()); + RuntimeChildDatatypeDefinition def = new RuntimeChildCodedDatatypeDefinition(next, elementName, datatypeName, min, max, codeTableName); + orderToElementDef.put(order, def); + } else { + @SuppressWarnings("unchecked") + String datatypeName = scan((Class) 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 theCodeType) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildChoiceDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildChoiceDefinition.java new file mode 100644 index 00000000000..9277cdddb51 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildChoiceDefinition.java @@ -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 myChoices; + + public RuntimeChildChoiceDefinition(Field theField, String theElementName, int theMin, int theMax, List theChoiceNames) { + super(theField, theElementName,theMin,theMax); + + myChoices= theChoiceNames; + } + + public List getChoices() { + return myChoices; + } + + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildCodedDatatypeDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildCodedDatatypeDefinition.java new file mode 100644 index 00000000000..7c6b3a71b35 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildCodedDatatypeDefinition.java @@ -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; + } + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildDatatypeDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildDatatypeDefinition.java new file mode 100644 index 00000000000..17782e59285 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildDatatypeDefinition.java @@ -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; + } + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildResourceDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildResourceDefinition.java new file mode 100644 index 00000000000..6c9ac32cf93 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildResourceDefinition.java @@ -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; + } + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeCompositeDatatypeDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeCompositeDatatypeDefinition.java new file mode 100644 index 00000000000..faeda7e35a3 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeCompositeDatatypeDefinition.java @@ -0,0 +1,12 @@ +package ca.uhn.fhir.context; + +import ca.uhn.fhir.model.api.ICompositeDatatype; + +public class RuntimeCompositeDatatypeDefinition extends BaseRuntimeCompositeElementDefinition { + + public RuntimeCompositeDatatypeDefinition(String theName, Class theImplementingClass) { + super(theName, theImplementingClass); + } + + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimePrimitiveDatatypeDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimePrimitiveDatatypeDefinition.java new file mode 100644 index 00000000000..3d90cb67b64 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimePrimitiveDatatypeDefinition.java @@ -0,0 +1,11 @@ +package ca.uhn.fhir.context; + +import ca.uhn.fhir.model.api.IPrimitiveDatatype; + +public class RuntimePrimitiveDatatypeDefinition extends BaseRuntimeElementDefinition{ + + public RuntimePrimitiveDatatypeDefinition(String theName, Class theImplementingClass) { + super(theName, theImplementingClass); + } + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeResourceDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeResourceDefinition.java new file mode 100644 index 00000000000..cdbb653a987 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeResourceDefinition.java @@ -0,0 +1,11 @@ +package ca.uhn.fhir.context; + +import ca.uhn.fhir.model.api.IResource; + +public class RuntimeResourceDefinition extends BaseRuntimeCompositeElementDefinition { + + public RuntimeResourceDefinition(Class theClass, String theName) { + super(theName, theClass); + } + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseCompositeDatatype.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseCompositeDatatype.java new file mode 100644 index 00000000000..c4201f05529 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseCompositeDatatype.java @@ -0,0 +1,6 @@ +package ca.uhn.fhir.model.api; + + +public class BaseCompositeDatatype extends BaseDatatype implements ICompositeDatatype { + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseDatatype.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseDatatype.java new file mode 100644 index 00000000000..ef9a56c6b66 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseDatatype.java @@ -0,0 +1,6 @@ +package ca.uhn.fhir.model.api; + + +public abstract class BaseDatatype implements IDatatype { + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseElement.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseElement.java new file mode 100644 index 00000000000..c3a67104a00 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseElement.java @@ -0,0 +1,5 @@ +package ca.uhn.fhir.model.api; + +public abstract class BaseElement implements IElement { + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BasePrimitiveDatatype.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BasePrimitiveDatatype.java new file mode 100644 index 00000000000..9a2f18f52ab --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BasePrimitiveDatatype.java @@ -0,0 +1,6 @@ +package ca.uhn.fhir.model.api; + + +public class BasePrimitiveDatatype extends BaseDatatype implements IPrimitiveDatatype { + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/CodeableConceptElement.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/CodeableConceptElement.java new file mode 100644 index 00000000000..e9be1fac60a --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/CodeableConceptElement.java @@ -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 type(); + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Constraint.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Constraint.java new file mode 100644 index 00000000000..ad2dd62f76a --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Constraint.java @@ -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 {}; +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/DatatypeDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/DatatypeDefinition.java new file mode 100644 index 00000000000..72b44ec377c --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/DatatypeDefinition.java @@ -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(); + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Description.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Description.java new file mode 100644 index 00000000000..e1e7ff1eb23 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Description.java @@ -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(); + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/EnumeratedCodeValue.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/EnumeratedCodeValue.java new file mode 100644 index 00000000000..6b837a1bdb1 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/EnumeratedCodeValue.java @@ -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 ""; +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/EnumeratedValueSet.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/EnumeratedValueSet.java new file mode 100644 index 00000000000..c8bf8dac5c9 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/EnumeratedValueSet.java @@ -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 {}; + + + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ICodeEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ICodeEnum.java new file mode 100644 index 00000000000..2a7dbe6b569 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ICodeEnum.java @@ -0,0 +1,5 @@ +package ca.uhn.fhir.model.api; + +public interface ICodeEnum extends IPrimitiveDatatype { + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ICompositeDatatype.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ICompositeDatatype.java new file mode 100644 index 00000000000..a23ffbeb211 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ICompositeDatatype.java @@ -0,0 +1,6 @@ +package ca.uhn.fhir.model.api; + + +public interface ICompositeDatatype extends IDatatype, ICompositeElement { + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ICompositeElement.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ICompositeElement.java new file mode 100644 index 00000000000..27d3068184a --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ICompositeElement.java @@ -0,0 +1,5 @@ +package ca.uhn.fhir.model.api; + +public interface ICompositeElement extends IElement { + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IDatatype.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IDatatype.java new file mode 100644 index 00000000000..c939f231de8 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IDatatype.java @@ -0,0 +1,5 @@ +package ca.uhn.fhir.model.api; + +public interface IDatatype extends IElement { + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IElement.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IElement.java new file mode 100644 index 00000000000..4a5e09c0107 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IElement.java @@ -0,0 +1,5 @@ +package ca.uhn.fhir.model.api; + +public interface IElement { + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IPrimitiveDatatype.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IPrimitiveDatatype.java new file mode 100644 index 00000000000..5b3ceca722b --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IPrimitiveDatatype.java @@ -0,0 +1,5 @@ +package ca.uhn.fhir.model.api; + +public interface IPrimitiveDatatype extends IDatatype { + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IResource.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IResource.java new file mode 100644 index 00000000000..83a0b304b3f --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IResource.java @@ -0,0 +1,6 @@ +package ca.uhn.fhir.model.api; + + +public interface IResource extends ICompositeElement { + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceChoiceElement.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceChoiceElement.java new file mode 100644 index 00000000000..30f41e88a43 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceChoiceElement.java @@ -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[] types() default {}; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceElement.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceElement.java new file mode 100644 index 00000000000..b68ebf2fae4 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceElement.java @@ -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(); + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceReference.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceReference.java new file mode 100644 index 00000000000..74713e99a6e --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceReference.java @@ -0,0 +1,7 @@ +package ca.uhn.fhir.model.api; + +import ca.uhn.fhir.model.resource.BaseResource; + +public class ResourceReference { + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceReferenceElement.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceReferenceElement.java new file mode 100644 index 00000000000..70b8ce197ea --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceReferenceElement.java @@ -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 type(); + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/AttachmentDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/AttachmentDt.java new file mode 100644 index 00000000000..c9865155680 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/AttachmentDt.java @@ -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; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/Base64BinaryDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/Base64BinaryDt.java new file mode 100644 index 00000000000..11f14994966 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/Base64BinaryDt.java @@ -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; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/BooleanDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/BooleanDt.java new file mode 100644 index 00000000000..1b658d6c4aa --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/BooleanDt.java @@ -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; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/CodeDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/CodeDt.java new file mode 100644 index 00000000000..d1d808be7d4 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/CodeDt.java @@ -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 extends BasePrimitiveDatatype { + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/CodeableConceptDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/CodeableConceptDt.java new file mode 100644 index 00000000000..12273321b93 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/CodeableConceptDt.java @@ -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 extends BaseCompositeDatatype { + + @ResourceElement(name="coding", order=0) + private List myCoding; + + @ResourceElement(name="text",order=1) + private StringDt myText; +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/CodingDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/CodingDt.java new file mode 100644 index 00000000000..fced4c7df7f --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/CodingDt.java @@ -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 myAssigner; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/DateDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/DateDt.java new file mode 100644 index 00000000000..6a81ec03ddf --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/DateDt.java @@ -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; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/DateTimeDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/DateTimeDt.java new file mode 100644 index 00000000000..802cb966fe6 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/DateTimeDt.java @@ -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; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/DecimalDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/DecimalDt.java new file mode 100644 index 00000000000..d667ad35231 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/DecimalDt.java @@ -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; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/IdentifierDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/IdentifierDt.java new file mode 100644 index 00000000000..921712d1bf3 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/IdentifierDt.java @@ -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 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 myAssigner; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/InstantDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/InstantDt.java new file mode 100644 index 00000000000..88ec86e6776 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/InstantDt.java @@ -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; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/IntegerDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/IntegerDt.java new file mode 100644 index 00000000000..5b1bdefafbf --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/IntegerDt.java @@ -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; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/PeriodDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/PeriodDt.java new file mode 100644 index 00000000000..ebbb3cafd62 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/PeriodDt.java @@ -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; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/QuantityDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/QuantityDt.java new file mode 100644 index 00000000000..cee5b00e99e --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/QuantityDt.java @@ -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; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/RatioDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/RatioDt.java new file mode 100644 index 00000000000..2686cb8fb62 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/RatioDt.java @@ -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; +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/SampledDataDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/SampledDataDt.java new file mode 100644 index 00000000000..a0d63c6d5cd --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/SampledDataDt.java @@ -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; +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/StringDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/StringDt.java new file mode 100644 index 00000000000..948327a287f --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/StringDt.java @@ -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; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/UriDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/UriDt.java new file mode 100644 index 00000000000..b8b94cd143c --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/datatype/UriDt.java @@ -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; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/BodySiteEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/BodySiteEnum.java new file mode 100644 index 00000000000..dbf2db2fba2 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/BodySiteEnum.java @@ -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 { + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/IdentifierUseEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/IdentifierUseEnum.java new file mode 100644 index 00000000000..34778c0b942 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/IdentifierUseEnum.java @@ -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 +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/ObservationCodesEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/ObservationCodesEnum.java new file mode 100644 index 00000000000..3663aa49795 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/ObservationCodesEnum.java @@ -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 { + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/ObservationInterpretationEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/ObservationInterpretationEnum.java new file mode 100644 index 00000000000..c702dac15b6 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/ObservationInterpretationEnum.java @@ -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 +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/ObservationMethodEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/ObservationMethodEnum.java new file mode 100644 index 00000000000..ea240e4ffc7 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/ObservationMethodEnum.java @@ -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 { + + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/ObservationReliabilityEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/ObservationReliabilityEnum.java new file mode 100644 index 00000000000..ea25d24b936 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/ObservationReliabilityEnum.java @@ -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 + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/ObservationStatusEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/ObservationStatusEnum.java new file mode 100644 index 00000000000..265579c8932 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/ObservationStatusEnum.java @@ -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 + + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/QuantityComparator.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/QuantityComparator.java new file mode 100644 index 00000000000..b1339383b22 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/enm/QuantityComparator.java @@ -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; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/BaseResource.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/BaseResource.java new file mode 100644 index 00000000000..2521a337ca3 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/BaseResource.java @@ -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 { + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/BaseResourceWithIdentifier.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/BaseResourceWithIdentifier.java new file mode 100644 index 00000000000..11264cb04c4 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/BaseResourceWithIdentifier.java @@ -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; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/Observation.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/Observation.java new file mode 100644 index 00000000000..93e79d335bf --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/Observation.java @@ -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 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 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 myStatus; + + @ResourceElement(name="reliability", order=7, min=1) + @CodeableConceptElement(type=ObservationStatusEnum.class) + private CodeableConceptDt myReliability; + + @ResourceElement(name="bodySite", order=8) + @CodeableConceptElement(type=BodySiteEnum.class) + private CodeableConceptDt myBodySite; + + @ResourceElement(name="method", order=9) + @CodeableConceptElement(type=ObservationMethodEnum.class) + private CodeableConceptDt myMethod; + + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/Organization.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/Organization.java new file mode 100644 index 00000000000..e910ccced2d --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/Organization.java @@ -0,0 +1,5 @@ +package ca.uhn.fhir.model.resource; + +public class Organization extends BaseResource { +//TODO: fill in +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/ResourceDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/ResourceDefinition.java new file mode 100644 index 00000000000..c631892ad13 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/ResourceDefinition.java @@ -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; + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/ValueSet.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/ValueSet.java new file mode 100644 index 00000000000..5046ac3c77e --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/ValueSet.java @@ -0,0 +1,5 @@ +package ca.uhn.fhir.model.resource; + +public class ValueSet extends BaseResource { + +} diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/context/ModelScannerTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/context/ModelScannerTest.java new file mode 100644 index 00000000000..b78faea7370 --- /dev/null +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/context/ModelScannerTest.java @@ -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); + + + } + +} diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000000..aa02d3093f3 --- /dev/null +++ b/pom.xml @@ -0,0 +1,48 @@ + + + + + org.sonatype.oss + oss-parent + 6 + + + 4.0.0 + ca.uhn.hapi.fhir + hapi-fhir + pom + 1.0-SNAPSHOT + HAPI + http://hl7api.sourceforge.net/ + + + + + + + + hapi-fhir-base + + + + UTF-8 + + 1.6.6 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.6 + 1.6 + + + + + +