Merge branch 'hl7org_dstu21'
This commit is contained in:
commit
09b0982df1
|
@ -8,6 +8,11 @@ import javax.servlet.ServletException;
|
|||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||
import org.hl7.fhir.instance.hapi.validation.DefaultProfileValidationSupport;
|
||||
import org.hl7.fhir.instance.hapi.validation.FhirInstanceValidator;
|
||||
import org.hl7.fhir.instance.hapi.validation.IValidationSupport;
|
||||
import org.hl7.fhir.instance.hapi.validation.IValidationSupport.CodeValidationResult;
|
||||
import org.hl7.fhir.instance.hapi.validation.ValidationSupportChain;
|
||||
import org.hl7.fhir.instance.model.ValueSet;
|
||||
import org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent;
|
||||
import org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionComponent;
|
||||
|
@ -23,11 +28,7 @@ import ca.uhn.fhir.parser.IParser;
|
|||
import ca.uhn.fhir.parser.StrictErrorHandler;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.validation.DefaultProfileValidationSupport;
|
||||
import ca.uhn.fhir.validation.ValidationSupportChain;
|
||||
import ca.uhn.fhir.validation.FhirInstanceValidator;
|
||||
import ca.uhn.fhir.validation.FhirValidator;
|
||||
import ca.uhn.fhir.validation.IValidationSupport;
|
||||
import ca.uhn.fhir.validation.SingleValidationMessage;
|
||||
import ca.uhn.fhir.validation.ValidationResult;
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ public abstract class BaseRuntimeChildDatatypeDefinition extends BaseRuntimeDecl
|
|||
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
|
||||
// should use RuntimeChildAny
|
||||
assert Modifier.isInterface(theDatatype.getModifiers()) == false : "Type of " + theDatatype + " shouldn't be here";
|
||||
assert Modifier.isAbstract(theDatatype.getModifiers()) == false : "Type of " + theDatatype + " shouldn't be here";
|
||||
myDatatype = theDatatype;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public abstract class BaseRuntimeElementDefinition<T extends IBase> {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName()+"[" + getName() + "]";
|
||||
return getClass().getSimpleName()+"[" + getName() + ", " + getImplementingClass().getSimpleName() + "]";
|
||||
}
|
||||
|
||||
public void addExtension(RuntimeChildDeclaredExtensionDefinition theExtension) {
|
||||
|
@ -214,8 +214,8 @@ public abstract class BaseRuntimeElementDefinition<T extends IBase> {
|
|||
/**
|
||||
* HL7.org style.
|
||||
*/
|
||||
PRIMITIVE_XHTML_HL7ORG
|
||||
|
||||
PRIMITIVE_XHTML_HL7ORG,
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -124,8 +124,6 @@ public class FhirContext {
|
|||
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 {
|
||||
throw new IllegalStateException(getLocalizer().getMessage(FhirContext.class, "noStructures"));
|
||||
}
|
||||
|
@ -483,7 +481,7 @@ public class FhirContext {
|
|||
myParserErrorHandler = theParserErrorHandler;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({ "cast" })
|
||||
private List<Class<? extends IElement>> toElementList(Collection<Class<? extends IBaseResource>> theResourceTypes) {
|
||||
if (theResourceTypes == null) {
|
||||
return null;
|
||||
|
@ -495,16 +493,6 @@ public class FhirContext {
|
|||
return resTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a new FhirContext with version {@link FhirVersionEnum#DEV}
|
||||
*
|
||||
* @deprecated Support for DEV resources will be removed, you should use DSTU2 resources instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static FhirContext forDev() {
|
||||
return new FhirContext(FhirVersionEnum.DEV);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a new FhirContext with version {@link FhirVersionEnum#DSTU1}
|
||||
*/
|
||||
|
|
|
@ -34,25 +34,38 @@ public enum FhirVersionEnum {
|
|||
* ***********************
|
||||
*/
|
||||
|
||||
DSTU1("ca.uhn.fhir.model.dstu.FhirDstu1", null),
|
||||
DSTU1("ca.uhn.fhir.model.dstu.FhirDstu1", null, false),
|
||||
|
||||
DSTU2("ca.uhn.fhir.model.dstu2.FhirDstu2", null),
|
||||
DSTU2("ca.uhn.fhir.model.dstu2.FhirDstu2", null, false),
|
||||
|
||||
DEV("ca.uhn.fhir.model.dev.FhirDev", null),
|
||||
DSTU2_1("org.hl7.fhir.dstu21.hapi.ctx.FhirDstu21", null, true),
|
||||
|
||||
DSTU2_HL7ORG("org.hl7.fhir.instance.FhirDstu2Hl7Org", DSTU2),
|
||||
|
||||
DSTU2_1("ca.uhn.fhir.model.dstu21.FhirDstu21", null);
|
||||
DSTU2_HL7ORG("org.hl7.fhir.instance.FhirDstu2Hl7Org", DSTU2, true);
|
||||
|
||||
|
||||
private final String myVersionClass;
|
||||
private final FhirVersionEnum myEquivalent;
|
||||
private final boolean myIsRi;
|
||||
private volatile Boolean myPresentOnClasspath;
|
||||
private final String myVersionClass;
|
||||
private volatile IFhirVersion myVersionImplementation;
|
||||
|
||||
FhirVersionEnum(String theVersionClass, FhirVersionEnum theEquivalent) {
|
||||
FhirVersionEnum(String theVersionClass, FhirVersionEnum theEquivalent, boolean theIsRi) {
|
||||
myVersionClass = theVersionClass;
|
||||
myEquivalent = theEquivalent;
|
||||
myIsRi = theIsRi;
|
||||
}
|
||||
|
||||
public IFhirVersion getVersionImplementation() {
|
||||
if (!isPresentOnClasspath()) {
|
||||
throw new IllegalStateException("Version " + name() + " is not present on classpath");
|
||||
}
|
||||
if (myVersionImplementation == null) {
|
||||
try {
|
||||
myVersionImplementation = (IFhirVersion) Class.forName(myVersionClass).newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new InternalErrorException("Failed to instantiate FHIR version " + name(), e);
|
||||
}
|
||||
}
|
||||
return myVersionImplementation;
|
||||
}
|
||||
|
||||
public boolean isEquivalentTo(FhirVersionEnum theVersion) {
|
||||
|
@ -86,18 +99,11 @@ public enum FhirVersionEnum {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
public IFhirVersion getVersionImplementation() {
|
||||
if (!isPresentOnClasspath()) {
|
||||
throw new IllegalStateException("Version " + name() + " is not present on classpath");
|
||||
}
|
||||
if (myVersionImplementation == null) {
|
||||
try {
|
||||
myVersionImplementation = (IFhirVersion) Class.forName(myVersionClass).newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new InternalErrorException("Failed to instantiate FHIR version " + name(), e);
|
||||
}
|
||||
}
|
||||
return myVersionImplementation;
|
||||
/**
|
||||
* Is this version using the HL7.org RI structures?
|
||||
*/
|
||||
public boolean isRi() {
|
||||
return myIsRi;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
|||
import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
|
||||
import org.hl7.fhir.instance.model.api.IBaseEnumeration;
|
||||
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||
import org.hl7.fhir.instance.model.api.IBaseMetaType;
|
||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseXhtml;
|
||||
|
@ -231,7 +232,8 @@ class ModelScanner {
|
|||
}
|
||||
|
||||
private boolean isStandardType(Class<? extends IBase> theClass) {
|
||||
return myVersionTypes.contains(theClass);
|
||||
boolean retVal = myVersionTypes.contains(theClass);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -245,58 +247,58 @@ class ModelScanner {
|
|||
private <T extends Annotation> T pullAnnotation(Class<?> theContainer, AnnotatedElement theTarget, Class<T> theAnnotationType) {
|
||||
|
||||
T retVal = theTarget.getAnnotation(theAnnotationType);
|
||||
if (myContext.getVersion().getVersion() != FhirVersionEnum.DSTU2_HL7ORG) {
|
||||
// if (myContext.getVersion().getVersion() != FhirVersionEnum.DSTU2_HL7ORG) {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
if (retVal == null) {
|
||||
final Class<? extends Annotation> altAnnotationClass;
|
||||
/*
|
||||
* Use a cache to minimize Class.forName calls, since they are slow and expensive..
|
||||
*/
|
||||
if (myAnnotationForwards.containsKey(theAnnotationType) == false) {
|
||||
String sourceClassName = theAnnotationType.getName();
|
||||
String candidateAltClassName = sourceClassName.replace("ca.uhn.fhir.model.api.annotation", "org.hl7.fhir.instance.model.annotations");
|
||||
if (!sourceClassName.equals(candidateAltClassName)) {
|
||||
Class<?> forName;
|
||||
try {
|
||||
forName = Class.forName(candidateAltClassName);
|
||||
ourLog.debug("Forwarding annotation request for [{}] to class [{}]", theAnnotationType, forName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
forName = null;
|
||||
}
|
||||
altAnnotationClass = (Class<? extends Annotation>) forName;
|
||||
} else {
|
||||
altAnnotationClass = null;
|
||||
}
|
||||
myAnnotationForwards.put(theAnnotationType, altAnnotationClass);
|
||||
} else {
|
||||
altAnnotationClass = myAnnotationForwards.get(theAnnotationType);
|
||||
}
|
||||
|
||||
if (altAnnotationClass == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Annotation altAnnotation;
|
||||
altAnnotation = theTarget.getAnnotation(altAnnotationClass);
|
||||
if (altAnnotation == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
InvocationHandler h = new InvocationHandler() {
|
||||
|
||||
@Override
|
||||
public Object invoke(Object theProxy, Method theMethod, Object[] theArgs) throws Throwable {
|
||||
Method altMethod = altAnnotationClass.getMethod(theMethod.getName(), theMethod.getParameterTypes());
|
||||
return altMethod.invoke(altAnnotation, theArgs);
|
||||
}
|
||||
};
|
||||
retVal = (T) Proxy.newProxyInstance(theAnnotationType.getClassLoader(), new Class<?>[] { theAnnotationType }, h);
|
||||
|
||||
}
|
||||
|
||||
return retVal;
|
||||
// }
|
||||
//
|
||||
// if (retVal == null) {
|
||||
// final Class<? extends Annotation> altAnnotationClass;
|
||||
// /*
|
||||
// * Use a cache to minimize Class.forName calls, since they are slow and expensive..
|
||||
// */
|
||||
// if (myAnnotationForwards.containsKey(theAnnotationType) == false) {
|
||||
// String sourceClassName = theAnnotationType.getName();
|
||||
// String candidateAltClassName = sourceClassName.replace("ca.uhn.fhir.model.api.annotation", "org.hl7.fhir.instance.model.annotations");
|
||||
// if (!sourceClassName.equals(candidateAltClassName)) {
|
||||
// Class<?> forName;
|
||||
// try {
|
||||
// forName = Class.forName(candidateAltClassName);
|
||||
// ourLog.debug("Forwarding annotation request for [{}] to class [{}]", theAnnotationType, forName);
|
||||
// } catch (ClassNotFoundException e) {
|
||||
// forName = null;
|
||||
// }
|
||||
// altAnnotationClass = (Class<? extends Annotation>) forName;
|
||||
// } else {
|
||||
// altAnnotationClass = null;
|
||||
// }
|
||||
// myAnnotationForwards.put(theAnnotationType, altAnnotationClass);
|
||||
// } else {
|
||||
// altAnnotationClass = myAnnotationForwards.get(theAnnotationType);
|
||||
// }
|
||||
//
|
||||
// if (altAnnotationClass == null) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// final Annotation altAnnotation;
|
||||
// altAnnotation = theTarget.getAnnotation(altAnnotationClass);
|
||||
// if (altAnnotation == null) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// InvocationHandler h = new InvocationHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public Object invoke(Object theProxy, Method theMethod, Object[] theArgs) throws Throwable {
|
||||
// Method altMethod = altAnnotationClass.getMethod(theMethod.getName(), theMethod.getParameterTypes());
|
||||
// return altMethod.invoke(altAnnotation, theArgs);
|
||||
// }
|
||||
// };
|
||||
// retVal = (T) Proxy.newProxyInstance(theAnnotationType.getClassLoader(), new Class<?>[] { theAnnotationType }, h);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// return retVal;
|
||||
}
|
||||
|
||||
private void scan(Class<? extends IBase> theClass) throws ConfigurationException {
|
||||
|
@ -366,6 +368,8 @@ class ModelScanner {
|
|||
RuntimeCompositeDatatypeDefinition resourceDef;
|
||||
if (theClass.equals(ExtensionDt.class)) {
|
||||
resourceDef = new RuntimeExtensionDtDefinition(theDatatypeDefinition, theClass, true);
|
||||
// } else if (IBaseMetaType.class.isAssignableFrom(theClass)) {
|
||||
// resourceDef = new RuntimeMetaDefinition(theDatatypeDefinition, theClass, isStandardType(theClass));
|
||||
} else {
|
||||
resourceDef = new RuntimeCompositeDatatypeDefinition(theDatatypeDefinition, theClass, isStandardType(theClass));
|
||||
}
|
||||
|
@ -608,7 +612,7 @@ 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) || "org.hl7.fhir.instance.model.Type".equals(nextElementType.getName()) || IBaseDatatype.class.equals(nextElementType)) {
|
||||
} else if (IDatatype.class.equals(nextElementType) || IElement.class.equals(nextElementType) || "Type".equals(nextElementType.getSimpleName()) || IBaseDatatype.class.equals(nextElementType)) {
|
||||
|
||||
RuntimeChildAny def = new RuntimeChildAny(next, elementName, childAnnotation, descriptionAnnotation);
|
||||
orderMap.put(order, def);
|
||||
|
@ -687,7 +691,13 @@ class ModelScanner {
|
|||
}
|
||||
myClassToElementDefinitions.put(theClass, resourceDef);
|
||||
if (!theDatatypeDefinition.isSpecialization()) {
|
||||
myNameToElementDefinitions.put(resourceName, resourceDef);
|
||||
if (myVersion.isRi() && IDatatype.class.isAssignableFrom(theClass)) {
|
||||
ourLog.debug("Not adding non RI type {} to RI context", theClass);
|
||||
} else if (!myVersion.isRi() && !IDatatype.class.isAssignableFrom(theClass)) {
|
||||
ourLog.debug("Not adding RI type {} to non RI context", theClass);
|
||||
} else {
|
||||
myNameToElementDefinitions.put(resourceName, resourceDef);
|
||||
}
|
||||
}
|
||||
|
||||
return resourceName;
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
|
@ -35,7 +34,6 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
|||
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||
import ca.uhn.fhir.model.primitive.CodeDt;
|
||||
|
||||
public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildDefinition {
|
||||
|
||||
|
@ -149,6 +147,8 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD
|
|||
return false;
|
||||
}
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RuntimeChildUndeclaredExtensionDefinition.class);
|
||||
|
||||
@Override
|
||||
void sealAndInitialize(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) {
|
||||
Map<String, BaseRuntimeElementDefinition<?>> datatypeAttributeNameToDefinition = new HashMap<String, BaseRuntimeElementDefinition<?>>();
|
||||
|
@ -160,7 +160,12 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD
|
|||
|
||||
myDatatypeToDefinition.put(next.getImplementingClass(), next);
|
||||
|
||||
if (!((IRuntimeDatatypeDefinition) next).isSpecialization()) {
|
||||
boolean isSpecialization = ((IRuntimeDatatypeDefinition) next).isSpecialization();
|
||||
if (isSpecialization) {
|
||||
ourLog.trace("Not adding specialization: {}", next.getImplementingClass());
|
||||
}
|
||||
|
||||
if (!isSpecialization) {
|
||||
|
||||
if (!next.isStandardType()) {
|
||||
continue;
|
||||
|
|
|
@ -74,7 +74,14 @@ public class RuntimePrimitiveDatatypeDefinition extends BaseRuntimeElementDefini
|
|||
if (myProfileOfType != null) {
|
||||
myProfileOf = theClassToElementDefinitions.get(myProfileOfType);
|
||||
if (myProfileOf == null) {
|
||||
throw new ConfigurationException("Unknown profileOf value: " + myProfileOfType + " in type " + getImplementingClass().getName());
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append("Unknown profileOf value: ");
|
||||
b.append(myProfileOfType);
|
||||
b.append(" in type ");
|
||||
b.append(getImplementingClass().getName());
|
||||
b.append(" - Valid types: ");
|
||||
b.append(theClassToElementDefinitions.keySet());
|
||||
throw new ConfigurationException(b.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,11 +58,8 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
|
|||
|
||||
try {
|
||||
IBaseResource instance = theClass.newInstance();
|
||||
if (instance instanceof IAnyResource) {
|
||||
myStructureVersion = FhirVersionEnum.DSTU2_HL7ORG;
|
||||
} else {
|
||||
myStructureVersion = ((IResource)instance).getStructureFhirVersionEnum();
|
||||
}
|
||||
myStructureVersion = instance.getStructureFhirVersionEnum();
|
||||
assert myStructureVersion != null;
|
||||
} catch (Exception e) {
|
||||
throw new ConfigurationException(myContext.getLocalizer().getMessage(getClass(), "nonInstantiableType", theClass.getName(), e.toString()), e);
|
||||
}
|
||||
|
|
|
@ -25,12 +25,12 @@ import java.util.Date;
|
|||
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.IServerConformanceProvider;
|
||||
import ca.uhn.fhir.rest.server.IVersionSpecificBundleFactory;
|
||||
|
@ -54,10 +54,12 @@ public interface IFhirVersion {
|
|||
|
||||
Class<?> getContainedType();
|
||||
|
||||
BaseCodingDt newCodingDt();
|
||||
IBase newCodingDt();
|
||||
|
||||
IVersionSpecificBundleFactory newBundleFactory(FhirContext theContext);
|
||||
|
||||
IPrimitiveType<Date> getLastUpdated(IBaseResource theResource);
|
||||
|
||||
IIdType newIdType();
|
||||
|
||||
}
|
||||
|
|
|
@ -40,15 +40,6 @@ import ca.uhn.fhir.model.primitive.IdDt;
|
|||
* </p>
|
||||
*/
|
||||
public interface IResource extends ICompositeElement, org.hl7.fhir.instance.model.api.IBaseResource {
|
||||
/**
|
||||
* Include constant for <code>*</code> (return all includes)
|
||||
*/
|
||||
public static final Include INCLUDE_ALL = new Include("*", false).toLocked();
|
||||
|
||||
/**
|
||||
* Include set containing only {@link #INCLUDE_ALL}
|
||||
*/
|
||||
public static final Set<Include> WILDCARD_ALL_SET = Collections.unmodifiableSet(new HashSet<Include>(Arrays.asList(INCLUDE_ALL)));
|
||||
|
||||
/**
|
||||
* Returns the contained resource list for this resource.
|
||||
|
|
|
@ -29,6 +29,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
|
||||
import ca.uhn.fhir.model.primitive.DecimalDt;
|
||||
|
@ -71,7 +73,7 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
|||
* Values for this key are of type <b>{@link InstantDt}</b>
|
||||
* </p>
|
||||
*/
|
||||
public static final ResourceMetadataKeyEnum<InstantDt> DELETED_AT = new ResourceMetadataKeyEnum<InstantDt>("DELETED_AT") {
|
||||
public static final ResourceMetadataKeySupportingAnyResource<InstantDt, IPrimitiveType<Date>> DELETED_AT = new ResourceMetadataKeySupportingAnyResource<InstantDt, IPrimitiveType<Date>>("DELETED_AT") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
|
@ -83,6 +85,17 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
|||
public void put(IResource theResource, InstantDt theObject) {
|
||||
theResource.getResourceMetadata().put(DELETED_AT, theObject);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public IPrimitiveType<Date> get(IAnyResource theResource) {
|
||||
return (IPrimitiveType<Date>) theResource.getUserData(DELETED_AT.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(IAnyResource theResource, IPrimitiveType<Date> theObject) {
|
||||
theResource.setUserData(DELETED_AT.name(), theObject);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -120,7 +133,7 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
|||
* Values for this key are of type <b>{@link BundleEntrySearchModeEnum}</b>
|
||||
* </p>
|
||||
*/
|
||||
public static final ResourceMetadataKeyEnum<BundleEntrySearchModeEnum> ENTRY_SEARCH_MODE = new ResourceMetadataKeyEnum<BundleEntrySearchModeEnum>("ENTRY_SEARCH_MODE") {
|
||||
public static final ResourceMetadataKeySupportingAnyResource<BundleEntrySearchModeEnum, String> ENTRY_SEARCH_MODE = new ResourceMetadataKeySupportingAnyResource<BundleEntrySearchModeEnum, String>("ENTRY_SEARCH_MODE") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public BundleEntrySearchModeEnum get(IResource theResource) {
|
||||
|
@ -131,6 +144,16 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
|||
public void put(IResource theResource, BundleEntrySearchModeEnum theObject) {
|
||||
theResource.getResourceMetadata().put(ENTRY_SEARCH_MODE, theObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(IAnyResource theResource) {
|
||||
return (String) theResource.getUserData(ENTRY_SEARCH_MODE.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(IAnyResource theResource, String theObject) {
|
||||
theResource.setUserData(ENTRY_SEARCH_MODE.name(), theObject);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -145,7 +168,7 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
|||
* Values for this key are of type <b>{@link BundleEntryTransactionMethodEnum}</b>
|
||||
* </p>
|
||||
*/
|
||||
public static final ResourceMetadataKeyEnum<BundleEntryTransactionMethodEnum> ENTRY_TRANSACTION_METHOD = new ResourceMetadataKeyEnum<BundleEntryTransactionMethodEnum>(
|
||||
public static final ResourceMetadataKeySupportingAnyResource<BundleEntryTransactionMethodEnum, String> ENTRY_TRANSACTION_METHOD = new ResourceMetadataKeySupportingAnyResource<BundleEntryTransactionMethodEnum, String>(
|
||||
"ENTRY_TRANSACTION_OPERATION") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -159,6 +182,17 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
|||
public void put(IResource theResource, BundleEntryTransactionMethodEnum theObject) {
|
||||
theResource.getResourceMetadata().put(ENTRY_TRANSACTION_METHOD, theObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(IAnyResource theResource) {
|
||||
return (String) theResource.getUserData(ENTRY_TRANSACTION_METHOD.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(IAnyResource theResource, String theObject) {
|
||||
theResource.setUserData(ENTRY_TRANSACTION_METHOD.name(), theObject);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -444,7 +478,7 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
|||
return result;
|
||||
}
|
||||
|
||||
private String name() {
|
||||
public String name() {
|
||||
return myValue;
|
||||
}
|
||||
|
||||
|
@ -573,4 +607,19 @@ public abstract class ResourceMetadataKeyEnum<T> implements Serializable {
|
|||
+ IdDt.class.getCanonicalName());
|
||||
}
|
||||
|
||||
public static abstract class ResourceMetadataKeySupportingAnyResource<T, T2> extends ResourceMetadataKeyEnum<T> {
|
||||
|
||||
public ResourceMetadataKeySupportingAnyResource(String theValue) {
|
||||
super(theValue);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
public abstract T2 get(IAnyResource theResource);
|
||||
|
||||
public abstract void put(IAnyResource theResource, T2 theObject);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,9 +51,8 @@ public @interface ResourceDef {
|
|||
String id() default "";
|
||||
|
||||
/**
|
||||
* The URL indicating the profile for this resource definition, if known. If this value is set
|
||||
* on a custom profile definition class in a server, the profile is assumed to be external to
|
||||
* the server, so the server will not export a profile for it.
|
||||
* The URL indicating the profile for this resource definition. If specified, this URL will be
|
||||
* automatically added to the meta tag when the resource is serialized.
|
||||
*/
|
||||
String profile() default "";
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.model.base.composite;
|
|||
*/
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.api.IBaseCoding;
|
||||
|
||||
import ca.uhn.fhir.model.api.BaseIdentifiableElement;
|
||||
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
||||
|
|
|
@ -675,4 +675,25 @@ public class IdDt extends UriDt implements IPrimitiveDatatype<String>, IIdType {
|
|||
return theIdPart.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIdType setParts(String theBaseUrl, String theResourceType, String theIdPart, String theVersionIdPart) {
|
||||
if (isNotBlank(theVersionIdPart)) {
|
||||
Validate.notBlank(theResourceType, "If theVersionIdPart is populated, theResourceType and theIdPart must be populated");
|
||||
Validate.notBlank(theIdPart, "If theVersionIdPart is populated, theResourceType and theIdPart must be populated");
|
||||
}
|
||||
if (isNotBlank(theBaseUrl) && isNotBlank(theIdPart)) {
|
||||
Validate.notBlank(theResourceType, "If theBaseUrl is populated and theIdPart is populated, theResourceType must be populated");
|
||||
}
|
||||
|
||||
setValue(null);
|
||||
|
||||
myBaseUrl = theBaseUrl;
|
||||
myResourceType = theResourceType;
|
||||
myUnqualifiedId = theIdPart;
|
||||
myUnqualifiedVersionId = StringUtils.defaultIfBlank(theVersionIdPart, null);
|
||||
myHaveComponentParts = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseCoding;
|
||||
import org.hl7.fhir.instance.model.api.IBaseMetaType;
|
||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
@ -374,6 +375,15 @@ public abstract class BaseParser implements IParser {
|
|||
return stringWriter.toString();
|
||||
}
|
||||
|
||||
private void filterCodingsWithNoCodeOrSystem(List<? extends IBaseCoding> tagList) {
|
||||
for (int i = 0; i < tagList.size(); i++) {
|
||||
if (isBlank(tagList.get(i).getCode()) && isBlank(tagList.get(i).getSystem())) {
|
||||
tagList.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String fixContainedResourceId(String theValue) {
|
||||
if (StringUtils.isNotBlank(theValue) && theValue.charAt(0) == '#') {
|
||||
return theValue.substring(1);
|
||||
|
@ -409,7 +419,7 @@ public abstract class BaseParser implements IParser {
|
|||
TagList tags = ResourceMetadataKeyEnum.TAG_LIST.get(theIResource);
|
||||
if (shouldAddSubsettedTag()) {
|
||||
tags = new TagList(tags);
|
||||
tags.add(new Tag(Constants.TAG_SUBSETTED_SYSTEM, Constants.TAG_SUBSETTED_CODE, "Resource encoded in summary mode"));
|
||||
tags.add(new Tag(Constants.TAG_SUBSETTED_SYSTEM, Constants.TAG_SUBSETTED_CODE, subsetDescription()));
|
||||
}
|
||||
|
||||
return tags;
|
||||
|
@ -538,56 +548,51 @@ public abstract class BaseParser implements IParser {
|
|||
}
|
||||
|
||||
@SuppressWarnings("cast")
|
||||
protected List<? extends IBase> preProcessValues(BaseRuntimeChildDefinition metaChildUncast, List<? extends IBase> theValues) {
|
||||
if (myContext.getVersion().getVersion().equals(FhirVersionEnum.DSTU2_HL7ORG)) {
|
||||
if (shouldAddSubsettedTag() && metaChildUncast.getValidChildNames().contains("meta")) {
|
||||
BaseRuntimeElementDefinition<?> childByName = metaChildUncast.getChildByName("meta");
|
||||
if (childByName instanceof BaseRuntimeElementCompositeDefinition<?>) {
|
||||
BaseRuntimeElementCompositeDefinition<?> metaChildUncast1 = (BaseRuntimeElementCompositeDefinition<?>) childByName;
|
||||
if (metaChildUncast1 != null) {
|
||||
if (IBaseMetaType.class.isAssignableFrom(metaChildUncast1.getImplementingClass())) {
|
||||
IBaseMetaType metaValue;
|
||||
if (theValues != null && theValues.size() >= 1) {
|
||||
metaValue = (IBaseMetaType) theValues.iterator().next();
|
||||
try {
|
||||
metaValue = (IBaseMetaType) metaValue.getClass().getMethod("copy").invoke(metaValue);
|
||||
} catch (Exception e) {
|
||||
throw new InternalErrorException("Failed to duplicate meta", e);
|
||||
}
|
||||
} else {
|
||||
metaValue = (IBaseMetaType) metaChildUncast1.newInstance();
|
||||
}
|
||||
|
||||
ArrayList<IBase> retVal = new ArrayList<IBase>();
|
||||
retVal.add(metaValue);
|
||||
|
||||
BaseRuntimeChildDefinition tagChild = metaChildUncast1.getChildByName("tag");
|
||||
BaseRuntimeElementCompositeDefinition<?> codingDef = (BaseRuntimeElementCompositeDefinition<?>) ((BaseRuntimeElementCompositeDefinition<?>) tagChild.getChildByName("tag"));
|
||||
IBase coding = codingDef.newInstance();
|
||||
tagChild.getMutator().addValue(metaValue, coding);
|
||||
|
||||
BaseRuntimeChildDefinition systemChild = codingDef.getChildByName("system");
|
||||
IPrimitiveType<?> system = (IPrimitiveType<?>) myContext.getElementDefinition("uri").newInstance();
|
||||
system.setValueAsString(Constants.TAG_SUBSETTED_SYSTEM);
|
||||
systemChild.getMutator().addValue(coding, system);
|
||||
|
||||
BaseRuntimeChildDefinition codeChild = codingDef.getChildByName("code");
|
||||
IPrimitiveType<?> code = (IPrimitiveType<?>) myContext.getElementDefinition("code").newInstance();
|
||||
code.setValueAsString(Constants.TAG_SUBSETTED_CODE);
|
||||
codeChild.getMutator().addValue(coding, code);
|
||||
|
||||
BaseRuntimeChildDefinition displayChild = codingDef.getChildByName("display");
|
||||
IPrimitiveType<?> display = (IPrimitiveType<?>) myContext.getElementDefinition("string").newInstance();
|
||||
display.setValueAsString("Resource encoded in summary mode");
|
||||
displayChild.getMutator().addValue(coding, display);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
protected List<? extends IBase> preProcessValues(BaseRuntimeChildDefinition metaChildUncast, IBaseResource theResource, List<? extends IBase> theValues) {
|
||||
if (myContext.getVersion().getVersion().isRi()) {
|
||||
|
||||
/*
|
||||
* If we're encoding the meta tag, we do some massaging of the meta values before
|
||||
* encoding. Buf if there is no meta element at all, we create one since we're possibly going to be
|
||||
* adding things to it
|
||||
*/
|
||||
if (theValues.isEmpty() && metaChildUncast.getElementName().equals("meta")) {
|
||||
BaseRuntimeElementDefinition<?> metaChild = metaChildUncast.getChildByName("meta");
|
||||
if (IBaseMetaType.class.isAssignableFrom(metaChild.getImplementingClass())) {
|
||||
IBaseMetaType newType = (IBaseMetaType) metaChild.newInstance();
|
||||
theValues = Collections.singletonList(newType);
|
||||
}
|
||||
}
|
||||
|
||||
if (theValues.size() == 1 && theValues.get(0) instanceof IBaseMetaType) {
|
||||
|
||||
IBaseMetaType metaValue = (IBaseMetaType) theValues.get(0);
|
||||
try {
|
||||
metaValue = (IBaseMetaType) metaValue.getClass().getMethod("copy").invoke(metaValue);
|
||||
} catch (Exception e) {
|
||||
throw new InternalErrorException("Failed to duplicate meta", e);
|
||||
}
|
||||
|
||||
if (isBlank(metaValue.getVersionId())) {
|
||||
if (theResource.getIdElement().hasVersionIdPart()) {
|
||||
metaValue.setVersionId(theResource.getIdElement().getVersionIdPart());
|
||||
}
|
||||
}
|
||||
|
||||
filterCodingsWithNoCodeOrSystem(metaValue.getTag());
|
||||
filterCodingsWithNoCodeOrSystem(metaValue.getSecurity());
|
||||
|
||||
if (shouldAddSubsettedTag()) {
|
||||
IBaseCoding coding = metaValue.addTag();
|
||||
coding.setCode(Constants.TAG_SUBSETTED_CODE);
|
||||
coding.setSystem(Constants.TAG_SUBSETTED_SYSTEM);
|
||||
coding.setDisplay(subsetDescription());
|
||||
}
|
||||
|
||||
return Collections.singletonList(metaValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return theValues;
|
||||
}
|
||||
|
||||
|
@ -656,6 +661,10 @@ public abstract class BaseParser implements IParser {
|
|||
return isSummaryMode() || isSuppressNarratives();
|
||||
}
|
||||
|
||||
private String subsetDescription() {
|
||||
return "Resource encoded in summary mode";
|
||||
}
|
||||
|
||||
protected void throwExceptionForUnknownChildType(BaseRuntimeChildDefinition nextChild, Class<? extends IBase> theType) {
|
||||
if (nextChild instanceof BaseRuntimeDeclaredChildDefinition) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
|
|
|
@ -531,7 +531,7 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
BaseRuntimeChildDefinition nextChild = nextChildElem.getDef();
|
||||
if (nextChild instanceof RuntimeChildNarrativeDefinition) {
|
||||
INarrativeGenerator gen = myContext.getNarrativeGenerator();
|
||||
if (gen != null) {
|
||||
if (gen != null && theResource instanceof IResource) {
|
||||
BaseNarrativeDt<?> narr = ((IResource) theResource).getText();
|
||||
if (narr.getDiv().isEmpty()) {
|
||||
gen.generateNarrative(theResDef.getResourceProfile(), theResource, narr);
|
||||
|
@ -552,7 +552,7 @@ public class JsonParser extends BaseParser implements IParser {
|
|||
}
|
||||
|
||||
List<? extends IBase> values = nextChild.getAccessor().getValues(theNextValue);
|
||||
values = super.preProcessValues(nextChild, values);
|
||||
values = super.preProcessValues(nextChild, theResource, values);
|
||||
|
||||
if (values == null || values.isEmpty()) {
|
||||
continue;
|
||||
|
|
|
@ -35,8 +35,11 @@ import javax.xml.stream.events.XMLEvent;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBinary;
|
||||
import org.hl7.fhir.instance.model.api.IBaseCoding;
|
||||
import org.hl7.fhir.instance.model.api.IBaseElement;
|
||||
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||
import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
|
||||
|
@ -147,11 +150,7 @@ class ParserState<T> {
|
|||
IBase newChildInstance;
|
||||
try {
|
||||
IFhirVersion version;
|
||||
if (theTarget instanceof IResource) {
|
||||
version = ((IResource) theTarget).getStructureFhirVersionEnum().getVersionImplementation();
|
||||
} else {
|
||||
version = FhirVersionEnum.DSTU2_HL7ORG.getVersionImplementation();
|
||||
}
|
||||
version = theTarget.getStructureFhirVersionEnum().getVersionImplementation();
|
||||
newChildInstance = version.getResourceReferenceType().newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
throw new ConfigurationException("Failed to instantiate " + myContext.getVersion().getResourceReferenceType(), e);
|
||||
|
@ -234,10 +233,10 @@ class ParserState<T> {
|
|||
throws DataFormatException {
|
||||
ParserState<T> retVal = new ParserState<T>(theContext, theJsonMode, theErrorHandler);
|
||||
if (theResourceType == null) {
|
||||
if (theContext.getVersion().getVersion() != FhirVersionEnum.DSTU2_HL7ORG) {
|
||||
retVal.push(retVal.new PreResourceStateHapi(theResourceType));
|
||||
} else {
|
||||
if (theContext.getVersion().getVersion().isRi()) {
|
||||
retVal.push(retVal.new PreResourceStateHl7Org(theResourceType));
|
||||
} else {
|
||||
retVal.push(retVal.new PreResourceStateHapi(theResourceType));
|
||||
}
|
||||
} else {
|
||||
if (IResource.class.isAssignableFrom(theResourceType)) {
|
||||
|
@ -1409,7 +1408,7 @@ class ParserState<T> {
|
|||
private class ContainedResourcesStateHl7Org extends PreResourceState {
|
||||
|
||||
public ContainedResourcesStateHl7Org(PreResourceState thePreResourcesState) {
|
||||
super(thePreResourcesState, FhirVersionEnum.DSTU2_HL7ORG);
|
||||
super(thePreResourcesState, thePreResourcesState.myParentVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1664,11 +1663,11 @@ class ParserState<T> {
|
|||
return;
|
||||
}
|
||||
case RESOURCE: {
|
||||
if (myInstance instanceof IResource || myInstance instanceof IElement) {
|
||||
ParserState<T>.PreResourceStateHapi state = new PreResourceStateHapi(myInstance, child.getMutator(), null);
|
||||
if (myInstance instanceof IAnyResource || myInstance instanceof IBaseBackboneElement) {
|
||||
ParserState<T>.PreResourceStateHl7Org state = new PreResourceStateHl7Org(myInstance, child.getMutator(), null);
|
||||
push(state);
|
||||
} else {
|
||||
ParserState<T>.PreResourceStateHl7Org state = new PreResourceStateHl7Org(myInstance, child.getMutator(), null);
|
||||
ParserState<T>.PreResourceStateHapi state = new PreResourceStateHapi(myInstance, child.getMutator(), null);
|
||||
push(state);
|
||||
}
|
||||
return;
|
||||
|
@ -1757,7 +1756,7 @@ class ParserState<T> {
|
|||
case RESOURCE_REF: {
|
||||
ICompositeType newChildInstance = (ICompositeType) newResourceReferenceDt(getPreResourceState().myInstance);
|
||||
myExtension.setValue(newChildInstance);
|
||||
if (myContext.getVersion().getVersion().equals(FhirVersionEnum.DSTU2_HL7ORG)) {
|
||||
if (myContext.getVersion().getVersion().isRi()) {
|
||||
ParserState<T>.ResourceReferenceStateHl7Org newState = new ResourceReferenceStateHl7Org(getPreResourceState(), (IBaseReference) newChildInstance);
|
||||
push(newState);
|
||||
} else {
|
||||
|
@ -1788,7 +1787,7 @@ class ParserState<T> {
|
|||
|
||||
private class SecurityLabelElementStateHapi extends ElementCompositeState {
|
||||
|
||||
public SecurityLabelElementStateHapi(ParserState<T>.PreResourceState thePreResourceState, BaseRuntimeElementCompositeDefinition<?> theDef, BaseCodingDt codingDt) {
|
||||
public SecurityLabelElementStateHapi(ParserState<T>.PreResourceState thePreResourceState, BaseRuntimeElementCompositeDefinition<?> theDef, IBase codingDt) {
|
||||
super(thePreResourceState, theDef, codingDt);
|
||||
}
|
||||
|
||||
|
@ -1824,12 +1823,12 @@ class ParserState<T> {
|
|||
myMap.put(ResourceMetadataKeyEnum.UPDATED, updated);
|
||||
} else if (theLocalPart.equals("security")) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<BaseCodingDt> securityLabels = (List<BaseCodingDt>) myMap.get(ResourceMetadataKeyEnum.SECURITY_LABELS);
|
||||
List<IBase> securityLabels = (List<IBase>) myMap.get(ResourceMetadataKeyEnum.SECURITY_LABELS);
|
||||
if (securityLabels == null) {
|
||||
securityLabels = new ArrayList<BaseCodingDt>();
|
||||
securityLabels = new ArrayList<IBase>();
|
||||
myMap.put(ResourceMetadataKeyEnum.SECURITY_LABELS, securityLabels);
|
||||
}
|
||||
BaseCodingDt securityLabel = myContext.getVersion().newCodingDt();
|
||||
IBase securityLabel = myContext.getVersion().newCodingDt();
|
||||
BaseRuntimeElementCompositeDefinition<?> codinfDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition(securityLabel.getClass());
|
||||
push(new SecurityLabelElementStateHapi(getPreResourceState(), codinfDef, securityLabel));
|
||||
securityLabels.add(securityLabel);
|
||||
|
|
|
@ -600,7 +600,7 @@ public class XmlParser extends BaseParser implements IParser {
|
|||
} else {
|
||||
|
||||
List<? extends IBase> values = nextChild.getAccessor().getValues(theElement);
|
||||
values = super.preProcessValues(nextChild, values);
|
||||
values = super.preProcessValues(nextChild, theResource, values);
|
||||
|
||||
if (values == null || values.isEmpty()) {
|
||||
continue;
|
||||
|
|
|
@ -23,8 +23,9 @@ package ca.uhn.fhir.rest.annotation;
|
|||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.rest.param.CompositeParam;
|
||||
import ca.uhn.fhir.rest.param.ReferenceParam;
|
||||
//import ca.uhn.fhir.testmodel.Patient; // TODO: qualify this correctly
|
||||
|
@ -116,5 +117,5 @@ public @interface OptionalParam {
|
|||
* this value must not be populated.
|
||||
* </p>
|
||||
*/
|
||||
Class<? extends IResource>[] targetTypes() default {};
|
||||
Class<? extends IBaseResource>[] targetTypes() default {};
|
||||
}
|
||||
|
|
|
@ -23,8 +23,9 @@ package ca.uhn.fhir.rest.annotation;
|
|||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.rest.param.CompositeParam;
|
||||
import ca.uhn.fhir.rest.param.ReferenceParam;
|
||||
//import ca.uhn.fhir.testmodel.Patient; // TODO: qualify this correctly
|
||||
|
@ -97,6 +98,6 @@ public @interface RequiredParam {
|
|||
* If the parameter annotated with this annotation is not a {@link ReferenceParam}, this value must not be populated.
|
||||
* </p>
|
||||
*/
|
||||
Class<? extends IResource>[] targetTypes() default {};
|
||||
Class<? extends IBaseResource>[] targetTypes() default {};
|
||||
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class MethodOutcome {
|
|||
* If not null, indicates whether the resource was created (as opposed to being updated). This is generally not needed, since the server can assume based on the method being called
|
||||
* whether the result was a creation or an update. However, it can be useful if you are implementing an update method that does a create if the ID doesn't already exist.
|
||||
*/
|
||||
public MethodOutcome(IdDt theId, Boolean theCreated) {
|
||||
public MethodOutcome(IIdType theId, Boolean theCreated) {
|
||||
myId = theId;
|
||||
myCreated = theCreated;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class MethodOutcome {
|
|||
* @param theBaseOperationOutcome
|
||||
* The operation outcome to return with the response (or null for none)
|
||||
*/
|
||||
public MethodOutcome(IdDt theId, IBaseOperationOutcome theBaseOperationOutcome) {
|
||||
public MethodOutcome(IIdType theId, IBaseOperationOutcome theBaseOperationOutcome) {
|
||||
myId = theId;
|
||||
myOperationOutcome = theBaseOperationOutcome;
|
||||
}
|
||||
|
@ -82,17 +82,17 @@ public class MethodOutcome {
|
|||
* If not null, indicates whether the resource was created (as opposed to being updated). This is generally not needed, since the server can assume based on the method being called
|
||||
* whether the result was a creation or an update. However, it can be useful if you are implementing an update method that does a create if the ID doesn't already exist.
|
||||
*/
|
||||
public MethodOutcome(IdDt theId, IBaseOperationOutcome theBaseOperationOutcome, Boolean theCreated) {
|
||||
public MethodOutcome(IIdType theId, IBaseOperationOutcome theBaseOperationOutcome, Boolean theCreated) {
|
||||
myId = theId;
|
||||
myOperationOutcome = theBaseOperationOutcome;
|
||||
myCreated = theCreated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use the constructor which accepts a single IdDt parameter, and include the logical ID and version ID in that IdDt instance
|
||||
* @deprecated Use the constructor which accepts a single IIdType parameter, and include the logical ID and version ID in that IIdType instance
|
||||
*/
|
||||
@Deprecated
|
||||
public MethodOutcome(IdDt theId, IdDt theVersionId) {
|
||||
public MethodOutcome(IIdType theId, IdDt theVersionId) {
|
||||
myId = theId;
|
||||
myVersionId = theVersionId;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class MethodOutcome {
|
|||
* @deprecated Use the constructor which accepts a single IdDt parameter, and include the logical ID and version ID in that IdDt instance
|
||||
*/
|
||||
@Deprecated
|
||||
public MethodOutcome(IdDt theId, IdDt theVersionId, IBaseOperationOutcome theBaseOperationOutcome) {
|
||||
public MethodOutcome(IIdType theId, IdDt theVersionId, IBaseOperationOutcome theBaseOperationOutcome) {
|
||||
myId = theId;
|
||||
myVersionId = theVersionId;
|
||||
myOperationOutcome = theBaseOperationOutcome;
|
||||
|
@ -175,7 +175,7 @@ public class MethodOutcome {
|
|||
* @param theId
|
||||
* The ID of the created/updated resource
|
||||
*/
|
||||
public void setId(IdDt theId) {
|
||||
public void setId(IIdType theId) {
|
||||
myId = theId;
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ public class MethodOutcome {
|
|||
}
|
||||
|
||||
/**
|
||||
* @deprecated Put the ID and version ID into the same IdDt instance and pass it to {@link #setId(IdDt)}
|
||||
* @deprecated Put the ID and version ID into the same IdDt instance and pass it to {@link #setId(IIdType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setVersionId(IdDt theVersionId) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package ca.uhn.fhir.rest.client;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
|
@ -47,6 +49,7 @@ import org.apache.http.client.methods.CloseableHttpResponse;
|
|||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
@ -71,6 +74,7 @@ import ca.uhn.fhir.rest.method.MethodUtil;
|
|||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||
import ca.uhn.fhir.util.OperationOutcomeUtil;
|
||||
|
||||
public abstract class BaseClient implements IRestfulClient {
|
||||
|
||||
|
@ -284,7 +288,7 @@ public abstract class BaseClient implements IRestfulClient {
|
|||
}
|
||||
|
||||
String message = "HTTP " + response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase();
|
||||
BaseOperationOutcome oo = null;
|
||||
IBaseOperationOutcome oo = null;
|
||||
if (Constants.CT_TEXT.equals(mimeType)) {
|
||||
message = message + ": " + body;
|
||||
} else {
|
||||
|
@ -293,9 +297,10 @@ public abstract class BaseClient implements IRestfulClient {
|
|||
IParser p = enc.newParser(theContext);
|
||||
try {
|
||||
// TODO: handle if something other than OO comes back
|
||||
oo = (BaseOperationOutcome) p.parseResource(body);
|
||||
if (oo.getIssueFirstRep().getDetailsElement().isEmpty() == false) {
|
||||
message = message + ": " + oo.getIssueFirstRep().getDetailsElement().getValue();
|
||||
oo = (IBaseOperationOutcome) p.parseResource(body);
|
||||
String details = OperationOutcomeUtil.getFirstIssueDetails(getFhirContext(), oo);
|
||||
if (isNotBlank(details)) {
|
||||
message = message + ": " + details;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ourLog.debug("Failed to process OperationOutcome response");
|
||||
|
|
|
@ -1798,7 +1798,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
|
|||
}
|
||||
}
|
||||
|
||||
if (myReturnBundleType == null && myContext.getVersion().getVersion().equals(FhirVersionEnum.DSTU2_HL7ORG)) {
|
||||
if (myReturnBundleType == null && myContext.getVersion().getVersion().isRi()) {
|
||||
throw new IllegalArgumentException("When using the client with HL7.org structures, you must specify "
|
||||
+ "the bundle return type for the client by adding \".returnBundle(org.hl7.fhir.instance.model.Bundle.class)\" to your search method call before the \".execute()\" method");
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ abstract class BaseAddOrDeleteTagsMethodBinding extends BaseMethodBinding<Void>
|
|||
|
||||
myResourceName = theConetxt.getResourceDefinition(myType).getName();
|
||||
|
||||
myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod);
|
||||
myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod, getContext());
|
||||
myVersionIdParamIndex = MethodUtil.findVersionIdParameterIndex(theMethod);
|
||||
myTagListParamIndex = MethodUtil.findTagListParameterIndex(theMethod);
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -267,12 +268,14 @@ abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<Metho
|
|||
}
|
||||
}
|
||||
|
||||
protected static void parseContentLocation(MethodOutcome theOutcomeToPopulate, String theResourceName, String theLocationHeader) {
|
||||
protected static void parseContentLocation(FhirContext theContext, MethodOutcome theOutcomeToPopulate, String theResourceName, String theLocationHeader) {
|
||||
if (StringUtils.isBlank(theLocationHeader)) {
|
||||
return;
|
||||
}
|
||||
|
||||
theOutcomeToPopulate.setId(new IdDt(theLocationHeader));
|
||||
IIdType id = theContext.getVersion().newIdType();
|
||||
id.setValue(theLocationHeader);
|
||||
theOutcomeToPopulate.setId(id);
|
||||
|
||||
String resourceNamePart = "/" + theResourceName + "/";
|
||||
int resourceIndex = theLocationHeader.lastIndexOf(resourceNamePart);
|
||||
|
|
|
@ -75,7 +75,7 @@ abstract class BaseOutcomeReturningMethodBindingWithResourceParam extends BaseOu
|
|||
}
|
||||
|
||||
myResourceName = theContext.getResourceDefinition(myResourceType).getName();
|
||||
myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod);
|
||||
myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod, getContext());
|
||||
if (myIdParamIndex != null) {
|
||||
myIdParamType = (Class<? extends IIdType>) theMethod.getParameterTypes()[myIdParamIndex];
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class DeleteMethodBinding extends BaseOutcomeReturningMethodBinding {
|
|||
}
|
||||
}
|
||||
|
||||
myIdParameterIndex = MethodUtil.findIdParameterIndex(theMethod);
|
||||
myIdParameterIndex = MethodUtil.findIdParameterIndex(theMethod, getContext());
|
||||
if (myIdParameterIndex == null) {
|
||||
throw new ConfigurationException("Method '" + theMethod.getName() + "' on type '" + theMethod.getDeclaringClass().getCanonicalName() + "' has no parameter annotated with the @" + IdParam.class.getSimpleName() + " annotation");
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class DynamicSearchMethodBinding extends BaseResourceReturningMethodBindi
|
|||
myParamNames.add(next.getName());
|
||||
}
|
||||
|
||||
myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod);
|
||||
myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod, getContext());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ public class GetTagsMethodBinding extends BaseMethodBinding<TagList> {
|
|||
myResourceName = theConetxt.getResourceDefinition(myType).getName();
|
||||
}
|
||||
|
||||
myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod);
|
||||
myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod, getContext());
|
||||
myVersionIdParamIndex = MethodUtil.findVersionIdParameterIndex(theMethod);
|
||||
|
||||
if (myIdParamIndex != null && myType.equals(IResource.class)) {
|
||||
|
|
|
@ -55,7 +55,7 @@ public class HistoryMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
public HistoryMethodBinding(Method theMethod, FhirContext theConetxt, Object theProvider) {
|
||||
super(toReturnType(theMethod, theProvider), theMethod, theConetxt, theProvider);
|
||||
|
||||
myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod);
|
||||
myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod, getContext());
|
||||
|
||||
History historyAnnotation = theMethod.getAnnotation(History.class);
|
||||
Class<? extends IBaseResource> type = historyAnnotation.type();
|
||||
|
|
|
@ -322,8 +322,20 @@ public class MethodUtil {
|
|||
return MethodUtil.findParamAnnotationIndex(theMethod, ConditionalUrlParam.class);
|
||||
}
|
||||
|
||||
public static Integer findIdParameterIndex(Method theMethod) {
|
||||
return MethodUtil.findParamAnnotationIndex(theMethod, IdParam.class);
|
||||
public static Integer findIdParameterIndex(Method theMethod, FhirContext theContext) {
|
||||
Integer index = MethodUtil.findParamAnnotationIndex(theMethod, IdParam.class);
|
||||
if (index != null) {
|
||||
Class<?> paramType = theMethod.getParameterTypes()[index];
|
||||
if (IIdType.class.equals(paramType)) {
|
||||
return index;
|
||||
}
|
||||
boolean isRi = theContext.getVersion().getVersion().isRi();
|
||||
boolean usesHapiId = IdDt.class.equals(paramType);
|
||||
if (isRi == usesHapiId) {
|
||||
throw new ConfigurationException("Method uses the wrong Id datatype (IdDt / IdType) for the given context FHIR version: " + theMethod.toString());
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
public static Integer findParamAnnotationIndex(Method theMethod, Class<?> toFind) {
|
||||
|
@ -732,7 +744,7 @@ public class MethodUtil {
|
|||
MethodOutcome retVal = new MethodOutcome();
|
||||
if (locationHeaders != null && locationHeaders.size() > 0) {
|
||||
String locationHeader = locationHeaders.get(0);
|
||||
BaseOutcomeReturningMethodBinding.parseContentLocation(retVal, theResourceName, locationHeader);
|
||||
BaseOutcomeReturningMethodBinding.parseContentLocation(theContext, retVal, theResourceName, locationHeader);
|
||||
}
|
||||
if (theResponseStatusCode != Constants.STATUS_HTTP_204_NO_CONTENT) {
|
||||
EncodingEnum ct = EncodingEnum.forContentType(theResponseMimeType);
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.hl7.fhir.instance.model.api.IBase;
|
|||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseParameters;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
|
@ -42,7 +43,6 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
|
@ -76,7 +76,7 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
super(theReturnResourceType, theMethod, theContext, theProvider);
|
||||
|
||||
myIdempotent = theIdempotent;
|
||||
myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod);
|
||||
myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod, getContext());
|
||||
if (myIdParamIndex != null) {
|
||||
for (Annotation next : theMethod.getParameterAnnotations()[myIdParamIndex]) {
|
||||
if (next instanceof IdParam) {
|
||||
|
@ -230,7 +230,7 @@ public class OperationMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
public BaseHttpClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException {
|
||||
String id = null;
|
||||
if (myIdParamIndex != null) {
|
||||
IdDt idDt = (IdDt) theArgs[myIdParamIndex];
|
||||
IIdType idDt = (IIdType) theArgs[myIdParamIndex];
|
||||
id = idDt.getValue();
|
||||
}
|
||||
IBaseParameters parameters = (IBaseParameters) getContext().getResourceDefinition("Parameters").newInstance();
|
||||
|
|
|
@ -43,6 +43,7 @@ import ca.uhn.fhir.context.RuntimeChildPrimitiveDatatypeDefinition;
|
|||
import ca.uhn.fhir.context.RuntimePrimitiveDatatypeDefinition;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.i18n.HapiLocalizer;
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.ValidationModeEnum;
|
||||
|
@ -66,7 +67,7 @@ public class OperationParameter implements IParameter {
|
|||
private final String myOperationName;
|
||||
private Class<?> myParameterType;
|
||||
private String myParamType;
|
||||
private FhirContext myContext;
|
||||
private final FhirContext myContext;
|
||||
private boolean myAllowGet;
|
||||
|
||||
public OperationParameter(FhirContext theCtx, String theOperationName, OperationParam theOperationParam) {
|
||||
|
@ -83,6 +84,10 @@ public class OperationParameter implements IParameter {
|
|||
|
||||
|
||||
|
||||
protected FhirContext getContext() {
|
||||
return myContext;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
return myMax;
|
||||
}
|
||||
|
@ -102,6 +107,12 @@ public class OperationParameter implements IParameter {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initializeTypes(Method theMethod, Class<? extends Collection<?>> theOuterCollectionType, Class<? extends Collection<?>> theInnerCollectionType, Class<?> theParameterType) {
|
||||
if (getContext().getVersion().getVersion().isRi()) {
|
||||
if (IDatatype.class.isAssignableFrom(theParameterType)) {
|
||||
throw new ConfigurationException("Incorrect use of type " + theParameterType.getSimpleName() + " as parameter type for method when context is for version " + getContext().getVersion().getVersion().name() + " in method: " + theMethod.toString());
|
||||
}
|
||||
}
|
||||
|
||||
myParameterType = theParameterType;
|
||||
if (theInnerCollectionType != null) {
|
||||
myInnerCollectionType = CollectionBinder.getInstantiableCollectionType(theInnerCollectionType, myName);
|
||||
|
|
|
@ -72,7 +72,7 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding implem
|
|||
|
||||
Validate.notNull(theMethod, "Method must not be null");
|
||||
|
||||
Integer idIndex = MethodUtil.findIdParameterIndex(theMethod);
|
||||
Integer idIndex = MethodUtil.findIdParameterIndex(theMethod, getContext());
|
||||
Integer versionIdIndex = MethodUtil.findVersionIdParameterIndex(theMethod);
|
||||
|
||||
Class<?>[] parameterTypes = theMethod.getParameterTypes();
|
||||
|
|
|
@ -31,6 +31,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
|
@ -43,7 +45,7 @@ public abstract class RequestDetails {
|
|||
private String myCompartmentName;
|
||||
private String myCompleteUrl;
|
||||
private String myFhirServerBase;
|
||||
private IdDt myId;
|
||||
private IIdType myId;
|
||||
private String myOperation;
|
||||
private Map<String, String[]> myParameters;
|
||||
private String myRequestPath;
|
||||
|
@ -72,7 +74,7 @@ public abstract class RequestDetails {
|
|||
return myFhirServerBase;
|
||||
}
|
||||
|
||||
public IdDt getId() {
|
||||
public IIdType getId() {
|
||||
return myId;
|
||||
}
|
||||
|
||||
|
@ -132,7 +134,7 @@ public abstract class RequestDetails {
|
|||
myFhirServerBase = theFhirServerBase;
|
||||
}
|
||||
|
||||
public void setId(IdDt theId) {
|
||||
public void setId(IIdType theId) {
|
||||
myId = theId;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public class SearchMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
Search search = theMethod.getAnnotation(Search.class);
|
||||
this.myQueryName = StringUtils.defaultIfBlank(search.queryName(), null);
|
||||
this.myCompartmentName = StringUtils.defaultIfBlank(search.compartmentName(), null);
|
||||
this.myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod);
|
||||
this.myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod, getContext());
|
||||
this.myAllowUnknownParams = search.allowUnknownParams();
|
||||
|
||||
Description desc = theMethod.getAnnotation(Description.class);
|
||||
|
|
|
@ -30,13 +30,13 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterAnd;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.base.composite.BaseIdentifierDt;
|
||||
import ca.uhn.fhir.model.base.composite.BaseQuantityDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
|
@ -133,7 +133,7 @@ public class SearchParameter extends BaseQueryParameter {
|
|||
}
|
||||
|
||||
private List<Class<? extends IQueryParameterType>> myCompositeTypes;
|
||||
private List<Class<? extends IResource>> myDeclaredTypes;
|
||||
private List<Class<? extends IBaseResource>> myDeclaredTypes;
|
||||
private String myDescription;
|
||||
private String myName;
|
||||
private IParamBinder<?> myParamBinder;
|
||||
|
@ -168,7 +168,7 @@ public class SearchParameter extends BaseQueryParameter {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
public List<Class<? extends IResource>> getDeclaredTypes() {
|
||||
public List<Class<? extends IBaseResource>> getDeclaredTypes() {
|
||||
return Collections.unmodifiableList(myDeclaredTypes);
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ public class SearchParameter extends BaseQueryParameter {
|
|||
myCompositeTypes = Arrays.asList(theCompositeTypes);
|
||||
}
|
||||
|
||||
public void setDeclaredTypes(Class<? extends IResource>[] theTypes) {
|
||||
public void setDeclaredTypes(Class<? extends IBaseResource>[] theTypes) {
|
||||
myDeclaredTypes = Arrays.asList(theTypes);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ca.uhn.fhir.rest.method;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
|
@ -26,6 +25,8 @@ import java.lang.reflect.Method;
|
|||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
|
@ -44,7 +45,7 @@ public class UpdateMethodBinding extends BaseOutcomeReturningMethodBindingWithRe
|
|||
public UpdateMethodBinding(Method theMethod, FhirContext theContext, Object theProvider) {
|
||||
super(theMethod, theContext, Update.class, theProvider);
|
||||
|
||||
myIdParameterIndex = MethodUtil.findIdParameterIndex(theMethod);
|
||||
myIdParameterIndex = MethodUtil.findIdParameterIndex(theMethod, getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,9 +60,9 @@ public class UpdateMethodBinding extends BaseOutcomeReturningMethodBindingWithRe
|
|||
* Content-Location header, but we allow it in the PUT URL as well..
|
||||
*/
|
||||
String locationHeader = theRequest.getHeader(Constants.HEADER_CONTENT_LOCATION);
|
||||
IdDt id = theRequest.getId();
|
||||
IIdType id = theRequest.getId();
|
||||
if (isNotBlank(locationHeader)) {
|
||||
id = new IdDt(locationHeader);
|
||||
id.setValue(locationHeader);
|
||||
if (isNotBlank(id.getResourceType())) {
|
||||
if (!getResourceName().equals(id.getResourceType())) {
|
||||
throw new InvalidRequestException("Attempting to update '" + getResourceName() + "' but content-location header specifies different resource type '" + id.getResourceType() + "' - header value: " + locationHeader);
|
||||
|
@ -85,7 +86,7 @@ public class UpdateMethodBinding extends BaseOutcomeReturningMethodBindingWithRe
|
|||
|
||||
if (isNotBlank(locationHeader)) {
|
||||
MethodOutcome mo = new MethodOutcome();
|
||||
parseContentLocation(mo, getResourceName(), locationHeader);
|
||||
parseContentLocation(getContext(), mo, getResourceName(), locationHeader);
|
||||
if (mo.getId() == null || mo.getId().isEmpty()) {
|
||||
throw new InvalidRequestException("Invalid Content-Location header for resource " + getResourceName() + ": " + locationHeader);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class ValidateMethodBindingDstu1 extends BaseOutcomeReturningMethodBindin
|
|||
public ValidateMethodBindingDstu1(Method theMethod, FhirContext theContext, Object theProvider) {
|
||||
super(theMethod, theContext, Validate.class, theProvider);
|
||||
|
||||
myIdParameterIndex = MethodUtil.findIdParameterIndex(theMethod);
|
||||
myIdParameterIndex = MethodUtil.findIdParameterIndex(theMethod, getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.model.api.IQueryParameterOr;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
|
@ -63,6 +64,14 @@ public class DateParam extends DateTimeDt implements IQueryParameterType, IQuery
|
|||
setValueAsString(theDate != null ? theDate.getValueAsString() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public DateParam(QuantityCompararatorEnum theComparator, IPrimitiveType<Date> theDate) {
|
||||
myComparator = theComparator;
|
||||
setValueAsString(theDate != null ? theDate.getValueAsString() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
|
|
@ -24,6 +24,8 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.model.api.IQueryParameterAnd;
|
||||
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
|
@ -106,6 +108,20 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
|||
setRangeFromDatesInclusive(theLowerBound, theUpperBound);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor which takes two Dates representing the lower and upper bounds of the range (inclusive on both ends)
|
||||
*
|
||||
* @param theLowerBound
|
||||
* A qualified date param representing the lower date bound (optionally may include time), e.g.
|
||||
* "2011-02-22" or "2011-02-22T13:12:00Z". Will be treated inclusively. Either theLowerBound or theUpperBound may both be populated, or one may be null, but it is not valid for both to be null.
|
||||
* @param theUpperBound
|
||||
* A qualified date param representing the upper date bound (optionally may include time), e.g.
|
||||
* "2011-02-22" or "2011-02-22T13:12:00Z". Will be treated inclusively. Either theLowerBound or theUpperBound may both be populated, or one may be null, but it is not valid for both to be null.
|
||||
*/
|
||||
public DateRangeParam(IPrimitiveType<Date> theLowerBound, IPrimitiveType<Date> theUpperBound) {
|
||||
setRangeFromDatesInclusive(theLowerBound, theUpperBound);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor which takes two strings representing the lower and upper bounds of the range (inclusive on both ends)
|
||||
*
|
||||
|
@ -272,6 +288,21 @@ public class DateRangeParam implements IQueryParameterAnd<DateParam> {
|
|||
validateAndThrowDataFormatExceptionIfInvalid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the range from a pair of dates, inclusive on both ends
|
||||
*
|
||||
* @param theLowerBound
|
||||
* A qualified date param representing the lower date bound (optionally may include time), e.g.
|
||||
* "2011-02-22" or "2011-02-22T13:12:00Z". Will be treated inclusively. Either theLowerBound or theUpperBound may both be populated, or one may be null, but it is not valid for both to be null.
|
||||
* @param theUpperBound
|
||||
* A qualified date param representing the upper date bound (optionally may include time), e.g.
|
||||
* "2011-02-22" or "2011-02-22T13:12:00Z". Will be treated inclusively. Either theLowerBound or theUpperBound may both be populated, or one may be null, but it is not valid for both to be null.
|
||||
*/
|
||||
public void setRangeFromDatesInclusive(IPrimitiveType<Date> theLowerBound, IPrimitiveType<Date> theUpperBound) {
|
||||
myLowerBound = theLowerBound != null ? new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, theLowerBound) : null;
|
||||
myUpperBound = theUpperBound != null ? new DateParam(QuantityCompararatorEnum.LESSTHAN_OR_EQUALS, theUpperBound) : null;
|
||||
validateAndThrowDataFormatExceptionIfInvalid();
|
||||
}
|
||||
/**
|
||||
* Sets the range from a pair of dates, inclusive on both ends
|
||||
*
|
||||
|
|
|
@ -116,6 +116,16 @@ public class QuantityParam extends BaseParam implements IQueryParameterType {
|
|||
setValueAsQueryToken(null, theQuantity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param theQuantity
|
||||
* A quantity value (with no system or units), such as <code>100</code>
|
||||
*/
|
||||
public QuantityParam(long theQuantity) {
|
||||
setValueAsQueryToken(null, Long.toString(theQuantity));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
|
|
@ -50,12 +50,12 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.ProvidedResourceScanner;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.rest.annotation.Destroy;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
|
@ -64,7 +64,6 @@ import ca.uhn.fhir.rest.api.MethodOutcome;
|
|||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.method.BaseMethodBinding;
|
||||
import ca.uhn.fhir.rest.method.ConformanceMethodBinding;
|
||||
import ca.uhn.fhir.rest.method.PageMethodBinding;
|
||||
import ca.uhn.fhir.rest.method.ParseAction;
|
||||
import ca.uhn.fhir.rest.method.RequestDetails;
|
||||
import ca.uhn.fhir.rest.server.exceptions.AuthenticationException;
|
||||
|
@ -565,13 +564,14 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
Map<String, String[]> params = new HashMap<String, String[]>(theRequest.getParameterMap());
|
||||
requestDetails.setParameters(params);
|
||||
|
||||
IdDt id;
|
||||
IIdType id;
|
||||
populateRequestDetailsFromRequestPath(requestDetails, requestPath);
|
||||
|
||||
if (theRequestType == RequestTypeEnum.PUT) {
|
||||
String contentLocation = theRequest.getHeader(Constants.HEADER_CONTENT_LOCATION);
|
||||
if (contentLocation != null) {
|
||||
id = new IdDt(contentLocation);
|
||||
id = myFhirContext.getVersion().newIdType();
|
||||
id.setValue(contentLocation);
|
||||
requestDetails.setId(id);
|
||||
}
|
||||
}
|
||||
|
@ -876,7 +876,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
StringTokenizer tok = new StringTokenizer(theRequestPath, "/");
|
||||
String resourceName = null;
|
||||
|
||||
IdDt id = null;
|
||||
IIdType id = null;
|
||||
String operation = null;
|
||||
String compartment = null;
|
||||
if (tok.hasMoreTokens()) {
|
||||
|
@ -893,7 +893,8 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
if (partIsOperation(nextString)) {
|
||||
operation = nextString;
|
||||
} else {
|
||||
id = new IdDt(resourceName, UrlUtil.unescape(nextString));
|
||||
id = myFhirContext.getVersion().newIdType();
|
||||
id.setParts(null, resourceName, UrlUtil.unescape(nextString), null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -905,7 +906,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
if (id == null) {
|
||||
throw new InvalidRequestException("Don't know how to handle request path: " + theRequestPath);
|
||||
}
|
||||
id = new IdDt(resourceName, id.getIdPart(), UrlUtil.unescape(versionString));
|
||||
id.setParts(null, resourceName, id.getIdPart(), UrlUtil.unescape(versionString));
|
||||
} else {
|
||||
operation = Constants.PARAM_HISTORY;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
|
||||
public class DatatypeUtil {
|
||||
|
@ -46,9 +48,9 @@ public class DatatypeUtil {
|
|||
/**
|
||||
* Joins a list of strings with a single space (' ') between each string
|
||||
*/
|
||||
public static String joinStringsSpaceSeparated(List<StringDt> theStrings) {
|
||||
public static String joinStringsSpaceSeparated(List<? extends IPrimitiveType<String>> theStrings) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (StringDt next : theStrings) {
|
||||
for (IPrimitiveType<String> next : theStrings) {
|
||||
if (next.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -30,8 +30,12 @@ import java.util.TreeSet;
|
|||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||
import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
|
||||
import org.hl7.fhir.instance.model.api.IBaseHasModifierExtensions;
|
||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IDomainResource;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||
|
@ -68,6 +72,21 @@ public class FhirTerser {
|
|||
addUndeclaredExtensions(nextExt, theDefinition, theChildDefinition, theCallback);
|
||||
}
|
||||
}
|
||||
|
||||
if (theElement instanceof IBaseHasExtensions) {
|
||||
for (IBaseExtension<?, ?> nextExt : ((IBaseHasExtensions)theElement).getExtension()) {
|
||||
theCallback.acceptElement(nextExt.getValue(), null, theChildDefinition, theDefinition);
|
||||
addUndeclaredExtensions(nextExt, theDefinition, theChildDefinition, theCallback);
|
||||
}
|
||||
}
|
||||
|
||||
if (theElement instanceof IBaseHasModifierExtensions) {
|
||||
for (IBaseExtension<?, ?> nextExt : ((IBaseHasModifierExtensions)theElement).getModifierExtension()) {
|
||||
theCallback.acceptElement(nextExt.getValue(), null, theChildDefinition, theDefinition);
|
||||
addUndeclaredExtensions(nextExt, theDefinition, theChildDefinition, theCallback);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,6 +23,7 @@ package ca.uhn.fhir.util;
|
|||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||
|
@ -52,6 +53,4 @@ public interface IModelVisitor {
|
|||
*/
|
||||
void acceptUndeclaredExtension(ISupportsUndeclaredExtensions theContainingElement, List<String> thePathToElement, BaseRuntimeChildDefinition theChildDefinition, BaseRuntimeElementDefinition<?> theDefinition, ExtensionDt theNextExt);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -160,7 +160,8 @@ public class OperationOutcomeUtil {
|
|||
} else {
|
||||
detailsChild = issueElement.getChildByName("details");
|
||||
}
|
||||
BaseRuntimeElementDefinition<?> stringDef = theCtx.getElementDefinition("string");
|
||||
|
||||
BaseRuntimeElementDefinition<?> stringDef = detailsChild.getChildByName(detailsChild.getElementName());
|
||||
BaseRuntimeChildDefinition severityChild = issueElement.getChildByName("severity");
|
||||
BaseRuntimeChildDefinition locationChild = issueElement.getChildByName("location");
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class ParametersUtil {
|
|||
IBase parameter = paramChildElem.newInstance();
|
||||
paramChild.getMutator().addValue(theTargetResource, parameter);
|
||||
IPrimitiveType<?> value;
|
||||
if (theContext.getVersion().getVersion().equals(FhirVersionEnum.DSTU2_HL7ORG)) {
|
||||
if (theContext.getVersion().getVersion().isRi()) {
|
||||
value = (IPrimitiveType<?>) theContext.getElementDefinition("string").newInstance(theName);
|
||||
} else {
|
||||
value = new StringDt(theName);
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
|
||||
import ca.uhn.fhir.rest.gclient.StringClientParam;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
|
@ -20,15 +23,45 @@ package org.hl7.fhir.instance.model.api;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
|
||||
public interface IAnyResource extends IBaseResource {
|
||||
|
||||
/**
|
||||
* Search parameter constant for <b>_language</b>
|
||||
*/
|
||||
@SearchParamDefinition(name="_language", path="", description="The language of the resource", type="string" )
|
||||
public static final String SP_RES_LANGUAGE = "_language";
|
||||
|
||||
|
||||
/**
|
||||
* Search parameter constant for <b>_id</b>
|
||||
*/
|
||||
@SearchParamDefinition(name="_id", path="", description="The ID of the resource", type="string" )
|
||||
public static final String SP_RES_ID = "_id";
|
||||
|
||||
/**
|
||||
* <b>Fluent Client</b> search parameter constant for <b>_id</b>
|
||||
* <p>
|
||||
* Description: <b>the _id of a resource</b><br>
|
||||
* Type: <b>string</b><br>
|
||||
* Path: <b>Resource._id</b><br>
|
||||
* </p>
|
||||
*/
|
||||
public static final StringClientParam RES_ID = new StringClientParam(IAnyResource.SP_RES_ID);
|
||||
|
||||
String getId();
|
||||
|
||||
IAnyResource setId(String theId);
|
||||
|
||||
@Override
|
||||
IIdType getIdElement();
|
||||
|
||||
IPrimitiveType<String> getLanguageElement();
|
||||
|
||||
IBaseMetaType getMeta();
|
||||
|
||||
|
||||
public Object getUserData(String name);
|
||||
|
||||
@Override
|
||||
IAnyResource setId(String theId);
|
||||
|
||||
public void setUserData(String name, Object value);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
|
@ -21,6 +23,6 @@ package org.hl7.fhir.instance.model.api;
|
|||
*/
|
||||
|
||||
|
||||
public interface IBaseBackboneElement extends IBase, IBaseHasExtensions, IBaseHasModifierExtensions {
|
||||
public interface IBaseBackboneElement extends IElement, IBaseHasExtensions, IBaseHasModifierExtensions {
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.hl7.fhir.instance.model.api;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
public interface IBaseCoding {
|
||||
public interface IBaseCoding extends IBase {
|
||||
|
||||
String getCode();
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
|
@ -21,6 +23,6 @@ package org.hl7.fhir.instance.model.api;
|
|||
*/
|
||||
|
||||
|
||||
public interface IBaseDatatype extends IBase {
|
||||
public interface IBaseDatatype extends IElement {
|
||||
|
||||
}
|
||||
|
|
|
@ -45,4 +45,16 @@ public interface IBaseMetaType extends ICompositeType {
|
|||
|
||||
IBaseMetaType setVersionId(String theVersionId);
|
||||
|
||||
/**
|
||||
* Returns the first tag (if any) that has the given system and code, or returns
|
||||
* <code>null</code> if none
|
||||
*/
|
||||
IBaseCoding getTag(String theSystem, String theCode);
|
||||
|
||||
/**
|
||||
* Returns the first security label (if any) that has the given system and code, or returns
|
||||
* <code>null</code> if none
|
||||
*/
|
||||
IBaseCoding getSecurity(String theSystem, String theCode);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
package org.hl7.fhir.instance.model.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
|
@ -29,7 +37,17 @@ package org.hl7.fhir.instance.model.api;
|
|||
* the second are HAPI's Resource structures, e.g.
|
||||
* <code>ca.uhn.fhir.model.dstu.resource.Patient</code>)
|
||||
*/
|
||||
public interface IBaseResource extends IBase {
|
||||
public interface IBaseResource extends IBase, IElement {
|
||||
|
||||
/**
|
||||
* Include constant for <code>*</code> (return all includes)
|
||||
*/
|
||||
public static final Include INCLUDE_ALL = new Include("*", false).toLocked();
|
||||
|
||||
/**
|
||||
* Include set containing only {@link #INCLUDE_ALL}
|
||||
*/
|
||||
public static final Set<Include> WILDCARD_ALL_SET = Collections.unmodifiableSet(new HashSet<Include>(Arrays.asList(INCLUDE_ALL)));
|
||||
|
||||
IIdType getIdElement();
|
||||
|
||||
|
@ -37,4 +55,6 @@ public interface IBaseResource extends IBase {
|
|||
|
||||
IBaseResource setId(IIdType theId);
|
||||
|
||||
FhirVersionEnum getStructureFhirVersionEnum();
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ package org.hl7.fhir.instance.model.api;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public interface IDomainResource extends IAnyResource {
|
||||
public interface IDomainResource extends IAnyResource, IBaseHasExtensions, IBaseHasModifierExtensions {
|
||||
|
||||
List<? extends IAnyResource> getContained();
|
||||
|
||||
|
|
|
@ -135,4 +135,20 @@ public interface IIdType {
|
|||
|
||||
IIdType withVersion(String theVersion);
|
||||
|
||||
/**
|
||||
* Sets the value of this ID by combining all of the individual parts.
|
||||
* <p>
|
||||
* <b>Required parameters:</b> The following rules apply to the parameters of this method (in this case, populated means
|
||||
* a non-empty string and not populated means <code>null</code> or an empty string)
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>All values may be not populated</li>
|
||||
* <li>If <b>theVersionIdPart</b> is populated, <b>theResourceType</b> and <b>theIdPart</b> must be populated</li>
|
||||
* <li>If <b>theBaseUrl</b> is populated and <b>theIdPart</b> is populated, <b>theResourceType</b> must be populated</li>
|
||||
* </ul>
|
||||
*
|
||||
* @return Returns a reference to <code>this</code> for easy method chaining
|
||||
*/
|
||||
IIdType setParts(String theBaseUrl, String theResourceType, String theIdPart, String theVersionIdPart);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package ca.uhn.fhir.cli;
|
||||
|
||||
import org.hl7.fhir.instance.model.ValueSet;
|
||||
import org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent;
|
||||
import org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionComponent;
|
||||
import org.hl7.fhir.dstu21.hapi.validation.IValidationSupport;
|
||||
import org.hl7.fhir.dstu21.model.ValueSet;
|
||||
import org.hl7.fhir.dstu21.model.ValueSet.ConceptSetComponent;
|
||||
import org.hl7.fhir.dstu21.model.ValueSet.ValueSetExpansionComponent;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.ServerValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||
import ca.uhn.fhir.validation.IValidationSupport;
|
||||
|
||||
public class LoadingValidationSupport implements IValidationSupport {
|
||||
|
||||
|
|
|
@ -4,15 +4,13 @@ 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.leftPad;
|
||||
import static org.fusesource.jansi.Ansi.*;
|
||||
import static org.fusesource.jansi.Ansi.ansi;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.Option;
|
||||
|
@ -21,24 +19,20 @@ import org.apache.commons.cli.Options;
|
|||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
import org.fusesource.jansi.Ansi.Color;
|
||||
import org.hl7.fhir.dstu21.hapi.validation.DefaultProfileValidationSupport;
|
||||
import org.hl7.fhir.dstu21.hapi.validation.FhirInstanceValidator;
|
||||
import org.hl7.fhir.dstu21.hapi.validation.ValidationSupportChain;
|
||||
import org.hl7.fhir.dstu21.model.StructureDefinition;
|
||||
|
||||
import com.phloc.commons.io.file.FileUtils;
|
||||
import com.sun.tools.corba.se.idl.ParameterEntry;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu2.resource.StructureDefinition;
|
||||
import ca.uhn.fhir.rest.method.MethodUtil;
|
||||
import ca.uhn.fhir.rest.param.ParameterUtil;
|
||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.validation.DefaultProfileValidationSupport;
|
||||
import ca.uhn.fhir.validation.FhirInstanceValidator;
|
||||
import ca.uhn.fhir.validation.FhirValidator;
|
||||
import ca.uhn.fhir.validation.SingleValidationMessage;
|
||||
import ca.uhn.fhir.validation.ValidationResult;
|
||||
import ca.uhn.fhir.validation.ValidationSupportChain;
|
||||
import net.sf.saxon.expr.instruct.LocalParam;
|
||||
import net.sf.saxon.om.Chain;
|
||||
|
||||
public class ValidateCommand extends BaseCommand {
|
||||
|
||||
|
@ -112,7 +106,7 @@ public class ValidateCommand extends BaseCommand {
|
|||
throw new ParseException("Failed to load file '" + localProfile + "' - Error: " + e.toString());
|
||||
}
|
||||
|
||||
org.hl7.fhir.instance.model.StructureDefinition sd = (org.hl7.fhir.instance.model.StructureDefinition) MethodUtil.detectEncodingNoDefault(input).newParser(FhirContext.forDstu2Hl7Org()).parseResource(input);
|
||||
StructureDefinition sd = (StructureDefinition) MethodUtil.detectEncodingNoDefault(input).newParser(getFhirCtx()).parseResource(input);
|
||||
instanceValidator.setStructureDefintion(sd);
|
||||
}
|
||||
if (theCommandLine.hasOption("r")) {
|
||||
|
|
|
@ -404,6 +404,11 @@
|
|||
<artifactId>hapi-fhir-structures-dstu2.1</artifactId>
|
||||
<version>1.4-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-validation-resources-dstu2.1</artifactId>
|
||||
<version>1.4-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
|
|
@ -42,7 +42,7 @@ public class BaseDstu21Config extends BaseConfig {
|
|||
}
|
||||
|
||||
@Bean(name = "mySystemDaoDstu21", autowire = Autowire.BY_NAME)
|
||||
public IFhirSystemDao<ca.uhn.fhir.model.dstu21.resource.Bundle, ca.uhn.fhir.model.dstu21.composite.MetaDt> systemDaoDstu21() {
|
||||
public IFhirSystemDao<org.hl7.fhir.dstu21.model.Bundle, org.hl7.fhir.dstu21.model.Meta> systemDaoDstu21() {
|
||||
ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu21 retVal = new ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu21();
|
||||
return retVal;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class BaseDstu21Config extends BaseConfig {
|
|||
}
|
||||
|
||||
@Bean(name = "myJpaValidationSupportDstu21", autowire = Autowire.BY_NAME)
|
||||
public ca.uhn.fhir.jpa.dao.IJpaValidationSupport jpaValidationSupportDstu2() {
|
||||
public ca.uhn.fhir.jpa.dao.IJpaValidationSupportDstu21 jpaValidationSupportDstu2() {
|
||||
ca.uhn.fhir.jpa.dao.JpaValidationSupportDstu21 retVal = new ca.uhn.fhir.jpa.dao.JpaValidationSupportDstu21();
|
||||
return retVal;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public class BaseDstu2Config extends BaseConfig {
|
|||
}
|
||||
|
||||
@Bean(name = "myJpaValidationSupportDstu2", autowire = Autowire.BY_NAME)
|
||||
public ca.uhn.fhir.jpa.dao.IJpaValidationSupport jpaValidationSupportDstu2() {
|
||||
public ca.uhn.fhir.jpa.dao.IJpaValidationSupportDstu2 jpaValidationSupportDstu2() {
|
||||
ca.uhn.fhir.jpa.dao.JpaValidationSupportDstu2 retVal = new ca.uhn.fhir.jpa.dao.JpaValidationSupportDstu2();
|
||||
return retVal;
|
||||
}
|
||||
|
|
|
@ -53,8 +53,15 @@ import org.apache.commons.lang3.NotImplementedException;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.utils.URLEncodedUtils;
|
||||
import org.hl7.fhir.dstu21.model.IdType;
|
||||
import org.hl7.fhir.dstu21.model.StringType;
|
||||
import org.hl7.fhir.dstu21.model.Bundle.HTTPVerb;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseCoding;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IDomainResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -108,6 +115,7 @@ import ca.uhn.fhir.model.dstu.resource.BaseResource;
|
|||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.XhtmlDt;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntryTransactionMethodEnum;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
|
@ -167,7 +175,6 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
RESOURCE_META_AND_PARAMS = Collections.unmodifiableMap(resourceMetaAndParams);
|
||||
}
|
||||
|
||||
|
||||
public static final long INDEX_STATUS_INDEXED = Long.valueOf(1L);
|
||||
public static final long INDEX_STATUS_INDEXING_FAILED = Long.valueOf(2L);
|
||||
public static final String NS_JPA_PROFILE = "https://github.com/jamesagnew/hapi-fhir/ns/jpa/profile";
|
||||
|
@ -225,13 +232,12 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
myPlatformTransactionManager = thePlatformTransactionManager;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void setResourceDaos(List<IFhirResourceDao<?>> theResourceDaos) {
|
||||
// myResourceDaos = theResourceDaos;
|
||||
// }
|
||||
// @Override
|
||||
// public void setResourceDaos(List<IFhirResourceDao<?>> theResourceDaos) {
|
||||
// myResourceDaos = theResourceDaos;
|
||||
// }
|
||||
|
||||
|
||||
protected Set<ResourceLink> extractResourceLinks(ResourceTable theEntity, IResource theResource) {
|
||||
protected Set<ResourceLink> extractResourceLinks(ResourceTable theEntity, IBaseResource theResource) {
|
||||
Set<ResourceLink> retVal = new HashSet<ResourceLink>();
|
||||
|
||||
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
|
||||
|
@ -262,31 +268,31 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
}
|
||||
|
||||
ResourceLink nextEntity;
|
||||
if (nextObject instanceof BaseResourceReferenceDt) {
|
||||
BaseResourceReferenceDt nextValue = (BaseResourceReferenceDt) nextObject;
|
||||
if (nextObject instanceof IBaseReference) {
|
||||
IBaseReference nextValue = (IBaseReference) nextObject;
|
||||
if (nextValue.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (nextValue.getReference().isEmpty() || nextValue.getReference().getValue().startsWith("#")) {
|
||||
if (nextValue.getReferenceElement().isEmpty() || nextValue.getReferenceElement().getValue().startsWith("#")) {
|
||||
// This is a blank or contained resource reference
|
||||
continue;
|
||||
}
|
||||
|
||||
String typeString = nextValue.getReference().getResourceType();
|
||||
String typeString = nextValue.getReferenceElement().getResourceType();
|
||||
if (isBlank(typeString)) {
|
||||
throw new InvalidRequestException("Invalid resource reference found at path[" + nextPathsUnsplit + "] - Does not contain resource type - " + nextValue.getReference().getValue());
|
||||
throw new InvalidRequestException("Invalid resource reference found at path[" + nextPathsUnsplit + "] - Does not contain resource type - " + nextValue.getReferenceElement().getValue());
|
||||
}
|
||||
RuntimeResourceDefinition resourceDefinition;
|
||||
try {
|
||||
resourceDefinition = getContext().getResourceDefinition(typeString);
|
||||
} catch (DataFormatException e) {
|
||||
throw new InvalidRequestException("Invalid resource reference found at path[" + nextPathsUnsplit + "] - Resource type is unknown or not supported on this server - " + nextValue.getReference().getValue());
|
||||
throw new InvalidRequestException("Invalid resource reference found at path[" + nextPathsUnsplit + "] - Resource type is unknown or not supported on this server - " + nextValue.getReferenceElement().getValue());
|
||||
}
|
||||
|
||||
Class<? extends IBaseResource> type = resourceDefinition.getImplementingClass();
|
||||
String id = nextValue.getReference().getIdPart();
|
||||
String id = nextValue.getReferenceElement().getIdPart();
|
||||
if (StringUtils.isBlank(id)) {
|
||||
throw new InvalidRequestException("Invalid resource reference found at path[" + nextPathsUnsplit + "] - Does not contain resource ID - " + nextValue.getReference().getValue());
|
||||
throw new InvalidRequestException("Invalid resource reference found at path[" + nextPathsUnsplit + "] - Does not contain resource ID - " + nextValue.getReferenceElement().getValue());
|
||||
}
|
||||
|
||||
IFhirResourceDao<?> dao = getDao(type);
|
||||
|
@ -295,7 +301,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
b.append("This server (version ");
|
||||
b.append(myContext.getVersion().getVersion());
|
||||
b.append(") is not able to handle resources of type[");
|
||||
b.append(nextValue.getReference().getResourceType());
|
||||
b.append(nextValue.getReferenceElement().getResourceType());
|
||||
b.append("] - Valid resource types for this server: ");
|
||||
b.append(myResourceTypeToDao.keySet().toString());
|
||||
|
||||
|
@ -303,7 +309,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
}
|
||||
Long valueOf;
|
||||
try {
|
||||
valueOf = translateForcedIdToPid(nextValue.getReference());
|
||||
valueOf = translateForcedIdToPid(nextValue.getReferenceElement());
|
||||
} catch (ResourceNotFoundException e) {
|
||||
String resName = getContext().getResourceDefinition(type).getName();
|
||||
throw new InvalidRequestException("Resource " + resName + "/" + id + " not found, specified in path: " + nextPathsUnsplit);
|
||||
|
@ -316,7 +322,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
}
|
||||
|
||||
if (!typeString.equals(target.getResourceType())) {
|
||||
throw new UnprocessableEntityException("Resource contains reference to " + nextValue.getReference().getValue() + " but resource with ID " + nextValue.getReference().getIdPart() + " is actually of type " + target.getResourceType());
|
||||
throw new UnprocessableEntityException("Resource contains reference to " + nextValue.getReferenceElement().getValue() + " but resource with ID " + nextValue.getReferenceElement().getIdPart() + " is actually of type " + target.getResourceType());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -366,35 +372,35 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
protected Set<ResourceIndexedSearchParamDate> extractSearchParamDates(ResourceTable theEntity, IResource theResource) {
|
||||
protected Set<ResourceIndexedSearchParamDate> extractSearchParamDates(ResourceTable theEntity, IBaseResource theResource) {
|
||||
return mySearchParamExtractor.extractSearchParamDates(theEntity, theResource);
|
||||
}
|
||||
|
||||
protected Set<ResourceIndexedSearchParamNumber> extractSearchParamNumber(ResourceTable theEntity, IResource theResource) {
|
||||
protected Set<ResourceIndexedSearchParamNumber> extractSearchParamNumber(ResourceTable theEntity, IBaseResource theResource) {
|
||||
return mySearchParamExtractor.extractSearchParamNumber(theEntity, theResource);
|
||||
}
|
||||
|
||||
protected Set<ResourceIndexedSearchParamUri> extractSearchParamUri(ResourceTable theEntity, IResource theResource) {
|
||||
protected Set<ResourceIndexedSearchParamUri> extractSearchParamUri(ResourceTable theEntity, IBaseResource theResource) {
|
||||
return mySearchParamExtractor.extractSearchParamUri(theEntity, theResource);
|
||||
}
|
||||
|
||||
protected Set<ResourceIndexedSearchParamCoords> extractSearchParamCoords(ResourceTable theEntity, IResource theResource) {
|
||||
protected Set<ResourceIndexedSearchParamCoords> extractSearchParamCoords(ResourceTable theEntity, IBaseResource theResource) {
|
||||
return mySearchParamExtractor.extractSearchParamCoords(theEntity, theResource);
|
||||
}
|
||||
|
||||
protected Set<ResourceIndexedSearchParamQuantity> extractSearchParamQuantity(ResourceTable theEntity, IResource theResource) {
|
||||
protected Set<ResourceIndexedSearchParamQuantity> extractSearchParamQuantity(ResourceTable theEntity, IBaseResource theResource) {
|
||||
return mySearchParamExtractor.extractSearchParamQuantity(theEntity, theResource);
|
||||
}
|
||||
|
||||
protected Set<ResourceIndexedSearchParamString> extractSearchParamStrings(ResourceTable theEntity, IResource theResource) {
|
||||
protected Set<ResourceIndexedSearchParamString> extractSearchParamStrings(ResourceTable theEntity, IBaseResource theResource) {
|
||||
return mySearchParamExtractor.extractSearchParamStrings(theEntity, theResource);
|
||||
}
|
||||
|
||||
protected Set<BaseResourceIndexedSearchParam> extractSearchParamTokens(ResourceTable theEntity, IResource theResource) {
|
||||
protected Set<BaseResourceIndexedSearchParam> extractSearchParamTokens(ResourceTable theEntity, IBaseResource theResource) {
|
||||
return mySearchParamExtractor.extractSearchParamTokens(theEntity, theResource);
|
||||
}
|
||||
|
||||
private List<Object> extractValues(String thePath, IResource theResource) {
|
||||
private List<Object> extractValues(String thePath, IBaseResource theResource) {
|
||||
List<Object> values = new ArrayList<Object>();
|
||||
FhirTerser t = getContext().newTerser();
|
||||
String nextPathTrimmed = thePath.trim();
|
||||
|
@ -516,12 +522,12 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
}
|
||||
}
|
||||
|
||||
protected TagList getTags(Class<? extends IResource> theResourceType, IIdType theResourceId) {
|
||||
protected TagList getTags(Class<? extends IBaseResource> theResourceType, IIdType theResourceId) {
|
||||
String resourceName = null;
|
||||
if (theResourceType != null) {
|
||||
resourceName = toResourceName(theResourceType);
|
||||
if (theResourceId != null && theResourceId.hasVersionIdPart()) {
|
||||
IFhirResourceDao<? extends IResource> dao = getDao(theResourceType);
|
||||
IFhirResourceDao<? extends IBaseResource> dao = getDao(theResourceType);
|
||||
BaseHasResource entity = dao.readEntity(theResourceId);
|
||||
TagList retVal = new TagList();
|
||||
for (BaseTag next : entity.getTags()) {
|
||||
|
@ -622,7 +628,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
}
|
||||
throw e;
|
||||
}
|
||||
IResource resource = (IResource) toResource(type.getImplementingClass(), next, true);
|
||||
IBaseResource resource = (IBaseResource) toResource(type.getImplementingClass(), next, true);
|
||||
retVal.add(resource);
|
||||
}
|
||||
return retVal;
|
||||
|
@ -656,7 +662,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected void populateResourceIntoEntity(IResource theResource, ResourceTable theEntity) {
|
||||
protected void populateResourceIntoEntity(IBaseResource theResource, ResourceTable theEntity) {
|
||||
theEntity.setResourceType(toResourceName(theResource));
|
||||
|
||||
List<BaseResourceReferenceDt> refs = myContext.newTerser().getAllPopulatedChildElementsOfType(theResource, BaseResourceReferenceDt.class);
|
||||
|
@ -689,6 +695,36 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
|
||||
theEntity.setHasTags(false);
|
||||
|
||||
if (theResource instanceof IResource) {
|
||||
extractTagsHapi((IResource) theResource, theEntity, allDefs);
|
||||
} else {
|
||||
extractTagsRi((IAnyResource) theResource, theEntity, allDefs);
|
||||
}
|
||||
|
||||
ArrayList<ResourceTag> existingTags = new ArrayList<ResourceTag>();
|
||||
if (theEntity.isHasTags()) {
|
||||
existingTags.addAll(theEntity.getTags());
|
||||
}
|
||||
for (ResourceTag next : existingTags) {
|
||||
TagDefinition nextDef = next.getTag();
|
||||
if (!allDefs.contains(nextDef)) {
|
||||
if (shouldDroppedTagBeRemovedOnUpdate(theEntity, next)) {
|
||||
theEntity.getTags().remove(next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (theResource instanceof IResource) {
|
||||
String title = ResourceMetadataKeyEnum.TITLE.get((IResource) theResource);
|
||||
if (title != null && title.length() > BaseHasResource.MAX_TITLE_LENGTH) {
|
||||
title = title.substring(0, BaseHasResource.MAX_TITLE_LENGTH);
|
||||
}
|
||||
theEntity.setTitle(title);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void extractTagsHapi(IResource theResource, ResourceTable theEntity, Set<TagDefinition> allDefs) {
|
||||
TagList tagList = ResourceMetadataKeyEnum.TAG_LIST.get(theResource);
|
||||
if (tagList != null) {
|
||||
for (Tag next : tagList) {
|
||||
|
@ -718,26 +754,38 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
theEntity.setHasTags(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<ResourceTag> existingTags = new ArrayList<ResourceTag>();
|
||||
if (theEntity.isHasTags()) {
|
||||
existingTags.addAll(theEntity.getTags());
|
||||
}
|
||||
for (ResourceTag next : existingTags) {
|
||||
TagDefinition nextDef = next.getTag();
|
||||
if (!allDefs.contains(nextDef)) {
|
||||
if (shouldDroppedTagBeRemovedOnUpdate(theEntity, next)) {
|
||||
theEntity.getTags().remove(next);
|
||||
}
|
||||
private void extractTagsRi(IAnyResource theResource, ResourceTable theEntity, Set<TagDefinition> allDefs) {
|
||||
List<? extends IBaseCoding> tagList = theResource.getMeta().getTag();
|
||||
if (tagList != null) {
|
||||
for (IBaseCoding next : tagList) {
|
||||
TagDefinition tag = getTag(TagTypeEnum.TAG, next.getSystem(), next.getCode(), next.getDisplay());
|
||||
allDefs.add(tag);
|
||||
theEntity.addTag(tag);
|
||||
theEntity.setHasTags(true);
|
||||
}
|
||||
}
|
||||
|
||||
String title = ResourceMetadataKeyEnum.TITLE.get(theResource);
|
||||
if (title != null && title.length() > BaseHasResource.MAX_TITLE_LENGTH) {
|
||||
title = title.substring(0, BaseHasResource.MAX_TITLE_LENGTH);
|
||||
List<? extends IBaseCoding> securityLabels = theResource.getMeta().getSecurity();
|
||||
if (securityLabels != null) {
|
||||
for (IBaseCoding next : securityLabels) {
|
||||
TagDefinition tag = getTag(TagTypeEnum.SECURITY_LABEL, next.getSystem(), next.getCode(), next.getDisplay());
|
||||
allDefs.add(tag);
|
||||
theEntity.addTag(tag);
|
||||
theEntity.setHasTags(true);
|
||||
}
|
||||
}
|
||||
theEntity.setTitle(title);
|
||||
|
||||
List<? extends IPrimitiveType<String>> profiles = theResource.getMeta().getProfile();
|
||||
if (profiles != null) {
|
||||
for (IPrimitiveType<String> next : profiles) {
|
||||
TagDefinition tag = getTag(TagTypeEnum.PROFILE, NS_JPA_PROFILE, next.getValue(), null);
|
||||
allDefs.add(tag);
|
||||
theEntity.addTag(tag);
|
||||
theEntity.setHasTags(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -787,7 +835,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
return type;
|
||||
}
|
||||
|
||||
protected <R extends IResource> Set<Long> processMatchUrl(String theMatchUrl, Class<R> theResourceType) {
|
||||
protected <R extends IBaseResource> Set<Long> processMatchUrl(String theMatchUrl, Class<R> theResourceType) {
|
||||
RuntimeResourceDefinition resourceDef = getContext().getResourceDefinition(theResourceType);
|
||||
|
||||
SearchParameterMap paramMap = translateMatchUrl(theMatchUrl, resourceDef);
|
||||
|
@ -1034,23 +1082,23 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
}
|
||||
}
|
||||
|
||||
// protected MetaDt toMetaDt(Collection<TagDefinition> tagDefinitions) {
|
||||
// MetaDt retVal = new MetaDt();
|
||||
// for (TagDefinition next : tagDefinitions) {
|
||||
// switch (next.getTagType()) {
|
||||
// case PROFILE:
|
||||
// retVal.addProfile(next.getCode());
|
||||
// break;
|
||||
// case SECURITY_LABEL:
|
||||
// retVal.addSecurity().setSystem(next.getSystem()).setCode(next.getCode()).setDisplay(next.getDisplay());
|
||||
// break;
|
||||
// case TAG:
|
||||
// retVal.addTag().setSystem(next.getSystem()).setCode(next.getCode()).setDisplay(next.getDisplay());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// return retVal;
|
||||
// }
|
||||
// protected MetaDt toMetaDt(Collection<TagDefinition> tagDefinitions) {
|
||||
// MetaDt retVal = new MetaDt();
|
||||
// for (TagDefinition next : tagDefinitions) {
|
||||
// switch (next.getTagType()) {
|
||||
// case PROFILE:
|
||||
// retVal.addProfile(next.getCode());
|
||||
// break;
|
||||
// case SECURITY_LABEL:
|
||||
// retVal.addSecurity().setSystem(next.getSystem()).setCode(next.getCode()).setDisplay(next.getDisplay());
|
||||
// break;
|
||||
// case TAG:
|
||||
// retVal.addTag().setSystem(next.getSystem()).setCode(next.getCode()).setDisplay(next.getDisplay());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// return retVal;
|
||||
// }
|
||||
|
||||
@Autowired
|
||||
public void setContext(FhirContext theContext) {
|
||||
|
@ -1066,7 +1114,6 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
mySearchParamExtractor = new SearchParamExtractorDstu21(theContext);
|
||||
break;
|
||||
case DSTU2_HL7ORG:
|
||||
case DEV:
|
||||
throw new IllegalStateException("Don't know how to handle version: " + myContext.getVersion().getVersion());
|
||||
}
|
||||
}
|
||||
|
@ -1123,7 +1170,18 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
throw new DataFormatException(msg, e);
|
||||
}
|
||||
|
||||
IResource res = (IResource) retVal;
|
||||
if (retVal instanceof IResource) {
|
||||
IResource res = (IResource) retVal;
|
||||
retVal = populateResourceMetadataHapi(theResourceType, theEntity, theForHistoryOperation, res);
|
||||
} else {
|
||||
IAnyResource res = (IAnyResource) retVal;
|
||||
retVal = populateResourceMetadataRi(theResourceType, theEntity, theForHistoryOperation, res);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private <R extends IBaseResource> R populateResourceMetadataHapi(Class<R> theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation, IResource res) {
|
||||
R retVal = (R) res;
|
||||
if (theEntity.getDeleted() != null) {
|
||||
res = (IResource) myContext.getResourceDefinition(theResourceType).newInstance();
|
||||
retVal = (R) res;
|
||||
|
@ -1159,7 +1217,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
Collection<? extends BaseTag> tags = theEntity.getTags();
|
||||
if (theEntity.isHasTags()) {
|
||||
TagList tagList = new TagList();
|
||||
List<BaseCodingDt> securityLabels = new ArrayList<BaseCodingDt>();
|
||||
List<IBaseCoding> securityLabels = new ArrayList<IBaseCoding>();
|
||||
List<IdDt> profiles = new ArrayList<IdDt>();
|
||||
for (BaseTag next : tags) {
|
||||
switch (next.getTag().getTagType()) {
|
||||
|
@ -1167,7 +1225,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
profiles.add(new IdDt(next.getTag().getCode()));
|
||||
break;
|
||||
case SECURITY_LABEL:
|
||||
BaseCodingDt secLabel = myContext.getVersion().newCodingDt();
|
||||
IBaseCoding secLabel = (IBaseCoding) myContext.getVersion().newCodingDt();
|
||||
secLabel.setSystem(next.getTag().getSystem());
|
||||
secLabel.setCode(next.getTag().getCode());
|
||||
secLabel.setDisplay(next.getTag().getDisplay());
|
||||
|
@ -1182,21 +1240,88 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
ResourceMetadataKeyEnum.TAG_LIST.put(res, tagList);
|
||||
}
|
||||
if (securityLabels.size() > 0) {
|
||||
ResourceMetadataKeyEnum.SECURITY_LABELS.put(res, securityLabels);
|
||||
ResourceMetadataKeyEnum.SECURITY_LABELS.put(res, toBaseCodingList(securityLabels));
|
||||
}
|
||||
if (profiles.size() > 0) {
|
||||
ResourceMetadataKeyEnum.PROFILES.put(res, profiles);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
protected String toResourceName(Class<? extends IResource> theResourceType) {
|
||||
private <R extends IBaseResource> R populateResourceMetadataRi(Class<R> theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation, IAnyResource res) {
|
||||
R retVal = (R) res;
|
||||
if (theEntity.getDeleted() != null) {
|
||||
res = (IAnyResource) myContext.getResourceDefinition(theResourceType).newInstance();
|
||||
retVal = (R) res;
|
||||
ResourceMetadataKeyEnum.DELETED_AT.put(res, new InstantDt(theEntity.getDeleted()));
|
||||
if (theForHistoryOperation) {
|
||||
ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, HTTPVerb.DELETE.toCode());
|
||||
}
|
||||
} else if (theForHistoryOperation) {
|
||||
/*
|
||||
* If the create and update times match, this was when the resource was created so we should mark it as a POST.
|
||||
* Otherwise, it's a PUT.
|
||||
*/
|
||||
Date published = theEntity.getPublished().getValue();
|
||||
Date updated = theEntity.getUpdated().getValue();
|
||||
if (published.equals(updated)) {
|
||||
ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, HTTPVerb.POST.toCode());
|
||||
} else {
|
||||
ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, HTTPVerb.PUT.toCode());
|
||||
}
|
||||
}
|
||||
|
||||
res.getMeta().getTag().clear();
|
||||
res.getMeta().getProfile().clear();
|
||||
res.getMeta().getSecurity().clear();
|
||||
res.getMeta().setLastUpdated(null);
|
||||
res.getMeta().setVersionId(null);
|
||||
|
||||
populateResourceId(res, theEntity);
|
||||
|
||||
res.getMeta().setLastUpdated(theEntity.getUpdatedDate());
|
||||
IDao.RESOURCE_PID.put(res, theEntity.getId());
|
||||
|
||||
Collection<? extends BaseTag> tags = theEntity.getTags();
|
||||
if (theEntity.isHasTags()) {
|
||||
for (BaseTag next : tags) {
|
||||
switch (next.getTag().getTagType()) {
|
||||
case PROFILE:
|
||||
res.getMeta().addProfile(next.getTag().getCode());
|
||||
break;
|
||||
case SECURITY_LABEL:
|
||||
IBaseCoding sec = res.getMeta().addSecurity();
|
||||
sec.setSystem(next.getTag().getSystem());
|
||||
sec.setCode(next.getTag().getCode());
|
||||
sec.setDisplay(next.getTag().getDisplay());
|
||||
break;
|
||||
case TAG:
|
||||
IBaseCoding tag = res.getMeta().addTag();
|
||||
tag.setSystem(next.getTag().getSystem());
|
||||
tag.setCode(next.getTag().getCode());
|
||||
tag.setDisplay(next.getTag().getDisplay());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private static List<BaseCodingDt> toBaseCodingList(List<IBaseCoding> theSecurityLabels) {
|
||||
ArrayList<BaseCodingDt> retVal = new ArrayList<BaseCodingDt>(theSecurityLabels.size());
|
||||
for (IBaseCoding next : theSecurityLabels) {
|
||||
retVal.add((BaseCodingDt) next);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
protected String toResourceName(Class<? extends IBaseResource> theResourceType) {
|
||||
return myContext.getResourceDefinition(theResourceType).getName();
|
||||
}
|
||||
|
||||
protected String toResourceName(IResource theResource) {
|
||||
protected String toResourceName(IBaseResource theResource) {
|
||||
return myContext.getResourceDefinition(theResource).getName();
|
||||
}
|
||||
|
||||
|
@ -1238,7 +1363,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected ResourceTable updateEntity(final IResource theResource, ResourceTable theEntity, boolean theUpdateHistory, Date theDeletedTimestampOrNull, boolean thePerformIndexing, boolean theUpdateVersion, Date theUpdateTime) {
|
||||
protected ResourceTable updateEntity(final IBaseResource theResource, ResourceTable theEntity, boolean theUpdateHistory, Date theDeletedTimestampOrNull, boolean thePerformIndexing, boolean theUpdateVersion, Date theUpdateTime) {
|
||||
|
||||
/*
|
||||
* This should be the very first thing..
|
||||
|
@ -1350,22 +1475,26 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
|
||||
links = extractResourceLinks(theEntity, theResource);
|
||||
|
||||
/*
|
||||
* If the existing resource already has links and those match links we still want,
|
||||
* use them instead of removing them and re adding them
|
||||
/*
|
||||
* If the existing resource already has links and those match links we still want, use them instead of
|
||||
* removing them and re adding them
|
||||
*/
|
||||
for (Iterator<ResourceLink> existingLinkIter = existingResourceLinks.iterator(); existingLinkIter.hasNext(); ) {
|
||||
for (Iterator<ResourceLink> existingLinkIter = existingResourceLinks.iterator(); existingLinkIter.hasNext();) {
|
||||
ResourceLink nextExisting = existingLinkIter.next();
|
||||
if (links.remove(nextExisting)) {
|
||||
existingLinkIter.remove();
|
||||
links.add(nextExisting);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
populateResourceIntoEntity(theResource, theEntity);
|
||||
|
||||
theEntity.setUpdated(theUpdateTime);
|
||||
theEntity.setLanguage(theResource.getLanguage().getValue());
|
||||
if (theResource instanceof IResource) {
|
||||
theEntity.setLanguage(((IResource) theResource).getLanguage().getValue());
|
||||
} else {
|
||||
theEntity.setLanguage(((IAnyResource) theResource).getLanguageElement().getValue());
|
||||
}
|
||||
theEntity.setParamsString(stringParams);
|
||||
theEntity.setParamsStringPopulated(stringParams.isEmpty() == false);
|
||||
theEntity.setParamsToken(tokenParams);
|
||||
|
@ -1390,13 +1519,13 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
|
||||
populateResourceIntoEntity(theResource, theEntity);
|
||||
theEntity.setUpdated(theUpdateTime);
|
||||
theEntity.setLanguage(theResource.getLanguage().getValue());
|
||||
// theEntity.setLanguage(theResource.getLanguage().getValue());
|
||||
theEntity.setIndexStatus(null);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (theEntity.getId() == null) {
|
||||
myEntityManager.persist(theEntity);
|
||||
|
||||
|
@ -1481,12 +1610,20 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
myEntityManager.flush();
|
||||
|
||||
if (theResource != null) {
|
||||
theResource.setId(theEntity.getIdDt());
|
||||
populateResourceId(theResource, theEntity);
|
||||
}
|
||||
|
||||
return theEntity;
|
||||
}
|
||||
|
||||
private void populateResourceId(final IBaseResource theResource, BaseHasResource theEntity) {
|
||||
IIdType id = theEntity.getIdDt();
|
||||
if (getContext().getVersion().getVersion().isRi()) {
|
||||
id = new IdType(id.getValue());
|
||||
}
|
||||
theResource.setId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses may override to provide behaviour. Called when a resource has been inserved into the database for the
|
||||
* first time.
|
||||
|
@ -1524,13 +1661,20 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
* TODO
|
||||
*/
|
||||
protected void validateResourceForStorage(T theResource, ResourceTable theEntityToSave) {
|
||||
IResource res = (IResource) theResource;
|
||||
TagList tagList = ResourceMetadataKeyEnum.TAG_LIST.get(res);
|
||||
if (tagList != null) {
|
||||
Tag tag = tagList.getTag(Constants.TAG_SUBSETTED_SYSTEM, Constants.TAG_SUBSETTED_CODE);
|
||||
if (tag != null) {
|
||||
throw new UnprocessableEntityException("Resource contains the 'subsetted' tag, and must not be stored as it may contain a subset of available data");
|
||||
Object tag = null;
|
||||
if (theResource instanceof IResource) {
|
||||
IResource res = (IResource) theResource;
|
||||
TagList tagList = ResourceMetadataKeyEnum.TAG_LIST.get(res);
|
||||
if (tagList != null) {
|
||||
tag = tagList.getTag(Constants.TAG_SUBSETTED_SYSTEM, Constants.TAG_SUBSETTED_CODE);
|
||||
}
|
||||
} else {
|
||||
IAnyResource res = (IAnyResource)theResource;
|
||||
tag = res.getMeta().getTag(Constants.TAG_SUBSETTED_SYSTEM, Constants.TAG_SUBSETTED_CODE);
|
||||
}
|
||||
|
||||
if (tag != null) {
|
||||
throw new UnprocessableEntityException("Resource contains the 'subsetted' tag, and must not be stored as it may contain a subset of available data");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1547,26 +1691,49 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
return new String(out).toUpperCase();
|
||||
}
|
||||
|
||||
private static String parseNarrativeTextIntoWords(IResource theResource) {
|
||||
private static String parseNarrativeTextIntoWords(IBaseResource theResource) {
|
||||
|
||||
StringBuilder b = new StringBuilder();
|
||||
List<XMLEvent> xmlEvents = theResource.getText().getDiv().getValue();
|
||||
if (xmlEvents != null) {
|
||||
for (XMLEvent next : xmlEvents) {
|
||||
if (next.isCharacters()) {
|
||||
Characters characters = next.asCharacters();
|
||||
b.append(characters.getData()).append(" ");
|
||||
if (theResource instanceof IResource) {
|
||||
IResource resource = (IResource) theResource;
|
||||
List<XMLEvent> xmlEvents = resource.getText().getDiv().getValue();
|
||||
if (xmlEvents != null) {
|
||||
for (XMLEvent next : xmlEvents) {
|
||||
if (next.isCharacters()) {
|
||||
Characters characters = next.asCharacters();
|
||||
b.append(characters.getData()).append(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (theResource instanceof IDomainResource) {
|
||||
IDomainResource resource = (IDomainResource) theResource;
|
||||
try {
|
||||
String divAsString = resource.getText().getDivAsString();
|
||||
XhtmlDt xhtml = new XhtmlDt(divAsString);
|
||||
List<XMLEvent> xmlEvents = xhtml.getValue();
|
||||
if (xmlEvents != null) {
|
||||
for (XMLEvent next : xmlEvents) {
|
||||
if (next.isCharacters()) {
|
||||
Characters characters = next.asCharacters();
|
||||
b.append(characters.getData()).append(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new DataFormatException("Unable to convert DIV to string", e);
|
||||
}
|
||||
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
private String parseContentTextIntoWords(IResource theResource) {
|
||||
StringBuilder retVal = new StringBuilder();
|
||||
private String parseContentTextIntoWords(IBaseResource theResource) {
|
||||
StringBuilder retVal = new StringBuilder();
|
||||
@SuppressWarnings("rawtypes")
|
||||
List<IPrimitiveType> childElements = getContext().newTerser().getAllPopulatedChildElementsOfType(theResource, IPrimitiveType.class);
|
||||
for (@SuppressWarnings("rawtypes") IPrimitiveType nextType : childElements) {
|
||||
if (nextType instanceof StringDt) {
|
||||
for (@SuppressWarnings("rawtypes")
|
||||
IPrimitiveType nextType : childElements) {
|
||||
if (nextType instanceof StringDt || nextType.getClass().equals(StringType.class)) {
|
||||
String nextValue = nextType.getValueAsString();
|
||||
if (isNotBlank(nextValue)) {
|
||||
retVal.append(nextValue.replace("\n", " ").replace("\r", " "));
|
||||
|
@ -1584,10 +1751,11 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
|
|||
|
||||
IBaseOperationOutcome oo = OperationOutcomeUtil.newInstance(getContext());
|
||||
for (DeleteConflict next : theDeleteConflicts) {
|
||||
String msg = "Unable to delete " + next.getTargetId().toUnqualifiedVersionless().getValue() + " because at least one resource has a reference to this resource. First reference found was resource " + next.getTargetId().toUnqualifiedVersionless().getValue() + " in path " + next.getSourcePath();
|
||||
String msg = "Unable to delete " + next.getTargetId().toUnqualifiedVersionless().getValue() + " because at least one resource has a reference to this resource. First reference found was resource " + next.getTargetId().toUnqualifiedVersionless().getValue() + " in path "
|
||||
+ next.getSourcePath();
|
||||
OperationOutcomeUtil.addIssue(getContext(), oo, OO_SEVERITY_ERROR, msg, null, "processing");
|
||||
}
|
||||
|
||||
|
||||
throw new ResourceVersionConflictException("Delete failed because of constraint failure", oo);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@ import javax.persistence.NoResultException;
|
|||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.hl7.fhir.dstu21.model.IdType;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseCoding;
|
||||
import org.hl7.fhir.instance.model.api.IBaseMetaType;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
|
@ -87,7 +89,7 @@ import ca.uhn.fhir.util.FhirTerser;
|
|||
import ca.uhn.fhir.util.ObjectUtil;
|
||||
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseHapiFhirDao<T> implements IFhirResourceDao<T> {
|
||||
public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends BaseHapiFhirDao<T> implements IFhirResourceDao<T> {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseHapiFhirResourceDao.class);
|
||||
|
||||
|
@ -148,14 +150,14 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
|
||||
@Override
|
||||
public DaoMethodOutcome create(T theResource, String theIfNoneExist, boolean thePerformIndexing) {
|
||||
if (isNotBlank(theResource.getId().getIdPart())) {
|
||||
if (isNotBlank(theResource.getIdElement().getIdPart())) {
|
||||
if (getContext().getVersion().getVersion().equals(FhirVersionEnum.DSTU1)) {
|
||||
if (theResource.getId().isIdPartValidLong()) {
|
||||
String message = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithClientAssignedNumericId", theResource.getId().getIdPart());
|
||||
if (theResource.getIdElement().isIdPartValidLong()) {
|
||||
String message = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithClientAssignedNumericId", theResource.getIdElement().getIdPart());
|
||||
throw new InvalidRequestException(message, createErrorOperationOutcome(message));
|
||||
}
|
||||
} else {
|
||||
String message = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithClientAssignedId", theResource.getId().getIdPart());
|
||||
String message = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithClientAssignedId", theResource.getIdElement().getIdPart());
|
||||
throw new InvalidRequestException(message, createErrorOperationOutcome(message));
|
||||
}
|
||||
}
|
||||
|
@ -177,11 +179,11 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
public DaoMethodOutcome delete(IIdType theId) {
|
||||
List<DeleteConflict> deleteConflicts = new ArrayList<DeleteConflict>();
|
||||
StopWatch w = new StopWatch();
|
||||
|
||||
|
||||
ResourceTable savedEntity = delete(theId, deleteConflicts);
|
||||
|
||||
validateDeleteConflictsEmptyOrThrowException(deleteConflicts);
|
||||
|
||||
|
||||
ourLog.info("Processed delete on {} in {}ms", theId.getValue(), w.getMillisAndRestart());
|
||||
return toMethodOutcome(savedEntity, null);
|
||||
}
|
||||
|
@ -220,9 +222,9 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
List<DeleteConflict> deleteConflicts = new ArrayList<DeleteConflict>();
|
||||
|
||||
List<ResourceTable> deletedResources = deleteByUrl(theUrl, deleteConflicts);
|
||||
|
||||
|
||||
validateDeleteConflictsEmptyOrThrowException(deleteConflicts);
|
||||
|
||||
|
||||
if (deletedResources.isEmpty()) {
|
||||
throw new ResourceNotFoundException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "unableToDeleteNotFound", theUrl));
|
||||
}
|
||||
|
@ -244,7 +246,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
for (Long pid : resource) {
|
||||
ResourceTable entity = myEntityManager.find(ResourceTable.class, pid);
|
||||
retVal.add(entity);
|
||||
|
||||
|
||||
validateOkToDelete(deleteConflicts, entity);
|
||||
|
||||
// Notify interceptors
|
||||
|
@ -264,7 +266,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
@ -288,16 +290,16 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
}
|
||||
}
|
||||
|
||||
if (isNotBlank(theResource.getId().getIdPart())) {
|
||||
if (isValidPid(theResource.getId())) {
|
||||
if (isNotBlank(theResource.getIdElement().getIdPart())) {
|
||||
if (isValidPid(theResource.getIdElement())) {
|
||||
throw new UnprocessableEntityException("This server cannot create an entity with a user-specified numeric ID - Client should not specify an ID when creating a new resource, or should include at least one letter in the ID to force a client-defined ID");
|
||||
}
|
||||
createForcedIdIfNeeded(entity, theResource.getId());
|
||||
createForcedIdIfNeeded(entity, theResource.getIdElement());
|
||||
|
||||
if (entity.getForcedId() != null) {
|
||||
try {
|
||||
translateForcedIdToPid(theResource.getId());
|
||||
throw new UnprocessableEntityException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "duplicateCreateForcedId", theResource.getId().getIdPart()));
|
||||
translateForcedIdToPid(theResource.getIdElement());
|
||||
throw new UnprocessableEntityException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "duplicateCreateForcedId", theResource.getIdElement().getIdPart()));
|
||||
} catch (ResourceNotFoundException e) {
|
||||
// good, this ID doesn't exist so we can create it
|
||||
}
|
||||
|
@ -306,7 +308,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
}
|
||||
|
||||
// Notify interceptors
|
||||
ActionRequestDetails requestDetails = new ActionRequestDetails(theResource.getId(), toResourceName(theResource), theResource);
|
||||
ActionRequestDetails requestDetails = new ActionRequestDetails(theResource.getIdElement(), toResourceName(theResource), theResource);
|
||||
notifyInterceptors(RestOperationTypeEnum.CREATE, requestDetails);
|
||||
|
||||
// Perform actual DB update
|
||||
|
@ -389,7 +391,13 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
BaseHasResource entity = readEntity(theId.toVersionless(), false);
|
||||
validateResourceType(entity);
|
||||
currentTmp = toResource(myResourceType, entity, true);
|
||||
if (ResourceMetadataKeyEnum.UPDATED.get(currentTmp).after(end.getValue())) {
|
||||
Date lastUpdated;
|
||||
if (currentTmp instanceof IResource) {
|
||||
lastUpdated = ResourceMetadataKeyEnum.UPDATED.get((IResource) currentTmp).getValue();
|
||||
} else {
|
||||
lastUpdated = ((IAnyResource) currentTmp).getMeta().getLastUpdated();
|
||||
}
|
||||
if (lastUpdated.after(end.getValue())) {
|
||||
currentTmp = null;
|
||||
}
|
||||
} catch (ResourceNotFoundException e) {
|
||||
|
@ -660,7 +668,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
ourLog.info("Processed metaDeleteOperation on {} in {}ms", new Object[] { theResourceId.getValue(), w.getMillisAndRestart() });
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
MT retVal = (MT)metaGetOperation(theMetaDel.getClass(), theResourceId);
|
||||
MT retVal = (MT) metaGetOperation(theMetaDel.getClass(), theResourceId);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
@ -679,7 +687,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
protected <MT extends IBaseMetaType> MT toMetaDt(Class<MT> theType, Collection<TagDefinition> tagDefinitions) {
|
||||
MT retVal;
|
||||
try {
|
||||
|
@ -746,9 +754,9 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
* The resource that is about to be stored
|
||||
*/
|
||||
protected void preProcessResourceForStorage(T theResource) {
|
||||
if (theResource.getId().hasIdPart()) {
|
||||
if (!theResource.getId().isIdPartValid()) {
|
||||
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithInvalidId", theResource.getId().getIdPart()));
|
||||
if (theResource.getIdElement().hasIdPart()) {
|
||||
if (!theResource.getIdElement().isIdPartValid()) {
|
||||
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithInvalidId", theResource.getIdElement().getIdPart()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -773,7 +781,12 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
|
||||
T retVal = toResource(myResourceType, entity, false);
|
||||
|
||||
InstantDt deleted = ResourceMetadataKeyEnum.DELETED_AT.get(retVal);
|
||||
IPrimitiveType<Date> deleted;
|
||||
if (retVal instanceof IResource) {
|
||||
deleted = ResourceMetadataKeyEnum.DELETED_AT.get((IResource) retVal);
|
||||
} else {
|
||||
deleted = ResourceMetadataKeyEnum.DELETED_AT.get((IAnyResource) retVal);
|
||||
}
|
||||
if (deleted != null && !deleted.isEmpty()) {
|
||||
throw new ResourceGoneException("Resource was deleted at " + deleted.getValueAsString());
|
||||
}
|
||||
|
@ -887,7 +900,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
}
|
||||
return search(map);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IBundleProvider search(final SearchParameterMap theParams) {
|
||||
// Notify interceptors
|
||||
|
@ -927,7 +940,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Required
|
||||
public void setResourceType(Class<? extends IResource> theTableType) {
|
||||
public void setResourceType(Class<? extends IBaseResource> theTableType) {
|
||||
myResourceType = (Class<T>) theTableType;
|
||||
}
|
||||
|
||||
|
@ -939,18 +952,29 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
mySecondaryPrimaryKeyParamName = theSecondaryPrimaryKeyParamName;
|
||||
}
|
||||
|
||||
private DaoMethodOutcome toMethodOutcome(final BaseHasResource theEntity, IResource theResource) {
|
||||
private DaoMethodOutcome toMethodOutcome(final BaseHasResource theEntity, IBaseResource theResource) {
|
||||
DaoMethodOutcome outcome = new DaoMethodOutcome();
|
||||
outcome.setId(theEntity.getIdDt());
|
||||
|
||||
IIdType id = theEntity.getIdDt();
|
||||
if (getContext().getVersion().getVersion().isRi()) {
|
||||
id = new IdType(id.getValue());
|
||||
}
|
||||
|
||||
outcome.setId(id);
|
||||
outcome.setResource(theResource);
|
||||
if (theResource != null) {
|
||||
theResource.setId(theEntity.getIdDt());
|
||||
ResourceMetadataKeyEnum.UPDATED.put(theResource, theEntity.getUpdated());
|
||||
theResource.setId(id);
|
||||
if (theResource instanceof IResource) {
|
||||
ResourceMetadataKeyEnum.UPDATED.put((IResource) theResource, theEntity.getUpdated());
|
||||
} else {
|
||||
IBaseMetaType meta = ((IAnyResource) theResource).getMeta();
|
||||
meta.setLastUpdated(theEntity.getUpdatedDate());
|
||||
}
|
||||
}
|
||||
return outcome;
|
||||
}
|
||||
|
||||
private DaoMethodOutcome toMethodOutcome(final ResourceTable theEntity, IResource theResource) {
|
||||
private DaoMethodOutcome toMethodOutcome(final ResourceTable theEntity, IBaseResource theResource) {
|
||||
DaoMethodOutcome retVal = toMethodOutcome((BaseHasResource) theEntity, theResource);
|
||||
retVal.setEntity(theEntity);
|
||||
return retVal;
|
||||
|
@ -972,9 +996,6 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public DaoMethodOutcome update(T theResource) {
|
||||
return update(theResource, null);
|
||||
|
@ -1007,7 +1028,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
return create(theResource, null, thePerformIndexing);
|
||||
}
|
||||
} else {
|
||||
resourceId = theResource.getId();
|
||||
resourceId = theResource.getIdElement();
|
||||
if (resourceId == null || isBlank(resourceId.getIdPart())) {
|
||||
throw new InvalidRequestException("Can not update a resource with no ID");
|
||||
}
|
||||
|
@ -1015,7 +1036,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
entity = readEntityLatestVersion(resourceId);
|
||||
} catch (ResourceNotFoundException e) {
|
||||
if (resourceId.isIdPartValidLong()) {
|
||||
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithClientAssignedNumericId", theResource.getId().getIdPart()));
|
||||
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithClientAssignedNumericId", theResource.getIdElement().getIdPart()));
|
||||
}
|
||||
return doCreate(theResource, null, thePerformIndexing, new Date());
|
||||
}
|
||||
|
@ -1081,8 +1102,6 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
|
|||
theDeleteConflicts.add(new DeleteConflict(sourceId, sourcePath, targetId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void validateResourceType(BaseHasResource entity) {
|
||||
validateResourceType(entity, myResourceName);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ package ca.uhn.fhir.jpa.dao;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
|
@ -40,7 +42,7 @@ public class BaseSearchParamExtractor {
|
|||
return myContext;
|
||||
}
|
||||
|
||||
protected List<Object> extractValues(String thePaths, IResource theResource) {
|
||||
protected List<Object> extractValues(String thePaths, IBaseResource theResource) {
|
||||
List<Object> values = new ArrayList<Object>();
|
||||
String[] nextPathsSplit = thePaths.split("\\|");
|
||||
FhirTerser t = myContext.newTerser();
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package ca.uhn.fhir.jpa.dao;
|
||||
|
||||
import org.hl7.fhir.dstu21.model.Bundle;
|
||||
import org.hl7.fhir.dstu21.model.Bundle.BundleEntryComponent;
|
||||
import org.hl7.fhir.dstu21.model.Bundle.BundleType;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
|
@ -20,9 +24,6 @@ package ca.uhn.fhir.jpa.dao;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.model.dstu21.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Bundle.Entry;
|
||||
import ca.uhn.fhir.model.dstu21.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
|
||||
public class FhirResourceDaoBundleDstu21 extends FhirResourceDaoDstu21<Bundle> {
|
||||
|
@ -31,12 +32,12 @@ public class FhirResourceDaoBundleDstu21 extends FhirResourceDaoDstu21<Bundle> {
|
|||
protected void preProcessResourceForStorage(Bundle theResource) {
|
||||
super.preProcessResourceForStorage(theResource);
|
||||
|
||||
if (theResource.getTypeElement().getValueAsEnum() != BundleTypeEnum.DOCUMENT) {
|
||||
String message = "Unable to store a Bundle resource on this server with a Bundle.type value other than '" + BundleTypeEnum.DOCUMENT.getCode() + "' - Value was: " + (theResource.getTypeElement().getValueAsEnum() != null ? theResource.getTypeElement().getValueAsEnum().getCode() : "(missing)");
|
||||
if (theResource.getType() != BundleType.DOCUMENT) {
|
||||
String message = "Unable to store a Bundle resource on this server with a Bundle.type value other than '" + BundleType.DOCUMENT.toCode() + "' - Value was: " + (theResource.getType() != null ? theResource.getType().toCode() : "(missing)");
|
||||
throw new UnprocessableEntityException(message);
|
||||
}
|
||||
|
||||
for (Entry next : theResource.getEntry()) {
|
||||
for (BundleEntryComponent next : theResource.getEntry()) {
|
||||
next.setFullUrl((String)null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,10 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.instance.hapi.validation.DefaultProfileValidationSupport;
|
||||
import org.hl7.fhir.instance.hapi.validation.FhirInstanceValidator;
|
||||
import org.hl7.fhir.instance.hapi.validation.IValidationSupport;
|
||||
import org.hl7.fhir.instance.hapi.validation.ValidationSupportChain;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
@ -51,17 +55,12 @@ import ca.uhn.fhir.rest.api.ValidationModeEnum;
|
|||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
||||
import ca.uhn.fhir.util.FhirTerser;
|
||||
import ca.uhn.fhir.validation.DefaultProfileValidationSupport;
|
||||
import ca.uhn.fhir.validation.FhirInstanceValidator;
|
||||
import ca.uhn.fhir.validation.FhirValidator;
|
||||
import ca.uhn.fhir.validation.IValidationContext;
|
||||
import ca.uhn.fhir.validation.IValidationSupport;
|
||||
import ca.uhn.fhir.validation.IValidatorModule;
|
||||
import ca.uhn.fhir.validation.ValidationResult;
|
||||
import ca.uhn.fhir.validation.ValidationSupportChain;
|
||||
import net.sourceforge.cobertura.CoverageIgnore;
|
||||
|
||||
public class FhirResourceDaoDstu2<T extends IResource> extends BaseHapiFhirResourceDao<T> {
|
||||
|
|
|
@ -26,10 +26,17 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.dstu21.hapi.validation.FhirInstanceValidator;
|
||||
import org.hl7.fhir.dstu21.hapi.validation.IValidationSupport;
|
||||
import org.hl7.fhir.dstu21.model.IdType;
|
||||
import org.hl7.fhir.dstu21.model.OperationOutcome;
|
||||
import org.hl7.fhir.dstu21.model.OperationOutcome.IssueSeverity;
|
||||
import org.hl7.fhir.dstu21.model.OperationOutcome.OperationOutcomeIssueComponent;
|
||||
import org.hl7.fhir.dstu21.validation.IResourceValidator.BestPracticeWarningLevel;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.validation.IResourceValidator.BestPracticeWarningLevel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
||||
|
@ -38,12 +45,8 @@ import ca.uhn.fhir.context.RuntimeSearchParam;
|
|||
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.util.DeleteConflict;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||
import ca.uhn.fhir.model.dstu21.resource.OperationOutcome;
|
||||
import ca.uhn.fhir.model.dstu21.valueset.IssueSeverityEnum;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.ValidationModeEnum;
|
||||
|
@ -52,17 +55,13 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
||||
import ca.uhn.fhir.util.FhirTerser;
|
||||
import ca.uhn.fhir.validation.DefaultProfileValidationSupport;
|
||||
import ca.uhn.fhir.validation.FhirInstanceValidator;
|
||||
import ca.uhn.fhir.validation.FhirValidator;
|
||||
import ca.uhn.fhir.validation.IValidationContext;
|
||||
import ca.uhn.fhir.validation.IValidationSupport;
|
||||
import ca.uhn.fhir.validation.IValidatorModule;
|
||||
import ca.uhn.fhir.validation.ValidationResult;
|
||||
import ca.uhn.fhir.validation.ValidationSupportChain;
|
||||
import net.sourceforge.cobertura.CoverageIgnore;
|
||||
|
||||
public class FhirResourceDaoDstu21<T extends IResource> extends BaseHapiFhirResourceDao<T> {
|
||||
public class FhirResourceDaoDstu21<T extends IAnyResource> extends BaseHapiFhirResourceDao<T> {
|
||||
|
||||
@Autowired()
|
||||
@Qualifier("myJpaValidationSupportDstu21")
|
||||
|
@ -90,8 +89,9 @@ public class FhirResourceDaoDstu21<T extends IResource> extends BaseHapiFhirReso
|
|||
@Override
|
||||
protected IBaseOperationOutcome createOperationOutcome(String theSeverity, String theMessage) {
|
||||
OperationOutcome oo = new OperationOutcome();
|
||||
oo.getIssueFirstRep().getSeverityElement().setValue(theSeverity);
|
||||
oo.getIssueFirstRep().getDiagnosticsElement().setValue(theMessage);
|
||||
OperationOutcomeIssueComponent issue = oo.addIssue();
|
||||
issue.getSeverityElement().setValueAsString(theSeverity);
|
||||
issue.setDiagnostics(theMessage);
|
||||
return oo;
|
||||
}
|
||||
|
||||
|
@ -113,15 +113,15 @@ public class FhirResourceDaoDstu21<T extends IResource> extends BaseHapiFhirReso
|
|||
validateDeleteConflictsEmptyOrThrowException(deleteConflicts);
|
||||
|
||||
OperationOutcome oo = new OperationOutcome();
|
||||
oo.addIssue().setSeverity(IssueSeverityEnum.INFORMATION).setDiagnostics("Ok to delete");
|
||||
return new MethodOutcome(new IdDt(theId.getValue()), oo);
|
||||
oo.addIssue().setSeverity(IssueSeverity.INFORMATION).setDiagnostics("Ok to delete");
|
||||
return new MethodOutcome(new IdType(theId.getValue()), oo);
|
||||
}
|
||||
|
||||
FhirValidator validator = getContext().newValidator();
|
||||
|
||||
FhirInstanceValidator val = new FhirInstanceValidator();
|
||||
val.setBestPracticeWarningLevel(BestPracticeWarningLevel.Warning);
|
||||
val.setValidationSupport(new ValidationSupportChain(new DefaultProfileValidationSupport(), myJpaValidationSupport));
|
||||
// val.setValidationSupport(new ValidationSupportChain(new DefaultProfileValidationSupport(), myJpaValidationSupport));
|
||||
validator.registerValidatorModule(val);
|
||||
|
||||
validator.registerValidatorModule(new IdChecker(theMode));
|
||||
|
|
|
@ -24,11 +24,12 @@ import java.util.Collections;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.SearchParameterMap.EverythingModeEnum;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Encounter;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.UnsignedIntDt;
|
||||
import ca.uhn.fhir.rest.api.SortSpec;
|
||||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
|
@ -37,7 +38,7 @@ import ca.uhn.fhir.rest.server.IBundleProvider;
|
|||
public class FhirResourceDaoEncounterDstu2 extends FhirResourceDaoDstu2<Encounter>implements IFhirResourceDaoEncounter<Encounter> {
|
||||
|
||||
@Override
|
||||
public IBundleProvider encounterInstanceEverything(HttpServletRequest theServletRequest, IdDt theId, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSort) {
|
||||
public IBundleProvider encounterInstanceEverything(HttpServletRequest theServletRequest, IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort) {
|
||||
SearchParameterMap paramMap = new SearchParameterMap();
|
||||
if (theCount != null) {
|
||||
paramMap.setCount(theCount.getValue());
|
||||
|
@ -56,7 +57,7 @@ public class FhirResourceDaoEncounterDstu2 extends FhirResourceDaoDstu2<Encounte
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBundleProvider encounterTypeEverything(HttpServletRequest theServletRequest, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSort) {
|
||||
public IBundleProvider encounterTypeEverything(HttpServletRequest theServletRequest, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort) {
|
||||
return encounterInstanceEverything(theServletRequest, null, theCount, theLastUpdated, theSort);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,11 +24,12 @@ import java.util.Collections;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.hl7.fhir.dstu21.model.Encounter;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.SearchParameterMap.EverythingModeEnum;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Encounter;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.UnsignedIntDt;
|
||||
import ca.uhn.fhir.rest.api.SortSpec;
|
||||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
|
@ -37,7 +38,7 @@ import ca.uhn.fhir.rest.server.IBundleProvider;
|
|||
public class FhirResourceDaoEncounterDstu21 extends FhirResourceDaoDstu21<Encounter>implements IFhirResourceDaoEncounter<Encounter> {
|
||||
|
||||
@Override
|
||||
public IBundleProvider encounterInstanceEverything(HttpServletRequest theServletRequest, IdDt theId, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSort) {
|
||||
public IBundleProvider encounterInstanceEverything(HttpServletRequest theServletRequest, IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort) {
|
||||
SearchParameterMap paramMap = new SearchParameterMap();
|
||||
if (theCount != null) {
|
||||
paramMap.setCount(theCount.getValue());
|
||||
|
@ -56,7 +57,7 @@ public class FhirResourceDaoEncounterDstu21 extends FhirResourceDaoDstu21<Encoun
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBundleProvider encounterTypeEverything(HttpServletRequest theServletRequest, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSort) {
|
||||
public IBundleProvider encounterTypeEverything(HttpServletRequest theServletRequest, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort) {
|
||||
return encounterInstanceEverything(theServletRequest, null, theCount, theLastUpdated, theSort);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,11 +25,11 @@ import java.util.Collections;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.SearchParameterMap.EverythingModeEnum;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.UnsignedIntDt;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.SortSpec;
|
||||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||
|
@ -41,7 +41,7 @@ import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetai
|
|||
|
||||
public class FhirResourceDaoPatientDstu2 extends FhirResourceDaoDstu2<Patient>implements IFhirResourceDaoPatient<Patient> {
|
||||
|
||||
private IBundleProvider doEverythingOperation(IIdType theId, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative) {
|
||||
private IBundleProvider doEverythingOperation(IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative) {
|
||||
SearchParameterMap paramMap = new SearchParameterMap();
|
||||
if (theCount != null) {
|
||||
paramMap.setCount(theCount.getValue());
|
||||
|
@ -66,7 +66,7 @@ public class FhirResourceDaoPatientDstu2 extends FhirResourceDaoDstu2<Patient>im
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBundleProvider patientInstanceEverything(HttpServletRequest theServletRequest, IIdType theId, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative) {
|
||||
public IBundleProvider patientInstanceEverything(HttpServletRequest theServletRequest, IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative) {
|
||||
// Notify interceptors
|
||||
ActionRequestDetails requestDetails = new ActionRequestDetails(null, getResourceName());
|
||||
notifyInterceptors(RestOperationTypeEnum.EXTENDED_OPERATION_INSTANCE, requestDetails);
|
||||
|
@ -75,7 +75,7 @@ public class FhirResourceDaoPatientDstu2 extends FhirResourceDaoDstu2<Patient>im
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBundleProvider patientTypeEverything(HttpServletRequest theServletRequest, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative) {
|
||||
public IBundleProvider patientTypeEverything(HttpServletRequest theServletRequest, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative) {
|
||||
// Notify interceptors
|
||||
ActionRequestDetails requestDetails = new ActionRequestDetails(null, getResourceName());
|
||||
notifyInterceptors(RestOperationTypeEnum.EXTENDED_OPERATION_TYPE, requestDetails);
|
||||
|
|
|
@ -24,12 +24,12 @@ import java.util.Collections;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.hl7.fhir.dstu21.model.Patient;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.SearchParameterMap.EverythingModeEnum;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.UnsignedIntDt;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.SortSpec;
|
||||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||
|
@ -41,7 +41,7 @@ import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetai
|
|||
|
||||
public class FhirResourceDaoPatientDstu21 extends FhirResourceDaoDstu21<Patient>implements IFhirResourceDaoPatient<Patient> {
|
||||
|
||||
private IBundleProvider doEverythingOperation(IIdType theId, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative) {
|
||||
private IBundleProvider doEverythingOperation(IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative) {
|
||||
SearchParameterMap paramMap = new SearchParameterMap();
|
||||
if (theCount != null) {
|
||||
paramMap.setCount(theCount.getValue());
|
||||
|
@ -66,7 +66,7 @@ public class FhirResourceDaoPatientDstu21 extends FhirResourceDaoDstu21<Patient>
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBundleProvider patientInstanceEverything(HttpServletRequest theServletRequest, IIdType theId, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative) {
|
||||
public IBundleProvider patientInstanceEverything(HttpServletRequest theServletRequest, IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative) {
|
||||
// Notify interceptors
|
||||
ActionRequestDetails requestDetails = new ActionRequestDetails(null, getResourceName());
|
||||
notifyInterceptors(RestOperationTypeEnum.EXTENDED_OPERATION_INSTANCE, requestDetails);
|
||||
|
@ -75,7 +75,7 @@ public class FhirResourceDaoPatientDstu21 extends FhirResourceDaoDstu21<Patient>
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBundleProvider patientTypeEverything(HttpServletRequest theServletRequest, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative) {
|
||||
public IBundleProvider patientTypeEverything(HttpServletRequest theServletRequest, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative) {
|
||||
// Notify interceptors
|
||||
ActionRequestDetails requestDetails = new ActionRequestDetails(null, getResourceName());
|
||||
notifyInterceptors(RestOperationTypeEnum.EXTENDED_OPERATION_TYPE, requestDetails);
|
||||
|
|
|
@ -22,6 +22,7 @@ package ca.uhn.fhir.jpa.dao;
|
|||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.hl7.fhir.instance.hapi.validation.FhirQuestionnaireResponseValidator;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
@ -36,7 +37,6 @@ import ca.uhn.fhir.model.dstu2.resource.QuestionnaireResponse;
|
|||
import ca.uhn.fhir.model.dstu2.resource.ValueSet;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.validation.FhirQuestionnaireResponseValidator;
|
||||
import ca.uhn.fhir.validation.FhirValidator;
|
||||
import ca.uhn.fhir.validation.IResourceLoader;
|
||||
import ca.uhn.fhir.validation.ValidationResult;
|
||||
|
|
|
@ -22,33 +22,30 @@ package ca.uhn.fhir.jpa.dao;
|
|||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.hl7.fhir.dstu21.hapi.validation.FhirQuestionnaireResponseValidator;
|
||||
import org.hl7.fhir.dstu21.model.OperationOutcome;
|
||||
import org.hl7.fhir.dstu21.model.Questionnaire;
|
||||
import org.hl7.fhir.dstu21.model.QuestionnaireResponse;
|
||||
import org.hl7.fhir.dstu21.model.ValueSet;
|
||||
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
||||
import ca.uhn.fhir.model.dstu21.resource.OperationOutcome;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Questionnaire;
|
||||
import ca.uhn.fhir.model.dstu21.resource.QuestionnaireResponse;
|
||||
import ca.uhn.fhir.model.dstu21.resource.ValueSet;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.validation.FhirQuestionnaireResponseValidator;
|
||||
import ca.uhn.fhir.validation.FhirValidator;
|
||||
import ca.uhn.fhir.validation.IResourceLoader;
|
||||
import ca.uhn.fhir.validation.ValidationResult;
|
||||
|
||||
public class FhirResourceDaoQuestionnaireResponseDstu21 extends FhirResourceDaoDstu21<QuestionnaireResponse> {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("myFhirContextDstu2Hl7Org")
|
||||
private FhirContext myRefImplCtx;
|
||||
|
||||
private Boolean myValidateResponses;
|
||||
|
||||
@Autowired
|
||||
private IJpaValidationSupportDstu21 myValidationSupport;
|
||||
|
||||
/**
|
||||
* Initialize the bean
|
||||
*/
|
||||
|
@ -74,17 +71,17 @@ public class FhirResourceDaoQuestionnaireResponseDstu21 extends FhirResourceDaoD
|
|||
return;
|
||||
}
|
||||
|
||||
FhirValidator val = myRefImplCtx.newValidator();
|
||||
FhirValidator val = getContext().newValidator();
|
||||
val.setValidateAgainstStandardSchema(false);
|
||||
val.setValidateAgainstStandardSchematron(false);
|
||||
|
||||
FhirQuestionnaireResponseValidator module = new FhirQuestionnaireResponseValidator();
|
||||
module.setResourceLoader(new JpaResourceLoader());
|
||||
module.setValidationSupport(myValidationSupport);
|
||||
val.registerValidatorModule(module);
|
||||
|
||||
ValidationResult result = val.validateWithResult(myRefImplCtx.newJsonParser().parseResource(getContext().newJsonParser().encodeResourceToString(qa)));
|
||||
ValidationResult result = val.validateWithResult(getContext().newJsonParser().parseResource(getContext().newJsonParser().encodeResourceToString(qa)));
|
||||
if (!result.isSuccessful()) {
|
||||
IBaseOperationOutcome oo = getContext().newJsonParser().parseResource(OperationOutcome.class, myRefImplCtx.newJsonParser().encodeResourceToString(result.toOperationOutcome()));
|
||||
IBaseOperationOutcome oo = getContext().newJsonParser().parseResource(OperationOutcome.class, getContext().newJsonParser().encodeResourceToString(result.toOperationOutcome()));
|
||||
throw new UnprocessableEntityException(getContext(), oo);
|
||||
}
|
||||
}
|
||||
|
@ -101,16 +98,11 @@ public class FhirResourceDaoQuestionnaireResponseDstu21 extends FhirResourceDaoD
|
|||
if ("ValueSet".equals(theType.getSimpleName())) {
|
||||
IFhirResourceDao<ValueSet> dao = getDao(ValueSet.class);
|
||||
ValueSet in = dao.read(theId);
|
||||
String encoded = getContext().newJsonParser().encodeResourceToString(in);
|
||||
|
||||
// TODO: this is temporary until structures-dstu2 catches up to structures-hl7org.dstu2
|
||||
encoded = encoded.replace("\"define\"", "\"codeSystem\"");
|
||||
|
||||
return myRefImplCtx.newJsonParser().parseResource(theType, encoded);
|
||||
return (T) in;
|
||||
} else if ("Questionnaire".equals(theType.getSimpleName())) {
|
||||
IFhirResourceDao<Questionnaire> dao = getDao(Questionnaire.class);
|
||||
Questionnaire vs = dao.read(theId);
|
||||
return myRefImplCtx.newJsonParser().parseResource(theType, getContext().newJsonParser().encodeResourceToString(vs));
|
||||
return (T) vs;
|
||||
} else {
|
||||
// Should not happen, validator will only ask for these two
|
||||
throw new IllegalStateException("Unexpected request to load resource of type " + theType);
|
||||
|
|
|
@ -21,17 +21,16 @@ package ca.uhn.fhir.jpa.dao;
|
|||
*/
|
||||
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.hl7.fhir.dstu21.model.Bundle;
|
||||
import org.hl7.fhir.dstu21.model.Meta;
|
||||
import org.hl7.fhir.dstu21.model.SearchParameter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
import ca.uhn.fhir.model.dstu21.composite.MetaDt;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu21.resource.SearchParameter;
|
||||
|
||||
public class FhirResourceDaoSearchParameterDstu21 extends FhirResourceDaoDstu21<SearchParameter>implements IFhirResourceDaoSearchParameter<SearchParameter> {
|
||||
|
||||
@Autowired
|
||||
private IFhirSystemDao<Bundle, MetaDt> mySystemDao;
|
||||
private IFhirSystemDao<Bundle, Meta> mySystemDao;
|
||||
|
||||
/**
|
||||
* This method is called once per minute to perform any required re-indexing. During most passes this will
|
||||
|
|
|
@ -258,7 +258,7 @@ public class FhirResourceDaoSubscriptionDstu2 extends FhirResourceDaoDstu2<Subsc
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ResourceTable updateEntity(IResource theResource, ResourceTable theEntity, boolean theUpdateHistory, Date theDeletedTimestampOrNull, boolean thePerformIndexing, boolean theUpdateVersion,
|
||||
protected ResourceTable updateEntity(IBaseResource theResource, ResourceTable theEntity, boolean theUpdateHistory, Date theDeletedTimestampOrNull, boolean thePerformIndexing, boolean theUpdateVersion,
|
||||
Date theUpdateTime) {
|
||||
ResourceTable retVal = super.updateEntity(theResource, theEntity, theUpdateHistory, theDeletedTimestampOrNull, thePerformIndexing, theUpdateVersion, theUpdateTime);
|
||||
|
||||
|
|
|
@ -30,6 +30,9 @@ import java.util.List;
|
|||
import javax.persistence.Query;
|
||||
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.hl7.fhir.dstu21.model.Subscription;
|
||||
import org.hl7.fhir.dstu21.model.Subscription.SubscriptionStatus;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -50,11 +53,8 @@ import ca.uhn.fhir.jpa.dao.data.ISubscriptionTableDao;
|
|||
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.entity.SubscriptionFlaggedResource;
|
||||
import ca.uhn.fhir.jpa.entity.SubscriptionTable;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Subscription;
|
||||
import ca.uhn.fhir.model.dstu21.valueset.SubscriptionStatusEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.SubscriptionStatusEnum;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
@ -85,7 +85,7 @@ public class FhirResourceDaoSubscriptionDstu21 extends FhirResourceDaoDstu21<Sub
|
|||
subscriptionEntity.setSubscriptionResource(theEntity);
|
||||
subscriptionEntity.setNextCheck(theEntity.getPublished().getValue());
|
||||
subscriptionEntity.setMostRecentMatch(theEntity.getPublished().getValue());
|
||||
subscriptionEntity.setStatus(theSubscription.getStatusElement().getValue());
|
||||
subscriptionEntity.setStatus(theSubscription.getStatusElement().getValueAsString());
|
||||
myEntityManager.persist(subscriptionEntity);
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ public class FhirResourceDaoSubscriptionDstu21 extends FhirResourceDaoDstu21<Sub
|
|||
return 0;
|
||||
}
|
||||
|
||||
ourLog.debug("Subscription {} search from {} to {}", new Object[] { subscription.getId().getIdPart(), new InstantDt(new Date(start)), new InstantDt(new Date(end)) });
|
||||
ourLog.debug("Subscription {} search from {} to {}", new Object[] { subscription.getIdElement().getIdPart(), new InstantDt(new Date(start)), new InstantDt(new Date(end)) });
|
||||
|
||||
DateRangeParam range = new DateRangeParam();
|
||||
range.setLowerBound(new DateParam(QuantityCompararatorEnum.GREATERTHAN, start));
|
||||
|
@ -170,13 +170,14 @@ public class FhirResourceDaoSubscriptionDstu21 extends FhirResourceDaoDstu21<Sub
|
|||
return 0;
|
||||
}
|
||||
|
||||
ourLog.info("Found {} new results for Subscription {}", results.size(), subscription.getId().getIdPart());
|
||||
ourLog.info("Found {} new results for Subscription {}", results.size(), subscription.getIdElement().getIdPart());
|
||||
|
||||
List<SubscriptionFlaggedResource> flags = new ArrayList<SubscriptionFlaggedResource>();
|
||||
Date mostRecentMatch = null;
|
||||
for (IBaseResource next : results.getResources(0, results.size())) {
|
||||
for (IBaseResource nextBase : results.getResources(0, results.size())) {
|
||||
IAnyResource next = (IAnyResource)nextBase;
|
||||
|
||||
Date updated = ResourceMetadataKeyEnum.UPDATED.get((IResource) next).getValue();
|
||||
Date updated = next.getMeta().getLastUpdated();
|
||||
if (mostRecentMatch == null) {
|
||||
mostRecentMatch = updated;
|
||||
} else {
|
||||
|
@ -188,7 +189,7 @@ public class FhirResourceDaoSubscriptionDstu21 extends FhirResourceDaoDstu21<Sub
|
|||
}
|
||||
|
||||
SubscriptionFlaggedResource nextFlag = new SubscriptionFlaggedResource();
|
||||
Long pid = IDao.RESOURCE_PID.get((IResource) next);
|
||||
Long pid = IDao.RESOURCE_PID.get(next);
|
||||
|
||||
ourLog.info("New resource for subscription: {}", pid);
|
||||
|
||||
|
@ -200,7 +201,7 @@ public class FhirResourceDaoSubscriptionDstu21 extends FhirResourceDaoDstu21<Sub
|
|||
|
||||
mySubscriptionFlaggedResourceDataDao.save(flags);
|
||||
|
||||
ourLog.debug("Updating most recent match for subcription {} to {}", subscription.getId().getIdPart(), new InstantDt(mostRecentMatch));
|
||||
ourLog.debug("Updating most recent match for subcription {} to {}", subscription.getIdElement().getIdPart(), new InstantDt(mostRecentMatch));
|
||||
|
||||
theSubscriptionTable.setMostRecentMatch(mostRecentMatch);
|
||||
mySubscriptionTableDao.save(theSubscriptionTable);
|
||||
|
@ -258,7 +259,7 @@ public class FhirResourceDaoSubscriptionDstu21 extends FhirResourceDaoDstu21<Sub
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ResourceTable updateEntity(IResource theResource, ResourceTable theEntity, boolean theUpdateHistory, Date theDeletedTimestampOrNull, boolean thePerformIndexing, boolean theUpdateVersion,
|
||||
protected ResourceTable updateEntity(IBaseResource theResource, ResourceTable theEntity, boolean theUpdateHistory, Date theDeletedTimestampOrNull, boolean thePerformIndexing, boolean theUpdateVersion,
|
||||
Date theUpdateTime) {
|
||||
ResourceTable retVal = super.updateEntity(theResource, theEntity, theUpdateHistory, theDeletedTimestampOrNull, thePerformIndexing, theUpdateVersion, theUpdateTime);
|
||||
|
||||
|
@ -273,9 +274,9 @@ public class FhirResourceDaoSubscriptionDstu21 extends FhirResourceDaoDstu21<Sub
|
|||
} else {
|
||||
Query q = myEntityManager.createNamedQuery("Q_HFJ_SUBSCRIPTION_SET_STATUS");
|
||||
q.setParameter("res_id", resourceId);
|
||||
q.setParameter("status", resource.getStatusElement().getValue());
|
||||
q.setParameter("status", resource.getStatusElement().getValueAsString());
|
||||
if (q.executeUpdate() > 0) {
|
||||
ourLog.info("Updated subscription status for subscription {} to {}", resourceId, resource.getStatusElement().getValueAsEnum());
|
||||
ourLog.info("Updated subscription status for subscription {} to {}", resourceId, resource.getStatus());
|
||||
} else {
|
||||
createSubscriptionTable(retVal, resource);
|
||||
}
|
||||
|
@ -323,7 +324,7 @@ public class FhirResourceDaoSubscriptionDstu21 extends FhirResourceDaoDstu21<Sub
|
|||
throw new UnprocessableEntityException("Subscription.channel.type must be populated on this server");
|
||||
}
|
||||
|
||||
SubscriptionStatusEnum status = theResource.getStatusElement().getValueAsEnum();
|
||||
SubscriptionStatus status = theResource.getStatus();
|
||||
if (status == null) {
|
||||
throw new UnprocessableEntityException("Subscription.status must be populated on this server");
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ import java.util.Set;
|
|||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.apache.commons.codec.binary.StringUtils;
|
||||
import org.hl7.fhir.instance.hapi.validation.DefaultProfileValidationSupport;
|
||||
import org.hl7.fhir.instance.hapi.validation.ValidationSupportChain;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -45,23 +47,18 @@ import ca.uhn.fhir.model.dstu2.resource.ValueSet.CodeSystemConcept;
|
|||
import ca.uhn.fhir.model.dstu2.resource.ValueSet.ComposeInclude;
|
||||
import ca.uhn.fhir.model.dstu2.resource.ValueSet.ComposeIncludeConcept;
|
||||
import ca.uhn.fhir.model.dstu2.resource.ValueSet.ExpansionContains;
|
||||
import ca.uhn.fhir.model.primitive.CodeDt;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.param.TokenParam;
|
||||
import ca.uhn.fhir.rest.param.UriParam;
|
||||
import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.validation.DefaultProfileValidationSupport;
|
||||
import ca.uhn.fhir.validation.ValidationSupportChain;
|
||||
|
||||
public class FhirResourceDaoValueSetDstu2 extends FhirResourceDaoDstu2<ValueSet>implements IFhirResourceDaoValueSet<ValueSet, CodingDt, CodeableConceptDt> {
|
||||
|
||||
@Autowired
|
||||
private IJpaValidationSupport myJpaValidationSupport;
|
||||
private IJpaValidationSupportDstu2 myJpaValidationSupport;
|
||||
|
||||
private ValidationSupportChain myValidationSupport;
|
||||
|
||||
|
@ -181,8 +178,7 @@ public class FhirResourceDaoValueSetDstu2 extends FhirResourceDaoDstu2<ValueSet>
|
|||
}
|
||||
|
||||
@Override
|
||||
public ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult validateCode(UriDt theValueSetIdentifier, IIdType theId, CodeDt theCode, UriDt theSystem, StringDt theDisplay,
|
||||
CodingDt theCoding, CodeableConceptDt theCodeableConcept) {
|
||||
public ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult validateCode(IPrimitiveType<String> theValueSetIdentifier, IIdType theId, IPrimitiveType<String> theCode, IPrimitiveType<String> theSystem, IPrimitiveType<String> theDisplay, CodingDt theCoding, CodeableConceptDt theCodeableConcept) {
|
||||
List<IIdType> valueSetIds;
|
||||
|
||||
boolean haveCodeableConcept = theCodeableConcept != null && theCodeableConcept.getCoding().size() > 0;
|
||||
|
@ -292,7 +288,7 @@ public class FhirResourceDaoValueSetDstu2 extends FhirResourceDaoDstu2<ValueSet>
|
|||
}
|
||||
|
||||
@Override
|
||||
public ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.LookupCodeResult lookupCode(CodeDt theCode, UriDt theSystem, CodingDt theCoding) {
|
||||
public ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.LookupCodeResult lookupCode(IPrimitiveType<String> theCode, IPrimitiveType<String> theSystem, CodingDt theCoding) {
|
||||
boolean haveCoding = theCoding != null && isNotBlank(theCoding.getSystem()) && isNotBlank(theCoding.getCode());
|
||||
boolean haveCode = theCode != null && theCode.isEmpty() == false;
|
||||
boolean haveSystem = theSystem != null && theSystem.isEmpty() == false;
|
||||
|
|
|
@ -25,49 +25,44 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.apache.commons.codec.binary.StringUtils;
|
||||
import org.hl7.fhir.dstu21.hapi.validation.DefaultProfileValidationSupport;
|
||||
import org.hl7.fhir.dstu21.hapi.validation.HapiWorkerContext;
|
||||
import org.hl7.fhir.dstu21.hapi.validation.ValidationSupportChain;
|
||||
import org.hl7.fhir.dstu21.model.CodeableConcept;
|
||||
import org.hl7.fhir.dstu21.model.Coding;
|
||||
import org.hl7.fhir.dstu21.model.IdType;
|
||||
import org.hl7.fhir.dstu21.model.ValueSet;
|
||||
import org.hl7.fhir.dstu21.model.ValueSet.ConceptDefinitionComponent;
|
||||
import org.hl7.fhir.dstu21.model.ValueSet.ConceptReferenceComponent;
|
||||
import org.hl7.fhir.dstu21.model.ValueSet.ConceptSetComponent;
|
||||
import org.hl7.fhir.dstu21.model.ValueSet.ValueSetExpansionComponent;
|
||||
import org.hl7.fhir.dstu21.model.ValueSet.ValueSetExpansionContainsComponent;
|
||||
import org.hl7.fhir.dstu21.terminologies.ValueSetExpander;
|
||||
import org.hl7.fhir.dstu21.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jpa.entity.BaseHasResource;
|
||||
import ca.uhn.fhir.model.dstu21.composite.CodeableConceptDt;
|
||||
import ca.uhn.fhir.model.dstu21.composite.CodingDt;
|
||||
import ca.uhn.fhir.model.dstu21.resource.ValueSet;
|
||||
import ca.uhn.fhir.model.dstu21.resource.ValueSet.CodeSystemConcept;
|
||||
import ca.uhn.fhir.model.dstu21.resource.ValueSet.ComposeInclude;
|
||||
import ca.uhn.fhir.model.dstu21.resource.ValueSet.ComposeIncludeConcept;
|
||||
import ca.uhn.fhir.model.dstu21.resource.ValueSet.ExpansionContains;
|
||||
import ca.uhn.fhir.model.primitive.CodeDt;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.param.TokenParam;
|
||||
import ca.uhn.fhir.rest.param.UriParam;
|
||||
import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.validation.DefaultProfileValidationSupport;
|
||||
import ca.uhn.fhir.validation.ValidationSupportChain;
|
||||
|
||||
public class FhirResourceDaoValueSetDstu21 extends FhirResourceDaoDstu21<ValueSet>implements IFhirResourceDaoValueSet<ValueSet, CodingDt, CodeableConceptDt> {
|
||||
public class FhirResourceDaoValueSetDstu21 extends FhirResourceDaoDstu21<ValueSet> implements IFhirResourceDaoValueSet<ValueSet, Coding, CodeableConcept> {
|
||||
|
||||
@Autowired
|
||||
private IJpaValidationSupport myJpaValidationSupport;
|
||||
|
||||
private IJpaValidationSupportDstu21 myJpaValidationSupport;
|
||||
|
||||
private ValidationSupportChain myValidationSupport;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("myFhirContextDstu2Hl7Org")
|
||||
private FhirContext myRiCtx;
|
||||
|
||||
private DefaultProfileValidationSupport myDefaultProfileValidationSupport;
|
||||
|
||||
|
@ -78,27 +73,26 @@ public class FhirResourceDaoValueSetDstu21 extends FhirResourceDaoDstu21<ValueSe
|
|||
myDefaultProfileValidationSupport = new DefaultProfileValidationSupport();
|
||||
myValidationSupport = new ValidationSupportChain(myDefaultProfileValidationSupport, myJpaValidationSupport);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ValueSet expand(IIdType theId, String theFilter) {
|
||||
ValueSet source = loadValueSetForExpansion(theId);
|
||||
return expand(source, theFilter);
|
||||
HapiWorkerContext workerContext = new HapiWorkerContext(getContext(), myValidationSupport);
|
||||
ValueSet source = workerContext.fetchResource(ValueSet.class, theId.getValue());
|
||||
|
||||
}
|
||||
|
||||
private ValueSet loadValueSetForExpansion(IIdType theId) {
|
||||
if (theId.getValue().startsWith("http://hl7.org/fhir/")) {
|
||||
org.hl7.fhir.instance.model.ValueSet valueSet = myValidationSupport.fetchResource(myRiCtx, org.hl7.fhir.instance.model.ValueSet.class, theId.getValue());
|
||||
if (valueSet != null) {
|
||||
return getContext().newJsonParser().parseResource(ValueSet.class, myRiCtx.newJsonParser().encodeResourceToString(valueSet));
|
||||
ValueSetExpansionOutcome outcome = workerContext.expand(source);
|
||||
ValueSetExpansionComponent expansion = outcome.getValueset().getExpansion();
|
||||
if (isNotBlank(theFilter)) {
|
||||
for (Iterator<ValueSetExpansionContainsComponent> containsIter = expansion.getContains().iterator(); containsIter.hasNext();) {
|
||||
ValueSetExpansionContainsComponent nextContains = containsIter.next();
|
||||
if (!nextContains.getDisplay().toLowerCase().contains(theFilter.toLowerCase())) {
|
||||
containsIter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
BaseHasResource sourceEntity = readEntity(theId);
|
||||
if (sourceEntity == null) {
|
||||
throw new ResourceNotFoundException(theId);
|
||||
}
|
||||
ValueSet source = (ValueSet) toResource(sourceEntity, false);
|
||||
return source;
|
||||
|
||||
ValueSet retVal = new ValueSet();
|
||||
retVal.setExpansion(expansion);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -107,10 +101,10 @@ public class FhirResourceDaoValueSetDstu21 extends FhirResourceDaoDstu21<ValueSe
|
|||
throw new InvalidRequestException("URI must not be blank or missing");
|
||||
}
|
||||
ValueSet source;
|
||||
|
||||
org.hl7.fhir.instance.model.ValueSet defaultValueSet = myDefaultProfileValidationSupport.fetchResource(myRiCtx, org.hl7.fhir.instance.model.ValueSet.class, theUri);
|
||||
|
||||
org.hl7.fhir.instance.model.ValueSet defaultValueSet = myDefaultProfileValidationSupport.fetchResource(getContext(), org.hl7.fhir.instance.model.ValueSet.class, theUri);
|
||||
if (defaultValueSet != null) {
|
||||
source = getContext().newJsonParser().parseResource(ValueSet.class, myRiCtx.newJsonParser().encodeResourceToString(defaultValueSet));
|
||||
source = getContext().newJsonParser().parseResource(ValueSet.class, getContext().newJsonParser().encodeResourceToString(defaultValueSet));
|
||||
} else {
|
||||
IBundleProvider ids = search(ValueSet.SP_URL, new UriParam(theUri));
|
||||
if (ids.size() == 0) {
|
||||
|
@ -126,14 +120,14 @@ public class FhirResourceDaoValueSetDstu21 extends FhirResourceDaoDstu21<ValueSe
|
|||
@Override
|
||||
public ValueSet expand(ValueSet source, String theFilter) {
|
||||
ValueSet retVal = new ValueSet();
|
||||
retVal.setDate(DateTimeDt.withCurrentTime());
|
||||
|
||||
retVal.setDate(new Date());
|
||||
|
||||
/*
|
||||
* Add composed concepts
|
||||
*/
|
||||
|
||||
for (ComposeInclude nextInclude : source.getCompose().getInclude()) {
|
||||
for (ComposeIncludeConcept next : nextInclude.getConcept()) {
|
||||
for (ConceptSetComponent nextInclude : source.getCompose().getInclude()) {
|
||||
for (ConceptReferenceComponent next : nextInclude.getConcept()) {
|
||||
if (isBlank(theFilter)) {
|
||||
addCompose(retVal, nextInclude.getSystem(), next.getCode(), next.getDisplay());
|
||||
} else {
|
||||
|
@ -149,14 +143,14 @@ public class FhirResourceDaoValueSetDstu21 extends FhirResourceDaoDstu21<ValueSe
|
|||
* Add defined concepts
|
||||
*/
|
||||
|
||||
for (CodeSystemConcept next : source.getCodeSystem().getConcept()) {
|
||||
for (ConceptDefinitionComponent next : source.getCodeSystem().getConcept()) {
|
||||
addCompose(theFilter, retVal, source, next);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private void addCompose(String theFilter, ValueSet theValueSetToPopulate, ValueSet theSourceValueSet, CodeSystemConcept theConcept) {
|
||||
private void addCompose(String theFilter, ValueSet theValueSetToPopulate, ValueSet theSourceValueSet, ConceptDefinitionComponent theConcept) {
|
||||
if (isBlank(theFilter)) {
|
||||
addCompose(theValueSetToPopulate, theSourceValueSet.getCodeSystem().getSystem(), theConcept.getCode(), theConcept.getDisplay());
|
||||
} else {
|
||||
|
@ -165,7 +159,7 @@ public class FhirResourceDaoValueSetDstu21 extends FhirResourceDaoDstu21<ValueSe
|
|||
addCompose(theValueSetToPopulate, theSourceValueSet.getCodeSystem().getSystem(), theConcept.getCode(), theConcept.getDisplay());
|
||||
}
|
||||
}
|
||||
for (CodeSystemConcept nextChild : theConcept.getConcept()) {
|
||||
for (ConceptDefinitionComponent nextChild : theConcept.getConcept()) {
|
||||
addCompose(theFilter, theValueSetToPopulate, theSourceValueSet, nextChild);
|
||||
}
|
||||
}
|
||||
|
@ -174,15 +168,15 @@ public class FhirResourceDaoValueSetDstu21 extends FhirResourceDaoDstu21<ValueSe
|
|||
if (isBlank(theCode)) {
|
||||
return;
|
||||
}
|
||||
ExpansionContains contains = retVal.getExpansion().addContains();
|
||||
ValueSetExpansionContainsComponent contains = retVal.getExpansion().addContains();
|
||||
contains.setSystem(theSystem);
|
||||
contains.setCode(theCode);
|
||||
contains.setDisplay(theDisplay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult validateCode(UriDt theValueSetIdentifier, IIdType theId, CodeDt theCode, UriDt theSystem, StringDt theDisplay,
|
||||
CodingDt theCoding, CodeableConceptDt theCodeableConcept) {
|
||||
public ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult validateCode(IPrimitiveType<String> theValueSetIdentifier, IIdType theId, IPrimitiveType<String> theCode, IPrimitiveType<String> theSystem, IPrimitiveType<String> theDisplay, Coding theCoding,
|
||||
CodeableConcept theCodeableConcept) {
|
||||
List<IIdType> valueSetIds;
|
||||
|
||||
boolean haveCodeableConcept = theCodeableConcept != null && theCodeableConcept.getCoding().size() > 0;
|
||||
|
@ -203,7 +197,7 @@ public class FhirResourceDaoValueSetDstu21 extends FhirResourceDaoDstu21<ValueSe
|
|||
Set<Long> ids = searchForIds(ValueSet.SP_IDENTIFIER, new TokenParam(null, theValueSetIdentifier.getValue()));
|
||||
valueSetIds = new ArrayList<IIdType>();
|
||||
for (Long next : ids) {
|
||||
valueSetIds.add(new IdDt("ValueSet", next));
|
||||
valueSetIds.add(new IdType("ValueSet", next));
|
||||
}
|
||||
} else {
|
||||
if (theCode == null || theCode.isEmpty()) {
|
||||
|
@ -216,7 +210,7 @@ public class FhirResourceDaoValueSetDstu21 extends FhirResourceDaoDstu21<ValueSe
|
|||
|
||||
for (IIdType nextId : valueSetIds) {
|
||||
ValueSet expansion = expand(nextId, null);
|
||||
List<ExpansionContains> contains = expansion.getExpansion().getContains();
|
||||
List<ValueSetExpansionContainsComponent> contains = expansion.getExpansion().getContains();
|
||||
ValidateCodeResult result = validateCodeIsInContains(contains, toStringOrNull(theSystem), toStringOrNull(theCode), theCoding, theCodeableConcept);
|
||||
if (result != null) {
|
||||
if (theDisplay != null && isNotBlank(theDisplay.getValue()) && isNotBlank(result.getDisplay())) {
|
||||
|
@ -232,15 +226,15 @@ public class FhirResourceDaoValueSetDstu21 extends FhirResourceDaoDstu21<ValueSe
|
|||
}
|
||||
|
||||
private List<IIdType> findValueSetIdsContainingSystemAndCode(String theCode, String theSystem) {
|
||||
if (theSystem != null && theSystem.startsWith("http://hl7.org/fhir/")) {
|
||||
return Collections.singletonList((IIdType)new IdDt(theSystem));
|
||||
}
|
||||
|
||||
// if (theSystem != null && theSystem.startsWith("http://hl7.org/fhir/ValueSet")) {
|
||||
// return Collections.singletonList((IIdType) new IdType(theSystem));
|
||||
// }
|
||||
|
||||
List<IIdType> valueSetIds;
|
||||
Set<Long> ids = searchForIds(ValueSet.SP_CODE, new TokenParam(theSystem, theCode));
|
||||
valueSetIds = new ArrayList<IIdType>();
|
||||
for (Long next : ids) {
|
||||
valueSetIds.add(new IdDt("ValueSet", next));
|
||||
valueSetIds.add(new IdType("ValueSet", next));
|
||||
}
|
||||
return valueSetIds;
|
||||
}
|
||||
|
@ -259,9 +253,8 @@ public class FhirResourceDaoValueSetDstu21 extends FhirResourceDaoDstu21<ValueSe
|
|||
return thePrimitive != null ? thePrimitive.getValue() : null;
|
||||
}
|
||||
|
||||
private ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult validateCodeIsInContains(List<ExpansionContains> contains, String theSystem, String theCode, CodingDt theCoding,
|
||||
CodeableConceptDt theCodeableConcept) {
|
||||
for (ExpansionContains nextCode : contains) {
|
||||
private ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult validateCodeIsInContains(List<ValueSetExpansionContainsComponent> contains, String theSystem, String theCode, Coding theCoding, CodeableConcept theCodeableConcept) {
|
||||
for (ValueSetExpansionContainsComponent nextCode : contains) {
|
||||
ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult result = validateCodeIsInContains(nextCode.getContains(), theSystem, theCode, theCoding, theCodeableConcept);
|
||||
if (result != null) {
|
||||
return result;
|
||||
|
@ -279,7 +272,7 @@ public class FhirResourceDaoValueSetDstu21 extends FhirResourceDaoDstu21<ValueSe
|
|||
return new ValidateCodeResult(true, "Validation succeeded", nextCode.getDisplay());
|
||||
}
|
||||
} else {
|
||||
for (CodingDt next : theCodeableConcept.getCoding()) {
|
||||
for (Coding next : theCodeableConcept.getCoding()) {
|
||||
if (StringUtils.equals(system, next.getSystem()) && StringUtils.equals(code, next.getCode())) {
|
||||
return new ValidateCodeResult(true, "Validation succeeded", nextCode.getDisplay());
|
||||
}
|
||||
|
@ -292,7 +285,7 @@ public class FhirResourceDaoValueSetDstu21 extends FhirResourceDaoDstu21<ValueSe
|
|||
}
|
||||
|
||||
@Override
|
||||
public ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.LookupCodeResult lookupCode(CodeDt theCode, UriDt theSystem, CodingDt theCoding) {
|
||||
public ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.LookupCodeResult lookupCode(IPrimitiveType<String> theCode, IPrimitiveType<String> theSystem, Coding theCoding) {
|
||||
boolean haveCoding = theCoding != null && isNotBlank(theCoding.getSystem()) && isNotBlank(theCoding.getCode());
|
||||
boolean haveCode = theCode != null && theCode.isEmpty() == false;
|
||||
boolean haveSystem = theSystem != null && theSystem.isEmpty() == false;
|
||||
|
@ -313,45 +306,95 @@ public class FhirResourceDaoValueSetDstu21 extends FhirResourceDaoDstu21<ValueSe
|
|||
code = theCode.getValue();
|
||||
system = theSystem.getValue();
|
||||
}
|
||||
|
||||
List<IIdType> valueSetIds = findValueSetIdsContainingSystemAndCode(code, system);
|
||||
for (IIdType nextId : valueSetIds) {
|
||||
ValueSet expansion = expand(nextId, null);
|
||||
List<ExpansionContains> contains = expansion.getExpansion().getContains();
|
||||
|
||||
// CodeValidationResult validateOutcome = myJpaValidationSupport.validateCode(getContext(), system, code, null);
|
||||
//
|
||||
// LookupCodeResult result = new LookupCodeResult();
|
||||
// result.setSearchedForCode(code);
|
||||
// result.setSearchedForSystem(system);
|
||||
// result.setFound(false);
|
||||
// if (validateOutcome.isOk()) {
|
||||
// result.setFound(true);
|
||||
// result.setCodeIsAbstract(validateOutcome.asConceptDefinition().getAbstract());
|
||||
// result.setCodeDisplay(validateOutcome.asConceptDefinition().getDisplay());
|
||||
// }
|
||||
// return result;
|
||||
|
||||
if (myValidationSupport.isCodeSystemSupported(getContext(), system)) {
|
||||
HapiWorkerContext ctx = new HapiWorkerContext(getContext(), myValidationSupport);
|
||||
ValueSetExpander expander = ctx.getExpander();
|
||||
ValueSet source = new ValueSet();
|
||||
source.getCompose().addInclude().setSystem(system).addConcept().setCode(code);
|
||||
|
||||
ValueSetExpansionOutcome expansion;
|
||||
try {
|
||||
expansion = expander.expand(source);
|
||||
} catch (Exception e) {
|
||||
throw new InternalErrorException(e);
|
||||
}
|
||||
List<ValueSetExpansionContainsComponent> contains = expansion.getValueset().getExpansion().getContains();
|
||||
ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.LookupCodeResult result = lookup(contains, system, code);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/*
|
||||
* If it's not a built-in code system, use ones from the database
|
||||
*/
|
||||
|
||||
List<IIdType> valueSetIds = findValueSetIdsContainingSystemAndCode(code, system);
|
||||
for (IIdType nextId : valueSetIds) {
|
||||
ValueSet expansion = read(nextId);
|
||||
for (ConceptDefinitionComponent next : expansion.getCodeSystem().getConcept()) {
|
||||
if (code.equals(next.getCode())) {
|
||||
ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.LookupCodeResult retVal = new LookupCodeResult();
|
||||
retVal.setSearchedForCode(code);
|
||||
retVal.setSearchedForSystem(system);
|
||||
retVal.setFound(true);
|
||||
if (next.getAbstractElement().getValue() != null) {
|
||||
retVal.setCodeIsAbstract(next.getAbstractElement().booleanValue());
|
||||
}
|
||||
retVal.setCodeDisplay(next.getDisplay());
|
||||
retVal.setCodeSystemDisplayName("Unknown"); // TODO: implement
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// We didn't find it..
|
||||
LookupCodeResult retVal = new LookupCodeResult();
|
||||
retVal.setFound(false);
|
||||
retVal.setSearchedForCode(code);
|
||||
retVal.setSearchedForSystem(system);
|
||||
return retVal;
|
||||
|
||||
}
|
||||
|
||||
private ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.LookupCodeResult lookup(List<ExpansionContains> theContains, String theSystem, String theCode) {
|
||||
for (ExpansionContains nextCode : theContains) {
|
||||
private ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.LookupCodeResult lookup(List<ValueSetExpansionContainsComponent> theContains, String theSystem, String theCode) {
|
||||
for (ValueSetExpansionContainsComponent nextCode : theContains) {
|
||||
|
||||
String system = nextCode.getSystem();
|
||||
String code = nextCode.getCode();
|
||||
if (theSystem.equals(system) && theCode.equals(code)) {
|
||||
ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.LookupCodeResult retVal = new LookupCodeResult();
|
||||
retVal.setSearchedForCode(code);
|
||||
retVal.setSearchedForSystem(system);
|
||||
retVal.setFound(true);
|
||||
if (nextCode.getAbstract() != null) {
|
||||
retVal.setCodeIsAbstract(nextCode.getAbstract().booleanValue());
|
||||
}
|
||||
retVal.setCodeDisplay(nextCode.getDisplay());
|
||||
retVal.setCodeSystemVersion(nextCode.getVersion());
|
||||
retVal.setCodeSystemDisplayName("Unknown"); // TODO: implement
|
||||
return retVal;
|
||||
String system = nextCode.getSystem();
|
||||
String code = nextCode.getCode();
|
||||
if (theSystem.equals(system) && theCode.equals(code)) {
|
||||
ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.LookupCodeResult retVal = new LookupCodeResult();
|
||||
retVal.setSearchedForCode(code);
|
||||
retVal.setSearchedForSystem(system);
|
||||
retVal.setFound(true);
|
||||
if (nextCode.getAbstractElement().getValue() != null) {
|
||||
retVal.setCodeIsAbstract(nextCode.getAbstractElement().booleanValue());
|
||||
}
|
||||
|
||||
retVal.setCodeDisplay(nextCode.getDisplay());
|
||||
retVal.setCodeSystemVersion(nextCode.getVersion());
|
||||
retVal.setCodeSystemDisplayName("Unknown"); // TODO: implement
|
||||
return retVal;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,21 @@ import java.util.Set;
|
|||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.hl7.fhir.dstu21.model.Bundle;
|
||||
import org.hl7.fhir.dstu21.model.Bundle.BundleEntryComponent;
|
||||
import org.hl7.fhir.dstu21.model.Bundle.BundleEntryResponseComponent;
|
||||
import org.hl7.fhir.dstu21.model.Bundle.BundleType;
|
||||
import org.hl7.fhir.dstu21.model.Bundle.HTTPVerb;
|
||||
import org.hl7.fhir.dstu21.model.IdType;
|
||||
import org.hl7.fhir.dstu21.model.Meta;
|
||||
import org.hl7.fhir.dstu21.model.OperationOutcome;
|
||||
import org.hl7.fhir.dstu21.model.OperationOutcome.IssueSeverity;
|
||||
import org.hl7.fhir.dstu21.model.Resource;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
|
@ -60,15 +73,6 @@ import ca.uhn.fhir.jpa.util.DeleteConflict;
|
|||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||
import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt;
|
||||
import ca.uhn.fhir.model.dstu21.composite.MetaDt;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Bundle.Entry;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Bundle.EntryResponse;
|
||||
import ca.uhn.fhir.model.dstu21.resource.OperationOutcome;
|
||||
import ca.uhn.fhir.model.dstu21.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.model.dstu21.valueset.HTTPVerbEnum;
|
||||
import ca.uhn.fhir.model.dstu21.valueset.IssueSeverityEnum;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
|
@ -90,7 +94,7 @@ import ca.uhn.fhir.util.FhirTerser;
|
|||
import ca.uhn.fhir.util.UrlUtil;
|
||||
import ca.uhn.fhir.util.UrlUtil.UrlParts;
|
||||
|
||||
public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
||||
public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, Meta> {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirSystemDaoDstu21.class);
|
||||
|
||||
@Autowired
|
||||
|
@ -104,7 +108,7 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||
|
||||
Bundle resp = new Bundle();
|
||||
resp.setType(BundleTypeEnum.BATCH_RESPONSE);
|
||||
resp.setType(BundleType.BATCHRESPONSE);
|
||||
OperationOutcome ooResp = new OperationOutcome();
|
||||
resp.addEntry().setResource(ooResp);
|
||||
|
||||
|
@ -112,13 +116,13 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
* For batch, we handle each entry as a mini-transaction in its own database transaction so that if one fails, it doesn't prevent others
|
||||
*/
|
||||
|
||||
for (final Entry nextRequestEntry : theRequest.getEntry()) {
|
||||
for (final BundleEntryComponent nextRequestEntry : theRequest.getEntry()) {
|
||||
|
||||
TransactionCallback<Bundle> callback = new TransactionCallback<Bundle>() {
|
||||
@Override
|
||||
public Bundle doInTransaction(TransactionStatus theStatus) {
|
||||
Bundle subRequestBundle = new Bundle();
|
||||
subRequestBundle.setType(BundleTypeEnum.TRANSACTION);
|
||||
subRequestBundle.setType(BundleType.TRANSACTION);
|
||||
subRequestBundle.addEntry(nextRequestEntry);
|
||||
|
||||
Bundle subResponseBundle = transaction((ServletRequestDetails) theRequestDetails, subRequestBundle, "Batch sub-request");
|
||||
|
@ -131,7 +135,7 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
Bundle nextResponseBundle = txTemplate.execute(callback);
|
||||
caughtEx = null;
|
||||
|
||||
Entry subResponseEntry = nextResponseBundle.getEntry().get(0);
|
||||
BundleEntryComponent subResponseEntry = nextResponseBundle.getEntry().get(0);
|
||||
resp.addEntry(subResponseEntry);
|
||||
/*
|
||||
* If the individual entry didn't have a resource in its response, bring the sub-transaction's OperationOutcome across so the client can see it
|
||||
|
@ -148,13 +152,13 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
}
|
||||
|
||||
if (caughtEx != null) {
|
||||
Entry nextEntry = resp.addEntry();
|
||||
BundleEntryComponent nextEntry = resp.addEntry();
|
||||
|
||||
OperationOutcome oo = new OperationOutcome();
|
||||
oo.addIssue().setSeverity(IssueSeverityEnum.ERROR).setDiagnostics(caughtEx.getMessage());
|
||||
oo.addIssue().setSeverity(IssueSeverity.ERROR).setDiagnostics(caughtEx.getMessage());
|
||||
nextEntry.setResource(oo);
|
||||
|
||||
EntryResponse nextEntryResp = nextEntry.getResponse();
|
||||
BundleEntryResponseComponent nextEntryResp = nextEntry.getResponse();
|
||||
nextEntryResp.setStatus(toStatusString(caughtEx.getStatusCode()));
|
||||
}
|
||||
|
||||
|
@ -162,12 +166,12 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
|
||||
long delay = System.currentTimeMillis() - start;
|
||||
ourLog.info("Batch completed in {}ms", new Object[] { delay });
|
||||
ooResp.addIssue().setSeverity(IssueSeverityEnum.INFORMATION).setDiagnostics("Batch completed in " + delay + "ms");
|
||||
ooResp.addIssue().setSeverity(IssueSeverity.INFORMATION).setDiagnostics("Batch completed in " + delay + "ms");
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
private String extractTransactionUrlOrThrowException(Entry nextEntry, HTTPVerbEnum verb) {
|
||||
private String extractTransactionUrlOrThrowException(BundleEntryComponent nextEntry, HTTPVerb verb) {
|
||||
String url = nextEntry.getRequest().getUrl();
|
||||
if (isBlank(url)) {
|
||||
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionMissingUrl", verb.name()));
|
||||
|
@ -189,8 +193,8 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
return p.parseResource(theResource.getClass(), p.encodeResourceToString(theResource));
|
||||
}
|
||||
|
||||
private IFhirResourceDao<?> getDaoOrThrowException(Class<? extends IResource> theClass) {
|
||||
IFhirResourceDao<? extends IResource> retVal = getDao(theClass);
|
||||
private IFhirResourceDao<?> getDaoOrThrowException(Class<? extends IBaseResource> theClass) {
|
||||
IFhirResourceDao<? extends IBaseResource> retVal = getDao(theClass);
|
||||
if (retVal == null) {
|
||||
throw new InvalidRequestException("Unable to process request, this server does not know how to handle resources of type " + getContext().getResourceDefinition(theClass).getName());
|
||||
}
|
||||
|
@ -198,7 +202,7 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public MetaDt metaGetOperation() {
|
||||
public Meta metaGetOperation() {
|
||||
// Notify interceptors
|
||||
ActionRequestDetails requestDetails = new ActionRequestDetails(null, null);
|
||||
notifyInterceptors(RestOperationTypeEnum.META, requestDetails);
|
||||
|
@ -207,13 +211,13 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
TypedQuery<TagDefinition> q = myEntityManager.createQuery(sql, TagDefinition.class);
|
||||
List<TagDefinition> tagDefinitions = q.getResultList();
|
||||
|
||||
MetaDt retVal = toMetaDt(tagDefinitions);
|
||||
Meta retVal = toMeta(tagDefinitions);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
protected MetaDt toMetaDt(Collection<TagDefinition> tagDefinitions) {
|
||||
MetaDt retVal = new MetaDt();
|
||||
protected Meta toMeta(Collection<TagDefinition> tagDefinitions) {
|
||||
Meta retVal = new Meta();
|
||||
for (TagDefinition next : tagDefinitions) {
|
||||
switch (next.getTagType()) {
|
||||
case PROFILE:
|
||||
|
@ -268,18 +272,18 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Bundle transaction(ServletRequestDetails theRequestDetails, Bundle theRequest, String theActionName) {
|
||||
BundleTypeEnum transactionType = theRequest.getTypeElement().getValueAsEnum();
|
||||
if (transactionType == BundleTypeEnum.BATCH) {
|
||||
BundleType transactionType = theRequest.getTypeElement().getValue();
|
||||
if (transactionType == BundleType.BATCH) {
|
||||
return batch(theRequestDetails, theRequest);
|
||||
}
|
||||
|
||||
if (transactionType == null) {
|
||||
String message = "Transactiion Bundle did not specify valid Bundle.type, assuming " + BundleTypeEnum.TRANSACTION.getCode();
|
||||
String message = "Transactiion Bundle did not specify valid Bundle.type, assuming " + BundleType.TRANSACTION.toCode();
|
||||
ourLog.warn(message);
|
||||
transactionType = BundleTypeEnum.TRANSACTION;
|
||||
transactionType = BundleType.TRANSACTION;
|
||||
}
|
||||
if (transactionType != BundleTypeEnum.TRANSACTION) {
|
||||
throw new InvalidRequestException("Unable to process transaction where incoming Bundle.type = " + transactionType.getCode());
|
||||
if (transactionType != BundleType.TRANSACTION) {
|
||||
throw new InvalidRequestException("Unable to process transaction where incoming Bundle.type = " + transactionType.toCode());
|
||||
}
|
||||
|
||||
ourLog.info("Beginning {} with {} resources", theActionName, theRequest.getEntry().size());
|
||||
|
@ -287,9 +291,9 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
long start = System.currentTimeMillis();
|
||||
Date updateTime = new Date();
|
||||
|
||||
Set<IdDt> allIds = new LinkedHashSet<IdDt>();
|
||||
Map<IdDt, IdDt> idSubstitutions = new HashMap<IdDt, IdDt>();
|
||||
Map<IdDt, DaoMethodOutcome> idToPersistedOutcome = new HashMap<IdDt, DaoMethodOutcome>();
|
||||
Set<IdType> allIds = new LinkedHashSet<IdType>();
|
||||
Map<IdType, IdType> idSubstitutions = new HashMap<IdType, IdType>();
|
||||
Map<IdType, DaoMethodOutcome> idToPersistedOutcome = new HashMap<IdType, DaoMethodOutcome>();
|
||||
|
||||
/*
|
||||
* We want to execute the transaction request bundle elements in the order
|
||||
|
@ -302,12 +306,12 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
* we want the GET processing to use the final indexing state
|
||||
*/
|
||||
Bundle response = new Bundle();
|
||||
List<Entry> getEntries = new ArrayList<Entry>();
|
||||
IdentityHashMap<Entry, Integer> originalRequestOrder = new IdentityHashMap<Bundle.Entry, Integer>();
|
||||
List<BundleEntryComponent> getEntries = new ArrayList<BundleEntryComponent>();
|
||||
IdentityHashMap<BundleEntryComponent, Integer> originalRequestOrder = new IdentityHashMap<Bundle.BundleEntryComponent, Integer>();
|
||||
for (int i = 0; i < theRequest.getEntry().size(); i++) {
|
||||
originalRequestOrder.put(theRequest.getEntry().get(i), i);
|
||||
response.addEntry();
|
||||
if (theRequest.getEntry().get(i).getRequest().getMethodElement().getValueAsEnum() == HTTPVerbEnum.GET) {
|
||||
if (theRequest.getEntry().get(i).getRequest().getMethodElement().getValue() == HTTPVerb.GET) {
|
||||
getEntries.add(theRequest.getEntry().get(i));
|
||||
}
|
||||
}
|
||||
|
@ -326,16 +330,16 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
ourLog.info("Processed {} non-GET entries out of {}", i, theRequest.getEntry().size());
|
||||
}
|
||||
|
||||
Entry nextReqEntry = theRequest.getEntry().get(i);
|
||||
IResource res = nextReqEntry.getResource();
|
||||
IdDt nextResourceId = null;
|
||||
BundleEntryComponent nextReqEntry = theRequest.getEntry().get(i);
|
||||
Resource res = nextReqEntry.getResource();
|
||||
IdType nextResourceId = null;
|
||||
if (res != null) {
|
||||
|
||||
nextResourceId = res.getId();
|
||||
nextResourceId = res.getIdElement();
|
||||
|
||||
if (nextResourceId.hasIdPart() == false) {
|
||||
if (isNotBlank(nextReqEntry.getFullUrl())) {
|
||||
nextResourceId = new IdDt(nextReqEntry.getFullUrl());
|
||||
nextResourceId = new IdType(nextReqEntry.getFullUrl());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -344,7 +348,7 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
}
|
||||
|
||||
if (nextResourceId.hasIdPart() && !nextResourceId.hasResourceType() && !isPlaceholder(nextResourceId)) {
|
||||
nextResourceId = new IdDt(toResourceName(res.getClass()), nextResourceId.getIdPart());
|
||||
nextResourceId = new IdType(toResourceName(res.getClass()), nextResourceId.getIdPart());
|
||||
res.setId(nextResourceId);
|
||||
}
|
||||
|
||||
|
@ -356,7 +360,7 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionContainsMultipleWithDuplicateId", nextResourceId));
|
||||
}
|
||||
} else if (nextResourceId.hasResourceType() && nextResourceId.hasIdPart()) {
|
||||
IdDt nextId = nextResourceId.toUnqualifiedVersionless();
|
||||
IdType nextId = nextResourceId.toUnqualifiedVersionless();
|
||||
if (!allIds.add(nextId)) {
|
||||
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionContainsMultipleWithDuplicateId", nextId));
|
||||
}
|
||||
|
@ -364,13 +368,13 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
|
||||
}
|
||||
|
||||
HTTPVerbEnum verb = nextReqEntry.getRequest().getMethodElement().getValueAsEnum();
|
||||
HTTPVerb verb = nextReqEntry.getRequest().getMethodElement().getValue();
|
||||
if (verb == null) {
|
||||
throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionEntryHasInvalidVerb", nextReqEntry.getRequest().getMethod()));
|
||||
}
|
||||
|
||||
String resourceType = res != null ? getContext().getResourceDefinition(res).getName() : null;
|
||||
Entry nextRespEntry = response.getEntry().get(originalRequestOrder.get(nextReqEntry));
|
||||
BundleEntryComponent nextRespEntry = response.getEntry().get(originalRequestOrder.get(nextReqEntry));
|
||||
|
||||
switch (verb) {
|
||||
case POST: {
|
||||
|
@ -387,10 +391,10 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
// DELETE
|
||||
String url = extractTransactionUrlOrThrowException(nextReqEntry, verb);
|
||||
UrlParts parts = UrlUtil.parseUrl(url);
|
||||
ca.uhn.fhir.jpa.dao.IFhirResourceDao<? extends IBaseResource> dao = toDao(parts, verb.getCode(), url);
|
||||
ca.uhn.fhir.jpa.dao.IFhirResourceDao<? extends IBaseResource> dao = toDao(parts, verb.toCode(), url);
|
||||
int status = Constants.STATUS_HTTP_204_NO_CONTENT;
|
||||
if (parts.getResourceId() != null) {
|
||||
ResourceTable deleted = dao.delete(new IdDt(parts.getResourceType(), parts.getResourceId()), deleteConflicts);
|
||||
ResourceTable deleted = dao.delete(new IdType(parts.getResourceType(), parts.getResourceId()), deleteConflicts);
|
||||
if (deleted != null) {
|
||||
deletedResources.add(deleted.getIdDt().toUnqualifiedVersionless());
|
||||
}
|
||||
|
@ -418,7 +422,7 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
|
||||
UrlParts parts = UrlUtil.parseUrl(url);
|
||||
if (isNotBlank(parts.getResourceId())) {
|
||||
res.setId(new IdDt(parts.getResourceType(), parts.getResourceId()));
|
||||
res.setId(new IdType(parts.getResourceType(), parts.getResourceId()));
|
||||
outcome = resourceDao.update(res, null, false);
|
||||
} else {
|
||||
res.setId((String) null);
|
||||
|
@ -452,24 +456,24 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
|
||||
FhirTerser terser = getContext().newTerser();
|
||||
for (DaoMethodOutcome nextOutcome : idToPersistedOutcome.values()) {
|
||||
IResource nextResource = (IResource) nextOutcome.getResource();
|
||||
IBaseResource nextResource = (IBaseResource) nextOutcome.getResource();
|
||||
if (nextResource == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<BaseResourceReferenceDt> allRefs = terser.getAllPopulatedChildElementsOfType(nextResource, BaseResourceReferenceDt.class);
|
||||
for (BaseResourceReferenceDt nextRef : allRefs) {
|
||||
IdDt nextId = nextRef.getReference();
|
||||
List<IBaseReference> allRefs = terser.getAllPopulatedChildElementsOfType(nextResource, IBaseReference.class);
|
||||
for (IBaseReference nextRef : allRefs) {
|
||||
IIdType nextId = nextRef.getReferenceElement();
|
||||
if (idSubstitutions.containsKey(nextId)) {
|
||||
IdDt newId = idSubstitutions.get(nextId);
|
||||
IdType newId = idSubstitutions.get(nextId);
|
||||
ourLog.info(" * Replacing resource ref {} with {}", nextId, newId);
|
||||
nextRef.setReference(newId);
|
||||
nextRef.setReference(newId.getValue());
|
||||
} else {
|
||||
ourLog.debug(" * Reference [{}] does not exist in bundle", nextId);
|
||||
}
|
||||
}
|
||||
|
||||
InstantDt deletedInstantOrNull = ResourceMetadataKeyEnum.DELETED_AT.get(nextResource);
|
||||
IPrimitiveType<Date> deletedInstantOrNull = ResourceMetadataKeyEnum.DELETED_AT.get((IAnyResource) nextResource);
|
||||
Date deletedTimestampOrNull = deletedInstantOrNull != null ? deletedInstantOrNull.getValue() : null;
|
||||
updateEntity(nextResource, nextOutcome.getEntity(), false, deletedTimestampOrNull, true, false, updateTime);
|
||||
}
|
||||
|
@ -479,8 +483,8 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
/*
|
||||
* Double check we didn't allow any duplicates we shouldn't have
|
||||
*/
|
||||
for (Entry nextEntry : theRequest.getEntry()) {
|
||||
if (nextEntry.getRequest().getMethodElement().getValueAsEnum() == HTTPVerbEnum.POST) {
|
||||
for (BundleEntryComponent nextEntry : theRequest.getEntry()) {
|
||||
if (nextEntry.getRequest().getMethodElement().getValue() == HTTPVerb.POST) {
|
||||
String matchUrl = nextEntry.getRequest().getIfNoneExist();
|
||||
if (isNotBlank(matchUrl)) {
|
||||
IFhirResourceDao<?> resourceDao = getDao(nextEntry.getResource().getClass());
|
||||
|
@ -493,8 +497,8 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
}
|
||||
}
|
||||
|
||||
for (IdDt next : allIds) {
|
||||
IdDt replacement = idSubstitutions.get(next);
|
||||
for (IdType next : allIds) {
|
||||
IdType replacement = idSubstitutions.get(next);
|
||||
if (replacement == null) {
|
||||
continue;
|
||||
}
|
||||
|
@ -508,16 +512,16 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
* Loop through the request and process any entries of type GET
|
||||
*/
|
||||
for (int i = 0; i < getEntries.size(); i++) {
|
||||
Entry nextReqEntry = getEntries.get(i);
|
||||
BundleEntryComponent nextReqEntry = getEntries.get(i);
|
||||
Integer originalOrder = originalRequestOrder.get(nextReqEntry);
|
||||
Entry nextRespEntry = response.getEntry().get(originalOrder);
|
||||
BundleEntryComponent nextRespEntry = response.getEntry().get(originalOrder);
|
||||
|
||||
ServletSubRequestDetails requestDetails = new ServletSubRequestDetails();
|
||||
requestDetails.setServletRequest(theRequestDetails.getServletRequest());
|
||||
requestDetails.setRequestType(RequestTypeEnum.GET);
|
||||
requestDetails.setServer(theRequestDetails.getServer());
|
||||
|
||||
String url = extractTransactionUrlOrThrowException(nextReqEntry, HTTPVerbEnum.GET);
|
||||
String url = extractTransactionUrlOrThrowException(nextReqEntry, HTTPVerb.GET);
|
||||
|
||||
int qIndex = url.indexOf('?');
|
||||
ArrayListMultimap<String, String> paramValues = ArrayListMultimap.create();
|
||||
|
@ -561,7 +565,7 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
if (paramValues.containsKey(Constants.PARAM_SUMMARY) || paramValues.containsKey(Constants.PARAM_CONTENT)) {
|
||||
resource = filterNestedBundle(requestDetails, resource);
|
||||
}
|
||||
nextRespEntry.setResource((IResource) resource);
|
||||
nextRespEntry.setResource((Resource) resource);
|
||||
nextRespEntry.getResponse().setStatus(toStatusString(Constants.STATUS_HTTP_200_OK));
|
||||
} catch (NotModifiedException e) {
|
||||
nextRespEntry.getResponse().setStatus(toStatusString(Constants.STATUS_HTTP_304_NOT_MODIFIED));
|
||||
|
@ -575,21 +579,21 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
long delay = System.currentTimeMillis() - start;
|
||||
ourLog.info(theActionName + " completed in {}ms", new Object[] { delay });
|
||||
|
||||
response.setType(BundleTypeEnum.TRANSACTION_RESPONSE);
|
||||
response.setType(BundleType.TRANSACTIONRESPONSE);
|
||||
return response;
|
||||
}
|
||||
|
||||
private static void handleTransactionCreateOrUpdateOutcome(Map<IdDt, IdDt> idSubstitutions, Map<IdDt, DaoMethodOutcome> idToPersistedOutcome, IdDt nextResourceId, DaoMethodOutcome outcome,
|
||||
Entry newEntry, String theResourceType, IResource theRes) {
|
||||
IdDt newId = (IdDt) outcome.getId().toUnqualifiedVersionless();
|
||||
IdDt resourceId = isPlaceholder(nextResourceId) ? nextResourceId : nextResourceId.toUnqualifiedVersionless();
|
||||
private static void handleTransactionCreateOrUpdateOutcome(Map<IdType, IdType> idSubstitutions, Map<IdType, DaoMethodOutcome> idToPersistedOutcome, IdType nextResourceId, DaoMethodOutcome outcome,
|
||||
BundleEntryComponent newEntry, String theResourceType, IBaseResource theRes) {
|
||||
IdType newId = (IdType) outcome.getId().toUnqualifiedVersionless();
|
||||
IdType resourceId = isPlaceholder(nextResourceId) ? nextResourceId : nextResourceId.toUnqualifiedVersionless();
|
||||
if (newId.equals(resourceId) == false) {
|
||||
idSubstitutions.put(resourceId, newId);
|
||||
if (isPlaceholder(resourceId)) {
|
||||
/*
|
||||
* The correct way for substitution IDs to be is to be with no resource type, but we'll accept the qualified kind too just to be lenient.
|
||||
*/
|
||||
idSubstitutions.put(new IdDt(theResourceType + '/' + resourceId.getValue()), newId);
|
||||
idSubstitutions.put(new IdType(theResourceType + '/' + resourceId.getValue()), newId);
|
||||
}
|
||||
}
|
||||
idToPersistedOutcome.put(newId, outcome);
|
||||
|
@ -600,10 +604,10 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
}
|
||||
newEntry.getResponse().setLocation(outcome.getId().toUnqualified().getValue());
|
||||
newEntry.getResponse().setEtag(outcome.getId().getVersionIdPart());
|
||||
newEntry.getResponse().setLastModified(ResourceMetadataKeyEnum.UPDATED.get(theRes));
|
||||
newEntry.getResponse().setLastModified(((Resource)theRes).getMeta().getLastUpdated());
|
||||
}
|
||||
|
||||
private static boolean isPlaceholder(IdDt theId) {
|
||||
private static boolean isPlaceholder(IdType theId) {
|
||||
if ("urn:oid:".equals(theId.getBaseUrl()) || "urn:uuid:".equals(theId.getBaseUrl())) {
|
||||
return true;
|
||||
}
|
||||
|
@ -624,20 +628,20 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
* Process any GET interactions
|
||||
*/
|
||||
//@formatter:off
|
||||
public class TransactionSorter implements Comparator<Entry> {
|
||||
public class TransactionSorter implements Comparator<BundleEntryComponent> {
|
||||
|
||||
@Override
|
||||
public int compare(Entry theO1, Entry theO2) {
|
||||
public int compare(BundleEntryComponent theO1, BundleEntryComponent theO2) {
|
||||
int o1 = toOrder(theO1);
|
||||
int o2 = toOrder(theO2);
|
||||
|
||||
return o1 - o2;
|
||||
}
|
||||
|
||||
private int toOrder(Entry theO1) {
|
||||
private int toOrder(BundleEntryComponent theO1) {
|
||||
int o1 = 0;
|
||||
if (theO1.getRequest().getMethodElement().getValueAsEnum() != null) {
|
||||
switch (theO1.getRequest().getMethodElement().getValueAsEnum()) {
|
||||
if (theO1.getRequest().getMethodElement().getValue() != null) {
|
||||
switch (theO1.getRequest().getMethodElement().getValue()) {
|
||||
case DELETE:
|
||||
o1 = 1;
|
||||
break;
|
||||
|
@ -650,6 +654,9 @@ public class FhirSystemDaoDstu21 extends BaseHapiFhirSystemDao<Bundle, MetaDt> {
|
|||
case GET:
|
||||
o1 = 4;
|
||||
break;
|
||||
case NULL:
|
||||
o1 = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return o1;
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package ca.uhn.fhir.jpa.dao;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.jpa.entity.BaseHasResource;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum.ResourceMetadataKeySupportingAnyResource;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
|
@ -28,7 +30,7 @@ import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
|||
|
||||
public interface IDao {
|
||||
|
||||
public static final ResourceMetadataKeyEnum<Long> RESOURCE_PID = new ResourceMetadataKeyEnum<Long>("RESOURCE_PID") {
|
||||
public static final ResourceMetadataKeySupportingAnyResource<Long, Long> RESOURCE_PID = new ResourceMetadataKeySupportingAnyResource<Long, Long>("RESOURCE_PID") {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -41,6 +43,16 @@ public interface IDao {
|
|||
public void put(IResource theResource, Long theObject) {
|
||||
theResource.getResourceMetadata().put(RESOURCE_PID, theObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long get(IAnyResource theResource) {
|
||||
return (Long) theResource.getUserData(RESOURCE_PID.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(IAnyResource theResource, Long theObject) {
|
||||
theResource.setUserData(RESOURCE_PID.name(), theObject);
|
||||
}
|
||||
};
|
||||
|
||||
IBaseResource toResource(BaseHasResource theEntity, boolean theForHistoryOperation);
|
||||
|
|
|
@ -23,17 +23,17 @@ import javax.servlet.http.HttpServletRequest;
|
|||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.UnsignedIntDt;
|
||||
import ca.uhn.fhir.rest.api.SortSpec;
|
||||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||
import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||
|
||||
public interface IFhirResourceDaoEncounter<T extends IBaseResource> extends IFhirResourceDao<T> {
|
||||
|
||||
IBundleProvider encounterInstanceEverything(HttpServletRequest theServletRequest, IdDt theId, UnsignedIntDt theCount, DateRangeParam theLastUpdate, SortSpec theSort);
|
||||
IBundleProvider encounterInstanceEverything(HttpServletRequest theServletRequest, IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdate, SortSpec theSort);
|
||||
|
||||
IBundleProvider encounterTypeEverything(HttpServletRequest theServletRequest, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSortSpec);
|
||||
IBundleProvider encounterTypeEverything(HttpServletRequest theServletRequest, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSortSpec);
|
||||
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ import javax.servlet.http.HttpServletRequest;
|
|||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.model.primitive.UnsignedIntDt;
|
||||
import ca.uhn.fhir.rest.api.SortSpec;
|
||||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||
import ca.uhn.fhir.rest.param.StringAndListParam;
|
||||
|
@ -33,8 +33,8 @@ import ca.uhn.fhir.rest.server.IBundleProvider;
|
|||
|
||||
public interface IFhirResourceDaoPatient<T extends IBaseResource> extends IFhirResourceDao<T> {
|
||||
|
||||
IBundleProvider patientInstanceEverything(HttpServletRequest theServletRequest, IIdType theId, UnsignedIntDt theCount, DateRangeParam theLastUpdate, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative);
|
||||
IBundleProvider patientInstanceEverything(HttpServletRequest theServletRequest, IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdate, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative);
|
||||
|
||||
IBundleProvider patientTypeEverything(HttpServletRequest theServletRequest, UnsignedIntDt theCount, DateRangeParam theLastUpdated, SortSpec theSortSpec, StringAndListParam theContent, StringAndListParam theNarrative);
|
||||
IBundleProvider patientTypeEverything(HttpServletRequest theServletRequest, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSortSpec, StringAndListParam theContent, StringAndListParam theNarrative);
|
||||
|
||||
}
|
||||
|
|
|
@ -22,10 +22,7 @@ package ca.uhn.fhir.jpa.dao;
|
|||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.model.primitive.CodeDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
public interface IFhirResourceDaoValueSet<T extends IBaseResource, CD, CC> extends IFhirResourceDao<T> {
|
||||
|
||||
|
@ -35,9 +32,9 @@ public interface IFhirResourceDaoValueSet<T extends IBaseResource, CD, CC> exten
|
|||
|
||||
T expandByIdentifier(String theUri, String theFilter);
|
||||
|
||||
LookupCodeResult lookupCode(CodeDt theCode, UriDt theSystem, CD theCoding);
|
||||
LookupCodeResult lookupCode(IPrimitiveType<String> theCode, IPrimitiveType<String> theSystem, CD theCoding);
|
||||
|
||||
ValidateCodeResult validateCode(UriDt theValueSetIdentifier, IIdType theId, CodeDt theCode, UriDt theSystem, StringDt theDisplay, CD theCoding, CC theCodeableConcept);
|
||||
ValidateCodeResult validateCode(IPrimitiveType<String> theValueSetIdentifier, IIdType theId, IPrimitiveType<String> theCode, IPrimitiveType<String> theSystem, IPrimitiveType<String> theDisplay, CD theCoding, CC theCodeableConcept);
|
||||
|
||||
public class LookupCodeResult {
|
||||
private String myCodeDisplay;
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package ca.uhn.fhir.jpa.dao;
|
||||
|
||||
import org.hl7.fhir.instance.hapi.validation.IValidationSupport;
|
||||
|
||||
public interface IJpaValidationSupportDstu2 extends IValidationSupport {
|
||||
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package ca.uhn.fhir.jpa.dao;
|
||||
|
||||
import org.hl7.fhir.dstu21.hapi.validation.IValidationSupport;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
|
@ -20,8 +22,6 @@ package ca.uhn.fhir.jpa.dao;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.validation.IValidationSupport;
|
||||
|
||||
public interface IJpaValidationSupport extends IValidationSupport {
|
||||
public interface IJpaValidationSupportDstu21 extends IValidationSupport {
|
||||
|
||||
}
|
|
@ -22,6 +22,8 @@ package ca.uhn.fhir.jpa.dao;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.jpa.entity.BaseResourceIndexedSearchParam;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamCoords;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamDate;
|
||||
|
@ -30,22 +32,21 @@ import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamQuantity;
|
|||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamUri;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
|
||||
interface ISearchParamExtractor {
|
||||
|
||||
public abstract Set<ResourceIndexedSearchParamCoords> extractSearchParamCoords(ResourceTable theEntity, IResource theResource);
|
||||
public abstract Set<ResourceIndexedSearchParamCoords> extractSearchParamCoords(ResourceTable theEntity, IBaseResource theResource);
|
||||
|
||||
public abstract Set<ResourceIndexedSearchParamDate> extractSearchParamDates(ResourceTable theEntity, IResource theResource);
|
||||
public abstract Set<ResourceIndexedSearchParamDate> extractSearchParamDates(ResourceTable theEntity, IBaseResource theResource);
|
||||
|
||||
public abstract Set<ResourceIndexedSearchParamNumber> extractSearchParamNumber(ResourceTable theEntity, IResource theResource);
|
||||
public abstract Set<ResourceIndexedSearchParamNumber> extractSearchParamNumber(ResourceTable theEntity, IBaseResource theResource);
|
||||
|
||||
public abstract Set<ResourceIndexedSearchParamQuantity> extractSearchParamQuantity(ResourceTable theEntity, IResource theResource);
|
||||
public abstract Set<ResourceIndexedSearchParamQuantity> extractSearchParamQuantity(ResourceTable theEntity, IBaseResource theResource);
|
||||
|
||||
public abstract Set<ResourceIndexedSearchParamString> extractSearchParamStrings(ResourceTable theEntity, IResource theResource);
|
||||
public abstract Set<ResourceIndexedSearchParamString> extractSearchParamStrings(ResourceTable theEntity, IBaseResource theResource);
|
||||
|
||||
public abstract Set<BaseResourceIndexedSearchParam> extractSearchParamTokens(ResourceTable theEntity, IResource theResource);
|
||||
public abstract Set<BaseResourceIndexedSearchParam> extractSearchParamTokens(ResourceTable theEntity, IBaseResource theResource);
|
||||
|
||||
public abstract Set<ResourceIndexedSearchParamUri> extractSearchParamUri(ResourceTable theEntity, IResource theResource);
|
||||
public abstract Set<ResourceIndexedSearchParamUri> extractSearchParamUri(ResourceTable theEntity, IBaseResource theResource);
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
import ca.uhn.fhir.rest.param.UriParam;
|
||||
import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||
|
||||
public class JpaValidationSupportDstu2 implements IJpaValidationSupport {
|
||||
public class JpaValidationSupportDstu2 implements IJpaValidationSupportDstu2 {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(JpaValidationSupportDstu2.class);
|
||||
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package ca.uhn.fhir.jpa.dao;
|
||||
|
||||
import org.hl7.fhir.dstu21.model.IdType;
|
||||
import org.hl7.fhir.dstu21.model.StructureDefinition;
|
||||
import org.hl7.fhir.dstu21.model.ValueSet;
|
||||
import org.hl7.fhir.dstu21.model.ValueSet.ConceptSetComponent;
|
||||
import org.hl7.fhir.dstu21.model.ValueSet.ValueSetExpansionComponent;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
|
@ -20,32 +26,26 @@ package ca.uhn.fhir.jpa.dao;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import org.hl7.fhir.instance.model.ValueSet;
|
||||
import org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent;
|
||||
import org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionComponent;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.param.UriParam;
|
||||
import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||
|
||||
public class JpaValidationSupportDstu21 implements IJpaValidationSupport {
|
||||
public class JpaValidationSupportDstu21 implements IJpaValidationSupportDstu21 {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(JpaValidationSupportDstu21.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("myFhirContextDstu2Hl7Org")
|
||||
private FhirContext myRiCtx;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("myStructureDefinitionDaoDstu21")
|
||||
private IFhirResourceDao<ca.uhn.fhir.model.dstu21.resource.StructureDefinition> myStructureDefinitionDao;
|
||||
private IFhirResourceDao<StructureDefinition> myStructureDefinitionDao;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("myValueSetDaoDstu21")
|
||||
private IFhirResourceDao<ca.uhn.fhir.model.dstu21.resource.ValueSet> myValueSetDao;
|
||||
private IFhirResourceDao<ValueSet> myValueSetDao;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("myFhirContextDstu21")
|
||||
|
@ -63,10 +63,20 @@ public class JpaValidationSupportDstu21 implements IJpaValidationSupport {
|
|||
|
||||
@Override
|
||||
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {
|
||||
String resourceName = myRiCtx.getResourceDefinition(theClass).getName();
|
||||
IdType id = new IdType(theUri);
|
||||
boolean localReference = false;
|
||||
if (id.hasBaseUrl() == false && id.hasIdPart() == true) {
|
||||
localReference = true;
|
||||
}
|
||||
|
||||
String resourceName = myDstu21Ctx.getResourceDefinition(theClass).getName();
|
||||
IBundleProvider search;
|
||||
if ("ValueSet".equals(resourceName)) {
|
||||
search = myValueSetDao.search(ca.uhn.fhir.model.dstu2.resource.ValueSet.SP_URL, new UriParam(theUri));
|
||||
if (localReference) {
|
||||
search = myValueSetDao.search(ca.uhn.fhir.model.dstu2.resource.ValueSet.SP_RES_ID, new StringParam(theUri));
|
||||
} else {
|
||||
search = myValueSetDao.search(ca.uhn.fhir.model.dstu2.resource.ValueSet.SP_URL, new UriParam(theUri));
|
||||
}
|
||||
} else if ("StructureDefinition".equals(resourceName)) {
|
||||
search = myStructureDefinitionDao.search(ca.uhn.fhir.model.dstu2.resource.StructureDefinition.SP_URL, new UriParam(theUri));
|
||||
} else {
|
||||
|
@ -81,15 +91,7 @@ public class JpaValidationSupportDstu21 implements IJpaValidationSupport {
|
|||
ourLog.warn("Found multiple {} instances with URL search value of: {}", resourceName, theUri);
|
||||
}
|
||||
|
||||
IBaseResource res = search.getResources(0, 1).get(0);
|
||||
|
||||
/*
|
||||
* Validator wants RI structures and not HAPI ones, so convert
|
||||
*
|
||||
* TODO: we really need a more efficient way of converting.. Or maybe this will just go away when we move to RI structures
|
||||
*/
|
||||
String encoded = myDstu21Ctx.newJsonParser().encodeResourceToString(res);
|
||||
return myRiCtx.newJsonParser().parseResource(theClass, encoded);
|
||||
return (T) search.getResources(0, 1).get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -55,6 +55,7 @@ import javax.persistence.criteria.Root;
|
|||
import javax.persistence.criteria.Subquery;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
@ -1302,17 +1303,25 @@ public class SearchBuilder {
|
|||
|
||||
for (ResourceTable next : q.getResultList()) {
|
||||
Class<? extends IBaseResource> resourceType = myContext.getResourceDefinition(next.getResourceType()).getImplementingClass();
|
||||
IResource resource = (IResource) myCallingDao.toResource(resourceType, next, theForHistoryOperation);
|
||||
IBaseResource resource = (IBaseResource) myCallingDao.toResource(resourceType, next, theForHistoryOperation);
|
||||
Integer index = position.get(next.getId());
|
||||
if (index == null) {
|
||||
ourLog.warn("Got back unexpected resource PID {}", next.getId());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (theRevIncludedPids.contains(next.getId())) {
|
||||
ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.put(resource, BundleEntrySearchModeEnum.INCLUDE);
|
||||
if (resource instanceof IResource) {
|
||||
if (theRevIncludedPids.contains(next.getId())) {
|
||||
ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.put((IResource)resource, BundleEntrySearchModeEnum.INCLUDE);
|
||||
} else {
|
||||
ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.put((IResource)resource, BundleEntrySearchModeEnum.MATCH);
|
||||
}
|
||||
} else {
|
||||
ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.put(resource, BundleEntrySearchModeEnum.MATCH);
|
||||
if (theRevIncludedPids.contains(next.getId())) {
|
||||
ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.put((IAnyResource)resource, BundleEntrySearchModeEnum.INCLUDE.getCode());
|
||||
} else {
|
||||
ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.put((IAnyResource)resource, BundleEntrySearchModeEnum.MATCH.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
theResourceListToPopulate.set(index, resource);
|
||||
|
|
|
@ -35,6 +35,7 @@ import javax.measure.unit.NonSI;
|
|||
import javax.measure.unit.Unit;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -51,7 +52,6 @@ import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamUri;
|
|||
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.base.composite.BaseHumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.AddressDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.CodeableConceptDt;
|
||||
|
@ -75,12 +75,12 @@ public class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<ResourceIndexedSearchParamCoords> extractSearchParamCoords(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<ResourceIndexedSearchParamCoords> extractSearchParamCoords(ResourceTable theEntity, IBaseResource theResource) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ResourceIndexedSearchParamDate> extractSearchParamDates(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<ResourceIndexedSearchParamDate> extractSearchParamDates(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<ResourceIndexedSearchParamDate> retVal = new HashSet<ResourceIndexedSearchParamDate>();
|
||||
|
||||
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
|
||||
|
@ -135,7 +135,7 @@ public class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public HashSet<ResourceIndexedSearchParamNumber> extractSearchParamNumber(ResourceTable theEntity, IResource theResource) {
|
||||
public HashSet<ResourceIndexedSearchParamNumber> extractSearchParamNumber(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<ResourceIndexedSearchParamNumber> retVal = new HashSet<ResourceIndexedSearchParamNumber>();
|
||||
|
||||
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
|
||||
|
@ -230,7 +230,7 @@ public class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<ResourceIndexedSearchParamQuantity> extractSearchParamQuantity(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<ResourceIndexedSearchParamQuantity> extractSearchParamQuantity(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<ResourceIndexedSearchParamQuantity> retVal = new HashSet<ResourceIndexedSearchParamQuantity>();
|
||||
|
||||
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
|
||||
|
@ -278,7 +278,7 @@ public class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<ResourceIndexedSearchParamString> extractSearchParamStrings(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<ResourceIndexedSearchParamString> extractSearchParamStrings(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<ResourceIndexedSearchParamString> retVal = new HashSet<ResourceIndexedSearchParamString>();
|
||||
|
||||
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
|
||||
|
@ -364,7 +364,7 @@ public class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<BaseResourceIndexedSearchParam> extractSearchParamTokens(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<BaseResourceIndexedSearchParam> extractSearchParamTokens(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<BaseResourceIndexedSearchParam> retVal = new HashSet<BaseResourceIndexedSearchParam>();
|
||||
|
||||
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
|
||||
|
@ -472,7 +472,7 @@ public class SearchParamExtractorDstu1 extends BaseSearchParamExtractor implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<ResourceIndexedSearchParamUri> extractSearchParamUri(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<ResourceIndexedSearchParamUri> extractSearchParamUri(ResourceTable theEntity, IBaseResource theResource) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import javax.measure.unit.Unit;
|
|||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -51,7 +52,6 @@ import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamUri;
|
|||
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
|
||||
import ca.uhn.fhir.model.base.composite.BaseHumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.AddressDt;
|
||||
|
@ -109,7 +109,7 @@ public class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<ResourceIndexedSearchParamCoords> extractSearchParamCoords(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<ResourceIndexedSearchParamCoords> extractSearchParamCoords(ResourceTable theEntity, IBaseResource theResource) {
|
||||
// TODO: implement
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implemen
|
|||
* ca.uhn.fhir.model.api.IResource)
|
||||
*/
|
||||
@Override
|
||||
public Set<ResourceIndexedSearchParamDate> extractSearchParamDates(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<ResourceIndexedSearchParamDate> extractSearchParamDates(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<ResourceIndexedSearchParamDate> retVal = new HashSet<ResourceIndexedSearchParamDate>();
|
||||
|
||||
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
|
||||
|
@ -182,7 +182,7 @@ public class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implemen
|
|||
* ca.uhn.fhir.model.api.IResource)
|
||||
*/
|
||||
@Override
|
||||
public HashSet<ResourceIndexedSearchParamNumber> extractSearchParamNumber(ResourceTable theEntity, IResource theResource) {
|
||||
public HashSet<ResourceIndexedSearchParamNumber> extractSearchParamNumber(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<ResourceIndexedSearchParamNumber> retVal = new HashSet<ResourceIndexedSearchParamNumber>();
|
||||
|
||||
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
|
||||
|
@ -282,7 +282,7 @@ public class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implemen
|
|||
* ca.uhn.fhir.model.api.IResource)
|
||||
*/
|
||||
@Override
|
||||
public Set<ResourceIndexedSearchParamQuantity> extractSearchParamQuantity(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<ResourceIndexedSearchParamQuantity> extractSearchParamQuantity(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<ResourceIndexedSearchParamQuantity> retVal = new HashSet<ResourceIndexedSearchParamQuantity>();
|
||||
|
||||
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
|
||||
|
@ -336,7 +336,7 @@ public class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implemen
|
|||
* ca.uhn.fhir.model.api.IResource)
|
||||
*/
|
||||
@Override
|
||||
public Set<ResourceIndexedSearchParamString> extractSearchParamStrings(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<ResourceIndexedSearchParamString> extractSearchParamStrings(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<ResourceIndexedSearchParamString> retVal = new HashSet<ResourceIndexedSearchParamString>();
|
||||
|
||||
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
|
||||
|
@ -418,7 +418,7 @@ public class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implemen
|
|||
* ca.uhn.fhir.model.api.IResource)
|
||||
*/
|
||||
@Override
|
||||
public Set<BaseResourceIndexedSearchParam> extractSearchParamTokens(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<BaseResourceIndexedSearchParam> extractSearchParamTokens(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<BaseResourceIndexedSearchParam> retVal = new HashSet<BaseResourceIndexedSearchParam>();
|
||||
|
||||
String useSystem = null;
|
||||
|
@ -576,7 +576,7 @@ public class SearchParamExtractorDstu2 extends BaseSearchParamExtractor implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<ResourceIndexedSearchParamUri> extractSearchParamUri(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<ResourceIndexedSearchParamUri> extractSearchParamUri(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<ResourceIndexedSearchParamUri> retVal = new HashSet<ResourceIndexedSearchParamUri>();
|
||||
|
||||
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
|
||||
|
|
|
@ -29,12 +29,33 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.measure.quantity.Quantity;
|
||||
import javax.measure.unit.NonSI;
|
||||
import javax.measure.unit.Unit;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.hl7.fhir.dstu21.model.Address;
|
||||
import org.hl7.fhir.dstu21.model.BaseDateTimeType;
|
||||
import org.hl7.fhir.dstu21.model.CodeableConcept;
|
||||
import org.hl7.fhir.dstu21.model.Coding;
|
||||
import org.hl7.fhir.dstu21.model.Conformance.ConformanceRestSecurityComponent;
|
||||
import org.hl7.fhir.dstu21.model.ContactPoint;
|
||||
import org.hl7.fhir.dstu21.model.Duration;
|
||||
import org.hl7.fhir.dstu21.model.Enumeration;
|
||||
import org.hl7.fhir.dstu21.model.HumanName;
|
||||
import org.hl7.fhir.dstu21.model.Identifier;
|
||||
import org.hl7.fhir.dstu21.model.IntegerType;
|
||||
import org.hl7.fhir.dstu21.model.Location.LocationPositionComponent;
|
||||
import org.hl7.fhir.dstu21.model.Patient.PatientCommunicationComponent;
|
||||
import org.hl7.fhir.dstu21.model.Period;
|
||||
import org.hl7.fhir.dstu21.model.Quantity;
|
||||
import org.hl7.fhir.dstu21.model.Questionnaire;
|
||||
import org.hl7.fhir.dstu21.model.StringType;
|
||||
import org.hl7.fhir.dstu21.model.UriType;
|
||||
import org.hl7.fhir.dstu21.model.ValueSet;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -49,33 +70,6 @@ import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString;
|
|||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamToken;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamUri;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
|
||||
import ca.uhn.fhir.model.base.composite.BaseHumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu21.composite.AddressDt;
|
||||
import ca.uhn.fhir.model.dstu21.composite.BoundCodeableConceptDt;
|
||||
import ca.uhn.fhir.model.dstu21.composite.CodeableConceptDt;
|
||||
import ca.uhn.fhir.model.dstu21.composite.CodingDt;
|
||||
import ca.uhn.fhir.model.dstu21.composite.ContactPointDt;
|
||||
import ca.uhn.fhir.model.dstu21.composite.DurationDt;
|
||||
import ca.uhn.fhir.model.dstu21.composite.HumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu21.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu21.composite.PeriodDt;
|
||||
import ca.uhn.fhir.model.dstu21.composite.QuantityDt;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Conformance.RestSecurity;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Location;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Patient.Communication;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Questionnaire;
|
||||
import ca.uhn.fhir.model.dstu21.resource.ValueSet;
|
||||
import ca.uhn.fhir.model.dstu21.valueset.RestfulSecurityServiceEnum;
|
||||
import ca.uhn.fhir.model.primitive.BaseDateTimeDt;
|
||||
import ca.uhn.fhir.model.primitive.BoundCodeDt;
|
||||
import ca.uhn.fhir.model.primitive.IntegerDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
|
||||
|
||||
public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor implements ISearchParamExtractor {
|
||||
|
@ -109,7 +103,7 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<ResourceIndexedSearchParamCoords> extractSearchParamCoords(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<ResourceIndexedSearchParamCoords> extractSearchParamCoords(ResourceTable theEntity, IBaseResource theResource) {
|
||||
// TODO: implement
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
@ -118,10 +112,10 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
* (non-Javadoc)
|
||||
*
|
||||
* @see ca.uhn.fhir.jpa.dao.ISearchParamExtractor#extractSearchParamDates(ca.uhn.fhir.jpa.entity.ResourceTable,
|
||||
* ca.uhn.fhir.model.api.IResource)
|
||||
* ca.uhn.fhir.model.api.IBaseResource)
|
||||
*/
|
||||
@Override
|
||||
public Set<ResourceIndexedSearchParamDate> extractSearchParamDates(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<ResourceIndexedSearchParamDate> extractSearchParamDates(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<ResourceIndexedSearchParamDate> retVal = new HashSet<ResourceIndexedSearchParamDate>();
|
||||
|
||||
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
|
||||
|
@ -146,14 +140,14 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
}
|
||||
|
||||
ResourceIndexedSearchParamDate nextEntity;
|
||||
if (nextObject instanceof BaseDateTimeDt) {
|
||||
BaseDateTimeDt nextValue = (BaseDateTimeDt) nextObject;
|
||||
if (nextObject instanceof BaseDateTimeType) {
|
||||
BaseDateTimeType nextValue = (BaseDateTimeType) nextObject;
|
||||
if (nextValue.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
nextEntity = new ResourceIndexedSearchParamDate(nextSpDef.getName(), nextValue.getValue(), nextValue.getValue());
|
||||
} else if (nextObject instanceof PeriodDt) {
|
||||
PeriodDt nextValue = (PeriodDt) nextObject;
|
||||
} else if (nextObject instanceof Period) {
|
||||
Period nextValue = (Period) nextObject;
|
||||
if (nextValue.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -179,10 +173,10 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
* (non-Javadoc)
|
||||
*
|
||||
* @see ca.uhn.fhir.jpa.dao.ISearchParamExtractor#extractSearchParamNumber(ca.uhn.fhir.jpa.entity.ResourceTable,
|
||||
* ca.uhn.fhir.model.api.IResource)
|
||||
* ca.uhn.fhir.model.api.IBaseResource)
|
||||
*/
|
||||
@Override
|
||||
public HashSet<ResourceIndexedSearchParamNumber> extractSearchParamNumber(ResourceTable theEntity, IResource theResource) {
|
||||
public HashSet<ResourceIndexedSearchParamNumber> extractSearchParamNumber(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<ResourceIndexedSearchParamNumber> retVal = new HashSet<ResourceIndexedSearchParamNumber>();
|
||||
|
||||
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
|
||||
|
@ -197,7 +191,7 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
}
|
||||
|
||||
for (Object nextObject : extractValues(nextPath, theResource)) {
|
||||
if (nextObject == null || ((IDatatype) nextObject).isEmpty()) {
|
||||
if (nextObject == null || ((IBase) nextObject).isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -207,19 +201,19 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
multiType = true;
|
||||
}
|
||||
|
||||
if (nextObject instanceof DurationDt) {
|
||||
DurationDt nextValue = (DurationDt) nextObject;
|
||||
if (nextObject instanceof Duration) {
|
||||
Duration nextValue = (Duration) nextObject;
|
||||
if (nextValue.getValueElement().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (new UriDt(BaseHapiFhirDao.UCUM_NS).equals(nextValue.getSystemElement())) {
|
||||
if (BaseHapiFhirDao.UCUM_NS.equals(nextValue.getSystem())) {
|
||||
if (isNotBlank(nextValue.getCode())) {
|
||||
|
||||
Unit<? extends Quantity> unit = Unit.valueOf(nextValue.getCode());
|
||||
Unit<? extends javax.measure.quantity.Quantity> unit = Unit.valueOf(nextValue.getCode());
|
||||
javax.measure.converter.UnitConverter dayConverter = unit.getConverterTo(NonSI.DAY);
|
||||
double dayValue = dayConverter.convert(nextValue.getValue().doubleValue());
|
||||
DurationDt newValue = new DurationDt();
|
||||
Duration newValue = new Duration();
|
||||
newValue.setSystem(BaseHapiFhirDao.UCUM_NS);
|
||||
newValue.setCode(NonSI.DAY.toString());
|
||||
newValue.setValue(dayValue);
|
||||
|
@ -234,8 +228,8 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
*
|
||||
* @SuppressWarnings("unchecked") PhysicsUnit<org.unitsofmeasurement.quantity.Time> timeUnit =
|
||||
* (PhysicsUnit<Time>) unit; UnitConverter conv = timeUnit.getConverterTo(UCUM.DAY); double
|
||||
* dayValue = conv.convert(nextValue.getValue().getValue().doubleValue()); DurationDt newValue =
|
||||
* new DurationDt(); newValue.setSystem(UCUM_NS); newValue.setCode(UCUM.DAY.getSymbol());
|
||||
* dayValue = conv.convert(nextValue.getValue().getValue().doubleValue()); Duration newValue =
|
||||
* new Duration(); newValue.setSystem(UCUM_NS); newValue.setCode(UCUM.DAY.getSymbol());
|
||||
* newValue.setValue(dayValue); nextValue=newValue; }
|
||||
*/
|
||||
}
|
||||
|
@ -244,8 +238,8 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
ResourceIndexedSearchParamNumber nextEntity = new ResourceIndexedSearchParamNumber(resourceName, nextValue.getValue());
|
||||
nextEntity.setResource(theEntity);
|
||||
retVal.add(nextEntity);
|
||||
} else if (nextObject instanceof QuantityDt) {
|
||||
QuantityDt nextValue = (QuantityDt) nextObject;
|
||||
} else if (nextObject instanceof Quantity) {
|
||||
Quantity nextValue = (Quantity) nextObject;
|
||||
if (nextValue.getValueElement().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -253,8 +247,8 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
ResourceIndexedSearchParamNumber nextEntity = new ResourceIndexedSearchParamNumber(resourceName, nextValue.getValue());
|
||||
nextEntity.setResource(theEntity);
|
||||
retVal.add(nextEntity);
|
||||
} else if (nextObject instanceof IntegerDt) {
|
||||
IntegerDt nextValue = (IntegerDt) nextObject;
|
||||
} else if (nextObject instanceof IntegerType) {
|
||||
IntegerType nextValue = (IntegerType) nextObject;
|
||||
if (nextValue.getValue() == null) {
|
||||
continue;
|
||||
}
|
||||
|
@ -279,10 +273,10 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
* (non-Javadoc)
|
||||
*
|
||||
* @see ca.uhn.fhir.jpa.dao.ISearchParamExtractor#extractSearchParamQuantity(ca.uhn.fhir.jpa.entity.ResourceTable,
|
||||
* ca.uhn.fhir.model.api.IResource)
|
||||
* ca.uhn.fhir.model.api.IBaseResource)
|
||||
*/
|
||||
@Override
|
||||
public Set<ResourceIndexedSearchParamQuantity> extractSearchParamQuantity(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<ResourceIndexedSearchParamQuantity> extractSearchParamQuantity(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<ResourceIndexedSearchParamQuantity> retVal = new HashSet<ResourceIndexedSearchParamQuantity>();
|
||||
|
||||
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
|
||||
|
@ -297,7 +291,7 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
}
|
||||
|
||||
for (Object nextObject : extractValues(nextPath, theResource)) {
|
||||
if (nextObject == null || ((IDatatype) nextObject).isEmpty()) {
|
||||
if (nextObject == null || ((IBase) nextObject).isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -307,8 +301,8 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
multiType = true;
|
||||
}
|
||||
|
||||
if (nextObject instanceof QuantityDt) {
|
||||
QuantityDt nextValue = (QuantityDt) nextObject;
|
||||
if (nextObject instanceof Quantity) {
|
||||
Quantity nextValue = (Quantity) nextObject;
|
||||
if (nextValue.getValueElement().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -333,10 +327,10 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
* (non-Javadoc)
|
||||
*
|
||||
* @see ca.uhn.fhir.jpa.dao.ISearchParamExtractor#extractSearchParamStrings(ca.uhn.fhir.jpa.entity.ResourceTable,
|
||||
* ca.uhn.fhir.model.api.IResource)
|
||||
* ca.uhn.fhir.model.api.IBaseResource)
|
||||
*/
|
||||
@Override
|
||||
public Set<ResourceIndexedSearchParamString> extractSearchParamStrings(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<ResourceIndexedSearchParamString> extractSearchParamStrings(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<ResourceIndexedSearchParamString> retVal = new HashSet<ResourceIndexedSearchParamString>();
|
||||
|
||||
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
|
||||
|
@ -361,7 +355,7 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
}
|
||||
|
||||
for (Object nextObject : extractValues(nextPath, theResource)) {
|
||||
if (nextObject == null || ((IDatatype) nextObject).isEmpty()) {
|
||||
if (nextObject == null || ((IBase) nextObject).isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -370,32 +364,32 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
multiType = true;
|
||||
}
|
||||
|
||||
if (nextObject instanceof IPrimitiveDatatype<?>) {
|
||||
IPrimitiveDatatype<?> nextValue = (IPrimitiveDatatype<?>) nextObject;
|
||||
if (nextObject instanceof IPrimitiveType<?>) {
|
||||
IPrimitiveType<?> nextValue = (IPrimitiveType<?>) nextObject;
|
||||
String searchTerm = nextValue.getValueAsString();
|
||||
addSearchTerm(theEntity, retVal, resourceName, searchTerm);
|
||||
} else {
|
||||
if (nextObject instanceof BaseHumanNameDt) {
|
||||
ArrayList<StringDt> allNames = new ArrayList<StringDt>();
|
||||
HumanNameDt nextHumanName = (HumanNameDt) nextObject;
|
||||
if (nextObject instanceof HumanName) {
|
||||
ArrayList<StringType> allNames = new ArrayList<StringType>();
|
||||
HumanName nextHumanName = (HumanName) nextObject;
|
||||
allNames.addAll(nextHumanName.getFamily());
|
||||
allNames.addAll(nextHumanName.getGiven());
|
||||
for (StringDt nextName : allNames) {
|
||||
for (StringType nextName : allNames) {
|
||||
addSearchTerm(theEntity, retVal, resourceName, nextName.getValue());
|
||||
}
|
||||
} else if (nextObject instanceof AddressDt) {
|
||||
ArrayList<StringDt> allNames = new ArrayList<StringDt>();
|
||||
AddressDt nextAddress = (AddressDt) nextObject;
|
||||
} else if (nextObject instanceof Address) {
|
||||
ArrayList<StringType> allNames = new ArrayList<StringType>();
|
||||
Address nextAddress = (Address) nextObject;
|
||||
allNames.addAll(nextAddress.getLine());
|
||||
allNames.add(nextAddress.getCityElement());
|
||||
allNames.add(nextAddress.getStateElement());
|
||||
allNames.add(nextAddress.getCountryElement());
|
||||
allNames.add(nextAddress.getPostalCodeElement());
|
||||
for (StringDt nextName : allNames) {
|
||||
for (StringType nextName : allNames) {
|
||||
addSearchTerm(theEntity, retVal, resourceName, nextName.getValue());
|
||||
}
|
||||
} else if (nextObject instanceof ContactPointDt) {
|
||||
ContactPointDt nextContact = (ContactPointDt) nextObject;
|
||||
} else if (nextObject instanceof ContactPoint) {
|
||||
ContactPoint nextContact = (ContactPoint) nextObject;
|
||||
if (nextContact.getValueElement().isEmpty() == false) {
|
||||
addSearchTerm(theEntity, retVal, resourceName, nextContact.getValue());
|
||||
}
|
||||
|
@ -415,10 +409,10 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
* (non-Javadoc)
|
||||
*
|
||||
* @see ca.uhn.fhir.jpa.dao.ISearchParamExtractor#extractSearchParamTokens(ca.uhn.fhir.jpa.entity.ResourceTable,
|
||||
* ca.uhn.fhir.model.api.IResource)
|
||||
* ca.uhn.fhir.model.api.IBaseResource)
|
||||
*/
|
||||
@Override
|
||||
public Set<BaseResourceIndexedSearchParam> extractSearchParamTokens(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<BaseResourceIndexedSearchParam> extractSearchParamTokens(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<BaseResourceIndexedSearchParam> retVal = new HashSet<BaseResourceIndexedSearchParam>();
|
||||
|
||||
String useSystem = null;
|
||||
|
@ -447,25 +441,25 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
List<String> codes = new ArrayList<String>();
|
||||
|
||||
String needContactPointSystem = null;
|
||||
if (nextPath.endsWith("(system=phone)")) {
|
||||
nextPath = nextPath.substring(0, nextPath.length() - "(system=phone)".length());
|
||||
if (nextPath.endsWith(".where(system='phone')")) {
|
||||
nextPath = nextPath.substring(0, nextPath.length() - ".where(system='phone')".length());
|
||||
needContactPointSystem = "phone";
|
||||
}
|
||||
if (nextPath.endsWith("(system=email)")) {
|
||||
nextPath = nextPath.substring(0, nextPath.length() - "(system=email)".length());
|
||||
if (nextPath.endsWith(".where(system='email')")) {
|
||||
nextPath = nextPath.substring(0, nextPath.length() - ".where(system='email')".length());
|
||||
needContactPointSystem = "email";
|
||||
}
|
||||
|
||||
for (Object nextObject : extractValues(nextPath, theResource)) {
|
||||
|
||||
// Patient:language
|
||||
if (nextObject instanceof Patient.Communication) {
|
||||
Communication nextValue = (Patient.Communication) nextObject;
|
||||
if (nextObject instanceof PatientCommunicationComponent) {
|
||||
PatientCommunicationComponent nextValue = (PatientCommunicationComponent) nextObject;
|
||||
nextObject = nextValue.getLanguage();
|
||||
}
|
||||
|
||||
if (nextObject instanceof IdentifierDt) {
|
||||
IdentifierDt nextValue = (IdentifierDt) nextObject;
|
||||
if (nextObject instanceof Identifier) {
|
||||
Identifier nextValue = (Identifier) nextObject;
|
||||
if (nextValue.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -480,8 +474,8 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
addStringParam(theEntity, retVal, nextSpDef, nextValue.getType().getText());
|
||||
}
|
||||
|
||||
} else if (nextObject instanceof ContactPointDt) {
|
||||
ContactPointDt nextValue = (ContactPointDt) nextObject;
|
||||
} else if (nextObject instanceof ContactPoint) {
|
||||
ContactPoint nextValue = (ContactPoint) nextObject;
|
||||
if (nextValue.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -492,16 +486,16 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
}
|
||||
systems.add(nextValue.getSystemElement().getValueAsString());
|
||||
codes.add(nextValue.getValueElement().getValue());
|
||||
} else if (nextObject instanceof BoundCodeDt) {
|
||||
BoundCodeDt<?> obj = (BoundCodeDt<?>) nextObject;
|
||||
} else if (nextObject instanceof Enumeration<?>) {
|
||||
Enumeration<?> obj = (Enumeration<?>) nextObject;
|
||||
String system = extractSystem(obj);
|
||||
String code = obj.getValue();
|
||||
String code = obj.getValueAsString();
|
||||
if (isNotBlank(code)) {
|
||||
systems.add(system);
|
||||
codes.add(code);
|
||||
}
|
||||
} else if (nextObject instanceof IPrimitiveDatatype<?>) {
|
||||
IPrimitiveDatatype<?> nextValue = (IPrimitiveDatatype<?>) nextObject;
|
||||
} else if (nextObject instanceof IPrimitiveType<?>) {
|
||||
IPrimitiveType<?> nextValue = (IPrimitiveType<?>) nextObject;
|
||||
if (nextValue.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -511,24 +505,24 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
systems.add(null);
|
||||
}
|
||||
codes.add(nextValue.getValueAsString());
|
||||
} else if (nextObject instanceof CodingDt) {
|
||||
CodingDt nextValue = (CodingDt) nextObject;
|
||||
} else if (nextObject instanceof Coding) {
|
||||
Coding nextValue = (Coding) nextObject;
|
||||
extractTokensFromCoding(systems, codes, theEntity, retVal, nextSpDef, nextValue);
|
||||
} else if (nextObject instanceof CodeableConceptDt) {
|
||||
CodeableConceptDt nextCC = (CodeableConceptDt) nextObject;
|
||||
} else if (nextObject instanceof CodeableConcept) {
|
||||
CodeableConcept nextCC = (CodeableConcept) nextObject;
|
||||
if (!nextCC.getTextElement().isEmpty()) {
|
||||
addStringParam(theEntity, retVal, nextSpDef, nextCC.getTextElement().getValue());
|
||||
}
|
||||
|
||||
extractTokensFromCodeableConcept(systems, codes, nextCC, theEntity, retVal, nextSpDef);
|
||||
} else if (nextObject instanceof RestSecurity) {
|
||||
} else if (nextObject instanceof ConformanceRestSecurityComponent) {
|
||||
// Conformance.security search param points to something kind of useless right now - This should probably
|
||||
// be fixed.
|
||||
RestSecurity sec = (RestSecurity) nextObject;
|
||||
for (BoundCodeableConceptDt<RestfulSecurityServiceEnum> nextCC : sec.getService()) {
|
||||
ConformanceRestSecurityComponent sec = (ConformanceRestSecurityComponent) nextObject;
|
||||
for (CodeableConcept nextCC : sec.getService()) {
|
||||
extractTokensFromCodeableConcept(systems, codes, nextCC, theEntity, retVal, nextSpDef);
|
||||
}
|
||||
} else if (nextObject instanceof Location.Position) {
|
||||
} else if (nextObject instanceof LocationPositionComponent) {
|
||||
ourLog.warn("Position search not currently supported, not indexing location");
|
||||
continue;
|
||||
} else {
|
||||
|
@ -576,7 +570,7 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<ResourceIndexedSearchParamUri> extractSearchParamUri(ResourceTable theEntity, IResource theResource) {
|
||||
public Set<ResourceIndexedSearchParamUri> extractSearchParamUri(ResourceTable theEntity, IBaseResource theResource) {
|
||||
HashSet<ResourceIndexedSearchParamUri> retVal = new HashSet<ResourceIndexedSearchParamUri>();
|
||||
|
||||
RuntimeResourceDefinition def = getContext().getResourceDefinition(theResource);
|
||||
|
@ -591,7 +585,7 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
}
|
||||
|
||||
for (Object nextObject : extractValues(nextPath, theResource)) {
|
||||
if (nextObject == null || ((IDatatype) nextObject).isEmpty()) {
|
||||
if (nextObject == null || ((IBase) nextObject).isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -601,8 +595,8 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
multiType = true;
|
||||
}
|
||||
|
||||
if (nextObject instanceof UriDt) {
|
||||
UriDt nextValue = (UriDt) nextObject;
|
||||
if (nextObject instanceof UriType) {
|
||||
UriType nextValue = (UriType) nextObject;
|
||||
if (isBlank(nextValue.getValue())) {
|
||||
continue;
|
||||
}
|
||||
|
@ -626,13 +620,13 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
return retVal;
|
||||
}
|
||||
|
||||
private void extractTokensFromCodeableConcept(List<String> theSystems, List<String> theCodes, CodeableConceptDt theCodeableConcept, ResourceTable theEntity, Set<BaseResourceIndexedSearchParam> theListToPopulate, RuntimeSearchParam theParameterDef) {
|
||||
for (CodingDt nextCoding : theCodeableConcept.getCoding()) {
|
||||
private void extractTokensFromCodeableConcept(List<String> theSystems, List<String> theCodes, CodeableConcept theCodeableConcept, ResourceTable theEntity, Set<BaseResourceIndexedSearchParam> theListToPopulate, RuntimeSearchParam theParameterDef) {
|
||||
for (Coding nextCoding : theCodeableConcept.getCoding()) {
|
||||
extractTokensFromCoding(theSystems, theCodes, theEntity, theListToPopulate, theParameterDef, nextCoding);
|
||||
}
|
||||
}
|
||||
|
||||
private void extractTokensFromCoding(List<String> theSystems, List<String> theCodes, ResourceTable theEntity, Set<BaseResourceIndexedSearchParam> theListToPopulate, RuntimeSearchParam theParameterDef, CodingDt nextCoding) {
|
||||
private void extractTokensFromCoding(List<String> theSystems, List<String> theCodes, ResourceTable theEntity, Set<BaseResourceIndexedSearchParam> theListToPopulate, RuntimeSearchParam theParameterDef, Coding nextCoding) {
|
||||
if (nextCoding != null && !nextCoding.isEmpty()) {
|
||||
|
||||
String nextSystem = nextCoding.getSystemElement().getValueAsString();
|
||||
|
@ -649,10 +643,9 @@ public class SearchParamExtractorDstu21 extends BaseSearchParamExtractor impleme
|
|||
}
|
||||
}
|
||||
|
||||
private static <T extends Enum<?>> String extractSystem(BoundCodeDt<T> theBoundCode) {
|
||||
if (theBoundCode.getValueAsEnum() != null) {
|
||||
IValueSetEnumBinder<T> binder = theBoundCode.getBinder();
|
||||
return binder.toSystemString(theBoundCode.getValueAsEnum());
|
||||
private static <T extends Enum<?>> String extractSystem(Enumeration<T> theBoundCode) {
|
||||
if (theBoundCode.getValue() != null) {
|
||||
return theBoundCode.getEnumFactory().toSystem(theBoundCode.getValue());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -24,15 +24,12 @@ import java.util.Date;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sourceforge.cobertura.CoverageIgnore;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.springframework.beans.factory.annotation.Required;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.TagList;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.annotation.GetTags;
|
||||
import ca.uhn.fhir.rest.annotation.History;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
|
@ -40,8 +37,9 @@ import ca.uhn.fhir.rest.annotation.Read;
|
|||
import ca.uhn.fhir.rest.annotation.Since;
|
||||
import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import net.sourceforge.cobertura.CoverageIgnore;
|
||||
|
||||
public abstract class BaseJpaResourceProvider<T extends IResource> extends BaseJpaProvider implements IResourceProvider {
|
||||
public abstract class BaseJpaResourceProvider<T extends IBaseResource> extends BaseJpaProvider implements IResourceProvider {
|
||||
|
||||
private IFhirResourceDao<T> myDao;
|
||||
|
||||
|
@ -59,7 +57,7 @@ public abstract class BaseJpaResourceProvider<T extends IResource> extends BaseJ
|
|||
}
|
||||
|
||||
@History
|
||||
public IBundleProvider getHistoryForResourceInstance(HttpServletRequest theRequest, @IdParam IdDt theId, @Since Date theDate) {
|
||||
public IBundleProvider getHistoryForResourceInstance(HttpServletRequest theRequest, @IdParam IIdType theId, @Since Date theDate) {
|
||||
startRequest(theRequest);
|
||||
try {
|
||||
return myDao.history(theId, theDate);
|
||||
|
@ -79,12 +77,12 @@ public abstract class BaseJpaResourceProvider<T extends IResource> extends BaseJ
|
|||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IResource> getResourceType() {
|
||||
public Class<? extends IBaseResource> getResourceType() {
|
||||
return myDao.getResourceType();
|
||||
}
|
||||
|
||||
@GetTags
|
||||
public TagList getTagsForResourceInstance(HttpServletRequest theRequest, @IdParam IdDt theResourceId) {
|
||||
public TagList getTagsForResourceInstance(HttpServletRequest theRequest, @IdParam IIdType theResourceId) {
|
||||
startRequest(theRequest);
|
||||
try {
|
||||
return myDao.getTags(theResourceId);
|
||||
|
@ -104,7 +102,7 @@ public abstract class BaseJpaResourceProvider<T extends IResource> extends BaseJ
|
|||
}
|
||||
|
||||
@Read(version = true)
|
||||
public T read(HttpServletRequest theRequest, @IdParam IdDt theId) {
|
||||
public T read(HttpServletRequest theRequest, @IdParam IIdType theId) {
|
||||
startRequest(theRequest);
|
||||
try {
|
||||
return myDao.read(theId);
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package ca.uhn.fhir.jpa.provider;
|
||||
|
||||
import org.hl7.fhir.dstu21.model.Encounter;
|
||||
import org.hl7.fhir.dstu21.model.IdType;
|
||||
import org.hl7.fhir.dstu21.model.UnsignedIntType;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
|
@ -22,7 +26,6 @@ package ca.uhn.fhir.jpa.provider;
|
|||
|
||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoEncounter;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Encounter;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
|
@ -43,11 +46,11 @@ public class BaseJpaResourceProviderEncounterDstu21 extends JpaResourceProviderD
|
|||
javax.servlet.http.HttpServletRequest theServletRequest,
|
||||
|
||||
@IdParam
|
||||
ca.uhn.fhir.model.primitive.IdDt theId,
|
||||
IdType theId,
|
||||
|
||||
@Description(formalDefinition="Results from this method are returned across multiple pages. This parameter controls the size of those pages.")
|
||||
@OperationParam(name = Constants.PARAM_COUNT)
|
||||
ca.uhn.fhir.model.primitive.UnsignedIntDt theCount,
|
||||
UnsignedIntType theCount,
|
||||
|
||||
@Description(shortDefinition="Only return resources which were last updated as specified by the given range")
|
||||
@OperationParam(name = Constants.PARAM_LASTUPDATED, min=0, max=1)
|
||||
|
@ -76,7 +79,7 @@ public class BaseJpaResourceProviderEncounterDstu21 extends JpaResourceProviderD
|
|||
|
||||
@Description(formalDefinition="Results from this method are returned across multiple pages. This parameter controls the size of those pages.")
|
||||
@OperationParam(name = Constants.PARAM_COUNT)
|
||||
ca.uhn.fhir.model.primitive.UnsignedIntDt theCount,
|
||||
UnsignedIntType theCount,
|
||||
|
||||
@Description(shortDefinition="Only return resources which were last updated as specified by the given range")
|
||||
@OperationParam(name = Constants.PARAM_LASTUPDATED, min=0, max=1)
|
||||
|
|
|
@ -4,6 +4,11 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.dstu21.model.IdType;
|
||||
import org.hl7.fhir.dstu21.model.Patient;
|
||||
import org.hl7.fhir.dstu21.model.StringType;
|
||||
import org.hl7.fhir.dstu21.model.UnsignedIntType;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR JPA Server
|
||||
|
@ -26,8 +31,6 @@ import java.util.List;
|
|||
|
||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoPatient;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
|
@ -51,11 +54,11 @@ public class BaseJpaResourceProviderPatientDstu21 extends JpaResourceProviderDst
|
|||
javax.servlet.http.HttpServletRequest theServletRequest,
|
||||
|
||||
@IdParam
|
||||
ca.uhn.fhir.model.primitive.IdDt theId,
|
||||
IdType theId,
|
||||
|
||||
@Description(formalDefinition="Results from this method are returned across multiple pages. This parameter controls the size of those pages.")
|
||||
@OperationParam(name = Constants.PARAM_COUNT)
|
||||
ca.uhn.fhir.model.primitive.UnsignedIntDt theCount,
|
||||
UnsignedIntType theCount,
|
||||
|
||||
@Description(shortDefinition="Only return resources which were last updated as specified by the given range")
|
||||
@OperationParam(name = Constants.PARAM_LASTUPDATED, min=0, max=1)
|
||||
|
@ -63,11 +66,11 @@ public class BaseJpaResourceProviderPatientDstu21 extends JpaResourceProviderDst
|
|||
|
||||
@Description(shortDefinition="Filter the resources to return only resources matching the given _content filter (note that this filter is applied only to results which link to the given patient, not to the patient itself or to supporting resources linked to by the matched resources)")
|
||||
@OperationParam(name = Constants.PARAM_CONTENT, min=0, max=OperationParam.MAX_UNLIMITED)
|
||||
List<StringDt> theContent,
|
||||
List<StringType> theContent,
|
||||
|
||||
@Description(shortDefinition="Filter the resources to return only resources matching the given _text filter (note that this filter is applied only to results which link to the given patient, not to the patient itself or to supporting resources linked to by the matched resources)")
|
||||
@OperationParam(name = Constants.PARAM_TEXT, min=0, max=OperationParam.MAX_UNLIMITED)
|
||||
List<StringDt> theNarrative,
|
||||
List<StringType> theNarrative,
|
||||
|
||||
@Sort
|
||||
SortSpec theSortSpec
|
||||
|
@ -93,7 +96,7 @@ public class BaseJpaResourceProviderPatientDstu21 extends JpaResourceProviderDst
|
|||
|
||||
@Description(formalDefinition="Results from this method are returned across multiple pages. This parameter controls the size of those pages.")
|
||||
@OperationParam(name = Constants.PARAM_COUNT)
|
||||
ca.uhn.fhir.model.primitive.UnsignedIntDt theCount,
|
||||
UnsignedIntType theCount,
|
||||
|
||||
@Description(shortDefinition="Only return resources which were last updated as specified by the given range")
|
||||
@OperationParam(name = Constants.PARAM_LASTUPDATED, min=0, max=1)
|
||||
|
@ -101,11 +104,11 @@ public class BaseJpaResourceProviderPatientDstu21 extends JpaResourceProviderDst
|
|||
|
||||
@Description(shortDefinition="Filter the resources to return only resources matching the given _content filter (note that this filter is applied only to results which link to the given patient, not to the patient itself or to supporting resources linked to by the matched resources)")
|
||||
@OperationParam(name = Constants.PARAM_CONTENT, min=0, max=OperationParam.MAX_UNLIMITED)
|
||||
List<StringDt> theContent,
|
||||
List<StringType> theContent,
|
||||
|
||||
@Description(shortDefinition="Filter the resources to return only resources matching the given _text filter (note that this filter is applied only to results which link to the given patient, not to the patient itself or to supporting resources linked to by the matched resources)")
|
||||
@OperationParam(name = Constants.PARAM_TEXT, min=0, max=OperationParam.MAX_UNLIMITED)
|
||||
List<StringDt> theNarrative,
|
||||
List<StringType> theNarrative,
|
||||
|
||||
@Sort
|
||||
SortSpec theSortSpec
|
||||
|
@ -121,10 +124,10 @@ public class BaseJpaResourceProviderPatientDstu21 extends JpaResourceProviderDst
|
|||
|
||||
}
|
||||
|
||||
private StringAndListParam toStringAndList(List<StringDt> theNarrative) {
|
||||
private StringAndListParam toStringAndList(List<StringType> theNarrative) {
|
||||
StringAndListParam retVal = new StringAndListParam();
|
||||
if (theNarrative != null) {
|
||||
for (StringDt next : theNarrative) {
|
||||
for (StringType next : theNarrative) {
|
||||
if (isNotBlank(next.getValue())) {
|
||||
retVal.addAnd(new StringOrListParam().addOr(new StringParam(next.getValue())));
|
||||
}
|
||||
|
|
|
@ -24,36 +24,35 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.hl7.fhir.dstu21.model.BooleanType;
|
||||
import org.hl7.fhir.dstu21.model.CodeType;
|
||||
import org.hl7.fhir.dstu21.model.CodeableConcept;
|
||||
import org.hl7.fhir.dstu21.model.Coding;
|
||||
import org.hl7.fhir.dstu21.model.IdType;
|
||||
import org.hl7.fhir.dstu21.model.Parameters;
|
||||
import org.hl7.fhir.dstu21.model.StringType;
|
||||
import org.hl7.fhir.dstu21.model.UriType;
|
||||
import org.hl7.fhir.dstu21.model.ValueSet;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet;
|
||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.LookupCodeResult;
|
||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult;
|
||||
import ca.uhn.fhir.model.dstu21.composite.CodeableConceptDt;
|
||||
import ca.uhn.fhir.model.dstu21.composite.CodingDt;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Parameters;
|
||||
import ca.uhn.fhir.model.dstu21.resource.ValueSet;
|
||||
import ca.uhn.fhir.model.primitive.BooleanDt;
|
||||
import ca.uhn.fhir.model.primitive.CodeDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
|
||||
public class BaseJpaResourceProviderValueSetDstu21 extends JpaResourceProviderDstu2<ValueSet> {
|
||||
public class BaseJpaResourceProviderValueSetDstu21 extends JpaResourceProviderDstu21<ValueSet> {
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name = "$expand", idempotent = true)
|
||||
public ValueSet expand(
|
||||
HttpServletRequest theServletRequest,
|
||||
@IdParam(optional=true) IdDt theId,
|
||||
@IdParam(optional=true) IdType theId,
|
||||
@OperationParam(name="valueSet", min=0, max=1) ValueSet theValueSet,
|
||||
@OperationParam(name="identifier", min=0, max=1) UriDt theIdentifier,
|
||||
@OperationParam(name = "filter", min=0, max=1) StringDt theFilter) {
|
||||
@OperationParam(name="identifier", min=0, max=1) UriType theIdentifier,
|
||||
@OperationParam(name = "filter", min=0, max=1) StringType theFilter) {
|
||||
//@formatter:on
|
||||
|
||||
boolean haveId = theId != null && theId.hasIdPart();
|
||||
|
@ -70,7 +69,7 @@ public class BaseJpaResourceProviderValueSetDstu21 extends JpaResourceProviderDs
|
|||
|
||||
startRequest(theServletRequest);
|
||||
try {
|
||||
IFhirResourceDaoValueSet<ValueSet, CodingDt, CodeableConceptDt> dao = (IFhirResourceDaoValueSet<ValueSet, CodingDt, CodeableConceptDt>) getDao();
|
||||
IFhirResourceDaoValueSet<ValueSet, Coding, CodeableConcept> dao = (IFhirResourceDaoValueSet<ValueSet, Coding, CodeableConcept>) getDao();
|
||||
if (haveId) {
|
||||
return dao.expand(theId, toFilterString(theFilter));
|
||||
} else if (haveIdentifier) {
|
||||
|
@ -100,39 +99,39 @@ public class BaseJpaResourceProviderValueSetDstu21 extends JpaResourceProviderDs
|
|||
}
|
||||
|
||||
|
||||
private String toFilterString(StringDt theFilter) {
|
||||
private String toFilterString(StringType theFilter) {
|
||||
return theFilter != null ? theFilter.getValue() : null;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name = "$lookup", idempotent = true, returnParameters= {
|
||||
@OperationParam(name="name", type=StringDt.class, min=1),
|
||||
@OperationParam(name="version", type=StringDt.class, min=0),
|
||||
@OperationParam(name="display", type=StringDt.class, min=1),
|
||||
@OperationParam(name="abstract", type=BooleanDt.class, min=1),
|
||||
@OperationParam(name="name", type=StringType.class, min=1),
|
||||
@OperationParam(name="version", type=StringType.class, min=0),
|
||||
@OperationParam(name="display", type=StringType.class, min=1),
|
||||
@OperationParam(name="abstract", type=BooleanType.class, min=1),
|
||||
})
|
||||
public Parameters lookup(
|
||||
HttpServletRequest theServletRequest,
|
||||
@OperationParam(name="code", min=0, max=1) CodeDt theCode,
|
||||
@OperationParam(name="system", min=0, max=1) UriDt theSystem,
|
||||
@OperationParam(name="coding", min=0, max=1) CodingDt theCoding
|
||||
@OperationParam(name="code", min=0, max=1) CodeType theCode,
|
||||
@OperationParam(name="system", min=0, max=1) UriType theSystem,
|
||||
@OperationParam(name="coding", min=0, max=1) Coding theCoding
|
||||
) {
|
||||
//@formatter:on
|
||||
|
||||
startRequest(theServletRequest);
|
||||
try {
|
||||
IFhirResourceDaoValueSet<ValueSet, CodingDt, CodeableConceptDt> dao = (IFhirResourceDaoValueSet<ValueSet, CodingDt, CodeableConceptDt>) getDao();
|
||||
IFhirResourceDaoValueSet<ValueSet, Coding, CodeableConcept> dao = (IFhirResourceDaoValueSet<ValueSet, Coding, CodeableConcept>) getDao();
|
||||
LookupCodeResult result = dao.lookupCode(theCode, theSystem, theCoding);
|
||||
if (result.isFound()==false) {
|
||||
throw new ResourceNotFoundException("Unable to find code[" + result.getSearchedForCode() + "] in system[" + result.getSearchedForSystem() + "]");
|
||||
}
|
||||
Parameters retVal = new Parameters();
|
||||
retVal.addParameter().setName("name").setValue(new StringDt(result.getCodeSystemDisplayName()));
|
||||
retVal.addParameter().setName("name").setValue(new StringType(result.getCodeSystemDisplayName()));
|
||||
if (isNotBlank(result.getCodeSystemVersion())) {
|
||||
retVal.addParameter().setName("version").setValue(new StringDt(result.getCodeSystemVersion()));
|
||||
retVal.addParameter().setName("version").setValue(new StringType(result.getCodeSystemVersion()));
|
||||
}
|
||||
retVal.addParameter().setName("display").setValue(new StringDt(result.getCodeDisplay()));
|
||||
retVal.addParameter().setName("abstract").setValue(new BooleanDt(result.isCodeIsAbstract()));
|
||||
retVal.addParameter().setName("display").setValue(new StringType(result.getCodeDisplay()));
|
||||
retVal.addParameter().setName("abstract").setValue(new BooleanType(result.isCodeIsAbstract()));
|
||||
return retVal;
|
||||
} finally {
|
||||
endRequest(theServletRequest);
|
||||
|
@ -142,33 +141,33 @@ public class BaseJpaResourceProviderValueSetDstu21 extends JpaResourceProviderDs
|
|||
|
||||
//@formatter:off
|
||||
@Operation(name = "$validate-code", idempotent = true, returnParameters= {
|
||||
@OperationParam(name="result", type=BooleanDt.class, min=1),
|
||||
@OperationParam(name="message", type=StringDt.class),
|
||||
@OperationParam(name="display", type=StringDt.class)
|
||||
@OperationParam(name="result", type=BooleanType.class, min=1),
|
||||
@OperationParam(name="message", type=StringType.class),
|
||||
@OperationParam(name="display", type=StringType.class)
|
||||
})
|
||||
public Parameters validateCode(
|
||||
HttpServletRequest theServletRequest,
|
||||
@IdParam(optional=true) IdDt theId,
|
||||
@OperationParam(name="identifier", min=0, max=1) UriDt theValueSetIdentifier,
|
||||
@OperationParam(name="code", min=0, max=1) CodeDt theCode,
|
||||
@OperationParam(name="system", min=0, max=1) UriDt theSystem,
|
||||
@OperationParam(name="display", min=0, max=1) StringDt theDisplay,
|
||||
@OperationParam(name="coding", min=0, max=1) CodingDt theCoding,
|
||||
@OperationParam(name="codeableConcept", min=0, max=1) CodeableConceptDt theCodeableConcept
|
||||
@IdParam(optional=true) IdType theId,
|
||||
@OperationParam(name="identifier", min=0, max=1) UriType theValueSetIdentifier,
|
||||
@OperationParam(name="code", min=0, max=1) CodeType theCode,
|
||||
@OperationParam(name="system", min=0, max=1) UriType theSystem,
|
||||
@OperationParam(name="display", min=0, max=1) StringType theDisplay,
|
||||
@OperationParam(name="coding", min=0, max=1) Coding theCoding,
|
||||
@OperationParam(name="codeableConcept", min=0, max=1) CodeableConcept theCodeableConcept
|
||||
) {
|
||||
//@formatter:on
|
||||
|
||||
startRequest(theServletRequest);
|
||||
try {
|
||||
IFhirResourceDaoValueSet<ValueSet, CodingDt, CodeableConceptDt> dao = (IFhirResourceDaoValueSet<ValueSet, CodingDt, CodeableConceptDt>) getDao();
|
||||
IFhirResourceDaoValueSet<ValueSet, Coding, CodeableConcept> dao = (IFhirResourceDaoValueSet<ValueSet, Coding, CodeableConcept>) getDao();
|
||||
ValidateCodeResult result = dao.validateCode(theValueSetIdentifier, theId, theCode, theSystem, theDisplay, theCoding, theCodeableConcept);
|
||||
Parameters retVal = new Parameters();
|
||||
retVal.addParameter().setName("result").setValue(new BooleanDt(result.isResult()));
|
||||
retVal.addParameter().setName("result").setValue(new BooleanType(result.isResult()));
|
||||
if (isNotBlank(result.getMessage())) {
|
||||
retVal.addParameter().setName("message").setValue(new StringDt(result.getMessage()));
|
||||
retVal.addParameter().setName("message").setValue(new StringType(result.getMessage()));
|
||||
}
|
||||
if (isNotBlank(result.getDisplay())) {
|
||||
retVal.addParameter().setName("display").setValue(new StringDt(result.getDisplay()));
|
||||
retVal.addParameter().setName("display").setValue(new StringType(result.getDisplay()));
|
||||
}
|
||||
return retVal;
|
||||
} finally {
|
||||
|
|
|
@ -25,34 +25,34 @@ import java.util.Map;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.hl7.fhir.dstu21.model.Bundle;
|
||||
import org.hl7.fhir.dstu21.model.CodeType;
|
||||
import org.hl7.fhir.dstu21.model.Conformance;
|
||||
import org.hl7.fhir.dstu21.model.Conformance.ConditionalDeleteStatus;
|
||||
import org.hl7.fhir.dstu21.model.Conformance.ConformanceRestComponent;
|
||||
import org.hl7.fhir.dstu21.model.Conformance.ConformanceRestResourceComponent;
|
||||
import org.hl7.fhir.dstu21.model.Conformance.ConformanceRestResourceSearchParamComponent;
|
||||
import org.hl7.fhir.dstu21.model.DecimalType;
|
||||
import org.hl7.fhir.dstu21.model.Enumerations.SearchParamType;
|
||||
import org.hl7.fhir.dstu21.model.Extension;
|
||||
import org.hl7.fhir.dstu21.model.Meta;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
|
||||
import ca.uhn.fhir.model.dstu21.composite.MetaDt;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Conformance;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Conformance.Rest;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Conformance.RestResource;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Conformance.RestResourceSearchParam;
|
||||
import ca.uhn.fhir.model.dstu21.valueset.ConditionalDeleteStatusEnum;
|
||||
import ca.uhn.fhir.model.dstu21.valueset.ResourceTypeEnum;
|
||||
import ca.uhn.fhir.model.dstu21.valueset.SearchParamTypeEnum;
|
||||
import ca.uhn.fhir.model.primitive.BoundCodeDt;
|
||||
import ca.uhn.fhir.model.primitive.DecimalDt;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.server.provider.dstu21.ServerConformanceProvider;
|
||||
import ca.uhn.fhir.util.ExtensionConstants;
|
||||
import net.sourceforge.cobertura.CoverageIgnore;
|
||||
|
||||
public class JpaConformanceProviderDstu21 extends ServerConformanceProvider {
|
||||
public class JpaConformanceProviderDstu21 extends org.hl7.fhir.dstu21.hapi.rest.server.ServerConformanceProvider {
|
||||
|
||||
private volatile Conformance myCachedValue;
|
||||
private DaoConfig myDaoConfig;
|
||||
private String myImplementationDescription;
|
||||
private RestfulServer myRestfulServer;
|
||||
private IFhirSystemDao<Bundle, MetaDt> mySystemDao;
|
||||
private IFhirSystemDao<Bundle, Meta> mySystemDao;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -66,7 +66,7 @@ public class JpaConformanceProviderDstu21 extends ServerConformanceProvider {
|
|||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public JpaConformanceProviderDstu21(RestfulServer theRestfulServer, IFhirSystemDao<Bundle, MetaDt> theSystemDao, DaoConfig theDaoConfig) {
|
||||
public JpaConformanceProviderDstu21(RestfulServer theRestfulServer, IFhirSystemDao<Bundle, Meta> theSystemDao, DaoConfig theDaoConfig) {
|
||||
super(theRestfulServer);
|
||||
myRestfulServer = theRestfulServer;
|
||||
mySystemDao = theSystemDao;
|
||||
|
@ -83,26 +83,26 @@ public class JpaConformanceProviderDstu21 extends ServerConformanceProvider {
|
|||
FhirContext ctx = myRestfulServer.getFhirContext();
|
||||
|
||||
retVal = super.getServerConformance(theRequest);
|
||||
for (Rest nextRest : retVal.getRest()) {
|
||||
for (ConformanceRestComponent nextRest : retVal.getRest()) {
|
||||
|
||||
for (RestResource nextResource : nextRest.getResource()) {
|
||||
for (ConformanceRestResourceComponent nextResource : nextRest.getResource()) {
|
||||
|
||||
ConditionalDeleteStatusEnum conditionalDelete = nextResource.getConditionalDeleteElement().getValueAsEnum();
|
||||
if (conditionalDelete == ConditionalDeleteStatusEnum.MULTIPLE_DELETES_SUPPORTED && myDaoConfig.isAllowMultipleDelete() == false) {
|
||||
nextResource.setConditionalDelete(ConditionalDeleteStatusEnum.SINGLE_DELETES_SUPPORTED);
|
||||
ConditionalDeleteStatus conditionalDelete = nextResource.getConditionalDelete();
|
||||
if (conditionalDelete == ConditionalDeleteStatus.MULTIPLE && myDaoConfig.isAllowMultipleDelete() == false) {
|
||||
nextResource.setConditionalDelete(ConditionalDeleteStatus.SINGLE);
|
||||
}
|
||||
|
||||
// Add resource counts
|
||||
Long count = counts.get(nextResource.getTypeElement().getValueAsString());
|
||||
if (count != null) {
|
||||
nextResource.addUndeclaredExtension(false, ExtensionConstants.CONF_RESOURCE_COUNT, new DecimalDt(count));
|
||||
nextResource.addExtension(new Extension(ExtensionConstants.CONF_RESOURCE_COUNT, new DecimalType(count)));
|
||||
}
|
||||
|
||||
// Add chained params
|
||||
for (RestResourceSearchParam nextParam : nextResource.getSearchParam()) {
|
||||
if (nextParam.getTypeElement().getValueAsEnum() == SearchParamTypeEnum.REFERENCE) {
|
||||
List<BoundCodeDt<ResourceTypeEnum>> targets = nextParam.getTarget();
|
||||
for (BoundCodeDt<ResourceTypeEnum> next : targets) {
|
||||
for (ConformanceRestResourceSearchParamComponent nextParam : nextResource.getSearchParam()) {
|
||||
if (nextParam.getType() == SearchParamType.REFERENCE) {
|
||||
List<CodeType> targets = nextParam.getTarget();
|
||||
for (CodeType next : targets) {
|
||||
RuntimeResourceDefinition def = ctx.getResourceDefinition(next.getValue());
|
||||
for (RuntimeSearchParam nextChainedParam : def.getSearchParams()) {
|
||||
nextParam.addChain(nextChainedParam.getName());
|
||||
|
@ -135,7 +135,7 @@ public class JpaConformanceProviderDstu21 extends ServerConformanceProvider {
|
|||
}
|
||||
|
||||
@CoverageIgnore
|
||||
public void setSystemDao(IFhirSystemDao<Bundle, MetaDt> mySystemDao) {
|
||||
public void setSystemDao(IFhirSystemDao<Bundle, Meta> mySystemDao) {
|
||||
this.mySystemDao = mySystemDao;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,11 +22,12 @@ package ca.uhn.fhir.jpa.provider;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.hl7.fhir.dstu21.model.IdType;
|
||||
import org.hl7.fhir.dstu21.model.Meta;
|
||||
import org.hl7.fhir.dstu21.model.Parameters;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu2.composite.MetaDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Parameters;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.annotation.ConditionalUrlParam;
|
||||
import ca.uhn.fhir.rest.annotation.Create;
|
||||
import ca.uhn.fhir.rest.annotation.Delete;
|
||||
|
@ -41,7 +42,7 @@ import ca.uhn.fhir.rest.api.ValidationModeEnum;
|
|||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
|
||||
public class JpaResourceProviderDstu21<T extends IResource> extends BaseJpaResourceProvider<T> {
|
||||
public class JpaResourceProviderDstu21<T extends IAnyResource> extends BaseJpaResourceProvider<T> {
|
||||
|
||||
public static final String OPERATION_NAME_META = "$meta";
|
||||
public static final String OPERATION_NAME_META_DELETE = "$meta-delete";
|
||||
|
@ -70,7 +71,7 @@ public class JpaResourceProviderDstu21<T extends IResource> extends BaseJpaResou
|
|||
}
|
||||
|
||||
@Delete()
|
||||
public MethodOutcome delete(HttpServletRequest theRequest, @IdParam IdDt theResource, @ConditionalUrlParam(supportsMultiple=true) String theConditional) {
|
||||
public MethodOutcome delete(HttpServletRequest theRequest, @IdParam IdType theResource, @ConditionalUrlParam(supportsMultiple=true) String theConditional) {
|
||||
startRequest(theRequest);
|
||||
try {
|
||||
if (theConditional != null) {
|
||||
|
@ -85,49 +86,49 @@ public class JpaResourceProviderDstu21<T extends IResource> extends BaseJpaResou
|
|||
|
||||
//@formatter:off
|
||||
@Operation(name=OPERATION_NAME_META, idempotent=true, returnParameters= {
|
||||
@OperationParam(name="return", type=MetaDt.class)
|
||||
@OperationParam(name="return", type=Meta.class)
|
||||
})
|
||||
//@formatter:on
|
||||
public Parameters meta() {
|
||||
Parameters parameters = new Parameters();
|
||||
MetaDt metaGetOperation = getDao().metaGetOperation(MetaDt.class);
|
||||
Meta metaGetOperation = getDao().metaGetOperation(Meta.class);
|
||||
parameters.addParameter().setName("return").setValue(metaGetOperation);
|
||||
return parameters;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name=OPERATION_NAME_META, idempotent=true, returnParameters= {
|
||||
@OperationParam(name="return", type=MetaDt.class)
|
||||
@OperationParam(name="return", type=Meta.class)
|
||||
})
|
||||
//@formatter:on
|
||||
public Parameters meta(@IdParam IdDt theId) {
|
||||
public Parameters meta(@IdParam IdType theId) {
|
||||
Parameters parameters = new Parameters();
|
||||
MetaDt metaGetOperation = getDao().metaGetOperation(MetaDt.class, theId);
|
||||
Meta metaGetOperation = getDao().metaGetOperation(Meta.class, theId);
|
||||
parameters.addParameter().setName("return").setValue(metaGetOperation);
|
||||
return parameters;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name=OPERATION_NAME_META_ADD, idempotent=true, returnParameters= {
|
||||
@OperationParam(name="return", type=MetaDt.class)
|
||||
@OperationParam(name="return", type=Meta.class)
|
||||
})
|
||||
//@formatter:on
|
||||
public Parameters metaAdd(@IdParam IdDt theId, @OperationParam(name = "meta") MetaDt theMeta) {
|
||||
public Parameters metaAdd(@IdParam IdType theId, @OperationParam(name = "meta") Meta theMeta) {
|
||||
if (theMeta == null) {
|
||||
throw new InvalidRequestException("Input contains no parameter with name 'meta'");
|
||||
}
|
||||
Parameters parameters = new Parameters();
|
||||
MetaDt metaAddOperation = getDao().metaAddOperation(theId, theMeta);
|
||||
Meta metaAddOperation = getDao().metaAddOperation(theId, theMeta);
|
||||
parameters.addParameter().setName("return").setValue(metaAddOperation);
|
||||
return parameters;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name=OPERATION_NAME_META_DELETE, idempotent=true, returnParameters= {
|
||||
@OperationParam(name="return", type=MetaDt.class)
|
||||
@OperationParam(name="return", type=Meta.class)
|
||||
})
|
||||
//@formatter:on
|
||||
public Parameters metaDelete(@IdParam IdDt theId, @OperationParam(name = "meta") MetaDt theMeta) {
|
||||
public Parameters metaDelete(@IdParam IdType theId, @OperationParam(name = "meta") Meta theMeta) {
|
||||
if (theMeta == null) {
|
||||
throw new InvalidRequestException("Input contains no parameter with name 'meta'");
|
||||
}
|
||||
|
@ -137,7 +138,7 @@ public class JpaResourceProviderDstu21<T extends IResource> extends BaseJpaResou
|
|||
}
|
||||
|
||||
@Update
|
||||
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam T theResource, @IdParam IdDt theId, @ConditionalUrlParam String theConditional) {
|
||||
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam T theResource, @IdParam IdType theId, @ConditionalUrlParam String theConditional) {
|
||||
startRequest(theRequest);
|
||||
try {
|
||||
if (theConditional != null) {
|
||||
|
@ -158,7 +159,7 @@ public class JpaResourceProviderDstu21<T extends IResource> extends BaseJpaResou
|
|||
}
|
||||
|
||||
@Validate
|
||||
public MethodOutcome validate(@ResourceParam T theResource, @IdParam IdDt theId, @ResourceParam String theRawResource, @ResourceParam EncodingEnum theEncoding, @Validate.Mode ValidationModeEnum theMode,
|
||||
public MethodOutcome validate(@ResourceParam T theResource, @IdParam IdType theId, @ResourceParam String theRawResource, @ResourceParam EncodingEnum theEncoding, @Validate.Mode ValidationModeEnum theMode,
|
||||
@Validate.Profile String theProfile) {
|
||||
return getDao().validate(theResource, theId, theRawResource, theEncoding, theMode, theProfile);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,13 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.hl7.fhir.dstu21.model.Bundle;
|
||||
import org.hl7.fhir.dstu21.model.DecimalType;
|
||||
import org.hl7.fhir.dstu21.model.IntegerType;
|
||||
import org.hl7.fhir.dstu21.model.Meta;
|
||||
import org.hl7.fhir.dstu21.model.Parameters;
|
||||
import org.hl7.fhir.dstu21.model.Parameters.ParametersParameterComponent;
|
||||
import org.hl7.fhir.dstu21.model.StringType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
||||
|
@ -35,13 +42,7 @@ import ca.uhn.fhir.jpa.dao.FhirSearchDao.Suggestion;
|
|||
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
|
||||
import ca.uhn.fhir.jpa.dao.ISearchDao;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.model.dstu21.composite.MetaDt;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Parameters;
|
||||
import ca.uhn.fhir.model.dstu21.resource.Parameters.Parameter;
|
||||
import ca.uhn.fhir.model.primitive.DecimalDt;
|
||||
import ca.uhn.fhir.model.primitive.IntegerDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
import ca.uhn.fhir.rest.annotation.Transaction;
|
||||
|
@ -50,11 +51,11 @@ import ca.uhn.fhir.rest.method.RequestDetails;
|
|||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
|
||||
public class JpaSystemProviderDstu21 extends BaseJpaSystemProvider<Bundle, MetaDt> {
|
||||
public class JpaSystemProviderDstu21 extends BaseJpaSystemProvider<Bundle, Meta> {
|
||||
|
||||
@Autowired()
|
||||
@Qualifier("mySystemDaoDstu21")
|
||||
private IFhirSystemDao<Bundle, MetaDt> mySystemDao;
|
||||
private IFhirSystemDao<Bundle, Meta> mySystemDao;
|
||||
|
||||
@Autowired
|
||||
private ISearchDao mySearchDao;
|
||||
|
@ -163,7 +164,7 @@ public class JpaSystemProviderDstu21 extends BaseJpaSystemProvider<Bundle, MetaD
|
|||
Map<String, Long> counts = mySystemDao.getResourceCounts();
|
||||
counts = new TreeMap<String, Long>(counts);
|
||||
for (Entry<String, Long> nextEntry : counts.entrySet()) {
|
||||
retVal.addParameter().setName(new StringDt(nextEntry.getKey())).setValue(new IntegerDt(nextEntry.getValue().intValue()));
|
||||
retVal.addParameter().setName((nextEntry.getKey())).setValue(new IntegerType(nextEntry.getValue().intValue()));
|
||||
}
|
||||
|
||||
return retVal;
|
||||
|
@ -178,13 +179,13 @@ public class JpaSystemProviderDstu21 extends BaseJpaSystemProvider<Bundle, MetaD
|
|||
int count = mySystemDao.markAllResourcesForReindexing();
|
||||
|
||||
Parameters retVal = new Parameters();
|
||||
retVal.addParameter().setName("count").setValue(new IntegerDt(count));
|
||||
retVal.addParameter().setName("count").setValue(new IntegerType(count));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//@formatter:off
|
||||
@Operation(name="$meta", idempotent=true, returnParameters= {
|
||||
@OperationParam(name="return", type=MetaDt.class)
|
||||
@OperationParam(name="return", type=Meta.class)
|
||||
})
|
||||
//@formatter:on
|
||||
public Parameters meta() {
|
||||
|
@ -216,8 +217,8 @@ public class JpaSystemProviderDstu21 extends BaseJpaSystemProvider<Bundle, MetaD
|
|||
for (Suggestion next : keywords) {
|
||||
//@formatter:off
|
||||
retVal.addParameter()
|
||||
.addPart(new Parameter().setName("keyword").setValue(new StringDt(next.getTerm())))
|
||||
.addPart(new Parameter().setName("score").setValue(new DecimalDt(next.getScore())));
|
||||
.addPart(new ParametersParameterComponent().setName("keyword").setValue(new StringType(next.getTerm())))
|
||||
.addPart(new ParametersParameterComponent().setName("score").setValue(new DecimalType(next.getScore())));
|
||||
//@formatter:on
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue