Fix unit tests

This commit is contained in:
jamesagnew 2014-03-10 18:17:30 -04:00
parent 6140e73034
commit 53882b2c23
60 changed files with 710 additions and 360 deletions

View File

@ -28,3 +28,5 @@
* Support slices in the model * Support slices in the model
* Support extensions (declared and undeclared) in primitives, narratives, etc. * Support extensions (declared and undeclared) in primitives, narratives, etc.
* Create a Maven archetype for a server project and a client project

View File

@ -151,6 +151,8 @@
<version>3.3</version> <version>3.3</version>
</plugin> </plugin>
<!-- <!--
-->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId> <artifactId>maven-surefire-report-plugin</artifactId>
@ -176,7 +178,6 @@
<artifactId>maven-jxr-plugin</artifactId> <artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version> <version>2.3</version>
</plugin> </plugin>
-->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId> <artifactId>maven-project-info-reports-plugin</artifactId>

View File

@ -24,6 +24,9 @@ public abstract class BaseRuntimeElementCompositeDefinition<T extends IComposite
if (theNext == null) { if (theNext == null) {
throw new NullPointerException(); throw new NullPointerException();
} }
// if (theNext.getValidChildNames().contains("performetPractitioner")) {
// throw new NullPointerException();
// }
if (theNext.getExtensionUrl() != null) { if (theNext.getExtensionUrl() != null) {
throw new IllegalArgumentException("Shouldn't haven an extension URL, use addExtension instead"); throw new IllegalArgumentException("Shouldn't haven an extension URL, use addExtension instead");
} }

View File

@ -27,7 +27,7 @@ import ca.uhn.fhir.model.api.IPrimitiveDatatype;
import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.IResourceBlock; import ca.uhn.fhir.model.api.IResourceBlock;
import ca.uhn.fhir.model.api.IValueSetEnumBinder; import ca.uhn.fhir.model.api.IValueSetEnumBinder;
import ca.uhn.fhir.model.api.ResourceReference; import ca.uhn.fhir.model.api.BaseResourceReference;
import ca.uhn.fhir.model.api.annotation.Block; import ca.uhn.fhir.model.api.annotation.Block;
import ca.uhn.fhir.model.api.annotation.Child; import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.CodeTableDef; import ca.uhn.fhir.model.api.annotation.CodeTableDef;
@ -37,6 +37,7 @@ import ca.uhn.fhir.model.api.annotation.Extension;
import ca.uhn.fhir.model.api.annotation.ResourceDef; import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt; import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.primitive.BoundCodeDt; import ca.uhn.fhir.model.primitive.BoundCodeDt;
import ca.uhn.fhir.model.primitive.BoundCodeableConceptDt;
import ca.uhn.fhir.model.primitive.CodeDt; import ca.uhn.fhir.model.primitive.CodeDt;
import ca.uhn.fhir.model.primitive.DateDt; import ca.uhn.fhir.model.primitive.DateDt;
import ca.uhn.fhir.model.primitive.ICodedDatatype; import ca.uhn.fhir.model.primitive.ICodedDatatype;
@ -323,7 +324,7 @@ class ModelScanner {
if (IElement.class.isAssignableFrom(nextElementType)) { if (IElement.class.isAssignableFrom(nextElementType)) {
addScanAlso((Class<? extends IElement>) nextElementType); addScanAlso((Class<? extends IElement>) nextElementType);
} }
} else if (ResourceReference.class.isAssignableFrom(nextElementType)) { } else if (BaseResourceReference.class.isAssignableFrom(nextElementType)) {
/* /*
* Child is a resource reference * Child is a resource reference
*/ */
@ -361,9 +362,14 @@ class ModelScanner {
} else { } else {
def = new RuntimeChildPrimitiveDatatypeDefinition(next, elementName, descriptionAnnotation, childAnnotation, nextDatatype); def = new RuntimeChildPrimitiveDatatypeDefinition(next, elementName, descriptionAnnotation, childAnnotation, nextDatatype);
} }
} else {
if (nextElementType.equals(BoundCodeableConceptDt.class)) {
IValueSetEnumBinder<Enum<?>> binder = getBoundCodeBinder(next);
def = new RuntimeChildCompositeBoundDatatypeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype, binder);
} else { } else {
def = new RuntimeChildCompositeDatatypeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype); def = new RuntimeChildCompositeDatatypeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype);
} }
}
CodeableConceptElement concept = next.getAnnotation(CodeableConceptElement.class); CodeableConceptElement concept = next.getAnnotation(CodeableConceptElement.class);
if (concept != null) { if (concept != null) {

View File

@ -0,0 +1,27 @@
package ca.uhn.fhir.context;
import java.lang.reflect.Field;
import ca.uhn.fhir.model.api.IDatatype;
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Description;
public class RuntimeChildCompositeBoundDatatypeDefinition extends RuntimeChildCompositeDatatypeDefinition {
private IValueSetEnumBinder<Enum<?>> myBinder;
public RuntimeChildCompositeBoundDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class<? extends IDatatype> theDatatype, IValueSetEnumBinder<Enum<?>> theBinder) {
super(theField, theElementName, theChildAnnotation, theDescriptionAnnotation, theDatatype);
myBinder = theBinder;
if (theBinder==null) {
throw new IllegalArgumentException("Binder must not be null");
}
}
@Override
public IValueSetEnumBinder<Enum<?>> getInstanceConstructorArguments() {
return myBinder;
}
}

View File

@ -8,7 +8,7 @@ import java.util.Set;
import ca.uhn.fhir.model.api.IElement; import ca.uhn.fhir.model.api.IElement;
import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ResourceReference; import ca.uhn.fhir.model.api.BaseResourceReference;
import ca.uhn.fhir.model.api.annotation.Child; import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Description; import ca.uhn.fhir.model.api.annotation.Description;
@ -28,7 +28,7 @@ public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefi
@Override @Override
public String getChildNameByDatatype(Class<? extends IElement> theDatatype) { public String getChildNameByDatatype(Class<? extends IElement> theDatatype) {
if (ResourceReference.class.equals(theDatatype)) { if (BaseResourceReference.class.isAssignableFrom(theDatatype)) {
return getElementName(); return getElementName();
} }
return null; return null;
@ -36,7 +36,7 @@ public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefi
@Override @Override
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theDatatype) { public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IElement> theDatatype) {
if (ResourceReference.class.equals(theDatatype)) { if (BaseResourceReference.class.isAssignableFrom(theDatatype)) {
return myRuntimeDef; return myRuntimeDef;
} }
return null; return null;

View File

@ -11,7 +11,7 @@ import java.util.Set;
import ca.uhn.fhir.model.api.IDatatype; import ca.uhn.fhir.model.api.IDatatype;
import ca.uhn.fhir.model.api.IElement; import ca.uhn.fhir.model.api.IElement;
import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ResourceReference; import ca.uhn.fhir.model.api.BaseResourceReference;
import ca.uhn.fhir.model.api.UndeclaredExtension; import ca.uhn.fhir.model.api.UndeclaredExtension;
public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildDefinition { public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildDefinition {
@ -70,13 +70,13 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD
} }
// Resource Reference // Resource Reference
myDatatypeToAttributeName.put(ResourceReference.class, "valueReference"); myDatatypeToAttributeName.put(BaseResourceReference.class, "valueReference");
List<Class<? extends IResource>> types = new ArrayList<Class<? extends IResource>>(); List<Class<? extends IResource>> types = new ArrayList<Class<? extends IResource>>();
types.add(IResource.class); types.add(IResource.class);
RuntimeResourceReferenceDefinition def = new RuntimeResourceReferenceDefinition("valueResource", types); RuntimeResourceReferenceDefinition def = new RuntimeResourceReferenceDefinition("valueResource", types);
def.sealAndInitialize(theClassToElementDefinitions); def.sealAndInitialize(theClassToElementDefinitions);
myAttributeNameToDefinition.put("valueResource", def); myAttributeNameToDefinition.put("valueResource", def);
myDatatypeToDefinition.put(ResourceReference.class, def); myDatatypeToDefinition.put(BaseResourceReference.class, def);
} }

View File

@ -208,6 +208,7 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
StructureElement extSlice = theStruct.addElement(); StructureElement extSlice = theStruct.addElement();
extSlice.setName(elementName); extSlice.setName(elementName);
extSlice.setPath(join(path, '.') + '.' + elementName); extSlice.setPath(join(path, '.') + '.' + elementName);
extSlice.getDefinition().setIsModifier(theIsModifier);
extSlice.getDefinition().addType().setCode(DataTypeEnum.EXTENSION); extSlice.getDefinition().addType().setCode(DataTypeEnum.EXTENSION);
extSlice.getDefinition().setMin(0); extSlice.getDefinition().setMin(0);
extSlice.getDefinition().setMax("*"); extSlice.getDefinition().setMax("*");

View File

@ -6,15 +6,15 @@ import java.util.Map;
import ca.uhn.fhir.model.api.IElement; import ca.uhn.fhir.model.api.IElement;
import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ResourceReference; import ca.uhn.fhir.model.api.BaseResourceReference;
public class RuntimeResourceReferenceDefinition extends BaseRuntimeElementDefinition<ResourceReference> { public class RuntimeResourceReferenceDefinition extends BaseRuntimeElementDefinition<BaseResourceReference> {
private final List<Class<? extends IResource>> myResourceTypes; private final List<Class<? extends IResource>> myResourceTypes;
private HashMap<Class<? extends IResource>, RuntimeResourceDefinition> myResourceTypeToDefinition; private HashMap<Class<? extends IResource>, RuntimeResourceDefinition> myResourceTypeToDefinition;
public RuntimeResourceReferenceDefinition(String theName, List<Class<? extends IResource>> theResourceTypes) { public RuntimeResourceReferenceDefinition(String theName, List<Class<? extends IResource>> theResourceTypes) {
super(theName, ResourceReference.class); super(theName, BaseResourceReference.class);
if (theResourceTypes == null || theResourceTypes.isEmpty()) { if (theResourceTypes == null || theResourceTypes.isEmpty()) {
throw new ConfigurationException("Element '" + theName + "' has no resource types noted"); throw new ConfigurationException("Element '" + theName + "' has no resource types noted");
} }

View File

@ -1,11 +1,25 @@
package ca.uhn.fhir.model.api; package ca.uhn.fhir.model.api;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
public abstract class BaseElement implements IElement, ISupportsUndeclaredExtensions { public abstract class BaseElement implements IElement, ISupportsUndeclaredExtensions {
private List<UndeclaredExtension> myUndeclaredExtensions; private List<UndeclaredExtension> myUndeclaredExtensions;
private List<UndeclaredExtension> myUndeclaredModifierExtensions;
@Override
public List<UndeclaredExtension> getAllUndeclaredExtensions() {
ArrayList<UndeclaredExtension> retVal = new ArrayList<UndeclaredExtension>();
if (myUndeclaredExtensions != null) {
retVal.addAll(myUndeclaredExtensions);
}
if (myUndeclaredModifierExtensions != null) {
retVal.addAll(myUndeclaredModifierExtensions);
}
return Collections.unmodifiableList(retVal);
}
@Override @Override
public List<UndeclaredExtension> getUndeclaredExtensions() { public List<UndeclaredExtension> getUndeclaredExtensions() {
@ -15,6 +29,14 @@ public abstract class BaseElement implements IElement, ISupportsUndeclaredExtens
return myUndeclaredExtensions; return myUndeclaredExtensions;
} }
@Override
public List<UndeclaredExtension> getUndeclaredModifierExtensions() {
if (myUndeclaredModifierExtensions == null) {
myUndeclaredModifierExtensions = new ArrayList<UndeclaredExtension>();
}
return myUndeclaredModifierExtensions;
}
/** /**
* Intended to be called by extending classes {@link #isEmpty()} implementations, returns <code>true</code> if all content in this superclass instance is empty per the semantics of * Intended to be called by extending classes {@link #isEmpty()} implementations, returns <code>true</code> if all content in this superclass instance is empty per the semantics of
* {@link #isEmpty()}. * {@link #isEmpty()}.
@ -27,6 +49,13 @@ public abstract class BaseElement implements IElement, ISupportsUndeclaredExtens
} }
} }
} }
if (myUndeclaredModifierExtensions != null) {
for (UndeclaredExtension next : myUndeclaredModifierExtensions) {
if (!next.isEmpty()) {
return false;
}
}
}
return true; return true;
} }

View File

@ -0,0 +1,8 @@
package ca.uhn.fhir.model.api;
public abstract class BaseResourceReference extends BaseElement {
}

View File

@ -5,8 +5,18 @@ import java.util.List;
public interface ISupportsUndeclaredExtensions { public interface ISupportsUndeclaredExtensions {
/** /**
* Returns a list containing all undeclared extensions * Returns a list containing all undeclared non-modifier extensions
*/ */
List<UndeclaredExtension> getUndeclaredExtensions(); List<UndeclaredExtension> getUndeclaredExtensions();
/**
* Returns an <b>immutable</b> list containing all extensions (modifier and non-modifier)
*/
List<UndeclaredExtension> getAllUndeclaredExtensions();
/**
* Returns a list containing all undeclared modifier extensions
*/
List<UndeclaredExtension> getUndeclaredModifierExtensions();
} }

View File

@ -1,32 +0,0 @@
package ca.uhn.fhir.model.api;
import org.apache.commons.lang3.StringUtils;
public class ResourceReference implements IDatatype {
private String myDisplay;
private String myReference;
public String getDisplay() {
return myDisplay;
}
public String getReference() {
return myReference;
}
public void setDisplay(String theDisplay) {
myDisplay = theDisplay;
}
public void setReference(String theReference) {
myReference = theReference;
}
@Override
public boolean isEmpty() {
return StringUtils.isBlank(myDisplay) && StringUtils.isBlank(myReference);
}
}

View File

@ -1,27 +1,54 @@
package ca.uhn.fhir.model.api; package ca.uhn.fhir.model.api;
public class UndeclaredExtension extends BaseElement { public class UndeclaredExtension extends BaseElement {
private String myUrl; private String myUrl;
private IElement myValue; private IElement myValue;
private boolean myIsModifier;
public UndeclaredExtension() { public UndeclaredExtension(boolean theIsModifier) {
super(); myIsModifier = theIsModifier;
} }
public UndeclaredExtension(String theUrl) { public UndeclaredExtension(boolean theIsModifier, String theUrl) {
myUrl=theUrl; myIsModifier = theIsModifier;
myUrl = theUrl;
}
public boolean isModifier() {
return myIsModifier;
} }
public String getUrl() { public String getUrl() {
return myUrl; return myUrl;
} }
/**
* Returns the value of this extension, if one exists.
* <p>
* Note that if this extension contains extensions (instead of a datatype) then <b>this method will return null</b>. In that case, you must use {@link #getUndeclaredExtensions()} and
* {@link #getUndeclaredModifierExtensions()} to retrieve the child extensions.
* </p>
*/
public IElement getValue() { public IElement getValue() {
return myValue; return myValue;
} }
/**
* Returns the value of this extension, casted to a primitive datatype. This is a convenience method which should only be called if you are sure that the value for this particular extension will
* be a primitive.
* <p>
* Note that if this extension contains extensions (instead of a datatype) then <b>this method will return null</b>. In that case, you must use {@link #getUndeclaredExtensions()} and
* {@link #getUndeclaredModifierExtensions()} to retrieve the child extensions.
* </p>
*
* @throws ClassCastException
* If the value of this extension is not a primitive datatype
*/
public IPrimitiveDatatype<?> getValueAsPrimitive() {
return (IPrimitiveDatatype<?>) getValue();
}
public void setUrl(String theUrl) { public void setUrl(String theUrl) {
myUrl = theUrl; myUrl = theUrl;
} }
@ -32,7 +59,7 @@ public class UndeclaredExtension extends BaseElement {
@Override @Override
public boolean isEmpty() { public boolean isEmpty() {
return myValue == null || myValue.isEmpty(); return super.isBaseEmpty() && myValue == null || myValue.isEmpty();
} }
} }

View File

@ -13,6 +13,8 @@ public @interface ResourceDef {
String name(); String name();
String id() default "";
String profile() default ""; String profile() default "";
int identifierOrder() default ORDER_NOT_SPECIFIED; int identifierOrder() default ORDER_NOT_SPECIFIED;

View File

@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
* </p> * </p>
*/ */
@DatatypeDef(name="Address") @DatatypeDef(name="Address")
public class AddressDt extends BaseElement implements ICompositeDatatype { public class AddressDt
extends BaseElement implements ICompositeDatatype {
@Child(name="use", type=CodeDt.class, order=0, min=0, max=1) @Child(name="use", type=CodeDt.class, order=0, min=0, max=1)

View File

@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
* </p> * </p>
*/ */
@DatatypeDef(name="Attachment") @DatatypeDef(name="Attachment")
public class AttachmentDt extends BaseElement implements ICompositeDatatype { public class AttachmentDt
extends BaseElement implements ICompositeDatatype {
@Child(name="contentType", type=CodeDt.class, order=0, min=1, max=1) @Child(name="contentType", type=CodeDt.class, order=0, min=1, max=1)

View File

@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
* </p> * </p>
*/ */
@DatatypeDef(name="CodeableConcept") @DatatypeDef(name="CodeableConcept")
public class CodeableConceptDt extends BaseElement implements ICompositeDatatype { public class CodeableConceptDt
extends BaseElement implements ICompositeDatatype {
@Child(name="coding", type=CodingDt.class, order=0, min=0, max=Child.MAX_UNLIMITED) @Child(name="coding", type=CodingDt.class, order=0, min=0, max=Child.MAX_UNLIMITED)

View File

@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
* </p> * </p>
*/ */
@DatatypeDef(name="Coding") @DatatypeDef(name="Coding")
public class CodingDt extends BaseElement implements ICompositeDatatype { public class CodingDt
extends BaseElement implements ICompositeDatatype {
@Child(name="system", type=UriDt.class, order=0, min=0, max=1) @Child(name="system", type=UriDt.class, order=0, min=0, max=1)
@ -83,7 +84,7 @@ public class CodingDt extends BaseElement implements ICompositeDatatype {
shortDefinition="Set this coding was chosen from", shortDefinition="Set this coding was chosen from",
formalDefinition="The set of possible coded values this coding was chosen from or constrained by" formalDefinition="The set of possible coded values this coding was chosen from or constrained by"
) )
private ResourceReference myValueSet; private ResourceReferenceDt myValueSet;
@Override @Override
@ -316,9 +317,9 @@ public class CodingDt extends BaseElement implements ICompositeDatatype {
* The set of possible coded values this coding was chosen from or constrained by * The set of possible coded values this coding was chosen from or constrained by
* </p> * </p>
*/ */
public ResourceReference getValueSet() { public ResourceReferenceDt getValueSet() {
if (myValueSet == null) { if (myValueSet == null) {
myValueSet = new ResourceReference(); myValueSet = new ResourceReferenceDt();
} }
return myValueSet; return myValueSet;
} }
@ -331,7 +332,7 @@ public class CodingDt extends BaseElement implements ICompositeDatatype {
* The set of possible coded values this coding was chosen from or constrained by * The set of possible coded values this coding was chosen from or constrained by
* </p> * </p>
*/ */
public void setValueSet(ResourceReference theValue) { public void setValueSet(ResourceReferenceDt theValue) {
myValueSet = theValue; myValueSet = theValue;
} }

View File

@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
* </p> * </p>
*/ */
@DatatypeDef(name="Contact") @DatatypeDef(name="Contact")
public class ContactDt extends BaseElement implements ICompositeDatatype { public class ContactDt
extends BaseElement implements ICompositeDatatype {
@Child(name="system", type=CodeDt.class, order=0, min=0, max=1) @Child(name="system", type=CodeDt.class, order=0, min=0, max=1)

View File

@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
* </p> * </p>
*/ */
@DatatypeDef(name="HumanName") @DatatypeDef(name="HumanName")
public class HumanNameDt extends BaseElement implements ICompositeDatatype { public class HumanNameDt
extends BaseElement implements ICompositeDatatype {
@Child(name="use", type=CodeDt.class, order=0, min=0, max=1) @Child(name="use", type=CodeDt.class, order=0, min=0, max=1)

View File

@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
* </p> * </p>
*/ */
@DatatypeDef(name="Identifier") @DatatypeDef(name="Identifier")
public class IdentifierDt extends BaseElement implements ICompositeDatatype , IQueryParameterType { public class IdentifierDt
extends BaseElement implements ICompositeDatatype , IQueryParameterType {
/** /**
* Creates a new identifier * Creates a new identifier
@ -97,7 +98,7 @@ public class IdentifierDt extends BaseElement implements ICompositeDatatype , I
shortDefinition="Organization that issued id (may be just text)", shortDefinition="Organization that issued id (may be just text)",
formalDefinition="Organization that issued/manages the identifier" formalDefinition="Organization that issued/manages the identifier"
) )
private ResourceReference myAssigner; private ResourceReferenceDt myAssigner;
@Override @Override
@ -318,9 +319,9 @@ public class IdentifierDt extends BaseElement implements ICompositeDatatype , I
* Organization that issued/manages the identifier * Organization that issued/manages the identifier
* </p> * </p>
*/ */
public ResourceReference getAssigner() { public ResourceReferenceDt getAssigner() {
if (myAssigner == null) { if (myAssigner == null) {
myAssigner = new ResourceReference(); myAssigner = new ResourceReferenceDt();
} }
return myAssigner; return myAssigner;
} }
@ -333,7 +334,7 @@ public class IdentifierDt extends BaseElement implements ICompositeDatatype , I
* Organization that issued/manages the identifier * Organization that issued/manages the identifier
* </p> * </p>
*/ */
public void setAssigner(ResourceReference theValue) { public void setAssigner(ResourceReferenceDt theValue) {
myAssigner = theValue; myAssigner = theValue;
} }

View File

@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
* </p> * </p>
*/ */
@DatatypeDef(name="Period") @DatatypeDef(name="Period")
public class PeriodDt extends BaseElement implements ICompositeDatatype { public class PeriodDt
extends BaseElement implements ICompositeDatatype {
@Child(name="start", type=DateTimeDt.class, order=0, min=0, max=1) @Child(name="start", type=DateTimeDt.class, order=0, min=0, max=1)

View File

@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
* </p> * </p>
*/ */
@DatatypeDef(name="Quantity") @DatatypeDef(name="Quantity")
public class QuantityDt extends BaseElement implements ICompositeDatatype { public class QuantityDt
extends BaseElement implements ICompositeDatatype {
@Child(name="value", type=DecimalDt.class, order=0, min=0, max=1) @Child(name="value", type=DecimalDt.class, order=0, min=0, max=1)
@ -120,7 +121,7 @@ public class QuantityDt extends BaseElement implements ICompositeDatatype {
* The value of the measured amount. The value includes an implicit precision in the presentation of the value * The value of the measured amount. The value includes an implicit precision in the presentation of the value
* </p> * </p>
*/ */
public void setValue( long theValue) { public void setValue( java.math.BigDecimal theValue) {
myValue = new DecimalDt(theValue); myValue = new DecimalDt(theValue);
} }
@ -144,7 +145,7 @@ public class QuantityDt extends BaseElement implements ICompositeDatatype {
* The value of the measured amount. The value includes an implicit precision in the presentation of the value * The value of the measured amount. The value includes an implicit precision in the presentation of the value
* </p> * </p>
*/ */
public void setValue( java.math.BigDecimal theValue) { public void setValue( long theValue) {
myValue = new DecimalDt(theValue); myValue = new DecimalDt(theValue);
} }

View File

@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
* </p> * </p>
*/ */
@DatatypeDef(name="Range") @DatatypeDef(name="Range")
public class RangeDt extends BaseElement implements ICompositeDatatype { public class RangeDt
extends BaseElement implements ICompositeDatatype {
@Child(name="low", type=QuantityDt.class, order=0, min=0, max=1) @Child(name="low", type=QuantityDt.class, order=0, min=0, max=1)

View File

@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
* </p> * </p>
*/ */
@DatatypeDef(name="Ratio") @DatatypeDef(name="Ratio")
public class RatioDt extends BaseElement implements ICompositeDatatype { public class RatioDt
extends BaseElement implements ICompositeDatatype {
@Child(name="numerator", type=QuantityDt.class, order=0, min=0, max=1) @Child(name="numerator", type=QuantityDt.class, order=0, min=0, max=1)

View File

@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
* </p> * </p>
*/ */
@DatatypeDef(name="ResourceReference") @DatatypeDef(name="ResourceReference")
public class ResourceReferenceDt extends BaseElement implements ICompositeDatatype { public class ResourceReferenceDt
extends BaseResourceReference implements ICompositeDatatype {
@Child(name="reference", type=StringDt.class, order=0, min=0, max=1) @Child(name="reference", type=StringDt.class, order=0, min=0, max=1)

View File

@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
* </p> * </p>
*/ */
@DatatypeDef(name="SampledData") @DatatypeDef(name="SampledData")
public class SampledDataDt extends BaseElement implements ICompositeDatatype { public class SampledDataDt
extends BaseElement implements ICompositeDatatype {
@Child(name="origin", type=QuantityDt.class, order=0, min=1, max=1) @Child(name="origin", type=QuantityDt.class, order=0, min=1, max=1)
@ -165,7 +166,7 @@ public class SampledDataDt extends BaseElement implements ICompositeDatatype {
* The length of time between sampling times, measured in milliseconds * The length of time between sampling times, measured in milliseconds
* </p> * </p>
*/ */
public void setPeriod( long theValue) { public void setPeriod( java.math.BigDecimal theValue) {
myPeriod = new DecimalDt(theValue); myPeriod = new DecimalDt(theValue);
} }
@ -189,7 +190,7 @@ public class SampledDataDt extends BaseElement implements ICompositeDatatype {
* The length of time between sampling times, measured in milliseconds * The length of time between sampling times, measured in milliseconds
* </p> * </p>
*/ */
public void setPeriod( java.math.BigDecimal theValue) { public void setPeriod( long theValue) {
myPeriod = new DecimalDt(theValue); myPeriod = new DecimalDt(theValue);
} }
@ -232,7 +233,7 @@ public class SampledDataDt extends BaseElement implements ICompositeDatatype {
* A correction factor that is applied to the sampled data points before they are added to the origin * A correction factor that is applied to the sampled data points before they are added to the origin
* </p> * </p>
*/ */
public void setFactor( long theValue) { public void setFactor( java.math.BigDecimal theValue) {
myFactor = new DecimalDt(theValue); myFactor = new DecimalDt(theValue);
} }
@ -256,7 +257,7 @@ public class SampledDataDt extends BaseElement implements ICompositeDatatype {
* A correction factor that is applied to the sampled data points before they are added to the origin * A correction factor that is applied to the sampled data points before they are added to the origin
* </p> * </p>
*/ */
public void setFactor( java.math.BigDecimal theValue) { public void setFactor( long theValue) {
myFactor = new DecimalDt(theValue); myFactor = new DecimalDt(theValue);
} }
@ -299,7 +300,7 @@ public class SampledDataDt extends BaseElement implements ICompositeDatatype {
* The lower limit of detection of the measured points. This is needed if any of the data points have the value \"L\" (lower than detection limit) * The lower limit of detection of the measured points. This is needed if any of the data points have the value \"L\" (lower than detection limit)
* </p> * </p>
*/ */
public void setLowerLimit( long theValue) { public void setLowerLimit( java.math.BigDecimal theValue) {
myLowerLimit = new DecimalDt(theValue); myLowerLimit = new DecimalDt(theValue);
} }
@ -323,7 +324,7 @@ public class SampledDataDt extends BaseElement implements ICompositeDatatype {
* The lower limit of detection of the measured points. This is needed if any of the data points have the value \"L\" (lower than detection limit) * The lower limit of detection of the measured points. This is needed if any of the data points have the value \"L\" (lower than detection limit)
* </p> * </p>
*/ */
public void setLowerLimit( java.math.BigDecimal theValue) { public void setLowerLimit( long theValue) {
myLowerLimit = new DecimalDt(theValue); myLowerLimit = new DecimalDt(theValue);
} }
@ -366,7 +367,7 @@ public class SampledDataDt extends BaseElement implements ICompositeDatatype {
* The upper limit of detection of the measured points. This is needed if any of the data points have the value \"U\" (higher than detection limit) * The upper limit of detection of the measured points. This is needed if any of the data points have the value \"U\" (higher than detection limit)
* </p> * </p>
*/ */
public void setUpperLimit( long theValue) { public void setUpperLimit( java.math.BigDecimal theValue) {
myUpperLimit = new DecimalDt(theValue); myUpperLimit = new DecimalDt(theValue);
} }
@ -390,7 +391,7 @@ public class SampledDataDt extends BaseElement implements ICompositeDatatype {
* The upper limit of detection of the measured points. This is needed if any of the data points have the value \"U\" (higher than detection limit) * The upper limit of detection of the measured points. This is needed if any of the data points have the value \"U\" (higher than detection limit)
* </p> * </p>
*/ */
public void setUpperLimit( java.math.BigDecimal theValue) { public void setUpperLimit( long theValue) {
myUpperLimit = new DecimalDt(theValue); myUpperLimit = new DecimalDt(theValue);
} }

View File

@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
* </p> * </p>
*/ */
@DatatypeDef(name="Schedule") @DatatypeDef(name="Schedule")
public class ScheduleDt extends BaseElement implements ICompositeDatatype { public class ScheduleDt
extends BaseElement implements ICompositeDatatype {
@Child(name="event", type=PeriodDt.class, order=0, min=0, max=Child.MAX_UNLIMITED) @Child(name="event", type=PeriodDt.class, order=0, min=0, max=Child.MAX_UNLIMITED)
@ -319,7 +320,7 @@ public class ScheduleDt extends BaseElement implements ICompositeDatatype {
* How long each repetition should last * How long each repetition should last
* </p> * </p>
*/ */
public void setDuration( long theValue) { public void setDuration( java.math.BigDecimal theValue) {
myDuration = new DecimalDt(theValue); myDuration = new DecimalDt(theValue);
} }
@ -343,7 +344,7 @@ public class ScheduleDt extends BaseElement implements ICompositeDatatype {
* How long each repetition should last * How long each repetition should last
* </p> * </p>
*/ */
public void setDuration( java.math.BigDecimal theValue) { public void setDuration( long theValue) {
myDuration = new DecimalDt(theValue); myDuration = new DecimalDt(theValue);
} }

View File

@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
* Allows institutions to track their devices. * Allows institutions to track their devices.
* </p> * </p>
*/ */
@ResourceDef(name="Device", profile="http://hl7.org/fhir/profiles/Device") @ResourceDef(name="Device", profile="http://hl7.org/fhir/profiles/Device", id="device")
public class Device extends BaseResource implements IResource { public class Device extends BaseResource implements IResource {
/** /**
@ -184,7 +184,7 @@ public class Device extends BaseResource implements IResource {
shortDefinition="Organization responsible for device", shortDefinition="Organization responsible for device",
formalDefinition="An organization that is responsible for the provision and ongoing maintenance of the device" formalDefinition="An organization that is responsible for the provision and ongoing maintenance of the device"
) )
private ResourceReference myOwner; private ResourceReferenceDt myOwner;
@Child(name="location", order=9, min=0, max=1, type={ @Child(name="location", order=9, min=0, max=1, type={
Location.class, Location.class,
@ -193,7 +193,7 @@ public class Device extends BaseResource implements IResource {
shortDefinition="Where the resource is found", shortDefinition="Where the resource is found",
formalDefinition="The resource may be found in a literal location (i.e. GPS coordinates), a logical place (i.e. \"in/with the patient\"), or a coded location" formalDefinition="The resource may be found in a literal location (i.e. GPS coordinates), a logical place (i.e. \"in/with the patient\"), or a coded location"
) )
private ResourceReference myLocation; private ResourceReferenceDt myLocation;
@Child(name="patient", order=10, min=0, max=1, type={ @Child(name="patient", order=10, min=0, max=1, type={
Patient.class, Patient.class,
@ -202,7 +202,7 @@ public class Device extends BaseResource implements IResource {
shortDefinition="If the resource is affixed to a person", shortDefinition="If the resource is affixed to a person",
formalDefinition="Patient information, if the resource is affixed to a person" formalDefinition="Patient information, if the resource is affixed to a person"
) )
private ResourceReference myPatient; private ResourceReferenceDt myPatient;
@Child(name="contact", type=ContactDt.class, order=11, min=0, max=Child.MAX_UNLIMITED) @Child(name="contact", type=ContactDt.class, order=11, min=0, max=Child.MAX_UNLIMITED)
@Description( @Description(
@ -579,9 +579,9 @@ public class Device extends BaseResource implements IResource {
* An organization that is responsible for the provision and ongoing maintenance of the device * An organization that is responsible for the provision and ongoing maintenance of the device
* </p> * </p>
*/ */
public ResourceReference getOwner() { public ResourceReferenceDt getOwner() {
if (myOwner == null) { if (myOwner == null) {
myOwner = new ResourceReference(); myOwner = new ResourceReferenceDt();
} }
return myOwner; return myOwner;
} }
@ -594,7 +594,7 @@ public class Device extends BaseResource implements IResource {
* An organization that is responsible for the provision and ongoing maintenance of the device * An organization that is responsible for the provision and ongoing maintenance of the device
* </p> * </p>
*/ */
public void setOwner(ResourceReference theValue) { public void setOwner(ResourceReferenceDt theValue) {
myOwner = theValue; myOwner = theValue;
} }
@ -610,9 +610,9 @@ public class Device extends BaseResource implements IResource {
* The resource may be found in a literal location (i.e. GPS coordinates), a logical place (i.e. \"in/with the patient\"), or a coded location * The resource may be found in a literal location (i.e. GPS coordinates), a logical place (i.e. \"in/with the patient\"), or a coded location
* </p> * </p>
*/ */
public ResourceReference getLocation() { public ResourceReferenceDt getLocation() {
if (myLocation == null) { if (myLocation == null) {
myLocation = new ResourceReference(); myLocation = new ResourceReferenceDt();
} }
return myLocation; return myLocation;
} }
@ -625,7 +625,7 @@ public class Device extends BaseResource implements IResource {
* The resource may be found in a literal location (i.e. GPS coordinates), a logical place (i.e. \"in/with the patient\"), or a coded location * The resource may be found in a literal location (i.e. GPS coordinates), a logical place (i.e. \"in/with the patient\"), or a coded location
* </p> * </p>
*/ */
public void setLocation(ResourceReference theValue) { public void setLocation(ResourceReferenceDt theValue) {
myLocation = theValue; myLocation = theValue;
} }
@ -641,9 +641,9 @@ public class Device extends BaseResource implements IResource {
* Patient information, if the resource is affixed to a person * Patient information, if the resource is affixed to a person
* </p> * </p>
*/ */
public ResourceReference getPatient() { public ResourceReferenceDt getPatient() {
if (myPatient == null) { if (myPatient == null) {
myPatient = new ResourceReference(); myPatient = new ResourceReferenceDt();
} }
return myPatient; return myPatient;
} }
@ -656,7 +656,7 @@ public class Device extends BaseResource implements IResource {
* Patient information, if the resource is affixed to a person * Patient information, if the resource is affixed to a person
* </p> * </p>
*/ */
public void setPatient(ResourceReference theValue) { public void setPatient(ResourceReferenceDt theValue) {
myPatient = theValue; myPatient = theValue;
} }

View File

@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
* *
* </p> * </p>
*/ */
@ResourceDef(name="Group", profile="http://hl7.org/fhir/profiles/Group") @ResourceDef(name="Group", profile="http://hl7.org/fhir/profiles/Group", id="group")
public class Group extends BaseResource implements IResource { public class Group extends BaseResource implements IResource {
/** /**
@ -191,7 +191,7 @@ public class Group extends BaseResource implements IResource {
shortDefinition="Who is in group", shortDefinition="Who is in group",
formalDefinition="Identifies the resource instances that are members of the group." formalDefinition="Identifies the resource instances that are members of the group."
) )
private List<ResourceReference> myMember; private List<ResourceReferenceDt> myMember;
@Override @Override
@ -487,7 +487,7 @@ public class Group extends BaseResource implements IResource {
* Identifies the resource instances that are members of the group. * Identifies the resource instances that are members of the group.
* </p> * </p>
*/ */
public List<ResourceReference> getMember() { public List<ResourceReferenceDt> getMember() {
return myMember; return myMember;
} }
@ -499,7 +499,7 @@ public class Group extends BaseResource implements IResource {
* Identifies the resource instances that are members of the group. * Identifies the resource instances that are members of the group.
* </p> * </p>
*/ */
public void setMember(List<ResourceReference> theValue) { public void setMember(List<ResourceReferenceDt> theValue) {
myMember = theValue; myMember = theValue;
} }

View File

@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
* *
* </p> * </p>
*/ */
@ResourceDef(name="Location", profile="http://hl7.org/fhir/profiles/Location") @ResourceDef(name="Location", profile="http://hl7.org/fhir/profiles/Location", id="location")
public class Location extends BaseResource implements IResource { public class Location extends BaseResource implements IResource {
/** /**
@ -184,7 +184,7 @@ public class Location extends BaseResource implements IResource {
shortDefinition="The organization that is responsible for the provisioning and upkeep of the location", shortDefinition="The organization that is responsible for the provisioning and upkeep of the location",
formalDefinition="" formalDefinition=""
) )
private ResourceReference myManagingOrganization; private ResourceReferenceDt myManagingOrganization;
@Child(name="status", type=CodeDt.class, order=9, min=0, max=1) @Child(name="status", type=CodeDt.class, order=9, min=0, max=1)
@Description( @Description(
@ -200,7 +200,7 @@ public class Location extends BaseResource implements IResource {
shortDefinition="Another Location which this Location is physically part of", shortDefinition="Another Location which this Location is physically part of",
formalDefinition="" formalDefinition=""
) )
private ResourceReference myPartOf; private ResourceReferenceDt myPartOf;
@Child(name="mode", type=CodeDt.class, order=11, min=0, max=1) @Child(name="mode", type=CodeDt.class, order=11, min=0, max=1)
@Description( @Description(
@ -522,9 +522,9 @@ public class Location extends BaseResource implements IResource {
* *
* </p> * </p>
*/ */
public ResourceReference getManagingOrganization() { public ResourceReferenceDt getManagingOrganization() {
if (myManagingOrganization == null) { if (myManagingOrganization == null) {
myManagingOrganization = new ResourceReference(); myManagingOrganization = new ResourceReferenceDt();
} }
return myManagingOrganization; return myManagingOrganization;
} }
@ -537,7 +537,7 @@ public class Location extends BaseResource implements IResource {
* *
* </p> * </p>
*/ */
public void setManagingOrganization(ResourceReference theValue) { public void setManagingOrganization(ResourceReferenceDt theValue) {
myManagingOrganization = theValue; myManagingOrganization = theValue;
} }
@ -596,9 +596,9 @@ public class Location extends BaseResource implements IResource {
* *
* </p> * </p>
*/ */
public ResourceReference getPartOf() { public ResourceReferenceDt getPartOf() {
if (myPartOf == null) { if (myPartOf == null) {
myPartOf = new ResourceReference(); myPartOf = new ResourceReferenceDt();
} }
return myPartOf; return myPartOf;
} }
@ -611,7 +611,7 @@ public class Location extends BaseResource implements IResource {
* *
* </p> * </p>
*/ */
public void setPartOf(ResourceReference theValue) { public void setPartOf(ResourceReferenceDt theValue) {
myPartOf = theValue; myPartOf = theValue;
} }
@ -736,7 +736,7 @@ public class Location extends BaseResource implements IResource {
* Longitude. The value domain and the interpretation are the same as for the text of the longitude element in KML (see notes below) * Longitude. The value domain and the interpretation are the same as for the text of the longitude element in KML (see notes below)
* </p> * </p>
*/ */
public void setLongitude( long theValue) { public void setLongitude( java.math.BigDecimal theValue) {
myLongitude = new DecimalDt(theValue); myLongitude = new DecimalDt(theValue);
} }
@ -760,7 +760,7 @@ public class Location extends BaseResource implements IResource {
* Longitude. The value domain and the interpretation are the same as for the text of the longitude element in KML (see notes below) * Longitude. The value domain and the interpretation are the same as for the text of the longitude element in KML (see notes below)
* </p> * </p>
*/ */
public void setLongitude( java.math.BigDecimal theValue) { public void setLongitude( long theValue) {
myLongitude = new DecimalDt(theValue); myLongitude = new DecimalDt(theValue);
} }
@ -803,7 +803,7 @@ public class Location extends BaseResource implements IResource {
* Latitude. The value domain and the interpretation are the same as for the text of the latitude element in KML (see notes below) * Latitude. The value domain and the interpretation are the same as for the text of the latitude element in KML (see notes below)
* </p> * </p>
*/ */
public void setLatitude( long theValue) { public void setLatitude( java.math.BigDecimal theValue) {
myLatitude = new DecimalDt(theValue); myLatitude = new DecimalDt(theValue);
} }
@ -827,7 +827,7 @@ public class Location extends BaseResource implements IResource {
* Latitude. The value domain and the interpretation are the same as for the text of the latitude element in KML (see notes below) * Latitude. The value domain and the interpretation are the same as for the text of the latitude element in KML (see notes below)
* </p> * </p>
*/ */
public void setLatitude( java.math.BigDecimal theValue) { public void setLatitude( long theValue) {
myLatitude = new DecimalDt(theValue); myLatitude = new DecimalDt(theValue);
} }
@ -870,7 +870,7 @@ public class Location extends BaseResource implements IResource {
* Altitude. The value domain and the interpretation are the same as for the text of the altitude element in KML (see notes below) * Altitude. The value domain and the interpretation are the same as for the text of the altitude element in KML (see notes below)
* </p> * </p>
*/ */
public void setAltitude( long theValue) { public void setAltitude( java.math.BigDecimal theValue) {
myAltitude = new DecimalDt(theValue); myAltitude = new DecimalDt(theValue);
} }
@ -894,7 +894,7 @@ public class Location extends BaseResource implements IResource {
* Altitude. The value domain and the interpretation are the same as for the text of the altitude element in KML (see notes below) * Altitude. The value domain and the interpretation are the same as for the text of the altitude element in KML (see notes below)
* </p> * </p>
*/ */
public void setAltitude( java.math.BigDecimal theValue) { public void setAltitude( long theValue) {
myAltitude = new DecimalDt(theValue); myAltitude = new DecimalDt(theValue);
} }

View File

@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
* *
* </p> * </p>
*/ */
@ResourceDef(name="Medication", profile="http://hl7.org/fhir/profiles/Medication") @ResourceDef(name="Medication", profile="http://hl7.org/fhir/profiles/Medication", id="medication")
public class Medication extends BaseResource implements IResource { public class Medication extends BaseResource implements IResource {
/** /**
@ -139,7 +139,7 @@ public class Medication extends BaseResource implements IResource {
shortDefinition="Manufacturer of the item", shortDefinition="Manufacturer of the item",
formalDefinition="Describes the details of the manufacturer" formalDefinition="Describes the details of the manufacturer"
) )
private ResourceReference myManufacturer; private ResourceReferenceDt myManufacturer;
@Child(name="kind", type=CodeDt.class, order=4, min=0, max=1) @Child(name="kind", type=CodeDt.class, order=4, min=0, max=1)
@Description( @Description(
@ -295,9 +295,9 @@ public class Medication extends BaseResource implements IResource {
* Describes the details of the manufacturer * Describes the details of the manufacturer
* </p> * </p>
*/ */
public ResourceReference getManufacturer() { public ResourceReferenceDt getManufacturer() {
if (myManufacturer == null) { if (myManufacturer == null) {
myManufacturer = new ResourceReference(); myManufacturer = new ResourceReferenceDt();
} }
return myManufacturer; return myManufacturer;
} }
@ -310,7 +310,7 @@ public class Medication extends BaseResource implements IResource {
* Describes the details of the manufacturer * Describes the details of the manufacturer
* </p> * </p>
*/ */
public void setManufacturer(ResourceReference theValue) { public void setManufacturer(ResourceReferenceDt theValue) {
myManufacturer = theValue; myManufacturer = theValue;
} }
@ -561,7 +561,7 @@ public class Medication extends BaseResource implements IResource {
shortDefinition="The product contained", shortDefinition="The product contained",
formalDefinition="The actual ingredient - either a substance (simple ingredient) or another medication" formalDefinition="The actual ingredient - either a substance (simple ingredient) or another medication"
) )
private ResourceReference myItem; private ResourceReferenceDt myItem;
@Child(name="amount", type=RatioDt.class, order=1, min=0, max=1) @Child(name="amount", type=RatioDt.class, order=1, min=0, max=1)
@Description( @Description(
@ -586,7 +586,7 @@ public class Medication extends BaseResource implements IResource {
* The actual ingredient - either a substance (simple ingredient) or another medication * The actual ingredient - either a substance (simple ingredient) or another medication
* </p> * </p>
*/ */
public ResourceReference getItem() { public ResourceReferenceDt getItem() {
return myItem; return myItem;
} }
@ -598,7 +598,7 @@ public class Medication extends BaseResource implements IResource {
* The actual ingredient - either a substance (simple ingredient) or another medication * The actual ingredient - either a substance (simple ingredient) or another medication
* </p> * </p>
*/ */
public void setItem(ResourceReference theValue) { public void setItem(ResourceReferenceDt theValue) {
myItem = theValue; myItem = theValue;
} }

View File

@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
* Observations are a key aspect of healthcare. This resource is used to capture those that do not require more sophisticated mechanisms. * Observations are a key aspect of healthcare. This resource is used to capture those that do not require more sophisticated mechanisms.
* </p> * </p>
*/ */
@ResourceDef(name="Observation", profile="http://hl7.org/fhir/profiles/Observation") @ResourceDef(name="Observation", profile="http://hl7.org/fhir/profiles/Observation", id="observation")
public class Observation extends BaseResource implements IResource { public class Observation extends BaseResource implements IResource {
/** /**
@ -289,7 +289,7 @@ public class Observation extends BaseResource implements IResource {
shortDefinition="Who and/or what this is about", shortDefinition="Who and/or what this is about",
formalDefinition="The thing the observation is being made about" formalDefinition="The thing the observation is being made about"
) )
private ResourceReference mySubject; private ResourceReferenceDt mySubject;
@Child(name="specimen", order=12, min=0, max=1, type={ @Child(name="specimen", order=12, min=0, max=1, type={
Specimen.class, Specimen.class,
@ -298,7 +298,7 @@ public class Observation extends BaseResource implements IResource {
shortDefinition="Specimen used for this observation", shortDefinition="Specimen used for this observation",
formalDefinition="The specimen that was used when this observation was made" formalDefinition="The specimen that was used when this observation was made"
) )
private ResourceReference mySpecimen; private ResourceReferenceDt mySpecimen;
@Child(name="performer", order=13, min=0, max=Child.MAX_UNLIMITED, type={ @Child(name="performer", order=13, min=0, max=Child.MAX_UNLIMITED, type={
Practitioner.class, Practitioner.class,
@ -309,7 +309,7 @@ public class Observation extends BaseResource implements IResource {
shortDefinition="Who did the observation", shortDefinition="Who did the observation",
formalDefinition="Who was responsible for asserting the observed value as \"true\"" formalDefinition="Who was responsible for asserting the observed value as \"true\""
) )
private List<ResourceReference> myPerformer; private List<ResourceReferenceDt> myPerformer;
@Child(name="referenceRange", order=14, min=0, max=Child.MAX_UNLIMITED) @Child(name="referenceRange", order=14, min=0, max=Child.MAX_UNLIMITED)
@Description( @Description(
@ -748,7 +748,7 @@ public class Observation extends BaseResource implements IResource {
* The thing the observation is being made about * The thing the observation is being made about
* </p> * </p>
*/ */
public ResourceReference getSubject() { public ResourceReferenceDt getSubject() {
return mySubject; return mySubject;
} }
@ -760,7 +760,7 @@ public class Observation extends BaseResource implements IResource {
* The thing the observation is being made about * The thing the observation is being made about
* </p> * </p>
*/ */
public void setSubject(ResourceReference theValue) { public void setSubject(ResourceReferenceDt theValue) {
mySubject = theValue; mySubject = theValue;
} }
@ -776,9 +776,9 @@ public class Observation extends BaseResource implements IResource {
* The specimen that was used when this observation was made * The specimen that was used when this observation was made
* </p> * </p>
*/ */
public ResourceReference getSpecimen() { public ResourceReferenceDt getSpecimen() {
if (mySpecimen == null) { if (mySpecimen == null) {
mySpecimen = new ResourceReference(); mySpecimen = new ResourceReferenceDt();
} }
return mySpecimen; return mySpecimen;
} }
@ -791,7 +791,7 @@ public class Observation extends BaseResource implements IResource {
* The specimen that was used when this observation was made * The specimen that was used when this observation was made
* </p> * </p>
*/ */
public void setSpecimen(ResourceReference theValue) { public void setSpecimen(ResourceReferenceDt theValue) {
mySpecimen = theValue; mySpecimen = theValue;
} }
@ -807,7 +807,7 @@ public class Observation extends BaseResource implements IResource {
* Who was responsible for asserting the observed value as \"true\" * Who was responsible for asserting the observed value as \"true\"
* </p> * </p>
*/ */
public List<ResourceReference> getPerformer() { public List<ResourceReferenceDt> getPerformer() {
return myPerformer; return myPerformer;
} }
@ -819,7 +819,7 @@ public class Observation extends BaseResource implements IResource {
* Who was responsible for asserting the observed value as \"true\" * Who was responsible for asserting the observed value as \"true\"
* </p> * </p>
*/ */
public void setPerformer(List<ResourceReference> theValue) { public void setPerformer(List<ResourceReferenceDt> theValue) {
myPerformer = theValue; myPerformer = theValue;
} }
@ -1111,7 +1111,7 @@ public class Observation extends BaseResource implements IResource {
shortDefinition="Observation that is related to this one", shortDefinition="Observation that is related to this one",
formalDefinition="A reference to the observation that is related to this observation" formalDefinition="A reference to the observation that is related to this observation"
) )
private ResourceReference myTarget; private ResourceReferenceDt myTarget;
@Override @Override
@ -1172,9 +1172,9 @@ public class Observation extends BaseResource implements IResource {
* A reference to the observation that is related to this observation * A reference to the observation that is related to this observation
* </p> * </p>
*/ */
public ResourceReference getTarget() { public ResourceReferenceDt getTarget() {
if (myTarget == null) { if (myTarget == null) {
myTarget = new ResourceReference(); myTarget = new ResourceReferenceDt();
} }
return myTarget; return myTarget;
} }
@ -1187,7 +1187,7 @@ public class Observation extends BaseResource implements IResource {
* A reference to the observation that is related to this observation * A reference to the observation that is related to this observation
* </p> * </p>
*/ */
public void setTarget(ResourceReference theValue) { public void setTarget(ResourceReferenceDt theValue) {
myTarget = theValue; myTarget = theValue;
} }

View File

@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
* *
* </p> * </p>
*/ */
@ResourceDef(name="Organization", profile="http://hl7.org/fhir/profiles/Organization") @ResourceDef(name="Organization", profile="http://hl7.org/fhir/profiles/Organization", id="organization")
public class Organization extends BaseResource implements IResource { public class Organization extends BaseResource implements IResource {
/** /**
@ -153,7 +153,7 @@ public class Organization extends BaseResource implements IResource {
shortDefinition="The organization of which this organization forms a part", shortDefinition="The organization of which this organization forms a part",
formalDefinition="The organization of which this organization forms a part" formalDefinition="The organization of which this organization forms a part"
) )
private ResourceReference myPartOf; private ResourceReferenceDt myPartOf;
@Child(name="contact", order=6, min=0, max=Child.MAX_UNLIMITED) @Child(name="contact", order=6, min=0, max=Child.MAX_UNLIMITED)
@Description( @Description(
@ -169,7 +169,7 @@ public class Organization extends BaseResource implements IResource {
shortDefinition="Location(s) the organization uses to provide services", shortDefinition="Location(s) the organization uses to provide services",
formalDefinition="Location(s) the organization uses to provide services" formalDefinition="Location(s) the organization uses to provide services"
) )
private List<ResourceReference> myLocation; private List<ResourceReferenceDt> myLocation;
@Child(name="active", type=BooleanDt.class, order=8, min=0, max=1) @Child(name="active", type=BooleanDt.class, order=8, min=0, max=1)
@Description( @Description(
@ -412,9 +412,9 @@ public class Organization extends BaseResource implements IResource {
* The organization of which this organization forms a part * The organization of which this organization forms a part
* </p> * </p>
*/ */
public ResourceReference getPartOf() { public ResourceReferenceDt getPartOf() {
if (myPartOf == null) { if (myPartOf == null) {
myPartOf = new ResourceReference(); myPartOf = new ResourceReferenceDt();
} }
return myPartOf; return myPartOf;
} }
@ -427,7 +427,7 @@ public class Organization extends BaseResource implements IResource {
* The organization of which this organization forms a part * The organization of which this organization forms a part
* </p> * </p>
*/ */
public void setPartOf(ResourceReference theValue) { public void setPartOf(ResourceReferenceDt theValue) {
myPartOf = theValue; myPartOf = theValue;
} }
@ -487,9 +487,9 @@ public class Organization extends BaseResource implements IResource {
* Location(s) the organization uses to provide services * Location(s) the organization uses to provide services
* </p> * </p>
*/ */
public List<ResourceReference> getLocation() { public List<ResourceReferenceDt> getLocation() {
if (myLocation == null) { if (myLocation == null) {
myLocation = new ArrayList<ResourceReference>(); myLocation = new ArrayList<ResourceReferenceDt>();
} }
return myLocation; return myLocation;
} }
@ -502,7 +502,7 @@ public class Organization extends BaseResource implements IResource {
* Location(s) the organization uses to provide services * Location(s) the organization uses to provide services
* </p> * </p>
*/ */
public void setLocation(List<ResourceReference> theValue) { public void setLocation(List<ResourceReferenceDt> theValue) {
myLocation = theValue; myLocation = theValue;
} }

View File

@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
* Tracking patient is the center of the healthcare process * Tracking patient is the center of the healthcare process
* </p> * </p>
*/ */
@ResourceDef(name="Patient", profile="http://hl7.org/fhir/profiles/Patient") @ResourceDef(name="Patient", profile="http://hl7.org/fhir/profiles/Patient", id="patient")
public class Patient extends BaseResource implements IResource { public class Patient extends BaseResource implements IResource {
/** /**
@ -296,7 +296,7 @@ public class Patient extends BaseResource implements IResource {
shortDefinition="Patient's nominated care provider", shortDefinition="Patient's nominated care provider",
formalDefinition="Patient's nominated care provider" formalDefinition="Patient's nominated care provider"
) )
private List<ResourceReference> myCareProvider; private List<ResourceReferenceDt> myCareProvider;
@Child(name="managingOrganization", order=14, min=0, max=1, type={ @Child(name="managingOrganization", order=14, min=0, max=1, type={
Organization.class, Organization.class,
@ -305,7 +305,7 @@ public class Patient extends BaseResource implements IResource {
shortDefinition="Organization that is the custodian of the patient record", shortDefinition="Organization that is the custodian of the patient record",
formalDefinition="Organization that is the custodian of the patient record" formalDefinition="Organization that is the custodian of the patient record"
) )
private ResourceReference myManagingOrganization; private ResourceReferenceDt myManagingOrganization;
@Child(name="link", order=15, min=0, max=Child.MAX_UNLIMITED) @Child(name="link", order=15, min=0, max=Child.MAX_UNLIMITED)
@Description( @Description(
@ -873,7 +873,7 @@ public class Patient extends BaseResource implements IResource {
* Patient's nominated care provider * Patient's nominated care provider
* </p> * </p>
*/ */
public List<ResourceReference> getCareProvider() { public List<ResourceReferenceDt> getCareProvider() {
return myCareProvider; return myCareProvider;
} }
@ -885,7 +885,7 @@ public class Patient extends BaseResource implements IResource {
* Patient's nominated care provider * Patient's nominated care provider
* </p> * </p>
*/ */
public void setCareProvider(List<ResourceReference> theValue) { public void setCareProvider(List<ResourceReferenceDt> theValue) {
myCareProvider = theValue; myCareProvider = theValue;
} }
@ -901,9 +901,9 @@ public class Patient extends BaseResource implements IResource {
* Organization that is the custodian of the patient record * Organization that is the custodian of the patient record
* </p> * </p>
*/ */
public ResourceReference getManagingOrganization() { public ResourceReferenceDt getManagingOrganization() {
if (myManagingOrganization == null) { if (myManagingOrganization == null) {
myManagingOrganization = new ResourceReference(); myManagingOrganization = new ResourceReferenceDt();
} }
return myManagingOrganization; return myManagingOrganization;
} }
@ -916,7 +916,7 @@ public class Patient extends BaseResource implements IResource {
* Organization that is the custodian of the patient record * Organization that is the custodian of the patient record
* </p> * </p>
*/ */
public void setManagingOrganization(ResourceReference theValue) { public void setManagingOrganization(ResourceReferenceDt theValue) {
myManagingOrganization = theValue; myManagingOrganization = theValue;
} }
@ -1062,7 +1062,7 @@ public class Patient extends BaseResource implements IResource {
shortDefinition="Organization that is associated with the contact", shortDefinition="Organization that is associated with the contact",
formalDefinition="Organization on behalf of which the contact is acting or for which the contact is working." formalDefinition="Organization on behalf of which the contact is acting or for which the contact is working."
) )
private ResourceReference myOrganization; private ResourceReferenceDt myOrganization;
@Override @Override
@ -1273,9 +1273,9 @@ public class Patient extends BaseResource implements IResource {
* Organization on behalf of which the contact is acting or for which the contact is working. * Organization on behalf of which the contact is acting or for which the contact is working.
* </p> * </p>
*/ */
public ResourceReference getOrganization() { public ResourceReferenceDt getOrganization() {
if (myOrganization == null) { if (myOrganization == null) {
myOrganization = new ResourceReference(); myOrganization = new ResourceReferenceDt();
} }
return myOrganization; return myOrganization;
} }
@ -1288,7 +1288,7 @@ public class Patient extends BaseResource implements IResource {
* Organization on behalf of which the contact is acting or for which the contact is working. * Organization on behalf of which the contact is acting or for which the contact is working.
* </p> * </p>
*/ */
public void setOrganization(ResourceReference theValue) { public void setOrganization(ResourceReferenceDt theValue) {
myOrganization = theValue; myOrganization = theValue;
} }
@ -1463,7 +1463,7 @@ public class Patient extends BaseResource implements IResource {
shortDefinition="The other patient resource that the link refers to", shortDefinition="The other patient resource that the link refers to",
formalDefinition="The other patient resource that the link refers to" formalDefinition="The other patient resource that the link refers to"
) )
private ResourceReference myOther; private ResourceReferenceDt myOther;
@Child(name="type", type=CodeDt.class, order=1, min=1, max=1) @Child(name="type", type=CodeDt.class, order=1, min=1, max=1)
@Description( @Description(
@ -1488,9 +1488,9 @@ public class Patient extends BaseResource implements IResource {
* The other patient resource that the link refers to * The other patient resource that the link refers to
* </p> * </p>
*/ */
public ResourceReference getOther() { public ResourceReferenceDt getOther() {
if (myOther == null) { if (myOther == null) {
myOther = new ResourceReference(); myOther = new ResourceReferenceDt();
} }
return myOther; return myOther;
} }
@ -1503,7 +1503,7 @@ public class Patient extends BaseResource implements IResource {
* The other patient resource that the link refers to * The other patient resource that the link refers to
* </p> * </p>
*/ */
public void setOther(ResourceReference theValue) { public void setOther(ResourceReferenceDt theValue) {
myOther = theValue; myOther = theValue;
} }

View File

@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
* Need to track doctors, staff, locums etc. for both healthcare practitioners, funders, etc. * Need to track doctors, staff, locums etc. for both healthcare practitioners, funders, etc.
* </p> * </p>
*/ */
@ResourceDef(name="Practitioner", profile="http://hl7.org/fhir/profiles/Practitioner") @ResourceDef(name="Practitioner", profile="http://hl7.org/fhir/profiles/Practitioner", id="practitioner")
public class Practitioner extends BaseResource implements IResource { public class Practitioner extends BaseResource implements IResource {
/** /**
@ -187,7 +187,7 @@ public class Practitioner extends BaseResource implements IResource {
shortDefinition="The represented organization", shortDefinition="The represented organization",
formalDefinition="The organization that the practitioner represents" formalDefinition="The organization that the practitioner represents"
) )
private ResourceReference myOrganization; private ResourceReferenceDt myOrganization;
@Child(name="role", type=CodeableConceptDt.class, order=8, min=0, max=Child.MAX_UNLIMITED) @Child(name="role", type=CodeableConceptDt.class, order=8, min=0, max=Child.MAX_UNLIMITED)
@Description( @Description(
@ -217,7 +217,7 @@ public class Practitioner extends BaseResource implements IResource {
shortDefinition="The location(s) at which this practitioner provides care", shortDefinition="The location(s) at which this practitioner provides care",
formalDefinition="The location(s) at which this practitioner provides care" formalDefinition="The location(s) at which this practitioner provides care"
) )
private List<ResourceReference> myLocation; private List<ResourceReferenceDt> myLocation;
@Child(name="qualification", order=12, min=0, max=Child.MAX_UNLIMITED) @Child(name="qualification", order=12, min=0, max=Child.MAX_UNLIMITED)
@Description( @Description(
@ -541,9 +541,9 @@ public class Practitioner extends BaseResource implements IResource {
* The organization that the practitioner represents * The organization that the practitioner represents
* </p> * </p>
*/ */
public ResourceReference getOrganization() { public ResourceReferenceDt getOrganization() {
if (myOrganization == null) { if (myOrganization == null) {
myOrganization = new ResourceReference(); myOrganization = new ResourceReferenceDt();
} }
return myOrganization; return myOrganization;
} }
@ -556,7 +556,7 @@ public class Practitioner extends BaseResource implements IResource {
* The organization that the practitioner represents * The organization that the practitioner represents
* </p> * </p>
*/ */
public void setOrganization(ResourceReference theValue) { public void setOrganization(ResourceReferenceDt theValue) {
myOrganization = theValue; myOrganization = theValue;
} }
@ -715,9 +715,9 @@ public class Practitioner extends BaseResource implements IResource {
* The location(s) at which this practitioner provides care * The location(s) at which this practitioner provides care
* </p> * </p>
*/ */
public List<ResourceReference> getLocation() { public List<ResourceReferenceDt> getLocation() {
if (myLocation == null) { if (myLocation == null) {
myLocation = new ArrayList<ResourceReference>(); myLocation = new ArrayList<ResourceReferenceDt>();
} }
return myLocation; return myLocation;
} }
@ -730,7 +730,7 @@ public class Practitioner extends BaseResource implements IResource {
* The location(s) at which this practitioner provides care * The location(s) at which this practitioner provides care
* </p> * </p>
*/ */
public void setLocation(List<ResourceReference> theValue) { public void setLocation(List<ResourceReferenceDt> theValue) {
myLocation = theValue; myLocation = theValue;
} }
@ -856,7 +856,7 @@ public class Practitioner extends BaseResource implements IResource {
shortDefinition="Organization that regulates and issues the qualification", shortDefinition="Organization that regulates and issues the qualification",
formalDefinition="Organization that regulates and issues the qualification" formalDefinition="Organization that regulates and issues the qualification"
) )
private ResourceReference myIssuer; private ResourceReferenceDt myIssuer;
@Override @Override
@ -936,9 +936,9 @@ public class Practitioner extends BaseResource implements IResource {
* Organization that regulates and issues the qualification * Organization that regulates and issues the qualification
* </p> * </p>
*/ */
public ResourceReference getIssuer() { public ResourceReferenceDt getIssuer() {
if (myIssuer == null) { if (myIssuer == null) {
myIssuer = new ResourceReference(); myIssuer = new ResourceReferenceDt();
} }
return myIssuer; return myIssuer;
} }
@ -951,7 +951,7 @@ public class Practitioner extends BaseResource implements IResource {
* Organization that regulates and issues the qualification * Organization that regulates and issues the qualification
* </p> * </p>
*/ */
public void setIssuer(ResourceReference theValue) { public void setIssuer(ResourceReferenceDt theValue) {
myIssuer = theValue; myIssuer = theValue;
} }

View File

@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
* *
* </p> * </p>
*/ */
@ResourceDef(name="Profile", profile="http://hl7.org/fhir/profiles/Profile") @ResourceDef(name="Profile", profile="http://hl7.org/fhir/profiles/Profile", id="profile")
public class Profile extends BaseResource implements IResource { public class Profile extends BaseResource implements IResource {
/** /**

View File

@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
* *
* </p> * </p>
*/ */
@ResourceDef(name="Specimen", profile="http://hl7.org/fhir/profiles/Specimen") @ResourceDef(name="Specimen", profile="http://hl7.org/fhir/profiles/Specimen", id="specimen")
public class Specimen extends BaseResource implements IResource { public class Specimen extends BaseResource implements IResource {
/** /**
@ -82,7 +82,7 @@ public class Specimen extends BaseResource implements IResource {
shortDefinition="Where the specimen came from. This may be the patient(s) or from the environment or a device", shortDefinition="Where the specimen came from. This may be the patient(s) or from the environment or a device",
formalDefinition="" formalDefinition=""
) )
private ResourceReference mySubject; private ResourceReferenceDt mySubject;
@Child(name="accessionIdentifier", type=IdentifierDt.class, order=4, min=0, max=1) @Child(name="accessionIdentifier", type=IdentifierDt.class, order=4, min=0, max=1)
@Description( @Description(
@ -254,7 +254,7 @@ public class Specimen extends BaseResource implements IResource {
* *
* </p> * </p>
*/ */
public ResourceReference getSubject() { public ResourceReferenceDt getSubject() {
return mySubject; return mySubject;
} }
@ -266,7 +266,7 @@ public class Specimen extends BaseResource implements IResource {
* *
* </p> * </p>
*/ */
public void setSubject(ResourceReference theValue) { public void setSubject(ResourceReferenceDt theValue) {
mySubject = theValue; mySubject = theValue;
} }
@ -502,7 +502,7 @@ public class Specimen extends BaseResource implements IResource {
shortDefinition="The subject of the relationship", shortDefinition="The subject of the relationship",
formalDefinition="The specimen resource that is the target of this relationship" formalDefinition="The specimen resource that is the target of this relationship"
) )
private List<ResourceReference> myTarget; private List<ResourceReferenceDt> myTarget;
@Override @Override
@ -563,9 +563,9 @@ public class Specimen extends BaseResource implements IResource {
* The specimen resource that is the target of this relationship * The specimen resource that is the target of this relationship
* </p> * </p>
*/ */
public List<ResourceReference> getTarget() { public List<ResourceReferenceDt> getTarget() {
if (myTarget == null) { if (myTarget == null) {
myTarget = new ArrayList<ResourceReference>(); myTarget = new ArrayList<ResourceReferenceDt>();
} }
return myTarget; return myTarget;
} }
@ -578,7 +578,7 @@ public class Specimen extends BaseResource implements IResource {
* The specimen resource that is the target of this relationship * The specimen resource that is the target of this relationship
* </p> * </p>
*/ */
public void setTarget(List<ResourceReference> theValue) { public void setTarget(List<ResourceReferenceDt> theValue) {
myTarget = theValue; myTarget = theValue;
} }
@ -606,7 +606,7 @@ public class Specimen extends BaseResource implements IResource {
shortDefinition="Who collected the specimen", shortDefinition="Who collected the specimen",
formalDefinition="Person who collected the specimen" formalDefinition="Person who collected the specimen"
) )
private ResourceReference myCollector; private ResourceReferenceDt myCollector;
@Child(name="comment", type=StringDt.class, order=1, min=0, max=Child.MAX_UNLIMITED) @Child(name="comment", type=StringDt.class, order=1, min=0, max=Child.MAX_UNLIMITED)
@Description( @Description(
@ -662,9 +662,9 @@ public class Specimen extends BaseResource implements IResource {
* Person who collected the specimen * Person who collected the specimen
* </p> * </p>
*/ */
public ResourceReference getCollector() { public ResourceReferenceDt getCollector() {
if (myCollector == null) { if (myCollector == null) {
myCollector = new ResourceReference(); myCollector = new ResourceReferenceDt();
} }
return myCollector; return myCollector;
} }
@ -677,7 +677,7 @@ public class Specimen extends BaseResource implements IResource {
* Person who collected the specimen * Person who collected the specimen
* </p> * </p>
*/ */
public void setCollector(ResourceReference theValue) { public void setCollector(ResourceReferenceDt theValue) {
myCollector = theValue; myCollector = theValue;
} }
@ -911,7 +911,7 @@ public class Specimen extends BaseResource implements IResource {
shortDefinition="Material used in the processing step", shortDefinition="Material used in the processing step",
formalDefinition="" formalDefinition=""
) )
private List<ResourceReference> myAdditive; private List<ResourceReferenceDt> myAdditive;
@Override @Override
@ -1015,9 +1015,9 @@ public class Specimen extends BaseResource implements IResource {
* *
* </p> * </p>
*/ */
public List<ResourceReference> getAdditive() { public List<ResourceReferenceDt> getAdditive() {
if (myAdditive == null) { if (myAdditive == null) {
myAdditive = new ArrayList<ResourceReference>(); myAdditive = new ArrayList<ResourceReferenceDt>();
} }
return myAdditive; return myAdditive;
} }
@ -1030,7 +1030,7 @@ public class Specimen extends BaseResource implements IResource {
* *
* </p> * </p>
*/ */
public void setAdditive(List<ResourceReference> theValue) { public void setAdditive(List<ResourceReferenceDt> theValue) {
myAdditive = theValue; myAdditive = theValue;
} }
@ -1093,7 +1093,7 @@ public class Specimen extends BaseResource implements IResource {
shortDefinition="Additive associated with container", shortDefinition="Additive associated with container",
formalDefinition="Additive associated with the container" formalDefinition="Additive associated with the container"
) )
private ResourceReference myAdditive; private ResourceReferenceDt myAdditive;
@Override @Override
@ -1291,9 +1291,9 @@ public class Specimen extends BaseResource implements IResource {
* Additive associated with the container * Additive associated with the container
* </p> * </p>
*/ */
public ResourceReference getAdditive() { public ResourceReferenceDt getAdditive() {
if (myAdditive == null) { if (myAdditive == null) {
myAdditive = new ResourceReference(); myAdditive = new ResourceReferenceDt();
} }
return myAdditive; return myAdditive;
} }
@ -1306,7 +1306,7 @@ public class Specimen extends BaseResource implements IResource {
* Additive associated with the container * Additive associated with the container
* </p> * </p>
*/ */
public void setAdditive(ResourceReference theValue) { public void setAdditive(ResourceReferenceDt theValue) {
myAdditive = theValue; myAdditive = theValue;
} }

View File

@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
* *
* </p> * </p>
*/ */
@ResourceDef(name="Substance", profile="http://hl7.org/fhir/profiles/Substance") @ResourceDef(name="Substance", profile="http://hl7.org/fhir/profiles/Substance", id="substance")
public class Substance extends BaseResource implements IResource { public class Substance extends BaseResource implements IResource {
/** /**
@ -470,7 +470,7 @@ public class Substance extends BaseResource implements IResource {
shortDefinition="A component of the substance", shortDefinition="A component of the substance",
formalDefinition="Another substance that is a component of this substance" formalDefinition="Another substance that is a component of this substance"
) )
private ResourceReference mySubstance; private ResourceReferenceDt mySubstance;
@Override @Override
@ -519,9 +519,9 @@ public class Substance extends BaseResource implements IResource {
* Another substance that is a component of this substance * Another substance that is a component of this substance
* </p> * </p>
*/ */
public ResourceReference getSubstance() { public ResourceReferenceDt getSubstance() {
if (mySubstance == null) { if (mySubstance == null) {
mySubstance = new ResourceReference(); mySubstance = new ResourceReferenceDt();
} }
return mySubstance; return mySubstance;
} }
@ -534,7 +534,7 @@ public class Substance extends BaseResource implements IResource {
* Another substance that is a component of this substance * Another substance that is a component of this substance
* </p> * </p>
*/ */
public void setSubstance(ResourceReference theValue) { public void setSubstance(ResourceReferenceDt theValue) {
mySubstance = theValue; mySubstance = theValue;
} }

View File

@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
* *
* </p> * </p>
*/ */
@ResourceDef(name="ValueSet", profile="http://hl7.org/fhir/profiles/ValueSet") @ResourceDef(name="ValueSet", profile="http://hl7.org/fhir/profiles/ValueSet", id="valueset")
public class ValueSet extends BaseResource implements IResource { public class ValueSet extends BaseResource implements IResource {
/** /**

View File

@ -30,8 +30,9 @@ import ca.uhn.fhir.model.api.IPrimitiveDatatype;
import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.IResourceBlock; import ca.uhn.fhir.model.api.IResourceBlock;
import ca.uhn.fhir.model.api.ISupportsUndeclaredExtensions; import ca.uhn.fhir.model.api.ISupportsUndeclaredExtensions;
import ca.uhn.fhir.model.api.ResourceReference; import ca.uhn.fhir.model.api.BaseResourceReference;
import ca.uhn.fhir.model.api.UndeclaredExtension; import ca.uhn.fhir.model.api.UndeclaredExtension;
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.primitive.XhtmlDt; import ca.uhn.fhir.model.primitive.XhtmlDt;
class ParserState<T extends IElement> { class ParserState<T extends IElement> {
@ -58,8 +59,8 @@ class ParserState<T extends IElement> {
myState.enteringNewElement(theNamespaceURI, theName); myState.enteringNewElement(theNamespaceURI, theName);
} }
public void enteringNewElementExtension(StartElement theElem, String theUrlAttr) { public void enteringNewElementExtension(StartElement theElem, String theUrlAttr, boolean theIsModifier) {
myState.enteringNewElementExtension(theElem, theUrlAttr); myState.enteringNewElementExtension(theElem, theUrlAttr, theIsModifier);
} }
public T getObject() { public T getObject() {
@ -370,15 +371,19 @@ class ParserState<T extends IElement> {
/** /**
* Default implementation just handles undeclared extensions * Default implementation just handles undeclared extensions
*/ */
public void enteringNewElementExtension(@SuppressWarnings("unused") StartElement theElement, String theUrlAttr) { public void enteringNewElementExtension(@SuppressWarnings("unused") StartElement theElement, String theUrlAttr, boolean theIsModifier) {
if (getCurrentElement() instanceof ISupportsUndeclaredExtensions) { if (getCurrentElement() instanceof ISupportsUndeclaredExtensions) {
UndeclaredExtension newExtension = new UndeclaredExtension(theUrlAttr); UndeclaredExtension newExtension = new UndeclaredExtension(theIsModifier, theUrlAttr);
// TODO: fail if we don't support undeclared extensions ISupportsUndeclaredExtensions elem = (ISupportsUndeclaredExtensions) getCurrentElement();
((ISupportsUndeclaredExtensions) getCurrentElement()).getUndeclaredExtensions().add(newExtension); if (theIsModifier) {
elem.getUndeclaredModifierExtensions().add(newExtension);
} else {
elem.getUndeclaredExtensions().add(newExtension);
}
ExtensionState newState = new ExtensionState(newExtension); ExtensionState newState = new ExtensionState(newExtension);
push(newState); push(newState);
} else { } else {
throw new DataFormatException("Extension is not supported at this position"); throw new DataFormatException("Type " + getCurrentElement() + " does not support undeclared extentions, and found an extension with URL: " + theUrlAttr);
} }
} }
@ -446,7 +451,7 @@ class ParserState<T extends IElement> {
} }
case RESOURCE_REF: { case RESOURCE_REF: {
RuntimeResourceReferenceDefinition resourceRefTarget = (RuntimeResourceReferenceDefinition) target; RuntimeResourceReferenceDefinition resourceRefTarget = (RuntimeResourceReferenceDefinition) target;
ResourceReference newChildInstance = new ResourceReference(); ResourceReferenceDt newChildInstance = new ResourceReferenceDt();
myDefinition.getMutator().addValue(myParentInstance, newChildInstance); myDefinition.getMutator().addValue(myParentInstance, newChildInstance);
ResourceReferenceState newState = new ResourceReferenceState(resourceRefTarget, newChildInstance); ResourceReferenceState newState = new ResourceReferenceState(resourceRefTarget, newChildInstance);
push(newState); push(newState);
@ -463,7 +468,7 @@ class ParserState<T extends IElement> {
} }
@Override @Override
public void enteringNewElementExtension(StartElement theElement, String theUrlAttr) { public void enteringNewElementExtension(StartElement theElement, String theUrlAttr, boolean theIsModifier) {
RuntimeChildDeclaredExtensionDefinition declaredExtension = myDefinition.getChildExtensionForUrl(theUrlAttr); RuntimeChildDeclaredExtensionDefinition declaredExtension = myDefinition.getChildExtensionForUrl(theUrlAttr);
if (declaredExtension != null) { if (declaredExtension != null) {
if (myChildInstance == null) { if (myChildInstance == null) {
@ -473,7 +478,7 @@ class ParserState<T extends IElement> {
BaseState newState = new DeclaredExtensionState(declaredExtension, myChildInstance); BaseState newState = new DeclaredExtensionState(declaredExtension, myChildInstance);
push(newState); push(newState);
} else { } else {
super.enteringNewElementExtension(theElement, theUrlAttr); super.enteringNewElementExtension(theElement, theUrlAttr, theIsModifier);
} }
} }
@ -514,7 +519,7 @@ class ParserState<T extends IElement> {
switch (target.getChildType()) { switch (target.getChildType()) {
case COMPOSITE_DATATYPE: { case COMPOSITE_DATATYPE: {
BaseRuntimeElementCompositeDefinition<?> compositeTarget = (BaseRuntimeElementCompositeDefinition<?>) target; BaseRuntimeElementCompositeDefinition<?> compositeTarget = (BaseRuntimeElementCompositeDefinition<?>) target;
ICompositeDatatype newChildInstance = (ICompositeDatatype) compositeTarget.newInstance(); ICompositeDatatype newChildInstance = (ICompositeDatatype) compositeTarget.newInstance(child.getInstanceConstructorArguments());
child.getMutator().addValue(myInstance, newChildInstance); child.getMutator().addValue(myInstance, newChildInstance);
ElementCompositeState newState = new ElementCompositeState(compositeTarget, newChildInstance); ElementCompositeState newState = new ElementCompositeState(compositeTarget, newChildInstance);
push(newState); push(newState);
@ -531,7 +536,7 @@ class ParserState<T extends IElement> {
} }
case RESOURCE_REF: { case RESOURCE_REF: {
RuntimeResourceReferenceDefinition resourceRefTarget = (RuntimeResourceReferenceDefinition) target; RuntimeResourceReferenceDefinition resourceRefTarget = (RuntimeResourceReferenceDefinition) target;
ResourceReference newChildInstance = new ResourceReference(); ResourceReferenceDt newChildInstance = new ResourceReferenceDt();
child.getMutator().addValue(myInstance, newChildInstance); child.getMutator().addValue(myInstance, newChildInstance);
ResourceReferenceState newState = new ResourceReferenceState(resourceRefTarget, newChildInstance); ResourceReferenceState newState = new ResourceReferenceState(resourceRefTarget, newChildInstance);
push(newState); push(newState);
@ -564,13 +569,13 @@ class ParserState<T extends IElement> {
} }
@Override @Override
public void enteringNewElementExtension(StartElement theElement, String theUrlAttr) { public void enteringNewElementExtension(StartElement theElement, String theUrlAttr, boolean theIsModifier) {
RuntimeChildDeclaredExtensionDefinition declaredExtension = myDefinition.getDeclaredExtension(theUrlAttr); RuntimeChildDeclaredExtensionDefinition declaredExtension = myDefinition.getDeclaredExtension(theUrlAttr);
if (declaredExtension != null) { if (declaredExtension != null) {
BaseState newState = new DeclaredExtensionState(declaredExtension, myInstance); BaseState newState = new DeclaredExtensionState(declaredExtension, myInstance);
push(newState); push(newState);
} else { } else {
super.enteringNewElementExtension(theElement, theUrlAttr); super.enteringNewElementExtension(theElement, theUrlAttr, theIsModifier);
} }
} }
@ -623,7 +628,7 @@ class ParserState<T extends IElement> {
} }
case RESOURCE_REF: { case RESOURCE_REF: {
RuntimeResourceReferenceDefinition resourceRefTarget = (RuntimeResourceReferenceDefinition) target; RuntimeResourceReferenceDefinition resourceRefTarget = (RuntimeResourceReferenceDefinition) target;
ResourceReference newChildInstance = new ResourceReference(); ResourceReferenceDt newChildInstance = new ResourceReferenceDt();
myExtension.setValue(newChildInstance); myExtension.setValue(newChildInstance);
ResourceReferenceState newState = new ResourceReferenceState(resourceRefTarget, newChildInstance); ResourceReferenceState newState = new ResourceReferenceState(resourceRefTarget, newChildInstance);
push(newState); push(newState);
@ -784,10 +789,10 @@ class ParserState<T extends IElement> {
private class ResourceReferenceState extends BaseState { private class ResourceReferenceState extends BaseState {
private RuntimeResourceReferenceDefinition myDefinition; private RuntimeResourceReferenceDefinition myDefinition;
private ResourceReference myInstance; private ResourceReferenceDt myInstance;
private ResourceReferenceSubState mySubState; private ResourceReferenceSubState mySubState;
public ResourceReferenceState(RuntimeResourceReferenceDefinition theDefinition, ResourceReference theInstance) { public ResourceReferenceState(RuntimeResourceReferenceDefinition theDefinition, ResourceReferenceDt theInstance) {
myDefinition = theDefinition; myDefinition = theDefinition;
myInstance = theInstance; myInstance = theInstance;
mySubState = ResourceReferenceSubState.INITIAL; mySubState = ResourceReferenceSubState.INITIAL;

View File

@ -34,6 +34,7 @@ import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
import ca.uhn.fhir.context.BaseRuntimeElementDefinition; import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeChildDeclaredExtensionDefinition;
import ca.uhn.fhir.context.RuntimeChildUndeclaredExtensionDefinition; import ca.uhn.fhir.context.RuntimeChildUndeclaredExtensionDefinition;
import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.model.api.Bundle;
@ -42,8 +43,9 @@ import ca.uhn.fhir.model.api.IElement;
import ca.uhn.fhir.model.api.IPrimitiveDatatype; import ca.uhn.fhir.model.api.IPrimitiveDatatype;
import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ISupportsUndeclaredExtensions; import ca.uhn.fhir.model.api.ISupportsUndeclaredExtensions;
import ca.uhn.fhir.model.api.ResourceReference; import ca.uhn.fhir.model.api.BaseResourceReference;
import ca.uhn.fhir.model.api.UndeclaredExtension; import ca.uhn.fhir.model.api.UndeclaredExtension;
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.primitive.InstantDt; import ca.uhn.fhir.model.primitive.InstantDt;
import ca.uhn.fhir.model.primitive.StringDt; import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.model.primitive.XhtmlDt; import ca.uhn.fhir.model.primitive.XhtmlDt;
@ -89,7 +91,14 @@ public class XmlParser implements IParser {
if (urlAttr == null || isBlank(urlAttr.getValue())) { if (urlAttr == null || isBlank(urlAttr.getValue())) {
throw new DataFormatException("Extension element has no 'url' attribute"); throw new DataFormatException("Extension element has no 'url' attribute");
} }
parserState.enteringNewElementExtension(elem, urlAttr.getValue()); parserState.enteringNewElementExtension(elem, urlAttr.getValue(),false);
} else if ("modifierExtension".equals(elem.getName().getLocalPart())) {
Attribute urlAttr = elem.getAttributeByName(new QName("url"));
if (urlAttr == null || isBlank(urlAttr.getValue())) {
throw new DataFormatException("Extension element has no 'url' attribute");
}
parserState.enteringNewElementExtension(elem, urlAttr.getValue(),true);
} else { } else {
String elementName = elem.getName().getLocalPart(); String elementName = elem.getName().getLocalPart();
@ -131,7 +140,7 @@ public class XmlParser implements IParser {
parserState.xmlEvent(nextEvent); parserState.xmlEvent(nextEvent);
} catch (DataFormatException e) { } catch (DataFormatException e) {
throw new DataFormatException("DataFormatException at [" + nextEvent.getLocation().toString() + "]: "+e.getMessage(), e); throw new DataFormatException("DataFormatException at [" + nextEvent.getLocation().toString() + "]: " + e.getMessage(), e);
} }
} }
return null; return null;
@ -140,7 +149,9 @@ public class XmlParser implements IParser {
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see ca.uhn.fhir.parser.IParser#encodeBundleToString(ca.uhn.fhir.model.api.Bundle) * @see ca.uhn.fhir.parser.IParser#encodeBundleToString(ca.uhn.fhir.model.api.Bundle)
*/ */
@Override @Override
@ -151,7 +162,9 @@ public class XmlParser implements IParser {
return stringWriter.toString(); return stringWriter.toString();
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see ca.uhn.fhir.parser.IParser#encodeBundleToWriter(ca.uhn.fhir.model.api.Bundle, java.io.Writer) * @see ca.uhn.fhir.parser.IParser#encodeBundleToWriter(ca.uhn.fhir.model.api.Bundle, java.io.Writer)
*/ */
@Override @Override
@ -211,9 +224,8 @@ public class XmlParser implements IParser {
} }
} }
private void encodeChildElementToStreamWriter(XMLStreamWriter theEventWriter, IElement nextValue, String childName, BaseRuntimeElementDefinition<?> childDef, String theExtensionUrl)
throws XMLStreamException, DataFormatException {
private void encodeChildElementToStreamWriter(XMLStreamWriter theEventWriter, IElement nextValue, String childName, BaseRuntimeElementDefinition<?> childDef, String theExtensionUrl) throws XMLStreamException, DataFormatException {
if (nextValue.isEmpty()) { if (nextValue.isEmpty()) {
return; return;
} }
@ -243,7 +255,7 @@ public class XmlParser implements IParser {
break; break;
} }
case RESOURCE_REF: { case RESOURCE_REF: {
ResourceReference ref = (ResourceReference) nextValue; ResourceReferenceDt ref = (ResourceReferenceDt) nextValue;
if (!ref.isEmpty()) { if (!ref.isEmpty()) {
theEventWriter.writeStartElement(childName); theEventWriter.writeStartElement(childName);
encodeResourceReferenceToStreamWriter(theEventWriter, ref); encodeResourceReferenceToStreamWriter(theEventWriter, ref);
@ -268,7 +280,8 @@ public class XmlParser implements IParser {
} }
private void encodeCompositeElementChildrenToStreamWriter(IElement theElement, XMLStreamWriter theEventWriter, List<? extends BaseRuntimeChildDefinition> children) throws XMLStreamException, DataFormatException { private void encodeCompositeElementChildrenToStreamWriter(IElement theElement, XMLStreamWriter theEventWriter, List<? extends BaseRuntimeChildDefinition> children) throws XMLStreamException,
DataFormatException {
for (BaseRuntimeChildDefinition nextChild : children) { for (BaseRuntimeChildDefinition nextChild : children) {
List<? extends IElement> values = nextChild.getAccessor().getValues(theElement); List<? extends IElement> values = nextChild.getAccessor().getValues(theElement);
if (values == null || values.isEmpty()) { if (values == null || values.isEmpty()) {
@ -288,7 +301,13 @@ public class XmlParser implements IParser {
} }
if (extensionUrl != null && childName.equals("extension") == false) { if (extensionUrl != null && childName.equals("extension") == false) {
RuntimeChildDeclaredExtensionDefinition extDef = (RuntimeChildDeclaredExtensionDefinition) nextChild;
if (extDef.isModifier()) {
theEventWriter.writeStartElement("modifierExtension");
}else {
theEventWriter.writeStartElement("extension"); theEventWriter.writeStartElement("extension");
}
theEventWriter.writeAttribute("url", extensionUrl); theEventWriter.writeAttribute("url", extensionUrl);
encodeChildElementToStreamWriter(theEventWriter, nextValue, childName, childDef, null); encodeChildElementToStreamWriter(theEventWriter, nextValue, childName, childDef, null);
theEventWriter.writeEndElement(); theEventWriter.writeEndElement();
@ -299,18 +318,24 @@ public class XmlParser implements IParser {
} }
} }
private void encodeCompositeElementToStreamWriter(IElement theElement, XMLStreamWriter theEventWriter, BaseRuntimeElementCompositeDefinition<?> resDef) throws XMLStreamException, DataFormatException { private void encodeCompositeElementToStreamWriter(IElement theElement, XMLStreamWriter theEventWriter, BaseRuntimeElementCompositeDefinition<?> resDef) throws XMLStreamException,
DataFormatException {
encodeExtensionsIfPresent(theEventWriter, theElement); encodeExtensionsIfPresent(theEventWriter, theElement);
encodeCompositeElementChildrenToStreamWriter(theElement, theEventWriter, resDef.getExtensions()); encodeCompositeElementChildrenToStreamWriter(theElement, theEventWriter, resDef.getExtensions());
encodeCompositeElementChildrenToStreamWriter(theElement, theEventWriter, resDef.getChildren()); encodeCompositeElementChildrenToStreamWriter(theElement, theEventWriter, resDef.getChildren());
} }
private void encodeExtensionsIfPresent(XMLStreamWriter theWriter, IElement theResource) throws XMLStreamException, DataFormatException { private void encodeExtensionsIfPresent(XMLStreamWriter theWriter, IElement theResource) throws XMLStreamException, DataFormatException {
boolean retVal = false;
if (theResource instanceof ISupportsUndeclaredExtensions) { if (theResource instanceof ISupportsUndeclaredExtensions) {
for (UndeclaredExtension next : ((ISupportsUndeclaredExtensions) theResource).getUndeclaredExtensions()) { ISupportsUndeclaredExtensions res = (ISupportsUndeclaredExtensions) theResource;
retVal = true; encodeUndeclaredExtensions(theWriter, res.getUndeclaredExtensions(), "extension");
theWriter.writeStartElement("extension"); encodeUndeclaredExtensions(theWriter, res.getUndeclaredModifierExtensions(), "modifierExtension");
}
}
private void encodeUndeclaredExtensions(XMLStreamWriter theWriter, List<UndeclaredExtension> extensions, String tagName) throws XMLStreamException {
for (UndeclaredExtension next : extensions) {
theWriter.writeStartElement(tagName);
theWriter.writeAttribute("url", next.getUrl()); theWriter.writeAttribute("url", next.getUrl());
if (next.getValue() != null) { if (next.getValue() != null) {
@ -327,22 +352,23 @@ public class XmlParser implements IParser {
theWriter.writeEndElement(); theWriter.writeEndElement();
} }
} }
}
private void encodeResourceReferenceToStreamWriter(XMLStreamWriter theEventWriter, ResourceReference theRef) throws XMLStreamException { private void encodeResourceReferenceToStreamWriter(XMLStreamWriter theEventWriter, ResourceReferenceDt theRef) throws XMLStreamException {
if (StringUtils.isNotBlank(theRef.getDisplay())) { if (!(theRef.getDisplay().isEmpty())) {
theEventWriter.writeStartElement("display"); theEventWriter.writeStartElement("display");
theEventWriter.writeAttribute("value", theRef.getDisplay()); theEventWriter.writeAttribute("value", theRef.getDisplay().getValue());
theEventWriter.writeEndElement(); theEventWriter.writeEndElement();
} }
if (StringUtils.isNotBlank(theRef.getReference())) { if (!(theRef.getReference().isEmpty())) {
theEventWriter.writeStartElement("reference"); theEventWriter.writeStartElement("reference");
theEventWriter.writeAttribute("value", theRef.getReference()); theEventWriter.writeAttribute("value", theRef.getReference().getValue());
theEventWriter.writeEndElement(); theEventWriter.writeEndElement();
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see ca.uhn.fhir.parser.IParser#encodeResourceToString(ca.uhn.fhir.model.api.IResource) * @see ca.uhn.fhir.parser.IParser#encodeResourceToString(ca.uhn.fhir.model.api.IResource)
*/ */
@Override @Override
@ -352,7 +378,9 @@ public class XmlParser implements IParser {
return stringWriter.toString(); return stringWriter.toString();
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see ca.uhn.fhir.parser.IParser#encodeResourceToWriter(ca.uhn.fhir.model.api.IResource, java.io.Writer) * @see ca.uhn.fhir.parser.IParser#encodeResourceToWriter(ca.uhn.fhir.model.api.IResource, java.io.Writer)
*/ */
@Override @Override
@ -368,7 +396,9 @@ public class XmlParser implements IParser {
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see ca.uhn.fhir.parser.IParser#encodeResourceToXmlStreamWriter(ca.uhn.fhir.model.api.IResource, javax.xml.stream.XMLStreamWriter) * @see ca.uhn.fhir.parser.IParser#encodeResourceToXmlStreamWriter(ca.uhn.fhir.model.api.IResource, javax.xml.stream.XMLStreamWriter)
*/ */
@Override @Override
@ -431,7 +461,7 @@ public class XmlParser implements IParser {
theEventWriter.writeStartElement(se.getName().getLocalPart()); theEventWriter.writeStartElement(se.getName().getLocalPart());
if (StringUtils.isBlank(se.getName().getPrefix())) { if (StringUtils.isBlank(se.getName().getPrefix())) {
theEventWriter.writeDefaultNamespace(se.getName().getNamespaceURI()); theEventWriter.writeDefaultNamespace(se.getName().getNamespaceURI());
}else { } else {
theEventWriter.writeNamespace(se.getName().getPrefix(), se.getName().getNamespaceURI()); theEventWriter.writeNamespace(se.getName().getPrefix(), se.getName().getNamespaceURI());
} }
} else { } else {
@ -442,7 +472,7 @@ public class XmlParser implements IParser {
if (StringUtils.isBlank(se.getName().getPrefix())) { if (StringUtils.isBlank(se.getName().getPrefix())) {
theEventWriter.writeStartElement(se.getName().getLocalPart()); theEventWriter.writeStartElement(se.getName().getLocalPart());
theEventWriter.writeDefaultNamespace(se.getName().getNamespaceURI()); theEventWriter.writeDefaultNamespace(se.getName().getNamespaceURI());
}else { } else {
theEventWriter.writeStartElement(se.getName().getNamespaceURI(), se.getName().getLocalPart()); theEventWriter.writeStartElement(se.getName().getNamespaceURI(), se.getName().getLocalPart());
} }
} }
@ -464,7 +494,9 @@ public class XmlParser implements IParser {
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see ca.uhn.fhir.parser.IParser#parseBundle(java.lang.String) * @see ca.uhn.fhir.parser.IParser#parseBundle(java.lang.String)
*/ */
@Override @Override
@ -478,7 +510,9 @@ public class XmlParser implements IParser {
return doXmlLoop(theStreamReader, parserState); return doXmlLoop(theStreamReader, parserState);
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see ca.uhn.fhir.parser.IParser#parseResource(java.lang.String) * @see ca.uhn.fhir.parser.IParser#parseResource(java.lang.String)
*/ */
@Override @Override
@ -486,7 +520,9 @@ public class XmlParser implements IParser {
return parseResource(null, theMessageString); return parseResource(null, theMessageString);
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see ca.uhn.fhir.parser.IParser#parseResource(javax.xml.stream.XMLEventReader) * @see ca.uhn.fhir.parser.IParser#parseResource(javax.xml.stream.XMLEventReader)
*/ */
@Override @Override

View File

@ -17,6 +17,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import ca.uhn.fhir.rest.server.exceptions.*; import ca.uhn.fhir.rest.server.exceptions.*;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
@ -98,9 +99,18 @@ public abstract class RestfulServer extends HttpServlet {
} }
} }
/**
* This method must be overridden to provide one or more resource providers
*/
public abstract Collection<IResourceProvider> getResourceProviders(); public abstract Collection<IResourceProvider> getResourceProviders();
public abstract ISecurityManager getSecurityManager(); /**
* This method should be overridden to provide a security manager
* instance. By default, returns null.
*/
public ISecurityManager getSecurityManager() {
return null;
}
protected void handleRequest(SearchMethodBinding.RequestType requestType, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { protected void handleRequest(SearchMethodBinding.RequestType requestType, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try { try {

View File

@ -8,17 +8,16 @@ public class ElementUtil {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static boolean isEmpty(Object... theElements) { public static boolean isEmpty(Object... theElements) {
if (theElements ==null) { if (theElements == null) {
return true; return true;
} }
for (int i = 0; i < theElements.length; i++) { for (int i = 0; i < theElements.length; i++) {
Object next = theElements[i]; Object next = theElements[i];
if (next instanceof List) { if (next instanceof List) {
if (!isEmpty((List<? extends IElement>)next)) { if (!isEmpty((List<? extends IElement>) next)) {
return false; return false;
} }
} } else if (next != null && !((IElement) next).isEmpty()) {
if (next != null && !((IElement)next).isEmpty()) {
return false; return false;
} }
} }
@ -26,7 +25,7 @@ public class ElementUtil {
} }
public static boolean isEmpty(IElement... theElements) { public static boolean isEmpty(IElement... theElements) {
if (theElements ==null) { if (theElements == null) {
return true; return true;
} }
for (int i = 0; i < theElements.length; i++) { for (int i = 0; i < theElements.length; i++) {
@ -39,7 +38,7 @@ public class ElementUtil {
} }
public static boolean isEmpty(List<? extends IElement> theElements) { public static boolean isEmpty(List<? extends IElement> theElements) {
if (theElements ==null) { if (theElements == null) {
return true; return true;
} }
for (int i = 0; i < theElements.size(); i++) { for (int i = 0; i < theElements.size(); i++) {

View File

@ -0,0 +1,38 @@
package example;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.servlet.annotation.WebServlet;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer;
//START SNIPPET: servlet
/**
* In this example, we are using Servlet 3.0 annotations to define
* the URL pattern for this servlet, but we could also
* define this in a web.xml file.
*/
@WebServlet(urlPatterns= {"/fhir/*"}, displayName="FHIR Server")
public class ExampleRestfulServlet extends RestfulServer {
private static final long serialVersionUID = 1L;
/**
* Restful servers must provide an implementation of this method, which
* returns all resource providers to be used by this server. In the example
* below, we are creating a RESTful server which is able to serve
* Patient and Observation resources.
*/
@Override
public Collection<IResourceProvider> getResourceProviders() {
List<IResourceProvider> retVal = new ArrayList<IResourceProvider>();
retVal.add(new RestfulPatientResourceProvider());
retVal.add(new RestfulObservationResourceProvider());
return retVal;
}
}
//END SNIPPET: servlet

View File

@ -0,0 +1,86 @@
package example;
import java.util.Collections;
import java.util.List;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.model.dstu.valueset.AdministrativeGenderCodesEnum;
import ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.model.primitive.UriDt;
import ca.uhn.fhir.rest.annotation.Read;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.operations.Search;
import ca.uhn.fhir.rest.server.parameters.Required;
//START SNIPPET: provider
/**
* All resource providers must implement IResourceProvider
*/
public class RestfulObservationResourceProvider implements IResourceProvider {
/**
* The getResourceType method comes from IResourceProvider, and must
* be overridden to indicate what type of resource this provider
* supplies.
*/
@Override
public Class<Patient> getResourceType() {
return Patient.class;
}
/**
* The "@Read" annotation indicates that this method supports the
* read operation. It takes one argument, the Resource type being returned.
*
* @param theId
* The read operation takes one parameter, which must be of type
* IdDt and must be annotated with the "@Read.IdParam" annotation.
* @return
* Returns a resource matching this identifier, or null if none exists.
*/
@Read(Patient.class)
public Patient getResourceById(@Read.IdParam IdDt theId) {
Patient patient = new Patient();
patient.addIdentifier();
patient.getIdentifier().get(0).setSystem(new UriDt("urn:hapitest:mrns"));
patient.getIdentifier().get(0).setValue("00002");
patient.addName().addFamily("Test");
patient.getName().get(0).addGiven("PatientOne");
patient.setGender(AdministrativeGenderCodesEnum.F);
return patient;
}
/**
* The "@Search" annotation indicates that this method supports the
* search operation. You may have many different method annotated with
* this annotation, to support many different search criteria. This
* example searches by family name.
*
* @param theIdentifier
* This operation takes one parameter which is the search criteria. It is
* annotated with the "@Required" annotation. This annotation takes one argument,
* a string containing the name of the search criteria. The datatype here
* is StringDt, but there are other possible parameter types depending on the
* specific search criteria.
* @return
* This method returns a list of Patients. This list may contain multiple
* matching resources, or it may also be empty.
*/
@Search(Patient.class)
public List<Patient> getPatient(@Required(name = Patient.SP_FAMILY) StringDt theFamilyName) {
Patient patient = new Patient();
patient.addIdentifier();
patient.getIdentifier().get(0).setUse(IdentifierUseEnum.OFFICIAL);
patient.getIdentifier().get(0).setSystem(new UriDt("urn:hapitest:mrns"));
patient.getIdentifier().get(0).setValue("00001");
patient.addName();
patient.getName().get(0).addFamily("Test");
patient.getName().get(0).addGiven("PatientOne");
patient.getGender().setText("M");
return Collections.singletonList(patient);
}
}
//END SNIPPET: provider

View File

@ -1,30 +0,0 @@
package example;
import java.util.Arrays;
import java.util.Collection;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.ISecurityManager;
import ca.uhn.fhir.rest.server.RestfulServer;
public class RestfulServlet extends RestfulServer {
private static final long serialVersionUID = 1L;
private Collection<IResourceProvider> myResourceProviders;
public RestfulServlet(IResourceProvider... theResourceProviders) {
myResourceProviders = Arrays.asList(theResourceProviders);
}
@Override
public Collection<IResourceProvider> getResourceProviders() {
return myResourceProviders;
}
@Override
public ISecurityManager getSecurityManager() {
return null;
}
}

View File

@ -9,7 +9,7 @@
<body> <body>
<!-- The body of the document contains a number of sections --> <!-- The body of the document contains a number of sections -->
<section name="Working with Resources"> <section name="Creating a RESTful Server">
<macro name="toc"> <macro name="toc">
</macro> </macro>
@ -26,7 +26,7 @@
be possible to create a FHIR compliant server quickly and easily. be possible to create a FHIR compliant server quickly and easily.
</p> </p>
<subsection name="Creating A Server"> <subsection name="Defining Resource Providers">
<p> <p>
The first step in creating a FHIR RESTful Server is to define one or The first step in creating a FHIR RESTful Server is to define one or
@ -41,7 +41,9 @@
</p> </p>
<p> <p>
Resource providers each contain one or more methods which have been A Resource provider class must implement the
<a href="./apidocs/ca/uhn/fhir/rest/server/IResourceProvider.html">IResourceProvider</a> interface,
and will contain one or more methods which have been
annotated with special annotations indicating which RESTful operation annotated with special annotations indicating which RESTful operation
that method supports. Below is a simple example of a resource provider that method supports. Below is a simple example of a resource provider
which supports the which supports the
@ -59,6 +61,36 @@
</subsection> </subsection>
<subsection name="Create a Server">
<p>
Once your resource providers are created, your next step is to
define a server class.
</p>
<p>
HAPI provides a class called
<a href="./apidocs/ca/uhn/fhir/rest/server/RestfulServer.html">RestfulServer</a>, which
is a specialized Java Servlet. To create a server, you simply create a class
which extends RestfulServer as shown in the example below.
</p>
<macro name="snippet">
<param name="id" value="servlet" />
<param name="file" value="src/site/example/java/example/ExampleRestfulServlet.java" />
</macro>
</subsection>
<subsection name="Deploy">
<p>
Once you have created your resource providers and your restful server class,
you can bundle these into a WAR file and you are ready to deploy to
any JEE container (Tomcat, Websphere, Glassfish, etc).
</p>
</subsection>
</section> </section>

View File

@ -20,25 +20,25 @@ public class ModelScannerTest {
assertEquals(RuntimeChildCompositeDatatypeDefinition.class, def.getChildByNameOrThrowDataFormatException("identifier").getClass()); assertEquals(RuntimeChildCompositeDatatypeDefinition.class, def.getChildByNameOrThrowDataFormatException("identifier").getClass());
RuntimeChildDeclaredExtensionDefinition ext = def.getDeclaredExtension("http://foo/1"); RuntimeChildDeclaredExtensionDefinition ext = def.getDeclaredExtension("http://foo/#f1");
assertNotNull(ext); assertNotNull(ext);
BaseRuntimeElementDefinition<?> valueString = ext.getChildByName("valueString"); BaseRuntimeElementDefinition<?> valueString = ext.getChildByName("valueString");
assertNotNull(valueString); assertNotNull(valueString);
ext = def.getDeclaredExtension("http://foo/2"); ext = def.getDeclaredExtension("http://foo/#f2");
assertNotNull(ext); assertNotNull(ext);
valueString = ext.getChildByName("valueString"); valueString = ext.getChildByName("valueString");
assertNotNull(valueString); assertNotNull(valueString);
ext = def.getDeclaredExtension("http://bar/1"); ext = def.getDeclaredExtension("http://bar/#b1");
assertNotNull(ext); assertNotNull(ext);
RuntimeChildDeclaredExtensionDefinition childExt = ext.getChildExtensionForUrl("http://bar/1/1"); RuntimeChildDeclaredExtensionDefinition childExt = ext.getChildExtensionForUrl("http://bar/#b1/1");
assertNotNull(childExt); assertNotNull(childExt);
BaseRuntimeElementDefinition<?> valueDate = childExt.getChildByName("valueDate"); BaseRuntimeElementDefinition<?> valueDate = childExt.getChildByName("valueDate");
assertNotNull(valueDate); assertNotNull(valueDate);
childExt = ext.getChildExtensionForUrl("http://bar/1/2"); childExt = ext.getChildExtensionForUrl("http://bar/#b1/2");
assertNotNull(childExt); assertNotNull(childExt);
childExt = childExt.getChildExtensionForUrl("http://bar/1/2/1"); childExt = childExt.getChildExtensionForUrl("http://bar/#b1/2/1");
assertNotNull(childExt); assertNotNull(childExt);
valueDate = childExt.getChildByName("valueDate"); valueDate = childExt.getChildByName("valueDate");
assertNotNull(valueDate); assertNotNull(valueDate);

View File

@ -21,19 +21,19 @@ public class ResourceWithExtensionsA implements IResource {
*/ */
@Child(name = "bar1", type = Bar1.class, order = 2, min = 1, max = Child.MAX_UNLIMITED) @Child(name = "bar1", type = Bar1.class, order = 2, min = 1, max = Child.MAX_UNLIMITED)
@Extension(url = "http://bar/#b1", definedLocally=true) @Extension(url = "http://bar/#b1", definedLocally=true, isModifier=false)
private List<Bar1> myBar1; private List<Bar1> myBar1;
@Child(name = "bar2", type = Bar1.class, order = 3, min = 1, max = Child.MAX_UNLIMITED) @Child(name = "bar2", type = Bar1.class, order = 3, min = 1, max = Child.MAX_UNLIMITED)
@Extension(url = "http://bar/#b2", definedLocally=true) @Extension(url = "http://bar/#b2", definedLocally=true, isModifier=false)
private Bar1 myBar2; private Bar1 myBar2;
@Child(name = "foo1", type = StringDt.class, order = 0, min = 0, max = Child.MAX_UNLIMITED) @Child(name = "foo1", type = StringDt.class, order = 0, min = 0, max = Child.MAX_UNLIMITED)
@Extension(url = "http://foo/#f1", definedLocally=true) @Extension(url = "http://foo/#f1", definedLocally=true, isModifier=false)
private List<StringDt> myFoo1; private List<StringDt> myFoo1;
@Child(name = "foo2", type = StringDt.class, order = 1, min = 0, max = 1) @Child(name = "foo2", type = StringDt.class, order = 1, min = 0, max = 1)
@Extension(url = "http://foo/#f2", definedLocally=true) @Extension(url = "http://foo/#f2", definedLocally=true, isModifier=true)
private StringDt myFoo2; private StringDt myFoo2;
@Child(name = "identifier", type = IdentifierDt.class, order = 0, min = 0, max = Child.MAX_UNLIMITED) @Child(name = "identifier", type = IdentifierDt.class, order = 0, min = 0, max = Child.MAX_UNLIMITED)
@ -87,11 +87,11 @@ public class ResourceWithExtensionsA implements IResource {
} }
@Child(name = "bar11", type = DateDt.class, order = 0, min = 0, max = Child.MAX_UNLIMITED) @Child(name = "bar11", type = DateDt.class, order = 0, min = 0, max = Child.MAX_UNLIMITED)
@Extension(url = "http://bar/#1/1", definedLocally=true) @Extension(url = "http://bar/#b1/1", definedLocally=true, isModifier=false)
private List<DateDt> myBar11; private List<DateDt> myBar11;
@Child(name = "bar12", type = DateDt.class, order = 1, min = 0, max = Child.MAX_UNLIMITED) @Child(name = "bar12", type = DateDt.class, order = 1, min = 0, max = Child.MAX_UNLIMITED)
@Extension(url = "http://bar/#1/2", definedLocally=true) @Extension(url = "http://bar/#b1/2", definedLocally=true, isModifier=false)
private List<Bar2> myBar12; private List<Bar2> myBar12;
@Override @Override
@ -121,11 +121,11 @@ public class ResourceWithExtensionsA implements IResource {
public static class Bar2 implements IExtension { public static class Bar2 implements IExtension {
@Child(name = "bar121", type = DateDt.class, order = 0, min = 0, max = Child.MAX_UNLIMITED) @Child(name = "bar121", type = DateDt.class, order = 0, min = 0, max = Child.MAX_UNLIMITED)
@Extension(url = "http://bar/#1/2/1", definedLocally=true) @Extension(url = "http://bar/#b1/2/1", definedLocally=true, isModifier=false)
private List<DateDt> myBar121; private List<DateDt> myBar121;
@Child(name = "bar122", type = DateDt.class, order = 1, min = 0, max = Child.MAX_UNLIMITED) @Child(name = "bar122", type = DateDt.class, order = 1, min = 0, max = Child.MAX_UNLIMITED)
@Extension(url = "http://bar/#1/2/2", definedLocally=true) @Extension(url = "http://bar/#b1/2/2", definedLocally=true, isModifier=false)
private List<DateDt> myBar122; private List<DateDt> myBar122;
@Override @Override

View File

@ -7,6 +7,7 @@ import org.junit.Test;
import ca.uhn.fhir.model.dstu.resource.Patient; import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.model.dstu.resource.Profile; import ca.uhn.fhir.model.dstu.resource.Profile;
import ca.uhn.fhir.model.dstu.resource.Profile.ExtensionDefn; import ca.uhn.fhir.model.dstu.resource.Profile.ExtensionDefn;
import ca.uhn.fhir.model.dstu.resource.Profile.Structure;
import ca.uhn.fhir.model.dstu.valueset.DataTypeEnum; import ca.uhn.fhir.model.dstu.valueset.DataTypeEnum;
public class RuntimeResourceDefinitionTest { public class RuntimeResourceDefinitionTest {
@ -21,6 +22,14 @@ public class RuntimeResourceDefinitionTest {
ourLog.info(ctx.newXmlParser().encodeResourceToString(profile)); ourLog.info(ctx.newXmlParser().encodeResourceToString(profile));
Structure struct = profile.getStructure().get(0);
assertEquals("Patient", struct.getElement().get(0).getPath().getValue());
assertEquals("Patient.extension", struct.getElement().get(1).getPath().getValue());
assertEquals("Patient.modifierExtension", struct.getElement().get(2).getPath().getValue());
assertEquals("Patient.text", struct.getElement().get(3).getPath().getValue());
assertEquals("Patient.contained", struct.getElement().get(4).getPath().getValue());
assertEquals("Patient.language", struct.getElement().get(5).getPath().getValue());
} }
@Test @Test
@ -30,35 +39,35 @@ public class RuntimeResourceDefinitionTest {
Profile profile = def.toProfile(); Profile profile = def.toProfile();
ourLog.debug(ctx.newXmlParser().encodeResourceToString(profile)); ourLog.info(ctx.newXmlParser().encodeResourceToString(profile));
assertEquals(1, profile.getStructure().get(0).getElement().get(0).getDefinition().getType().size()); assertEquals(1, profile.getStructure().get(0).getElement().get(0).getDefinition().getType().size());
assertEquals("Resource", profile.getStructure().get(0).getElement().get(0).getDefinition().getType().get(0).getCode().getValue()); assertEquals("Resource", profile.getStructure().get(0).getElement().get(0).getDefinition().getType().get(0).getCode().getValue());
ExtensionDefn ext = profile.getExtensionDefn().get(0); ExtensionDefn ext = profile.getExtensionDefn().get(1);
assertEquals("1/1", ext.getCode().getValue()); assertEquals("b1/1", ext.getCode().getValue());
assertEquals(DataTypeEnum.DATE.getCode(), ext.getDefinition().getType().get(0).getCode().getValue()); assertEquals(DataTypeEnum.DATE.getCode(), ext.getDefinition().getType().get(0).getCode().getValue());
ext = profile.getExtensionDefn().get(1); ext = profile.getExtensionDefn().get(2);
assertEquals("1/2", ext.getCode().getValue()); assertEquals("b1/2", ext.getCode().getValue());
assertEquals(DataTypeEnum.EXTENSION, ext.getDefinition().getType().get(0).getCode().getValueAsEnum()); assertEquals(DataTypeEnum.EXTENSION, ext.getDefinition().getType().get(0).getCode().getValueAsEnum());
assertEquals("#1/2/1", ext.getDefinition().getType().get(0).getProfile().getValueAsString()); assertEquals("#b1/2/1", ext.getDefinition().getType().get(0).getProfile().getValueAsString());
assertEquals(DataTypeEnum.EXTENSION, ext.getDefinition().getType().get(1).getCode().getValueAsEnum()); assertEquals(DataTypeEnum.EXTENSION, ext.getDefinition().getType().get(1).getCode().getValueAsEnum());
assertEquals("#1/2/2", ext.getDefinition().getType().get(1).getProfile().getValueAsString()); assertEquals("#b1/2/2", ext.getDefinition().getType().get(1).getProfile().getValueAsString());
assertEquals("ResourceWithExtensionsA.extension", profile.getStructure().get(0).getElement().get(1).getPath().getValue()); assertEquals("ResourceWithExtensionsA.extension", profile.getStructure().get(0).getElement().get(1).getPath().getValue());
assertEquals("ResourceWithExtensionsA.extension", profile.getStructure().get(0).getElement().get(2).getPath().getValue()); assertEquals("ResourceWithExtensionsA.extension", profile.getStructure().get(0).getElement().get(2).getPath().getValue());
assertEquals("ResourceWithExtensionsA.extension", profile.getStructure().get(0).getElement().get(3).getPath().getValue()); assertEquals("ResourceWithExtensionsA.extension", profile.getStructure().get(0).getElement().get(3).getPath().getValue());
assertEquals("ResourceWithExtensionsA.extension", profile.getStructure().get(0).getElement().get(4).getPath().getValue()); assertEquals("ResourceWithExtensionsA.extension", profile.getStructure().get(0).getElement().get(4).getPath().getValue());
assertEquals("ResourceWithExtensionsA.extension", profile.getStructure().get(0).getElement().get(5).getPath().getValue()); assertEquals("ResourceWithExtensionsA.modifierExtension", profile.getStructure().get(0).getElement().get(5).getPath().getValue());
assertEquals(DataTypeEnum.EXTENSION, profile.getStructure().get(0).getElement().get(1).getDefinition().getType().get(0).getCode().getValueAsEnum()); assertEquals(DataTypeEnum.EXTENSION, profile.getStructure().get(0).getElement().get(1).getDefinition().getType().get(0).getCode().getValueAsEnum());
assertEquals("url", profile.getStructure().get(0).getElement().get(1).getSlicing().getDiscriminator().getValue()); assertEquals("url", profile.getStructure().get(0).getElement().get(1).getSlicing().getDiscriminator().getValue());
assertEquals(DataTypeEnum.EXTENSION, profile.getStructure().get(0).getElement().get(2).getDefinition().getType().get(0).getCode().getValueAsEnum()); assertEquals(DataTypeEnum.EXTENSION, profile.getStructure().get(0).getElement().get(2).getDefinition().getType().get(0).getCode().getValueAsEnum());
assertEquals("f1", profile.getStructure().get(0).getElement().get(2).getDefinition().getType().get(0).getProfile().getValueAsString()); assertEquals("#f1", profile.getStructure().get(0).getElement().get(2).getDefinition().getType().get(0).getProfile().getValueAsString());
assertEquals("ResourceWithExtensionsA.identifier", profile.getStructure().get(0).getElement().get(6).getPath().getValue()); assertEquals("ResourceWithExtensionsA.identifier", profile.getStructure().get(0).getElement().get(9).getPath().getValue());
} }

View File

@ -146,33 +146,33 @@ public class XmlParserTest {
} }
@Test @Test
public void testLoadAndEncodeExtensions() throws ConfigurationException, DataFormatException, SAXException, IOException { public void testLoadAndEncodeDeclaredExtensions() throws ConfigurationException, DataFormatException, SAXException, IOException {
FhirContext ctx = new FhirContext(ResourceWithExtensionsA.class); FhirContext ctx = new FhirContext(ResourceWithExtensionsA.class);
IParser p = new XmlParser(ctx); IParser p = new XmlParser(ctx);
//@formatter:off //@formatter:off
String msg = "<ResourceWithExtensionsA xmlns=\"http://hl7.org/fhir\">\n" + String msg = "<ResourceWithExtensionsA xmlns=\"http://hl7.org/fhir\">\n" +
" <extension url=\"http://foo/1\">\n" + " <extension url=\"http://foo/#f1\">\n" +
" <valueString value=\"Foo1Value\"/>\n" + " <valueString value=\"Foo1Value\"/>\n" +
" </extension>\n" + " </extension>\n" +
" <extension url=\"http://foo/1\">\n" + " <extension url=\"http://foo/#f1\">\n" +
" <valueString value=\"Foo1Value2\"/>\n" + " <valueString value=\"Foo1Value2\"/>\n" +
" </extension>\n" + " </extension>\n" +
" <extension url=\"http://foo/2\">\n" + " <modifierExtension url=\"http://foo/#f2\">\n" +
" <valueString value=\"Foo2Value1\"/>\n" + " <valueString value=\"Foo2Value1\"/>\n" +
" </extension>\n" + " </modifierExtension>\n" +
" <extension url=\"http://bar/1\">\n" + " <extension url=\"http://bar/#b1\">\n" +
" <extension url=\"http://bar/1/1\">\n" + " <extension url=\"http://bar/#b1/1\">\n" +
" <valueDate value=\"2013-01-01\"/>\n" + " <valueDate value=\"2013-01-01\"/>\n" +
" </extension>\n" + " </extension>\n" +
" <extension url=\"http://bar/1/2\">\n" + " <extension url=\"http://bar/#b1/2\">\n" +
" <extension url=\"http://bar/1/2/1\">\n" + " <extension url=\"http://bar/#b1/2/1\">\n" +
" <valueDate value=\"2013-01-02\"/>\n" + " <valueDate value=\"2013-01-02\"/>\n" +
" </extension>\n" + " </extension>\n" +
" <extension url=\"http://bar/1/2/1\">\n" + " <extension url=\"http://bar/#b1/2/1\">\n" +
" <valueDate value=\"2013-01-12\"/>\n" + " <valueDate value=\"2013-01-12\"/>\n" +
" </extension>\n" + " </extension>\n" +
" <extension url=\"http://bar/1/2/2\">\n" + " <extension url=\"http://bar/#b1/2/2\">\n" +
" <valueDate value=\"2013-01-03\"/>\n" + " <valueDate value=\"2013-01-03\"/>\n" +
" </extension>\n" + " </extension>\n" +
" </extension>\n" + " </extension>\n" +
@ -200,6 +200,60 @@ public class XmlParserTest {
assertTrue(d.toString(), d.identical()); assertTrue(d.toString(), d.identical());
} }
@Test
public void testLoadAndEncodeUndeclaredExtensions() throws ConfigurationException, DataFormatException, SAXException, IOException {
FhirContext ctx = new FhirContext(Patient.class);
IParser p = new XmlParser(ctx);
//@formatter:off
String msg = "<Patient xmlns=\"http://hl7.org/fhir\">\n" +
" <extension url=\"http://foo/#f1\">\n" +
" <valueString value=\"Foo1Value\"/>\n" +
" </extension>\n" +
" <extension url=\"http://foo/#f1\">\n" +
" <valueString value=\"Foo1Value2\"/>\n" +
" </extension>\n" +
" <extension url=\"http://bar/#b1\">\n" +
" <extension url=\"http://bar/#b1/1\">\n" +
" <valueDate value=\"2013-01-01\"/>\n" +
" </extension>\n" +
" <extension url=\"http://bar/#b1/2\">\n" +
" <extension url=\"http://bar/#b1/2/1\">\n" +
" <valueDate value=\"2013-01-02\"/>\n" +
" </extension>\n" +
" <extension url=\"http://bar/#b1/2/1\">\n" +
" <valueDate value=\"2013-01-12\"/>\n" +
" </extension>\n" +
" <extension url=\"http://bar/#b1/2/2\">\n" +
" <valueDate value=\"2013-01-03\"/>\n" +
" </extension>\n" +
" </extension>\n" +
" </extension>\n" +
" <modifierExtension url=\"http://foo/#f2\">\n" +
" <valueString value=\"Foo2Value1\"/>\n" +
" </modifierExtension>\n" +
" <identifier>\n" +
" <label value=\"IdentifierLabel\"/>\n" +
" </identifier>\n" +
"</Patient>";
//@formatter:on
Patient resource = (Patient) p.parseResource(msg);
assertEquals("IdentifierLabel", resource.getIdentifier().get(0).getLabel().getValue());
assertEquals("Foo1Value", resource.getUndeclaredExtensions().get(0).getValueAsPrimitive().getValueAsString());
assertEquals("Foo1Value2", resource.getUndeclaredExtensions().get(1).getValueAsPrimitive().getValueAsString());
assertEquals("Foo2Value1", resource.getUndeclaredModifierExtensions().get(0).getValueAsPrimitive().getValueAsString());
assertEquals("2013-01-01", resource.getUndeclaredExtensions().get(2).getUndeclaredExtensions().get(0).getValueAsPrimitive().getValueAsString());
assertEquals("2013-01-02", resource.getUndeclaredExtensions().get(2).getUndeclaredExtensions().get(1).getUndeclaredExtensions().get(0).getValueAsPrimitive().getValueAsString());
String encoded = p.encodeResourceToString(resource);
ourLog.info(encoded);
Diff d = new Diff(new StringReader(msg), new StringReader(encoded));
assertTrue(d.toString(), d.identical());
}
@BeforeClass @BeforeClass
public static void beforeClass() { public static void beforeClass() {
XMLUnit.setIgnoreAttributeOrder(true); XMLUnit.setIgnoreAttributeOrder(true);

View File

@ -1,18 +1,15 @@
package ca.uhn.fhir.rest.server; package ca.uhn.fhir.rest.server;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.entity.ContentType; import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.entity.StringEntity; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.apache.http.impl.conn.SchemeRegistryFactory;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler; import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
@ -33,7 +30,7 @@ public class ResfulServerTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResfulServerTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResfulServerTest.class);
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;
private static DefaultHttpClient ourClient; private static CloseableHttpClient ourClient;
private static FhirContext ourCtx; private static FhirContext ourCtx;
@BeforeClass @BeforeClass
@ -49,8 +46,10 @@ public class ResfulServerTest {
ourServer.setHandler(proxyHandler); ourServer.setHandler(proxyHandler);
ourServer.start(); ourServer.start();
PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(SchemeRegistryFactory.createDefault(), 5000, TimeUnit.MILLISECONDS); PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
ourClient = new DefaultHttpClient(connectionManager); HttpClientBuilder builder = HttpClientBuilder.create();
builder.setConnectionManager(connectionManager);
ourClient = builder.build();
ourCtx = new FhirContext(Patient.class); ourCtx = new FhirContext(Patient.class);

View File

@ -148,6 +148,7 @@ public abstract class BaseStructureParser {
ctx.put("includeDescriptionAnnotations", true); ctx.put("includeDescriptionAnnotations", true);
ctx.put("packageBase", thePackageBase); ctx.put("packageBase", thePackageBase);
ctx.put("profile", theResource.getProfile()); ctx.put("profile", theResource.getProfile());
ctx.put("id", StringUtils.defaultString(theResource.getId()));
ctx.put("className", theResource.getName()); ctx.put("className", theResource.getName());
ctx.put("shortName", defaultString(theResource.getShortName())); ctx.put("shortName", defaultString(theResource.getShortName()));
ctx.put("definition", defaultString(theResource.getDefinition())); ctx.put("definition", defaultString(theResource.getDefinition()));

View File

@ -53,6 +53,8 @@ public abstract class BaseStructureSpreadsheetParser extends BaseStructureParser
parseBasicElements(resourceRow, resource); parseBasicElements(resourceRow, resource);
resource.setId(resource.getName().toLowerCase());
if (this instanceof ResourceGeneratorUsingSpreadsheet) { if (this instanceof ResourceGeneratorUsingSpreadsheet) {
resource.setProfile("http://hl7.org/fhir/profiles/" + resource.getElementName()); resource.setProfile("http://hl7.org/fhir/profiles/" + resource.getElementName());
} }

View File

@ -67,7 +67,7 @@ public class Child extends BaseElement {
public String getReferenceType() { public String getReferenceType() {
String retVal; String retVal;
if (this.isResourceRef()) { if (this.isResourceRef()) {
retVal = (ResourceReference.class.getSimpleName()); retVal = "ResourceReferenceDt"; // (ResourceReferenceDt.class.getSimpleName());
} else if (this.getType().size() == 1 || this instanceof ResourceBlock) { } else if (this.getType().size() == 1 || this instanceof ResourceBlock) {
if (isBoundCode()) { if (isBoundCode()) {
retVal = "Bound" + getSingleType() + "<" + getBindingClass() + ">"; retVal = "Bound" + getSingleType() + "<" + getBindingClass() + ">";

View File

@ -5,9 +5,14 @@ import java.util.List;
public class Resource extends BaseElement { public class Resource extends BaseElement {
private String myId;
private String myProfile; private String myProfile;
private List<SearchParameter> mySearchParameters; private List<SearchParameter> mySearchParameters;
public String getId() {
return myId;
}
public String getProfile() { public String getProfile() {
return myProfile; return myProfile;
} }
@ -24,6 +29,10 @@ public class Resource extends BaseElement {
return ""; return "";
} }
public void setId(String theId) {
myId = theId;
}
public void setProfile(String theProfile) { public void setProfile(String theProfile) {
myProfile = theProfile; myProfile = theProfile;
} }

View File

@ -24,7 +24,9 @@ import ${packageBase}.resource.*;
* </p> * </p>
*/ */
@DatatypeDef(name="${className}") @DatatypeDef(name="${className}")
public class ${className}Dt extends BaseElement implements ICompositeDatatype #{if}( ${className} == "Identifier" ), IQueryParameterType #{end} public class ${className}Dt
extends #{if}(${className}=="ResourceReference") BaseResourceReference #{else} BaseElement #{end}
implements ICompositeDatatype #{if}( ${className} == "Identifier" ), IQueryParameterType #{end}
{ {
######################### #########################

View File

@ -23,7 +23,7 @@ import ${packageBase}.valueset.*;
* ${requirements} * ${requirements}
* </p> * </p>
*/ */
@ResourceDef(name="${className}", profile="${profile}") @ResourceDef(name="${className}", profile="${profile}", id="${id}")
public class ${className} extends BaseResource implements IResource { public class ${className} extends BaseResource implements IResource {
#foreach ( $param in $searchParams ) #foreach ( $param in $searchParams )