More work on struct integration
This commit is contained in:
parent
6a036dabe5
commit
795041a514
|
@ -48,7 +48,7 @@ public abstract class BaseRuntimeChildDefinition {
|
|||
abstract void sealAndInitialize(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions);
|
||||
|
||||
public interface IAccessor {
|
||||
List<? extends IBase> getValues(Object theTarget);
|
||||
List<IBase> getValues(Object theTarget);
|
||||
}
|
||||
|
||||
public abstract String getElementName();
|
||||
|
|
|
@ -32,7 +32,6 @@ import java.util.List;
|
|||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.util.BeanUtils;
|
||||
|
@ -199,13 +198,13 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil
|
|||
|
||||
private final class FieldPlainAccessor implements IAccessor {
|
||||
@Override
|
||||
public List<? extends IElement> getValues(Object theTarget) {
|
||||
public List<IBase> getValues(Object theTarget) {
|
||||
try {
|
||||
Object values = myField.get(theTarget);
|
||||
if (values == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<? extends IElement> retVal = (List<? extends IElement>) Collections.singletonList((IElement)values);
|
||||
List<IBase> retVal = Collections.singletonList((IBase)values);
|
||||
return retVal;
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new ConfigurationException("Failed to get value", e);
|
||||
|
@ -237,10 +236,10 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil
|
|||
private final class FieldListAccessor implements IAccessor {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<? extends IElement> getValues(Object theTarget) {
|
||||
List<? extends IElement> retVal;
|
||||
public List<IBase> getValues(Object theTarget) {
|
||||
List<IBase> retVal;
|
||||
try {
|
||||
retVal = (List<? extends IElement>) myField.get(theTarget);
|
||||
retVal = (List<IBase>) myField.get(theTarget);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new ConfigurationException("Failed to get value", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
|
@ -262,9 +261,9 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<IElement> getValues(Object theTarget) {
|
||||
public List<IBase> getValues(Object theTarget) {
|
||||
try {
|
||||
return (List<IElement>) myAccessorMethod.invoke(theTarget);
|
||||
return (List<IBase>) myAccessorMethod.invoke(theTarget);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ConfigurationException("Failed to get value", e);
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -284,8 +283,7 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil
|
|||
|
||||
@Override
|
||||
public void addValue(Object theTarget, IBase theValue) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<IBase> existingList = (List<IBase>) myAccessor.getValues(theTarget);
|
||||
List<IBase> existingList = myAccessor.getValues(theTarget);
|
||||
if (existingList == null) {
|
||||
existingList = new ArrayList<IBase>();
|
||||
try {
|
||||
|
@ -310,9 +308,9 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<IElement> getValues(Object theTarget) {
|
||||
public List<IBase> getValues(Object theTarget) {
|
||||
try {
|
||||
return Collections.singletonList((IElement) myAccessorMethod.invoke(theTarget));
|
||||
return Collections.singletonList((IBase)myAccessorMethod.invoke(theTarget));
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ConfigurationException("Failed to get value", e);
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
|
|
@ -51,7 +51,6 @@ public abstract class BaseRuntimeElementDefinition<T extends IBase> {
|
|||
if (myName.endsWith("Dt")) {
|
||||
myName = myName.substring(0, myName.length() - 2);
|
||||
}
|
||||
|
||||
|
||||
myImplementingClass = theImplementingClass;
|
||||
}
|
||||
|
|
|
@ -116,6 +116,8 @@ public class FhirContext {
|
|||
myVersion = FhirVersionEnum.DSTU1.getVersionImplementation();
|
||||
} else if (FhirVersionEnum.DSTU2.isPresentOnClasspath()) {
|
||||
myVersion = FhirVersionEnum.DSTU2.getVersionImplementation();
|
||||
} else if (FhirVersionEnum.DSTU2_HL7ORG.isPresentOnClasspath()) {
|
||||
myVersion = FhirVersionEnum.DSTU2_HL7ORG.getVersionImplementation();
|
||||
} else if (FhirVersionEnum.DEV.isPresentOnClasspath()) {
|
||||
myVersion = FhirVersionEnum.DEV.getVersionImplementation();
|
||||
} else {
|
||||
|
@ -241,7 +243,7 @@ public class FhirContext {
|
|||
if (clazz == null) {
|
||||
throw new DataFormatException(createUnknownResourceNameError(resourceName, myVersion.getVersion()));
|
||||
}
|
||||
if (IResource.class.isAssignableFrom(clazz)) {
|
||||
if (IBaseResource.class.isAssignableFrom(clazz)) {
|
||||
retVal = scanResourceType((Class<? extends IResource>) clazz);
|
||||
}
|
||||
}
|
||||
|
@ -473,4 +475,8 @@ public class FhirContext {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
public static FhirContext forDstu2Hl7Org() {
|
||||
return new FhirContext(FhirVersionEnum.DSTU2_HL7ORG);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,9 @@ public enum FhirVersionEnum {
|
|||
|
||||
DSTU2("ca.uhn.fhir.model.dstu2.FhirDstu2", null),
|
||||
|
||||
DEV("ca.uhn.fhir.model.dev.FhirDev", null);
|
||||
DEV("ca.uhn.fhir.model.dev.FhirDev", null),
|
||||
|
||||
DSTU2_HL7ORG("org.hl7.fhir.instance.FhirDstu2Hl7Org", null);
|
||||
|
||||
|
||||
private final String myVersionClass;
|
||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.context;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -48,14 +48,18 @@ import java.util.Set;
|
|||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.hl7.fhir.instance.model.BackboneElement;
|
||||
import org.hl7.fhir.instance.model.DomainResource;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.ICompositeType;
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.Narrative;
|
||||
import org.hl7.fhir.instance.model.Reference;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBackboneElement;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||
import org.hl7.fhir.instance.model.api.IDatatypeElement;
|
||||
import org.hl7.fhir.instance.model.api.IDomainResource;
|
||||
import org.hl7.fhir.instance.model.api.INarrative;
|
||||
import org.hl7.fhir.instance.model.api.IReference;
|
||||
|
||||
import ca.uhn.fhir.model.api.CodeableConceptElement;
|
||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||
|
@ -110,7 +114,7 @@ class ModelScanner {
|
|||
}
|
||||
|
||||
private void addScanAlso(Class<? extends IBase> theType) {
|
||||
if (theType.isInterface()) {
|
||||
if (theType.isInterface() || Modifier.isAbstract(theType.getModifiers())) {
|
||||
return;
|
||||
}
|
||||
myScanAlso.add(theType);
|
||||
|
@ -264,7 +268,7 @@ class ModelScanner {
|
|||
|
||||
ResourceDef resourceDefinition = pullAnnotation(theClass, ResourceDef.class);
|
||||
if (resourceDefinition != null) {
|
||||
if (!IResource.class.isAssignableFrom(theClass)) {
|
||||
if (!IBaseResource.class.isAssignableFrom(theClass)) {
|
||||
throw new ConfigurationException("Resource type contains a @" + ResourceDef.class.getSimpleName() + " annotation but does not implement " + IResource.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -288,11 +292,10 @@ class ModelScanner {
|
|||
}
|
||||
|
||||
Block blockDefinition = pullAnnotation(theClass, Block.class);
|
||||
|
||||
if (blockDefinition != null) {
|
||||
if (IResourceBlock.class.isAssignableFrom(theClass)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends IResourceBlock> blockClass = (Class<? extends IResourceBlock>) theClass;
|
||||
scanBlock(blockClass);
|
||||
if (IResourceBlock.class.isAssignableFrom(theClass) || IBackboneElement.class.isAssignableFrom(theClass) || IDatatypeElement.class.isAssignableFrom(theClass)) {
|
||||
scanBlock(theClass);
|
||||
} else {
|
||||
throw new ConfigurationException("Type contains a @" + Block.class.getSimpleName() + " annotation but does not implement " + IResourceBlock.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
||||
}
|
||||
|
@ -303,7 +306,7 @@ class ModelScanner {
|
|||
}
|
||||
}
|
||||
|
||||
private void scanBlock(Class<? extends IResourceBlock> theClass) {
|
||||
private void scanBlock(Class<? extends IBase> theClass) {
|
||||
ourLog.debug("Scanning resource block class: {}", theClass.getName());
|
||||
|
||||
String resourceName = theClass.getCanonicalName();
|
||||
|
@ -344,7 +347,7 @@ class ModelScanner {
|
|||
Class<? extends IBase> current = theClass;
|
||||
do {
|
||||
classes.push(current);
|
||||
if (ICompositeElement.class.isAssignableFrom(current.getSuperclass())) {
|
||||
if (IBase.class.isAssignableFrom(current.getSuperclass())) {
|
||||
current = (Class<? extends IBase>) current.getSuperclass();
|
||||
} else {
|
||||
current = null;
|
||||
|
@ -456,8 +459,8 @@ class ModelScanner {
|
|||
if (order != Child.ORDER_UNKNOWN) {
|
||||
order = order + baseElementOrder;
|
||||
}
|
||||
// int min = childAnnotation.min();
|
||||
// int max = childAnnotation.max();
|
||||
// int min = childAnnotation.min();
|
||||
// int max = childAnnotation.max();
|
||||
|
||||
/*
|
||||
* Anything that's marked as unknown is given a new ID that is <0 so that it doesn't conflict with any given
|
||||
|
@ -485,14 +488,21 @@ class ModelScanner {
|
|||
|
||||
Class<?> nextElementType = determineElementType(next);
|
||||
|
||||
if (BaseContainedDt.class.isAssignableFrom(nextElementType) || (childAnnotation.name().equals("contained") && DomainResource.class.isAssignableFrom(theClass))) {
|
||||
if (IAnyResource.class.isAssignableFrom(nextElementType)) {
|
||||
/*
|
||||
* Child is a resource as a direct child, as in Bundle.entry.resource
|
||||
*/
|
||||
RuntimeChildDirectResource def = new RuntimeChildDirectResource(next, childAnnotation, descriptionAnnotation, elementName);
|
||||
orderMap.put(order, def);
|
||||
|
||||
} else if (BaseContainedDt.class.isAssignableFrom(nextElementType) || (childAnnotation.name().equals("contained") && IDomainResource.class.isAssignableFrom(theClass))) {
|
||||
/*
|
||||
* Child is contained resources
|
||||
*/
|
||||
RuntimeChildContainedResources def = new RuntimeChildContainedResources(next, childAnnotation, descriptionAnnotation, elementName);
|
||||
orderMap.put(order, def);
|
||||
|
||||
} else if (choiceTypes.size() > 1 && !BaseResourceReferenceDt.class.isAssignableFrom(nextElementType) && !Reference.class.isAssignableFrom(nextElementType)) {
|
||||
} else if (choiceTypes.size() > 1 && !BaseResourceReferenceDt.class.isAssignableFrom(nextElementType) && !IReference.class.isAssignableFrom(nextElementType)) {
|
||||
/*
|
||||
* Child is a choice element
|
||||
*/
|
||||
|
@ -520,7 +530,7 @@ class ModelScanner {
|
|||
if (IElement.class.isAssignableFrom(nextElementType)) {
|
||||
addScanAlso((Class<? extends IElement>) nextElementType);
|
||||
}
|
||||
} else if (BaseResourceReferenceDt.class.isAssignableFrom(nextElementType) || Reference.class.isAssignableFrom(nextElementType)) {
|
||||
} else if (BaseResourceReferenceDt.class.isAssignableFrom(nextElementType) || IReference.class.isAssignableFrom(nextElementType)) {
|
||||
/*
|
||||
* Child is a resource reference
|
||||
*/
|
||||
|
@ -535,7 +545,7 @@ class ModelScanner {
|
|||
RuntimeChildResourceDefinition def = new RuntimeChildResourceDefinition(next, elementName, childAnnotation, descriptionAnnotation, refTypesList);
|
||||
orderMap.put(order, def);
|
||||
|
||||
} else if (IResourceBlock.class.isAssignableFrom(nextElementType) || BackboneElement.class.isAssignableFrom(nextElementType)) {
|
||||
} else if (IResourceBlock.class.isAssignableFrom(nextElementType) || IBackboneElement.class.isAssignableFrom(nextElementType) || IDatatypeElement.class.isAssignableFrom(nextElementType)) {
|
||||
/*
|
||||
* Child is a resource block (i.e. a sub-tag within a resource) TODO: do these have a better name
|
||||
* according to HL7?
|
||||
|
@ -546,12 +556,12 @@ class ModelScanner {
|
|||
RuntimeChildResourceBlockDefinition def = new RuntimeChildResourceBlockDefinition(next, childAnnotation, descriptionAnnotation, elementName, blockDef);
|
||||
orderMap.put(order, def);
|
||||
|
||||
} else if (IDatatype.class.equals(nextElementType) || IElement.class.equals(nextElementType)) {
|
||||
} else if (IDatatype.class.equals(nextElementType) || IElement.class.equals(nextElementType) || "org.hl7.fhir.instance.model.Type".equals(nextElementType.getName())) {
|
||||
|
||||
RuntimeChildAny def = new RuntimeChildAny(next, elementName, childAnnotation, descriptionAnnotation);
|
||||
orderMap.put(order, def);
|
||||
|
||||
} else if (IDatatype.class.isAssignableFrom(nextElementType) || IPrimitiveType.class.isAssignableFrom(nextElementType) || ICompositeType.class.isAssignableFrom(nextElementType)) {
|
||||
} else if (IDatatype.class.isAssignableFrom(nextElementType) || IPrimitiveType.class.isAssignableFrom(nextElementType) || ICompositeType.class.isAssignableFrom(nextElementType) || IBaseDatatype.class.isAssignableFrom(nextElementType) || IBaseExtension.class.isAssignableFrom(nextElementType)) {
|
||||
Class<? extends IBase> nextDatatype = (Class<? extends IBase>) nextElementType;
|
||||
|
||||
addScanAlso(nextDatatype);
|
||||
|
@ -567,7 +577,7 @@ class ModelScanner {
|
|||
if (IBoundCodeableConcept.class.isAssignableFrom(nextElementType)) {
|
||||
IValueSetEnumBinder<Enum<?>> binder = getBoundCodeBinder(next);
|
||||
def = new RuntimeChildCompositeBoundDatatypeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype, binder);
|
||||
} else if (BaseNarrativeDt.class.isAssignableFrom(nextElementType) || Narrative.class.getName().equals(nextElementType.getClass().getName())) {
|
||||
} else if (BaseNarrativeDt.class.isAssignableFrom(nextElementType) || INarrative.class.getName().equals(nextElementType.getClass().getName())) {
|
||||
def = new RuntimeChildNarrativeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype);
|
||||
} else {
|
||||
def = new RuntimeChildCompositeDatatypeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype);
|
||||
|
@ -726,16 +736,22 @@ class ModelScanner {
|
|||
if (theDatatypes != null) {
|
||||
try {
|
||||
// Datatypes
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends IElement> nextClass = (Class<? extends IElement>) Class.forName(nextValue);
|
||||
if (!IElement.class.isAssignableFrom(nextClass)) {
|
||||
ourLog.warn("Class is not assignable from " + IElement.class.getSimpleName() + ": " + nextValue);
|
||||
Class<?> dtType = Class.forName(nextValue);
|
||||
if (IElement.class.isAssignableFrom(dtType)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends IElement> nextClass = (Class<? extends IElement>) dtType;
|
||||
theDatatypes.add(nextClass);
|
||||
} else if (IBaseDatatype.class.isAssignableFrom(dtType)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends IBaseDatatype> nextClass = (Class<? extends IBaseDatatype>) dtType;
|
||||
theDatatypes.add(nextClass);
|
||||
} else {
|
||||
ourLog.warn("Class is not assignable from " + IElement.class.getSimpleName() + " or " + IBaseDatatype.class.getSimpleName() + ": " + nextValue);
|
||||
continue;
|
||||
}
|
||||
|
||||
theDatatypes.add(nextClass);
|
||||
} catch (ClassNotFoundException e) {
|
||||
ourLog.error("Unknown class[" + nextValue+ "] for data type definition: " + nextKey.substring("datatype.".length()), e);
|
||||
ourLog.error("Unknown class[" + nextValue + "] for data type definition: " + nextKey.substring("datatype.".length()), e);
|
||||
}
|
||||
}
|
||||
} else if (nextKey.startsWith("resource.")) {
|
||||
|
@ -751,7 +767,7 @@ class ModelScanner {
|
|||
|
||||
theResourceTypes.put(resName, nextClass);
|
||||
} catch (ClassNotFoundException e) {
|
||||
ourLog.error("Unknown class[" + nextValue+ "] for resource definition: " + nextKey.substring("resource.".length()), e);
|
||||
ourLog.error("Unknown class[" + nextValue + "] for resource definition: " + nextKey.substring("resource.".length()), e);
|
||||
}
|
||||
} else {
|
||||
ourLog.warn("Unexpected property in version property file: {}={}", nextKey, nextValue);
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
|
@ -61,7 +62,7 @@ public class RuntimeChildAny extends RuntimeChildChoiceDefinition {
|
|||
}
|
||||
}
|
||||
|
||||
if (IResource.class.isAssignableFrom(next) || IDatatype.class.isAssignableFrom(next)) {
|
||||
if (IResource.class.isAssignableFrom(next) || IDatatype.class.isAssignableFrom(next) || IBaseDatatype.class.isAssignableFrom(next)) {
|
||||
choiceTypes.add(next);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,10 +32,8 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||
|
||||
public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefinition {
|
||||
|
||||
|
@ -107,7 +105,7 @@ public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefini
|
|||
}
|
||||
|
||||
if (IBaseResource.class.isAssignableFrom(next)) {
|
||||
Class<? extends BaseResourceReferenceDt> refType = theContext.getVersion().getResourceReferenceType();
|
||||
Class<? extends IBase> refType = theContext.getVersion().getResourceReferenceType();
|
||||
myDatatypeToElementDefinition.put(refType, nextDef);
|
||||
alternateElementName = getElementName() + "Resource";
|
||||
myDatatypeToElementName.put(refType, alternateElementName);
|
||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.context;
|
|||
*/
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -48,7 +49,7 @@ public class RuntimeChildContainedResources extends BaseRuntimeDeclaredChildDefi
|
|||
@Override
|
||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theType) {
|
||||
assert BaseContainedDt.class.isAssignableFrom(theType);
|
||||
return myElem;
|
||||
return myElem;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,7 +65,16 @@ public class RuntimeChildContainedResources extends BaseRuntimeDeclaredChildDefi
|
|||
|
||||
@Override
|
||||
void sealAndInitialize(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
myElem = new RuntimeElemContainedResources(theContext.getVersion().getContainedType());
|
||||
Class<?> actualType = theContext.getVersion().getContainedType();
|
||||
if (BaseContainedDt.class.isAssignableFrom(actualType)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends BaseContainedDt> type = (Class<? extends BaseContainedDt>) actualType;
|
||||
myElem = new RuntimeElemContainedResources(type);
|
||||
} else if (ArrayList.class.isAssignableFrom(actualType)) {
|
||||
myElem = null;
|
||||
} else {
|
||||
throw new ConfigurationException("Fhir Version definition returned invalid contained type: " + actualType);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package ca.uhn.fhir.context;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2015 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.base.composite.BaseContainedDt;
|
||||
|
||||
public class RuntimeChildDirectResource extends BaseRuntimeDeclaredChildDefinition {
|
||||
|
||||
private RuntimeElemContainedResources myElem;
|
||||
private FhirContext myContext;
|
||||
|
||||
RuntimeChildDirectResource(Field theField, Child theChildAnnotation, Description theDescriptionAnnotation, String theElementName) throws ConfigurationException {
|
||||
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseRuntimeElementDefinition<?> getChildByName(String theName) {
|
||||
return new RuntimeElementDirectResource();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public BaseRuntimeElementDefinition<?> getChildElementDefinitionByDatatype(Class<? extends IBase> theType) {
|
||||
return myContext.getResourceDefinition((Class<? extends IBaseResource>) theType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChildNameByDatatype(Class<? extends IBase> theDatatype) {
|
||||
return getElementName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getValidChildNames() {
|
||||
return Collections.singleton(getElementName());
|
||||
}
|
||||
|
||||
@Override
|
||||
void sealAndInitialize(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
myContext = theContext;
|
||||
}
|
||||
|
||||
}
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.context;
|
|||
*/
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -47,7 +48,9 @@ public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefi
|
|||
myResourceTypes = theResourceTypes;
|
||||
|
||||
if (theResourceTypes == null || theResourceTypes.isEmpty()) {
|
||||
throw new ConfigurationException("Field '" + theField.getName() + "' on type '" + theField.getDeclaringClass().getCanonicalName() + "' has no resource types noted");
|
||||
myResourceTypes = new ArrayList<Class<? extends IBaseResource>>();
|
||||
myResourceTypes.add(IBaseResource.class);
|
||||
// throw new ConfigurationException("Field '" + theField.getName() + "' on type '" + theField.getDeclaringClass().getCanonicalName() + "' has no resource types noted");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,12 +50,13 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD
|
|||
public IAccessor getAccessor() {
|
||||
return new IAccessor() {
|
||||
@Override
|
||||
public List<? extends IBase> getValues(Object theTarget) {
|
||||
public List<IBase> getValues(Object theTarget) {
|
||||
ExtensionDt target = (ExtensionDt) theTarget;
|
||||
if (target.getValue() != null) {
|
||||
return Collections.singletonList(target.getValue());
|
||||
return Collections.singletonList((IBase)target.getValue());
|
||||
}
|
||||
return target.getUndeclaredExtensions();
|
||||
ArrayList<IBase> retVal = new ArrayList<IBase>(target.getUndeclaredExtensions());
|
||||
return retVal;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package ca.uhn.fhir.context;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
public class RuntimeElementDirectResource extends BaseRuntimeElementDefinition<IBaseResource> {
|
||||
|
||||
public RuntimeElementDirectResource() {
|
||||
super("DirectChildResource", IBaseResource.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum getChildType() {
|
||||
return ChildTypeEnum.RESOURCE;
|
||||
}
|
||||
|
||||
}
|
|
@ -20,11 +20,11 @@ package ca.uhn.fhir.context;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.model.api.IResourceBlock;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
public class RuntimeResourceBlockDefinition extends BaseRuntimeElementCompositeDefinition<IResourceBlock> {
|
||||
public class RuntimeResourceBlockDefinition extends BaseRuntimeElementCompositeDefinition<IBase> {
|
||||
|
||||
public RuntimeResourceBlockDefinition(String theName, Class<? extends IResourceBlock> theImplementingClass) {
|
||||
public RuntimeResourceBlockDefinition(String theName, Class<? extends IBase> theImplementingClass) {
|
||||
super(theName, theImplementingClass);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.util.Map;
|
|||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
|
@ -38,7 +39,7 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
|
|||
|
||||
private RuntimeResourceDefinition myBaseDefinition;
|
||||
private Map<String, RuntimeSearchParam> myNameToSearchParam = new LinkedHashMap<String, RuntimeSearchParam>();
|
||||
private IResource myProfileDef;
|
||||
private IBaseResource myProfileDef;
|
||||
private String myResourceProfile;
|
||||
private List<RuntimeSearchParam> mySearchParams;
|
||||
private FhirContext myContext;
|
||||
|
@ -57,7 +58,11 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
|
|||
|
||||
try {
|
||||
IBaseResource instance = theClass.newInstance();
|
||||
myStructureVersion = ((IResource)instance).getStructureFhirVersionEnum();
|
||||
if (instance instanceof IAnyResource) {
|
||||
myStructureVersion = FhirVersionEnum.DSTU2_HL7ORG;
|
||||
} else {
|
||||
myStructureVersion = ((IResource)instance).getStructureFhirVersionEnum();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ConfigurationException(myContext.getLocalizer().getMessage(getClass(), "nonInstantiableType", theClass.getName(), e.toString()), e);
|
||||
}
|
||||
|
@ -152,23 +157,23 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
|
|||
}
|
||||
|
||||
@Deprecated
|
||||
public synchronized IResource toProfile() {
|
||||
public synchronized IBaseResource toProfile() {
|
||||
if (myProfileDef != null) {
|
||||
return myProfileDef;
|
||||
}
|
||||
|
||||
IResource retVal = myContext.getVersion().generateProfile(this, null);
|
||||
IBaseResource retVal = myContext.getVersion().generateProfile(this, null);
|
||||
myProfileDef = retVal;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public synchronized IResource toProfile(String theServerBase) {
|
||||
public synchronized IBaseResource toProfile(String theServerBase) {
|
||||
if (myProfileDef != null) {
|
||||
return myProfileDef;
|
||||
}
|
||||
|
||||
IResource retVal = myContext.getVersion().generateProfile(this, theServerBase);
|
||||
IBaseResource retVal = myContext.getVersion().generateProfile(this, theServerBase);
|
||||
myProfileDef = retVal;
|
||||
|
||||
return retVal;
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Map;
|
|||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.Resource;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||
|
@ -52,7 +52,7 @@ public class RuntimeResourceReferenceDefinition extends BaseRuntimeElementDefini
|
|||
void sealAndInitialize(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
myResourceTypeToDefinition = new HashMap<Class<? extends IBaseResource>, RuntimeResourceDefinition>();
|
||||
for (Class<? extends IBaseResource> next : myResourceTypes) {
|
||||
if (next.equals(IResource.class) || next.equals(Resource.class) || next.equals(IBaseResource.class)) {
|
||||
if (next.equals(IResource.class) || next.equals(IAnyResource.class) || next.equals(IBaseResource.class)) {
|
||||
continue;
|
||||
}
|
||||
RuntimeResourceDefinition definition = (RuntimeResourceDefinition) theClassToElementDefinitions.get(next);
|
||||
|
|
|
@ -22,12 +22,11 @@ package ca.uhn.fhir.model.api;
|
|||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.model.base.composite.BaseContainedDt;
|
||||
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.IServerConformanceProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
|
@ -40,14 +39,14 @@ public interface IFhirVersion {
|
|||
|
||||
InputStream getFhirVersionPropertiesFile();
|
||||
|
||||
IResource generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition, String theServerBase);
|
||||
IBaseResource generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition, String theServerBase);
|
||||
|
||||
IServerConformanceProvider<? extends IBaseResource> createServerConformanceProvider(RestfulServer theRestfulServer);
|
||||
|
||||
String getPathToSchemaDefinitions();
|
||||
|
||||
Class<? extends BaseResourceReferenceDt> getResourceReferenceType();
|
||||
Class<? extends IBase> getResourceReferenceType();
|
||||
|
||||
Class<? extends BaseContainedDt> getContainedType();
|
||||
Class<?> getContainedType();
|
||||
|
||||
}
|
||||
|
|
|
@ -20,13 +20,15 @@ package ca.uhn.fhir.model.primitive;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseBooleanDatatype;
|
||||
|
||||
import ca.uhn.fhir.model.api.BasePrimitive;
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
||||
@DatatypeDef(name = "boolean")
|
||||
public class BooleanDt extends BasePrimitive<Boolean> {
|
||||
public class BooleanDt extends BasePrimitive<Boolean> implements IBaseBooleanDatatype {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
|
@ -24,12 +24,14 @@ import java.math.BigDecimal;
|
|||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseDecimalDatatype;
|
||||
|
||||
import ca.uhn.fhir.model.api.BasePrimitive;
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
|
||||
|
||||
@DatatypeDef(name = "decimal")
|
||||
public class DecimalDt extends BasePrimitive<BigDecimal> implements Comparable<DecimalDt> {
|
||||
public class DecimalDt extends BasePrimitive<BigDecimal> implements Comparable<DecimalDt>, IBaseDecimalDatatype {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.Resource;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
|
@ -525,8 +525,8 @@ public class IdDt implements IPrimitiveDatatype<String> {
|
|||
throw new NullPointerException("theResource can not be null");
|
||||
} else if (theResouce instanceof IResource) {
|
||||
((IResource) theResouce).setId(new IdDt(getValue()));
|
||||
} else if (theResouce instanceof Resource) {
|
||||
((Resource) theResouce).setId(getIdPart());
|
||||
} else if (theResouce instanceof IAnyResource) {
|
||||
((IAnyResource) theResouce).setId(getIdPart());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown resource class type, does not implement IResource or extend Resource");
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ public class IdDt implements IPrimitiveDatatype<String> {
|
|||
throw new NullPointerException("theResource can not be null");
|
||||
} else if (theResouce instanceof IResource) {
|
||||
return ((IResource) theResouce).getId();
|
||||
} else if (theResouce instanceof Resource) {
|
||||
} else if (theResouce instanceof IAnyResource) {
|
||||
// TODO: implement
|
||||
throw new UnsupportedOperationException();
|
||||
} else {
|
||||
|
|
|
@ -20,13 +20,15 @@ package ca.uhn.fhir.model.primitive;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseIntegerDatatype;
|
||||
|
||||
import ca.uhn.fhir.model.api.BasePrimitive;
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
||||
@DatatypeDef(name = "integer")
|
||||
public class IntegerDt extends BasePrimitive<Integer> {
|
||||
public class IntegerDt extends BasePrimitive<Integer> implements IBaseIntegerDatatype {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
|
@ -36,11 +36,11 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.DomainResource;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.Reference;
|
||||
import org.hl7.fhir.instance.model.Resource;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IDomainResource;
|
||||
import org.hl7.fhir.instance.model.api.IReference;
|
||||
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeDeclaredChildDefinition;
|
||||
|
@ -81,9 +81,9 @@ public abstract class BaseParser implements IParser {
|
|||
existingIdToContainedResource.put(nextId, next);
|
||||
}
|
||||
}
|
||||
} else if (theTarget instanceof DomainResource) {
|
||||
List<Resource> containedResources = ((DomainResource) theTarget).getContained();
|
||||
for (Resource next : containedResources) {
|
||||
} else if (theTarget instanceof IDomainResource) {
|
||||
List<? extends IAnyResource> containedResources = ((IDomainResource) theTarget).getContained();
|
||||
for (IAnyResource next : containedResources) {
|
||||
String nextId = next.getId();
|
||||
if (StringUtils.isNotBlank(nextId)) {
|
||||
allIds.add(nextId);
|
||||
|
@ -122,9 +122,9 @@ public abstract class BaseParser implements IParser {
|
|||
}
|
||||
|
||||
{
|
||||
List<Reference> allElements = myContext.newTerser().getAllPopulatedChildElementsOfType(theResource, Reference.class);
|
||||
for (Reference next : allElements) {
|
||||
Resource resource = next.getResource();
|
||||
List<IReference> allElements = myContext.newTerser().getAllPopulatedChildElementsOfType(theResource, IReference.class);
|
||||
for (IReference next : allElements) {
|
||||
IAnyResource resource = next.getResource();
|
||||
if (resource != null) {
|
||||
if (resource.getIdElement().isEmpty() || resource.getId().startsWith("#")) {
|
||||
theContained.addContained(resource);
|
||||
|
@ -312,8 +312,8 @@ public abstract class BaseParser implements IParser {
|
|||
IdDt newId;
|
||||
if (theResource instanceof IResource && ((IResource) theResource).getId().isLocal()) {
|
||||
newId = ((IResource) theResource).getId();
|
||||
} else if (theResource instanceof Resource && ((Resource)theResource).getId() != null && ((Resource)theResource).getId().startsWith("#")) {
|
||||
newId = new IdDt(((Resource)theResource).getId());
|
||||
} else if (theResource instanceof IAnyResource && ((IAnyResource)theResource).getId() != null && ((IAnyResource)theResource).getId().startsWith("#")) {
|
||||
newId = new IdDt(((IAnyResource)theResource).getId());
|
||||
} else {
|
||||
// TODO: make this configurable between the two below (and something else?)
|
||||
// newId = new IdDt(UUID.randomUUID().toString());
|
||||
|
|
|
@ -20,13 +20,10 @@ package ca.uhn.fhir.parser;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -54,7 +51,11 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.Resource;
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBooleanDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDecimalDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseIntegerDatatype;
|
||||
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||
|
@ -340,28 +341,28 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
|
||||
switch (theChildDef.getChildType()) {
|
||||
case PRIMITIVE_DATATYPE: {
|
||||
IPrimitiveDatatype<?> value = (IPrimitiveDatatype<?>) theNextValue;
|
||||
IPrimitiveType<?> value = (IPrimitiveType<?>) theNextValue;
|
||||
if (isBlank(value.getValueAsString())) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (value instanceof IntegerDt) {
|
||||
if (value instanceof IBaseIntegerDatatype) {
|
||||
if (theChildName != null) {
|
||||
theWriter.write(theChildName, ((IntegerDt) value).getValue());
|
||||
theWriter.write(theChildName, ((IBaseIntegerDatatype) value).getValue());
|
||||
} else {
|
||||
theWriter.write(((IntegerDt) value).getValue());
|
||||
theWriter.write(((IBaseIntegerDatatype) value).getValue());
|
||||
}
|
||||
} else if (value instanceof DecimalDt) {
|
||||
} else if (value instanceof IBaseDecimalDatatype) {
|
||||
if (theChildName != null) {
|
||||
theWriter.write(theChildName, ((DecimalDt) value).getValue());
|
||||
theWriter.write(theChildName, ((IBaseDecimalDatatype) value).getValue());
|
||||
} else {
|
||||
theWriter.write(((DecimalDt) value).getValue());
|
||||
theWriter.write(((IBaseDecimalDatatype) value).getValue());
|
||||
}
|
||||
} else if (value instanceof BooleanDt) {
|
||||
} else if (value instanceof IBaseBooleanDatatype) {
|
||||
if (theChildName != null) {
|
||||
theWriter.write(theChildName, ((BooleanDt) value).getValue());
|
||||
theWriter.write(theChildName, ((IBaseBooleanDatatype) value).getValue());
|
||||
} else {
|
||||
theWriter.write(((BooleanDt) value).getValue());
|
||||
theWriter.write(((IBaseBooleanDatatype) value).getValue());
|
||||
}
|
||||
} else {
|
||||
String valueStr = value.getValueAsString();
|
||||
|
@ -443,6 +444,11 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case RESOURCE:
|
||||
IBaseResource resource = (IBaseResource) theNextValue;
|
||||
RuntimeResourceDefinition def = myContext.getResourceDefinition(resource);
|
||||
encodeResourceToJsonStreamWriter(def, resource, theWriter, theChildName, true);
|
||||
break;
|
||||
case UNDECL_EXT:
|
||||
default:
|
||||
throw new IllegalStateException("Should not have this state here: " + theChildDef.getChildType().name());
|
||||
|
@ -610,8 +616,8 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
resourceId = res.getId().getIdPart();
|
||||
}
|
||||
}
|
||||
} else if (theResource instanceof Resource) {
|
||||
Resource res = (Resource) theResource;
|
||||
} else if (theResource instanceof IAnyResource) {
|
||||
IAnyResource res = (IAnyResource) theResource;
|
||||
if (theIsSubElementWithinResource && StringUtils.isNotBlank(res.getId())) {
|
||||
resourceId = res.getId();
|
||||
}
|
||||
|
@ -656,6 +662,7 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
} else {
|
||||
encodeCompositeElementToStreamWriter(theResDef, theResource, theResource, theEventWriter, resDef, theIsSubElementWithinResource);
|
||||
}
|
||||
|
||||
theEventWriter.writeEnd();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,7 @@ package ca.uhn.fhir.parser;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.defaultIfBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
import static org.apache.commons.lang3.StringUtils.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -34,12 +32,16 @@ import javax.xml.stream.events.XMLEvent;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.Element;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.ICompositeType;
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseElement;
|
||||
import org.hl7.fhir.instance.model.api.IReference;
|
||||
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition.IMutator;
|
||||
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
|
@ -121,9 +123,9 @@ class ParserState<T> {
|
|||
return myState.isPreResource();
|
||||
}
|
||||
|
||||
private BaseContainedDt newContainedDt(IResource theTarget) {
|
||||
private Object newContainedDt(IResource theTarget) {
|
||||
|
||||
BaseContainedDt newChildInstance;
|
||||
Object newChildInstance;
|
||||
try {
|
||||
newChildInstance = theTarget.getStructureFhirVersionEnum().getVersionImplementation().getContainedType().newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
|
@ -134,12 +136,16 @@ class ParserState<T> {
|
|||
return newChildInstance;
|
||||
}
|
||||
|
||||
private BaseResourceReferenceDt newResourceReferenceDt(IBase theFirstTarget, IResource theTarget) {
|
||||
private IBase newResourceReferenceDt(IBaseResource theTarget) {
|
||||
|
||||
BaseResourceReferenceDt newChildInstance;
|
||||
IBase newChildInstance;
|
||||
try {
|
||||
// if (theFirstTarget instanceof IResource)
|
||||
IFhirVersion version = theTarget.getStructureFhirVersionEnum().getVersionImplementation();
|
||||
IFhirVersion version;
|
||||
if (theTarget instanceof IResource) {
|
||||
version = ((IResource) theTarget).getStructureFhirVersionEnum().getVersionImplementation();
|
||||
} else {
|
||||
version = FhirVersionEnum.DSTU2_HL7ORG.getVersionImplementation();
|
||||
}
|
||||
newChildInstance = version.getResourceReferenceType().newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
throw new ConfigurationException("Failed to instantiate " + myContext.getVersion().getResourceReferenceType(), e);
|
||||
|
@ -220,7 +226,19 @@ class ParserState<T> {
|
|||
*/
|
||||
public static <T extends IBaseResource> ParserState<T> getPreResourceInstance(Class<T> theResourceType, FhirContext theContext, boolean theJsonMode) throws DataFormatException {
|
||||
ParserState<T> retVal = new ParserState<T>(theContext, theJsonMode);
|
||||
retVal.push(retVal.new PreResourceState(theResourceType));
|
||||
if (theResourceType == null) {
|
||||
if (theContext.getVersion().getVersion() != FhirVersionEnum.DSTU2_HL7ORG) {
|
||||
retVal.push(retVal.new PreResourceStateHapi(theResourceType));
|
||||
} else {
|
||||
retVal.push(retVal.new PreResourceStateHl7Org(theResourceType));
|
||||
}
|
||||
} else {
|
||||
if (IResource.class.isAssignableFrom(theResourceType)) {
|
||||
retVal.push(retVal.new PreResourceStateHapi(theResourceType));
|
||||
} else {
|
||||
retVal.push(retVal.new PreResourceStateHl7Org(theResourceType));
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
@ -467,7 +485,7 @@ class ParserState<T> {
|
|||
} else if ("author".equals(theLocalPart)) {
|
||||
push(new AtomAuthorState(myEntry));
|
||||
} else if ("content".equals(theLocalPart)) {
|
||||
push(new PreResourceState(myEntry, myResourceType));
|
||||
push(new PreResourceStateHapi(myEntry, myResourceType));
|
||||
} else if ("summary".equals(theLocalPart)) {
|
||||
push(new XhtmlState(getPreResourceState(), myEntry.getSummary(), false));
|
||||
} else if ("category".equals(theLocalPart)) {
|
||||
|
@ -1016,7 +1034,7 @@ class ParserState<T> {
|
|||
} else if ("score".equals(theLocalPart)) {
|
||||
push(new PrimitiveState(getPreResourceState(), myEntry.getScore()));
|
||||
} else if ("resource".equals(theLocalPart)) {
|
||||
push(new PreResourceState(myEntry, myResourceType));
|
||||
push(new PreResourceStateHapi(myEntry, myResourceType));
|
||||
} else if ("deleted".equals(theLocalPart)) {
|
||||
push(new BundleEntryDeletedState(getPreResourceState(), myEntry));
|
||||
} else {
|
||||
|
@ -1293,10 +1311,10 @@ class ParserState<T> {
|
|||
|
||||
}
|
||||
|
||||
private class ContainedResourcesState extends PreResourceState {
|
||||
private class ContainedResourcesStateHapi extends PreResourceState {
|
||||
|
||||
public ContainedResourcesState(PreResourceState thePreResourcesState) {
|
||||
super(thePreResourcesState, thePreResourcesState.myInstance.getStructureFhirVersionEnum());
|
||||
public ContainedResourcesStateHapi(PreResourceState thePreResourcesState) {
|
||||
super(thePreResourcesState, ((IResource) thePreResourcesState.myInstance).getStructureFhirVersionEnum());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1370,9 +1388,9 @@ class ParserState<T> {
|
|||
return;
|
||||
}
|
||||
case RESOURCE_REF: {
|
||||
BaseResourceReferenceDt newChildInstance = newResourceReferenceDt(null, myPreResourceState.myInstance);
|
||||
IBase newChildInstance = newResourceReferenceDt(myPreResourceState.myInstance);
|
||||
myDefinition.getMutator().addValue(myParentInstance, newChildInstance);
|
||||
ResourceReferenceState newState = new ResourceReferenceState(getPreResourceState(), newChildInstance);
|
||||
BaseState newState = createResourceReferenceState(getPreResourceState(), newChildInstance);
|
||||
push(newState);
|
||||
return;
|
||||
}
|
||||
|
@ -1408,6 +1426,16 @@ class ParserState<T> {
|
|||
|
||||
}
|
||||
|
||||
private BaseState createResourceReferenceState(ParserState<T>.PreResourceState thePreResourceState, IBase newChildInstance) {
|
||||
BaseState newState;
|
||||
if (newChildInstance instanceof IReference) {
|
||||
newState = new ResourceReferenceStateHl7Org(thePreResourceState, (IReference) newChildInstance);
|
||||
} else {
|
||||
newState = new ResourceReferenceStateHapi(thePreResourceState, (BaseResourceReferenceDt) newChildInstance);
|
||||
}
|
||||
return newState;
|
||||
}
|
||||
|
||||
private class ElementCompositeState<T2 extends IBase> extends BaseState {
|
||||
|
||||
private BaseRuntimeElementCompositeDefinition<?> myDefinition;
|
||||
|
@ -1424,8 +1452,8 @@ class ParserState<T> {
|
|||
if ("id".equals(theName)) {
|
||||
if (myInstance instanceof IIdentifiableElement) {
|
||||
((IIdentifiableElement) myInstance).setElementSpecificId((theValue));
|
||||
} else if (myInstance instanceof Element) {
|
||||
((Element) myInstance).setId(theValue);
|
||||
} else if (myInstance instanceof IBaseElement) {
|
||||
((IBaseElement) myInstance).setId(theValue);
|
||||
} else if (myInstance instanceof IBaseResource) {
|
||||
new IdDt(theValue).applyTo((IBaseResource) myInstance);
|
||||
}
|
||||
|
@ -1464,9 +1492,9 @@ class ParserState<T> {
|
|||
switch (target.getChildType()) {
|
||||
case COMPOSITE_DATATYPE: {
|
||||
BaseRuntimeElementCompositeDefinition<?> compositeTarget = (BaseRuntimeElementCompositeDefinition<?>) target;
|
||||
ICompositeDatatype newChildInstance = (ICompositeDatatype) compositeTarget.newInstance(child.getInstanceConstructorArguments());
|
||||
ICompositeType newChildInstance = (ICompositeType) compositeTarget.newInstance(child.getInstanceConstructorArguments());
|
||||
child.getMutator().addValue(myInstance, newChildInstance);
|
||||
ElementCompositeState<ICompositeElement> newState = new ElementCompositeState<ICompositeElement>(getPreResourceState(), compositeTarget, newChildInstance);
|
||||
ParserState<T>.ElementCompositeState<ICompositeType> newState = new ElementCompositeState<ICompositeType>(getPreResourceState(), compositeTarget, newChildInstance);
|
||||
push(newState);
|
||||
return;
|
||||
}
|
||||
|
@ -1480,19 +1508,17 @@ class ParserState<T> {
|
|||
return;
|
||||
}
|
||||
case RESOURCE_REF: {
|
||||
RuntimeResourceReferenceDefinition resourceRefTarget = (RuntimeResourceReferenceDefinition) target;
|
||||
BaseResourceReferenceDt newChildInstance = newResourceReferenceDt(myInstance, getPreResourceState().myInstance);
|
||||
getPreResourceState().getResourceReferences().add(newChildInstance);
|
||||
IBase newChildInstance = newResourceReferenceDt(getPreResourceState().myInstance);
|
||||
child.getMutator().addValue(myInstance, newChildInstance);
|
||||
ResourceReferenceState newState = new ResourceReferenceState(getPreResourceState(), newChildInstance);
|
||||
BaseState newState = createResourceReferenceState(getPreResourceState(), newChildInstance);
|
||||
push(newState);
|
||||
return;
|
||||
}
|
||||
case RESOURCE_BLOCK: {
|
||||
RuntimeResourceBlockDefinition blockTarget = (RuntimeResourceBlockDefinition) target;
|
||||
IResourceBlock newBlockInstance = blockTarget.newInstance();
|
||||
IBase newBlockInstance = blockTarget.newInstance();
|
||||
child.getMutator().addValue(myInstance, newBlockInstance);
|
||||
ElementCompositeState<ICompositeElement> newState = new ElementCompositeState<ICompositeElement>(getPreResourceState(), blockTarget, newBlockInstance);
|
||||
ElementCompositeState<IBase> newState = new ElementCompositeState<IBase>(getPreResourceState(), blockTarget, newBlockInstance);
|
||||
push(newState);
|
||||
return;
|
||||
}
|
||||
|
@ -1505,21 +1531,24 @@ class ParserState<T> {
|
|||
return;
|
||||
}
|
||||
case CONTAINED_RESOURCES: {
|
||||
RuntimeElemContainedResources targetElem = (RuntimeElemContainedResources) target;
|
||||
List<? extends IBase> values = child.getAccessor().getValues(myInstance);
|
||||
BaseContainedDt newDt;
|
||||
Object newDt;
|
||||
if (values == null || values.isEmpty() || values.get(0) == null) {
|
||||
newDt = newContainedDt(getPreResourceState().myInstance);
|
||||
child.getMutator().addValue(myInstance, newDt);
|
||||
newDt = newContainedDt((IResource) getPreResourceState().myInstance);
|
||||
child.getMutator().addValue(myInstance, (IBase) newDt);
|
||||
} else {
|
||||
newDt = (BaseContainedDt) values.get(0);
|
||||
newDt = values.get(0);
|
||||
}
|
||||
ContainedResourcesState state = new ContainedResourcesState(getPreResourceState());
|
||||
ContainedResourcesStateHapi state = new ContainedResourcesStateHapi(getPreResourceState());
|
||||
push(state);
|
||||
return;
|
||||
}
|
||||
case RESOURCE: {
|
||||
ParserState<T>.PreResourceStateHl7Org state = new PreResourceStateHl7Org(myInstance, child.getMutator(), null);
|
||||
push(state);
|
||||
return;
|
||||
}
|
||||
case UNDECL_EXT:
|
||||
case RESOURCE:
|
||||
case EXTENSION_DECLARED: {
|
||||
// Throw an exception because this shouldn't happen here
|
||||
break;
|
||||
|
@ -1589,9 +1618,9 @@ class ParserState<T> {
|
|||
return;
|
||||
}
|
||||
case RESOURCE_REF: {
|
||||
BaseResourceReferenceDt newChildInstance = newResourceReferenceDt(null, getPreResourceState().myInstance);
|
||||
BaseResourceReferenceDt newChildInstance = (BaseResourceReferenceDt) newResourceReferenceDt(getPreResourceState().myInstance);
|
||||
myExtension.setValue(newChildInstance);
|
||||
ResourceReferenceState newState = new ResourceReferenceState(getPreResourceState(), newChildInstance);
|
||||
ResourceReferenceStateHapi newState = new ResourceReferenceStateHapi(getPreResourceState(), newChildInstance);
|
||||
push(newState);
|
||||
return;
|
||||
}
|
||||
|
@ -1714,18 +1743,72 @@ class ParserState<T> {
|
|||
|
||||
}
|
||||
|
||||
private class PreResourceState extends BaseState {
|
||||
private class PreResourceStateHapi extends PreResourceState {
|
||||
private BundleEntry myEntry;
|
||||
|
||||
public PreResourceStateHapi(BundleEntry theEntry, Class<? extends IBaseResource> theResourceType) {
|
||||
super(theResourceType);
|
||||
myEntry = theEntry;
|
||||
}
|
||||
|
||||
public PreResourceStateHapi(Class<? extends IBaseResource> theResourceType) {
|
||||
super(theResourceType);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void wereBack() {
|
||||
super.wereBack();
|
||||
|
||||
if (myEntry == null) {
|
||||
myObject = (T) getCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException {
|
||||
super.enteringNewElement(theNamespaceURI, theLocalPart);
|
||||
if (myEntry != null) {
|
||||
myEntry.setResource((IResource) getCurrentElement());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class PreResourceStateHl7Org extends PreResourceState {
|
||||
|
||||
private IMutator myMutator;
|
||||
private Object myTarget;
|
||||
|
||||
public PreResourceStateHl7Org(Object theTarget, IMutator theMutator, Class<? extends IBaseResource> theResourceType) {
|
||||
super(theResourceType);
|
||||
myMutator = theMutator;
|
||||
myTarget = theTarget;
|
||||
}
|
||||
|
||||
public PreResourceStateHl7Org(Class<? extends IBaseResource> theResourceType) {
|
||||
super(theResourceType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException {
|
||||
super.enteringNewElement(theNamespaceURI, theLocalPart);
|
||||
if (myMutator != null) {
|
||||
myMutator.addValue(myTarget, getCurrentElement());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private abstract class PreResourceState extends BaseState {
|
||||
|
||||
private Map<String, IBaseResource> myContainedResources = new HashMap<String, IBaseResource>();
|
||||
private BundleEntry myEntry;
|
||||
private IResource myInstance;
|
||||
private IBaseResource myInstance;
|
||||
private FhirVersionEnum myParentVersion;
|
||||
private List<BaseResourceReferenceDt> myResourceReferences = new ArrayList<BaseResourceReferenceDt>();
|
||||
private Class<? extends IBaseResource> myResourceType;
|
||||
|
||||
public PreResourceState(BundleEntry theEntry, Class<? extends IBaseResource> theResourceType) {
|
||||
public PreResourceState(Class<? extends IBaseResource> theResourceType) {
|
||||
super(null);
|
||||
myEntry = theEntry;
|
||||
myResourceType = theResourceType;
|
||||
if (theResourceType != null) {
|
||||
myParentVersion = myContext.getResourceDefinition(theResourceType).getStructureVersion();
|
||||
|
@ -1734,14 +1817,6 @@ class ParserState<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theResourceType
|
||||
* May be null
|
||||
*/
|
||||
public PreResourceState(Class<? extends IBaseResource> theResourceType) {
|
||||
this(null, theResourceType);
|
||||
}
|
||||
|
||||
public PreResourceState(PreResourceState thePreResourcesState, FhirVersionEnum theParentVersion) {
|
||||
super(thePreResourcesState);
|
||||
Validate.notNull(theParentVersion);
|
||||
|
@ -1772,16 +1847,15 @@ class ParserState<T> {
|
|||
}
|
||||
|
||||
RuntimeResourceDefinition def = (RuntimeResourceDefinition) definition;
|
||||
myInstance = (IResource) def.newInstance();
|
||||
if (myEntry != null) {
|
||||
myEntry.setResource(myInstance);
|
||||
}
|
||||
myInstance = def.newInstance();
|
||||
|
||||
String resourceName = def.getName();
|
||||
if ("Binary".equals(resourceName) && myContext.getVersion().getVersion() == FhirVersionEnum.DSTU1) {
|
||||
push(new BinaryResourceStateForDstu1(getRootPreResourceState(), (BaseBinary) myInstance));
|
||||
} else if (myInstance instanceof IResource) {
|
||||
push(new ResourceStateHapi(getRootPreResourceState(), def, (IResource) myInstance));
|
||||
} else {
|
||||
push(new ResourceState(getRootPreResourceState(), def, myInstance));
|
||||
push(new ResourceStateHl7Org(getRootPreResourceState(), def, myInstance));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1794,10 +1868,6 @@ class ParserState<T> {
|
|||
return myInstance;
|
||||
}
|
||||
|
||||
public List<BaseResourceReferenceDt> getResourceReferences() {
|
||||
return myResourceReferences;
|
||||
}
|
||||
|
||||
private PreResourceState getRootPreResourceState() {
|
||||
if (getPreResourceState() != null) {
|
||||
return getPreResourceState();
|
||||
|
@ -1814,10 +1884,6 @@ class ParserState<T> {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void wereBack() {
|
||||
if (myEntry == null) {
|
||||
myObject = (T) myInstance;
|
||||
}
|
||||
|
||||
myContext.newTerser().visit(myInstance, new IModelVisitor() {
|
||||
|
||||
@Override
|
||||
|
@ -1904,8 +1970,8 @@ class ParserState<T> {
|
|||
} else if ("id".equals(theName)) {
|
||||
if (myInstance instanceof IIdentifiableElement) {
|
||||
((IIdentifiableElement) myInstance).setElementSpecificId(theValue);
|
||||
} else if (myInstance instanceof Element) {
|
||||
((Element) myInstance).setId(theValue);
|
||||
} else if (myInstance instanceof IBaseElement) {
|
||||
((IBaseElement) myInstance).setId(theValue);
|
||||
} else if (myInstance instanceof IBaseResource) {
|
||||
new IdDt(theValue).applyTo((org.hl7.fhir.instance.model.IBaseResource) myInstance);
|
||||
}
|
||||
|
@ -1945,12 +2011,81 @@ class ParserState<T> {
|
|||
|
||||
}
|
||||
|
||||
private class ResourceReferenceState extends BaseState {
|
||||
private class ResourceReferenceStateHl7Org extends BaseState {
|
||||
|
||||
private IReference myInstance;
|
||||
private ResourceReferenceSubState mySubState;
|
||||
|
||||
public ResourceReferenceStateHl7Org(PreResourceState thePreResourceState, IReference theInstance) {
|
||||
super(thePreResourceState);
|
||||
myInstance = theInstance;
|
||||
mySubState = ResourceReferenceSubState.INITIAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attributeValue(String theName, String theValue) throws DataFormatException {
|
||||
if (!"value".equals(theName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (mySubState) {
|
||||
case DISPLAY:
|
||||
myInstance.setDisplay(theValue);
|
||||
break;
|
||||
case INITIAL:
|
||||
throw new DataFormatException("Unexpected attribute: " + theValue);
|
||||
case REFERENCE:
|
||||
myInstance.setReference(theValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endingElement() {
|
||||
switch (mySubState) {
|
||||
case INITIAL:
|
||||
pop();
|
||||
break;
|
||||
case DISPLAY:
|
||||
case REFERENCE:
|
||||
mySubState = ResourceReferenceSubState.INITIAL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enteringNewElement(String theNamespaceURI, String theLocalPart) throws DataFormatException {
|
||||
switch (mySubState) {
|
||||
case INITIAL:
|
||||
if ("display".equals(theLocalPart)) {
|
||||
mySubState = ResourceReferenceSubState.DISPLAY;
|
||||
break;
|
||||
} else if ("reference".equals(theLocalPart)) {
|
||||
mySubState = ResourceReferenceSubState.REFERENCE;
|
||||
break;
|
||||
} else if ("resource".equals(theLocalPart)) {
|
||||
mySubState = ResourceReferenceSubState.REFERENCE;
|
||||
break;
|
||||
}
|
||||
//$FALL-THROUGH$
|
||||
case DISPLAY:
|
||||
case REFERENCE:
|
||||
throw new DataFormatException("Unexpected element: " + theLocalPart);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IReference getCurrentElement() {
|
||||
return myInstance;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ResourceReferenceStateHapi extends BaseState {
|
||||
|
||||
private BaseResourceReferenceDt myInstance;
|
||||
private ResourceReferenceSubState mySubState;
|
||||
|
||||
public ResourceReferenceState(PreResourceState thePreResourceState, BaseResourceReferenceDt theInstance) {
|
||||
public ResourceReferenceStateHapi(PreResourceState thePreResourceState, BaseResourceReferenceDt theInstance) {
|
||||
super(thePreResourceState);
|
||||
myInstance = theInstance;
|
||||
mySubState = ResourceReferenceSubState.INITIAL;
|
||||
|
@ -2018,9 +2153,9 @@ class ParserState<T> {
|
|||
DISPLAY, INITIAL, REFERENCE
|
||||
}
|
||||
|
||||
private class ResourceState extends ElementCompositeState<IResource> {
|
||||
private class ResourceStateHapi extends ElementCompositeState<IResource> {
|
||||
|
||||
public ResourceState(PreResourceState thePreResourceState, BaseRuntimeElementCompositeDefinition<?> theDef, IResource theInstance) {
|
||||
public ResourceStateHapi(PreResourceState thePreResourceState, BaseRuntimeElementCompositeDefinition<?> theDef, IResource theInstance) {
|
||||
super(thePreResourceState, theDef, theInstance);
|
||||
}
|
||||
|
||||
|
@ -2037,6 +2172,14 @@ class ParserState<T> {
|
|||
|
||||
}
|
||||
|
||||
private class ResourceStateHl7Org extends ElementCompositeState<IBaseResource> {
|
||||
|
||||
public ResourceStateHl7Org(PreResourceState thePreResourceState, BaseRuntimeElementCompositeDefinition<?> theDef, IBaseResource theInstance) {
|
||||
super(thePreResourceState, theDef, theInstance);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class SwallowChildrenWholeState extends BaseState {
|
||||
|
||||
private int myDepth;
|
||||
|
|
|
@ -20,9 +20,7 @@ package ca.uhn.fhir.parser;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
@ -47,11 +45,11 @@ import javax.xml.stream.events.StartElement;
|
|||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.DomainResource;
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.Narrative;
|
||||
import org.hl7.fhir.instance.model.Resource;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IDomainResource;
|
||||
import org.hl7.fhir.instance.model.api.INarrative;
|
||||
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||
|
@ -525,7 +523,7 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
continue;
|
||||
}
|
||||
} else {
|
||||
Narrative narr1 = ((DomainResource) theResource).getText();
|
||||
INarrative narr1 = ((IDomainResource) theResource).getText();
|
||||
BaseNarrativeDt<?> narr2 = null;
|
||||
if (gen != null && narr1.isEmpty()) {
|
||||
// TODO: need to implement this
|
||||
|
@ -673,7 +671,7 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
}
|
||||
} else {
|
||||
// HL7 structs
|
||||
Resource resource = (Resource) theResource;
|
||||
IAnyResource resource = (IAnyResource) theResource;
|
||||
if (StringUtils.isNotBlank(resource.getId())) {
|
||||
resourceId = resource.getId();
|
||||
}
|
||||
|
|
|
@ -24,11 +24,14 @@ import java.io.IOException;
|
|||
import java.io.PrintWriter;
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
|
@ -52,7 +55,7 @@ import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
|||
|
||||
abstract class BaseAddOrDeleteTagsMethodBinding extends BaseMethodBinding<Void> {
|
||||
|
||||
private Class<? extends IResource> myType;
|
||||
private Class<? extends IBaseResource> myType;
|
||||
private Integer myIdParamIndex;
|
||||
private Integer myVersionIdParamIndex;
|
||||
private String myResourceName;
|
||||
|
@ -67,9 +70,10 @@ abstract class BaseAddOrDeleteTagsMethodBinding extends BaseMethodBinding<Void>
|
|||
myType = theTypeFromMethodAnnotation;
|
||||
}
|
||||
|
||||
if (myType.equals(IResource.class)) {
|
||||
if (Modifier.isInterface(myType.getModifiers())) {
|
||||
throw new ConfigurationException("Method '" + theMethod.getName() + "' does not specify a resource type, but has an @" + IdParam.class.getSimpleName() + " parameter. Please specity a resource type in the method annotation on this method");
|
||||
}
|
||||
|
||||
myResourceName = theConetxt.getResourceDefinition(myType).getName();
|
||||
|
||||
myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod);
|
||||
|
@ -132,7 +136,7 @@ abstract class BaseAddOrDeleteTagsMethodBinding extends BaseMethodBinding<Void>
|
|||
|
||||
TagList tagList = (TagList) theArgs[myTagListParamIndex];
|
||||
|
||||
Class<? extends IResource> type = myType;
|
||||
Class<? extends IBaseResource> type = myType;
|
||||
assert type != null;
|
||||
|
||||
if (isDelete()) {
|
||||
|
|
|
@ -254,9 +254,9 @@ public abstract class BaseMethodBinding<T> implements IClientResponseHandler<T>
|
|||
return null;
|
||||
}
|
||||
|
||||
Class<? extends IResource> returnType;
|
||||
Class<? extends IBaseResource> returnType;
|
||||
|
||||
Class<? extends IResource> returnTypeFromRp = null;
|
||||
Class<? extends IBaseResource> returnTypeFromRp = null;
|
||||
if (theProvider instanceof IResourceProvider) {
|
||||
returnTypeFromRp = ((IResourceProvider) theProvider).getResourceType();
|
||||
if (!verifyIsValidResourceReturnType(returnTypeFromRp)) {
|
||||
|
|
|
@ -42,7 +42,7 @@ abstract class BaseOutcomeReturningMethodBindingWithResourceParam extends BaseOu
|
|||
private int myResourceParameterIndex;
|
||||
private String myResourceName;
|
||||
private boolean myBinary;
|
||||
private Class<? extends IResource> myResourceType;
|
||||
private Class<? extends IBaseResource> myResourceType;
|
||||
|
||||
public BaseOutcomeReturningMethodBindingWithResourceParam(Method theMethod, FhirContext theContext, Class<?> theMethodAnnotation, Object theProvider) {
|
||||
super(theMethod, theContext, theMethodAnnotation, theProvider);
|
||||
|
@ -57,7 +57,7 @@ abstract class BaseOutcomeReturningMethodBindingWithResourceParam extends BaseOu
|
|||
}
|
||||
|
||||
resourceParameter = (ResourceParameter) next;
|
||||
Class<? extends IResource> providerResourceType = resourceParameter.getResourceType();
|
||||
Class<? extends IBaseResource> providerResourceType = resourceParameter.getResourceType();
|
||||
|
||||
if (theProvider instanceof IResourceProvider) {
|
||||
providerResourceType = ((IResourceProvider) theProvider).getResourceType();
|
||||
|
|
|
@ -26,9 +26,10 @@ import java.util.Collection;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
|
||||
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
|
@ -47,7 +48,7 @@ public class DynamicSearchMethodBinding extends BaseResourceReturningMethodBindi
|
|||
private HashSet<String> myParamNames;
|
||||
private Integer myIdParamIndex;
|
||||
|
||||
public DynamicSearchMethodBinding(Class<? extends IResource> theReturnResourceType, Method theMethod, FhirContext theConetxt, IDynamicSearchResourceProvider theProvider) {
|
||||
public DynamicSearchMethodBinding(Class<? extends IBaseResource> theReturnResourceType, Method theMethod, FhirContext theConetxt, IDynamicSearchResourceProvider theProvider) {
|
||||
super(theReturnResourceType, theMethod, theConetxt, theProvider);
|
||||
|
||||
myProvider = theProvider;
|
||||
|
|
|
@ -24,11 +24,14 @@ import java.io.IOException;
|
|||
import java.io.PrintWriter;
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
|
@ -51,7 +54,7 @@ import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
|||
|
||||
public class GetTagsMethodBinding extends BaseMethodBinding<TagList> {
|
||||
|
||||
private Class<? extends IResource> myType;
|
||||
private Class<? extends IBaseResource> myType;
|
||||
private Integer myIdParamIndex;
|
||||
private Integer myVersionIdParamIndex;
|
||||
private String myResourceName;
|
||||
|
@ -65,7 +68,7 @@ public class GetTagsMethodBinding extends BaseMethodBinding<TagList> {
|
|||
myType = theAnnotation.type();
|
||||
}
|
||||
|
||||
if (!IResource.class.equals(myType)) {
|
||||
if (!Modifier.isInterface(myType.getModifiers())) {
|
||||
myResourceName = theConetxt.getResourceDefinition(myType).getName();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,11 @@ package ca.uhn.fhir.rest.method;
|
|||
import static org.apache.commons.lang3.StringUtils.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
|
@ -57,8 +59,8 @@ public class HistoryMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod);
|
||||
|
||||
History historyAnnotation = theMethod.getAnnotation(History.class);
|
||||
Class<? extends IResource> type = historyAnnotation.type();
|
||||
if (type == IResource.class) {
|
||||
Class<? extends IBaseResource> type = historyAnnotation.type();
|
||||
if (Modifier.isInterface(type.getModifiers())) {
|
||||
if (theProvider instanceof IResourceProvider) {
|
||||
type = ((IResourceProvider) theProvider).getResourceType();
|
||||
if (myIdParamIndex != null) {
|
||||
|
@ -235,7 +237,7 @@ public class HistoryMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
return true;
|
||||
}
|
||||
|
||||
private static Class<? extends IResource> toReturnType(Method theMethod, Object theProvider) {
|
||||
private static Class<? extends IBaseResource> toReturnType(Method theMethod, Object theProvider) {
|
||||
if (theProvider instanceof IResourceProvider) {
|
||||
return ((IResourceProvider) theProvider).getResourceType();
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.client.utils.DateUtils;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.Resource;
|
||||
import org.hl7.fhir.instance.model.Resource.ResourceMetaComponent;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IMetaType;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -145,8 +145,8 @@ public class MethodUtil {
|
|||
if (resource instanceof IResource) {
|
||||
InstantDt lmValue = new InstantDt(headerDateValue);
|
||||
((IResource) resource).getResourceMetadata().put(ResourceMetadataKeyEnum.UPDATED, lmValue);
|
||||
} else if (resource instanceof Resource) {
|
||||
((Resource) resource).getMeta().setLastUpdated(headerDateValue);
|
||||
} else if (resource instanceof IAnyResource) {
|
||||
((IAnyResource) resource).getMeta().setLastUpdated(headerDateValue);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ourLog.warn("Unable to parse date string '{}'. Error is: {}", headerValue, e.toString());
|
||||
|
@ -190,8 +190,8 @@ public class MethodUtil {
|
|||
}
|
||||
if (resource instanceof IResource) {
|
||||
ResourceMetadataKeyEnum.TAG_LIST.put((IResource) resource, tagList);
|
||||
} else if (resource instanceof Resource) {
|
||||
ResourceMetaComponent meta = ((Resource) resource).getMeta();
|
||||
} else if (resource instanceof IAnyResource) {
|
||||
IMetaType meta = ((IAnyResource) resource).getMeta();
|
||||
for (Tag next : tagList) {
|
||||
meta.addTag().setSystem(next.getScheme()).setCode(next.getTerm()).setDisplay(next.getLabel());
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.util.Map;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -60,7 +61,7 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding implem
|
|||
private boolean mySupportsVersion;
|
||||
private Integer myVersionIdIndex;
|
||||
|
||||
public ReadMethodBinding(Class<? extends IResource> theAnnotatedResourceType, Method theMethod, FhirContext theContext, Object theProvider) {
|
||||
public ReadMethodBinding(Class<? extends IBaseResource> theAnnotatedResourceType, Method theMethod, FhirContext theContext, Object theProvider) {
|
||||
super(theAnnotatedResourceType, theMethod, theContext, theProvider);
|
||||
|
||||
Validate.notNull(theMethod, "Method must not be null");
|
||||
|
|
|
@ -20,8 +20,7 @@ package ca.uhn.fhir.rest.method;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
|
@ -34,6 +33,7 @@ import java.util.Map.Entry;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -58,18 +58,18 @@ public class SearchMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchMethodBinding.class);
|
||||
|
||||
private String myCompartmentName;
|
||||
private Class<? extends IResource> myDeclaredResourceType;
|
||||
private Class<? extends IBaseResource> myDeclaredResourceType;
|
||||
private String myDescription;
|
||||
private Integer myIdParamIndex;
|
||||
private String myQueryName;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public SearchMethodBinding(Class<? extends IResource> theReturnResourceType, Method theMethod, FhirContext theContext, Object theProvider) {
|
||||
public SearchMethodBinding(Class<? extends IBaseResource> theReturnResourceType, Method theMethod, FhirContext theContext, Object theProvider) {
|
||||
super(theReturnResourceType, theMethod, theContext, theProvider);
|
||||
Search search = theMethod.getAnnotation(Search.class);
|
||||
this.myQueryName = StringUtils.defaultIfBlank(search.queryName(), null);
|
||||
this.myCompartmentName = StringUtils.defaultIfBlank(search.compartmentName(), null);
|
||||
this.myDeclaredResourceType = (Class<? extends IResource>) theMethod.getReturnType();
|
||||
this.myDeclaredResourceType = (Class<? extends IBaseResource>) theMethod.getReturnType();
|
||||
this.myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod);
|
||||
|
||||
Description desc = theMethod.getAnnotation(Description.class);
|
||||
|
@ -118,7 +118,7 @@ public class SearchMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
|
||||
}
|
||||
|
||||
public Class<? extends IResource> getDeclaredResourceType() {
|
||||
public Class<? extends IBaseResource> getDeclaredResourceType() {
|
||||
return myDeclaredResourceType;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.rest.server;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
public interface IResourceProvider {
|
||||
|
||||
|
@ -29,6 +29,6 @@ public interface IResourceProvider {
|
|||
*
|
||||
* @return Returns the type of resource returned by this provider
|
||||
*/
|
||||
Class<? extends IResource> getResourceType();
|
||||
Class<? extends IBaseResource> getResourceType();
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.http.client.utils.DateUtils;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
|
@ -770,7 +771,7 @@ public class RestfulServer extends HttpServlet {
|
|||
Map<String, IResourceProvider> typeToProvider = new HashMap<String, IResourceProvider>();
|
||||
for (IResourceProvider nextProvider : resourceProvider) {
|
||||
|
||||
Class<? extends IResource> resourceType = nextProvider.getResourceType();
|
||||
Class<? extends IBaseResource> resourceType = nextProvider.getResourceType();
|
||||
if (resourceType == null) {
|
||||
throw new NullPointerException("getResourceType() on class '" + nextProvider.getClass().getCanonicalName() + "' returned null");
|
||||
}
|
||||
|
|
|
@ -232,7 +232,8 @@ public class FhirTerser {
|
|||
b.append(childDef.getName());
|
||||
b.append(" - Valid types: ");
|
||||
for (Iterator<String> iter = new TreeSet<String>(nextChild.getValidChildNames()).iterator(); iter.hasNext();) {
|
||||
b.append(nextChild.getChildByName(iter.next()).getImplementingClass().getSimpleName());
|
||||
BaseRuntimeElementDefinition<?> childByName = nextChild.getChildByName(iter.next());
|
||||
b.append(childByName.getImplementingClass().getSimpleName());
|
||||
if (iter.hasNext()) {
|
||||
b.append(", ");
|
||||
}
|
||||
|
@ -268,7 +269,7 @@ public class FhirTerser {
|
|||
* @param theVisitor
|
||||
* The visitor
|
||||
*/
|
||||
public void visit(IResource theResource, IModelVisitor theVisitor) {
|
||||
public void visit(IBaseResource theResource, IModelVisitor theVisitor) {
|
||||
BaseRuntimeElementCompositeDefinition<?> def = myContext.getResourceDefinition(theResource);
|
||||
visit(theResource, null, def, theVisitor);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.util;
|
|||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
||||
|
@ -28,7 +29,7 @@ import ca.uhn.fhir.model.api.ExtensionDt;
|
|||
import ca.uhn.fhir.model.api.ISupportsUndeclaredExtensions;
|
||||
|
||||
/**
|
||||
* @see FhirTerser#visit(ca.uhn.fhir.model.api.IResource, IModelVisitor)
|
||||
* @see FhirTerser#visit(IBaseResource, IModelVisitor)
|
||||
*/
|
||||
public interface IModelVisitor {
|
||||
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
package org.hl7.fhir.instance.formats;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2015 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.hl7.fhir.instance.model.DateAndTime;
|
||||
|
||||
public abstract class FormatUtilities {
|
||||
public static final String ID_REGEX = "[A-Za-z0-9\\-\\.]{1,64}";
|
||||
protected static final String FHIR_NS = "http://hl7.org/fhir";
|
||||
protected static final String ATOM_NS = "http://www.w3.org/2005/Atom";
|
||||
protected static final String GDATA_NS = "http://schemas.google.com/g/2005";
|
||||
|
||||
protected String toString(String value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
protected String toString(int value) {
|
||||
return java.lang.Integer.toString(value);
|
||||
}
|
||||
|
||||
protected String toString(boolean value) {
|
||||
return java.lang.Boolean.toString(value);
|
||||
}
|
||||
|
||||
protected String toString(BigDecimal value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
protected String toString(URI value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String toString(byte[] value) {
|
||||
byte[] encodeBase64 = Base64.encodeBase64(value);
|
||||
return new String(encodeBase64);
|
||||
}
|
||||
|
||||
protected String toString(DateAndTime value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static boolean isValidId(String tail) {
|
||||
return tail.matches(ID_REGEX);
|
||||
}
|
||||
|
||||
public static String makeId(String candidate) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (char c : candidate.toCharArray())
|
||||
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '.' || c == '-')
|
||||
b.append(c);
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,702 +0,0 @@
|
|||
package org.hl7.fhir.instance.model;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2015 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
// Generated on Sun, Dec 7, 2014 21:45-0500 for FHIR v0.3.0
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.instance.model.annotations.ResourceDef;
|
||||
import org.hl7.fhir.instance.model.annotations.SearchParamDefinition;
|
||||
import org.hl7.fhir.instance.model.annotations.Block;
|
||||
import org.hl7.fhir.instance.model.annotations.Child;
|
||||
import org.hl7.fhir.instance.model.annotations.Description;
|
||||
/**
|
||||
* Describes the intended objective(s) of carrying out the Care Plan.
|
||||
*/
|
||||
@ResourceDef(name="GoalRequest", profile="http://hl7.org/fhir/Profile/GoalRequest")
|
||||
public class GoalRequest extends DomainResource {
|
||||
|
||||
public enum GoalRequestStatus implements FhirEnum {
|
||||
/**
|
||||
* The goal is being sought but has not yet been reached. (Also applies if goal was reached in the past but there has been regression and goal is being sought again).
|
||||
*/
|
||||
INPROGRESS,
|
||||
/**
|
||||
* The goal has been met and no further action is needed.
|
||||
*/
|
||||
ACHIEVED,
|
||||
/**
|
||||
* The goal has been met, but ongoing activity is needed to sustain the goal objective.
|
||||
*/
|
||||
SUSTAINING,
|
||||
/**
|
||||
* The goal is no longer being sought.
|
||||
*/
|
||||
CANCELLED,
|
||||
/**
|
||||
* added to help the parsers
|
||||
*/
|
||||
NULL;
|
||||
|
||||
public static final GoalRequestStatusEnumFactory ENUM_FACTORY = new GoalRequestStatusEnumFactory();
|
||||
|
||||
public static GoalRequestStatus fromCode(String codeString) throws IllegalArgumentException {
|
||||
if (codeString == null || "".equals(codeString))
|
||||
return null;
|
||||
if ("in progress".equals(codeString))
|
||||
return INPROGRESS;
|
||||
if ("achieved".equals(codeString))
|
||||
return ACHIEVED;
|
||||
if ("sustaining".equals(codeString))
|
||||
return SUSTAINING;
|
||||
if ("cancelled".equals(codeString))
|
||||
return CANCELLED;
|
||||
throw new IllegalArgumentException("Unknown GoalRequestStatus code '"+codeString+"'");
|
||||
}
|
||||
@Override
|
||||
public String toCode() {
|
||||
switch (this) {
|
||||
case INPROGRESS: return "in progress";
|
||||
case ACHIEVED: return "achieved";
|
||||
case SUSTAINING: return "sustaining";
|
||||
case CANCELLED: return "cancelled";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
public String getSystem() {
|
||||
switch (this) {
|
||||
case INPROGRESS: return "";
|
||||
case ACHIEVED: return "";
|
||||
case SUSTAINING: return "";
|
||||
case CANCELLED: return "";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
public String getDefinition() {
|
||||
switch (this) {
|
||||
case INPROGRESS: return "The goal is being sought but has not yet been reached. (Also applies if goal was reached in the past but there has been regression and goal is being sought again).";
|
||||
case ACHIEVED: return "The goal has been met and no further action is needed.";
|
||||
case SUSTAINING: return "The goal has been met, but ongoing activity is needed to sustain the goal objective.";
|
||||
case CANCELLED: return "The goal is no longer being sought.";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
public String getDisplay() {
|
||||
switch (this) {
|
||||
case INPROGRESS: return "in progress";
|
||||
case ACHIEVED: return "achieved";
|
||||
case SUSTAINING: return "sustaining";
|
||||
case CANCELLED: return "cancelled";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class GoalRequestStatusEnumFactory implements EnumFactory<GoalRequestStatus> {
|
||||
public GoalRequestStatus fromCode(String codeString) throws IllegalArgumentException {
|
||||
if (codeString == null || "".equals(codeString))
|
||||
if (codeString == null || "".equals(codeString))
|
||||
return null;
|
||||
if ("in progress".equals(codeString))
|
||||
return GoalRequestStatus.INPROGRESS;
|
||||
if ("achieved".equals(codeString))
|
||||
return GoalRequestStatus.ACHIEVED;
|
||||
if ("sustaining".equals(codeString))
|
||||
return GoalRequestStatus.SUSTAINING;
|
||||
if ("cancelled".equals(codeString))
|
||||
return GoalRequestStatus.CANCELLED;
|
||||
throw new IllegalArgumentException("Unknown GoalRequestStatus code '"+codeString+"'");
|
||||
}
|
||||
public String toCode(GoalRequestStatus code) throws IllegalArgumentException {
|
||||
if (code == GoalRequestStatus.INPROGRESS)
|
||||
return "in progress";
|
||||
if (code == GoalRequestStatus.ACHIEVED)
|
||||
return "achieved";
|
||||
if (code == GoalRequestStatus.SUSTAINING)
|
||||
return "sustaining";
|
||||
if (code == GoalRequestStatus.CANCELLED)
|
||||
return "cancelled";
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
public enum GoalRequestMode implements FhirEnum {
|
||||
/**
|
||||
* planned.
|
||||
*/
|
||||
PLANNED,
|
||||
/**
|
||||
* proposed.
|
||||
*/
|
||||
PROPOSED,
|
||||
/**
|
||||
* ordered.
|
||||
*/
|
||||
ORDERED,
|
||||
/**
|
||||
* added to help the parsers
|
||||
*/
|
||||
NULL;
|
||||
|
||||
public static final GoalRequestModeEnumFactory ENUM_FACTORY = new GoalRequestModeEnumFactory();
|
||||
|
||||
public static GoalRequestMode fromCode(String codeString) throws IllegalArgumentException {
|
||||
if (codeString == null || "".equals(codeString))
|
||||
return null;
|
||||
if ("planned".equals(codeString))
|
||||
return PLANNED;
|
||||
if ("proposed".equals(codeString))
|
||||
return PROPOSED;
|
||||
if ("ordered".equals(codeString))
|
||||
return ORDERED;
|
||||
throw new IllegalArgumentException("Unknown GoalRequestMode code '"+codeString+"'");
|
||||
}
|
||||
@Override
|
||||
public String toCode() {
|
||||
switch (this) {
|
||||
case PLANNED: return "planned";
|
||||
case PROPOSED: return "proposed";
|
||||
case ORDERED: return "ordered";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
public String getSystem() {
|
||||
switch (this) {
|
||||
case PLANNED: return "";
|
||||
case PROPOSED: return "";
|
||||
case ORDERED: return "";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
public String getDefinition() {
|
||||
switch (this) {
|
||||
case PLANNED: return "planned.";
|
||||
case PROPOSED: return "proposed.";
|
||||
case ORDERED: return "ordered.";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
public String getDisplay() {
|
||||
switch (this) {
|
||||
case PLANNED: return "planned";
|
||||
case PROPOSED: return "proposed";
|
||||
case ORDERED: return "ordered";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class GoalRequestModeEnumFactory implements EnumFactory<GoalRequestMode> {
|
||||
public GoalRequestMode fromCode(String codeString) throws IllegalArgumentException {
|
||||
if (codeString == null || "".equals(codeString))
|
||||
if (codeString == null || "".equals(codeString))
|
||||
return null;
|
||||
if ("planned".equals(codeString))
|
||||
return GoalRequestMode.PLANNED;
|
||||
if ("proposed".equals(codeString))
|
||||
return GoalRequestMode.PROPOSED;
|
||||
if ("ordered".equals(codeString))
|
||||
return GoalRequestMode.ORDERED;
|
||||
throw new IllegalArgumentException("Unknown GoalRequestMode code '"+codeString+"'");
|
||||
}
|
||||
public String toCode(GoalRequestMode code) throws IllegalArgumentException {
|
||||
if (code == GoalRequestMode.PLANNED)
|
||||
return "planned";
|
||||
if (code == GoalRequestMode.PROPOSED)
|
||||
return "proposed";
|
||||
if (code == GoalRequestMode.ORDERED)
|
||||
return "ordered";
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This records identifiers associated with this care plan that are defined by business processed and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).
|
||||
*/
|
||||
@Child(name="identifier", type={Identifier.class}, order=-1, min=0, max=Child.MAX_UNLIMITED)
|
||||
@Description(shortDefinition="External Ids for this goal", formalDefinition="This records identifiers associated with this care plan that are defined by business processed and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation)." )
|
||||
protected List<Identifier> identifier;
|
||||
|
||||
/**
|
||||
* Identifies the patient/subject whose intended care is described by the plan.
|
||||
*/
|
||||
@Child(name="patient", type={Patient.class}, order=0, min=0, max=1)
|
||||
@Description(shortDefinition="The patient for whom this goal is intended for", formalDefinition="Identifies the patient/subject whose intended care is described by the plan." )
|
||||
protected Reference patient;
|
||||
|
||||
/**
|
||||
* The actual object that is the target of the reference (Identifies the patient/subject whose intended care is described by the plan.)
|
||||
*/
|
||||
protected Patient patientTarget;
|
||||
|
||||
/**
|
||||
* Human-readable description of a specific desired objective of the care plan.
|
||||
*/
|
||||
@Child(name="description", type={StringType.class}, order=1, min=1, max=1)
|
||||
@Description(shortDefinition="What's the desired outcome?", formalDefinition="Human-readable description of a specific desired objective of the care plan." )
|
||||
protected StringType description;
|
||||
|
||||
/**
|
||||
* Indicates whether the goal has been reached and is still considered relevant.
|
||||
*/
|
||||
@Child(name="status", type={CodeType.class}, order=2, min=0, max=1)
|
||||
@Description(shortDefinition="in progress | achieved | sustaining | cancelled", formalDefinition="Indicates whether the goal has been reached and is still considered relevant." )
|
||||
protected Enumeration<GoalRequestStatus> status;
|
||||
|
||||
/**
|
||||
* Any comments related to the goal.
|
||||
*/
|
||||
@Child(name="notes", type={StringType.class}, order=3, min=0, max=1)
|
||||
@Description(shortDefinition="Comments about the goal", formalDefinition="Any comments related to the goal." )
|
||||
protected StringType notes;
|
||||
|
||||
/**
|
||||
* The identified conditions that this goal relates to - the condition that caused it to be created, or that it is intended to address.
|
||||
*/
|
||||
@Child(name="concern", type={Condition.class}, order=4, min=0, max=Child.MAX_UNLIMITED)
|
||||
@Description(shortDefinition="Health issues this goal addresses", formalDefinition="The identified conditions that this goal relates to - the condition that caused it to be created, or that it is intended to address." )
|
||||
protected List<Reference> concern;
|
||||
/**
|
||||
* The actual objects that are the target of the reference (The identified conditions that this goal relates to - the condition that caused it to be created, or that it is intended to address.)
|
||||
*/
|
||||
protected List<Condition> concernTarget;
|
||||
|
||||
|
||||
/**
|
||||
* The status of the order.
|
||||
*/
|
||||
@Child(name="mode", type={CodeType.class}, order=5, min=0, max=1)
|
||||
@Description(shortDefinition="planned | proposed | ordered", formalDefinition="The status of the order." )
|
||||
protected Enumeration<GoalRequestMode> mode;
|
||||
|
||||
private static final long serialVersionUID = 1698507147L;
|
||||
|
||||
public GoalRequest() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GoalRequest(StringType description) {
|
||||
super();
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #identifier} (This records identifiers associated with this care plan that are defined by business processed and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).)
|
||||
*/
|
||||
public List<Identifier> getIdentifier() {
|
||||
if (this.identifier == null)
|
||||
this.identifier = new ArrayList<Identifier>();
|
||||
return this.identifier;
|
||||
}
|
||||
|
||||
public boolean hasIdentifier() {
|
||||
if (this.identifier == null)
|
||||
return false;
|
||||
for (Identifier item : this.identifier)
|
||||
if (!item.isEmpty())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #identifier} (This records identifiers associated with this care plan that are defined by business processed and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).)
|
||||
*/
|
||||
// syntactic sugar
|
||||
public Identifier addIdentifier() { //3
|
||||
Identifier t = new Identifier();
|
||||
if (this.identifier == null)
|
||||
this.identifier = new ArrayList<Identifier>();
|
||||
this.identifier.add(t);
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #patient} (Identifies the patient/subject whose intended care is described by the plan.)
|
||||
*/
|
||||
public Reference getPatient() {
|
||||
if (this.patient == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create GoalRequest.patient");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.patient = new Reference();
|
||||
return this.patient;
|
||||
}
|
||||
|
||||
public boolean hasPatient() {
|
||||
return this.patient != null && !this.patient.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #patient} (Identifies the patient/subject whose intended care is described by the plan.)
|
||||
*/
|
||||
public GoalRequest setPatient(Reference value) {
|
||||
this.patient = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Identifies the patient/subject whose intended care is described by the plan.)
|
||||
*/
|
||||
public Patient getPatientTarget() {
|
||||
if (this.patientTarget == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create GoalRequest.patient");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.patientTarget = new Patient();
|
||||
return this.patientTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #patient} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (Identifies the patient/subject whose intended care is described by the plan.)
|
||||
*/
|
||||
public GoalRequest setPatientTarget(Patient value) {
|
||||
this.patientTarget = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #description} (Human-readable description of a specific desired objective of the care plan.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
|
||||
*/
|
||||
public StringType getDescriptionElement() {
|
||||
if (this.description == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create GoalRequest.description");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.description = new StringType();
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public boolean hasDescriptionElement() {
|
||||
return this.description != null && !this.description.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasDescription() {
|
||||
return this.description != null && !this.description.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #description} (Human-readable description of a specific desired objective of the care plan.). This is the underlying object with id, value and extensions. The accessor "getDescription" gives direct access to the value
|
||||
*/
|
||||
public GoalRequest setDescriptionElement(StringType value) {
|
||||
this.description = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Human-readable description of a specific desired objective of the care plan.
|
||||
*/
|
||||
public String getDescription() {
|
||||
return this.description == null ? null : this.description.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value Human-readable description of a specific desired objective of the care plan.
|
||||
*/
|
||||
public GoalRequest setDescription(String value) {
|
||||
if (this.description == null)
|
||||
this.description = new StringType();
|
||||
this.description.setValue(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #status} (Indicates whether the goal has been reached and is still considered relevant.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
|
||||
*/
|
||||
public Enumeration<GoalRequestStatus> getStatusElement() {
|
||||
if (this.status == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create GoalRequest.status");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.status = new Enumeration<GoalRequestStatus>();
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public boolean hasStatusElement() {
|
||||
return this.status != null && !this.status.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasStatus() {
|
||||
return this.status != null && !this.status.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #status} (Indicates whether the goal has been reached and is still considered relevant.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
|
||||
*/
|
||||
public GoalRequest setStatusElement(Enumeration<GoalRequestStatus> value) {
|
||||
this.status = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Indicates whether the goal has been reached and is still considered relevant.
|
||||
*/
|
||||
public GoalRequestStatus getStatus() {
|
||||
return this.status == null ? null : this.status.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value Indicates whether the goal has been reached and is still considered relevant.
|
||||
*/
|
||||
public GoalRequest setStatus(GoalRequestStatus value) {
|
||||
if (value == null)
|
||||
this.status = null;
|
||||
else {
|
||||
if (this.status == null)
|
||||
this.status = new Enumeration<GoalRequestStatus>(GoalRequestStatus.ENUM_FACTORY);
|
||||
this.status.setValue(value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #notes} (Any comments related to the goal.). This is the underlying object with id, value and extensions. The accessor "getNotes" gives direct access to the value
|
||||
*/
|
||||
public StringType getNotesElement() {
|
||||
if (this.notes == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create GoalRequest.notes");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.notes = new StringType();
|
||||
return this.notes;
|
||||
}
|
||||
|
||||
public boolean hasNotesElement() {
|
||||
return this.notes != null && !this.notes.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasNotes() {
|
||||
return this.notes != null && !this.notes.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #notes} (Any comments related to the goal.). This is the underlying object with id, value and extensions. The accessor "getNotes" gives direct access to the value
|
||||
*/
|
||||
public GoalRequest setNotesElement(StringType value) {
|
||||
this.notes = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Any comments related to the goal.
|
||||
*/
|
||||
public String getNotes() {
|
||||
return this.notes == null ? null : this.notes.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value Any comments related to the goal.
|
||||
*/
|
||||
public GoalRequest setNotes(String value) {
|
||||
if (Utilities.noString(value))
|
||||
this.notes = null;
|
||||
else {
|
||||
if (this.notes == null)
|
||||
this.notes = new StringType();
|
||||
this.notes.setValue(value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #concern} (The identified conditions that this goal relates to - the condition that caused it to be created, or that it is intended to address.)
|
||||
*/
|
||||
public List<Reference> getConcern() {
|
||||
if (this.concern == null)
|
||||
this.concern = new ArrayList<Reference>();
|
||||
return this.concern;
|
||||
}
|
||||
|
||||
public boolean hasConcern() {
|
||||
if (this.concern == null)
|
||||
return false;
|
||||
for (Reference item : this.concern)
|
||||
if (!item.isEmpty())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #concern} (The identified conditions that this goal relates to - the condition that caused it to be created, or that it is intended to address.)
|
||||
*/
|
||||
// syntactic sugar
|
||||
public Reference addConcern() { //3
|
||||
Reference t = new Reference();
|
||||
if (this.concern == null)
|
||||
this.concern = new ArrayList<Reference>();
|
||||
this.concern.add(t);
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #concern} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. The identified conditions that this goal relates to - the condition that caused it to be created, or that it is intended to address.)
|
||||
*/
|
||||
public List<Condition> getConcernTarget() {
|
||||
if (this.concernTarget == null)
|
||||
this.concernTarget = new ArrayList<Condition>();
|
||||
return this.concernTarget;
|
||||
}
|
||||
|
||||
// syntactic sugar
|
||||
/**
|
||||
* @return {@link #concern} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. The identified conditions that this goal relates to - the condition that caused it to be created, or that it is intended to address.)
|
||||
*/
|
||||
public Condition addConcernTarget() {
|
||||
Condition r = new Condition();
|
||||
if (this.concernTarget == null)
|
||||
this.concernTarget = new ArrayList<Condition>();
|
||||
this.concernTarget.add(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #mode} (The status of the order.). This is the underlying object with id, value and extensions. The accessor "getMode" gives direct access to the value
|
||||
*/
|
||||
public Enumeration<GoalRequestMode> getModeElement() {
|
||||
if (this.mode == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create GoalRequest.mode");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.mode = new Enumeration<GoalRequestMode>();
|
||||
return this.mode;
|
||||
}
|
||||
|
||||
public boolean hasModeElement() {
|
||||
return this.mode != null && !this.mode.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasMode() {
|
||||
return this.mode != null && !this.mode.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #mode} (The status of the order.). This is the underlying object with id, value and extensions. The accessor "getMode" gives direct access to the value
|
||||
*/
|
||||
public GoalRequest setModeElement(Enumeration<GoalRequestMode> value) {
|
||||
this.mode = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The status of the order.
|
||||
*/
|
||||
public GoalRequestMode getMode() {
|
||||
return this.mode == null ? null : this.mode.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value The status of the order.
|
||||
*/
|
||||
public GoalRequest setMode(GoalRequestMode value) {
|
||||
if (value == null)
|
||||
this.mode = null;
|
||||
else {
|
||||
if (this.mode == null)
|
||||
this.mode = new Enumeration<GoalRequestMode>(GoalRequestMode.ENUM_FACTORY);
|
||||
this.mode.setValue(value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void listChildren(List<Property> childrenList) {
|
||||
super.listChildren(childrenList);
|
||||
childrenList.add(new Property("identifier", "Identifier", "This records identifiers associated with this care plan that are defined by business processed and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).", 0, java.lang.Integer.MAX_VALUE, identifier));
|
||||
childrenList.add(new Property("patient", "Reference(Patient)", "Identifies the patient/subject whose intended care is described by the plan.", 0, java.lang.Integer.MAX_VALUE, patient));
|
||||
childrenList.add(new Property("description", "string", "Human-readable description of a specific desired objective of the care plan.", 0, java.lang.Integer.MAX_VALUE, description));
|
||||
childrenList.add(new Property("status", "code", "Indicates whether the goal has been reached and is still considered relevant.", 0, java.lang.Integer.MAX_VALUE, status));
|
||||
childrenList.add(new Property("notes", "string", "Any comments related to the goal.", 0, java.lang.Integer.MAX_VALUE, notes));
|
||||
childrenList.add(new Property("concern", "Reference(Condition)", "The identified conditions that this goal relates to - the condition that caused it to be created, or that it is intended to address.", 0, java.lang.Integer.MAX_VALUE, concern));
|
||||
childrenList.add(new Property("mode", "code", "The status of the order.", 0, java.lang.Integer.MAX_VALUE, mode));
|
||||
}
|
||||
|
||||
public GoalRequest copy() {
|
||||
GoalRequest dst = new GoalRequest();
|
||||
copyValues(dst);
|
||||
if (identifier != null) {
|
||||
dst.identifier = new ArrayList<Identifier>();
|
||||
for (Identifier i : identifier)
|
||||
dst.identifier.add(i.copy());
|
||||
};
|
||||
dst.patient = patient == null ? null : patient.copy();
|
||||
dst.description = description == null ? null : description.copy();
|
||||
dst.status = status == null ? null : status.copy();
|
||||
dst.notes = notes == null ? null : notes.copy();
|
||||
if (concern != null) {
|
||||
dst.concern = new ArrayList<Reference>();
|
||||
for (Reference i : concern)
|
||||
dst.concern.add(i.copy());
|
||||
};
|
||||
dst.mode = mode == null ? null : mode.copy();
|
||||
return dst;
|
||||
}
|
||||
|
||||
protected GoalRequest typedCopy() {
|
||||
return copy();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (patient == null || patient.isEmpty())
|
||||
&& (description == null || description.isEmpty()) && (status == null || status.isEmpty())
|
||||
&& (notes == null || notes.isEmpty()) && (concern == null || concern.isEmpty()) && (mode == null || mode.isEmpty())
|
||||
;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceType getResourceType() {
|
||||
return ResourceType.GoalRequest;
|
||||
}
|
||||
|
||||
@SearchParamDefinition(name="patient", path="GoalRequest.patient", description="The patient for whom this goal is intended for", type="reference" )
|
||||
public static final String SP_PATIENT = "patient";
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package org.hl7.fhir.instance.model;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
|
@ -20,6 +22,6 @@ package org.hl7.fhir.instance.model;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
public interface ICompositeType extends IBase {
|
||||
public interface ICompositeType extends IBaseDatatype {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.hl7.fhir.instance.model;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
|
@ -21,7 +23,7 @@ package org.hl7.fhir.instance.model;
|
|||
*/
|
||||
|
||||
|
||||
public interface IPrimitiveType<T> extends IBase {
|
||||
public interface IPrimitiveType<T> extends IBaseDatatype {
|
||||
|
||||
void setValueAsString(String theValue) throws IllegalArgumentException;
|
||||
|
||||
|
|
|
@ -1,594 +0,0 @@
|
|||
package org.hl7.fhir.instance.model;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2015 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
// Generated on Fri, Dec 5, 2014 09:17+1100 for FHIR v0.3.0
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.instance.model.annotations.Block;
|
||||
import org.hl7.fhir.instance.model.annotations.Child;
|
||||
import org.hl7.fhir.instance.model.annotations.Description;
|
||||
import org.hl7.fhir.instance.model.annotations.ResourceDef;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
/**
|
||||
* Base Resource for everything.
|
||||
*/
|
||||
@ResourceDef(name="Resource", profile="http://hl7.org/fhir/Profile/Resource")
|
||||
public abstract class Resource extends Base implements IBaseResource {
|
||||
|
||||
@Block()
|
||||
public static class ResourceMetaComponent extends BackboneElement {
|
||||
/**
|
||||
* The version specific identifier, as it appears in the version portion of the url. This values changes when the resource is created, updated, or deleted.
|
||||
*/
|
||||
@Child(name="versionId", type={IdType.class}, order=1, min=0, max=1)
|
||||
@Description(shortDefinition="Version specific identifier", formalDefinition="The version specific identifier, as it appears in the version portion of the url. This values changes when the resource is created, updated, or deleted." )
|
||||
protected IdType versionId;
|
||||
|
||||
/**
|
||||
* When the resource last changed - e.g. when the version changed.
|
||||
*/
|
||||
@Child(name="lastUpdated", type={InstantType.class}, order=2, min=0, max=1)
|
||||
@Description(shortDefinition="When the resource version last changed", formalDefinition="When the resource last changed - e.g. when the version changed." )
|
||||
protected InstantType lastUpdated;
|
||||
|
||||
/**
|
||||
* A list of profiles that this resource claims to conform to. The URL is a reference to Profile.url.
|
||||
*/
|
||||
@Child(name="profile", type={UriType.class}, order=3, min=0, max=Child.MAX_UNLIMITED)
|
||||
@Description(shortDefinition="Profiles this resource claims to conform to", formalDefinition="A list of profiles that this resource claims to conform to. The URL is a reference to Profile.url." )
|
||||
protected List<UriType> profile;
|
||||
|
||||
/**
|
||||
* Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure.
|
||||
*/
|
||||
@Child(name="security", type={Coding.class}, order=4, min=0, max=Child.MAX_UNLIMITED)
|
||||
@Description(shortDefinition="Security Labels applied to this resource", formalDefinition="Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure." )
|
||||
protected List<Coding> security;
|
||||
|
||||
/**
|
||||
* Tags applied to this resource. Tags are intended to to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource.
|
||||
*/
|
||||
@Child(name="tag", type={Coding.class}, order=5, min=0, max=Child.MAX_UNLIMITED)
|
||||
@Description(shortDefinition="Tags applied", formalDefinition="Tags applied to this resource. Tags are intended to to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource." )
|
||||
protected List<Coding> tag;
|
||||
|
||||
private static final long serialVersionUID = 650918851L;
|
||||
|
||||
public ResourceMetaComponent() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #versionId} (The version specific identifier, as it appears in the version portion of the url. This values changes when the resource is created, updated, or deleted.). This is the underlying object with id, value and extensions. The accessor "getVersionId" gives direct access to the value
|
||||
*/
|
||||
public IdType getVersionIdElement() {
|
||||
if (this.versionId == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create ResourceMetaComponent.versionId");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.versionId = new IdType();
|
||||
return this.versionId;
|
||||
}
|
||||
|
||||
public boolean hasVersionIdElement() {
|
||||
return this.versionId != null && !this.versionId.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasVersionId() {
|
||||
return this.versionId != null && !this.versionId.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #versionId} (The version specific identifier, as it appears in the version portion of the url. This values changes when the resource is created, updated, or deleted.). This is the underlying object with id, value and extensions. The accessor "getVersionId" gives direct access to the value
|
||||
*/
|
||||
public ResourceMetaComponent setVersionIdElement(IdType value) {
|
||||
this.versionId = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The version specific identifier, as it appears in the version portion of the url. This values changes when the resource is created, updated, or deleted.
|
||||
*/
|
||||
public String getVersionId() {
|
||||
return this.versionId == null ? null : this.versionId.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value The version specific identifier, as it appears in the version portion of the url. This values changes when the resource is created, updated, or deleted.
|
||||
*/
|
||||
public ResourceMetaComponent setVersionId(String value) {
|
||||
if (Utilities.noString(value))
|
||||
this.versionId = null;
|
||||
else {
|
||||
if (this.versionId == null)
|
||||
this.versionId = new IdType();
|
||||
this.versionId.setValue(value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #lastUpdated} (When the resource last changed - e.g. when the version changed.). This is the underlying object with id, value and extensions. The accessor "getLastUpdated" gives direct access to the value
|
||||
*/
|
||||
public InstantType getLastUpdatedElement() {
|
||||
if (this.lastUpdated == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create ResourceMetaComponent.lastUpdated");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.lastUpdated = new InstantType();
|
||||
return this.lastUpdated;
|
||||
}
|
||||
|
||||
public boolean hasLastUpdatedElement() {
|
||||
return this.lastUpdated != null && !this.lastUpdated.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasLastUpdated() {
|
||||
return this.lastUpdated != null && !this.lastUpdated.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #lastUpdated} (When the resource last changed - e.g. when the version changed.). This is the underlying object with id, value and extensions. The accessor "getLastUpdated" gives direct access to the value
|
||||
*/
|
||||
public ResourceMetaComponent setLastUpdatedElement(InstantType value) {
|
||||
this.lastUpdated = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return When the resource last changed - e.g. when the version changed.
|
||||
*/
|
||||
public Date getLastUpdated() {
|
||||
return this.lastUpdated == null ? null : this.lastUpdated.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value When the resource last changed - e.g. when the version changed.
|
||||
*/
|
||||
public ResourceMetaComponent setLastUpdated(Date value) {
|
||||
if (value == null)
|
||||
this.lastUpdated = null;
|
||||
else {
|
||||
if (this.lastUpdated == null)
|
||||
this.lastUpdated = new InstantType();
|
||||
this.lastUpdated.setValue(value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #profile} (A list of profiles that this resource claims to conform to. The URL is a reference to Profile.url.)
|
||||
*/
|
||||
public List<UriType> getProfile() {
|
||||
if (this.profile == null)
|
||||
this.profile = new ArrayList<UriType>();
|
||||
return this.profile;
|
||||
}
|
||||
|
||||
public boolean hasProfile() {
|
||||
if (this.profile == null)
|
||||
return false;
|
||||
for (UriType item : this.profile)
|
||||
if (!item.isEmpty())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #profile} (A list of profiles that this resource claims to conform to. The URL is a reference to Profile.url.)
|
||||
*/
|
||||
// syntactic sugar
|
||||
public UriType addProfileElement() {//2
|
||||
UriType t = new UriType();
|
||||
if (this.profile == null)
|
||||
this.profile = new ArrayList<UriType>();
|
||||
this.profile.add(t);
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #profile} (A list of profiles that this resource claims to conform to. The URL is a reference to Profile.url.)
|
||||
*/
|
||||
public ResourceMetaComponent addProfile(String value) { //1
|
||||
UriType t = new UriType();
|
||||
t.setValue(value);
|
||||
if (this.profile == null)
|
||||
this.profile = new ArrayList<UriType>();
|
||||
this.profile.add(t);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #profile} (A list of profiles that this resource claims to conform to. The URL is a reference to Profile.url.)
|
||||
*/
|
||||
public boolean hasProfile(String value) {
|
||||
if (this.profile == null)
|
||||
return false;
|
||||
for (UriType v : this.profile)
|
||||
if (v.equals(value)) // uri
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #security} (Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure.)
|
||||
*/
|
||||
public List<Coding> getSecurity() {
|
||||
if (this.security == null)
|
||||
this.security = new ArrayList<Coding>();
|
||||
return this.security;
|
||||
}
|
||||
|
||||
public boolean hasSecurity() {
|
||||
if (this.security == null)
|
||||
return false;
|
||||
for (Coding item : this.security)
|
||||
if (!item.isEmpty())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #security} (Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure.)
|
||||
*/
|
||||
// syntactic sugar
|
||||
public Coding addSecurity() { //3
|
||||
Coding t = new Coding();
|
||||
if (this.security == null)
|
||||
this.security = new ArrayList<Coding>();
|
||||
this.security.add(t);
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #tag} (Tags applied to this resource. Tags are intended to to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource.)
|
||||
*/
|
||||
public List<Coding> getTag() {
|
||||
if (this.tag == null)
|
||||
this.tag = new ArrayList<Coding>();
|
||||
return this.tag;
|
||||
}
|
||||
|
||||
public boolean hasTag() {
|
||||
if (this.tag == null)
|
||||
return false;
|
||||
for (Coding item : this.tag)
|
||||
if (!item.isEmpty())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #tag} (Tags applied to this resource. Tags are intended to to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource.)
|
||||
*/
|
||||
// syntactic sugar
|
||||
public Coding addTag() { //3
|
||||
Coding t = new Coding();
|
||||
if (this.tag == null)
|
||||
this.tag = new ArrayList<Coding>();
|
||||
this.tag.add(t);
|
||||
return t;
|
||||
}
|
||||
|
||||
protected void listChildren(List<Property> childrenList) {
|
||||
super.listChildren(childrenList);
|
||||
childrenList.add(new Property("versionId", "id", "The version specific identifier, as it appears in the version portion of the url. This values changes when the resource is created, updated, or deleted.", 0, java.lang.Integer.MAX_VALUE, versionId));
|
||||
childrenList.add(new Property("lastUpdated", "instant", "When the resource last changed - e.g. when the version changed.", 0, java.lang.Integer.MAX_VALUE, lastUpdated));
|
||||
childrenList.add(new Property("profile", "uri", "A list of profiles that this resource claims to conform to. The URL is a reference to Profile.url.", 0, java.lang.Integer.MAX_VALUE, profile));
|
||||
childrenList.add(new Property("security", "Coding", "Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure.", 0, java.lang.Integer.MAX_VALUE, security));
|
||||
childrenList.add(new Property("tag", "Coding", "Tags applied to this resource. Tags are intended to to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource.", 0, java.lang.Integer.MAX_VALUE, tag));
|
||||
}
|
||||
|
||||
public ResourceMetaComponent copy() {
|
||||
ResourceMetaComponent dst = new ResourceMetaComponent();
|
||||
copyValues(dst);
|
||||
dst.versionId = versionId == null ? null : versionId.copy();
|
||||
dst.lastUpdated = lastUpdated == null ? null : lastUpdated.copy();
|
||||
if (profile != null) {
|
||||
dst.profile = new ArrayList<UriType>();
|
||||
for (UriType i : profile)
|
||||
dst.profile.add(i.copy());
|
||||
};
|
||||
if (security != null) {
|
||||
dst.security = new ArrayList<Coding>();
|
||||
for (Coding i : security)
|
||||
dst.security.add(i.copy());
|
||||
};
|
||||
if (tag != null) {
|
||||
dst.tag = new ArrayList<Coding>();
|
||||
for (Coding i : tag)
|
||||
dst.tag.add(i.copy());
|
||||
};
|
||||
return dst;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return super.isEmpty() && (versionId == null || versionId.isEmpty()) && (lastUpdated == null || lastUpdated.isEmpty())
|
||||
&& (profile == null || profile.isEmpty()) && (security == null || security.isEmpty()) && (tag == null || tag.isEmpty())
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The logical id of the resource, as used in the url for the resoure. Once assigned, this value never changes.
|
||||
*/
|
||||
@Child(name="id", type={IdType.class}, order=-1, min=0, max=1)
|
||||
@Description(shortDefinition="Logical id of this artefact", formalDefinition="The logical id of the resource, as used in the url for the resoure. Once assigned, this value never changes." )
|
||||
protected IdType id;
|
||||
|
||||
/**
|
||||
* The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource.
|
||||
*/
|
||||
@Child(name="meta", type={}, order=0, min=0, max=1)
|
||||
@Description(shortDefinition="Metadata about the resource", formalDefinition="The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource." )
|
||||
protected ResourceMetaComponent meta;
|
||||
|
||||
/**
|
||||
* A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content.
|
||||
*/
|
||||
@Child(name="implicitRules", type={UriType.class}, order=1, min=0, max=1)
|
||||
@Description(shortDefinition="A set of rules under which this content was created", formalDefinition="A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content." )
|
||||
protected UriType implicitRules;
|
||||
|
||||
/**
|
||||
* The base language in which the resource is written.
|
||||
*/
|
||||
@Child(name="language", type={CodeType.class}, order=2, min=0, max=1)
|
||||
@Description(shortDefinition="Language of the resource content", formalDefinition="The base language in which the resource is written." )
|
||||
protected CodeType language;
|
||||
|
||||
private static final long serialVersionUID = -519506254L;
|
||||
|
||||
public Resource() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #id} (The logical id of the resource, as used in the url for the resoure. Once assigned, this value never changes.). This is the underlying object with id, value and extensions. The accessor "getId" gives direct access to the value
|
||||
*/
|
||||
public IdType getIdElement() {
|
||||
if (this.id == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create Resource.id");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.id = new IdType();
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public boolean hasIdElement() {
|
||||
return this.id != null && !this.id.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasId() {
|
||||
return this.id != null && !this.id.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #id} (The logical id of the resource, as used in the url for the resoure. Once assigned, this value never changes.). This is the underlying object with id, value and extensions. The accessor "getId" gives direct access to the value
|
||||
*/
|
||||
public Resource setIdElement(IdType value) {
|
||||
this.id = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The logical id of the resource, as used in the url for the resoure. Once assigned, this value never changes.
|
||||
*/
|
||||
public String getId() {
|
||||
return this.id == null ? null : this.id.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value The logical id of the resource, as used in the url for the resoure. Once assigned, this value never changes.
|
||||
*/
|
||||
public Resource setId(String value) {
|
||||
if (Utilities.noString(value))
|
||||
this.id = null;
|
||||
else {
|
||||
if (this.id == null)
|
||||
this.id = new IdType();
|
||||
this.id.setValue(value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #meta} (The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource.)
|
||||
*/
|
||||
public ResourceMetaComponent getMeta() {
|
||||
if (this.meta == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create Resource.meta");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.meta = new ResourceMetaComponent();
|
||||
return this.meta;
|
||||
}
|
||||
|
||||
public boolean hasMeta() {
|
||||
return this.meta != null && !this.meta.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #meta} (The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource.)
|
||||
*/
|
||||
public Resource setMeta(ResourceMetaComponent value) {
|
||||
this.meta = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #implicitRules} (A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content.). This is the underlying object with id, value and extensions. The accessor "getImplicitRules" gives direct access to the value
|
||||
*/
|
||||
public UriType getImplicitRulesElement() {
|
||||
if (this.implicitRules == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create Resource.implicitRules");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.implicitRules = new UriType();
|
||||
return this.implicitRules;
|
||||
}
|
||||
|
||||
public boolean hasImplicitRulesElement() {
|
||||
return this.implicitRules != null && !this.implicitRules.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasImplicitRules() {
|
||||
return this.implicitRules != null && !this.implicitRules.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #implicitRules} (A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content.). This is the underlying object with id, value and extensions. The accessor "getImplicitRules" gives direct access to the value
|
||||
*/
|
||||
public Resource setImplicitRulesElement(UriType value) {
|
||||
this.implicitRules = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content.
|
||||
*/
|
||||
public String getImplicitRules() {
|
||||
return this.implicitRules == null ? null : this.implicitRules.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content.
|
||||
*/
|
||||
public Resource setImplicitRules(String value) {
|
||||
if (Utilities.noString(value))
|
||||
this.implicitRules = null;
|
||||
else {
|
||||
if (this.implicitRules == null)
|
||||
this.implicitRules = new UriType();
|
||||
this.implicitRules.setValue(value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #language} (The base language in which the resource is written.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
|
||||
*/
|
||||
public CodeType getLanguageElement() {
|
||||
if (this.language == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create Resource.language");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.language = new CodeType();
|
||||
return this.language;
|
||||
}
|
||||
|
||||
public boolean hasLanguageElement() {
|
||||
return this.language != null && !this.language.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasLanguage() {
|
||||
return this.language != null && !this.language.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #language} (The base language in which the resource is written.). This is the underlying object with id, value and extensions. The accessor "getLanguage" gives direct access to the value
|
||||
*/
|
||||
public Resource setLanguageElement(CodeType value) {
|
||||
this.language = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The base language in which the resource is written.
|
||||
*/
|
||||
public String getLanguage() {
|
||||
return this.language == null ? null : this.language.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value The base language in which the resource is written.
|
||||
*/
|
||||
public Resource setLanguage(String value) {
|
||||
if (Utilities.noString(value))
|
||||
this.language = null;
|
||||
else {
|
||||
if (this.language == null)
|
||||
this.language = new CodeType();
|
||||
this.language.setValue(value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void listChildren(List<Property> childrenList) {
|
||||
childrenList.add(new Property("id", "id", "The logical id of the resource, as used in the url for the resoure. Once assigned, this value never changes.", 0, java.lang.Integer.MAX_VALUE, id));
|
||||
childrenList.add(new Property("meta", "", "The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content may not always be associated with version changes to the resource.", 0, java.lang.Integer.MAX_VALUE, meta));
|
||||
childrenList.add(new Property("implicitRules", "uri", "A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content.", 0, java.lang.Integer.MAX_VALUE, implicitRules));
|
||||
childrenList.add(new Property("language", "code", "The base language in which the resource is written.", 0, java.lang.Integer.MAX_VALUE, language));
|
||||
}
|
||||
|
||||
public abstract Resource copy();
|
||||
|
||||
public void copyValues(Resource dst) {
|
||||
dst.id = id == null ? null : id.copy();
|
||||
dst.meta = meta == null ? null : meta.copy();
|
||||
dst.implicitRules = implicitRules == null ? null : implicitRules.copy();
|
||||
dst.language = language == null ? null : language.copy();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return super.isEmpty() && (id == null || id.isEmpty()) && (meta == null || meta.isEmpty()) && (implicitRules == null || implicitRules.isEmpty())
|
||||
&& (language == null || language.isEmpty());
|
||||
}
|
||||
|
||||
public abstract ResourceType getResourceType();
|
||||
|
||||
}
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
package org.hl7.fhir.instance.model.annotations;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2015 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.hl7.fhir.instance.model.Base;
|
||||
|
||||
|
||||
/**
|
||||
* Field annotation for fields within resource and datatype definitions, indicating
|
||||
* a child of that type.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(value= {ElementType.FIELD})
|
||||
public @interface Child {
|
||||
|
||||
/**
|
||||
* Constant value to supply for {@link #order()} when the order is defined
|
||||
* elsewhere
|
||||
*/
|
||||
int ORDER_UNKNOWN = -1;
|
||||
|
||||
/**
|
||||
* COnstant value to supply for {@link #max()} to indicate '*' (no maximum)
|
||||
*/
|
||||
int MAX_UNLIMITED = -1;
|
||||
|
||||
/**
|
||||
* The name of this field, as it will appear in serialized versions of the message
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* The order in which this field comes within its parent. The first field should have a
|
||||
* value of 0, the second a value of 1, etc.
|
||||
*/
|
||||
int order() default ORDER_UNKNOWN;
|
||||
|
||||
/**
|
||||
* The minimum number of repetitions allowed for this child
|
||||
*/
|
||||
int min() default 0;
|
||||
|
||||
/**
|
||||
* The maximum number of repetitions allowed for this child. Should be
|
||||
* set to {@link #MAX_UNLIMITED} if there is no limit to the number of
|
||||
* repetitions.
|
||||
*/
|
||||
int max() default 1;
|
||||
|
||||
/**
|
||||
* Lists the allowable types for this field, if the field supports multiple
|
||||
* types (otherwise does not need to be populated).
|
||||
* <p>
|
||||
* For example, if this field supports either DateTimeDt or BooleanDt types,
|
||||
* those two classes should be supplied here.
|
||||
* </p>
|
||||
*/
|
||||
Class<? extends Base>[] type() default {};
|
||||
|
||||
// Not implemented
|
||||
// /**
|
||||
// * This value is used when extending a built-in model class and defining a
|
||||
// * field to replace a field within the built-in class. For example, the {@link Patient}
|
||||
// * resource has a {@link Patient#getName() name} field, but if you wanted to extend Patient and
|
||||
// * provide your own implementation of {@link HumanNameDt} (most likely your own subclass of
|
||||
// * HumanNameDt which adds extensions of your choosing) you could do that using a replacement field.
|
||||
// */
|
||||
// String replaces() default "";
|
||||
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package org.hl7.fhir.instance.model.annotations;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2015 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Class annotation to note a class which defines a datatype
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(value= {ElementType.TYPE})
|
||||
public @interface DatatypeDef {
|
||||
|
||||
/**
|
||||
* The defined name of this datatype
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Set this to true (default is false) for any types that are
|
||||
* really only a specialization of another type. For example,
|
||||
* <code>BoundCodeDt</code> is really just a specific type of
|
||||
* <code>CodeDt</code> and not a separate datatype, so it should
|
||||
* have this set to true.
|
||||
*/
|
||||
boolean isSpecialization() default false;
|
||||
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package org.hl7.fhir.instance.model.annotations;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2015 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Annotation which may be placed on a resource/datatype definition, or a field, or
|
||||
* a search parameter definition in order to provide documentation for that item.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(value= {ElementType.FIELD, ElementType.TYPE, ElementType.PARAMETER, ElementType.METHOD})
|
||||
public @interface Description {
|
||||
|
||||
/**
|
||||
* Optional short name for this child
|
||||
*/
|
||||
String shortDefinition() default "";
|
||||
|
||||
/**
|
||||
* Optional formal definition for this child
|
||||
*/
|
||||
String formalDefinition() default "";
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package org.hl7.fhir.instance.model.annotations;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2015 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(value=ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface SearchParamDefinition {
|
||||
|
||||
/**
|
||||
* The name for this parameter
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* The path for this parameter
|
||||
*/
|
||||
String path();
|
||||
|
||||
/**
|
||||
* A description of this parameter
|
||||
*/
|
||||
String description() default "";
|
||||
|
||||
/**
|
||||
* The type for this parameter, e.g. "string", or "token"
|
||||
*/
|
||||
String type() default "string";
|
||||
|
||||
/**
|
||||
* If the parameter is of type "composite", this parameter lists the names of the parameters
|
||||
* which this parameter is a composite of. E.g. "name-value-token" is a composite of "name" and "value-token".
|
||||
* <p>
|
||||
* If the parameter is not a composite, this parameter must be empty
|
||||
* </p>
|
||||
*/
|
||||
String[] compositeOf() default {};
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
|
||||
public interface IAnyResource extends IBaseResource {
|
||||
|
||||
String getId();
|
||||
|
||||
IAnyResource setId(String theId);
|
||||
|
||||
IIdType getIdElement();
|
||||
|
||||
IMetaType getMeta();
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
public interface IBackboneElement {
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
|
||||
public interface IBaseBooleanDatatype extends IPrimitiveType<Boolean> {
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
public interface IBaseDatatype extends IBase {
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
|
||||
public interface IBaseDecimalDatatype extends IPrimitiveType<BigDecimal> {
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
public interface IBaseElement {
|
||||
|
||||
IBaseElement setId(String theValue);
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
import org.hl7.fhir.instance.model.ICompositeType;
|
||||
|
||||
public interface IBaseExtension extends ICompositeType {
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
import org.hl7.fhir.instance.model.IPrimitiveType;
|
||||
|
||||
public interface IBaseIntegerDatatype extends IPrimitiveType<Integer> {
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
public interface ICoding {
|
||||
|
||||
ICoding setSystem(String theScheme);
|
||||
|
||||
ICoding setCode(String theTerm);
|
||||
|
||||
ICoding setDisplay(String theLabel);
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
|
||||
public interface IDatatypeElement extends IElement {
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IDomainResource {
|
||||
|
||||
List<? extends IAnyResource> getContained();
|
||||
|
||||
INarrative getText();
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
|
||||
public interface IIdType {
|
||||
|
||||
boolean isEmpty();
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface IMetaType {
|
||||
|
||||
ICoding addTag();
|
||||
|
||||
IMetaType setLastUpdated(Date theHeaderDateValue);
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
import org.hl7.fhir.instance.model.ICompositeType;
|
||||
|
||||
public interface INarrative extends ICompositeType {
|
||||
|
||||
boolean isEmpty();
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBase;
|
||||
|
||||
public interface IReference extends IBase {
|
||||
|
||||
IAnyResource getResource();
|
||||
|
||||
void setResource(IAnyResource theResource);
|
||||
|
||||
String getReference();
|
||||
|
||||
IReference setReference(String theReference);
|
||||
|
||||
IBase setDisplay(String theValue);
|
||||
}
|
|
@ -3,6 +3,4 @@ encoding//src/main/java=UTF-8
|
|||
encoding//src/main/resources=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding//src/test/resources=UTF-8
|
||||
encoding//target/generated-resources/tinder=UTF-8
|
||||
encoding//target/generated-sources/tinder=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
|
|
|
@ -19,7 +19,6 @@ import org.eclipse.jetty.server.Server;
|
|||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hl7.fhir.instance.model.annotations.ResourceDef;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -29,6 +28,7 @@ import ca.uhn.fhir.model.api.IResource;
|
|||
import ca.uhn.fhir.model.api.TagList;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Extension;
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
import ca.uhn.fhir.model.dstu.resource.AdverseReaction;
|
||||
import ca.uhn.fhir.model.dstu.resource.DiagnosticReport;
|
||||
import ca.uhn.fhir.model.dstu.resource.Observation;
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
/bin
|
||||
/target
|
||||
*.log
|
||||
*.log*
|
||||
/.settings/
|
||||
.classpath
|
||||
.project
|
||||
/target/
|
||||
/target/
|
||||
/target/
|
||||
/target/
|
|
@ -1 +0,0 @@
|
|||
/bin/
|
|
@ -1,9 +0,0 @@
|
|||
package ca.uhn.fhir.parser;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
import ca.uhn.fhir.model.dstu.resource.Organization;
|
||||
|
||||
@ResourceDef()
|
||||
public class MyOrganization extends Organization {
|
||||
|
||||
}
|
|
@ -12,6 +12,7 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src/main/resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
@ -22,5 +23,6 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/hapi-fhir-base"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
|
@ -0,0 +1,2 @@
|
|||
/bin
|
||||
/target
|
|
@ -5,20 +5,20 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>0.8-SNAPSHOT</version>
|
||||
<version>0.9-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>hapi-fhir-structures-hl7org-dev</artifactId>
|
||||
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HAPI FHIR Structures - HL7.org DEV (FHIR Latest)</name>
|
||||
<name>HAPI FHIR Structures - HL7.org DSTU2</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
<version>0.8-SNAPSHOT</version>
|
||||
<version>0.9-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -28,6 +28,12 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>xpp3</groupId>
|
||||
<artifactId>xpp3_min</artifactId>
|
||||
<version>1.1.4c</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Testing -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
|
@ -0,0 +1,106 @@
|
|||
package org.hl7.fhir.instance;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR Structures - DSTU2 (FHIR v0.4.0)
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2015 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.conf.ServerConformanceProvider;
|
||||
import org.hl7.fhir.instance.conf.ServerProfileProvider;
|
||||
import org.hl7.fhir.instance.model.Profile;
|
||||
import org.hl7.fhir.instance.model.Reference;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.model.api.IFhirVersion;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.base.composite.BaseContainedDt;
|
||||
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
|
||||
public class FhirDstu2Hl7Org implements IFhirVersion {
|
||||
|
||||
private String myId;
|
||||
|
||||
@Override
|
||||
public ServerConformanceProvider createServerConformanceProvider(RestfulServer theServer) {
|
||||
return new ServerConformanceProvider(theServer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition, String theServerBase) {
|
||||
Profile retVal = new Profile();
|
||||
|
||||
RuntimeResourceDefinition def = theRuntimeResourceDefinition;
|
||||
|
||||
myId = def.getId();
|
||||
if (StringUtils.isBlank(myId)) {
|
||||
myId = theRuntimeResourceDefinition.getName().toLowerCase();
|
||||
}
|
||||
|
||||
retVal.setId(myId);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer) {
|
||||
return new ServerProfileProvider(theRestfulServer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FhirVersionEnum getVersion() {
|
||||
return FhirVersionEnum.DSTU2_HL7ORG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getFhirVersionPropertiesFile() {
|
||||
String path = "/org/hl7/fhir/instance/model/fhirversion.properties";
|
||||
InputStream str = FhirDstu2Hl7Org.class.getResourceAsStream(path);
|
||||
if (str == null) {
|
||||
str = FhirDstu2Hl7Org.class.getResourceAsStream(path.substring(1));
|
||||
}
|
||||
if (str == null) {
|
||||
throw new ConfigurationException("Can not find model property file on classpath: " + path);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPathToSchemaDefinitions() {
|
||||
return "ca/uhn/fhir/model/dstu2/schema";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Reference> getResourceReferenceType() {
|
||||
return Reference.class;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Class<ArrayList> getContainedType() {
|
||||
return ArrayList.class;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,369 @@
|
|||
package org.hl7.fhir.instance.conf;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR Structures - DSTU2 (FHIR v0.4.0)
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2015 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.Conformance;
|
||||
import org.hl7.fhir.instance.model.Conformance.ConformanceRestComponent;
|
||||
import org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceComponent;
|
||||
import org.hl7.fhir.instance.model.Conformance.ConformanceRestResourceSearchParamComponent;
|
||||
import org.hl7.fhir.instance.model.Conformance.ResourceInteractionComponent;
|
||||
import org.hl7.fhir.instance.model.Conformance.RestfulConformanceMode;
|
||||
import org.hl7.fhir.instance.model.Conformance.SystemRestfulInteraction;
|
||||
import org.hl7.fhir.instance.model.Conformance.TypeRestfulInteraction;
|
||||
import org.hl7.fhir.instance.model.DateTimeType;
|
||||
import org.hl7.fhir.instance.model.ResourceType;
|
||||
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.annotation.Metadata;
|
||||
import ca.uhn.fhir.rest.method.BaseMethodBinding;
|
||||
import ca.uhn.fhir.rest.method.DynamicSearchMethodBinding;
|
||||
import ca.uhn.fhir.rest.method.IParameter;
|
||||
import ca.uhn.fhir.rest.method.SearchMethodBinding;
|
||||
import ca.uhn.fhir.rest.method.SearchParameter;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.IServerConformanceProvider;
|
||||
import ca.uhn.fhir.rest.server.ResourceBinding;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
|
||||
/**
|
||||
* Server FHIR Provider which serves the conformance statement for a RESTful server implementation
|
||||
*
|
||||
* <p>
|
||||
* Note: This class is safe to extend, but it is important to note that the same instance of {@link Conformance} is always returned unless {@link #setCache(boolean)} is called with a value of
|
||||
* <code>false</code>. This means that if you are adding anything to the returned conformance instance on each call you should call <code>setCache(false)</code> in your provider constructor.
|
||||
* </p>
|
||||
*/
|
||||
public class ServerConformanceProvider implements IServerConformanceProvider<Conformance> {
|
||||
|
||||
private boolean myCache = true;
|
||||
private volatile Conformance myConformance;
|
||||
private String myPublisher = "Not provided";
|
||||
private final RestfulServer myRestfulServer;
|
||||
|
||||
public ServerConformanceProvider(RestfulServer theRestfulServer) {
|
||||
myRestfulServer = theRestfulServer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the "publisher" that will be placed in the generated conformance statement. As this is a mandatory element, the value should not be null (although this is not enforced). The
|
||||
* value defaults to "Not provided" but may be set to null, which will cause this element to be omitted.
|
||||
*/
|
||||
public String getPublisher() {
|
||||
return myPublisher;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Metadata
|
||||
public Conformance getServerConformance(HttpServletRequest theRequest) {
|
||||
if (myConformance != null && myCache) {
|
||||
return myConformance;
|
||||
}
|
||||
|
||||
Conformance retVal = new Conformance();
|
||||
|
||||
retVal.setPublisher(myPublisher);
|
||||
retVal.setDateElement(DateTimeType.now());
|
||||
retVal.setFhirVersion("0.4.0"); // TODO: pull from model
|
||||
retVal.setAcceptUnknown(false); // TODO: make this configurable - this is a fairly big effort since the parser
|
||||
// needs to be modified to actually allow it
|
||||
|
||||
retVal.getImplementation().setDescription(myRestfulServer.getImplementationDescription());
|
||||
retVal.getSoftware().setName(myRestfulServer.getServerName());
|
||||
retVal.getSoftware().setVersion(myRestfulServer.getServerVersion());
|
||||
retVal.addFormat(Constants.CT_FHIR_XML);
|
||||
retVal.addFormat(Constants.CT_FHIR_JSON);
|
||||
|
||||
ConformanceRestComponent rest = retVal.addRest();
|
||||
rest.setMode(RestfulConformanceMode.SERVER);
|
||||
|
||||
Set<SystemRestfulInteraction> systemOps = new HashSet<SystemRestfulInteraction>();
|
||||
|
||||
List<ResourceBinding> bindings = new ArrayList<ResourceBinding>(myRestfulServer.getResourceBindings());
|
||||
Collections.sort(bindings, new Comparator<ResourceBinding>() {
|
||||
@Override
|
||||
public int compare(ResourceBinding theArg0, ResourceBinding theArg1) {
|
||||
return theArg0.getResourceName().compareToIgnoreCase(theArg1.getResourceName());
|
||||
}
|
||||
});
|
||||
|
||||
for (ResourceBinding next : bindings) {
|
||||
|
||||
Set<TypeRestfulInteraction> resourceOps = new HashSet<TypeRestfulInteraction>();
|
||||
ConformanceRestResourceComponent resource = rest.addResource();
|
||||
|
||||
String resourceName = next.getResourceName();
|
||||
RuntimeResourceDefinition def = myRestfulServer.getFhirContext().getResourceDefinition(resourceName);
|
||||
resource.getTypeElement().setValue(def.getName());
|
||||
resource.getProfile().setReference(def.getResourceProfile(myRestfulServer.getServerBaseForRequest(theRequest)));
|
||||
|
||||
TreeSet<String> includes = new TreeSet<String>();
|
||||
|
||||
// Map<String, Conformance.RestResourceSearchParam> nameToSearchParam = new HashMap<String,
|
||||
// Conformance.RestResourceSearchParam>();
|
||||
for (BaseMethodBinding<?> nextMethodBinding : next.getMethodBindings()) {
|
||||
if (nextMethodBinding.getResourceOperationType() != null) {
|
||||
String resOpCode = nextMethodBinding.getResourceOperationType().getCode();
|
||||
if (resOpCode != null) {
|
||||
TypeRestfulInteraction resOp;
|
||||
try {
|
||||
resOp = TypeRestfulInteraction.fromCode(resOpCode);
|
||||
} catch (Exception e) {
|
||||
resOp = null;
|
||||
}
|
||||
if (resOp == null) {
|
||||
throw new InternalErrorException("Unknown type-restful-interaction: " + resOpCode);
|
||||
}
|
||||
if (resourceOps.contains(resOp) == false) {
|
||||
resourceOps.add(resOp);
|
||||
resource.addInteraction().setCode(resOp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nextMethodBinding.getSystemOperationType() != null) {
|
||||
String sysOpCode = nextMethodBinding.getSystemOperationType().getCode();
|
||||
if (sysOpCode != null) {
|
||||
SystemRestfulInteraction sysOp;
|
||||
try {
|
||||
sysOp = SystemRestfulInteraction.fromCode(sysOpCode);
|
||||
} catch (Exception e) {
|
||||
sysOp = null;
|
||||
}
|
||||
if (sysOp == null) {
|
||||
throw new InternalErrorException("Unknown system-restful-interaction: " + sysOpCode);
|
||||
}
|
||||
if (systemOps.contains(sysOp) == false) {
|
||||
systemOps.add(sysOp);
|
||||
rest.addInteraction().setCode(sysOp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nextMethodBinding instanceof SearchMethodBinding) {
|
||||
handleSearchMethodBinding(rest, resource, resourceName, def, includes, (SearchMethodBinding) nextMethodBinding);
|
||||
} else if (nextMethodBinding instanceof DynamicSearchMethodBinding) {
|
||||
handleDynamicSearchMethodBinding(resource, def, includes, (DynamicSearchMethodBinding) nextMethodBinding);
|
||||
}
|
||||
|
||||
Collections.sort(resource.getInteraction(), new Comparator<ResourceInteractionComponent>() {
|
||||
@Override
|
||||
public int compare(ResourceInteractionComponent theO1, ResourceInteractionComponent theO2) {
|
||||
TypeRestfulInteraction o1 = theO1.getCodeElement().getValue();
|
||||
TypeRestfulInteraction o2 = theO2.getCodeElement().getValue();
|
||||
if (o1 == null && o2 == null) {
|
||||
return 0;
|
||||
}
|
||||
if (o1 == null) {
|
||||
return 1;
|
||||
}
|
||||
if (o2 == null) {
|
||||
return -1;
|
||||
}
|
||||
return o1.ordinal() - o2.ordinal();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
for (String nextInclude : includes) {
|
||||
resource.addSearchInclude(nextInclude);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
myConformance = retVal;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private void handleDynamicSearchMethodBinding(ConformanceRestResourceComponent resource, RuntimeResourceDefinition def, TreeSet<String> includes, DynamicSearchMethodBinding searchMethodBinding) {
|
||||
includes.addAll(searchMethodBinding.getIncludes());
|
||||
|
||||
List<RuntimeSearchParam> searchParameters = new ArrayList<RuntimeSearchParam>();
|
||||
searchParameters.addAll(searchMethodBinding.getSearchParams());
|
||||
sortRuntimeSearchParameters(searchParameters);
|
||||
|
||||
if (!searchParameters.isEmpty()) {
|
||||
|
||||
for (RuntimeSearchParam nextParameter : searchParameters) {
|
||||
|
||||
String nextParamName = nextParameter.getName();
|
||||
|
||||
// String chain = null;
|
||||
String nextParamUnchainedName = nextParamName;
|
||||
if (nextParamName.contains(".")) {
|
||||
// chain = nextParamName.substring(nextParamName.indexOf('.') + 1);
|
||||
nextParamUnchainedName = nextParamName.substring(0, nextParamName.indexOf('.'));
|
||||
}
|
||||
|
||||
String nextParamDescription = nextParameter.getDescription();
|
||||
|
||||
/*
|
||||
* If the parameter has no description, default to the one from the resource
|
||||
*/
|
||||
if (StringUtils.isBlank(nextParamDescription)) {
|
||||
RuntimeSearchParam paramDef = def.getSearchParam(nextParamUnchainedName);
|
||||
if (paramDef != null) {
|
||||
nextParamDescription = paramDef.getDescription();
|
||||
}
|
||||
}
|
||||
|
||||
ConformanceRestResourceSearchParamComponent param;
|
||||
param = resource.addSearchParam();
|
||||
|
||||
param.setName(nextParamName);
|
||||
// if (StringUtils.isNotBlank(chain)) {
|
||||
// param.addChain(chain);
|
||||
// }
|
||||
param.setDocumentation(nextParamDescription);
|
||||
// param.setType(nextParameter.getParamType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSearchMethodBinding(ConformanceRestComponent rest, ConformanceRestResourceComponent resource, String resourceName, RuntimeResourceDefinition def, TreeSet<String> includes, SearchMethodBinding searchMethodBinding) {
|
||||
includes.addAll(searchMethodBinding.getIncludes());
|
||||
|
||||
List<IParameter> params = searchMethodBinding.getParameters();
|
||||
List<SearchParameter> searchParameters = new ArrayList<SearchParameter>();
|
||||
for (IParameter nextParameter : params) {
|
||||
if ((nextParameter instanceof SearchParameter)) {
|
||||
searchParameters.add((SearchParameter) nextParameter);
|
||||
}
|
||||
}
|
||||
sortSearchParameters(searchParameters);
|
||||
if (!searchParameters.isEmpty()) {
|
||||
// boolean allOptional = searchParameters.get(0).isRequired() == false;
|
||||
//
|
||||
// OperationDefinition query = null;
|
||||
// if (!allOptional) {
|
||||
// RestOperation operation = rest.addOperation();
|
||||
// query = new OperationDefinition();
|
||||
// operation.setDefinition(new ResourceReferenceDt(query));
|
||||
// query.getDescriptionElement().setValue(searchMethodBinding.getDescription());
|
||||
// query.addUndeclaredExtension(false, ExtensionConstants.QUERY_RETURN_TYPE, new CodeDt(resourceName));
|
||||
// for (String nextInclude : searchMethodBinding.getIncludes()) {
|
||||
// query.addUndeclaredExtension(false, ExtensionConstants.QUERY_ALLOWED_INCLUDE, new StringDt(nextInclude));
|
||||
// }
|
||||
// }
|
||||
|
||||
for (SearchParameter nextParameter : searchParameters) {
|
||||
|
||||
String nextParamName = nextParameter.getName();
|
||||
|
||||
String chain = null;
|
||||
String nextParamUnchainedName = nextParamName;
|
||||
if (nextParamName.contains(".")) {
|
||||
chain = nextParamName.substring(nextParamName.indexOf('.') + 1);
|
||||
nextParamUnchainedName = nextParamName.substring(0, nextParamName.indexOf('.'));
|
||||
}
|
||||
|
||||
String nextParamDescription = nextParameter.getDescription();
|
||||
|
||||
/*
|
||||
* If the parameter has no description, default to the one from the resource
|
||||
*/
|
||||
if (StringUtils.isBlank(nextParamDescription)) {
|
||||
RuntimeSearchParam paramDef = def.getSearchParam(nextParamUnchainedName);
|
||||
if (paramDef != null) {
|
||||
nextParamDescription = paramDef.getDescription();
|
||||
}
|
||||
}
|
||||
|
||||
ConformanceRestResourceSearchParamComponent param = resource.addSearchParam();
|
||||
param.setName(nextParamUnchainedName);
|
||||
if (StringUtils.isNotBlank(chain)) {
|
||||
param.addChain(chain);
|
||||
}
|
||||
param.setDocumentation(nextParamDescription);
|
||||
if (nextParameter.getParamType() != null) {
|
||||
param.getTypeElement().setValueAsString(nextParameter.getParamType().getCode());
|
||||
}
|
||||
for (Class<? extends IResource> nextTarget : nextParameter.getDeclaredTypes()) {
|
||||
RuntimeResourceDefinition targetDef = myRestfulServer.getFhirContext().getResourceDefinition(nextTarget);
|
||||
if (targetDef != null) {
|
||||
ResourceType code = ResourceType.valueOf(targetDef.getName());
|
||||
if (code != null) {
|
||||
param.addTarget(code.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cache property (default is true). If set to true, the same response will be returned for each invocation.
|
||||
* <p>
|
||||
* See the class documentation for an important note if you are extending this class
|
||||
* </p>
|
||||
*/
|
||||
public void setCache(boolean theCache) {
|
||||
myCache = theCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the "publisher" that will be placed in the generated conformance statement. As this is a mandatory element, the value should not be null (although this is not enforced). The
|
||||
* value defaults to "Not provided" but may be set to null, which will cause this element to be omitted.
|
||||
*/
|
||||
public void setPublisher(String thePublisher) {
|
||||
myPublisher = thePublisher;
|
||||
}
|
||||
|
||||
private void sortRuntimeSearchParameters(List<RuntimeSearchParam> searchParameters) {
|
||||
Collections.sort(searchParameters, new Comparator<RuntimeSearchParam>() {
|
||||
@Override
|
||||
public int compare(RuntimeSearchParam theO1, RuntimeSearchParam theO2) {
|
||||
return theO1.getName().compareTo(theO2.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void sortSearchParameters(List<SearchParameter> searchParameters) {
|
||||
Collections.sort(searchParameters, new Comparator<SearchParameter>() {
|
||||
@Override
|
||||
public int compare(SearchParameter theO1, SearchParameter theO2) {
|
||||
if (theO1.isRequired() == theO2.isRequired()) {
|
||||
return theO1.getName().compareTo(theO2.getName());
|
||||
}
|
||||
if (theO1.isRequired()) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package org.hl7.fhir.instance.conf;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR Structures - DSTU2 (FHIR v0.4.0)
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2015 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.hl7.fhir.instance.model.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.Profile;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Read;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
|
||||
public class ServerProfileProvider implements IResourceProvider {
|
||||
|
||||
private final FhirContext myContext;
|
||||
private final RestfulServer myRestfulServer;
|
||||
|
||||
public ServerProfileProvider(RestfulServer theServer) {
|
||||
myContext = theServer.getFhirContext();
|
||||
myRestfulServer = theServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IBaseResource> getResourceType() {
|
||||
return Profile.class;
|
||||
}
|
||||
|
||||
@Read()
|
||||
public Profile getProfileById(HttpServletRequest theRequest, @IdParam IdDt theId) {
|
||||
RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getValue());
|
||||
if (retVal==null) {
|
||||
return null;
|
||||
}
|
||||
String serverBase = getServerBase(theRequest);
|
||||
return (Profile) retVal.toProfile(serverBase);
|
||||
}
|
||||
|
||||
@Search()
|
||||
public List<Profile> getAllProfiles(HttpServletRequest theRequest) {
|
||||
final String serverBase = getServerBase(theRequest);
|
||||
List<RuntimeResourceDefinition> defs = new ArrayList<RuntimeResourceDefinition>(myContext.getResourceDefinitions());
|
||||
Collections.sort(defs, new Comparator<RuntimeResourceDefinition>() {
|
||||
@Override
|
||||
public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) {
|
||||
int cmp = theO1.getName().compareTo(theO2.getName());
|
||||
if (cmp==0) {
|
||||
cmp=theO1.getResourceProfile(serverBase).compareTo(theO2.getResourceProfile(serverBase));
|
||||
}
|
||||
return cmp;
|
||||
}});
|
||||
ArrayList<Profile> retVal = new ArrayList<Profile>();
|
||||
for (RuntimeResourceDefinition next : defs) {
|
||||
retVal.add((Profile) next.toProfile(serverBase));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private String getServerBase(HttpServletRequest theHttpRequest) {
|
||||
return myRestfulServer.getServerBaseForRequest(theHttpRequest);
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -1,87 +1,88 @@
|
|||
package org.hl7.fhir.instance.model;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2015 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
// Generated on Sun, Dec 7, 2014 21:45-0500 for FHIR v0.3.0
|
||||
|
||||
import org.hl7.fhir.instance.model.annotations.DatatypeDef;
|
||||
/**
|
||||
* A measured amount (or an amount that can potentially be measured). Note that measured amounts include amounts that are not precisely quantified, including amounts involving arbitrary units and floating currencies.
|
||||
*/
|
||||
@DatatypeDef(name="Age")
|
||||
public class Age extends Quantity {
|
||||
|
||||
private static final long serialVersionUID = -483422721L;
|
||||
|
||||
public Age copy() {
|
||||
Age dst = new Age();
|
||||
copyValues(dst);
|
||||
dst.value = value == null ? null : value.copy();
|
||||
dst.comparator = comparator == null ? null : comparator.copy();
|
||||
dst.units = units == null ? null : units.copy();
|
||||
dst.system = system == null ? null : system.copy();
|
||||
dst.code = code == null ? null : code.copy();
|
||||
return dst;
|
||||
}
|
||||
|
||||
protected Age typedCopy() {
|
||||
return copy();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return super.isEmpty() && (value == null || value.isEmpty()) && (comparator == null || comparator.isEmpty())
|
||||
&& (units == null || units.isEmpty()) && (system == null || system.isEmpty()) && (code == null || code.isEmpty())
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
package org.hl7.fhir.instance.model;
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
// Generated on Sat, Feb 14, 2015 16:12-0500 for FHIR v0.4.0
|
||||
|
||||
import org.hl7.fhir.instance.model.annotations.DatatypeDef;
|
||||
/**
|
||||
* A measured amount (or an amount that can potentially be measured). Note that measured amounts include amounts that are not precisely quantified, including amounts involving arbitrary units and floating currencies.
|
||||
*/
|
||||
@DatatypeDef(name="Age")
|
||||
public class Age extends Quantity {
|
||||
|
||||
private static final long serialVersionUID = -483422721L;
|
||||
|
||||
public Age copy() {
|
||||
Age dst = new Age();
|
||||
copyValues(dst);
|
||||
dst.value = value == null ? null : value.copy();
|
||||
dst.comparator = comparator == null ? null : comparator.copy();
|
||||
dst.units = units == null ? null : units.copy();
|
||||
dst.system = system == null ? null : system.copy();
|
||||
dst.code = code == null ? null : code.copy();
|
||||
return dst;
|
||||
}
|
||||
|
||||
protected Age typedCopy() {
|
||||
return copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsDeep(Base other) {
|
||||
if (!super.equalsDeep(other))
|
||||
return false;
|
||||
if (!(other instanceof Age))
|
||||
return false;
|
||||
Age o = (Age) other;
|
||||
return compareDeep(value, o.value, true) && compareDeep(comparator, o.comparator, true) && compareDeep(units, o.units, true)
|
||||
&& compareDeep(system, o.system, true) && compareDeep(code, o.code, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsShallow(Base other) {
|
||||
if (!super.equalsShallow(other))
|
||||
return false;
|
||||
if (!(other instanceof Age))
|
||||
return false;
|
||||
Age o = (Age) other;
|
||||
return compareValues(value, o.value, true) && compareValues(comparator, o.comparator, true) && compareValues(units, o.units, true)
|
||||
&& compareValues(system, o.system, true) && compareValues(code, o.code, true);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return super.isEmpty() && (value == null || value.isEmpty()) && (comparator == null || comparator.isEmpty())
|
||||
&& (units == null || units.isEmpty()) && (system == null || system.isEmpty()) && (code == null || code.isEmpty())
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,498 +1,495 @@
|
|||
package org.hl7.fhir.instance.model;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2015 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
// Generated on Sun, Dec 7, 2014 21:45-0500 for FHIR v0.3.0
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.instance.model.annotations.ResourceDef;
|
||||
import org.hl7.fhir.instance.model.annotations.SearchParamDefinition;
|
||||
import org.hl7.fhir.instance.model.annotations.Block;
|
||||
import org.hl7.fhir.instance.model.annotations.Child;
|
||||
import org.hl7.fhir.instance.model.annotations.Description;
|
||||
/**
|
||||
* Prospective warnings of potential issues when providing care to the patient.
|
||||
*/
|
||||
@ResourceDef(name="Alert", profile="http://hl7.org/fhir/Profile/Alert")
|
||||
public class Alert extends DomainResource {
|
||||
|
||||
public enum AlertStatus implements FhirEnum {
|
||||
/**
|
||||
* A current alert that should be displayed to a user. A system may use the category to determine which roles should view the alert.
|
||||
*/
|
||||
ACTIVE,
|
||||
/**
|
||||
* The alert does not need to be displayed any more.
|
||||
*/
|
||||
INACTIVE,
|
||||
/**
|
||||
* The alert was added in error, and should no longer be displayed.
|
||||
*/
|
||||
ENTEREDINERROR,
|
||||
/**
|
||||
* added to help the parsers
|
||||
*/
|
||||
NULL;
|
||||
|
||||
public static final AlertStatusEnumFactory ENUM_FACTORY = new AlertStatusEnumFactory();
|
||||
|
||||
public static AlertStatus fromCode(String codeString) throws IllegalArgumentException {
|
||||
if (codeString == null || "".equals(codeString))
|
||||
return null;
|
||||
if ("active".equals(codeString))
|
||||
return ACTIVE;
|
||||
if ("inactive".equals(codeString))
|
||||
return INACTIVE;
|
||||
if ("entered in error".equals(codeString))
|
||||
return ENTEREDINERROR;
|
||||
throw new IllegalArgumentException("Unknown AlertStatus code '"+codeString+"'");
|
||||
}
|
||||
@Override
|
||||
public String toCode() {
|
||||
switch (this) {
|
||||
case ACTIVE: return "active";
|
||||
case INACTIVE: return "inactive";
|
||||
case ENTEREDINERROR: return "entered in error";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
public String getSystem() {
|
||||
switch (this) {
|
||||
case ACTIVE: return "";
|
||||
case INACTIVE: return "";
|
||||
case ENTEREDINERROR: return "";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
public String getDefinition() {
|
||||
switch (this) {
|
||||
case ACTIVE: return "A current alert that should be displayed to a user. A system may use the category to determine which roles should view the alert.";
|
||||
case INACTIVE: return "The alert does not need to be displayed any more.";
|
||||
case ENTEREDINERROR: return "The alert was added in error, and should no longer be displayed.";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
public String getDisplay() {
|
||||
switch (this) {
|
||||
case ACTIVE: return "active";
|
||||
case INACTIVE: return "inactive";
|
||||
case ENTEREDINERROR: return "entered in error";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class AlertStatusEnumFactory implements EnumFactory<AlertStatus> {
|
||||
public AlertStatus fromCode(String codeString) throws IllegalArgumentException {
|
||||
if (codeString == null || "".equals(codeString))
|
||||
if (codeString == null || "".equals(codeString))
|
||||
return null;
|
||||
if ("active".equals(codeString))
|
||||
return AlertStatus.ACTIVE;
|
||||
if ("inactive".equals(codeString))
|
||||
return AlertStatus.INACTIVE;
|
||||
if ("entered in error".equals(codeString))
|
||||
return AlertStatus.ENTEREDINERROR;
|
||||
throw new IllegalArgumentException("Unknown AlertStatus code '"+codeString+"'");
|
||||
}
|
||||
public String toCode(AlertStatus code) throws IllegalArgumentException {
|
||||
if (code == AlertStatus.ACTIVE)
|
||||
return "active";
|
||||
if (code == AlertStatus.INACTIVE)
|
||||
return "inactive";
|
||||
if (code == AlertStatus.ENTEREDINERROR)
|
||||
return "entered in error";
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier assigned to the alert for external use (outside the FHIR environment).
|
||||
*/
|
||||
@Child(name="identifier", type={Identifier.class}, order=-1, min=0, max=Child.MAX_UNLIMITED)
|
||||
@Description(shortDefinition="Business identifier", formalDefinition="Identifier assigned to the alert for external use (outside the FHIR environment)." )
|
||||
protected List<Identifier> identifier;
|
||||
|
||||
/**
|
||||
* Allows an alert to be divided into different categories like clinical, administrative etc.
|
||||
*/
|
||||
@Child(name="category", type={CodeableConcept.class}, order=0, min=0, max=1)
|
||||
@Description(shortDefinition="Clinical, administrative, etc.", formalDefinition="Allows an alert to be divided into different categories like clinical, administrative etc." )
|
||||
protected CodeableConcept category;
|
||||
|
||||
/**
|
||||
* Supports basic workflow.
|
||||
*/
|
||||
@Child(name="status", type={CodeType.class}, order=1, min=1, max=1)
|
||||
@Description(shortDefinition="active | inactive | entered in error", formalDefinition="Supports basic workflow." )
|
||||
protected Enumeration<AlertStatus> status;
|
||||
|
||||
/**
|
||||
* The person who this alert concerns.
|
||||
*/
|
||||
@Child(name="subject", type={Patient.class}, order=2, min=1, max=1)
|
||||
@Description(shortDefinition="Who is alert about?", formalDefinition="The person who this alert concerns." )
|
||||
protected Reference subject;
|
||||
|
||||
/**
|
||||
* The actual object that is the target of the reference (The person who this alert concerns.)
|
||||
*/
|
||||
protected Patient subjectTarget;
|
||||
|
||||
/**
|
||||
* The person or device that created the alert.
|
||||
*/
|
||||
@Child(name="author", type={Practitioner.class, Patient.class, Device.class}, order=3, min=0, max=1)
|
||||
@Description(shortDefinition="Alert creator", formalDefinition="The person or device that created the alert." )
|
||||
protected Reference author;
|
||||
|
||||
/**
|
||||
* The actual object that is the target of the reference (The person or device that created the alert.)
|
||||
*/
|
||||
protected Resource authorTarget;
|
||||
|
||||
/**
|
||||
* The textual component of the alert to display to the user.
|
||||
*/
|
||||
@Child(name="note", type={StringType.class}, order=4, min=1, max=1)
|
||||
@Description(shortDefinition="Text of alert", formalDefinition="The textual component of the alert to display to the user." )
|
||||
protected StringType note;
|
||||
|
||||
private static final long serialVersionUID = -655685828L;
|
||||
|
||||
public Alert() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Alert(Enumeration<AlertStatus> status, Reference subject, StringType note) {
|
||||
super();
|
||||
this.status = status;
|
||||
this.subject = subject;
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #identifier} (Identifier assigned to the alert for external use (outside the FHIR environment).)
|
||||
*/
|
||||
public List<Identifier> getIdentifier() {
|
||||
if (this.identifier == null)
|
||||
this.identifier = new ArrayList<Identifier>();
|
||||
return this.identifier;
|
||||
}
|
||||
|
||||
public boolean hasIdentifier() {
|
||||
if (this.identifier == null)
|
||||
return false;
|
||||
for (Identifier item : this.identifier)
|
||||
if (!item.isEmpty())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #identifier} (Identifier assigned to the alert for external use (outside the FHIR environment).)
|
||||
*/
|
||||
// syntactic sugar
|
||||
public Identifier addIdentifier() { //3
|
||||
Identifier t = new Identifier();
|
||||
if (this.identifier == null)
|
||||
this.identifier = new ArrayList<Identifier>();
|
||||
this.identifier.add(t);
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #category} (Allows an alert to be divided into different categories like clinical, administrative etc.)
|
||||
*/
|
||||
public CodeableConcept getCategory() {
|
||||
if (this.category == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create Alert.category");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.category = new CodeableConcept();
|
||||
return this.category;
|
||||
}
|
||||
|
||||
public boolean hasCategory() {
|
||||
return this.category != null && !this.category.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #category} (Allows an alert to be divided into different categories like clinical, administrative etc.)
|
||||
*/
|
||||
public Alert setCategory(CodeableConcept value) {
|
||||
this.category = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #status} (Supports basic workflow.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
|
||||
*/
|
||||
public Enumeration<AlertStatus> getStatusElement() {
|
||||
if (this.status == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create Alert.status");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.status = new Enumeration<AlertStatus>();
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public boolean hasStatusElement() {
|
||||
return this.status != null && !this.status.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasStatus() {
|
||||
return this.status != null && !this.status.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #status} (Supports basic workflow.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
|
||||
*/
|
||||
public Alert setStatusElement(Enumeration<AlertStatus> value) {
|
||||
this.status = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Supports basic workflow.
|
||||
*/
|
||||
public AlertStatus getStatus() {
|
||||
return this.status == null ? null : this.status.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value Supports basic workflow.
|
||||
*/
|
||||
public Alert setStatus(AlertStatus value) {
|
||||
if (this.status == null)
|
||||
this.status = new Enumeration<AlertStatus>(AlertStatus.ENUM_FACTORY);
|
||||
this.status.setValue(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #subject} (The person who this alert concerns.)
|
||||
*/
|
||||
public Reference getSubject() {
|
||||
if (this.subject == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create Alert.subject");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.subject = new Reference();
|
||||
return this.subject;
|
||||
}
|
||||
|
||||
public boolean hasSubject() {
|
||||
return this.subject != null && !this.subject.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #subject} (The person who this alert concerns.)
|
||||
*/
|
||||
public Alert setSubject(Reference value) {
|
||||
this.subject = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #subject} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The person who this alert concerns.)
|
||||
*/
|
||||
public Patient getSubjectTarget() {
|
||||
if (this.subjectTarget == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create Alert.subject");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.subjectTarget = new Patient();
|
||||
return this.subjectTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #subject} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The person who this alert concerns.)
|
||||
*/
|
||||
public Alert setSubjectTarget(Patient value) {
|
||||
this.subjectTarget = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #author} (The person or device that created the alert.)
|
||||
*/
|
||||
public Reference getAuthor() {
|
||||
if (this.author == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create Alert.author");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.author = new Reference();
|
||||
return this.author;
|
||||
}
|
||||
|
||||
public boolean hasAuthor() {
|
||||
return this.author != null && !this.author.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #author} (The person or device that created the alert.)
|
||||
*/
|
||||
public Alert setAuthor(Reference value) {
|
||||
this.author = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #author} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The person or device that created the alert.)
|
||||
*/
|
||||
public Resource getAuthorTarget() {
|
||||
return this.authorTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #author} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The person or device that created the alert.)
|
||||
*/
|
||||
public Alert setAuthorTarget(Resource value) {
|
||||
this.authorTarget = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #note} (The textual component of the alert to display to the user.). This is the underlying object with id, value and extensions. The accessor "getNote" gives direct access to the value
|
||||
*/
|
||||
public StringType getNoteElement() {
|
||||
if (this.note == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create Alert.note");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.note = new StringType();
|
||||
return this.note;
|
||||
}
|
||||
|
||||
public boolean hasNoteElement() {
|
||||
return this.note != null && !this.note.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasNote() {
|
||||
return this.note != null && !this.note.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #note} (The textual component of the alert to display to the user.). This is the underlying object with id, value and extensions. The accessor "getNote" gives direct access to the value
|
||||
*/
|
||||
public Alert setNoteElement(StringType value) {
|
||||
this.note = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The textual component of the alert to display to the user.
|
||||
*/
|
||||
public String getNote() {
|
||||
return this.note == null ? null : this.note.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value The textual component of the alert to display to the user.
|
||||
*/
|
||||
public Alert setNote(String value) {
|
||||
if (this.note == null)
|
||||
this.note = new StringType();
|
||||
this.note.setValue(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void listChildren(List<Property> childrenList) {
|
||||
super.listChildren(childrenList);
|
||||
childrenList.add(new Property("identifier", "Identifier", "Identifier assigned to the alert for external use (outside the FHIR environment).", 0, java.lang.Integer.MAX_VALUE, identifier));
|
||||
childrenList.add(new Property("category", "CodeableConcept", "Allows an alert to be divided into different categories like clinical, administrative etc.", 0, java.lang.Integer.MAX_VALUE, category));
|
||||
childrenList.add(new Property("status", "code", "Supports basic workflow.", 0, java.lang.Integer.MAX_VALUE, status));
|
||||
childrenList.add(new Property("subject", "Reference(Patient)", "The person who this alert concerns.", 0, java.lang.Integer.MAX_VALUE, subject));
|
||||
childrenList.add(new Property("author", "Reference(Practitioner|Patient|Device)", "The person or device that created the alert.", 0, java.lang.Integer.MAX_VALUE, author));
|
||||
childrenList.add(new Property("note", "string", "The textual component of the alert to display to the user.", 0, java.lang.Integer.MAX_VALUE, note));
|
||||
}
|
||||
|
||||
public Alert copy() {
|
||||
Alert dst = new Alert();
|
||||
copyValues(dst);
|
||||
if (identifier != null) {
|
||||
dst.identifier = new ArrayList<Identifier>();
|
||||
for (Identifier i : identifier)
|
||||
dst.identifier.add(i.copy());
|
||||
};
|
||||
dst.category = category == null ? null : category.copy();
|
||||
dst.status = status == null ? null : status.copy();
|
||||
dst.subject = subject == null ? null : subject.copy();
|
||||
dst.author = author == null ? null : author.copy();
|
||||
dst.note = note == null ? null : note.copy();
|
||||
return dst;
|
||||
}
|
||||
|
||||
protected Alert typedCopy() {
|
||||
return copy();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (category == null || category.isEmpty())
|
||||
&& (status == null || status.isEmpty()) && (subject == null || subject.isEmpty()) && (author == null || author.isEmpty())
|
||||
&& (note == null || note.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceType getResourceType() {
|
||||
return ResourceType.Alert;
|
||||
}
|
||||
|
||||
@SearchParamDefinition(name="patient", path="Alert.subject", description="The identity of a subject to list alerts for", type="reference" )
|
||||
public static final String SP_PATIENT = "patient";
|
||||
@SearchParamDefinition(name="subject", path="Alert.subject", description="The identity of a subject to list alerts for", type="reference" )
|
||||
public static final String SP_SUBJECT = "subject";
|
||||
|
||||
}
|
||||
|
||||
package org.hl7.fhir.instance.model;
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
// Generated on Sat, Feb 14, 2015 16:12-0500 for FHIR v0.4.0
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.instance.model.annotations.ResourceDef;
|
||||
import org.hl7.fhir.instance.model.annotations.SearchParamDefinition;
|
||||
import org.hl7.fhir.instance.model.annotations.Block;
|
||||
import org.hl7.fhir.instance.model.annotations.Child;
|
||||
import org.hl7.fhir.instance.model.annotations.Description;
|
||||
/**
|
||||
* Prospective warnings of potential issues when providing care to the patient.
|
||||
*/
|
||||
@ResourceDef(name="Alert", profile="http://hl7.org/fhir/Profile/Alert")
|
||||
public class Alert extends DomainResource {
|
||||
|
||||
public enum AlertStatus {
|
||||
/**
|
||||
* A current alert that should be displayed to a user. A system may use the category to determine which roles should view the alert.
|
||||
*/
|
||||
ACTIVE,
|
||||
/**
|
||||
* The alert does not need to be displayed any more.
|
||||
*/
|
||||
INACTIVE,
|
||||
/**
|
||||
* The alert was added in error, and should no longer be displayed.
|
||||
*/
|
||||
ENTEREDINERROR,
|
||||
/**
|
||||
* added to help the parsers
|
||||
*/
|
||||
NULL;
|
||||
public static AlertStatus fromCode(String codeString) throws Exception {
|
||||
if (codeString == null || "".equals(codeString))
|
||||
return null;
|
||||
if ("active".equals(codeString))
|
||||
return ACTIVE;
|
||||
if ("inactive".equals(codeString))
|
||||
return INACTIVE;
|
||||
if ("entered-in-error".equals(codeString))
|
||||
return ENTEREDINERROR;
|
||||
throw new Exception("Unknown AlertStatus code '"+codeString+"'");
|
||||
}
|
||||
public String toCode() {
|
||||
switch (this) {
|
||||
case ACTIVE: return "active";
|
||||
case INACTIVE: return "inactive";
|
||||
case ENTEREDINERROR: return "entered-in-error";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
public String getSystem() {
|
||||
switch (this) {
|
||||
case ACTIVE: return "";
|
||||
case INACTIVE: return "";
|
||||
case ENTEREDINERROR: return "";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
public String getDefinition() {
|
||||
switch (this) {
|
||||
case ACTIVE: return "A current alert that should be displayed to a user. A system may use the category to determine which roles should view the alert.";
|
||||
case INACTIVE: return "The alert does not need to be displayed any more.";
|
||||
case ENTEREDINERROR: return "The alert was added in error, and should no longer be displayed.";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
public String getDisplay() {
|
||||
switch (this) {
|
||||
case ACTIVE: return "active";
|
||||
case INACTIVE: return "inactive";
|
||||
case ENTEREDINERROR: return "entered-in-error";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class AlertStatusEnumFactory implements EnumFactory<AlertStatus> {
|
||||
public AlertStatus fromCode(String codeString) throws IllegalArgumentException {
|
||||
if (codeString == null || "".equals(codeString))
|
||||
if (codeString == null || "".equals(codeString))
|
||||
return null;
|
||||
if ("active".equals(codeString))
|
||||
return AlertStatus.ACTIVE;
|
||||
if ("inactive".equals(codeString))
|
||||
return AlertStatus.INACTIVE;
|
||||
if ("entered-in-error".equals(codeString))
|
||||
return AlertStatus.ENTEREDINERROR;
|
||||
throw new IllegalArgumentException("Unknown AlertStatus code '"+codeString+"'");
|
||||
}
|
||||
public String toCode(AlertStatus code) {
|
||||
if (code == AlertStatus.ACTIVE)
|
||||
return "active";
|
||||
if (code == AlertStatus.INACTIVE)
|
||||
return "inactive";
|
||||
if (code == AlertStatus.ENTEREDINERROR)
|
||||
return "entered-in-error";
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier assigned to the alert for external use (outside the FHIR environment).
|
||||
*/
|
||||
@Child(name="identifier", type={Identifier.class}, order=-1, min=0, max=Child.MAX_UNLIMITED)
|
||||
@Description(shortDefinition="Business identifier", formalDefinition="Identifier assigned to the alert for external use (outside the FHIR environment)." )
|
||||
protected List<Identifier> identifier;
|
||||
|
||||
/**
|
||||
* Allows an alert to be divided into different categories like clinical, administrative etc.
|
||||
*/
|
||||
@Child(name="category", type={CodeableConcept.class}, order=0, min=0, max=1)
|
||||
@Description(shortDefinition="Clinical, administrative, etc.", formalDefinition="Allows an alert to be divided into different categories like clinical, administrative etc." )
|
||||
protected CodeableConcept category;
|
||||
|
||||
/**
|
||||
* Supports basic workflow.
|
||||
*/
|
||||
@Child(name="status", type={CodeType.class}, order=1, min=1, max=1)
|
||||
@Description(shortDefinition="active | inactive | entered-in-error", formalDefinition="Supports basic workflow." )
|
||||
protected Enumeration<AlertStatus> status;
|
||||
|
||||
/**
|
||||
* The person who this alert concerns.
|
||||
*/
|
||||
@Child(name="subject", type={Patient.class}, order=2, min=1, max=1)
|
||||
@Description(shortDefinition="Who is alert about?", formalDefinition="The person who this alert concerns." )
|
||||
protected Reference subject;
|
||||
|
||||
/**
|
||||
* The actual object that is the target of the reference (The person who this alert concerns.)
|
||||
*/
|
||||
protected Patient subjectTarget;
|
||||
|
||||
/**
|
||||
* The person or device that created the alert.
|
||||
*/
|
||||
@Child(name="author", type={Practitioner.class, Patient.class, Device.class}, order=3, min=0, max=1)
|
||||
@Description(shortDefinition="Alert creator", formalDefinition="The person or device that created the alert." )
|
||||
protected Reference author;
|
||||
|
||||
/**
|
||||
* The actual object that is the target of the reference (The person or device that created the alert.)
|
||||
*/
|
||||
protected Resource authorTarget;
|
||||
|
||||
/**
|
||||
* The textual component of the alert to display to the user.
|
||||
*/
|
||||
@Child(name="note", type={StringType.class}, order=4, min=1, max=1)
|
||||
@Description(shortDefinition="Text of alert", formalDefinition="The textual component of the alert to display to the user." )
|
||||
protected StringType note;
|
||||
|
||||
private static final long serialVersionUID = -655685828L;
|
||||
|
||||
public Alert() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Alert(Enumeration<AlertStatus> status, Reference subject, StringType note) {
|
||||
super();
|
||||
this.status = status;
|
||||
this.subject = subject;
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #identifier} (Identifier assigned to the alert for external use (outside the FHIR environment).)
|
||||
*/
|
||||
public List<Identifier> getIdentifier() {
|
||||
if (this.identifier == null)
|
||||
this.identifier = new ArrayList<Identifier>();
|
||||
return this.identifier;
|
||||
}
|
||||
|
||||
public boolean hasIdentifier() {
|
||||
if (this.identifier == null)
|
||||
return false;
|
||||
for (Identifier item : this.identifier)
|
||||
if (!item.isEmpty())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #identifier} (Identifier assigned to the alert for external use (outside the FHIR environment).)
|
||||
*/
|
||||
// syntactic sugar
|
||||
public Identifier addIdentifier() { //3
|
||||
Identifier t = new Identifier();
|
||||
if (this.identifier == null)
|
||||
this.identifier = new ArrayList<Identifier>();
|
||||
this.identifier.add(t);
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #category} (Allows an alert to be divided into different categories like clinical, administrative etc.)
|
||||
*/
|
||||
public CodeableConcept getCategory() {
|
||||
if (this.category == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create Alert.category");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.category = new CodeableConcept(); // cc
|
||||
return this.category;
|
||||
}
|
||||
|
||||
public boolean hasCategory() {
|
||||
return this.category != null && !this.category.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #category} (Allows an alert to be divided into different categories like clinical, administrative etc.)
|
||||
*/
|
||||
public Alert setCategory(CodeableConcept value) {
|
||||
this.category = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #status} (Supports basic workflow.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
|
||||
*/
|
||||
public Enumeration<AlertStatus> getStatusElement() {
|
||||
if (this.status == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create Alert.status");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.status = new Enumeration<AlertStatus>(new AlertStatusEnumFactory()); // bb
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public boolean hasStatusElement() {
|
||||
return this.status != null && !this.status.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasStatus() {
|
||||
return this.status != null && !this.status.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #status} (Supports basic workflow.). This is the underlying object with id, value and extensions. The accessor "getStatus" gives direct access to the value
|
||||
*/
|
||||
public Alert setStatusElement(Enumeration<AlertStatus> value) {
|
||||
this.status = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Supports basic workflow.
|
||||
*/
|
||||
public AlertStatus getStatus() {
|
||||
return this.status == null ? null : this.status.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value Supports basic workflow.
|
||||
*/
|
||||
public Alert setStatus(AlertStatus value) {
|
||||
if (this.status == null)
|
||||
this.status = new Enumeration<AlertStatus>(new AlertStatusEnumFactory());
|
||||
this.status.setValue(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #subject} (The person who this alert concerns.)
|
||||
*/
|
||||
public Reference getSubject() {
|
||||
if (this.subject == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create Alert.subject");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.subject = new Reference(); // cc
|
||||
return this.subject;
|
||||
}
|
||||
|
||||
public boolean hasSubject() {
|
||||
return this.subject != null && !this.subject.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #subject} (The person who this alert concerns.)
|
||||
*/
|
||||
public Alert setSubject(Reference value) {
|
||||
this.subject = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #subject} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The person who this alert concerns.)
|
||||
*/
|
||||
public Patient getSubjectTarget() {
|
||||
if (this.subjectTarget == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create Alert.subject");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.subjectTarget = new Patient(); // aa
|
||||
return this.subjectTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #subject} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The person who this alert concerns.)
|
||||
*/
|
||||
public Alert setSubjectTarget(Patient value) {
|
||||
this.subjectTarget = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #author} (The person or device that created the alert.)
|
||||
*/
|
||||
public Reference getAuthor() {
|
||||
if (this.author == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create Alert.author");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.author = new Reference(); // cc
|
||||
return this.author;
|
||||
}
|
||||
|
||||
public boolean hasAuthor() {
|
||||
return this.author != null && !this.author.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #author} (The person or device that created the alert.)
|
||||
*/
|
||||
public Alert setAuthor(Reference value) {
|
||||
this.author = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #author} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The person or device that created the alert.)
|
||||
*/
|
||||
public Resource getAuthorTarget() {
|
||||
return this.authorTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #author} The actual object that is the target of the reference. The reference library doesn't use these, but you can use it to hold the resource if you resolve it. (The person or device that created the alert.)
|
||||
*/
|
||||
public Alert setAuthorTarget(Resource value) {
|
||||
this.authorTarget = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link #note} (The textual component of the alert to display to the user.). This is the underlying object with id, value and extensions. The accessor "getNote" gives direct access to the value
|
||||
*/
|
||||
public StringType getNoteElement() {
|
||||
if (this.note == null)
|
||||
if (Configuration.errorOnAutoCreate())
|
||||
throw new Error("Attempt to auto-create Alert.note");
|
||||
else if (Configuration.doAutoCreate())
|
||||
this.note = new StringType(); // bb
|
||||
return this.note;
|
||||
}
|
||||
|
||||
public boolean hasNoteElement() {
|
||||
return this.note != null && !this.note.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasNote() {
|
||||
return this.note != null && !this.note.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value {@link #note} (The textual component of the alert to display to the user.). This is the underlying object with id, value and extensions. The accessor "getNote" gives direct access to the value
|
||||
*/
|
||||
public Alert setNoteElement(StringType value) {
|
||||
this.note = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The textual component of the alert to display to the user.
|
||||
*/
|
||||
public String getNote() {
|
||||
return this.note == null ? null : this.note.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value The textual component of the alert to display to the user.
|
||||
*/
|
||||
public Alert setNote(String value) {
|
||||
if (this.note == null)
|
||||
this.note = new StringType();
|
||||
this.note.setValue(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void listChildren(List<Property> childrenList) {
|
||||
super.listChildren(childrenList);
|
||||
childrenList.add(new Property("identifier", "Identifier", "Identifier assigned to the alert for external use (outside the FHIR environment).", 0, java.lang.Integer.MAX_VALUE, identifier));
|
||||
childrenList.add(new Property("category", "CodeableConcept", "Allows an alert to be divided into different categories like clinical, administrative etc.", 0, java.lang.Integer.MAX_VALUE, category));
|
||||
childrenList.add(new Property("status", "code", "Supports basic workflow.", 0, java.lang.Integer.MAX_VALUE, status));
|
||||
childrenList.add(new Property("subject", "Reference(Patient)", "The person who this alert concerns.", 0, java.lang.Integer.MAX_VALUE, subject));
|
||||
childrenList.add(new Property("author", "Reference(Practitioner|Patient|Device)", "The person or device that created the alert.", 0, java.lang.Integer.MAX_VALUE, author));
|
||||
childrenList.add(new Property("note", "string", "The textual component of the alert to display to the user.", 0, java.lang.Integer.MAX_VALUE, note));
|
||||
}
|
||||
|
||||
public Alert copy() {
|
||||
Alert dst = new Alert();
|
||||
copyValues(dst);
|
||||
if (identifier != null) {
|
||||
dst.identifier = new ArrayList<Identifier>();
|
||||
for (Identifier i : identifier)
|
||||
dst.identifier.add(i.copy());
|
||||
};
|
||||
dst.category = category == null ? null : category.copy();
|
||||
dst.status = status == null ? null : status.copy();
|
||||
dst.subject = subject == null ? null : subject.copy();
|
||||
dst.author = author == null ? null : author.copy();
|
||||
dst.note = note == null ? null : note.copy();
|
||||
return dst;
|
||||
}
|
||||
|
||||
protected Alert typedCopy() {
|
||||
return copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsDeep(Base other) {
|
||||
if (!super.equalsDeep(other))
|
||||
return false;
|
||||
if (!(other instanceof Alert))
|
||||
return false;
|
||||
Alert o = (Alert) other;
|
||||
return compareDeep(identifier, o.identifier, true) && compareDeep(category, o.category, true) && compareDeep(status, o.status, true)
|
||||
&& compareDeep(subject, o.subject, true) && compareDeep(author, o.author, true) && compareDeep(note, o.note, true)
|
||||
;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsShallow(Base other) {
|
||||
if (!super.equalsShallow(other))
|
||||
return false;
|
||||
if (!(other instanceof Alert))
|
||||
return false;
|
||||
Alert o = (Alert) other;
|
||||
return compareValues(status, o.status, true) && compareValues(note, o.note, true);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (category == null || category.isEmpty())
|
||||
&& (status == null || status.isEmpty()) && (subject == null || subject.isEmpty()) && (author == null || author.isEmpty())
|
||||
&& (note == null || note.isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceType getResourceType() {
|
||||
return ResourceType.Alert;
|
||||
}
|
||||
|
||||
@SearchParamDefinition(name="patient", path="Alert.subject", description="The identity of a subject to list alerts for", type="reference" )
|
||||
public static final String SP_PATIENT = "patient";
|
||||
@SearchParamDefinition(name="subject", path="Alert.subject", description="The identity of a subject to list alerts for", type="reference" )
|
||||
public static final String SP_SUBJECT = "subject";
|
||||
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue